Skip to content

Keep the dashboard running when a refresh fails - #440

Merged
tildesrc merged 1 commit into
mainfrom
panopticon/dashboard-survive-failed-refresh
Nov 4, 2026
Merged

tildesrc merged 1 commit into
mainfrom
panopticon/dashboard-survive-failed-refresh

Conversation

@tildesrc

Copy link
Copy Markdown
Contributor

Dashboard.action_refresh called list_tasks() / live_runners() with no error handling. It runs on the UI thread (first paint, r, Enter collapse, the snooze-display timer) and from the change-feed worker via call_from_thread, so any httpx failure from the task service — a 500, a ReadTimeout, a refused connection — exited the Textual app, killed the tmux pane and dropped panopticon start to the shell. Seen twice on 2026-10-22 while the service was stalled on database is locked. It also cleared the table before reading, so even a caught failure would have blanked it.

  • Read first, then draw. Both REST reads now happen before the table is touched. _refresh() catches httpx.HTTPError (status, timeout and transport errors; real bugs still surface) and returns whether it succeeded; action_refresh wraps it.
  • On failure: keep the last-drawn table, cursor and footer; show a "Task service unreachable — retrying…" warning once per outage (cleared by the next successful refresh).
  • Snooze timer: a failed repaint re-arms it on a fixed 5s retry, so countdown labels resume once the service is back.
  • Feed worker: when the marshalled rebuild fails it rewinds its version cursor (and backs off like its own poll errors), so the missed change is retried as soon as the service recovers rather than waiting for the next task change.

Tests in tests/terminal/test_dashboard.py make the fake client's list_tasks raise and cover the direct refresh (table kept, one warning), warn-once-per-outage, the snooze-timer path, and the feed-worker path including recovery.

Plan: task artifact plan.md.

🤖 Generated with Claude Code

action_refresh read the task list with no error handling, on the UI thread
(the snooze timer, `r`) and from the feed worker via call_from_thread, so a
500 / timeout / refused connection from the task service exited the app and
dropped the operator to the shell. It also cleared the table before reading.

Now the reads happen first; an httpx.HTTPError keeps the last-drawn table,
warns once per outage, re-arms the snooze timer, and the feed worker rewinds
its cursor so the missed change is retried once the service is back.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@tildesrc
tildesrc marked this pull request as ready for review November 4, 2026 04:05
@tildesrc
tildesrc merged commit 5c4a30c into main Nov 4, 2026
3 checks passed
tildesrc added a commit that referenced this pull request Nov 4, 2026
…r-row work, skip no-op writes

On a host with ~850 finished tasks and dozens of live agents, every change-feed tick made each
long-poller re-read and re-serialize the whole task list, and the dashboard fetched it twice and
rebuilt every row.

- GET /tasks takes `terminal_limit`: the N most recently updated finished task trees (a finished
  child of an active governor, and every member of a kept finished ensemble, always survive). The
  dashboard asks for the newest 50; `D` shows them all.
- The dashboard draws the snapshot its long-poll already returned instead of fetching again, and
  leaves the table alone when the rows it would draw are the ones on screen.
- The list endpoint resolves the artifact mark in one batched scan, memoised in the service (the
  artifact store's only writer), and composes container statuses in one pass over registrations.
- set_turn / set_blocked / report_lifecycle no longer save or bump the change feed when they
  restate the current value (the turn hooks fire on every prompt and stop).
- The host daemon's cleanup settles a finished task with no checkout and no claim of ours with a
  stat, not a `docker ps` fork per finished task per pass.
- Folded into #440's refresh error handling: `_refresh(tasks=None)` makes the reads (only
  the runner list when the long-poll or the snooze timer already holds the tasks) and keeps the
  last-drawn table on failure; `_render` draws.
- `panopticon request-mix [LOG]` tallies the service log: writes vs long-polls vs full reads.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tildesrc added a commit that referenced this pull request Nov 4, 2026
…r-row work, skip no-op writes (#441)

On a host with ~850 finished tasks and dozens of live agents, every change-feed tick made each
long-poller re-read and re-serialize the whole task list, and the dashboard fetched it twice and
rebuilt every row.

- GET /tasks takes `terminal_limit`: the N most recently updated finished task trees (a finished
  child of an active governor, and every member of a kept finished ensemble, always survive). The
  dashboard asks for the newest 50; `D` shows them all.
- The dashboard draws the snapshot its long-poll already returned instead of fetching again, and
  leaves the table alone when the rows it would draw are the ones on screen.
- The list endpoint resolves the artifact mark in one batched scan, memoised in the service (the
  artifact store's only writer), and composes container statuses in one pass over registrations.
- set_turn / set_blocked / report_lifecycle no longer save or bump the change feed when they
  restate the current value (the turn hooks fire on every prompt and stop).
- The host daemon's cleanup settles a finished task with no checkout and no claim of ours with a
  stat, not a `docker ps` fork per finished task per pass.
- Folded into #440's refresh error handling: `_refresh(tasks=None)` makes the reads (only
  the runner list when the long-poll or the snooze timer already holds the tasks) and keeps the
  last-drawn table on failure; `_render` draws.
- `panopticon request-mix [LOG]` tallies the service log: writes vs long-polls vs full reads.

Co-authored-by: Charlie Scherer <27368115+tildesrc@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant