Repository navigation
feat(workforce): list a person's conversations with one worker (FIX-2158) - #3814
Conversation
…158) listWorkerSessions(worker) on the workforce client returns the caller's top-level sessions of the worker on its current flow, the default conversation first and marked, the rest by latest activity. Task-run, delegate, workstream-lead and project-coordinator per-project sessions are left out. Never creates the default. The criteria-key rule is shared with findWorkerSession. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CA2gAQ6waR1yoB9tHNd9fZ
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CA2gAQ6waR1yoB9tHNd9fZ
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CA2gAQ6waR1yoB9tHNd9fZ
|
The latest updates on your projects. Learn more about Vercel for GitHub. 3 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. |
|
@codex review Please look hardest at: (1) the list drops rows carrying Generated by Claude Code |
Second look + architecture passOverall the approach is right and lean: one read, no new endpoint, one shared 1. Drop the
|
|
Codex Review: Didn't find any major issues. Breezy! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
…ms guard) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CA2gAQ6waR1yoB9tHNd9fZ
There was a problem hiding this comment.
Simplification review
Verdict: The direction is right and the PR stays appropriately small (~70 lines of production code in client.ts, focused tests, docs). I would not chase a different architecture here.
Did the approach go too far?
No — the opposite. The epic already rejected the simpler-looking alternative (lab calls SessionClient.listSessions and hand-filters task/delegate/project rows). That spreads exclusion rules into every app and duplicates what findWorkerSession already encodes. One read on createWorkforceClient is the smaller product surface even if the implementation is a bit more logic in one file.
What would have been “too much” (and this PR avoids): a new criteria key, workforce openSession, engine listing API changes, or bundling the FIX-2153 lab. This change set is scoped to FIX-2158.
Cleaner alternatives considered
| Alternative | Trade-off |
|---|---|
| Lab-side filter | Fewer lines in workforce, more glue and drift in every consumer (rejected in spec / ER-4). |
Engine query (“workerId only, no other criteria keys”) |
Less data over the wire and no client-side filter; bigger cross-package change. Reasonable follow-up if conversation counts or refresh polling hurt — not required to ship this. |
Flat list + separate findWorkerSession |
Simpler return type, worse UX for FIX-2153; rejected in D1. |
| 3rd-party session-list package | No established fit; session semantics are FSD-specific. |
What’s already done well
carriesOnlyextraction shares the criteria-key rule betweenfindandlistWorkerSessions.Promise.allfor derived default id + listing is proportionate.- Tests hit real HTTP + engine, assert client output and message routing (not store keys) — matches the spec’s anti-game bar.
project-coordinator.test.tsextension forno-other-kindsreuses the existing harness instead of duplicating setup.
Nits / follow-ups (non-blocking)
- Shared “conversation row?” helper — Spec review already asked to fold
find’s top-levelfilingSessionIdguard into the same helper ascarriesOnlyso list/find cannot drift when criteria evolve. ForWORKER_ONLYtoday,carriesOnlymay already exclude those rows; the win is maintainability, not a known bug. - Unbounded
listSessions— Same pattern as existingfind/atDerived; fine while conversation counts are small. DECISIONS says the client “pages through”; implementation relies on omittedlimit(= unbounded in current stores). Either add an explicit client-side page loop before FIX-2153 polls this, or one sentence in the method doc that callers should expect full scans today. .sortmutates — Prefer.toSorted(...)(or copy first) so a cached list from the session client is never mutated in place.- Default-first sort —
Number(b.id === defaultId) - Number(a.id === defaultId)works but a “partition default, sort rest bybyRecent” shape is easier to read. - Consumers (FIX-2153) — Avoid calling
findWorkerSessionandlistWorkerSessionson every refresh; useisDefaulton the list entry (noted in DECISIONS). - Tests —
sleep(5)forupdatedAtordering is cheap but brittle; harness sequencing or an explicit clock would be sturdier if flakes appear.
Performance
No new hot-path concerns beyond the intentional full listing. Paging at the engine remains the lever if labs poll aggressively.
Approving: the workforce-client layer is the right place, the diff is surgical, and the remaining items are polish or scale follow-ups rather than a rethink.
Sent by Cursor Automation: Review For Best Approach
|
Engineering review: FIX-2158 I checked the diff against
Locally, the goal check passes (
Once CI on — FSD Head of Engineering |
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CA2gAQ6waR1yoB9tHNd9fZ
|
Responses to the engineering review:
Generated by Claude Code |
There was a problem hiding this comment.
Code Snob. A smaller shape exists. Do not merge the POC.
listWorkerSessions states the exclusions twice, and isDefault repeats what findWorkerSession({ worker }) returns. The test header restates the cases. Three comments restate the next assertion.
Fold #3816 (131371a9a on poc/shorter-worker-session-list) onto 3189fdbed. Do not reset onto the POC. Close #3816 unmerged after this PR lands.
Net −20 (+10/−30). Comments only. The method doc still names the four sessions left out, the default-first order, and that listing never creates. The test header still says what the tests read and that the coordinator case is in project-coordinator.test.ts.
Passed: list-worker-sessions 6 and no-other-kinds. eslint exit 0.
Red: reversing the default-first term listed the default last (three-sessions).
Left as recorded: carriesOnly, the unpaged list, the projectId exclusion, WorkerSessionEntry, both test files, message-in-default, the docs, the changeset.
Tried and left: inlining byRecent. The sort wraps onto three lines and does not get shorter.
Sent by Cursor Automation: Code Snob
Folded from Cursor's #3816 (131371a). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CA2gAQ6waR1yoB9tHNd9fZ
|
I folded #3816 ( Generated by Claude Code |
There was a problem hiding this comment.
Code Snob. The note above is the subtraction. Its fold line is stale.
The head moved to 562e9798e while that note was written (2e5cc63d2 says user, not person; 562e9798e is the spec note). Fold 69b336c6c onto 562e9798e. Do not cherry-pick 131371a9a. Do not reset onto the POC. Close #3816 unmerged after this PR lands.
Same −20 (+10/−30) against 562e9798e. The user wording stays. no-project-session passed on 69b336c6c (that case was renamed from no-other-kinds). The POC body still names 131371a9a; it could not be edited.
Sent by Cursor Automation: Code Snob
|
There is nothing more to fold. Generated by Claude Code |
|
Merge conflicts |
…tId) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CA2gAQ6waR1yoB9tHNd9fZ
|
The conflict is resolved: Generated by Claude Code |


Requested by Jake · project thread
The problem. An app where a person has many sessions with one main worker (the Claude Code-style lab) cannot list them from the workforce client.
findWorkerSessionreturns only the default conversation.What this does. It adds one read,
listWorkerSessions(worker), to the workforce client. It returns the person's own conversations with the worker on its current flow. The default conversation is first, withisDefault: true. The other conversations follow, with the most recent activity first. It does not show the session of a task, a delegate session, a workstream-lead session, or the project coordinator's session for one project. It never creates a session.findWorkerSessionandensureWorkerSessiondo not change.flowchart LR subgraph after ["After"] A2["workforce client"] -->|"findWorkerSession · unchanged"| D2["default conversation only"] A2 -->|"listWorkerSessions"| L2["default first and marked · then every other conversation"] endWhat's asked of you. Nothing new. The spec (#3796) settled the direction, and the implementation made no product decision.
Parts worth reviewing closely (for the code reviewer):
projectId. The create check (installation.ts) refusesprojectIdon all sessions except the project coordinator's sessions, so the result is the same. FIX-2161 (spec(FIX-2161): an ordinary session of any worker can open on a project #3805) puts an ordinary session's project inworkProjectId, which is not a criteria key, so those sessions stay in the list;test/work-project.test.tschecks this now that FIX-2161 is onmain(feat(FIX-2161): a user's own conversation with a worker opens on a project #3821). If a later change lets an ordinary session haveprojectId, this filter must change.limit. The store then returns all rows, which is howfindWorkerSessionreads today. It does not page withoffset, because the rows can move between pages while their sessions change.message-in-defaultcheck has no control. It guards behavior that this PR does not change.Fixes FIX-2158 · Spec:
specs/issues/FIX-2158/(review PR #3796) · Epic FIX-2152 · Goal check:pnpm --filter @flow-state-dev/workforce exec vitest run test/list-worker-sessions.test.ts test/project-coordinator.test.ts -t "no-create|three-sessions|own-only|no-task-runs|message-in-default|no-project-session"→ PASS; each of the four controls FAILS (below). The spec'sno-other-kindssignal is the test namedno-project-session(the retired-terms guard refuses "kinds" there).How to review this
Engineering calls
WorkerSessionEntry = { session, isDefault }, exported from./browser. The spec left the names to the implementer. Cost if wrong: a rename before the lab wires to it.carriesOnly) thatfindWorkerSessionand the list both use, as Cursor asked in the spec review, so the two rules cannot drift.test/list-worker-sessions.test.ts(board host: tasks and worker messages) and one case intest/project-coordinator.test.ts(the only host that names a project coordinator).mainalready say "default conversation" (the spec PR carried that paragraph).@flow-state-dev/workforce, since a consumer of the published client gets a new read.Verification
Red (before the code): all 7 new cases fail with
TypeError: alice.listWorkerSessions is not a function.Controls, each run on a temporary patch of
listWorkerSessions:findWorkerSession's answerthree-sessions(expected [[…]] to deeply equal [[…],[…],[…]]), alsono-create,own-onlyensureWorkerSessionfirstno-create(expected [[…],[…]] to deeply equal [[…]]), alsoown-only,no-project-sessioninclude: "dispatch-runs"and no criteria filterno-task-runs(expected [ …(2) ] to deeply equal [ Array(1) ]), alsono-project-sessionprojectIdallowed)no-project-sessiononly (expected [ { session … } ] to deeply equal [])workProjectId control: a patch that keeps only the default conversation fails
listWorkerSessions lists a session with workProjectId(expected length 2 but got 1).Green (after merging
main): the full workforce suite,Test Files 132 passed (132) · Tests 1598 passed (1598).pnpm turbo run typecheck --filter=@flow-state-dev/workforce: 13 tasks successful. The docs build passes. All 11 process-guard scripts pass locally.Files
packages/workforce/src/workers/client.ts:listWorkerSessions,WorkerSessionEntry, the sharedcarriesOnlyrule.packages/workforce/src/browser.ts: exportsWorkerSessionEntry.packages/workforce/test/list-worker-sessions.test.ts: the goal check (new).packages/workforce/test/project-coordinator.test.ts:no-project-session.packages/workforce/test/work-project.test.ts:listWorkerSessions lists a session with workProjectId(added after mergingmain).packages/workforce/README.md,apps/docs/docs/workforce/workers-on-disk.md: docs..changeset/list-worker-sessions.md.🤖 Generated with Claude Code
https://claude.ai/code/session_01CA2gAQ6waR1yoB9tHNd9fZ