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

@@ -339,7 +339,7 @@ describe('TopMenuSection', () => {
const pinia = createTestingPinia({ createSpy: vi.fn })
configureSettings(pinia, true)
const executionStore = useExecutionStore(pinia)
executionStore.activePromptId = 'prompt-1'
executionStore.activeJobId = 'job-1'
const ComfyActionbarStub = createComfyActionbarStub(actionbarTarget)
@@ -429,7 +429,7 @@ describe('TopMenuSection', () => {
const pinia = createTestingPinia({ createSpy: vi.fn })
configureSettings(pinia, true)
const executionStore = useExecutionStore(pinia)
executionStore.activePromptId = 'prompt-1'
executionStore.activeJobId = 'job-1'
const ComfyActionbarStub = createComfyActionbarStub(actionbarTarget)

View File

@@ -290,12 +290,12 @@ const showQueueContextMenu = (event: MouseEvent) => {
}
const handleClearQueue = async () => {
const pendingPromptIds = queueStore.pendingTasks
.map((task) => task.promptId)
const pendingJobIds = queueStore.pendingTasks
.map((task) => task.jobId)
.filter((id): id is string => typeof id === 'string' && id.length > 0)
await commandStore.execute('Comfy.ClearPendingTasks')
executionStore.clearInitializationByPromptIds(pendingPromptIds)
executionStore.clearInitializationByJobIds(pendingJobIds)
}
const openCustomNodeManager = async () => {

View File

@@ -204,22 +204,22 @@ const {
const displayedJobGroups = computed(() => groupedJobItems.value)
const onCancelItem = wrapWithErrorHandlingAsync(async (item: JobListItem) => {
const promptId = item.taskRef?.promptId
if (!promptId) return
const jobId = item.taskRef?.jobId
if (!jobId) return
if (item.state === 'running' || item.state === 'initialization') {
// Running/initializing jobs: interrupt execution
// Cloud backend uses deleteItem, local uses interrupt
if (isCloud) {
await api.deleteItem('queue', promptId)
await api.deleteItem('queue', jobId)
} else {
await api.interrupt(promptId)
await api.interrupt(jobId)
}
executionStore.clearInitializationByPromptId(promptId)
executionStore.clearInitializationByJobId(jobId)
await queueStore.update()
} else if (item.state === 'pending') {
// Pending jobs: remove from queue
await api.deleteItem('queue', promptId)
await api.deleteItem('queue', jobId)
await queueStore.update()
}
})
@@ -249,11 +249,11 @@ const openAssetsSidebar = () => {
const focusAssetInSidebar = async (item: JobListItem) => {
const task = item.taskRef
const promptId = task?.promptId
const jobId = task?.jobId
const preview = task?.previewOutput
if (!promptId || !preview) return
if (!jobId || !preview) return
const assetId = String(promptId)
const assetId = String(jobId)
openAssetsSidebar()
await nextTick()
await assetsStore.updateHistory()
@@ -275,37 +275,37 @@ const inspectJobAsset = wrapWithErrorHandlingAsync(
)
const cancelQueuedWorkflows = wrapWithErrorHandlingAsync(async () => {
// Capture pending promptIds before clearing
const pendingPromptIds = queueStore.pendingTasks
.map((task) => task.promptId)
// Capture pending jobIds before clearing
const pendingJobIds = queueStore.pendingTasks
.map((task) => task.jobId)
.filter((id): id is string => typeof id === 'string' && id.length > 0)
await commandStore.execute('Comfy.ClearPendingTasks')
// Clear initialization state for removed prompts
executionStore.clearInitializationByPromptIds(pendingPromptIds)
// Clear initialization state for removed jobs
executionStore.clearInitializationByJobIds(pendingJobIds)
})
const interruptAll = wrapWithErrorHandlingAsync(async () => {
const tasks = queueStore.runningTasks
const promptIds = tasks
.map((task) => task.promptId)
const jobIds = tasks
.map((task) => task.jobId)
.filter((id): id is string => typeof id === 'string' && id.length > 0)
if (!promptIds.length) return
if (!jobIds.length) return
// Cloud backend supports cancelling specific jobs via /queue delete,
// while /interrupt always targets the "first" job. Use the targeted API
// on cloud to ensure we cancel the workflow the user clicked.
if (isCloud) {
await Promise.all(promptIds.map((id) => api.deleteItem('queue', id)))
executionStore.clearInitializationByPromptIds(promptIds)
await Promise.all(jobIds.map((id) => api.deleteItem('queue', id)))
executionStore.clearInitializationByJobIds(jobIds)
await queueStore.update()
return
}
await Promise.all(promptIds.map((id) => api.interrupt(id)))
executionStore.clearInitializationByPromptIds(promptIds)
await Promise.all(jobIds.map((id) => api.interrupt(id)))
executionStore.clearInitializationByJobIds(jobIds)
await queueStore.update()
})

View File

@@ -37,7 +37,7 @@ function resetStores() {
queue.runningTasks = []
queue.historyTasks = []
exec.nodeProgressStatesByPrompt = {}
exec.nodeProgressStatesByJob = {}
}
function makeTask(
@@ -145,10 +145,10 @@ export const Queued: Story = {
makePendingTask('job-older-2', 101, Date.now() - 30_000)
)
// Queued at (in metadata on prompt[4])
// Queued at (in metadata on job tuple)
// One running workflow
exec.nodeProgressStatesByPrompt = {
exec.nodeProgressStatesByJob = {
p1: {
'1': {
value: 1,
@@ -198,7 +198,7 @@ export const QueuedParallel: Story = {
]
// Two parallel workflows running
exec.nodeProgressStatesByPrompt = {
exec.nodeProgressStatesByJob = {
p1: {
'1': {
value: 1,
@@ -248,7 +248,7 @@ export const Running: Story = {
makeHistoryTask('hist-r3', 252, 60, true)
]
exec.nodeProgressStatesByPrompt = {
exec.nodeProgressStatesByJob = {
p1: {
'1': {
value: 5,
@@ -293,7 +293,7 @@ export const QueuedZeroAheadSingleRunning: Story = {
queue.runningTasks = [makeRunningTaskWithStart('running-1', 505, 20)]
exec.nodeProgressStatesByPrompt = {
exec.nodeProgressStatesByJob = {
p1: {
'1': {
value: 1,
@@ -341,7 +341,7 @@ export const QueuedZeroAheadMultiRunning: Story = {
makeRunningTaskWithStart('running-b', 507, 10)
]
exec.nodeProgressStatesByPrompt = {
exec.nodeProgressStatesByJob = {
p1: {
'1': {
value: 2,

View File

@@ -139,7 +139,7 @@ const copyJobId = () => void copyToClipboard(jobIdValue.value)
const taskForJob = computed(() => {
const pid = props.jobId
const findIn = (arr: TaskItemImpl[]) =>
arr.find((t) => String(t.promptId ?? '') === String(pid))
arr.find((t) => String(t.jobId ?? '') === String(pid))
return (
findIn(queueStore.pendingTasks) ||
findIn(queueStore.runningTasks) ||
@@ -151,9 +151,7 @@ const taskForJob = computed(() => {
const jobState = computed(() => {
const task = taskForJob.value
if (!task) return null
const isInitializing = executionStore.isPromptInitializing(
String(task?.promptId)
)
const isInitializing = executionStore.isJobInitializing(String(task?.jobId))
return jobStateFromTask(task, isInitializing)
})

View File

@@ -8,13 +8,13 @@ import { useJobErrorReporting } from '@/components/queue/job/useJobErrorReportin
import type { ExecutionError } from '@/platform/remote/comfyui/jobs/jobTypes'
const createTaskWithError = (
promptId: string,
jobId: string,
errorMessage?: string,
executionError?: ExecutionError,
createTime?: number
): TaskItemImpl =>
({
promptId,
jobId,
errorMessage,
executionError,
createTime: createTime ?? Date.now()

View File

@@ -80,7 +80,7 @@ const sampleAssets: AssetItem[] = [
size: 1887437,
tags: [],
user_metadata: {
promptId: 'job-running-1',
jobId: 'job-running-1',
nodeId: 12,
executionTimeInSeconds: 1.84
}

View File

@@ -9,7 +9,7 @@
>
<div class="flex items-center gap-2">
<span class="font-bold">{{ $t('assetBrowser.jobId') }}:</span>
<span class="text-sm">{{ folderPromptId?.substring(0, 8) }}</span>
<span class="text-sm">{{ folderJobId?.substring(0, 8) }}</span>
<button
class="m-0 cursor-pointer border-0 bg-transparent p-0 outline-0"
role="button"
@@ -273,10 +273,10 @@ const executionStore = useExecutionStore()
const settingStore = useSettingStore()
const activeTab = ref<'input' | 'output'>('output')
const folderPromptId = ref<string | null>(null)
const folderJobId = ref<string | null>(null)
const folderExecutionTime = ref<number | undefined>(undefined)
const expectedFolderCount = ref(0)
const isInFolderView = computed(() => folderPromptId.value !== null)
const isInFolderView = computed(() => folderJobId.value !== null)
const viewMode = useStorage<'list' | 'grid'>(
'Comfy.Assets.Sidebar.ViewMode',
'grid'
@@ -559,13 +559,13 @@ const handleBulkDelete = async (assets: AssetItem[]) => {
}
const handleClearQueue = async () => {
const pendingPromptIds = queueStore.pendingTasks
.map((task) => task.promptId)
const pendingJobIds = queueStore.pendingTasks
.map((task) => task.jobId)
.filter((id): id is string => typeof id === 'string' && id.length > 0)
await commandStore.execute('Comfy.ClearPendingTasks')
executionStore.clearInitializationByPromptIds(pendingPromptIds)
executionStore.clearInitializationByJobIds(pendingJobIds)
}
const handleBulkAddToWorkflow = async (assets: AssetItem[]) => {
@@ -628,14 +628,14 @@ const enterFolderView = async (asset: AssetItem) => {
return
}
const { promptId, executionTimeInSeconds } = metadata
const { jobId, executionTimeInSeconds } = metadata
if (!promptId) {
if (!jobId) {
console.warn('Missing required folder view data')
return
}
folderPromptId.value = promptId
folderJobId.value = jobId
folderExecutionTime.value = executionTimeInSeconds
expectedFolderCount.value = metadata.outputCount ?? 0
@@ -653,7 +653,7 @@ const enterFolderView = async (asset: AssetItem) => {
}
const exitFolderView = () => {
folderPromptId.value = null
folderJobId.value = null
folderExecutionTime.value = undefined
expectedFolderCount.value = 0
folderAssets.value = []
@@ -679,9 +679,9 @@ const handleEmptySpaceClick = () => {
}
const copyJobId = async () => {
if (folderPromptId.value) {
if (folderJobId.value) {
try {
await navigator.clipboard.writeText(folderPromptId.value)
await navigator.clipboard.writeText(folderJobId.value)
toast.add({
severity: 'success',
summary: t('mediaAsset.jobIdToast.copied'),