Repository navigation
Calm sidebar part 1: threadRoles and calmSidebarEnabled settings - #928
Conversation
Adds the person-only server setting threadRoles (one assistant thread, one orchestrator thread per project) and the per-device client setting calmSidebarEnabled, both off by default and read by nothing yet. - Lenient read: a bad hand-edited entry drops alone; an old file reads as no roles. - Per-entry patch: a new "fields" fork patch rule; orchestrators are set or removed (null) one project at a time. - Server save check: a new pointer must name an existing top-level thread (not a sub-agent, side chat or delegated task) of the right project. Fails closed where threads cannot be read. - Seam config announces the client settings patch spread for the sidebar PR that saves the toggle. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
lens: code · reviewer: lens agent (Opus 5.5) · read at: da45995 Answers to the brief's questions:
|
|
lens: code · reviewer: lens agent (Opus 5.5) · read at: da45995 Answers to the brief's questions:
|
|
lens: state · reviewer: lens agent · read at: da45995 |
|
lens: state · reviewer: lens agent · read at: da45995 |
- forkReport.test.ts: threadRoles is a NOT_A_SWITCH row (settings only so far; nothing reads them yet), so the fork report test is green again. - threadRoleTargetsLayer.ts: `delegatedFrom != null`, as upstream's isDelegatedAppThread (an MCP-launched thread may carry null). - threadRoleTargets.ts: an unexpected crash in the thread lookup also gives the "try again" refusal (Effect.exit instead of Effect.option). - New threadRoleTargetsLayer.test.ts: the real lookup layer over a stand-in orchestrator, through the settings service: sub-agent, side chat, delegated task, another project's thread and a missing one refused; a top-level own-project thread (also one with delegatedFrom null) saved. - Docs: a dropped hand-edited entry is gone after the next save; an archived or deleted role thread counts as no role for readers; a removed project's entry stays until a save clears it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
lens: code r2 · reviewer: lens agent (Opus 5.5 high) · read at: 2586f59 |
What and why
The calm sidebar shows the threads that matter (one assistant, one orchestrator per project) at the top. It folds every other top-level thread into one closed group. This PR adds only the settings and the server's save check. Nothing reads them yet, and both are off by default, so a machine behaves exactly as upstream's.
server.threadRoles(new, person-only) has two parts:assistant: a thread id, ornull.orchestrators: one thread id per project id.A role is a pointer stored in the settings, not a tag on the thread. That keeps each project to at most one orchestrator, and only the person can change it.
client.calmSidebarEnabled(new, per device, off) is the switch the sidebar PR will read. It is per device, so a phone can be calm while a desktop shows the full list.Server save check (
apps/server/src/fork/threadRoleTargets.ts). A save that sets a role pointer anew is refused unless the thread:The check reads threads through a small service that the runtime layer provides (
threadRoleTargetsLayer.ts, wired inforkLayers.ts), so the settings file imports no orchestration code. Where that service is missing, a new pointer is refused (fail closed). A refusal is upstream'sServerSettingsError(normalize) with aForkSettingsWriteErrorthat says what to fix. It is the same path the other fork save checks use.Per-entry patch. A new fork patch rule,
fields, changes each field by its own rule:assistantis replaced.orchestratorsis changed per entry;nullremoves one entry.Person-only.
FORK_PERSON_ONLY_KEYSis derived from every fork key, sothreadRolesjoins it with no extra line. A test pins it, and the managed policy can lock it only as a whole.Docs.
docs/fork/README.mdhas the setting rows and sections, andFORK_CHANGES.mdhas a new line.Owner decisions used
threadRolesstays person-only, so the settings tool refuses it for agents. The handoff comes later, through its own dedicated path with its own checks, not through the settings tool.Seams
settings.tsalready spreadsForkServerSettingsFields,ForkServerSettingsPatchFieldsandForkClientSettingsFields.ClientSettingsPatchhas no fork spread yet, and nothing saves a client fork setting yet. So this PR announces...ForkSettings.ForkClientSettingsPatchFields,forpackages/contracts/src/settings.tsin.github/fork-seams.json. The sidebar PR that saves the toggle adds the line (announce, then add).Upstream fit
ServerSettingsError;isListedThreadLineage, which already keeps sub-agents and side chats out of the sidebar;OrchestratorV2.getThreadShell, which returns null for a missing or deleted thread.forkSettings.ts,threadRoles.ts,forkSettingsPatch.ts,apps/server/src/fork/…, fork docs) or in the seam config.General vs project
State question
Old settings file with no roles. It reads as no roles (
{"assistant":null,"orchestrators":{}}). A later save of any other setting leaves the key out of the file, as before. A client settings file withoutcalmSidebarEnabledreads as off. Tested: contracts decode, and a load-then-save through the settings service.A bad entry (hand edit). It drops alone:
assistantreads as none;The other settings are never reset. A dropped entry is gone from the file after the next save of any setting (the save writes the settings as read); the docs say so. A save with a bad id is refused (strict patch).
An old pointer to a thread deleted since. It is not checked again when a save leaves it as it was, so it blocks no other save. Whoever reads the roles (a later PR) checks the thread and treats a failing one as "no role". Tested. An archived thread can take a role; readers treat an archived or deleted role thread as no role (in the docs).
A project removed since. Its orchestrator entry stays in the file (the project override sweep does not cover it) until a save removes it; readers skip it. In the docs.
Settings written half-way. The check runs before anything is written, inside upstream's one-writer semaphore. A refused save writes nothing (tested: the file is unchanged). A save that passes is written with upstream's atomic write (
writeFileStringAtomically, temp file then rename), so a crash leaves the old file or the new one, never a half-written roles state.Two writers at once. Saves are serialised by upstream's semaphore, and each patch is applied to the file as it is then. Two people setting different projects' orchestrators both keep theirs; two saves for the same project, the last one wins. Tested.
Runs again. Saving the same roles again sets no new pointer, so nothing is read or refused.
Server path without thread access. A new pointer is refused ("cannot be checked here"), never let through. Tested. If reading a thread fails, or the lookup crashes unexpectedly (a defect), the save is refused with "try again"; nothing is written either way. Tested.
Tests
packages/contracts/src/threadRoles.test.ts: old file, good value round trip, bad entries drop alone, bad assistant, non-object, strict patch, person-only,calmSidebarEnableddefault.packages/shared/src/forkSettingsThreadRoles.test.ts: per-entry patch (two projects kept,nullremoves one, assistant replaced, left-out or empty keeps).apps/server/src/fork/threadRoleTargets.test.ts:apps/server/src/fork/threadRoleTargetsLayer.test.ts(review round): the real lookup layer (threadRoleTargetsLayer.ts) over a stand-inOrchestratorV2.getThreadShell, through the settings service: sub-agent, side chat, delegated task, another project's thread and a missing one refused (nothing written); a top-level own-project thread saved, also one carryingdelegatedFrom: null(MCP-launched); the shell-to-target mapping.apps/server/src/golive/forkReport.test.ts:threadRolesis aNOT_A_SWITCHrow ("calm sidebar: settings only so far; nothing reads them yet").calmSidebarEnabledis a client key, which that test does not list.Tests fail without the change (shown before opening)
ForkSettingsWrite.check: 2 server tests fail ("refuses a role for a sub-agent, and writes nothing", "refuses a new role where the server cannot read threads").threadRolespatch rule set to plainreplaceinstead of per entry: 4 shared patch tests fail (two projects kept,nullremoves one, and the keep cases).delegatedFrom !== undefined,Effect.option, nothreadRolesreport row): 4 tests fail ("gives the same try-again refusal when the lookup crashes unexpectedly", "maps each shell as the check needs it", "saves a top-level thread of the project as its orchestrator", and the fork report's "counts every fork setting as a feature or names why it is not a switch"); with the fixes all 90 pass.ThreadRolesfields without their decoding defaults: the settings-service test fails on the sparse write ("Missing key assistant"); this was a real bug the test found and the fix is in.Checks run
effect-tsgo): contracts, shared, server, web: 0 errors.threadRoleTargets.test.ts,threadRoleTargetsLayer.test.ts,forkReport.test.ts: 90 pass;vp fmt --checkandvp linton the 6 touched files clean; pre-commit (fmt, lint, knip) pass; seam check exit 0. The seam announcement'ssinceis 2026-11-22 (today); refresh it to the merge day if this merges later.origin/main: exit 0.vp fmt --checkon the 15 touched files: clean. Pre-commit (fmt, lint, knip): pass.Part of the calm sidebar design (PR 1 of N)
Later, the owner-approved handoff of an orchestrator's role (#140) comes through its own path.
🤖 Generated with Claude Code