Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions FORK_CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ setting is missing here or a setting named here does not exist.
| Model policy: the setting for which models (and efforts) agents may pick, per provider driver: off, advise or enforce, and the allowed rows. The server checks an agent's pick (`delegate_task`, `create_threads`, `t3_thread_launch`, `t3_thread_configure`, here, and both before and after it goes to linked machines): a model in no row, a call that names no model, or an effort off its row is refused in enforce, only noted in advise. A person's own pick is never refused; Settings marks one outside the rows. A bad hand edit, or a settings file that does not parse, refuses every agent pick (a warning if the value says advise). Settings offers the fork's start rows (Opus 5.5 and Fable 5.2) while none are saved. While it is on, a child whose call names its model keeps only the options it names. | Agents should use the models the person chose for each kind of work. | `server.modelPolicy` | off | [#268](https://github.com/scuttletoby/t3code/pull/268), [#731](https://github.com/scuttletoby/t3code/issues/731) |
| Placement, part 1: the settings only. `placement` (off, advise or enforce; this machine's labels, an optional facts command, label groups that must never meet on one machine, and a weight per linked machine) and `placementNeeds` (labels a project's work needs). Person-only; a bad `placement` reads as off and a bad `placementNeeds` fits no machine, each kept as written. Nothing reads them yet. | Delegated work should go to a machine that has what it needs, and never where it must not run. | `server.placement`, `server.placementNeeds`, `projectOverride.placementNeeds` | off | [#134](https://github.com/scuttletoby/t3code/issues/134) |
| Calm sidebar, part 1: the settings. `threadRoles` names the assistant thread and one orchestrator per project; the server refuses a role for a thread that is missing, deleted, a sub-agent, a side chat, delegated from a linked machine or in another project. `calmSidebarEnabled` is the per-device switch. Nothing shows them yet. | A short sidebar: the threads that matter on top, the rest folded. | `server.threadRoles`, `client.calmSidebarEnabled` | off | [#928](https://github.com/scuttletoby/t3code/pull/928) |
| Assistant setup: the switch `assistant.enabled` (off) offers **Make assistant** in Settings, which makes a thread in the Scratch project, names it `threadRoles.assistant` and picks for it the new built-in MCP profile `assistant` (no outside servers, no shell, file or web tools; T3 tool groups `orchestration`, `threads` and `projects`). Claude only. | One thread you talk to across projects, with only T3's tools. | `server.assistant`, `server.mcpProfiles` | off | [#953](https://github.com/scuttletoby/t3code/pull/953) |

## Repository, CI and releases

Expand Down
15 changes: 14 additions & 1 deletion apps/server/src/fork/mcpProfile.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ describe("MCP profile resolver: old and empty state", () => {
});
});

it.each(["all", "t3-only"])(
it.each(["all", "t3-only", "assistant"])(
"refuses %s when a hand edit put a profile of that name in the file",
(name) => {
const file = {
Expand Down Expand Up @@ -662,6 +662,19 @@ describe('builtinTools "none" (assistant)', () => {
);
});

it("the built-in assistant: no servers or built-in tools, three groups; a child keeps it", () => {
const picked = fromFile({ mcpThreadProfiles: { a1: "assistant" } });
const own = resolved(resolveMcpProfile(picked, [top("a1")]));
expect([own.name, own.source]).toEqual(["assistant", "thread-pick"]);
expect(own.profile).toEqual({
servers: [],
t3Tools: ["orchestration", "threads", "projects"],
builtinTools: "none",
});
const sub = resolved(resolveMcpProfile(picked, [child("c1"), top("a1")]));
expect(sub.profile).toEqual(own.profile);
});

it.each([["some"], [false], [["Bash"]]])("refuses, never widens, builtinTools %j", (value) => {
const broken = fromFile({
mcpProfiles: { odd: { servers: "all", t3Tools: "all", builtinTools: value } },
Expand Down
1 change: 1 addition & 0 deletions apps/server/src/golive/forkReport.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1127,6 +1127,7 @@ describe("__fork-report settings", () => {
placementNeeds:
"placement: settings only so far; nothing reads them yet (later placement rows)",
threadRoles: "calm sidebar: settings only so far; nothing reads them yet",
assistant: "only offers Make assistant; the assistant is the threadRoles.assistant thread",
};

it("counts every fork setting as a feature or names why it is not a switch", () => {
Expand Down
1 change: 1 addition & 0 deletions apps/server/src/policy/forkManagedSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import type { ForkServerSettingKey } from "@t3tools/contracts";

const WHOLE_ONLY = [
"assistant",
"handoff",
"mcpCarriedProfiles",
"mcpProfile",
Expand Down
179 changes: 179 additions & 0 deletions apps/web/src/components/settings/fork/AssistantSettings.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
/**
* Fork (assistant): the switch `assistant.enabled` and "Make assistant", which makes a thread in the
* Scratch project and names it the assistant (`threadRoles.assistant`) with the built-in profile
* `assistant`. Server-wide, so a project screen does not show it. Every write is an ordinary settings
* save from the person at the screen; agents cannot change these keys. Docs: docs/fork/assistant.md.
*/
/* 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_PROVIDER_INTERACTION_MODE,
DEFAULT_RUNTIME_MODE,
type EnvironmentId,
type ServerSettingsPatch,
} from "@t3tools/contracts";
import { scopeThreadRef } from "@t3tools/client-runtime/environment";
import { useNavigate } from "@tanstack/react-router";
import { useRef, useState } from "react";

import { newThreadId } from "~/lib/utils";
import { useScratchProject } from "../../../hooks/useScratchProject";
import { useThreadShells, waitForThreadShell } from "../../../state/entities";
import { useEnvironmentProviders } from "../../../state/environments";
import { threadEnvironment } from "../../../state/threads";
import { useAtomCommand } from "../../../state/use-atom-command";
import { buildThreadRouteParams } from "../../../threadRoutes";
import { Button } from "../../ui/button";
import { Switch } from "../../ui/switch";
import { useSettingsScope } from "../SettingsScopeContext";
import { SettingsSection } from "../settingsLayout";
import { useSearchableSetting } from "../settingsSearch";
import { useUpdateScopedSettings } from "../useScopedSettings";
import { ForkRow } from "./ForkRow";
import {
assistantModelSelection,
assistantProfilePatch,
assistantRolePatch,
assistantThreadState,
assistantThreadText,
} from "./assistantSetup.logic";

export function AssistantSettings() {
const searchableSetting = useSearchableSetting();
const updateSettings = useUpdateScopedSettings();
const { targets } = useSettingsScope();
const { openScratchProject } = useScratchProject();
const createThread = useAtomCommand(threadEnvironment.create, { reportFailure: false });
const deleteThread = useAtomCommand(threadEnvironment.delete, { reportFailure: false });
const providers = useEnvironmentProviders();
const shells = useThreadShells();
const navigate = useNavigate();
const [busy, setBusy] = useState(false);
const running = useRef(false);
const [error, setError] = useState<string | null>(null);

const target = targets.length === 1 ? targets[0]! : null;
if (target === null) {
return (
<SettingsSection id="assistant-section" title="Assistant">
<ForkRow
serverScoped
{...searchableSetting("assistant")}
settingKeys={["assistant"]}
lockPaths={["assistant"]}
mixed
description="The assistant is set per environment. Select one environment to set it up."
/>
</SettingsSection>
);
}
const environmentId: EnvironmentId = target.environmentId;
const enabled = target.settings.assistant.enabled;
const state = assistantThreadState(
target.settings.threadRoles.assistant,
shells.filter((thread) => thread.environmentId === environmentId),
);
const modelSelection = assistantModelSelection(providers.get(environmentId) ?? []);

// Resolves once the save settled: true when every target saved it.
const save = (patch: ServerSettingsPatch) =>
new Promise<boolean>((resolve) =>
updateSettings(patch, { onFailed: () => resolve(false), onSaved: () => resolve(true) }),
);

const makeAssistant = async () => {
// A ref, not only the state: a double click arrives before the disabled button re-renders.
if (modelSelection === null || running.current) return;
running.current = true;
setBusy(true);
setError(null);
try {
const project = await openScratchProject(environmentId);
if (project === null) return;
const threadId = newThreadId();
// The pick first: a stop at any later point leaves no thread, or a thread already narrowed.
// A pick for a thread that never gets made does nothing.
if (!(await save(assistantProfilePatch(threadId)))) {
setError("The server refused the assistant profile. Nothing was made.");
return;
}
const created = await createThread({
environmentId,
input: {
threadId,
projectId: project.id,
title: "Assistant",
modelSelection,
runtimeMode: DEFAULT_RUNTIME_MODE,
interactionMode: DEFAULT_PROVIDER_INTERACTION_MODE,
branch: null,
worktreePath: null,
},
});
if (created._tag === "Failure") {
setError("Could not make the assistant's thread. Try again.");
return;
}
// An empty thread the role save did not name is removed; one that got a message stays.
const discard = () =>
void deleteThread({ environmentId, input: { threadId, onlyIfUnused: true } });
const ref = scopeThreadRef(environmentId, threadId);
if (!(await waitForThreadShell(ref))) {
setError("The assistant's thread was made, but it did not reach this client. Try again.");
discard();
return;
}
if (!(await save(assistantRolePatch(threadId)))) {
setError("The server refused to name the new thread the assistant. It was removed.");
discard();
return;
}
void navigate({ to: "/$environmentId/$threadId", params: buildThreadRouteParams(ref) });
} finally {
running.current = false;
setBusy(false);
}
};

return (
<SettingsSection id="assistant-section" title="Assistant">
<ForkRow
serverScoped
{...searchableSetting("assistant")}
settingKeys={["assistant"]}
lockPaths={["assistant"]}
description="One thread you talk to across projects. It runs with the assistant profile: no shell, files, web or outside servers; it can read, start and message threads. Claude only. Off: Settings offers no Make assistant."
control={
<Switch
checked={enabled}
onCheckedChange={(checked) =>
updateSettings({ assistant: { enabled: Boolean(checked) } })
}
aria-label="Offer Make assistant"
/>
}
/>
{enabled ? (
<ForkRow
serverScoped
{...searchableSetting("assistant-thread")}
settingKeys={["threadRoles"]}
lockPaths={["threadRoles", "mcpThreadProfiles"]}
status={error}
description={`${assistantThreadText(state)} Make assistant makes a new thread in the Scratch project and names it the assistant; an earlier one stays as it is.${
modelSelection === null ? " It needs a Claude provider that is on and available." : ""
}`}
control={
<Button
size="sm"
variant="outline"
disabled={busy || modelSelection === null}
onClick={() => void makeAssistant()}
>
Make assistant
</Button>
}
/>
) : null}
</SettingsSection>
);
}
2 changes: 2 additions & 0 deletions apps/web/src/components/settings/fork/ForkSettingsPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { useSettingsScope } from "../SettingsScopeContext";
import { SettingsPageContainer, SettingsRow, SettingsSection } from "../settingsLayout";
import { useSearchableSetting } from "../settingsSearch";
import { WaitsAndSlotsSettings } from "../WaitsAndSlotsSettings";
import { AssistantSettings } from "./AssistantSettings";
import { forkFeatureStatuses } from "./forkStatus.logic";
import { HandoffSettings } from "./HandoffSettings";
import { McpProfileSettings } from "./McpProfileSettings";
Expand Down Expand Up @@ -49,6 +50,7 @@ export function ForkSettingsPanel() {
<HandoffSettings isProjectScope={isProjectScope} />
<PlaytestSettings isProjectScope={isProjectScope} />
<McpProfileSettings isProjectScope={isProjectScope} />
{isProjectScope ? null : <AssistantSettings />}
</SettingsPageContainer>
);
}
Expand Down
Loading
Loading