Skip to content

Fix dash status badges + Peak CPU column, default TUI workflows to newest-first#352

Merged
daniel-thom merged 3 commits into
mainfrom
fix/dash-status-tui-sort
May 25, 2026
Merged

Fix dash status badges + Peak CPU column, default TUI workflows to newest-first#352
daniel-thom merged 3 commits into
mainfrom
fix/dash-status-tui-sort

Conversation

@daniel-thom
Copy link
Copy Markdown
Collaborator

Summary

Two small bug fixes that came up after PR #351 landed.

Dash status indexing was broken everywhere

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') was comparing undefined to 'Running'.
  • Status badges quietly fell back to status-unknown and displayed the raw lowercase string (e.g. running) instead of the capitalized "Running" with the right colors.
  • DAG visualizer rendered every node gray because its integer-keyed statusColors / statusNames maps missed on every string status.

Added JOB_STATUS_NAMES + formatJobStatus() + jobStatusSlug() helpers to app-utils.js (string-keyed, with a defensive integer fallback) and routed all 8 badge call sites in app-tables.js, app-details.js, app-job-details.js, and app-debugging.js through them. Rekeyed DAGVisualizer.statusColors and statusNames to snake_case strings.

Results tab showed Avg CPU instead of Peak CPU

The CLI's torc results list shows Peak CPU %, but the dash results tab was showing the avg_cpu_percent field under an "Avg CPU %" header. Switched both the column header and the value to peak_cpu_percent in 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_sort to IdDesc in src/tui/app.rs so 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

  • `cargo build --bin torc --features "client,tui,plot_resources"` — clean
  • `cargo nextest run --lib` — passes
  • Manual: open dash, confirm jobs table "Elapsed" shows time for running jobs (was always `-`)
  • Manual: confirm status badges show capitalized names with proper colors (Running blue, Completed green, etc.)
  • Manual: open the DAG view; nodes should be colored by status, not all gray
  • Manual: open results tab; header should say "Peak CPU %" and values should match `torc results list`
  • Manual: launch TUI; workflows list should show newest IDs at the top

🤖 Generated with Claude Code

daniel-thom and others added 2 commits May 25, 2026 14:37
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>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.

Comment thread torc-dash/static/js/app-tables.js Outdated
Comment thread torc-dash/static/js/app-utils.js
* 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>
@daniel-thom daniel-thom merged commit 3e7afa8 into main May 25, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants