Repository navigation
Calm sidebar part 1: threadRoles and calmSidebarEnabled settings - #928
scuttletoby wants to merge 2 commits into
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 |
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 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.
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, the save is refused with "try again". 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: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).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.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