Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions dashboard/web/jobs.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ <h1 x-show="selectedId">Job <span class="af-mono" x-text="selectedId.substring(0
<td class="af-mono" x-text="job.id.substring(0, 12) + '…'"></td>
<td class="af-mono af-truncate" x-text="jobCommand(job)"></td>
<td>
<span class="af-badge" :class="stateClass(job.state)" x-text="job.state"></span>
<span class="af-badge" :class="stateClass(job.state, job.output?.exit_code)" x-text="stateLabel(job.state, job.output?.exit_code)"></span>
</td>
<td x-text="afFormatTime(job.created_at)"></td>
<td x-text="afFormatTime(job.started_at)"></td>
Expand All @@ -109,7 +109,7 @@ <h1 x-show="selectedId">Job <span class="af-mono" x-text="selectedId.substring(0
<div>
<div class="af-item-header">
<div class="af-item-meta">
<span>State: <strong :class="stateClass(detailState)" x-text="detailState"></strong></span>
<span>State: <strong :class="stateClass(detailState, detailExitCode)" x-text="stateLabel(detailState, detailExitCode)"></strong></span>
<span>ID: <strong class="af-mono" x-text="selectedId"></strong></span>
<span>Created: <strong x-text="afFormatTime(detailCreated)"></strong></span>
<span x-show="detailStarted">Started: <strong x-text="afFormatTime(detailStarted)"></strong></span>
Expand Down Expand Up @@ -275,13 +275,18 @@ <h1 x-show="selectedId">Job <span class="af-mono" x-text="selectedId.substring(0
return 'command' in job ? job.command : (job.id || '');
},

stateClass(state) {
stateClass(state, exitCode) {
if (state === 'running') return 'af-prio af-prio-urgent';
if (state === 'queued') return 'af-prio af-prio-medium';
if (state === 'exited') return 'af-prio af-prio-low';
if (state === 'exited') return exitCode === 0 ? 'af-prio af-prio-low' : 'af-prio af-prio-urgent';
if (state === 'failed' || state === 'killed') return 'af-prio af-prio-urgent';
return '';
},

stateLabel(state, exitCode) {
if (state === 'exited') return exitCode === 0 ? 'done' : 'failed';
Comment on lines +281 to +287

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Handle missing exit codes before applying the failure mapping.

When output is missing, Line 96 can pass undefined, and detailExitCode can be null. Lines 281 and 287 then classify an exited job as urgent and failed. Reserve failed and urgent styling for nonzero numeric exit codes. Use an explicit neutral or unknown fallback for nullish values.

Suggested fix
-          if (state === 'exited') return exitCode === 0 ? 'af-prio af-prio-low' : 'af-prio af-prio-urgent';
+          if (state === 'exited') {
+            if (exitCode === null || exitCode === undefined) return 'af-prio af-prio-medium';
+            return exitCode === 0 ? 'af-prio af-prio-low' : 'af-prio af-prio-urgent';
+          }

-          if (state === 'exited') return exitCode === 0 ? 'done' : 'failed';
+          if (state === 'exited') {
+            if (exitCode === null || exitCode === undefined) return 'exited';
+            return exitCode === 0 ? 'done' : 'failed';
+          }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (state === 'exited') return exitCode === 0 ? 'af-prio af-prio-low' : 'af-prio af-prio-urgent';
if (state === 'failed' || state === 'killed') return 'af-prio af-prio-urgent';
return '';
},
stateLabel(state, exitCode) {
if (state === 'exited') return exitCode === 0 ? 'done' : 'failed';
if (state === 'exited') {
if (exitCode === null || exitCode === undefined) return 'af-prio af-prio-medium';
return exitCode === 0 ? 'af-prio af-prio-low' : 'af-prio af-prio-urgent';
}
if (state === 'failed' || state === 'killed') return 'af-prio af-prio-urgent';
return '';
},
stateLabel(state, exitCode) {
if (state === 'exited') {
if (exitCode === null || exitCode === undefined) return 'exited';
return exitCode === 0 ? 'done' : 'failed';
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@dashboard/web/jobs.html` around lines 281 - 287, Update the exited-state
handling in the priority mapper and stateLabel method to recognize only numeric,
nonzero exit codes as failures. For nullish or otherwise missing exitCode
values, return the existing neutral priority and an explicit unknown/neutral
label instead of urgent or failed; preserve the done mapping for numeric zero
and the existing failed/killed behavior.

return state;
},
};
}
</script>
Expand Down