Skip to content

feat: screens that stay current without polling, and a menu bar that shows what is running - #105

Merged
fylorn merged 1 commit into
devfrom
feat/live-updates
Sep 22, 2026
Merged

fylorn merged 1 commit into
devfrom
feat/live-updates

Conversation

@fylorn

@fylorn fylorn commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

Why

An audit of every screen that shows live data found:

  • one timed poll that core already pushes for (the Upstreams page asked every 30 s, and got a quota countdown that never moved);
  • screens that never changed once open (a request still running could not be opened at all, then sessions, keys, MCP findings, upstream credential and proxy state);
  • six core events the interface ignored, including request_routed, so a request that failed over stayed attributed to the upstream that failed;
  • a menu bar whose second line promised the output rate but had it hard-coded to nothing;
  • a push channel that could lose events silently, so a lost ending left a row "in progress" forever.

Core v0.25.0 (ThinkWatchProject/ThinkWatch-Core#102) adds what was missing on its side: EventsDropped, quota reset times as moments, the current credential and proxy state in the overview, and details of a request still running. This PR uses them.

What changed

Lost events. Core tells a subscriber that fell behind, and the Rust bridge sends the same events_dropped marker after it reconnects. useRequests takes the in-flight snapshot again and re-reads the history; a row still in progress that the history already has gets its ending from the stored row (mergeHistory). useLive resyncs its count and refills the chart, every useCoreEvent page refreshes, and App re-reads the overview (now coalesced, so a burst of triggers reads once).

Polling replaced. The Upstreams page takes quota straight from quota_seen and re-reads the 24-hour requests, cost and TTFB after requests land and when the window regains focus. Reset countdowns are computed locally from resets_at_ms (resetAt, useNow); a window whose reset has passed is no longer shown as current, in the table, the ChatGPT account section and the menu bar.

Screens that did not update.

  • A request still running opens with what is known so far (status, route, request body), marked in progress, and becomes the stored record when its priced event arrives. Core emits that event in the same lock as the database write, so the re-read never races it.
  • An open session refreshes as its requests land; the Keys page's last used and 24-hour usage follow requests; the MCP page rescans on scan_alert / clients_changed.
  • The Upstreams table shows Credential rejected and Sign in again; the proxy table shows the failure the gateway found (whichever is newer, that or a manual test). The overview is re-read on auth_changed, proxy_changed, credential_expired, and the first quota report for an upstream.
  • The traffic list takes the upstream from request_routed.

Rust side.

  • Menu bar: the requests in progress (N ▶) and the output rate (tokens per second of generation over requests finished in the last minute) are counted from events in a new tally module. While a countdown or a rate is shown, a 10 s tick recomputes them without asking core.
  • A core binary that cannot run is now a state, failed:<reason>, with the reason, a retry button, and a critical notice. Before, the app showed "starting" forever.
  • A wedged core that was replaced leaves an in-app notice. It does not interrupt, the same as a one-off crash.
  • The first autostart hint is a system notification through the notice bus (announce), and it respects the notice mode. It used to be emitted to a webview that is never open at login.
  • Tauri events with no listener are removed: core-restarting, core-safe-mode, core-failed, core-wedged, app-exiting, first-autostart.

Pins core v0.25.0 (control API 8).

Test plan

  • pnpm typecheck
  • pnpm test: 197 passed. New: resetAt, request_routed moving the upstream, mergeHistory ending a row whose ending was lost
  • cargo fmt --check, cargo clippy -- -D warnings, cargo test on src-tauri: 118 passed. New: the tally count and rate (incl. a resync while the snapshot is on its way), Failed from a binary that cannot run, the failed and wedged notices, notices reading resets_at_ms
  • Previewed with an isolated harness (mockIPC), zh and en:
    • drawer on a running request: every tab, then the switch to the full record on its priced event;
    • Upstreams table badges and tooltip, countdown, and a past reset not drawn as full;
    • proxy fault;
    • the connect screen when core cannot run.

🤖 Generated with Claude Code

…shows what is running

An audit of every live-updating screen found one timed poll that core
already pushes for, several screens that never changed once open, events
the app ignored, and a push channel that could lose events silently.
Core v0.25.0 (ThinkWatch-Core#102) adds what was missing on its side; this
uses it.

Lost events
- core now tells a subscriber that fell behind (events_dropped), and the
  Rust bridge sends the same marker when it reconnects after a drop.
  useRequests takes the in-flight snapshot again and re-reads the history;
  a row still "in progress" that the history already has gets its ending
  from the stored row (mergeHistory), so a lost ending no longer leaves a
  row running forever. useLive resyncs its in-progress count and refills
  the chart, every useCoreEvent page refreshes, and App re-reads the
  overview.

Polling replaced
- The Upstreams page stops asking every 30 s. Quota comes straight from
  quota_seen; the 24-hour requests, cost and TTFB are re-read after
  requests land and when the window regains focus.
- Quota resets are moments (resets_at_ms), and countdowns are recomputed
  locally as time passes. A window whose reset has passed is no longer
  shown as current, in the table, the ChatGPT account section and the
  menu bar.

Screens that did not update
- Opening a request that is still running shows what is known so far and
  follows it; the row is complete once its priced event arrives, which
  core sends in the same lock as the database write. Replay, content and
  usage say they are available when the request ends.
- An open session refreshes as its requests land; the Keys page's last
  used and 24-hour usage follow requests; the MCP page rescans on
  scan_alert and clients_changed.
- The Upstreams table shows a rejected credential and a needed sign-in,
  and the proxy table shows the failure the gateway found, whichever of
  that and a manual test is newer. The overview is re-read on
  auth_changed, proxy_changed, credential_expired and the first quota
  report for an upstream.
- The traffic list takes the upstream from request_routed, so a request
  that failed over is attributed to the upstream that served it.

Rust side
- The menu bar's second line shows the requests in progress and the
  output rate (tokens per second of generation, over requests finished in
  the last minute) instead of hard-coded blanks; both are counted from
  events, and ticks recompute them without asking core.
- A core binary that cannot run is a state (failed:<reason>) with the
  reason and a retry, instead of "starting" forever, plus a critical
  notice. A wedged core that was replaced leaves an in-app notice. The
  first autostart hint is a system notification that respects the notice
  mode; before, it went to a webview that is never open at login.
- Tauri events nobody listened to are gone: core-restarting,
  core-safe-mode, core-failed, core-wedged, app-exiting, first-autostart.

Pin core v0.25.0 (control API 8).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@fylorn
fylorn merged commit 45f508c into dev Sep 22, 2026
2 checks passed
@fylorn
fylorn deleted the feat/live-updates branch September 22, 2026 07:17
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