Fix dash status badges + Peak CPU column, default TUI workflows to newest-first#352
Merged
Conversation
The dash assumed `job.status` / `result.status` was an integer index into local `['Uninitialized', 'Blocked', ...]` arrays, but the API serves it as a snake_case string per the OpenAPI JobStatus enum (`#[serde(rename_all = "snake_case")]`). Symptoms: * Jobs table "Elapsed" column always rendered `-` because the `isRunning` check (`statusNames[job.status] === 'Running'`) compared `undefined` to `'Running'`. * Status badges visually fell back to the `status-unknown` CSS class and displayed the raw lowercase string (e.g. `running`) instead of the capitalized "Running" with the right colors. * DAG visualizer rendered every node in the gray default color because its integer-keyed `statusColors`/`statusNames` maps missed on every string status. Add `JOB_STATUS_NAMES` + `formatJobStatus()` + `jobStatusSlug()` helpers to `app-utils.js` (string-keyed, with an integer fallback for any legacy code path) and route all call sites through them. Rekey `DAGVisualizer.statusColors` and `statusNames` to snake_case strings. Also fix the results tab showing Avg CPU instead of Peak CPU: header column and value were `avg_cpu_percent` instead of `peak_cpu_percent` in both the main results table (`app-tables.js`) and the per-job results sub-tab (`app-job-details.js`). The CLI's `torc results list` already shows Peak CPU, so this aligns the surfaces. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The dash already sorts workflows by id descending so users see the most recent runs without scrolling; the TUI was inheriting whatever order the API returned, which is ascending by id. Switch the default `workflows_sort` to `IdDesc` so the two surfaces agree on the "newest first" convention. The sort is still user-controllable — pressing the ID column shortcut cycles Desc → Asc → unsorted as before. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes dashboard rendering regressions caused by the API switching JobStatus from legacy integers to snake_case strings, corrects a CPU column to show peak usage, and aligns the TUI workflow list default sort order with the dashboard (newest-first).
Changes:
- Add centralized JobStatus formatting + badge slug helpers and route status badge call sites through them; re-key DAG visualizer status maps to string statuses.
- Fix results tables to display Peak CPU % (header + value) using
peak_cpu_percent. - Default TUI workflows sort to
IdDesc(newest-first).
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
torc-dash/static/js/dag.js |
Re-keys DAG status color/name maps to snake_case string statuses. |
torc-dash/static/js/app-utils.js |
Adds JOB_STATUS_NAMES, JOB_STATUS_ORDER, formatJobStatus(), jobStatusSlug() helpers. |
torc-dash/static/js/app-tables.js |
Uses new status helpers in tables; switches results CPU column to peak. |
torc-dash/static/js/app-job-details.js |
Uses new status helpers; switches per-job results CPU column to peak. |
torc-dash/static/js/app-details.js |
Uses new status helpers; switches results CPU column to peak; updates status filtering/search text. |
torc-dash/static/js/app-debugging.js |
Uses new status helpers for debug job status display. |
src/tui/app.rs |
Changes default workflows sort to IdDesc (newest-first). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
* Route the jobs-table `isRunning` check through `jobStatusSlug()` so it gets the same legacy-integer fallback as the badge rendering. Without this, any future code path that handed us an integer status would silently regress the Elapsed column back to `-`. * Add a `.status-pending_failed` CSS rule mirroring `.status-failed`. `JOB_STATUS_NAMES` already lists `pending_failed` (it maps to `JobStatus::PendingFailed` server-side), so the helper was emitting a `status-pending_failed` class that had no matching stylesheet rule — pending_failed jobs would render with the unstyled base badge only. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two small bug fixes that came up after PR #351 landed.
Dash status indexing was broken everywhere
The dash assumed
job.status/result.statuswas an integer index into local['Uninitialized', 'Blocked', ...]arrays, but the API serves it as a snake_case string per the OpenAPIJobStatusenum (#[serde(rename_all = \"snake_case\")]). Symptoms:-because the `isRunning` check (statusNames[job.status] === 'Running') was comparingundefinedto'Running'.status-unknownand displayed the raw lowercase string (e.g.running) instead of the capitalized "Running" with the right colors.statusColors/statusNamesmaps missed on every string status.Added
JOB_STATUS_NAMES+formatJobStatus()+jobStatusSlug()helpers toapp-utils.js(string-keyed, with a defensive integer fallback) and routed all 8 badge call sites inapp-tables.js,app-details.js,app-job-details.js, andapp-debugging.jsthrough them. RekeyedDAGVisualizer.statusColorsandstatusNamesto snake_case strings.Results tab showed Avg CPU instead of Peak CPU
The CLI's
torc results listshows Peak CPU %, but the dash results tab was showing theavg_cpu_percentfield under an "Avg CPU %" header. Switched both the column header and the value topeak_cpu_percentin the main results table (app-tables.js) and the per-job results sub-tab (app-job-details.js).TUI workflows list now defaults to newest-first
The dash already sorts workflows by id descending so users see the most recent runs without scrolling; the TUI was inheriting whatever order the API returned (ascending by id). Switched the default
workflows_sorttoIdDescinsrc/tui/app.rsso the two surfaces agree.Sort is still user-controllable — the existing ID column shortcut cycles Desc → Asc → unsorted as before, just from a different starting point.
Test plan
🤖 Generated with Claude Code