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:
Christian Byrne
2026-02-20 02:10:53 -08:00
committed by GitHub
parent 541ad387b9
commit 473713cf02
39 changed files with 455 additions and 402 deletions

View File

@@ -21,7 +21,7 @@ const mockWorkflow: ComfyWorkflowJSON = {
// Jobs API detail response structure (matches actual /jobs/{id} response)
// workflow is nested at: workflow.extra_data.extra_pnginfo.workflow
const mockJobDetailResponse: JobDetail = {
id: 'test-prompt-id',
id: 'test-job-id',
status: 'completed',
create_time: 1234567890,
update_time: 1234567900,
@@ -43,15 +43,15 @@ const mockJobDetailResponse: JobDetail = {
}
describe('fetchJobDetail', () => {
it('should fetch job detail from /jobs/{prompt_id} endpoint', async () => {
it('should fetch job detail from /jobs/{job_id} endpoint', async () => {
const mockFetchApi = vi.fn().mockResolvedValue({
ok: true,
json: async () => mockJobDetailResponse
})
await fetchJobDetail(mockFetchApi, 'test-prompt-id')
await fetchJobDetail(mockFetchApi, 'test-job-id')
expect(mockFetchApi).toHaveBeenCalledWith('/jobs/test-prompt-id')
expect(mockFetchApi).toHaveBeenCalledWith('/jobs/test-job-id')
})
it('should return job detail with workflow and outputs', async () => {
@@ -60,10 +60,10 @@ describe('fetchJobDetail', () => {
json: async () => mockJobDetailResponse
})
const result = await fetchJobDetail(mockFetchApi, 'test-prompt-id')
const result = await fetchJobDetail(mockFetchApi, 'test-job-id')
expect(result).toBeDefined()
expect(result?.id).toBe('test-prompt-id')
expect(result?.id).toBe('test-job-id')
expect(result?.outputs).toEqual(mockJobDetailResponse.outputs)
expect(result?.workflow).toBeDefined()
})
@@ -82,7 +82,7 @@ describe('fetchJobDetail', () => {
it('should handle fetch errors gracefully', async () => {
const mockFetchApi = vi.fn().mockRejectedValue(new Error('Network error'))
const result = await fetchJobDetail(mockFetchApi, 'test-prompt-id')
const result = await fetchJobDetail(mockFetchApi, 'test-job-id')
expect(result).toBeUndefined()
})
@@ -95,7 +95,7 @@ describe('fetchJobDetail', () => {
}
})
const result = await fetchJobDetail(mockFetchApi, 'test-prompt-id')
const result = await fetchJobDetail(mockFetchApi, 'test-job-id')
expect(result).toBeUndefined()
})

View File

@@ -19,7 +19,7 @@ import { getJobWorkflow } from '@/services/jobOutputCache'
* @returns WorkflowSource with workflow and generated filename
*
* @example
* const asset = { name: 'output.png', user_metadata: { promptId: '123' } }
* const asset = { name: 'output.png', user_metadata: { jobId: '123' } }
* const { workflow, filename } = await extractWorkflowFromAsset(asset)
*/
export async function extractWorkflowFromAsset(asset: AssetItem): Promise<{
@@ -30,8 +30,8 @@ export async function extractWorkflowFromAsset(asset: AssetItem): Promise<{
// For output assets: use jobs API (with caching and validation)
const metadata = getOutputAssetMetadata(asset.user_metadata)
if (metadata?.promptId) {
const workflow = await getJobWorkflow(metadata.promptId)
if (metadata?.jobId) {
const workflow = await getJobWorkflow(metadata.jobId)
return { workflow: workflow ?? null, filename: baseFilename }
}