Skip to content

feat(FIX-2154): Grok Bot-style lab front end, on fixtures - #3798

Merged
jhoffner merged 3 commits into
mainfrom
claude/project-thread-aseh3k
Oct 23, 2026
Merged

jhoffner merged 3 commits into
mainfrom
claude/project-thread-aseh3k

Conversation

@jhoffner

Copy link
Copy Markdown
Collaborator

Requested by Jake · project thread

The problem

Someone who has used Grok Bot meets Workforce through Shift Manager, which is a new way of working. The epic needs a second, familiar app on the same package pieces. The approved spec (#3787) designed it: a list of workers, one long conversation each, and workers that message each other where you can see it. The package pieces it needs (FIX-2070's messaging, the history-window gap) are still being refactored, so Jake asked for the front end to be built now, on fixtures.

What this does

A new private lab, labs/teammates, with the screen from the spec's wireframe:

  • Left: the workers, lead, researcher and writer. Each row shows what the worker is doing (working, waiting on researcher, idle · 2h) and an unread count. There's no session list and no new-chat button.
  • Center: the chosen worker's one conversation. When lead messages researcher, a one-line card → to researcher shows in lead's conversation (it opens to the full text), and a line ← lead shows in researcher's. The reply lands in lead's conversation under researcher's name.
  • D2 on screen: while lead is answering you, researcher's reply shows as a pending line, ← researcher replied · lead reads it after this turn, and lands after lead's answer.
  • The divider: lead's conversation runs past the 50-turn history window. A divider marks where the turns lead reads word for word begin. It reads Earlier turns out of view, and Earlier turns summarized only when the summary (gap G1) is on.
  • Right: the Talk panel, lead's exchanges grouped by the other worker, read from the message log. It closes.

Everything goes through one adapter, src/adapter.ts. Each function names the package call it stands for (roster(), ensureWorkerSession, respond, session items, the message log, listSessionRequests, the window's mark). Until wiring, they run on src/fixtures.ts, marked fixture:. The lab copies FIX-2153's setup (the app contract in cli/index.ts, the design-system theme, the registry tokens, the inventory script) and shares no code with it.

What's asked of you

Nothing new. This implements the approved direction in specs/issues/FIX-2154/ (D1 and D2). Wiring waits on FIX-2070 and the history-window gap, as the spec says.

Parts worth reviewing closely

  1. The pending line is a UI join over two reads (src/lib/talk.ts → pendingFor): a log row addressed to the worker with no received entry carrying its message id. That needs G2 (a received message with its id). Check that the join can't show a stale pending line for a message that already landed.
  2. Unread counts (WorkersList.tsx): per viewer, in browser storage. A worker never seen starts with nothing unread, and the open conversation is marked seen as it grows. Check that the effect can't loop.
  3. Inventory (scripts/inventory.mjs): 31 files, no other row. Config 13 files, React UI 14, fixtures 1, checks 3.

SPEC.md · DECISIONS.md · Linear FIX-2154 · epic FIX-2152 · sibling lab #3793. Merges on approval. No changeset: the lab is private.

How to review this

How to review this. This implements an approved spec — the approach and the numbered decisions in its DECISIONS.md are already signed off by a human, so please review the code against that direction, not the direction itself. The canonical set is retained at specs/issues/FIX-2154/ on main; Linear links to it and the original merged spec PR, which keeps review history. Follow-up amendment PRs explain later direction changes. Current architecture docs remain the authority for shipped behavior (BP-037).

Most valuable here: correctness on the second path (the legacy shape, the null boundary, the concurrent case, the cancel path), anything deriving an auth or routing decision from caller-controllable input, and a behaviour the tests assert around rather than on.

Already settled upstream: the approach and every decision in the spec's DECISIONS.md (human-approved — if one is wrong, say so as a spec finding and it gets folded back; don't re-argue it inline), and the conventions in docs/contributing/best-practices.md.

Engineering calls
  • Adapter names. The spec's listTalk, workerActivity and summarizedUpTo became watchTalk, watchActivity and watchWindow, because each one is a live subscription. The header table in adapter.ts maps each one to its package call.
  • Fixture timing. lead takes longer to answer you (6s) than researcher takes to look a fact up (4.7s), so a second line sent before the reply always puts the reply mid-turn.
  • Memory composition (uses plus afterAnswer) lives in the host file, which wiring adds. The README says so. This PR has no host file and no fsdev.config.mts, which matches the sibling lab.
Everything else: verification
  • pnpm --filter @flow-state-dev/teammates test: 10 passed (7 screen, 3 inventory).
  • Each key test was shown to fail. With a fixture that lets a message interrupt the running turn, the pending test fails. With the divider always labelled summarized, the out-of-view test fails. Both pass again once the code is restored.
  • pnpm --filter @flow-state-dev/teammates typecheck and build are clean. node scripts/inventory.mjs passes, and --control fails as required on a planted src/glue.ts.
  • The built pages were driven in Chromium in light and dark: lead messages researcher, a second line puts the reply in pending, and the reply lands after lead's answer.

Generated by Claude Code

labs/teammates: a list of workers (lead, researcher, writer), each with
one long conversation, and workers that message each other where you can
see it. Worker talk shows as one-line cards in both conversations and in
a Talk panel over the message log (D1). A message never interrupts the
turn you are in: it shows as pending and lands after (D2). A divider
marks where the turns the worker reads word for word begin, labelled
"summarized" only when the earlier turns were.

The screen reads and writes through one adapter whose functions name the
package calls they stand for; until wiring they run on src/fixtures.ts.
The inventory script fails on any file that is not config, React UI, a
small flow, a check or a fixture. Setup copied from the Claude Code-style
lab, no code shared.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0147y64Do6d4RkSqzyXhUyKg
@linear-code

linear-code Bot commented Oct 23, 2026

Copy link
Copy Markdown

FIX-2154

@vercel

vercel Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

3 Skipped Deployments
Project Deployment Actions Updated
flow-state-dev-docs Ignored Ignored Oct 23, 2026 10:12pm UTC
flow-state-dev-kitchen-sink Ignored Ignored Oct 23, 2026 10:12pm UTC
flow-state-dev-ui Ignored Ignored Preview Oct 23, 2026 10:12pm UTC

Request Review

Copy link
Copy Markdown
Collaborator Author

@codex review

Please look especially at:

  • labs/teammates/src/lib/talk.ts (pendingFor, waitingOn): can a pending line go stale, or can "waiting on" stay up after a reply lands?
  • labs/teammates/src/components/WorkersList.tsx: can the unread effect (onSeen in a useEffect) loop or miscount?
  • labs/teammates/src/fixtures.ts: are the job queue and turn ordering right, so a message never runs inside a turn already running?

Generated by Claude Code

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review 🔄 Running since 2026-10-23T22:00:12.114719Z 15f8642 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Copy link
Copy Markdown
Collaborator Author

Second look + architecture pass (read-only; for the implementing agent to triage)

Overall the shape earns its scope: one adapter, fixtures confined to one file, joins as plain functions in lib/talk.ts. Findings below are ordered by how much they'd cost at wiring. I did not re-argue D1/D2.

Correctness (worth fixing in this PR)

  1. Stale/flashing pending lines when the conversation hasn't loaded. Conversation.tsx does entries = view?.entries ?? [] while talk comes from a separate subscription. useWatch also resets to undefined on every dep change. Whenever the log arrives before the session items (the normal order once wired, since these are two reads), pendingFor sees no received entries and shows every message ever addressed to the worker as pending. Fixtures emit both synchronously, so the tests can't see it. Fix: return [] from pendingFor (or skip rendering) until view is defined. Add a test with a fixture that delays watchConversation.
  2. Same join, window/paging variant. pendingFor treats "no received entry with this id" as "not read yet". If the wired session items are ever windowed or paged (the same history-window gap this lab is about), old messages whose received entry is out of the loaded range show as pending forever. The spec's G2 should say the join only holds over the full item list, or the pending signal should come from the package (message status) rather than this join. Worth a line in the adapter header at minimum, since this is the review question you asked in "Parts worth reviewing."
  3. Unread is a count, not a position. seen[worker] = entries.filter(!user).length, unread = count - seen. If the entry count ever drops (compaction, windowed load, a failed turn retried) seen stays above count and the next N genuinely new entries show no badge. Store the last-seen entry id and count entries after it; same cost, survives reordering/shrinking. No loop risk in the current effect (markSeen bails on equal), so that part of your question is fine.
  4. markSeen writes localStorage inside the setSeen updater. Updaters should be pure (StrictMode double-invokes them); move the write to an effect or do it outside the updater. Also the key teammates.seen isn't scoped by userId, so two users on one browser share unread state.
  5. waitingOn never clears if the recipient never replies, so a row can say "waiting on researcher" indefinitely. Probably acceptable for v1 but say so, or cap it with the recipient's running/queue state.

Architecture (the refactor opportunity is now, before wiring multiplies it)

  1. Subscription fan-out is the main structural issue. Each WorkerItem opens watchActivity + watchTalk + watchConversation (the full item list) per worker, and Conversation and TalkPanel open watchTalk/watchConversation again for the selected one. That is 3N+3 live subscriptions, and N full item streams solely to compute a badge number. Fixtures hide the cost; wired, it's N SSE connections. Two options, recommending the first:
    • Add one adapter read, watchWorkers(onChange) → { id, name, role, running, lastActiveAt, waitingOn, lastEntryId }[], and move the status/unread derivation behind it. The list reads one subscription; only the selected worker gets watchConversation. This also gives wiring a single place to bind to whatever the package offers cheaply (request list + a per-session cursor) instead of full items.
    • Or keep the adapter as is and lift activity/talk into one provider keyed by worker so the same data isn't subscribed 2-3 times each.
  2. listWorkers + openConversation are called per worker in App just to build a sessions map. ensureWorkerSession is idempotent by the spec, so fold the id into WorkerRow (or watchWorkers) and drop the second map and the Promise.all.
  3. Duplicated scaffolding: this lab copies the app contract, theme, tokens, and inventory.mjs from FIX-2153 and feat(FIX-2153): Claude Code-style lab front end, on fixtures #3793 (explicitly "shares no code"). Understood as an epic constraint, but three copies of the inventory script and use-watch-style helpers will drift; flag for the epic wrap rather than this PR.

Tests (intent)

  1. The unread test asserts "3" after researcher's activity, which pins the count scheme in Infer resource state types in projections and add portable projection resource schema options #3. If Infer resource state types in projections and add portable projection resource schema options #3 changes, assert the visible outcome (badge appears, clears on open, doesn't reappear after reload) rather than the number. Add: unread survives a reload, and unread doesn't re-appear for entries seen while open.
  2. No test for the pending line when the log row's message was already received (the exact stale case the PR body asks about) — add one alongside Kitchen-sink: Add inline editable artifacts and saveArtifact action #1.

None of this blocks the approach; #1 and #3 are the ones I'd fix before merge, #6/#7 are cheapest to do before the adapter is wired.


Generated by Claude Code

Fallow flagged it as an export with no consumer.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0147y64Do6d4RkSqzyXhUyKg

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/simplify review (FIX-2154 · teammates lab)

Verdict: The adapter-first, fixture-until-wiring shape matches ER-5 and the epic inventory rules; I would not replace it with a thinner “just React + mocks” lab without losing the wiring checklist and anti-game boundary. Where complexity crept in is mostly how watches and fixtures are wired, not that they exist.

What looks like the right approach

  • LabAdapter as the only package seam — UI stays ignorant of workforce/client; the README + adapter table are the wiring contract. That is heavier than a demo, but it is the spec product.
  • Scripted fixtures — Needed to prove D1/D2/divider on screen before G1/G2 land; screen tests on speed: 0.05 are the right verification tier for this PR.
  • Design-system + hand-rolled panes — Sensible; importing Shift Manager would violate “copy layout, not package.”

Where it went further than necessary (and cleaner alternatives)

Area Issue Simpler direction (optional / follow-up)
React subscriptions Every WorkerItem holds 3 useWatch hooks; the selected worker also subscribes in Conversation + TalkPanel → duplicate filter/sort work on every fixture notify(). Lift one subscription per channel at App (or a tiny LabWatchProvider / useSyncExternalStore keyed by worker+session). Sidebar rows become pure props. Matches Shift Manager’s snapshot style without depending on that package.
Fixture bus Global listeners + notify() rebroadcasts to all watches; watchTalk filter+sort runs per listener. Fine for 3 workers; at wiring, real SSE will want scoped emits anyway. Consider channel-keyed listeners in fixtures so you do not bake in broadcast semantics.
fixtures.ts size ~half simulator, ~half seed narrative (52+ turns, writer thread). Split static seed data (seed.ts / JSON) from queue + timer (~80 lines). Tests could use adapter.tick() instead of wall-clock setTimeout chains (and cancel timers on Unsubscribe to avoid post-cleanup() flake).
components.json shadcn scaffold with no src/components/ui/* yet — only cn + tokens. Drop until first fsdev ui add; keep tokens.css + design-system import.
Inventory (ER-1) adapter.ts is bucketed as React UI (inventory.mjs), while the spec table lists adapter separately. Add an adapter kind (or count under config) so the README proof matches spec semantics.
Wiring names Spec table uses listTalk / workerActivity / summarizedUpTo; code uses watch* — reasonable for streams, but worth one line in README that watch = future useSession / log subscription. At wiring, bind to useSession, listSessionRequests, WorkerMessageRow paging (kitchen-sink + shift-manager messages.ts as reference), not a second client abstraction.

Third-party / reuse (not implemented yet — by design)

  • @flow-state-dev/react useSession should replace watchConversation when wired.
  • Message log: reuse WorkerMessageRow + collection paging; map replyTo → inReplyTo once at the adapter.
  • Do not pull in @flow-state-dev/devtool just for useSessionRequests — copy the small client poll pattern if needed.

Skipped (larger than this PR)

  • Virtualizing long conversations, incremental log indexes, merging ConversationEntry with ItemsRenderer before G2 — all wiring-era concerns.

Approval stance

No merge blockers from this pass: complexity is concentrated in intentional lab proof, not accidental glue. I’m leaving COMMENT (not Approve) so the watch/subscription duplication and fixture timer lifecycle are visible for a quick pre-wiring tidy — happy to approve after those are addressed or explicitly deferred to wiring.

Open in Web View Automation 

Sent by Cursor Automation: Review For Best Approach

Comment thread labs/teammates/src/fixtures.ts Resolved
Comment thread labs/teammates/src/fixtures.ts Resolved
Comment thread labs/teammates/src/lib/use-watch.ts Resolved
Comment thread labs/teammates/scripts/inventory.mjs Resolved
Comment thread labs/teammates/components.json Resolved
Comment thread labs/teammates/src/adapter.ts Resolved

Copy link
Copy Markdown
Collaborator Author

Thanks for the /simplify pass. All of it is marked optional, so here's where each point stands:

  • One subscription per channel, scoped fixture emits. Deferred to wiring. Real session streams replace these watches then, and with three workers the duplicate filtering costs nothing a person would see.
  • Splitting seed data from the queue, tick(), and cancelling timers on unsubscribe. Stays as is. fixtures.ts is deleted at wiring, and its timers only call listeners that unmount has already removed, so nothing updates React after cleanup().
  • components.json. Kept on purpose: it's what fsdev ui add reads, the same as in the sibling lab, and it is how the registry tokens item arrives (ER-3).
  • Adapter as its own inventory kind. Stays as React UI. ER-1 classifies by path, and src/** is UI. The sibling lab counts it the same way, and the inventory has to agree across both labs.
  • watch* names vs the spec's. The header table in adapter.ts maps each function to its package call, and the PR body's Engineering calls section explains the rename.

Generated by Claude Code

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Snob — a smaller shape, same screen. POC: #3800 (03147c0e2). That PR does not merge.

useWatch is called six times. Each call exists to spell the callback (Parameters<LabAdapter["watchTalk"]>[1]) and hand the hook a deps array it then ignores under an eslint disable. Every watch on this adapter is (id, onChange). Pass the method and the id.

Unread counts are read only by the worker list. Threading seen / onSeen through App adds a prop pair and a second nameOf. The list can hold useSeen and use the nameOf the conversation already has.

The two typed temps in the fixture watches only named the object they passed on.

Net −17 against 15f864237 (+27/−44). pnpm --filter @flow-state-dev/teammates typecheck is clean. The lab tests are 10 passed (7 screen, 3 inventory), including the pending line and the unread count. Divider, Talk panel, and the fixture script are unchanged.

Fold 03147c0e2 onto this branch. Close #3800 unmerged after this PR lands.

View PR

Open in Web View Automation 

Sent by Cursor Automation: Code Snob

useWatch takes the adapter method and its id. Unread state stays in the
worker list, the only reader. Same screen.

Co-authored-by: Jake Hoffner <jhoffner@users.noreply.github.com>

Copy link
Copy Markdown
Collaborator Author

Folded 03147c0e2 in as 874ed14: keyed watches, with unread state held by the worker list. The lab tests (10), typecheck, inventory and the new-dead-code check all pass on the folded head. #3800 can close unmerged once this lands.


Generated by Claude Code

@jhoffner
jhoffner merged commit 0e26308 into main Oct 23, 2026
28 of 29 checks passed
@jhoffner
jhoffner deleted the claude/project-thread-aseh3k branch October 23, 2026 23:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants