Repository navigation
Calm sidebar part 2: thread roles and the calm grouping - #952
Conversation
Adds packages/client-runtime/src/state/threadRoles.ts, read by nothing yet (the sidebar comes in part 3): - resolveThreadRoles: the threadRoles pointers whose thread can hold the role now. A pointer to a missing, deleted or archived thread, a sub-agent, a side chat, a delegated task or (orchestrator) a thread of another project counts as no role; the pointer is left alone. Read leniently: a bad entry is skipped alone. - threadRole: a row's role, checking the row again. - calmPartition: off (the list as given), no-roles (the list plus a hint) or calm (assistants, then orchestrators on top; the rest folded, with how many wait on the person). - createThreadRolesAtom: the resolved roles of every enabled server; reads threads only where a role is named; stable while equal. Seam list: forkFiles gains threadRoles* in client-runtime and in contracts (part 1's file was missing, so any later edit of it was refused), and the one-line client-runtime export part 3 adds is announced. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…re not counted Review follow-up. A new install with no threads now gets the list as given (kind "off"), as the design's empty-state row says, so the sidebar never shows the pick-a-role hint on an empty list. The waiting count leaves out a usage-limit stop on purpose (it clears without the person); the doc comment now says so. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
lens: code · reviewer: lens agent (Opus, read-only) · read at: 2f06950 |
Calm sidebar PR 2 of 5.
What and why
The shared logic of the calm sidebar, in one new file the web and phone lists can both read:
packages/client-runtime/src/state/threadRoles.ts. Nothing reads it yet, so nothing a user can see changes. PR 3 adds the sidebar.resolveThreadRoles(roles, threads): thethreadRolespointers (Calm sidebar part 1: threadRoles and calmSidebarEnabled settings #928) whose thread can hold the role now. A pointer to a thread that is missing, deleted, archived, a sub-agent, a side chat, a task delegated from a linked machine or (orchestrator) in another project counts as no role. The pointer itself is left alone, so unarchiving brings the role back. Read leniently: a bad hand-edited entry (non-id value, blank key, wrong shape) is skipped alone.threadRole(thread, roles):assistant,orchestrator,childorplain. The row is checked again, so roles read a moment before the list never lift an archived, moved or child thread. A thread that is both assistant and orchestrator is the assistant.calmPartition(threads, rolesByEnvironment, enabled):off: the same array as given (upstream's list): calm is off, or there are no threads at all.no-roles: calm is on but no listed thread holds a role. The full list plus a hint; it never folds everything away.calm: role rows on top (assistants, then orchestrators), every other thread folded in list order, plus how many of those wait on the person (approval, question or user-only card, child request, guest message: the sidebar's own pills). A usage-limit stop is not counted on purpose: it clears without the person. This is the owner's "fold them, with a waiting count" (Owner question: calm sidebar - fold other threads with a waiting count, or hide them? #139).It only groups: every thread comes back exactly once, so search, drafts and links are untouched.
createThreadRolesAtom(...): the one atom. It holds the resolved roles of every enabled server, follows settings pushes and thread changes, and keeps the same map while the result is equal. It reads threads only on servers that name a role, so streaming costs nothing while none do. Its inputs are atoms upstream already exports (catalogValueAtom,settingsValueAtom,environmentThreadIndexAtom), so PR 3 wires it with one call.Seam list (
.github/fork-seams.json):forkFilesgainspackages/client-runtime/src/state/threadRoles*andpackages/contracts/src/threadRoles*. Without these entries, a later PR that edits either file is refused as an upstream file. PR 1's contracts file was missing: a probe commit that adds one line to it on top of main fails the seam check today.packages/client-runtime/package.json. This PR announces it:"./state/thread-roles": "./src/state/threadRoles.ts",. It has to be one line because the usual four-line form ends in},, a line upstream already has, so it cannot be announced. If PR 3 is more than 14 days away, the announcement expires harmlessly.Not here: #946 point 2 (no test fails if
ThreadRoleTargets.layerleavesforkLayers.ts). That is server wiring and does not fit a client-runtime PR, so it stays with the later Settings PR as #946 says. The owner's #140 answer (an orchestrator may pass its role on by itself) is a server write path and does not touch this reader.Tests
threadRoles.test.ts: 35 tests, one or more for each row of the design's state table that a reader sees, plus the atom. Without the change the module does not exist and the test file fails to load; with one rule broken on purpose, its tests catch it (both shown below).State question
"What happens when this runs again, stops half-way, or meets existing, old or empty state?"
resolveThreadRolesgives none. With calm on,no-roles: the full list and the hint, never an empty sidebar. New install with no threads:off, the empty list as upstream, with no hintthreadRoleskey at all; that server is left out of the map. An old settings file reads as no rolesUpstream fit
New fork file only. It uses upstream's
isListedThreadLineage, upstream'sdelegatedFrom != nullrule (the same as #928's server check) and upstream's existing atoms. It does not change upstream's navigation list: calm groups that list and never hides from it. No upstream file changes, apart from the seam list.General vs project
All general. No project, machine, account or thread id is in the code; the ids live only in each user's own settings. Works for web and phone alike (client-runtime).
Review
One Opus lens (read-only, state question asked for each part): no blocking findings; types fit PR 3's real atoms and rows without casts. Its three minor points are settled in the second commit and this text: an empty list no longer gets the hint, the usage-limit choice is written down, and the offline row above is worded to what the tests prove.
Checks
client-runtimetypecheck (effect-tsgo tsrs --noEmit): pass.webtypecheck (the same checker onapps/web; the app has no script of its own): pass, 0 errors.vp test run src/state/threadRoles.test.ts: 35 passed (again on the second commit).Error: Cannot find module './threadRoles.ts', test file failed.canHoldRoleon purpose: 4 failed, 31 passed (the archived pointer, unarchive brings it back, the row checked again, and the atom's archive then unarchive).vp lint --report-unused-disable-directiveson the changed files: 0 errors. Pre-commitvp fmt,vp lintandknip:check: pass.vp fmt --check: all files formatted.node .github/scripts/fork-seam-check.cjs --config-ref origin/main origin/main HEAD: exit 0.🤖 Generated with Claude Code