diff --git a/browser_tests/fixtures/ComfyPage.ts b/browser_tests/fixtures/ComfyPage.ts index 2f51533ce..fe439af20 100644 --- a/browser_tests/fixtures/ComfyPage.ts +++ b/browser_tests/fixtures/ComfyPage.ts @@ -21,7 +21,6 @@ import { import { Topbar } from './components/Topbar' import type { Position, Size } from './types' import { NodeReference, SubgraphSlotReference } from './utils/litegraphUtils' -import TaskHistory from './utils/taskHistory' dotenv.config() @@ -146,8 +145,6 @@ class ConfirmDialog { } export class ComfyPage { - private _history: TaskHistory | null = null - public readonly url: string // All canvas position operations are based on default view of canvas. public readonly canvas: Locator @@ -301,11 +298,6 @@ export class ComfyPage { } } - setupHistory(): TaskHistory { - this._history ??= new TaskHistory(this) - return this._history - } - async setup({ clearStorage = true, mockReleases = true diff --git a/browser_tests/fixtures/utils/taskHistory.ts b/browser_tests/fixtures/utils/taskHistory.ts deleted file mode 100644 index 01dfb1a4a..000000000 --- a/browser_tests/fixtures/utils/taskHistory.ts +++ /dev/null @@ -1,164 +0,0 @@ -import type { Request, Route } from '@playwright/test' -import _ from 'es-toolkit/compat' -import fs from 'fs' -import path from 'path' -import { v4 as uuidv4 } from 'uuid' - -import type { - HistoryTaskItem, - TaskItem, - TaskOutput -} from '../../../src/schemas/apiSchema' -import type { ComfyPage } from '../ComfyPage' - -/** keyof TaskOutput[string] */ -type OutputFileType = 'images' | 'audio' | 'animated' - -const DEFAULT_IMAGE = 'example.webp' - -const getFilenameParam = (request: Request) => { - const url = new URL(request.url()) - return url.searchParams.get('filename') || DEFAULT_IMAGE -} - -const getContentType = (filename: string, fileType: OutputFileType) => { - const subtype = path.extname(filename).slice(1) - switch (fileType) { - case 'images': - return `image/${subtype}` - case 'audio': - return `audio/${subtype}` - case 'animated': - return `video/${subtype}` - } -} - -const setQueueIndex = (task: TaskItem) => { - task.prompt[0] = TaskHistory.queueIndex++ -} - -const setPromptId = (task: TaskItem) => { - task.prompt[1] = uuidv4() -} - -export default class TaskHistory { - static queueIndex = 0 - static readonly defaultTask: Readonly = { - prompt: [0, 'prompt-id', {}, { client_id: uuidv4() }, []], - outputs: {}, - status: { - status_str: 'success', - completed: true, - messages: [] - }, - taskType: 'History' - } - private tasks: HistoryTaskItem[] = [] - private outputContentTypes: Map = new Map() - - constructor(readonly comfyPage: ComfyPage) {} - - private loadAsset: (filename: string) => Buffer = _.memoize( - (filename: string) => { - const filePath = this.comfyPage.assetPath(filename) - return fs.readFileSync(filePath) - } - ) - - private async handleGetHistory(route: Route) { - return route.fulfill({ - status: 200, - contentType: 'application/json', - body: JSON.stringify(this.tasks) - }) - } - - private async handleGetView(route: Route) { - const fileName = getFilenameParam(route.request()) - if (!this.outputContentTypes.has(fileName)) { - return route.continue() - } - - const asset = this.loadAsset(fileName) - return route.fulfill({ - status: 200, - contentType: this.outputContentTypes.get(fileName), - body: asset, - headers: { - 'Cache-Control': 'public, max-age=31536000', - 'Content-Length': asset.byteLength.toString() - } - }) - } - - async setupRoutes() { - return this.comfyPage.page.route( - /.*\/api\/(view|history)(\?.*)?$/, - async (route) => { - const request = route.request() - const method = request.method() - - const isViewReq = request.url().includes('view') && method === 'GET' - if (isViewReq) return this.handleGetView(route) - - const isHistoryPath = request.url().includes('history') - const isGetHistoryReq = isHistoryPath && method === 'GET' - if (isGetHistoryReq) return this.handleGetHistory(route) - - const isClearReq = - method === 'POST' && - isHistoryPath && - request.postDataJSON()?.clear === true - if (isClearReq) return this.clearTasks() - - return route.continue() - } - ) - } - - private createOutputs( - filenames: string[], - filetype: OutputFileType - ): TaskOutput { - return filenames.reduce((outputs, filename, i) => { - const nodeId = `${i + 1}` - outputs[nodeId] = { - [filetype]: [{ filename, subfolder: '', type: 'output' }] - } - const contentType = getContentType(filename, filetype) - this.outputContentTypes.set(filename, contentType) - return outputs - }, {}) - } - - private addTask(task: HistoryTaskItem) { - setPromptId(task) - setQueueIndex(task) - this.tasks.unshift(task) // Tasks are added to the front of the queue - } - - clearTasks(): this { - this.tasks = [] - return this - } - - withTask( - outputFilenames: string[], - outputFiletype: OutputFileType = 'images', - overrides: Partial = {} - ): this { - this.addTask({ - ...TaskHistory.defaultTask, - outputs: this.createOutputs(outputFilenames, outputFiletype), - ...overrides - }) - return this - } - - /** Repeats the last task in the task history a specified number of times. */ - repeat(n: number): this { - for (let i = 0; i < n; i++) - this.addTask(structuredClone(this.tasks.at(0)) as HistoryTaskItem) - return this - } -} diff --git a/browser_tests/tests/mobileBaseline.spec.ts-snapshots/mobile-default-workflow-mobile-chrome-linux.png b/browser_tests/tests/mobileBaseline.spec.ts-snapshots/mobile-default-workflow-mobile-chrome-linux.png index b983d8214..c21094f81 100644 Binary files a/browser_tests/tests/mobileBaseline.spec.ts-snapshots/mobile-default-workflow-mobile-chrome-linux.png and b/browser_tests/tests/mobileBaseline.spec.ts-snapshots/mobile-default-workflow-mobile-chrome-linux.png differ diff --git a/browser_tests/tests/mobileBaseline.spec.ts-snapshots/mobile-empty-canvas-mobile-chrome-linux.png b/browser_tests/tests/mobileBaseline.spec.ts-snapshots/mobile-empty-canvas-mobile-chrome-linux.png index 886d3404c..1c9232428 100644 Binary files a/browser_tests/tests/mobileBaseline.spec.ts-snapshots/mobile-empty-canvas-mobile-chrome-linux.png and b/browser_tests/tests/mobileBaseline.spec.ts-snapshots/mobile-empty-canvas-mobile-chrome-linux.png differ diff --git a/browser_tests/tests/mobileBaseline.spec.ts-snapshots/mobile-settings-dialog-mobile-chrome-linux.png b/browser_tests/tests/mobileBaseline.spec.ts-snapshots/mobile-settings-dialog-mobile-chrome-linux.png index d6c21bb98..49c6536d4 100644 Binary files a/browser_tests/tests/mobileBaseline.spec.ts-snapshots/mobile-settings-dialog-mobile-chrome-linux.png and b/browser_tests/tests/mobileBaseline.spec.ts-snapshots/mobile-settings-dialog-mobile-chrome-linux.png differ diff --git a/browser_tests/tests/vueNodes/interactions/canvas/pan.spec.ts-snapshots/vue-nodes-paned-with-touch-mobile-chrome-linux.png b/browser_tests/tests/vueNodes/interactions/canvas/pan.spec.ts-snapshots/vue-nodes-paned-with-touch-mobile-chrome-linux.png index 7bfad824d..b509651cf 100644 Binary files a/browser_tests/tests/vueNodes/interactions/canvas/pan.spec.ts-snapshots/vue-nodes-paned-with-touch-mobile-chrome-linux.png and b/browser_tests/tests/vueNodes/interactions/canvas/pan.spec.ts-snapshots/vue-nodes-paned-with-touch-mobile-chrome-linux.png differ diff --git a/browser_tests/tests/vueNodes/interactions/node/move.spec.ts-snapshots/vue-node-moved-node-touch-mobile-chrome-linux.png b/browser_tests/tests/vueNodes/interactions/node/move.spec.ts-snapshots/vue-node-moved-node-touch-mobile-chrome-linux.png index 447238891..fc9e06620 100644 Binary files a/browser_tests/tests/vueNodes/interactions/node/move.spec.ts-snapshots/vue-node-moved-node-touch-mobile-chrome-linux.png and b/browser_tests/tests/vueNodes/interactions/node/move.spec.ts-snapshots/vue-node-moved-node-touch-mobile-chrome-linux.png differ diff --git a/browser_tests/tests/vueNodes/nodeStates/colors.spec.ts-snapshots/vue-node-custom-colors-light-all-colors-chromium-linux.png b/browser_tests/tests/vueNodes/nodeStates/colors.spec.ts-snapshots/vue-node-custom-colors-light-all-colors-chromium-linux.png index a7ebfdac8..64ae5e68b 100644 Binary files a/browser_tests/tests/vueNodes/nodeStates/colors.spec.ts-snapshots/vue-node-custom-colors-light-all-colors-chromium-linux.png and b/browser_tests/tests/vueNodes/nodeStates/colors.spec.ts-snapshots/vue-node-custom-colors-light-all-colors-chromium-linux.png differ diff --git a/package.json b/package.json index a2105ad9a..a4db1d77d 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@comfyorg/comfyui-frontend", "private": true, - "version": "1.38.2", + "version": "1.38.3", "type": "module", "repository": "https://github.com/Comfy-Org/ComfyUI_frontend", "homepage": "https://comfy.org", diff --git a/src/components/actionbar/ComfyActionbar.vue b/src/components/actionbar/ComfyActionbar.vue index 1d24e4838..5ea860852 100644 --- a/src/components/actionbar/ComfyActionbar.vue +++ b/src/components/actionbar/ComfyActionbar.vue @@ -1,5 +1,5 @@