From beb883cdb2b1305726b7fe533ccac726a41dc3c0 Mon Sep 17 00:00:00 2001
From: scuttletoby <123843277+scuttletoby@users.noreply.github.com>
Date: Thu, 19 Nov 2026 17:31:24 +0100
Subject: [PATCH 1/4] feat(web): Fork settings page rows for automatic updates,
handoff and playtest
These fork settings had no screen. Settings > Fork gets three sections:
- Updates (server only): "Update automatically" and the quiet check program asked before an
automatic update.
- Handoff: the mode (Off, Handoff, Compact), each thread's own mode (added by thread id, shown
with its title where this client knows the thread, removable), and under Advanced the size and
idle sizes, who writes the handoff with its command (one argument per line) and the instructions.
- Playtest: the switch, which stays off until claim, renew, push and release are set; the steps as
JSON in a dialog, checked as the server's save checks them; the renew, idle and session limits
under Advanced.
Handoff and playtest are project-scoped and replace the environment's value whole, so a change on a
project screen saves the whole value it shows as the project's own, and the row's override control
clears it. The page leaves a marked place for MCP profiles. Every new row is in the settings search.
Co-Authored-By: Claude Opus 5.5
---
FORK_CHANGES.md | 60 +--
.../settings/fork/CommitTextField.tsx | 68 ++++
.../settings/fork/ForkPanels.browser.test.tsx | 189 ++++++++++
.../settings/fork/ForkSettingsPanel.tsx | 7 +
.../settings/fork/HandoffSettings.tsx | 344 ++++++++++++++++++
.../settings/fork/PlaytestSettings.tsx | 274 ++++++++++++++
.../settings/fork/UpdatesSettings.tsx | 93 +++++
.../fork/handoffSettings.logic.test.ts | 73 ++++
.../settings/fork/handoffSettings.logic.ts | 88 +++++
.../fork/playtestSettings.logic.test.ts | 68 ++++
.../settings/fork/playtestSettings.logic.ts | 67 ++++
.../settings/forkSettingsSearchItems.ts | 104 ++++++
docs/fork/README.md | 14 +-
13 files changed, 1417 insertions(+), 32 deletions(-)
create mode 100644 apps/web/src/components/settings/fork/CommitTextField.tsx
create mode 100644 apps/web/src/components/settings/fork/ForkPanels.browser.test.tsx
create mode 100644 apps/web/src/components/settings/fork/HandoffSettings.tsx
create mode 100644 apps/web/src/components/settings/fork/PlaytestSettings.tsx
create mode 100644 apps/web/src/components/settings/fork/UpdatesSettings.tsx
create mode 100644 apps/web/src/components/settings/fork/handoffSettings.logic.test.ts
create mode 100644 apps/web/src/components/settings/fork/handoffSettings.logic.ts
create mode 100644 apps/web/src/components/settings/fork/playtestSettings.logic.test.ts
create mode 100644 apps/web/src/components/settings/fork/playtestSettings.logic.ts
diff --git a/FORK_CHANGES.md b/FORK_CHANGES.md
index c99b0ea304364..3a52b49d0e5d5 100644
--- a/FORK_CHANGES.md
+++ b/FORK_CHANGES.md
@@ -12,36 +12,36 @@ setting is missing here or a setting named here does not exist.
## In T3 Code itself
-| Change | Why | Setting | Default | PR |
-| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| The server, the CLI and the desktop app look for updates in this fork's releases, not upstream's. | A fork build must never "update" to an upstream build and lose the fork's changes. | none | always | [#1](https://github.com/scuttletoby/t3code/pull/1) |
-| A server installed as a boot service can update itself once no thread is working, after an optional "is it quiet?" command agrees. | Updates without someone watching, and without cutting off running work. | `server.automaticUpdates`, `server.automaticUpdatesQuietCommand` | off | [#5](https://github.com/scuttletoby/t3code/pull/5) |
-| Every fork setting has a pinned default, and lives in the fork's own file (`forkSettings.ts`). | An upstream sync can never switch a fork feature on, and a new setting touches no upstream file. | none | always | [#171](https://github.com/scuttletoby/t3code/pull/171), [#185](https://github.com/scuttletoby/t3code/pull/185) |
-| The server keeps a history of each provider account's usage-limit readings. | Pacing needs to know how fast a limit is being used, not only where it stands. | none | always (read only) | [#24](https://github.com/scuttletoby/t3code/pull/24) |
-| The server reads usage limits every 10 minutes while no app is open. | Pacing has current numbers on a machine nobody is looking at. | `server.headlessUsageRefreshInterval` | on (10 minutes); read only | [#42](https://github.com/scuttletoby/t3code/pull/42) |
-| Usage pacing: a reserve of each limit window kept free for the person, and an even pace for agents. | Agents should not use up a subscription before its owner needs it. | `server.usagePacing` | off | [#52](https://github.com/scuttletoby/t3code/pull/52) |
-| The pacing gate on `delegate_task`: advise only, or move, lower the effort of, or hold a task on an account that is ahead of pace. | Delegated work follows the pace without the agent having to check. | `server.usagePacingGate`, `server.usagePacingLowerEffort` | off | [#73](https://github.com/scuttletoby/t3code/pull/73) |
-| Agent slots: `delegate_task` is refused above a number of running agents per machine or account, or below a memory floor. | Too many agents at once can overload a small machine. | `server.agentSlots` | off; rule only observes | [#84](https://github.com/scuttletoby/t3code/pull/84), [#89](https://github.com/scuttletoby/t3code/pull/89) |
-| Waits: agents can wait for a pull request, a file, a system unit, a named check command or a free agent slot (`wait_for`, `wait_list`, `wait_cancel`), and are woken when it happens. | An agent no longer polls or sleeps while it waits. | `server.waitFor`, `server.waitChecks`, `projectOverride.waitChecks` | off | [#84](https://github.com/scuttletoby/t3code/pull/84), [#90](https://github.com/scuttletoby/t3code/pull/90), [#91](https://github.com/scuttletoby/t3code/pull/91), [#103](https://github.com/scuttletoby/t3code/pull/103), [#106](https://github.com/scuttletoby/t3code/pull/106), [#109](https://github.com/scuttletoby/t3code/pull/109), [#110](https://github.com/scuttletoby/t3code/pull/110), [#116](https://github.com/scuttletoby/t3code/pull/116), [#119](https://github.com/scuttletoby/t3code/pull/119) |
-| The Settings page **Fork** (`/settings/fork`): every fork setting in one place, with one line per feature at the top saying whether it is on. So far: waits, wait checks, agent slots, usage pacing (per account by name), model policy and review rules. | Change every fork setting without editing a file. | `server.waitFor`, `server.waitChecks`, `server.agentSlots`, `server.usagePacing`, `server.usagePacingGate`, `server.usagePacingLowerEffort`, `server.reviewRules`, `server.modelPolicy` | off | [#104](https://github.com/scuttletoby/t3code/pull/104) |
-| The fork's checks on `delegate_task` (pacing, slots) sit behind one fork module. | Fewer fork lines in upstream's code, so syncs conflict less. No change in behaviour. | none | always | [#174](https://github.com/scuttletoby/t3code/pull/174) |
-| The fork's service layers in the server are wired from one fork file (`apps/server/src/fork/forkLayers.ts`). | Fewer fork lines in upstream's code, so syncs conflict less. No change in behaviour. | none | always | [#384](https://github.com/scuttletoby/t3code/pull/384) |
-| A pure capacity rule for "dynamic slots" (one budget per machine), with shared test cases. Not wired into anything yet. | A later step replaces fixed agent counts with what the machine can take. | none | not used | [#203](https://github.com/scuttletoby/t3code/pull/203) |
-| File links in chat open in the files viewer, full size, or in an editor on a remote machine, and can be downloaded, from their menu. | File links were only copyable on remote machines and had no menu on touch screens. | none | always | [#17](https://github.com/scuttletoby/t3code/pull/17) |
-| A hidden read-only command, `t3 __fork-report --base-dir `, prints what a T3 home holds and which fork features are on, and where. | The go-live kit checks a build and a home before switching, without writing anything. | none | only when run | [#172](https://github.com/scuttletoby/t3code/pull/172), [#184](https://github.com/scuttletoby/t3code/pull/184) |
-| A local, read-only "is T3 busy?" answer: `GET /api/fork/activity` on loopback, and `t3 __fork-report --base-dir --activity`, which asks it and exits 0 only when nothing is working. | A host quiet check reads T3's own turns and approvals instead of guessing from processes. | `server.activityProbe` | off | [#547](https://github.com/scuttletoby/t3code/pull/547) |
-| `t3 serve --hold-work` starts a server on a copy of a T3 home with all agent work and T3 Connect held. | Look at a new build's threads and migrations on a copy before it replaces a running T3. | none | only with the flag | [#175](https://github.com/scuttletoby/t3code/pull/175) |
-| Docs: one machine for new work through upstream's load-balancing weights; settings saved with an early draft's client setting for it still load. | Upstream already has the feature, so the fork's own setting was removed. | none | - | [#25](https://github.com/scuttletoby/t3code/pull/25) |
-| MCP profiles: named profiles (which outside MCP servers and T3 tool groups a thread gets), a default, a sub-agent rule, a pick per thread and the rules that pick one. Claude applies the outside servers and refuses a turn when its profile cannot. | Fewer tools per thread saves tokens and keeps agents from tools they should not use. | `server.mcpProfiles`, `server.mcpProfile`, `server.mcpSubagentProfile`, `server.mcpThreadProfiles`, `projectOverride.mcpProfile`, `projectOverride.mcpSubagentProfile` | off | [#227](https://github.com/scuttletoby/t3code/pull/227), [#528](https://github.com/scuttletoby/t3code/pull/528) |
-| Playtest mode, part 1: settings for a project's playtest adapter (claim, renew, push and release steps only the person sets) and the contract those steps follow. Nothing starts a session yet. | A person tries an agent's unfinished work on a test target, round after round, no PR per round. | `server.playtest`, `projectOverride.playtest` | off | [#260](https://github.com/scuttletoby/t3code/pull/260) |
-| Playtest mode, part 2: the session store and service: start (claim), rounds of push steps, end (release), kept across restarts. A session keeps the steps it started with. No tool calls it yet. | A person tries an agent's unfinished work on a test target, round after round, no PR per round. | `server.playtest`, `projectOverride.playtest` | off | [#261](https://github.com/scuttletoby/t3code/pull/261) |
-| Playtest mode, part 3: the worker renews claims, ends idle, too-long and gone-thread sessions, finishes what a restart cut, and tells the thread once when T3 ended a session. | A person tries an agent's unfinished work on a test target, round after round, no PR per round. | `server.playtest`, `projectOverride.playtest` | off | [#262](https://github.com/scuttletoby/t3code/pull/262) |
-| Handoff instead of compaction, part 1: the setting and the pure "should this thread hand off now?" decision. Nothing acts on it yet. | Long threads keep their children, PRs and waits instead of compacting. | `server.handoff`, `projectOverride.handoff` | off | [#282](https://github.com/scuttletoby/t3code/pull/282) |
-| Review rules, part 1: the setting for how this machine runs a review lens (runner, state question), off by default; `{"preset": "recommended"}` turns the fork's defaults on. A bad hand edit reads as off and is kept. Nothing reads it yet. | The repo says what a pull request needs and CI enforces it; the machine says how reviews run. | `server.reviewRules`, `projectOverride.reviewRules` | off | [#291](https://github.com/scuttletoby/t3code/pull/291) |
-| An interval setting the settings file cannot hold (negative, not finite, too large) is refused when saved; one already in the file reads as its default instead of resetting every setting. A test finds every interval setting from the schema. | A `1e400` saved as `null` made the next start reject the whole settings file. | none | always | [#323](https://github.com/scuttletoby/t3code/pull/323) |
-| Handoff instead of compaction, part 2: the handoff service hands a big or idle thread to a fresh session in the same thread, with T3's state and the recent conversation, only while the thread is quiet and still at the run that triggered it. | Long threads keep their children, PRs and waits instead of compacting. | `server.handoff`, `projectOverride.handoff` | off | [#320](https://github.com/scuttletoby/t3code/pull/320) |
-| A task delegated to a linked environment is still followed if the delegating call is cut off, and still delivers its reply when that environment runs another T3 version. | Its parent was never told: the task stayed running here and its result never arrived. | none | always | [#412](https://github.com/scuttletoby/t3code/pull/412), [#540](https://github.com/scuttletoby/t3code/pull/540) |
-| Model policy, part 1: the setting for which models (and efforts) agents may pick, per provider driver: off, advise or enforce, and the allowed rows. A bad hand edit reads as nothing allowed. Nothing reads the setting yet. | Agents should use the models the person chose for each kind of work. | `server.modelPolicy` | off | [#268](https://github.com/scuttletoby/t3code/pull/268) |
+| Change | Why | Setting | Default | PR |
+| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| The server, the CLI and the desktop app look for updates in this fork's releases, not upstream's. | A fork build must never "update" to an upstream build and lose the fork's changes. | none | always | [#1](https://github.com/scuttletoby/t3code/pull/1) |
+| A server installed as a boot service can update itself once no thread is working, after an optional "is it quiet?" command agrees. | Updates without someone watching, and without cutting off running work. | `server.automaticUpdates`, `server.automaticUpdatesQuietCommand` | off | [#5](https://github.com/scuttletoby/t3code/pull/5) |
+| Every fork setting has a pinned default, and lives in the fork's own file (`forkSettings.ts`). | An upstream sync can never switch a fork feature on, and a new setting touches no upstream file. | none | always | [#171](https://github.com/scuttletoby/t3code/pull/171), [#185](https://github.com/scuttletoby/t3code/pull/185) |
+| The server keeps a history of each provider account's usage-limit readings. | Pacing needs to know how fast a limit is being used, not only where it stands. | none | always (read only) | [#24](https://github.com/scuttletoby/t3code/pull/24) |
+| The server reads usage limits every 10 minutes while no app is open. | Pacing has current numbers on a machine nobody is looking at. | `server.headlessUsageRefreshInterval` | on (10 minutes); read only | [#42](https://github.com/scuttletoby/t3code/pull/42) |
+| Usage pacing: a reserve of each limit window kept free for the person, and an even pace for agents. | Agents should not use up a subscription before its owner needs it. | `server.usagePacing` | off | [#52](https://github.com/scuttletoby/t3code/pull/52) |
+| The pacing gate on `delegate_task`: advise only, or move, lower the effort of, or hold a task on an account that is ahead of pace. | Delegated work follows the pace without the agent having to check. | `server.usagePacingGate`, `server.usagePacingLowerEffort` | off | [#73](https://github.com/scuttletoby/t3code/pull/73) |
+| Agent slots: `delegate_task` is refused above a number of running agents per machine or account, or below a memory floor. | Too many agents at once can overload a small machine. | `server.agentSlots` | off; rule only observes | [#84](https://github.com/scuttletoby/t3code/pull/84), [#89](https://github.com/scuttletoby/t3code/pull/89) |
+| Waits: agents can wait for a pull request, a file, a system unit, a named check command or a free agent slot (`wait_for`, `wait_list`, `wait_cancel`), and are woken when it happens. | An agent no longer polls or sleeps while it waits. | `server.waitFor`, `server.waitChecks`, `projectOverride.waitChecks` | off | [#84](https://github.com/scuttletoby/t3code/pull/84), [#90](https://github.com/scuttletoby/t3code/pull/90), [#91](https://github.com/scuttletoby/t3code/pull/91), [#103](https://github.com/scuttletoby/t3code/pull/103), [#106](https://github.com/scuttletoby/t3code/pull/106), [#109](https://github.com/scuttletoby/t3code/pull/109), [#110](https://github.com/scuttletoby/t3code/pull/110), [#116](https://github.com/scuttletoby/t3code/pull/116), [#119](https://github.com/scuttletoby/t3code/pull/119) |
+| The Settings page **Fork** (`/settings/fork`): every fork setting in one place, with one line per feature at the top saying whether it is on: waits, wait checks, agent slots, usage pacing (per account by name), model policy, review rules, automatic updates, handoff and playtest. MCP profiles are not on it yet. | Change every fork setting without editing a file. | `server.waitFor`, `server.waitChecks`, `server.agentSlots`, `server.usagePacing`, `server.usagePacingGate`, `server.usagePacingLowerEffort`, `server.reviewRules`, `server.modelPolicy`, `server.automaticUpdates`, `server.automaticUpdatesQuietCommand`, `server.handoff`, `server.playtest` | off | [#104](https://github.com/scuttletoby/t3code/pull/104), [#543](https://github.com/scuttletoby/t3code/pull/543) |
+| The fork's checks on `delegate_task` (pacing, slots) sit behind one fork module. | Fewer fork lines in upstream's code, so syncs conflict less. No change in behaviour. | none | always | [#174](https://github.com/scuttletoby/t3code/pull/174) |
+| The fork's service layers in the server are wired from one fork file (`apps/server/src/fork/forkLayers.ts`). | Fewer fork lines in upstream's code, so syncs conflict less. No change in behaviour. | none | always | [#384](https://github.com/scuttletoby/t3code/pull/384) |
+| A pure capacity rule for "dynamic slots" (one budget per machine), with shared test cases. Not wired into anything yet. | A later step replaces fixed agent counts with what the machine can take. | none | not used | [#203](https://github.com/scuttletoby/t3code/pull/203) |
+| File links in chat open in the files viewer, full size, or in an editor on a remote machine, and can be downloaded, from their menu. | File links were only copyable on remote machines and had no menu on touch screens. | none | always | [#17](https://github.com/scuttletoby/t3code/pull/17) |
+| A hidden read-only command, `t3 __fork-report --base-dir `, prints what a T3 home holds and which fork features are on, and where. | The go-live kit checks a build and a home before switching, without writing anything. | none | only when run | [#172](https://github.com/scuttletoby/t3code/pull/172), [#184](https://github.com/scuttletoby/t3code/pull/184) |
+| A local, read-only "is T3 busy?" answer: `GET /api/fork/activity` on loopback, and `t3 __fork-report --base-dir --activity`, which asks it and exits 0 only when nothing is working. | A host quiet check reads T3's own turns and approvals instead of guessing from processes. | `server.activityProbe` | off | [#547](https://github.com/scuttletoby/t3code/pull/547) |
+| `t3 serve --hold-work` starts a server on a copy of a T3 home with all agent work and T3 Connect held. | Look at a new build's threads and migrations on a copy before it replaces a running T3. | none | only with the flag | [#175](https://github.com/scuttletoby/t3code/pull/175) |
+| Docs: one machine for new work through upstream's load-balancing weights; settings saved with an early draft's client setting for it still load. | Upstream already has the feature, so the fork's own setting was removed. | none | - | [#25](https://github.com/scuttletoby/t3code/pull/25) |
+| MCP profiles: named profiles (which outside MCP servers and T3 tool groups a thread gets), a default, a sub-agent rule, a pick per thread and the rules that pick one. Claude applies the outside servers and refuses a turn when its profile cannot. | Fewer tools per thread saves tokens and keeps agents from tools they should not use. | `server.mcpProfiles`, `server.mcpProfile`, `server.mcpSubagentProfile`, `server.mcpThreadProfiles`, `projectOverride.mcpProfile`, `projectOverride.mcpSubagentProfile` | off | [#227](https://github.com/scuttletoby/t3code/pull/227), [#528](https://github.com/scuttletoby/t3code/pull/528) |
+| Playtest mode, part 1: settings for a project's playtest adapter (claim, renew, push and release steps only the person sets) and the contract those steps follow. Nothing starts a session yet. | A person tries an agent's unfinished work on a test target, round after round, no PR per round. | `server.playtest`, `projectOverride.playtest` | off | [#260](https://github.com/scuttletoby/t3code/pull/260) |
+| Playtest mode, part 2: the session store and service: start (claim), rounds of push steps, end (release), kept across restarts. A session keeps the steps it started with. No tool calls it yet. | A person tries an agent's unfinished work on a test target, round after round, no PR per round. | `server.playtest`, `projectOverride.playtest` | off | [#261](https://github.com/scuttletoby/t3code/pull/261) |
+| Playtest mode, part 3: the worker renews claims, ends idle, too-long and gone-thread sessions, finishes what a restart cut, and tells the thread once when T3 ended a session. | A person tries an agent's unfinished work on a test target, round after round, no PR per round. | `server.playtest`, `projectOverride.playtest` | off | [#262](https://github.com/scuttletoby/t3code/pull/262) |
+| Handoff instead of compaction, part 1: the setting and the pure "should this thread hand off now?" decision. Nothing acts on it yet. | Long threads keep their children, PRs and waits instead of compacting. | `server.handoff`, `projectOverride.handoff` | off | [#282](https://github.com/scuttletoby/t3code/pull/282) |
+| Review rules, part 1: the setting for how this machine runs a review lens (runner, state question), off by default; `{"preset": "recommended"}` turns the fork's defaults on. A bad hand edit reads as off and is kept. Nothing reads it yet. | The repo says what a pull request needs and CI enforces it; the machine says how reviews run. | `server.reviewRules`, `projectOverride.reviewRules` | off | [#291](https://github.com/scuttletoby/t3code/pull/291) |
+| An interval setting the settings file cannot hold (negative, not finite, too large) is refused when saved; one already in the file reads as its default instead of resetting every setting. A test finds every interval setting from the schema. | A `1e400` saved as `null` made the next start reject the whole settings file. | none | always | [#323](https://github.com/scuttletoby/t3code/pull/323) |
+| Handoff instead of compaction, part 2: the handoff service hands a big or idle thread to a fresh session in the same thread, with T3's state and the recent conversation, only while the thread is quiet and still at the run that triggered it. | Long threads keep their children, PRs and waits instead of compacting. | `server.handoff`, `projectOverride.handoff` | off | [#320](https://github.com/scuttletoby/t3code/pull/320) |
+| A task delegated to a linked environment is still followed if the delegating call is cut off, and still delivers its reply when that environment runs another T3 version. | Its parent was never told: the task stayed running here and its result never arrived. | none | always | [#412](https://github.com/scuttletoby/t3code/pull/412), [#540](https://github.com/scuttletoby/t3code/pull/540) |
+| Model policy, part 1: the setting for which models (and efforts) agents may pick, per provider driver: off, advise or enforce, and the allowed rows. A bad hand edit reads as nothing allowed. Nothing reads the setting yet. | Agents should use the models the person chose for each kind of work. | `server.modelPolicy` | off | [#268](https://github.com/scuttletoby/t3code/pull/268) |
## Repository, CI and releases
diff --git a/apps/web/src/components/settings/fork/CommitTextField.tsx b/apps/web/src/components/settings/fork/CommitTextField.tsx
new file mode 100644
index 0000000000000..66591992feca5
--- /dev/null
+++ b/apps/web/src/components/settings/fork/CommitTextField.tsx
@@ -0,0 +1,68 @@
+/** Fork: a text field that saves on blur or Enter (multi-line: blur only) and shows why a value cannot be saved. */
+import { useState } from "react";
+
+import { Input } from "../../ui/input";
+import { Textarea } from "../../ui/textarea";
+
+export function CommitTextField({
+ value,
+ onCommit,
+ ariaLabel,
+ placeholder,
+ multiline = false,
+ disabled = false,
+}: {
+ readonly value: string;
+ /** Saves `text`; returns why it cannot be saved, or null. `revert` puts the stored value back. */
+ readonly onCommit: (text: string, revert: () => void) => string | null;
+ readonly ariaLabel: string;
+ readonly placeholder?: string;
+ readonly multiline?: boolean;
+ readonly disabled?: boolean;
+}) {
+ const [draft, setDraft] = useState({ saved: value, text: value });
+ const [error, setError] = useState(null);
+ if (draft.saved !== value) setDraft({ saved: value, text: value });
+
+ const commit = () => {
+ if (draft.text === value) return;
+ setError(onCommit(draft.text, () => setDraft({ saved: value, text: value })));
+ };
+ const change = (text: string) => {
+ setError(null);
+ setDraft({ ...draft, text });
+ };
+
+ return (
+
+ {multiline ? (
+
+ );
+}
diff --git a/apps/web/src/components/settings/fork/ForkPanels.browser.test.tsx b/apps/web/src/components/settings/fork/ForkPanels.browser.test.tsx
new file mode 100644
index 0000000000000..0faeb1f759a69
--- /dev/null
+++ b/apps/web/src/components/settings/fork/ForkPanels.browser.test.tsx
@@ -0,0 +1,189 @@
+import { type ManagedPolicySummary, ServerSettings } from "@t3tools/contracts";
+import * as Schema from "effect/Schema";
+import { describe, expect, it, vi } from "vite-plus/test";
+import { page, userEvent } from "vite-plus/test/browser";
+
+import "~/index.css";
+import { render } from "../../../../test/render";
+
+type Settings = ServerSettings;
+type UpdateOptions = { readonly onFailed?: () => void; readonly onSaved?: () => void };
+
+const state = vi.hoisted(() => ({
+ settings: {} as Settings,
+ environments: [] as Array<{
+ environmentId: string;
+ providers: Array<{ instanceId: string; displayName: string }>;
+ managedPolicy?: ManagedPolicySummary;
+ }>,
+ update: vi.fn((_patch: unknown, _options?: UpdateOptions) => {}),
+}));
+
+function scope() {
+ const environments = state.environments.map(({ environmentId, managedPolicy }) => ({
+ environmentId,
+ label: environmentId,
+ connection: { phase: "connected" },
+ serverConfig: {
+ settings: state.settings,
+ environment: { capabilities: {}, platform: { os: "linux", arch: "x64", machine: "server" } },
+ ...(managedPolicy ? { managedPolicy } : {}),
+ },
+ }));
+ return {
+ scope: {
+ kind: "all",
+ label: "All",
+ members: [],
+ environmentIds: environments.map(({ environmentId }) => environmentId),
+ },
+ environments,
+ connectedEnvironments: environments,
+ environment: environments[0] ?? null,
+ targets: environments.map(({ environmentId }) => ({
+ environmentId,
+ label: environmentId,
+ projectId: null,
+ settings: state.settings,
+ sources: {},
+ })),
+ target: null,
+ };
+}
+
+vi.mock(import("../SettingsScopeContext"), async (original) => ({
+ ...(await original()),
+ useSettingsScope: scope as never,
+ useOptionalSettingsScope: scope as never,
+}));
+vi.mock(import("../useScopedSettings"), async (original) => ({
+ ...(await original()),
+ useScopedSettings: ((select: (settings: Settings) => unknown) => select(state.settings)) as never,
+ useScopedSettingsMixed: () => false,
+ useScopedSettingsWriteAllowed: () => true,
+ useUpdateScopedSettings: (() => state.update) as never,
+ useClearScopedSettings: (() => vi.fn()) as never,
+ useClearProjectOverrides: (() => vi.fn()) as never,
+}));
+vi.mock(import("../../../state/environments"), async (original) => ({
+ ...(await original()),
+ useEnvironmentProviders: (() =>
+ new Map(
+ state.environments.map(({ environmentId, providers }) => [environmentId, providers]),
+ )) as never,
+}));
+vi.mock(import("../../../state/entities"), async (original) => ({
+ ...(await original()),
+ useThreadShells: (() => [{ id: "thread-1", title: "Fix the login page" }]) as never,
+}));
+vi.mock(import("../../../state/session"), async (original) => ({
+ ...(await original()),
+ useEnvironmentsWithScope: ((environments: ReadonlyArray<{ environmentId: string }>) =>
+ new Set(environments.map(({ environmentId }) => environmentId))) as never,
+}));
+
+import { HandoffSettings } from "./HandoffSettings";
+import { PlaytestSettings } from "./PlaytestSettings";
+import { UpdatesSettings } from "./UpdatesSettings";
+
+const decodeServerSettings = Schema.decodeUnknownSync(ServerSettings);
+
+/** The settings a server reads from `file`, so an old or empty file is tested as it loads. */
+function setup(file: object) {
+ state.settings = decodeServerSettings(file);
+ state.environments = [{ environmentId: "env-a", providers: [] }];
+ state.update.mockReset();
+}
+
+const STEPS = {
+ claim: { argv: ["/usr/local/bin/game", "claim"] },
+ renew: { argv: ["/usr/local/bin/game", "renew"] },
+ push: [{ name: "deploy", argv: ["/usr/local/bin/game", "deploy"] }],
+ release: { argv: ["/usr/local/bin/game", "release"] },
+};
+
+describe("UpdatesSettings", () => {
+ it("writes automatic updates and the quiet check from an empty settings file", async () => {
+ setup({});
+ await using screen = await render();
+
+ const toggle = screen.getByRole("switch", { name: "Update automatically" });
+ await expect.element(toggle).not.toBeChecked();
+ await userEvent.click(toggle);
+ expect(state.update.mock.calls[0]![0]).toEqual({ automaticUpdates: true });
+
+ await userEvent.type(
+ screen.getByRole("textbox", { name: "Quiet check before an update" }),
+ " /usr/local/bin/quiet {Enter}",
+ );
+ expect(state.update.mock.calls[1]![0]).toEqual({
+ automaticUpdatesQuietCommand: "/usr/local/bin/quiet",
+ });
+ });
+});
+
+describe("HandoffSettings", () => {
+ it("writes the whole value with the new mode, and adds a thread by id", async () => {
+ setup({});
+ await using screen = await render();
+ const empty = state.settings.handoff;
+
+ await userEvent.click(screen.getByRole("combobox", { name: "Handoff mode" }));
+ await userEvent.click(page.getByRole("option", { name: "Handoff" }));
+ expect(state.update.mock.calls[0]![0]).toEqual({ handoff: { ...empty, mode: "handoff" } });
+
+ await userEvent.type(screen.getByRole("textbox", { name: "Thread id" }), "thread-1{Enter}");
+ expect(state.update.mock.calls[1]![0]).toEqual({
+ handoff: { ...empty, threads: { "thread-1": "compact" } },
+ });
+ });
+
+ it("lists a stored thread by its title and removes it", async () => {
+ setup({ handoff: { mode: "handoff", threads: { "thread-1": "compact" } } });
+ await using screen = await render();
+
+ await expect.element(screen.getByText("Fix the login page")).toBeVisible();
+ await userEvent.click(
+ screen.getByRole("button", { name: "Remove the handoff mode of thread thread-1" }),
+ );
+ expect(state.update.mock.calls[0]![0]).toEqual({
+ handoff: { ...state.settings.handoff, threads: {} },
+ });
+ });
+});
+
+describe("PlaytestSettings", () => {
+ it("keeps the switch off until the steps are set, then saves edited steps whole", async () => {
+ setup({});
+ await using screen = await render();
+
+ await expect.element(screen.getByRole("switch", { name: "Playtest sessions" })).toBeDisabled();
+ await userEvent.click(screen.getByRole("button", { name: "Edit steps" }));
+ const dialog = page.getByRole("dialog");
+ const steps = dialog.getByRole("textbox", { name: "Playtest steps" });
+ await userEvent.clear(steps);
+ await userEvent.type(steps, "not json");
+ await userEvent.click(dialog.getByRole("button", { name: "Save steps" }));
+ await expect.element(dialog.getByRole("alert")).toBeVisible();
+ expect(state.update).not.toHaveBeenCalled();
+
+ await userEvent.clear(steps);
+ await userEvent.fill(steps, JSON.stringify(STEPS));
+ await userEvent.click(dialog.getByRole("button", { name: "Save steps" }));
+ const saved = (state.update.mock.calls[0]![0] as { playtest: typeof state.settings.playtest })
+ .playtest;
+ expect(saved.enabled).toBe(false);
+ expect(saved.push.map((step) => step.name)).toEqual(["deploy"]);
+ expect(saved.release?.argv).toEqual(STEPS.release.argv);
+ });
+
+ it("switches a complete adapter on and off", async () => {
+ setup({ playtest: STEPS });
+ await using screen = await render();
+
+ await userEvent.click(screen.getByRole("switch", { name: "Playtest sessions" }));
+ expect(state.update.mock.calls[0]![0]).toEqual({
+ playtest: { ...state.settings.playtest, enabled: true },
+ });
+ });
+});
diff --git a/apps/web/src/components/settings/fork/ForkSettingsPanel.tsx b/apps/web/src/components/settings/fork/ForkSettingsPanel.tsx
index 95a3da387ea91..8a7e3fc037adc 100644
--- a/apps/web/src/components/settings/fork/ForkSettingsPanel.tsx
+++ b/apps/web/src/components/settings/fork/ForkSettingsPanel.tsx
@@ -12,6 +12,9 @@ import { SettingsPageContainer, SettingsRow, SettingsSection } from "../settings
import { useSearchableSetting } from "../settingsSearch";
import { WaitsAndSlotsSettings } from "../WaitsAndSlotsSettings";
import { forkFeatureStatuses } from "./forkStatus.logic";
+import { HandoffSettings } from "./HandoffSettings";
+import { PlaytestSettings } from "./PlaytestSettings";
+import { UpdatesSettings } from "./UpdatesSettings";
import { ModelPolicySettings } from "./ModelPolicySettings";
import { UsagePacingSettings } from "./UsagePacingSettings";
@@ -41,6 +44,10 @@ export function ForkSettingsPanel() {
+ {isProjectScope ? null : }
+
+
+ {/* MCP profiles (server.mcpProfiles and the profile picks) get their section here. */}
);
}
diff --git a/apps/web/src/components/settings/fork/HandoffSettings.tsx b/apps/web/src/components/settings/fork/HandoffSettings.tsx
new file mode 100644
index 0000000000000..4e5a1603754e8
--- /dev/null
+++ b/apps/web/src/components/settings/fork/HandoffSettings.tsx
@@ -0,0 +1,344 @@
+/**
+ * Fork: handoff instead of compaction (`handoff`). A project's value replaces the environment's
+ * whole, so a change on a project screen saves the whole value it shows as the project's own. Every
+ * write is an ordinary settings patch from the person at the screen; agents cannot change it.
+ */
+/* oxlint-disable t3code/no-untranslated-copy -- Fork: this panel is the fork's own and its text is English only; upstream's translation catalogs hold no fork keys. */
+import {
+ DEFAULT_HANDOFF_SETTINGS,
+ HANDOFF_MIN_TOKENS,
+ type HandoffMode,
+ type HandoffSettings as HandoffValue,
+ type HandoffSource,
+} from "@t3tools/contracts";
+import { useState } from "react";
+
+import { useThreadShells } from "../../../state/entities";
+import { Button } from "../../ui/button";
+import { Input } from "../../ui/input";
+import { Select, SelectItem, SelectPopup, SelectTrigger, SelectValue } from "../../ui/select";
+import { AdvancedSettings } from "../AdvancedSettings";
+import { IntervalSecondsField } from "../IntervalSecondsField";
+import { SettingResetButton, SettingsRow, SettingsSection } from "../settingsLayout";
+import { useSearchableSetting } from "../settingsSearch";
+import {
+ useClearScopedSettings,
+ useScopedSettingSource,
+ useScopedSettings,
+ useScopedSettingsMixed,
+ useUpdateScopedSettings,
+} from "../useScopedSettings";
+import { CommitTextField } from "./CommitTextField";
+import {
+ HANDOFF_MODE_OPTIONS,
+ formatArgvLines,
+ handoffModeLabel,
+ handoffSourceProblem,
+ handoffThreadRows,
+ parseArgvLines,
+ threadModeProblem,
+ withThreadMode,
+} from "./handoffSettings.logic";
+
+const MIXED =
+ "The selected environments or projects have different handoff settings. Select one to edit them.";
+
+const SOURCE_LABELS: Record = {
+ agent: "The old session",
+ command: "A command",
+};
+
+function ModeSelect({
+ value,
+ label,
+ onChange,
+}: {
+ readonly value: HandoffMode;
+ readonly label: string;
+ readonly onChange: (mode: HandoffMode) => void;
+}) {
+ return (
+
+ );
+}
+
+export function HandoffSettings({ isProjectScope }: { readonly isProjectScope: boolean }) {
+ const searchableSetting = useSearchableSetting();
+ const updateSettings = useUpdateScopedSettings();
+ const clearScopedSettings = useClearScopedSettings();
+ const source = useScopedSettingSource(["handoff"]);
+ const mixed = useScopedSettingsMixed(["handoff"]) || source === "mixed";
+ const shown = useScopedSettings((settings) => settings.handoff);
+ const titles = new Map(useThreadShells().map((thread) => [thread.id as string, thread.title]));
+ const [threadDraft, setThreadDraft] = useState<{ id: string; mode: HandoffMode }>({
+ id: "",
+ mode: "compact",
+ });
+ const [threadError, setThreadError] = useState(null);
+ const [sourceError, setSourceError] = useState(null);
+
+ const save = (next: HandoffValue, onFailed?: () => void) =>
+ updateSettings({ handoff: next }, onFailed ? { onFailed } : undefined);
+ const option = HANDOFF_MODE_OPTIONS.find((candidate) => candidate.value === shown.mode);
+ const scopeNote = !isProjectScope
+ ? ""
+ : source === "project"
+ ? " This project's value replaces the environment's whole."
+ : " A change here gives this project its own copy of the environment's value.";
+ const rows = handoffThreadRows(shown.threads, titles);
+ const addThread = () => {
+ const problem = threadModeProblem(shown, threadDraft.id);
+ if (problem !== null) {
+ setThreadError(problem);
+ return;
+ }
+ setThreadError(null);
+ save(withThreadMode(shown, threadDraft.id.trim(), threadDraft.mode));
+ setThreadDraft({ ...threadDraft, id: "" });
+ };
+
+ if (mixed) {
+ return (
+
+
+
+ );
+ }
+
+ return (
+
+ clearScopedSettings(["handoff"])}
+ description={`${option?.description ?? ""}${scopeNote}`}
+ resetAction={
+ !isProjectScope && shown.mode !== DEFAULT_HANDOFF_SETTINGS.mode ? (
+ save({ ...shown, mode: DEFAULT_HANDOFF_SETTINGS.mode })}
+ />
+ ) : null
+ }
+ control={
+ save({ ...shown, mode })}
+ />
+ }
+ />
+
+
+ ) : null}
+
+ limit.id)}>
+ {LIMITS.map((limit) => {
+ const title = searchableSetting(limit.id).title;
+ return (
+
+
+ save(
+ { ...shown, [limit.key]: Math.min(limit.max, Math.max(limit.min, value)) },
+ options,
+ )
+ }
+ />
+ {limit.unit}
+
+ }
+ />
+ );
+ })}
+
+ {editing ? (
+ save(next, { onSaved, onFailed })}
+ />
+ ) : null}
+
+ );
+}
diff --git a/apps/web/src/components/settings/fork/UpdatesSettings.tsx b/apps/web/src/components/settings/fork/UpdatesSettings.tsx
new file mode 100644
index 0000000000000..2a4c4fdf381b0
--- /dev/null
+++ b/apps/web/src/components/settings/fork/UpdatesSettings.tsx
@@ -0,0 +1,93 @@
+/**
+ * Fork: automatic updates (`automaticUpdates`, `automaticUpdatesQuietCommand`). Server-wide, so a
+ * project screen does not show it. Every write is an ordinary settings patch from the person at the
+ * screen; agents cannot change it.
+ */
+/* oxlint-disable t3code/no-untranslated-copy -- Fork: this panel is the fork's own and its text is English only; upstream's translation catalogs hold no fork keys. */
+import { DEFAULT_SERVER_SETTINGS } from "@t3tools/contracts";
+
+import { Switch } from "../../ui/switch";
+import { useSettingsScope } from "../SettingsScopeContext";
+import { SettingResetButton, SettingsRow, SettingsSection } from "../settingsLayout";
+import { useSearchableSetting } from "../settingsSearch";
+import { targetsDiffer } from "../waitsAndSlotsSettings.logic";
+import { useScopedSettings, useUpdateScopedSettings } from "../useScopedSettings";
+import { CommitTextField } from "./CommitTextField";
+
+const MIXED = "The selected environments have different values. Select one environment to edit it.";
+
+export function UpdatesSettings() {
+ const searchableSetting = useSearchableSetting();
+ const updateSettings = useUpdateScopedSettings();
+ const { targets } = useSettingsScope();
+ const automatic = useScopedSettings((settings) => settings.automaticUpdates);
+ const quietCommand = useScopedSettings((settings) => settings.automaticUpdatesQuietCommand);
+ const automaticMixed = targetsDiffer(targets, (settings) => settings.automaticUpdates);
+ const quietMixed = targetsDiffer(targets, (settings) => settings.automaticUpdatesQuietCommand);
+
+ return (
+
+
+ updateSettings({ automaticUpdates: DEFAULT_SERVER_SETTINGS.automaticUpdates })
+ }
+ />
+ ) : null
+ }
+ control={
+ updateSettings({ automaticUpdates: Boolean(checked) })}
+ aria-label="Update automatically"
+ />
+ }
+ />
+ updateSettings({ automaticUpdatesQuietCommand: "" })}
+ />
+ ) : null
+ }
+ control={
+ quietMixed ? null : (
+ {
+ updateSettings({ automaticUpdatesQuietCommand: text.trim() }, { onFailed: revert });
+ return null;
+ }}
+ />
+ )
+ }
+ />
+
+ );
+}
diff --git a/apps/web/src/components/settings/fork/handoffSettings.logic.test.ts b/apps/web/src/components/settings/fork/handoffSettings.logic.test.ts
new file mode 100644
index 0000000000000..09385805916ae
--- /dev/null
+++ b/apps/web/src/components/settings/fork/handoffSettings.logic.test.ts
@@ -0,0 +1,73 @@
+import { HANDOFF_THREADS_MAX, HandoffSettings, ServerSettings } from "@t3tools/contracts";
+import * as Schema from "effect/Schema";
+import { describe, expect, it } from "vite-plus/test";
+
+import {
+ formatArgvLines,
+ handoffSourceProblem,
+ handoffThreadRows,
+ parseArgvLines,
+ threadModeProblem,
+ withThreadMode,
+} from "./handoffSettings.logic";
+
+const fromFile = Schema.decodeUnknownSync(ServerSettings);
+// What a save sends must pass the server's strict check (no unknown or bad field).
+const isSavable = Schema.is(HandoffSettings);
+
+describe("per-thread handoff modes", () => {
+ it("adds, changes and removes one thread's mode, keeping the rest of the value", () => {
+ const empty = fromFile({}).handoff;
+ const one = withThreadMode(empty, "thread-1", "handoff");
+ expect(one).toEqual({ ...empty, threads: { "thread-1": "handoff" } });
+ expect(withThreadMode(one, "thread-1", "compact").threads).toEqual({ "thread-1": "compact" });
+ expect(withThreadMode(one, "thread-1", null)).toEqual(empty);
+ expect(isSavable(one)).toBe(true);
+ });
+
+ it("refuses a blank id, a thread that already has a mode, and one past the cap", () => {
+ const stored = fromFile({ handoff: { threads: { "thread-1": "handoff" } } }).handoff;
+ expect(threadModeProblem(stored, " ")).toBe("Enter a thread id.");
+ expect(threadModeProblem(stored, " thread-1 ")).toBe("This thread already has its own mode.");
+ expect(threadModeProblem(stored, "thread-2")).toBeNull();
+ const full = {
+ ...stored,
+ threads: Object.fromEntries(
+ Array.from({ length: HANDOFF_THREADS_MAX }, (_, i) => [`t${i}`, "compact" as const]),
+ ),
+ };
+ expect(threadModeProblem(full, "one-more")).toMatch(/^At most 500 threads/);
+ });
+
+ it("titles the threads this client knows, then lists the unknown ones (a deleted thread)", () => {
+ expect(
+ handoffThreadRows(
+ { gone: "handoff", b: "compact", a: "handoff" },
+ new Map([
+ ["a", "Zebra"],
+ ["b", "Apple"],
+ ]),
+ ).map((row) => [row.threadId, row.title]),
+ ).toEqual([
+ ["b", "Apple"],
+ ["a", "Zebra"],
+ ["gone", null],
+ ]);
+ });
+});
+
+describe("handoff command", () => {
+ it("reads one argument per line and shows it back the same way", () => {
+ const argv = parseArgvLines(" /usr/bin/write-handoff\n\n--thread \n");
+ expect(argv).toEqual(["/usr/bin/write-handoff", "--thread"]);
+ expect(parseArgvLines(formatArgvLines(argv))).toEqual(argv);
+ expect(parseArgvLines(" \n ")).toBeUndefined();
+ expect(formatArgvLines(fromFile({}).handoff.command)).toBe("");
+ });
+
+ it("refuses a command source without a command, as the server's save does", () => {
+ expect(handoffSourceProblem("command", undefined)).not.toBeNull();
+ expect(handoffSourceProblem("command", ["/bin/x"])).toBeNull();
+ expect(handoffSourceProblem("agent", undefined)).toBeNull();
+ });
+});
diff --git a/apps/web/src/components/settings/fork/handoffSettings.logic.ts b/apps/web/src/components/settings/fork/handoffSettings.logic.ts
new file mode 100644
index 0000000000000..df2c43a45f34a
--- /dev/null
+++ b/apps/web/src/components/settings/fork/handoffSettings.logic.ts
@@ -0,0 +1,88 @@
+/** Fork: the pure parts of the handoff panel (`handoff`, server and project). */
+/* oxlint-disable t3code/no-untranslated-copy -- Fork: the fork's own settings are English only; upstream's translation catalogs hold no fork keys. */
+import { HANDOFF_THREADS_MAX, type HandoffMode, type HandoffSettings } from "@t3tools/contracts";
+
+export const HANDOFF_MODE_OPTIONS: ReadonlyArray<{
+ readonly value: HandoffMode;
+ readonly label: string;
+ readonly description: string;
+}> = [
+ { value: "off", label: "Off", description: "Long threads compact as upstream's settings say." },
+ {
+ value: "handoff",
+ label: "Handoff",
+ description:
+ "A long thread moves to a fresh session in the same thread with a written handoff, so its children, pull requests and waits keep working.",
+ },
+ {
+ value: "compact",
+ label: "Compact",
+ description: "Same as Off; use it to keep one project or thread out of a Handoff above it.",
+ },
+];
+
+export const handoffModeLabel = (mode: HandoffMode) =>
+ HANDOFF_MODE_OPTIONS.find((option) => option.value === mode)?.label ?? mode;
+
+/** The whole new value with one thread's mode set, or removed with `null`. */
+export function withThreadMode(
+ settings: HandoffSettings,
+ threadId: string,
+ mode: HandoffMode | null,
+): HandoffSettings {
+ const { [threadId]: _old, ...rest } = settings.threads;
+ return { ...settings, threads: mode === null ? rest : { ...rest, [threadId]: mode } };
+}
+
+/** Why a thread cannot be added, or null. */
+export function threadModeProblem(settings: HandoffSettings, threadId: string): string | null {
+ const id = threadId.trim();
+ if (id === "") return "Enter a thread id.";
+ if (Object.hasOwn(settings.threads, id)) return "This thread already has its own mode.";
+ if (Object.keys(settings.threads).length >= HANDOFF_THREADS_MAX) {
+ return `At most ${HANDOFF_THREADS_MAX} threads can have their own mode. Remove one first.`;
+ }
+ return null;
+}
+
+export interface HandoffThreadRow {
+ readonly threadId: string;
+ readonly title: string | null;
+ readonly mode: HandoffMode;
+}
+
+/** The per-thread modes, titled where this client knows the thread, by title then id. */
+export function handoffThreadRows(
+ threads: Readonly>,
+ titles: ReadonlyMap,
+): ReadonlyArray {
+ return Object.entries(threads)
+ .map(([threadId, mode]) => ({ threadId, title: titles.get(threadId) ?? null, mode }))
+ .toSorted(
+ (a, b) =>
+ Number(a.title === null) - Number(b.title === null) ||
+ (a.title ?? "").localeCompare(b.title ?? "") ||
+ a.threadId.localeCompare(b.threadId),
+ );
+}
+
+/** One argument per line, the program first; blank lines dropped. Empty: no command. */
+export function parseArgvLines(text: string): ReadonlyArray | undefined {
+ const argv = text
+ .split("\n")
+ .map((line) => line.trim())
+ .filter((line) => line !== "");
+ return argv.length === 0 ? undefined : argv;
+}
+
+export const formatArgvLines = (argv: ReadonlyArray | undefined) => (argv ?? []).join("\n");
+
+/** Why the source and command cannot be saved together, or null. */
+export function handoffSourceProblem(
+ source: HandoffSettings["source"],
+ command: ReadonlyArray | undefined,
+): string | null {
+ return source === "command" && command === undefined
+ ? "Written by a command needs a command: its program on the first line, one argument per line."
+ : null;
+}
diff --git a/apps/web/src/components/settings/fork/playtestSettings.logic.test.ts b/apps/web/src/components/settings/fork/playtestSettings.logic.test.ts
new file mode 100644
index 0000000000000..633c5614ad498
--- /dev/null
+++ b/apps/web/src/components/settings/fork/playtestSettings.logic.test.ts
@@ -0,0 +1,68 @@
+import { ServerSettings } from "@t3tools/contracts";
+import * as Schema from "effect/Schema";
+import { describe, expect, it } from "vite-plus/test";
+
+import {
+ playtestCommandLine,
+ playtestMissingSteps,
+ playtestStepsText,
+ withPlaytestSteps,
+} from "./playtestSettings.logic";
+
+const fromFile = Schema.decodeUnknownSync(ServerSettings);
+const step = (...argv: string[]) => ({ argv });
+const STEPS = {
+ claim: step("/usr/local/bin/game", "claim"),
+ renew: step("/usr/local/bin/game", "renew"),
+ push: [{ name: "deploy", ...step("/usr/local/bin/game", "deploy") }],
+ release: step("/usr/local/bin/game", "release"),
+};
+
+describe("playtest steps", () => {
+ it("an empty settings file has no steps, so the switch names all four as missing", () => {
+ const empty = fromFile({}).playtest;
+ expect(playtestMissingSteps(empty)).toEqual(["claim", "renew", "push", "release"]);
+ expect(playtestStepsText(empty)).toBe("{}");
+ });
+
+ it("saves the edited steps over the old ones and keeps the switch and limits", () => {
+ const stored = fromFile({ playtest: { maxHours: 3 } }).playtest;
+ const result = withPlaytestSteps(stored, JSON.stringify(STEPS));
+ if (!("value" in result)) throw new Error(result.error);
+ expect(result.value.maxHours).toBe(3);
+ expect(result.value.enabled).toBe(false);
+ expect(result.value.push.map((push) => push.name)).toEqual(["deploy"]);
+ expect(playtestMissingSteps(result.value)).toEqual([]);
+ // Shown again, the text reads back to the same value.
+ expect(withPlaytestSteps(result.value, playtestStepsText(result.value))).toEqual(result);
+ });
+
+ it("a step left out is removed, but not while playtest is on", () => {
+ const on = fromFile({ playtest: { enabled: true, ...STEPS } }).playtest;
+ const { release: _release, ...withoutRelease } = STEPS;
+ expect(withPlaytestSteps(on, JSON.stringify(withoutRelease))).toHaveProperty("error");
+ const off = { ...on, enabled: false };
+ const result = withPlaytestSteps(off, JSON.stringify(withoutRelease));
+ expect("value" in result && result.value.release).toBeUndefined();
+ });
+
+ it("refuses text the server's save would refuse", () => {
+ const empty = fromFile({}).playtest;
+ for (const text of [
+ "not json",
+ "[]",
+ JSON.stringify({ claim: step("game", "claim") }),
+ JSON.stringify({ push: [{ name: "claim", ...step("/bin/x") }] }),
+ JSON.stringify({ claim: { ...step("/bin/x"), typo: 1 } }),
+ JSON.stringify({ enabled: true }),
+ ]) {
+ expect(withPlaytestSteps(empty, text), text).toHaveProperty("error");
+ }
+ });
+
+ it("shows a step as one command line", () => {
+ expect(
+ playtestCommandLine({ argv: ["/bin/x", "a b", "c"], timeoutSeconds: 1, description: "" }),
+ ).toBe('/bin/x "a b" c');
+ });
+});
diff --git a/apps/web/src/components/settings/fork/playtestSettings.logic.ts b/apps/web/src/components/settings/fork/playtestSettings.logic.ts
new file mode 100644
index 0000000000000..85b95ae2aca7b
--- /dev/null
+++ b/apps/web/src/components/settings/fork/playtestSettings.logic.ts
@@ -0,0 +1,67 @@
+/** Fork: the pure parts of the playtest panel (`playtest`, server and project). */
+/* oxlint-disable t3code/no-untranslated-copy -- Fork: the fork's own settings are English only; upstream's translation catalogs hold no fork keys. */
+import { PlaytestSettings, type PlaytestStep } from "@t3tools/contracts";
+import * as Schema from "effect/Schema";
+
+const STEP_KEYS = ["claim", "renew", "push", "release"] as const;
+type StepKey = (typeof STEP_KEYS)[number];
+
+const decodePlaytestStrict = Schema.decodeUnknownExit(PlaytestSettings);
+
+/** The steps that keep the switch off: on needs claim, renew, at least one push step and release. */
+export function playtestMissingSteps(settings: PlaytestSettings): ReadonlyArray {
+ return [
+ ...(settings.claim === undefined ? ["claim"] : []),
+ ...(settings.renew === undefined ? ["renew"] : []),
+ ...(settings.push.length === 0 ? ["push"] : []),
+ ...(settings.release === undefined ? ["release"] : []),
+ ];
+}
+
+/** The program and its arguments as one line, quoting an argument with a space. */
+export const playtestCommandLine = (step: PlaytestStep) =>
+ step.argv.map((arg) => (/\s/.test(arg) ? JSON.stringify(arg) : arg)).join(" ");
+
+/** The four steps as the editor shows them: JSON, as in the settings file. */
+export function playtestStepsText(settings: PlaytestSettings): string {
+ const steps: Partial> = {};
+ for (const key of STEP_KEYS) {
+ if (key === "push" ? settings.push.length > 0 : settings[key] !== undefined) {
+ steps[key] = settings[key];
+ }
+ }
+ return JSON.stringify(steps, null, 2);
+}
+
+/**
+ * The whole new value with the edited steps in place of the old ones (a step left out is removed),
+ * or why it cannot be saved. Checked as the server's save checks it, unknown fields refused.
+ */
+export function withPlaytestSteps(
+ settings: PlaytestSettings,
+ text: string,
+): { readonly value: PlaytestSettings } | { readonly error: string } {
+ let parsed: unknown;
+ try {
+ parsed = JSON.parse(text.trim() === "" ? "{}" : text);
+ } catch {
+ return { error: "The steps are not valid JSON." };
+ }
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
+ return { error: "The steps are a JSON object with claim, renew, push and release." };
+ }
+ const unknown = Object.keys(parsed).filter(
+ (key) => !(STEP_KEYS as ReadonlyArray).includes(key),
+ );
+ if (unknown.length > 0) return { error: `Not a step: ${unknown.join(", ")}.` };
+ const { claim: _c, renew: _r, release: _l, ...rest } = settings;
+ const exit = decodePlaytestStrict(
+ { ...rest, push: [], ...parsed },
+ { onExcessProperty: "error" },
+ );
+ if (exit._tag === "Success") return { value: exit.value };
+ return {
+ error:
+ "The steps cannot be saved: each needs argv (its program by full path first, at most 50 items), an optional timeoutSeconds (1 to 3600) and description; push steps need a unique lower-case name other than claim, renew or release. While playtest is on, all four steps are needed.",
+ };
+}
diff --git a/apps/web/src/components/settings/forkSettingsSearchItems.ts b/apps/web/src/components/settings/forkSettingsSearchItems.ts
index e4b75db70947e..4e76b35a9695f 100644
--- a/apps/web/src/components/settings/forkSettingsSearchItems.ts
+++ b/apps/web/src/components/settings/forkSettingsSearchItems.ts
@@ -103,4 +103,108 @@ export const FORK_SETTINGS_SEARCH_ITEMS = [
environmentOnly: true,
scope: "project-defaults",
},
+ {
+ id: "automatic-updates",
+ title: "Update automatically",
+ to: FORK_PAGE,
+ searchTerms: ["automaticUpdates boot service t3 update release"],
+ environmentOnly: true,
+ scope: "environment-defaults",
+ },
+ {
+ id: "automatic-updates-quiet-command",
+ title: "Quiet check before an update",
+ to: FORK_PAGE,
+ searchTerms: ["automaticUpdatesQuietCommand program exit code not now"],
+ environmentOnly: true,
+ scope: "environment-defaults",
+ },
+ {
+ id: "handoff",
+ title: "Handoff instead of compaction",
+ to: FORK_PAGE,
+ searchTerms: ["handoff compaction compact long thread fresh session context"],
+ environmentOnly: true,
+ scope: "project-defaults",
+ },
+ {
+ id: "handoff-threads",
+ title: "Handoff mode per thread",
+ to: FORK_PAGE,
+ searchTerms: ["handoff threads thread id own mode"],
+ environmentOnly: true,
+ scope: "project-defaults",
+ },
+ {
+ id: "handoff-size",
+ title: "Handoff size",
+ to: FORK_PAGE,
+ searchTerms: ["handoff sizeTokens backstop tokens"],
+ environmentOnly: true,
+ scope: "project-defaults",
+ },
+ {
+ id: "handoff-idle",
+ title: "Idle handoff size",
+ to: FORK_PAGE,
+ searchTerms: ["handoff idleTokens prompt cache idle tokens"],
+ environmentOnly: true,
+ scope: "project-defaults",
+ },
+ {
+ id: "handoff-source",
+ title: "Handoff written by",
+ to: FORK_PAGE,
+ searchTerms: ["handoff source agent command program"],
+ environmentOnly: true,
+ scope: "project-defaults",
+ },
+ {
+ id: "handoff-instructions",
+ title: "Handoff instructions",
+ to: FORK_PAGE,
+ searchTerms: ["handoff instructions text prompt"],
+ environmentOnly: true,
+ scope: "project-defaults",
+ },
+ {
+ id: "playtest",
+ title: "Playtest sessions",
+ to: FORK_PAGE,
+ searchTerms: ["playtest test target staging round adapter"],
+ environmentOnly: true,
+ scope: "project-defaults",
+ },
+ {
+ id: "playtest-steps",
+ title: "Playtest steps",
+ to: FORK_PAGE,
+ searchTerms: ["playtest claim renew push release adapter argv program"],
+ environmentOnly: true,
+ scope: "project-defaults",
+ },
+ {
+ id: "playtest-renew-minutes",
+ title: "Renew the claim every",
+ to: FORK_PAGE,
+ searchTerms: ["playtest renewMinutes claim"],
+ environmentOnly: true,
+ scope: "project-defaults",
+ },
+ {
+ id: "playtest-idle-minutes",
+ title: "End an idle session after",
+ to: FORK_PAGE,
+ searchTerms: ["playtest idleMinutes idle"],
+ environmentOnly: true,
+ scope: "project-defaults",
+ },
+ {
+ id: "playtest-max-hours",
+ title: "Longest session",
+ to: FORK_PAGE,
+ searchTerms: ["playtest maxHours session limit"],
+ environmentOnly: true,
+ scope: "project-defaults",
+ },
] as const;
diff --git a/docs/fork/README.md b/docs/fork/README.md
index f49d4b701b2ad..44be38463caaa 100644
--- a/docs/fork/README.md
+++ b/docs/fork/README.md
@@ -81,7 +81,8 @@ A server installed as a boot service (`t3 service install`) updates itself to th
once no thread is working. Off: it updates only when someone runs `t3 update` or presses **Update**.
Upstream has a setting of this name pending (not on its `main` yet); the fork keeps `false` through every sync.
-Switch on in `settings.json`: `"automaticUpdates": true`. There is no Settings row for it yet. An
+Switch on: **Settings → Fork**, section Updates, "Update automatically", or in `settings.json`:
+`"automaticUpdates": true`. An
admin policy with updates `"off"` still wins. Details: [updates.md](updates.md).
### `server.automaticUpdatesQuietCommand`
@@ -89,7 +90,8 @@ admin policy with updates `"off"` still wins. Details: [updates.md](updates.md).
An optional program asked before each automatic update; a non-zero exit means "not now". Used only
while `automaticUpdates` is on. Empty: no program is asked.
-Set in `settings.json`: `"automaticUpdatesQuietCommand": "/path/to/quiet-check"`. Details:
+Set: **Settings → Fork**, section Updates, "Quiet check before an update", or in `settings.json`:
+`"automaticUpdatesQuietCommand": "/path/to/quiet-check"`. Details:
[updates.md](updates.md).
### `server.activityProbe`
@@ -204,6 +206,9 @@ arguments, run without a shell; T3 passes the session's facts as environment var
starts a session yet: the session store and the worker (renew, the idle and time limits, ends for
gone threads) are there, and the tool and the thread controls come in later pull requests. The steps' contract is in [playtest.md](playtest.md).
+In the app: **Settings → Fork**, section Playtest: the switch (it stays off until all four steps are
+set), the steps as JSON under **Edit steps** (checked as a save is), and the limits under Advanced.
+
Only the person can change it; agents cannot. A save that is on without all four steps, repeats a
push step's name (or names one `claim`, `renew` or `release`), or names a program by anything but
its full path on the server's OS is refused. A hand-edited
@@ -418,6 +423,11 @@ model (not set: the thread's current one). A save with a bad value, a field T3 d
typo), or `source: command` without a command, is refused; a hand-edited value that is not valid reads as off (with a warning in the
server log), never as `handoff`.
+In the app: **Settings → Fork**, section Handoff: the mode, each thread's own mode (added by thread
+id, shown with its title where this client knows the thread), and under Advanced the sizes, who
+writes the handoff (with its command) and the instructions. `modelSelection` has no row yet; a save
+there keeps it as stored.
+
```json
{ "handoff": { "mode": "handoff", "threads": { "": "compact" } } }
```
From a6ec2ea358d4392731a3d60c6dca3108e678690d Mon Sep 17 00:00:00 2001
From: scuttletoby <123843277+scuttletoby@users.noreply.github.com>
Date: Thu, 19 Nov 2026 17:33:11 +0100
Subject: [PATCH 2/4] docs(fork): list #544 with the Fork settings page
Co-Authored-By: Claude Opus 5.5
---
FORK_CHANGES.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/FORK_CHANGES.md b/FORK_CHANGES.md
index 3a52b49d0e5d5..36a025e9958b6 100644
--- a/FORK_CHANGES.md
+++ b/FORK_CHANGES.md
@@ -23,7 +23,7 @@ setting is missing here or a setting named here does not exist.
| The pacing gate on `delegate_task`: advise only, or move, lower the effort of, or hold a task on an account that is ahead of pace. | Delegated work follows the pace without the agent having to check. | `server.usagePacingGate`, `server.usagePacingLowerEffort` | off | [#73](https://github.com/scuttletoby/t3code/pull/73) |
| Agent slots: `delegate_task` is refused above a number of running agents per machine or account, or below a memory floor. | Too many agents at once can overload a small machine. | `server.agentSlots` | off; rule only observes | [#84](https://github.com/scuttletoby/t3code/pull/84), [#89](https://github.com/scuttletoby/t3code/pull/89) |
| Waits: agents can wait for a pull request, a file, a system unit, a named check command or a free agent slot (`wait_for`, `wait_list`, `wait_cancel`), and are woken when it happens. | An agent no longer polls or sleeps while it waits. | `server.waitFor`, `server.waitChecks`, `projectOverride.waitChecks` | off | [#84](https://github.com/scuttletoby/t3code/pull/84), [#90](https://github.com/scuttletoby/t3code/pull/90), [#91](https://github.com/scuttletoby/t3code/pull/91), [#103](https://github.com/scuttletoby/t3code/pull/103), [#106](https://github.com/scuttletoby/t3code/pull/106), [#109](https://github.com/scuttletoby/t3code/pull/109), [#110](https://github.com/scuttletoby/t3code/pull/110), [#116](https://github.com/scuttletoby/t3code/pull/116), [#119](https://github.com/scuttletoby/t3code/pull/119) |
-| The Settings page **Fork** (`/settings/fork`): every fork setting in one place, with one line per feature at the top saying whether it is on: waits, wait checks, agent slots, usage pacing (per account by name), model policy, review rules, automatic updates, handoff and playtest. MCP profiles are not on it yet. | Change every fork setting without editing a file. | `server.waitFor`, `server.waitChecks`, `server.agentSlots`, `server.usagePacing`, `server.usagePacingGate`, `server.usagePacingLowerEffort`, `server.reviewRules`, `server.modelPolicy`, `server.automaticUpdates`, `server.automaticUpdatesQuietCommand`, `server.handoff`, `server.playtest` | off | [#104](https://github.com/scuttletoby/t3code/pull/104), [#543](https://github.com/scuttletoby/t3code/pull/543) |
+| The Settings page **Fork** (`/settings/fork`): every fork setting in one place, with one line per feature at the top saying whether it is on: waits, wait checks, agent slots, usage pacing (per account by name), model policy, review rules, automatic updates, handoff and playtest. MCP profiles are not on it yet. | Change every fork setting without editing a file. | `server.waitFor`, `server.waitChecks`, `server.agentSlots`, `server.usagePacing`, `server.usagePacingGate`, `server.usagePacingLowerEffort`, `server.reviewRules`, `server.modelPolicy`, `server.automaticUpdates`, `server.automaticUpdatesQuietCommand`, `server.handoff`, `server.playtest` | off | [#104](https://github.com/scuttletoby/t3code/pull/104), [#543](https://github.com/scuttletoby/t3code/pull/543), [#544](https://github.com/scuttletoby/t3code/pull/544) |
| The fork's checks on `delegate_task` (pacing, slots) sit behind one fork module. | Fewer fork lines in upstream's code, so syncs conflict less. No change in behaviour. | none | always | [#174](https://github.com/scuttletoby/t3code/pull/174) |
| The fork's service layers in the server are wired from one fork file (`apps/server/src/fork/forkLayers.ts`). | Fewer fork lines in upstream's code, so syncs conflict less. No change in behaviour. | none | always | [#384](https://github.com/scuttletoby/t3code/pull/384) |
| A pure capacity rule for "dynamic slots" (one budget per machine), with shared test cases. Not wired into anything yet. | A later step replaces fixed agent counts with what the machine can take. | none | not used | [#203](https://github.com/scuttletoby/t3code/pull/203) |
From 7f0bb65c5e60509bb0bba140fba2b4199d42bc02 Mon Sep 17 00:00:00 2001
From: scuttletoby <123843277+scuttletoby@users.noreply.github.com>
Date: Thu, 19 Nov 2026 18:07:41 +0100
Subject: [PATCH 3/4] fix(web): project handoff and playtest removals stay
removed; Fork rows lock and reset per row
Fix round for the review of #544:
- On a project screen a save of handoff or playtest merged the shown
value into the project's current one, so a removed playtest step or
an emptied handoff command came back. Both now replace the project's
value whole, as waitChecks and reviewRules do (the server reads them
so). A test saves through the real writer and settings patch.
- A thread's title and id are in their own elements, so the title
reads (and is found) on its own.
- A managed lock or a missing write permission makes every handoff and
playtest control inert: the thread list, Add thread, the command and
instructions too. A refused Add thread keeps the typed id.
- On a project screen each Handoff and Playtest sub-row resets only its
own fields to the environment's value; the section's first row still
clears the whole override.
- "Reset playtest to default" restores the real default (steps
included), and a clamped number shows the saved value.
- The playtest test switches the adapter on and then off.
Co-Authored-By: Claude Opus 5.5
---
.../settings/fork/ForkPanels.browser.test.tsx | 56 ++++++++-
.../src/components/settings/fork/ForkRow.tsx | 37 +++++-
.../settings/fork/HandoffSettings.tsx | 109 +++++++++++-------
.../settings/fork/PlaytestSettings.tsx | 57 ++++++---
.../fork/forkProjectOverrides.test.ts | 93 +++++++++++++++
.../settings/fork/forkRowReset.logic.test.ts | 35 ++++++
.../settings/fork/forkRowReset.logic.ts | 20 ++++
.../src/components/settings/scopedSettings.ts | 4 +-
8 files changed, 342 insertions(+), 69 deletions(-)
create mode 100644 apps/web/src/components/settings/fork/forkProjectOverrides.test.ts
create mode 100644 apps/web/src/components/settings/fork/forkRowReset.logic.test.ts
create mode 100644 apps/web/src/components/settings/fork/forkRowReset.logic.ts
diff --git a/apps/web/src/components/settings/fork/ForkPanels.browser.test.tsx b/apps/web/src/components/settings/fork/ForkPanels.browser.test.tsx
index 0faeb1f759a69..7bc8d3f8af1b4 100644
--- a/apps/web/src/components/settings/fork/ForkPanels.browser.test.tsx
+++ b/apps/web/src/components/settings/fork/ForkPanels.browser.test.tsx
@@ -89,9 +89,11 @@ import { UpdatesSettings } from "./UpdatesSettings";
const decodeServerSettings = Schema.decodeUnknownSync(ServerSettings);
/** The settings a server reads from `file`, so an old or empty file is tested as it loads. */
-function setup(file: object) {
+function setup(file: object, managedPolicy?: ManagedPolicySummary) {
state.settings = decodeServerSettings(file);
- state.environments = [{ environmentId: "env-a", providers: [] }];
+ state.environments = [
+ { environmentId: "env-a", providers: [], ...(managedPolicy ? { managedPolicy } : {}) },
+ ];
state.update.mockReset();
}
@@ -132,10 +134,38 @@ describe("HandoffSettings", () => {
await userEvent.click(page.getByRole("option", { name: "Handoff" }));
expect(state.update.mock.calls[0]![0]).toEqual({ handoff: { ...empty, mode: "handoff" } });
- await userEvent.type(screen.getByRole("textbox", { name: "Thread id" }), "thread-1{Enter}");
+ const threadId = screen.getByRole("textbox", { name: "Thread id" });
+ await userEvent.type(threadId, "thread-1{Enter}");
expect(state.update.mock.calls[1]![0]).toEqual({
handoff: { ...empty, threads: { "thread-1": "compact" } },
});
+ // The typed id stays until the save is through: a refused save keeps it to try again.
+ state.update.mock.calls[1]![1]?.onFailed?.();
+ await expect.element(threadId).toHaveValue("thread-1");
+ state.update.mock.calls[1]![1]?.onSaved?.();
+ await expect.element(threadId).toHaveValue("");
+ });
+
+ it("greys out every control of a locked handoff, the thread list and command too", async () => {
+ setup(
+ { handoff: { mode: "handoff", threads: { "thread-1": "compact" } } },
+ { organization: "Example Corp", lockedSettings: ["handoff"] },
+ );
+ await using screen = await render();
+
+ await expect.element(screen.getByText("Fix the login page")).toBeVisible();
+ for (const selector of [
+ '[aria-label="Handoff mode"]',
+ '[aria-label="Handoff mode for thread thread-1"]',
+ '[aria-label="Remove the handoff mode of thread thread-1"]',
+ '[aria-label="Thread id"]',
+ ]) {
+ expect(screen.container.querySelector(selector)?.closest("[inert]"), selector).not.toBeNull();
+ }
+ const add = [...screen.container.querySelectorAll("button")].find(
+ (button) => button.textContent === "Add thread",
+ );
+ expect(add?.closest("[inert]")).not.toBeNull();
});
it("lists a stored thread by its title and removes it", async () => {
@@ -185,5 +215,25 @@ describe("PlaytestSettings", () => {
expect(state.update.mock.calls[0]![0]).toEqual({
playtest: { ...state.settings.playtest, enabled: true },
});
+
+ // The server now reads it as on.
+ state.settings = decodeServerSettings({ playtest: { ...STEPS, enabled: true } });
+ await screen.rerender();
+ const toggle = screen.getByRole("switch", { name: "Playtest sessions" });
+ await expect.element(toggle).toBeChecked();
+ await userEvent.click(toggle);
+ expect(state.update.mock.calls[1]![0]).toEqual({
+ playtest: { ...state.settings.playtest, enabled: false },
+ });
+ });
+
+ it("resets the server's playtest to the real default, steps included", async () => {
+ setup({ playtest: { ...STEPS, enabled: true, renewMinutes: 3 } });
+ await using screen = await render();
+
+ await userEvent.click(screen.getByRole("button", { name: "Reset playtest to default" }));
+ expect(state.update.mock.calls[0]![0]).toEqual({
+ playtest: decodeServerSettings({}).playtest,
+ });
});
});
diff --git a/apps/web/src/components/settings/fork/ForkRow.tsx b/apps/web/src/components/settings/fork/ForkRow.tsx
index 176fdae7e59c0..554b1058244a0 100644
--- a/apps/web/src/components/settings/fork/ForkRow.tsx
+++ b/apps/web/src/components/settings/fork/ForkRow.tsx
@@ -5,15 +5,16 @@
* too. The server refuses such a write anyway; this only keeps a click from ending in an error.
*/
/* oxlint-disable t3code/no-untranslated-copy -- Fork: the fork's own settings are English only; upstream's translation catalogs hold no fork keys. */
-import { isManagedSettingPath } from "@t3tools/contracts";
+import { isManagedSettingPath, type ServerSettings } from "@t3tools/contracts";
import { type ComponentProps, useState } from "react";
import { useEnvironmentProviders } from "../../../state/environments";
import { EMPTY_SERVER_PROVIDERS } from "../../../state/server";
import { IntervalSecondsField } from "../IntervalSecondsField";
import { useSettingsScope } from "../SettingsScopeContext";
-import { SettingsRow } from "../settingsLayout";
+import { SettingResetButton, SettingsRow } from "../settingsLayout";
import { useScopedSettingsWriteAllowed } from "../useScopedSettings";
+import { withFieldsFrom } from "./forkRowReset.logic";
/** Every selected environment's accounts, the primary's first, as the agent slots rows list them. */
export function useSelectedProviders() {
@@ -86,3 +87,35 @@ export function BoundedNumberField({
/>
);
}
+
+/**
+ * A sub-row's reset on a project screen whose value is the project's own: it puts back only that
+ * row's fields from the environment's value and keeps the rest of the override (upstream's row
+ * reset would clear the whole override). Null where there is nothing to reset.
+ */
+export function useSubRowReset(
+ key: K,
+ shown: ServerSettings[K],
+ isOwn: boolean,
+ save: (next: ServerSettings[K]) => void,
+) {
+ const { targets, connectedEnvironments } = useSettingsScope();
+ const target = targets[0];
+ const environmentValue =
+ target === undefined || target.projectId === null
+ ? undefined
+ : connectedEnvironments.find(
+ (environment) => environment.environmentId === target.environmentId,
+ )?.serverConfig?.settings[key];
+ return (keys: ReadonlyArray, ariaLabel: string) => {
+ if (!isOwn || environmentValue === undefined) return null;
+ const next = withFieldsFrom(shown, environmentValue, keys);
+ return next === null ? null : (
+ save(next)}
+ />
+ );
+ };
+}
diff --git a/apps/web/src/components/settings/fork/HandoffSettings.tsx b/apps/web/src/components/settings/fork/HandoffSettings.tsx
index 4e5a1603754e8..df74c36acded8 100644
--- a/apps/web/src/components/settings/fork/HandoffSettings.tsx
+++ b/apps/web/src/components/settings/fork/HandoffSettings.tsx
@@ -18,8 +18,7 @@ import { Button } from "../../ui/button";
import { Input } from "../../ui/input";
import { Select, SelectItem, SelectPopup, SelectTrigger, SelectValue } from "../../ui/select";
import { AdvancedSettings } from "../AdvancedSettings";
-import { IntervalSecondsField } from "../IntervalSecondsField";
-import { SettingResetButton, SettingsRow, SettingsSection } from "../settingsLayout";
+import { SettingResetButton, SettingsSection } from "../settingsLayout";
import { useSearchableSetting } from "../settingsSearch";
import {
useClearScopedSettings,
@@ -29,6 +28,7 @@ import {
useUpdateScopedSettings,
} from "../useScopedSettings";
import { CommitTextField } from "./CommitTextField";
+import { BoundedNumberField, ForkRow, useSubRowReset } from "./ForkRow";
import {
HANDOFF_MODE_OPTIONS,
formatArgvLines,
@@ -93,8 +93,14 @@ export function HandoffSettings({ isProjectScope }: { readonly isProjectScope: b
const [threadError, setThreadError] = useState(null);
const [sourceError, setSourceError] = useState(null);
- const save = (next: HandoffValue, onFailed?: () => void) =>
- updateSettings({ handoff: next }, onFailed ? { onFailed } : undefined);
+ const save = (next: HandoffValue, options?: { onFailed?: () => void; onSaved?: () => void }) =>
+ updateSettings({ handoff: next }, options);
+ const subRowReset = useSubRowReset(
+ "handoff",
+ shown,
+ isProjectScope && source === "project",
+ save,
+ );
const option = HANDOFF_MODE_OPTIONS.find((candidate) => candidate.value === shown.mode);
const scopeNote = !isProjectScope
? ""
@@ -109,17 +115,21 @@ export function HandoffSettings({ isProjectScope }: { readonly isProjectScope: b
return;
}
setThreadError(null);
- save(withThreadMode(shown, threadDraft.id.trim(), threadDraft.mode));
- setThreadDraft({ ...threadDraft, id: "" });
+ const id = threadDraft.id;
+ // The typed id stays until the save is through, so a refused save keeps it to try again.
+ save(withThreadMode(shown, id.trim(), threadDraft.mode), {
+ onSaved: () => setThreadDraft((draft) => (draft.id === id ? { ...draft, id: "" } : draft)),
+ });
};
if (mixed) {
return (
-
@@ -129,10 +139,11 @@ export function HandoffSettings({ isProjectScope }: { readonly isProjectScope: b
return (
- clearScopedSettings(["handoff"])}
description={`${option?.description ?? ""}${scopeNote}`}
resetAction={
@@ -151,9 +162,12 @@ export function HandoffSettings({ isProjectScope }: { readonly isProjectScope: b
/>
}
/>
-
{rows.map((row) => (