Repository navigation
fix(app): order the inbox Working shelf by when each run started - #60147
Conversation
There was a problem hiding this comment.
The approach looks sound. time.busy is the right signal for both the Working order and the timer, and the sort is stable: earliest-started run first, rows with no known start last, ties broken by key. I checked it with the titlebar tests (28 pass) and tsc -b in packages/app. I couldn't run the desktop/web Inbox here. A short before/after video of the Working shelf while two sessions stream would help reviewers.
Public API: unchanged. The change only reads the existing time.busy field.
One non-blocking point, inline: sessions that aren't loaded in the data store don't get a fresh time.busy when a new run starts. For those, the row shows plain "Working" and sorts last for the whole run.
| export function workingSince(session: SessionTime) { | ||
| const { busy, idle } = session.time | ||
|
|
||
| if (busy === undefined || (idle !== undefined && idle > busy)) return undefined |
There was a problem hiding this comment.
The data store only refetches on session.execution.started when the session is already in store.session.info or being synced (packages/client/src/solid/data.ts). Some inbox rows come only from the inbox-sessions list query (staleTime: 30_000, refetched on mount/reconnect), for example an older session rerun from the TUI or another window. For those, time.busy stays at the previous run's value for the whole new run, so the row shows plain "Working" and sorts last until it ends. That's no worse than the old stale time.updated timer. If you want those rows to get a timer too, one option is to refresh the inbox entry (or invalidate the inbox query) when such a session starts executing.
The Working shelf in the Inbox sidebar reordered on almost every streamed message, and each row's "Working Ns" timer kept resetting. Both used
time.updated, which the server bumps on every message event.Both now use
time.busy(#59910), which records when the session's current run started:workingSince(new,inbox-working.ts) treatstime.busyas the current run's start only when it isn't older thantime.idle. When a turn starts, the client marks the session working right away and refetches it to get the newtime.busy. Until that arrives, it still holds the previous run's start. A row in that state shows plain "Working" without a duration and sorts last. Servers that don't recordtime.busybehave the same way.This replaces the client-side arrival-order tracking in #59692.
Lint on touched files also clears two existing findings in
inbox.tsx: a missing blank line beforereturninDeleteDialog, and thestatus() as Exclude<…>assertion, which is now a narrowedstatusLabelhelper.Testing
bun test … src/shell/titlebar/(28 pass, including the newinbox-working.test.ts)bun run typecheckinpackages/appbun run lint:changed: cleanRequested by: @Brendonovich (Brendan via Slack)