Repository navigation
feat(kitchen-sink): live session rails with each row's state (FIX-2411) - #4760
Conversation
The harness rail reads through useSessionList and draws each row's turn state, model and age; its own read and reads counter go. The Flow State page drops its hand re-reads; railSessions passes subscribe through and gives coordinator rows their state. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NczDiFQ8qXgjG9CR9fxF2b
|
The latest updates on your projects. Learn more about Vercel for GitHub. 4 Skipped Deployments
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Second look + architecture reviewOverall: the direction is right. Moving the harness rail and Flow State page onto 1.
|
There was a problem hiding this comment.
Simplify review (FIX-2411 harness / Flow State rails)
Verdict: The direction is right and worth merging. Swapping the harness frame to useSessionList, deleting the reads counter / onTitled / leaf.refresh() chains, and passing subscribe through railSessions is the simpler architecture: one live read path, notices instead of imperative “please re-list.” That is the big win.
Where complexity crept in anyway: most of it is presentation, not the live-list wiring.
-
HarnessSessionListre-implements FlowNavigator row chrome — status mark, age,data-*hooks, and a copy ofuseMinuteClockalready live inFlowNavigator.ts. You correctly reusedsessionLabel/sessionRowState/sessionAgefrom@flow-state-dev/react; the remaining JSX is the drift surface (Tailwind orange vs nav CSS vars, missing full-datetitleon age, etc.). Kitchen Sink’s own rule says a second rail host is the signal to lift shared UI into the framework. Cleaner follow-up (not a blocker): export a smallSessionRowMeta+ shareduseMinuteClock(even@internal) and keep harness-only the model subline. -
rail-sessionsstatus merge — reasonable glue for coordinator rows built viaensureWorkerSession. Whenincludehas"status", you payensureWorkerSession × Nplus a full coordinatorlistwith status. Fine for three coordinators; worth a one-line comment that this is intentional and bounded, or a follow-up to fold status into the workforce read if this pattern spreads. -
Stale module doc —
harness-session-list.tsxstill says the frame “reads the listing once,” which contradictsharness-frame.tsxand the new behavior. Easy fix before or right after merge. -
sessionModelcast — if listing already exposes readonlystatefor harness flows, typing that onSessionSummary(or a narrow listed-session type) removes the cast; optional polish. -
rowstri-state inharness-frame—(loading || error) && sessions.length === 0 ? null : sessionsre-encodes hook semantics. Not wrong; could shrink later by passinglistthrough or a tiny{ rows, phase }helper if this pattern repeats.
Performance (scoped to this diff): default includeStatus: true + 3s poll in Next (no push) means periodic full list+status work — acceptable for harness-scale rails; the new e2e documents the bound well. Coordinator double-list is the only local smell.
Skipped (larger refactors): mounting FlowNavigator on harness pages (wrong UX), moving coordinator status into workforce in this PR.
Approving because the live-list approach is the right default and the remaining items are follow-up simplification, not a wrong architecture.
Sent by Cursor Automation: Review For Best Approach
| @@ -8,22 +8,35 @@ | |||
| * row that opens closed. Here the sessions are the rail's content. Drawn from | |||
| * the rows the frame read, so the frame reads the listing once. A failed read | |||
There was a problem hiding this comment.
This header still says the frame reads the listing once (Drawn from the rows the frame read…). After useSessionList in harness-frame, that is misleading for the next reader. Worth aligning with the frame module doc (live notices / poll fallback).
There was a problem hiding this comment.
Fixed in 359240e: the header now says the rows come from the frame's live read (notices, or the fallback timer without push).
Generated by Claude Code
| const match = ENGINE_ID.exec(session.id); | ||
| return match === null ? session.id : `${match[1]}_…${match[2]!.slice(-6)}`; | ||
| /** Now, a minute at a time: ages are drawn in minutes, never re-read. */ | ||
| function useMinuteClock(): number { |
There was a problem hiding this comment.
Simplify / reuse: useMinuteClock is duplicated verbatim from private code in FlowNavigator.ts. Not introduced by the live-list wiring itself — if we keep enriching flat rails, exporting this hook (or bundling it with shared row meta) avoids a third copy when another host appears.
There was a problem hiding this comment.
Kept as is for this PR. The navigator's clock is private to @flow-state-dev/react, so exporting it (or a shared row-meta component) is a package change that belongs in #4749 or a follow-up, not in the app PR.
Generated by Claude Code
| > | ||
| {sessionLabel(session)} | ||
| <span className="flex items-center gap-1.5"> | ||
| {state !== null && ( |
There was a problem hiding this comment.
Simplify / reuse: This mark + age layout mirrors sessionMeta() in FlowNavigator. Helpers are shared (session-row.ts); markup is not yet. Medium-term cleaner shape: a framework SessionRowMeta (className overrides for harness vs navigator) and harness-only second line for model. Optional for this PR, but this is the main “went further than necessary” surface area.
There was a problem hiding this comment.
Same as the clock: the shared helpers (label, state, age) are reused; lifting the markup into a framework component is a package change. Leaving it for a follow-up so this PR stays app-only.
Generated by Claude Code
| /** An engine-minted session id: its prefix, a timestamp, and a hex tail. */ | ||
| const ENGINE_ID = /^([a-z]+)_\d{13}_([0-9a-f]{6,})$/; | ||
| /** The model a listed session was born with: a readonly state field the listing carries. */ | ||
| function sessionModel(session: SessionSummary): string | undefined { |
There was a problem hiding this comment.
Cast on state.model — if the listing contract already carries exposed readonly session state for harness kinds, a typed field on SessionSummary (or a narrow list row type) would drop this helper entirely. Uncertain whether client types already guarantee state on list responses everywhere; if yes, typing beats casting.
There was a problem hiding this comment.
Leaving the cast: SessionSummary doesn't type a per-flow state field, and typing it for harness kinds is a client contract change outside this app PR.
Generated by Claude Code
| const list = useSessionList({ flowKind, client }); | ||
| const listError = list.error; | ||
| // `null` until a read answers with rows: still loading, or failed. | ||
| const rows = (list.isLoading || listError !== null) && list.sessions.length === 0 ? null : list.sessions; |
There was a problem hiding this comment.
The rows === null loading sentinel duplicates list.isLoading / list.error / list.sessions. Works today; if this tri-state shows up again, consider deriving it once next to useSessionList or exposing a small helper from react so hosts do not re-invent null-vs-empty semantics.
There was a problem hiding this comment.
Leaving it: the null sentinel is what the list component reads to tell loading from an empty list, and this is the only host doing it. Worth lifting if a second host repeats it.
Generated by Claude Code
| title: worker, | ||
| }), | ||
| const include = options?.include === undefined ? [] : [options.include].flat(); | ||
| const [rows, listed] = await Promise.all([ |
There was a problem hiding this comment.
When status is included, this does workforce ensureWorkerSession for each coordinator and a separate sessions.list({ include: ['status'] }), then merges by id. Correct for marks on synthetic rows; slightly chatty. A short comment that N is bounded (SHELL_COORDINATORS) would help, or a follow-up to attach status in one workforce call if this merge grows.
There was a problem hiding this comment.
Added a comment in 359240e saying the find is per declared coordinator (a fixed, small set) plus one status listing when state is asked for. Folding status into one workforce call is out of scope here.
Generated by Claude Code
| * timer, not push's second. The second-scale path over a real socket is the | ||
| * Node host's goal check (`packages/node/test/live-session-list.test.ts`). | ||
| * | ||
| * Red state: on the code before this change the harness rail read once, so |
There was a problem hiding this comment.
Nit: the “Red state: on the code before…” paragraph is useful in PR narrative but reads like implementation history in a test file. Consider trimming to the bound you assert (3s poll, Node test owns push) — optional, not blocking.
There was a problem hiding this comment.
Leaving it: this repo's tests state their red state so a reader knows what the test catches (BP-003).
Generated by Claude Code
…read is bounded (FIX-2411) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NczDiE3DUKgZCYa7rK37qK
There was a problem hiding this comment.
Code Snob — already tight. A rewrite does not shrink this contract. No POC.
Head fe61592ee591a5921477f6035e854ea5bd180f02. Nine files, +297/−105, all under apps/kitchen-sink.
I read harness-frame.tsx, harness-session-list.tsx, harness-mode-view.tsx, harness-session.tsx, app/flow-state/page.tsx, lib/rail-sessions.ts, e2e/live-session-list.spec.ts, test/harness-mode.test.tsx, and test/rail-sessions.test.ts. I compared them with session-row.ts, FlowNavigator.ts (sessionMeta, useMinuteClock), useSessionList.ts, client-session.ts, and SessionSummary.
- The hand re-reads are already gone: the title effect,
onTitled, thereadscounter, andleaf.refresh()after New session. What remains isuseSessionList. - D2 keeps two drawings.
sessionMetais the navigator's spans, coloured with--fsd-nav-*. The harness row is that mark, label, and age, plus the model line. A shared chrome component is a third surface and a style prop, longer than the row. useMinuteClockis the same seven-line clock in each drawing. Exporting the navigator's copy adds a public hook. Moving it intosession-row.tspulls React into that pure module. The local copy stays.sessionModelis the cast.SessionSummaryhas nostate;toClientSessionstill sends the exposed fields, andmodelis one of them. Inlining the cast is the same check inside the map. AddingstatetoSessionSummarybelongs on the listing type and does not shorten this row.railSessionslists coordinator status only whenincludecontains"status", joins by id, and keeps the coordinator id as the title. The omit-when-absent copy ofrequestWaitsForUsermatches the listing row.subscribeis the pass-through the navigator's leaves need. Dropping the undefined guard onincludeis one expression of the same check.- The
nullrows value is the loading and failed-empty state the list already drew, and the address effect reads that same value. PassingisLoadingbeside it repeats the condition. rail-sessions.test.tsis three clauses. The harness case is one live row. The e2e is the two timer cases.openMode,newSession, andsendserve both cases. The other mode specs' helpers return void and do not read the session id.
The file headers restate the live read. Cutting them leaves the same functions.
The seven red Kitchen Sink e2e specs stay on #4749, where this PR left them.
Sent by Cursor Automation: Code Snob
…ns, never the flow whole (FIX-2411) The rail's coordinator status read listed the whole coordinator flow, which reads every coordinator's sessions and broke the shell's reading-only-leaves check. Each declared coordinator now lists its own sessions (state.workerId) with status. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NczDiE3DUKgZCYa7rK37qK


Requested by Jake · project thread
What this does
The Kitchen Sink half of FIX-2411 (spec
specs/issues/FIX-2411/, #4728). Stacked on the package PR #4749; GitHub retargets it to main once #4749 merges. Merge #4749 first.useSessionList, so a session started in another tab joins the rail without a reload, and each row shows its turn state (Running, Failed, ...), model and age. Its own one-off read and reads counter are gone.railSessions: passessubscribethrough so the navigator's leaves stay live, and gives coordinator rows their turn state from the coordinator flow's own status listing.Kitchen Sink under Next serves no push socket, so its rails refresh on the client's 3 s fallback timer. The new e2e is bounded at 4 s for that reason; the 1 s goal over real push is proven on the Node host in #4749.
What's asked of you
Review and merge after #4749. No changeset: the app is private.
Worth a close look
lib/rail-sessions.ts: the coordinator status read runs only when the navigator asks forinclude: ["status"], lists each declared coordinator's own sessions (state.workerId), never the coordinator flow whole (the shell's reading-only-leaves e2e holds that), and a row keeps its coordinator-id title.Verification
e2e/live-session-list.spec.ts(2 cases)app/,components/,lib/from the base), rebuiltrail-sessions.test.tsandharness-mode.test.tsxcases). The per-coordinator listing case fails on the earlier whole-flow read.pnpm typecheck(kitchen-sink)workforce-shell,address,talk-from-page,live-session-list: 22 passed. (Locally the container's newer Chromium also logs a/favicon.ico404 that trips the console-error fixture; with a stub favicon, not committed, that noise goes away. CI's browser is unaffected.)Fixes FIX-2411 (Kitchen Sink half).
https://claude.ai/code/session_01NczDiE3DUKgZCYa7rK37qK
Generated by Claude Code