Skip to content

Live query activity over SSE, with a query detail sidebar - #5

Merged
tmphost-dev merged 1 commit into
mainfrom
feat/live-activity
Oct 23, 2026
Merged

tmphost-dev merged 1 commit into
mainfrom
feat/live-activity

Conversation

@tmphost-dev

Copy link
Copy Markdown
Contributor

What

  • Live activity: the Activity tab subscribes to GET /api/v1/databases/{id}/queries/stream (server-sent events) and adds each query as it is recorded, with a Live / Connecting / Offline indicator and a Reconnect button.
  • Query detail sidebar: clicking a row (or Enter on it) opens a right-hand sidebar with the full SQL (wrapped, copyable), status, rejection/error reason, time to the second, source, rows, duration and the tmphost result link. Escape, the close button or a second click closes it. Below lg it overlays from the right.

How

  • service/feed: an in-process, per-key pub/sub hub. A slow subscriber drops events rather than blocking the query path.
  • crud: record publishes each logged query; WatchQueries checks ownership (someone else's database is not found); deleting a database closes its watchers.
  • handler/live: the SSE endpoint, on the stdlib mux rather than Fiber, because the Fiber adaptor buffers whole responses. It authenticates with the at cookie, sends : ping heartbeats, and ends when the session token expires or the database is deleted.
  • Frontend createQueryStream: when the server refuses a reconnect (for example a 401 after expiry), it renews the session via /auth/refresh and retries with backoff. After 3 refusals it goes offline. Every (re)open reloads /queries to catch up, keeping streamed rows the reload missed.

Limits

The feed is in-process, so with several replicas a stream only shows queries run by its own replica. This is noted in docs/API.md and AGENTS.md.

Tests

  • Go: unit tests for the hub, the controller watch (including delete and log-failure), the SSE handler (auth, 404/500, events, heartbeats, session expiry, client disconnect, write/flush failures), and a full-stack test proving the stream flushes through the real mux. go test -race passes.
  • Vitest: the stream composable (open, drop, refuse→refresh→retry, offline, stop), the API helpers, and ActivityPanel (live rows, dedupe, catch-up merge, sidebar, copy, keyboard, reconnect).
  • make lint is clean, and make cover BASE=main reports no uncovered added lines.

🤖 Generated with Claude Code

The Activity tab now subscribes to GET /api/v1/databases/{id}/queries/stream
and adds queries as they are recorded. Clicking a row opens a right-hand
sidebar with the full SQL, its status, reason, rows, duration and result.

The stream is served by the stdlib mux, since the Fiber adaptor buffers
whole responses. It ends with the session or the database; the browser
renews the session and reconnects, catching up from /queries.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@tmphost-dev
tmphost-dev merged commit 5ba0d4e into main Oct 23, 2026
6 checks passed
@tmphost-dev
tmphost-dev deleted the feat/live-activity branch October 23, 2026 04:32
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