mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-03-13 17:10:06 +00:00
refactor: rename internal promptId/PromptId to jobId/JobId (#8730)
## Summary Rename all internal TypeScript usage of legacy `promptId`/`PromptId` naming to `jobId`/`JobId` across ~38 files for consistency with the domain model. ## Changes - **What**: Renamed internal variable names, type aliases, function names, class getters, interface fields, and comments from `promptId`/`PromptId` to `jobId`/`JobId`. Wire-protocol field names (`prompt_id` in Zod schemas and `e.detail.prompt_id` accesses) are intentionally preserved since they match the backend API contract. ## Review Focus - All changes are pure renames with no behavioral changes - Wire-protocol fields (`prompt_id`) are deliberately unchanged to maintain backend compatibility - Test fixtures updated to use consistent `job-id` naming ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-8730-refactor-rename-internal-promptId-PromptId-to-jobId-JobId-3016d73d3650813ca40ce337f7c5271a) by [Unito](https://www.unito.io)
This commit is contained in:
@@ -67,7 +67,7 @@ vi.mock('@/scripts/api', () => ({
|
||||
|
||||
describe('TaskItemImpl', () => {
|
||||
it('should remove animated property from outputs during construction', () => {
|
||||
const job = createHistoryJob(0, 'prompt-id')
|
||||
const job = createHistoryJob(0, 'job-id')
|
||||
const taskItem = new TaskItemImpl(job, {
|
||||
'node-1': {
|
||||
images: [{ filename: 'test.png', type: 'output', subfolder: '' }],
|
||||
@@ -83,7 +83,7 @@ describe('TaskItemImpl', () => {
|
||||
})
|
||||
|
||||
it('should handle outputs without animated property', () => {
|
||||
const job = createHistoryJob(0, 'prompt-id')
|
||||
const job = createHistoryJob(0, 'job-id')
|
||||
const taskItem = new TaskItemImpl(job, {
|
||||
'node-1': {
|
||||
images: [{ filename: 'test.png', type: 'output', subfolder: '' }]
|
||||
@@ -95,7 +95,7 @@ describe('TaskItemImpl', () => {
|
||||
})
|
||||
|
||||
it('should recognize webm video from core', () => {
|
||||
const job = createHistoryJob(0, 'prompt-id')
|
||||
const job = createHistoryJob(0, 'job-id')
|
||||
const taskItem = new TaskItemImpl(job, {
|
||||
'node-1': {
|
||||
video: [{ filename: 'test.webm', type: 'output', subfolder: '' }]
|
||||
@@ -112,7 +112,7 @@ describe('TaskItemImpl', () => {
|
||||
|
||||
// https://github.com/Kosinkadink/ComfyUI-VideoHelperSuite/blob/0a75c7958fe320efcb052f1d9f8451fd20c730a8/videohelpersuite/nodes.py#L578-L590
|
||||
it('should recognize webm video from VHS', () => {
|
||||
const job = createHistoryJob(0, 'prompt-id')
|
||||
const job = createHistoryJob(0, 'job-id')
|
||||
const taskItem = new TaskItemImpl(job, {
|
||||
'node-1': {
|
||||
gifs: [
|
||||
@@ -136,7 +136,7 @@ describe('TaskItemImpl', () => {
|
||||
})
|
||||
|
||||
it('should recognize mp4 video from core', () => {
|
||||
const job = createHistoryJob(0, 'prompt-id')
|
||||
const job = createHistoryJob(0, 'job-id')
|
||||
const taskItem = new TaskItemImpl(job, {
|
||||
'node-1': {
|
||||
images: [
|
||||
@@ -167,7 +167,7 @@ describe('TaskItemImpl', () => {
|
||||
|
||||
audioFormats.forEach(({ extension, mimeType }) => {
|
||||
it(`should recognize ${extension} audio`, () => {
|
||||
const job = createHistoryJob(0, 'prompt-id')
|
||||
const job = createHistoryJob(0, 'job-id')
|
||||
const taskItem = new TaskItemImpl(job, {
|
||||
'node-1': {
|
||||
audio: [
|
||||
@@ -193,14 +193,14 @@ describe('TaskItemImpl', () => {
|
||||
|
||||
describe('error extraction getters', () => {
|
||||
it('errorMessage returns undefined when no execution_error', () => {
|
||||
const job = createHistoryJob(0, 'prompt-id')
|
||||
const job = createHistoryJob(0, 'job-id')
|
||||
const taskItem = new TaskItemImpl(job)
|
||||
expect(taskItem.errorMessage).toBeUndefined()
|
||||
})
|
||||
|
||||
it('errorMessage returns the exception_message from execution_error', () => {
|
||||
const job: JobListItem = {
|
||||
...createHistoryJob(0, 'prompt-id'),
|
||||
...createHistoryJob(0, 'job-id'),
|
||||
status: 'failed',
|
||||
execution_error: {
|
||||
node_id: 'node-1',
|
||||
@@ -217,7 +217,7 @@ describe('TaskItemImpl', () => {
|
||||
})
|
||||
|
||||
it('executionError returns undefined when no execution_error', () => {
|
||||
const job = createHistoryJob(0, 'prompt-id')
|
||||
const job = createHistoryJob(0, 'job-id')
|
||||
const taskItem = new TaskItemImpl(job)
|
||||
expect(taskItem.executionError).toBeUndefined()
|
||||
})
|
||||
@@ -234,7 +234,7 @@ describe('TaskItemImpl', () => {
|
||||
current_outputs: {}
|
||||
}
|
||||
const job: JobListItem = {
|
||||
...createHistoryJob(0, 'prompt-id'),
|
||||
...createHistoryJob(0, 'job-id'),
|
||||
status: 'failed',
|
||||
execution_error: errorDetail
|
||||
}
|
||||
@@ -292,9 +292,9 @@ describe('useQueueStore', () => {
|
||||
|
||||
expect(store.runningTasks).toHaveLength(1)
|
||||
expect(store.pendingTasks).toHaveLength(2)
|
||||
expect(store.runningTasks[0].promptId).toBe('run-1')
|
||||
expect(store.pendingTasks[0].promptId).toBe('pend-2')
|
||||
expect(store.pendingTasks[1].promptId).toBe('pend-1')
|
||||
expect(store.runningTasks[0].jobId).toBe('run-1')
|
||||
expect(store.pendingTasks[0].jobId).toBe('pend-2')
|
||||
expect(store.pendingTasks[1].jobId).toBe('pend-1')
|
||||
})
|
||||
|
||||
it('should load history tasks from API', async () => {
|
||||
@@ -307,8 +307,8 @@ describe('useQueueStore', () => {
|
||||
await store.update()
|
||||
|
||||
expect(store.historyTasks).toHaveLength(2)
|
||||
expect(store.historyTasks[0].promptId).toBe('hist-1')
|
||||
expect(store.historyTasks[1].promptId).toBe('hist-2')
|
||||
expect(store.historyTasks[0].jobId).toBe('hist-1')
|
||||
expect(store.historyTasks[1].jobId).toBe('hist-2')
|
||||
})
|
||||
|
||||
it('should set loading state correctly', async () => {
|
||||
@@ -378,7 +378,7 @@ describe('useQueueStore', () => {
|
||||
|
||||
await store.update()
|
||||
expect(store.historyTasks).toHaveLength(1)
|
||||
expect(store.historyTasks[0].promptId).toBe('prompt-uuid-aaa')
|
||||
expect(store.historyTasks[0].jobId).toBe('prompt-uuid-aaa')
|
||||
|
||||
const hist2 = createHistoryJob(51, 'prompt-uuid-bbb')
|
||||
mockGetHistory.mockResolvedValue([hist2])
|
||||
@@ -386,7 +386,7 @@ describe('useQueueStore', () => {
|
||||
await store.update()
|
||||
|
||||
expect(store.historyTasks).toHaveLength(1)
|
||||
expect(store.historyTasks[0].promptId).toBe('prompt-uuid-bbb')
|
||||
expect(store.historyTasks[0].jobId).toBe('prompt-uuid-bbb')
|
||||
expect(store.historyTasks[0].queueIndex).toBe(51)
|
||||
})
|
||||
|
||||
@@ -406,10 +406,10 @@ describe('useQueueStore', () => {
|
||||
await store.update()
|
||||
|
||||
expect(store.historyTasks).toHaveLength(2)
|
||||
const promptIds = store.historyTasks.map((t) => t.promptId)
|
||||
expect(promptIds).toContain('second-prompt-at-101')
|
||||
expect(promptIds).toContain('prompt-at-99')
|
||||
expect(promptIds).not.toContain('first-prompt-at-100')
|
||||
const jobIds = store.historyTasks.map((t) => t.jobId)
|
||||
expect(jobIds).toContain('second-prompt-at-101')
|
||||
expect(jobIds).toContain('prompt-at-99')
|
||||
expect(jobIds).not.toContain('first-prompt-at-100')
|
||||
})
|
||||
|
||||
it('should handle multiple queueIndex collisions simultaneously', async () => {
|
||||
@@ -430,13 +430,13 @@ describe('useQueueStore', () => {
|
||||
await store.update()
|
||||
|
||||
expect(store.historyTasks).toHaveLength(3)
|
||||
const promptIds = store.historyTasks.map((t) => t.promptId)
|
||||
expect(promptIds).toEqual(['new-at-32', 'new-at-31', 'keep-at-30'])
|
||||
const jobIds = store.historyTasks.map((t) => t.jobId)
|
||||
expect(jobIds).toEqual(['new-at-32', 'new-at-31', 'keep-at-30'])
|
||||
})
|
||||
})
|
||||
|
||||
describe('update() - history reconciliation', () => {
|
||||
it('should keep existing items still on server (by promptId)', async () => {
|
||||
it('should keep existing items still on server (by jobId)', async () => {
|
||||
const hist1 = createHistoryJob(10, 'existing-1')
|
||||
const hist2 = createHistoryJob(9, 'existing-2')
|
||||
|
||||
@@ -452,9 +452,9 @@ describe('useQueueStore', () => {
|
||||
await store.update()
|
||||
|
||||
expect(store.historyTasks).toHaveLength(3)
|
||||
expect(store.historyTasks.map((t) => t.promptId)).toContain('existing-1')
|
||||
expect(store.historyTasks.map((t) => t.promptId)).toContain('existing-2')
|
||||
expect(store.historyTasks.map((t) => t.promptId)).toContain('new-1')
|
||||
expect(store.historyTasks.map((t) => t.jobId)).toContain('existing-1')
|
||||
expect(store.historyTasks.map((t) => t.jobId)).toContain('existing-2')
|
||||
expect(store.historyTasks.map((t) => t.jobId)).toContain('new-1')
|
||||
})
|
||||
|
||||
it('should remove items no longer on server', async () => {
|
||||
@@ -472,7 +472,7 @@ describe('useQueueStore', () => {
|
||||
await store.update()
|
||||
|
||||
expect(store.historyTasks).toHaveLength(1)
|
||||
expect(store.historyTasks[0].promptId).toBe('keep-me')
|
||||
expect(store.historyTasks[0].jobId).toBe('keep-me')
|
||||
})
|
||||
|
||||
it('should add new items from server', async () => {
|
||||
@@ -490,8 +490,8 @@ describe('useQueueStore', () => {
|
||||
await store.update()
|
||||
|
||||
expect(store.historyTasks).toHaveLength(3)
|
||||
expect(store.historyTasks.map((t) => t.promptId)).toContain('new-1')
|
||||
expect(store.historyTasks.map((t) => t.promptId)).toContain('new-2')
|
||||
expect(store.historyTasks.map((t) => t.jobId)).toContain('new-1')
|
||||
expect(store.historyTasks.map((t) => t.jobId)).toContain('new-2')
|
||||
})
|
||||
|
||||
it('should recreate TaskItemImpl when outputs_count changes', async () => {
|
||||
@@ -831,7 +831,7 @@ describe('useQueueStore', () => {
|
||||
await secondUpdate
|
||||
|
||||
expect(store.pendingTasks).toHaveLength(1)
|
||||
expect(store.pendingTasks[0].promptId).toBe('new-job')
|
||||
expect(store.pendingTasks[0].jobId).toBe('new-job')
|
||||
|
||||
resolveFirst!({
|
||||
Running: [],
|
||||
@@ -840,7 +840,7 @@ describe('useQueueStore', () => {
|
||||
await firstUpdate
|
||||
|
||||
expect(store.pendingTasks).toHaveLength(1)
|
||||
expect(store.pendingTasks[0].promptId).toBe('new-job')
|
||||
expect(store.pendingTasks[0].jobId).toBe('new-job')
|
||||
})
|
||||
|
||||
it('should set isLoading to false only for the latest request', async () => {
|
||||
@@ -897,13 +897,13 @@ describe('useQueueStore', () => {
|
||||
await secondUpdate
|
||||
|
||||
expect(store.pendingTasks).toHaveLength(1)
|
||||
expect(store.pendingTasks[0].promptId).toBe('new-job')
|
||||
expect(store.pendingTasks[0].jobId).toBe('new-job')
|
||||
expect(store.isLoading).toBe(false)
|
||||
|
||||
await expect(firstUpdate).rejects.toThrow('stale network error')
|
||||
|
||||
expect(store.pendingTasks).toHaveLength(1)
|
||||
expect(store.pendingTasks[0].promptId).toBe('new-job')
|
||||
expect(store.pendingTasks[0].jobId).toBe('new-job')
|
||||
expect(store.isLoading).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user