Show when the dashboard is working, and log slow answers #201

Merged
aluminum-ice merged 1 commit from dashboard-busy-indicator into main 2026-11-17 10:46:59 +00:00
Owner

What this PR does

Makes the dashboard show that it's working, and stops the auto-refresh from cancelling a tap:

  • A "working" indicator on every page (_BUSY_HTML/_BUSY_JS, added by _page()). A tap on a link to another dashboard page, or a form sent, marks the page busy at once. If the answer takes more than 150 ms, a bar slides across the top with a Working… label, which is also announced through a role=status region, so the cue isn't colour or motion alone. Under reduced motion the bar stays still. While busy, a second send of a form is dropped, so a double tap can't apply a change twice. Buttons aren't disabled, because a disabled button's value drops out of the form (the capture switch's action). Downloads (<a download>), new tabs, links off the device, jumps within the page, modified or middle clicks and gestures a page script already handled (the map's drag) are left alone. It clears when the page is shown again (the back button), and after a minute in any case. Without scripts the pages work as before.
  • The auto-refresh waits for a tap. The dashboard's 30 s reload and the agent page's start-up reload now skip a turn while a tap is loading (_BUSY_TEST). Before, a reload that landed while a tapped page was loading replaced it, so the tap seemed to be ignored.
  • Slow answers are logged. The app is wrapped to log web: slow response: METHOD ROUTE took N s for anything that took SLOW_RESPONSE_SECONDS (2 s) or more, up to the body being ready, with the sign-in check included. The route is the rule's pattern (a plugin page with its plugin's name), never the URL, whose query can carry a login token.
  • Beta check item 1.6, kept in every beta. Section 1 of each checklist now ends with the dashboard's response times. The device script counts this boot's slow-response lines per route (method, route pattern, count, slowest time). It reports PASS with none and INFO with the list otherwise, and SKIP on a daemon that doesn't log them yet. CLAUDE.md ("Verifying a beta") and tools/beta-check/README.md ("Checks every beta keeps") make it a standing item. The shared pkg_dir/pkg_has helpers moved above section 1 so it can use them.
  • Deferred: answering the capture switch at once instead of holding the page for the helper and the service to settle. It's in deferred.md, to be picked up once item 1.6 shows POST /capture among the slow ones.

Checklist

  • Lint passes: the real-data check and bash -n pass locally; shellcheck and the ansible/yamllint steps aren't installed here, so the Lint workflow is the check.
  • Tests pass: 1819 passed. The only failures are the 5 test_web.py potfile-import tests that also fail locally on main (werkzeug version); CI runs the full suite. The new tests run the indicator script under node with a small stand-in DOM (a slow load shows it, a download or new tab doesn't, a second form send is dropped, the back button clears it) and skip where node isn't installed. They also cover the refresh guard and the slow-response log (route not URL, a token never logged, a quick answer not logged). Three older tests that counted <script> tags now discount the shell's script.
  • Nothing real: the beta check's 1.6 output is a method, a route pattern from the code, a count and a time. Its parser was run off the device against invented log lines, and a URL with a query string doesn't match it.
  • Consent gates intact: no change to capture, plugins or the acknowledgment. The indicator only marks the page and drops a repeated form send.
  • Docs updated in the same PR: GUIDE_MD (the dashboard section), docs/developer/web-ui-conventions.md (the indicator, the refresh rule, the slow log, a checklist line), docs/developer/deferred.md, tools/beta-check/README.md, CLAUDE.md.
  • Commit messages are short and imperative.

Release impact

  • App-layer-safe: only the kestrel_pi package (web.py, userguide.py) ships. The beta-check scripts and docs aren't shipped.
  • Reflash-class

Notes for review

  • No new screenshot: the bar is hidden until a tap waits, so no guide figure changes.
  • For the next beta's checklist: a by-hand item (tap a slow control such as the capture switch; the bar and Working… appear; a second tap doesn't apply the change twice), plus 1.6 in section 1. Item 1.6 reads SKIP on a device still running beta.5 or earlier.

🤖 Generated with Claude Code

## What this PR does Makes the dashboard show that it's working, and stops the auto-refresh from cancelling a tap: - **A "working" indicator on every page** (`_BUSY_HTML`/`_BUSY_JS`, added by `_page()`). A tap on a link to another dashboard page, or a form sent, marks the page busy at once. If the answer takes more than 150 ms, a bar slides across the top with a **Working…** label, which is also announced through a `role=status` region, so the cue isn't colour or motion alone. Under reduced motion the bar stays still. While busy, a second send of a form is dropped, so a double tap can't apply a change twice. Buttons aren't disabled, because a disabled button's value drops out of the form (the capture switch's `action`). Downloads (`<a download>`), new tabs, links off the device, jumps within the page, modified or middle clicks and gestures a page script already handled (the map's drag) are left alone. It clears when the page is shown again (the back button), and after a minute in any case. Without scripts the pages work as before. - **The auto-refresh waits for a tap.** The dashboard's 30 s reload and the agent page's start-up reload now skip a turn while a tap is loading (`_BUSY_TEST`). Before, a reload that landed while a tapped page was loading replaced it, so the tap seemed to be ignored. - **Slow answers are logged.** The app is wrapped to log `web: slow response: METHOD ROUTE took N s` for anything that took `SLOW_RESPONSE_SECONDS` (2 s) or more, up to the body being ready, with the sign-in check included. The route is the rule's pattern (a plugin page with its plugin's name), never the URL, whose query can carry a login token. - **Beta check item 1.6, kept in every beta.** Section 1 of each checklist now ends with the dashboard's response times. The device script counts this boot's slow-response lines per route (method, route pattern, count, slowest time). It reports `PASS` with none and `INFO` with the list otherwise, and `SKIP` on a daemon that doesn't log them yet. CLAUDE.md ("Verifying a beta") and `tools/beta-check/README.md` ("Checks every beta keeps") make it a standing item. The shared `pkg_dir`/`pkg_has` helpers moved above section 1 so it can use them. - **Deferred:** answering the capture switch at once instead of holding the page for the helper and the service to settle. It's in `deferred.md`, to be picked up once item 1.6 shows `POST /capture` among the slow ones. ## Checklist - [ ] **Lint passes**: the real-data check and `bash -n` pass locally; shellcheck and the ansible/yamllint steps aren't installed here, so the **Lint** workflow is the check. - [x] **Tests pass**: 1819 passed. The only failures are the 5 `test_web.py` potfile-import tests that also fail locally on `main` (werkzeug version); CI runs the full suite. The new tests run the indicator script under node with a small stand-in DOM (a slow load shows it, a download or new tab doesn't, a second form send is dropped, the back button clears it) and skip where node isn't installed. They also cover the refresh guard and the slow-response log (route not URL, a token never logged, a quick answer not logged). Three older tests that counted `<script>` tags now discount the shell's script. - [x] **Nothing real**: the beta check's 1.6 output is a method, a route pattern from the code, a count and a time. Its parser was run off the device against invented log lines, and a URL with a query string doesn't match it. - [x] **Consent gates intact**: no change to capture, plugins or the acknowledgment. The indicator only marks the page and drops a repeated form send. - [x] **Docs updated in the same PR**: `GUIDE_MD` (the dashboard section), `docs/developer/web-ui-conventions.md` (the indicator, the refresh rule, the slow log, a checklist line), `docs/developer/deferred.md`, `tools/beta-check/README.md`, CLAUDE.md. - [x] Commit messages are short and imperative. ## Release impact - [x] **App-layer-safe**: only the `kestrel_pi` package (`web.py`, `userguide.py`) ships. The beta-check scripts and docs aren't shipped. - [ ] **Reflash-class** ## Notes for review - No new screenshot: the bar is hidden until a tap waits, so no guide figure changes. - For the next beta's checklist: a by-hand item (tap a slow control such as the capture switch; the bar and **Working…** appear; a second tap doesn't apply the change twice), plus 1.6 in section 1. Item 1.6 reads `SKIP` on a device still running beta.5 or earlier. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Show when the dashboard is working, and log slow answers
All checks were successful
Lint / lint (push) Successful in 31s
Test / test (push) Successful in 1m1s
Lint / lint (pull_request) Successful in 30s
Test / test (pull_request) Successful in 57s
b9e28a7eca
Every page gets a shared "working" indicator: a tap that takes more than a
moment shows a bar and a "Working..." label, and a second send of a form is
dropped while the first loads. The auto-refresh skips a turn while a tap is
loading instead of reloading over it. The daemon logs any answer that took
2 s or more by route, and the beta check counts them in every beta (item 1.6).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
aluminum-ice deleted branch dashboard-busy-indicator 2026-11-17 10:47:00 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
aluminum-ice/kestrel!201
No description provided.