address coderabbit comments, fix workflow id on popover

This commit is contained in:
Richard Yu
2025-12-04 14:01:15 -08:00
parent 2aa2be6d90
commit f556795663
5 changed files with 26 additions and 23 deletions

View File

@@ -92,16 +92,32 @@ function makeRunningTaskWithStart(
function makeHistoryTask(
id: string,
priority: number,
_durationSec: number,
durationSec: number,
ok: boolean,
errorMessage?: string
): TaskItemImpl {
const now = Date.now()
const executionEndTime = now
const executionStartTime = now - durationSec * 1000
return makeTask(id, priority, {
status: ok ? 'completed' : 'failed',
create_time: now,
create_time: executionStartTime - 5000,
update_time: now,
error_message: errorMessage
execution_start_time: executionStartTime,
execution_end_time: executionEndTime,
execution_error: errorMessage
? {
prompt_id: id,
timestamp: now,
node_id: '1',
node_type: 'ExampleNode',
exception_message: errorMessage,
exception_type: 'RuntimeError',
traceback: [],
current_inputs: {},
current_outputs: {}
}
: undefined
})
}

View File

@@ -12,7 +12,7 @@
v-for="ji in group.items"
:key="ji.id"
:job-id="ji.id"
:workflow-id="ji.taskRef?.workflow?.id"
:workflow-id="ji.taskRef?.workflowId"
:state="ji.state"
:title="ji.title"
:right-text="ji.meta"

View File

@@ -36,6 +36,8 @@ const zPreviewOutput = z
*/
const zExecutionError = z
.object({
prompt_id: z.string().optional(),
timestamp: z.number().optional(),
node_id: z.string(),
node_type: z.string(),
executed: z.array(z.string()).optional(),
@@ -61,20 +63,12 @@ const zRawJobListItem = z
execution_end_time: z.number().nullable().optional(),
preview_output: zPreviewOutput.nullable().optional(),
outputs_count: z.number().optional(),
error_message: z.string().nullable().optional(),
execution_error: zExecutionError.nullable().optional(),
workflow_id: z.string().nullable().optional(),
priority: z.number().optional()
})
.passthrough()
/**
* Job list item with priority always set (either from server or synthetic)
*/
const zJobListItem = zRawJobListItem.extend({
priority: z.number() // Always set: server-provided or synthetic (total - offset - index)
})
/**
* Job detail - returned by GET /api/jobs/{job_id} (detail endpoint)
* Includes full workflow and outputs for re-execution and downloads
@@ -117,5 +111,6 @@ export const zJobsListResponse = z
export type JobStatus = z.infer<typeof zJobStatus>
export type RawJobListItem = z.infer<typeof zRawJobListItem>
export type JobListItem = z.infer<typeof zJobListItem>
/** Job list item with priority always set (server-provided or synthetic) */
export type JobListItem = RawJobListItem & { priority: number }
export type JobDetail = z.infer<typeof zJobDetail>

View File

@@ -308,7 +308,7 @@ export class TaskItemImpl {
* Error message if job failed
*/
get errorMessage(): string | undefined {
return this.job.error_message ?? undefined
return this.job.execution_error?.exception_message ?? undefined
}
/**
@@ -484,15 +484,6 @@ export class TaskItemImpl {
public toJob(): JobListItem {
return this.job
}
/**
* Cancel this task (for queue items)
*/
public async cancel(): Promise<void> {
if (this.taskType === 'Running' || this.taskType === 'Pending') {
await api.interrupt(this.job.id)
}
}
}
export const useQueueStore = defineStore('queue', () => {

View File

@@ -154,6 +154,7 @@ describe('useResultGallery', () => {
const loadedTask = new TaskItemImpl(job, {}, fullOutputs)
task.loadFullOutputs = async () => loadedTask
// fetchApi presence triggers lazy loading when outputsCount > 1
const mockFetchApi = async () => new Response()
const { galleryItems, galleryActiveIndex, onViewItem } = useResultGallery(