feat(settings): configure default permissions for new threads (#11346)
This commit is contained in:
1 parent
4d16e6bc6f
commit
cf1ba3d7da
13 files changed
+237
-66
No files matched your search
@@ -467,7 +467,10 @@ export function NewTaskFlowProvider(props: React.PropsWithChildren) {
|
||||
const draftStartFromOrigin = selectedProjectDraft.workspaceSelection?.startFromOrigin;
|
||||
const startFromOrigin =
|
||||
draftStartFromOrigin ?? projectSettings.settings.newWorktreesStartFromOrigin;
|
||||
const runtimeMode = selectedProjectDraft.runtimeMode ?? DEFAULT_RUNTIME_MODE;
|
||||
const defaultRuntimeMode = editingPendingTask
|
||||
? (editingPendingTask.runtimeMode ?? DEFAULT_RUNTIME_MODE)
|
||||
: projectSettings.settings.defaultRuntimeMode;
|
||||
const runtimeMode = selectedProjectDraft.runtimeMode ?? defaultRuntimeMode;
|
||||
|
||||
// Antigravity keeps unavailable selections so sign-out or a catalog change
|
||||
// cannot switch the user's model. Other providers retain their fallback
|
||||
@@ -978,7 +981,7 @@ export function NewTaskFlowProvider(props: React.PropsWithChildren) {
|
||||
text,
|
||||
attachments: draft.attachments,
|
||||
modelSelection: draftModelSelection,
|
||||
runtimeMode: draft.runtimeMode ?? DEFAULT_RUNTIME_MODE,
|
||||
runtimeMode: draft.runtimeMode ?? defaultRuntimeMode,
|
||||
interactionMode: resolvePendingTaskInteractionMode({
|
||||
preferenceLoaded: planModePreferenceLoaded,
|
||||
planModeEnabled: legacyPlanModeEnabled,
|
||||
@@ -1014,6 +1017,7 @@ export function NewTaskFlowProvider(props: React.PropsWithChildren) {
|
||||
};
|
||||
},
|
||||
[
|
||||
defaultRuntimeMode,
|
||||
editingPendingProject,
|
||||
editingPendingTask,
|
||||
selectedEnvironmentServerConfig,
|
||||
|
||||
@@ -225,12 +225,37 @@ it.effect("resolveAutoBootstrapWelcomeTargets returns existing project and threa
|
||||
});
|
||||
|
||||
it.effect.each([
|
||||
{ existing: false, machineModel: null, projectModel: null },
|
||||
{ existing: false, machineModel: "claude-sonnet-4-6", projectModel: null },
|
||||
{ existing: true, machineModel: "claude-sonnet-4-6", projectModel: null },
|
||||
{ existing: true, machineModel: "claude-sonnet-4-6", projectModel: "gpt-5.4" },
|
||||
])("auto-bootstrap model precedence: %j", ({ existing, machineModel, projectModel }) =>
|
||||
{
|
||||
existing: false,
|
||||
machineModel: null,
|
||||
projectModel: null,
|
||||
machineMode: "full-access",
|
||||
projectMode: null,
|
||||
},
|
||||
{
|
||||
existing: false,
|
||||
machineModel: "claude-sonnet-4-6",
|
||||
projectModel: null,
|
||||
machineMode: "approval-required",
|
||||
projectMode: null,
|
||||
},
|
||||
{
|
||||
existing: true,
|
||||
machineModel: "claude-sonnet-4-6",
|
||||
projectModel: null,
|
||||
machineMode: "auto",
|
||||
projectMode: null,
|
||||
},
|
||||
{
|
||||
existing: true,
|
||||
machineModel: "claude-sonnet-4-6",
|
||||
projectModel: "gpt-5.4",
|
||||
machineMode: "full-access",
|
||||
projectMode: "auto-accept-edits",
|
||||
},
|
||||
] as const)("auto-bootstrap model and permissions precedence: %j", (options) =>
|
||||
Effect.gen(function* () {
|
||||
const { existing, machineModel, projectModel, machineMode, projectMode } = options;
|
||||
const machineSelection = machineModel
|
||||
? { instanceId: ProviderInstanceId.make("claude-code"), model: machineModel }
|
||||
: null;
|
||||
@@ -242,16 +267,21 @@ it.effect.each([
|
||||
readonly type: string;
|
||||
readonly defaultModelSelection?: unknown;
|
||||
readonly modelSelection?: unknown;
|
||||
readonly runtimeMode?: unknown;
|
||||
}>
|
||||
>([]);
|
||||
const targets = yield* ServerRuntimeStartup.resolveAutoBootstrapWelcomeTargets.pipe(
|
||||
Effect.provide(
|
||||
ServerSettings.layerTest({
|
||||
defaultModelSelection: machineSelection,
|
||||
defaultRuntimeMode: machineMode,
|
||||
projectSettingsOverrides:
|
||||
existing && projectSelection
|
||||
? {
|
||||
[ProjectId.make("existing-project")]: { defaultModelSelection: projectSelection },
|
||||
[ProjectId.make("existing-project")]: {
|
||||
defaultModelSelection: projectSelection,
|
||||
...(projectMode ? { defaultRuntimeMode: projectMode } : {}),
|
||||
},
|
||||
}
|
||||
: {},
|
||||
}),
|
||||
@@ -321,6 +351,7 @@ it.effect.each([
|
||||
existing ? ["thread.create"] : ["project.create", "thread.create"],
|
||||
);
|
||||
if (!existing) assert.equal("defaultModelSelection" in commands[0]!, false);
|
||||
assert.equal(commands.at(-1)?.runtimeMode, projectMode ?? machineMode);
|
||||
assert.deepStrictEqual(
|
||||
commands.at(-1)?.modelSelection,
|
||||
projectSelection ??
|
||||
|
||||
@@ -248,7 +248,8 @@ export const resolveAutoBootstrapWelcomeTargets = Effect.gen(function* () {
|
||||
title: "New thread",
|
||||
modelSelection: nextThreadModelSelection,
|
||||
interactionMode: DEFAULT_PROVIDER_INTERACTION_MODE,
|
||||
runtimeMode: "full-access",
|
||||
runtimeMode: resolveProjectSettings(settings, nextProjectId).settings
|
||||
.defaultRuntimeMode,
|
||||
branch: null,
|
||||
worktreePath: null,
|
||||
createdAt,
|
||||
|
||||
@@ -154,7 +154,6 @@ import {
|
||||
} from "../proposedPlan";
|
||||
import {
|
||||
DEFAULT_INTERACTION_MODE,
|
||||
DEFAULT_RUNTIME_MODE,
|
||||
DEFAULT_THREAD_TERMINAL_ID,
|
||||
MAX_TERMINALS_PER_GROUP,
|
||||
type ChatMessage,
|
||||
@@ -1839,7 +1838,11 @@ export default function ChatView(props: ChatViewProps) {
|
||||
// session.lastError. Bump a tick so the banner hides immediately. Mirrors
|
||||
// the branch mismatch banner.
|
||||
const [, setThreadErrorBannerDismissTick] = useState(0);
|
||||
const runtimeMode = composerRuntimeMode ?? activeThread?.runtimeMode ?? DEFAULT_RUNTIME_MODE;
|
||||
const defaultRuntimeMode = resolveProjectSettings(settings, activeThread?.projectId ?? null)
|
||||
.settings.defaultRuntimeMode;
|
||||
// Implicit drafts follow their current project/environment, including retargets.
|
||||
// Explicit composer choices and existing server threads retain their permissions.
|
||||
const runtimeMode = composerRuntimeMode ?? activeServerThread?.runtimeMode ?? defaultRuntimeMode;
|
||||
const isLocalDraftThread = !isServerThread && localDraftThread !== undefined;
|
||||
const canCheckoutPullRequestIntoThread = isLocalDraftThread;
|
||||
const activeThreadId = activeThread?.id ?? null;
|
||||
@@ -2293,7 +2296,8 @@ export default function ChatView(props: ChatViewProps) {
|
||||
setLogicalProjectDraftThreadId(logicalProjectKey, activeProjectRef, nextDraftId, {
|
||||
threadId: nextThreadId,
|
||||
createdAt: new Date().toISOString(),
|
||||
runtimeMode: DEFAULT_RUNTIME_MODE,
|
||||
runtimeMode: resolveProjectSettings(settings, activeProject.id, activeProject).settings
|
||||
.defaultRuntimeMode,
|
||||
interactionMode: DEFAULT_INTERACTION_MODE,
|
||||
...input,
|
||||
});
|
||||
@@ -2312,6 +2316,7 @@ export default function ChatView(props: ChatViewProps) {
|
||||
navigate,
|
||||
projectGroupingSettings,
|
||||
routeKind,
|
||||
settings,
|
||||
setDraftThreadContext,
|
||||
setLogicalProjectDraftThreadId,
|
||||
],
|
||||
@@ -7890,7 +7895,7 @@ export default function ChatView(props: ChatViewProps) {
|
||||
projectId: activeProject.id,
|
||||
title: nextThreadTitle,
|
||||
modelSelection: nextThreadModelSelection,
|
||||
runtimeMode,
|
||||
runtimeMode: defaultRuntimeMode,
|
||||
interactionMode: "default",
|
||||
branch: activeThreadBranch,
|
||||
worktreePath: activeThread.worktreePath,
|
||||
@@ -7913,7 +7918,7 @@ export default function ChatView(props: ChatViewProps) {
|
||||
},
|
||||
modelSelection: ctxSelectedModelSelection,
|
||||
titleSeed: nextThreadTitle,
|
||||
runtimeMode,
|
||||
runtimeMode: defaultRuntimeMode,
|
||||
interactionMode: "default",
|
||||
sourceProposedPlan: {
|
||||
threadId: activeThread.id,
|
||||
@@ -7987,7 +7992,7 @@ export default function ChatView(props: ChatViewProps) {
|
||||
isServerThread,
|
||||
navigate,
|
||||
resetLocalDispatch,
|
||||
runtimeMode,
|
||||
defaultRuntimeMode,
|
||||
startThreadTurn,
|
||||
environmentId,
|
||||
composerRef,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { runtimeModeConfig, runtimeModeOptions } from "./runtimeModeConfig";
|
||||
import { RefreshIcon } from "~/components/ui/refresh-icon";
|
||||
import {
|
||||
questionAttachmentDraftId,
|
||||
@@ -850,11 +851,6 @@ import {
|
||||
PaperclipIcon,
|
||||
PencilRulerIcon,
|
||||
PlayIcon,
|
||||
type LucideIcon,
|
||||
LockIcon,
|
||||
LockOpenIcon,
|
||||
PenLineIcon,
|
||||
SparklesIcon,
|
||||
XIcon,
|
||||
} from "lucide-react";
|
||||
import { proposedPlanTitle } from "../../proposedPlan";
|
||||
@@ -898,33 +894,6 @@ import type { ReviewCommentContext } from "../../reviewCommentContext";
|
||||
|
||||
const WORKSPACE_SNAPSHOT_RETRY_COOLDOWN_MS = 10_000;
|
||||
|
||||
const runtimeModeConfig: Record<
|
||||
RuntimeMode,
|
||||
{ label: string; description: string; icon: LucideIcon }
|
||||
> = {
|
||||
"approval-required": {
|
||||
label: "Supervised",
|
||||
description: "Ask before commands and file changes.",
|
||||
icon: LockIcon,
|
||||
},
|
||||
"auto-accept-edits": {
|
||||
label: "Auto-accept edits",
|
||||
description: "Auto-approve edits, ask before other actions.",
|
||||
icon: PenLineIcon,
|
||||
},
|
||||
auto: {
|
||||
label: "Auto",
|
||||
description: "Supported providers approve routine actions; others still ask.",
|
||||
icon: SparklesIcon,
|
||||
},
|
||||
"full-access": {
|
||||
label: "Full access",
|
||||
description: "Allow commands and edits without prompts.",
|
||||
icon: LockOpenIcon,
|
||||
},
|
||||
};
|
||||
|
||||
const runtimeModeOptions = Object.keys(runtimeModeConfig) as RuntimeMode[];
|
||||
const extendReplacementRangeForTrailingSpace = (
|
||||
text: string,
|
||||
rangeEnd: number,
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
import type { RuntimeMode } from "@t3tools/contracts";
|
||||
import { type LucideIcon, LockIcon, LockOpenIcon, PenLineIcon, SparklesIcon } from "lucide-react";
|
||||
|
||||
export const runtimeModeConfig: Record<
|
||||
RuntimeMode,
|
||||
{ label: string; description: string; icon: LucideIcon }
|
||||
> = {
|
||||
"approval-required": {
|
||||
label: "Supervised",
|
||||
description: "Ask before commands and file changes.",
|
||||
icon: LockIcon,
|
||||
},
|
||||
"auto-accept-edits": {
|
||||
label: "Auto-accept edits",
|
||||
description: "Auto-approve edits, ask before other actions.",
|
||||
icon: PenLineIcon,
|
||||
},
|
||||
auto: {
|
||||
label: "Auto",
|
||||
description: "Supported providers approve routine actions; others still ask.",
|
||||
icon: SparklesIcon,
|
||||
},
|
||||
"full-access": {
|
||||
label: "Full access",
|
||||
description: "Allow commands and edits without prompts.",
|
||||
icon: LockOpenIcon,
|
||||
},
|
||||
};
|
||||
|
||||
export const runtimeModeOptions = Object.keys(runtimeModeConfig) as RuntimeMode[];
|
||||
@@ -19,6 +19,7 @@ import { useEnvironments } from "../../state/environments";
|
||||
import { EMPTY_SERVER_PROVIDERS } from "../../state/server";
|
||||
import { resolveEnvModeLabel } from "../BranchToolbar.logic";
|
||||
import { ProviderModelPicker } from "../chat/ProviderModelPicker";
|
||||
import { runtimeModeConfig, runtimeModeOptions } from "../chat/runtimeModeConfig";
|
||||
import { PULL_REQUEST_MERGE_METHOD_LABELS } from "../pullRequest/pullRequestDetail.logic";
|
||||
import { TraitsPicker } from "../chat/TraitsPicker";
|
||||
import { Select, SelectItem, SelectPopup, SelectTrigger, SelectValue } from "../ui/select";
|
||||
@@ -67,6 +68,8 @@ export function ProjectDefaultsSettings({ category }: { category: ProjectSetting
|
||||
);
|
||||
const activeEntry = entries.find((entry) => entry.instanceId === selection?.instanceId);
|
||||
const mixedModel = useScopedSettingsMixed(["defaultModelSelection"]);
|
||||
const mixedPermissions = useScopedSettingsMixed(["defaultRuntimeMode"]);
|
||||
const PermissionIcon = runtimeModeConfig[settings.defaultRuntimeMode].icon;
|
||||
const mixedWorkspace = useScopedSettingsMixed(["defaultThreadEnvMode"]);
|
||||
const mixedBrowser = useScopedSettingsMixed(["enableAgentBrowserAccess"]);
|
||||
const mixedAutoPull = useScopedSettingsMixed(["defaultAutoPull"]);
|
||||
@@ -220,6 +223,67 @@ export function ProjectDefaultsSettings({ category }: { category: ProjectSetting
|
||||
)
|
||||
}
|
||||
/>
|
||||
<SettingsRow
|
||||
serverScoped
|
||||
settingKeys={["defaultRuntimeMode"]}
|
||||
mixed={mixedPermissions}
|
||||
{...searchableSetting("default-permissions")}
|
||||
description={
|
||||
isProjectScope
|
||||
? "Permissions for new threads in this project."
|
||||
: "Default permissions for new threads. Projects can override them."
|
||||
}
|
||||
resetAction={
|
||||
settings.defaultRuntimeMode !== DEFAULT_SERVER_SETTINGS.defaultRuntimeMode ? (
|
||||
<SettingResetButton
|
||||
label="default permissions"
|
||||
onClick={() =>
|
||||
updateSettings({
|
||||
defaultRuntimeMode: DEFAULT_SERVER_SETTINGS.defaultRuntimeMode,
|
||||
})
|
||||
}
|
||||
/>
|
||||
) : null
|
||||
}
|
||||
control={
|
||||
<Select
|
||||
value={mixedPermissions ? null : settings.defaultRuntimeMode}
|
||||
onValueChange={(value) => {
|
||||
if (value) updateSettings({ defaultRuntimeMode: value });
|
||||
}}
|
||||
>
|
||||
<SelectTrigger size="sm" aria-label="Default permissions">
|
||||
{!mixedPermissions && (
|
||||
<PermissionIcon className="size-3.5 shrink-0 text-muted-foreground" />
|
||||
)}
|
||||
<SelectValue>
|
||||
{mixedPermissions
|
||||
? "Mixed"
|
||||
: runtimeModeConfig[settings.defaultRuntimeMode].label}
|
||||
</SelectValue>
|
||||
</SelectTrigger>
|
||||
<SelectPopup align="end" alignItemWithTrigger={false}>
|
||||
{runtimeModeOptions.map((mode) => {
|
||||
const option = runtimeModeConfig[mode];
|
||||
const Icon = option.icon;
|
||||
return (
|
||||
<SelectItem key={mode} value={mode} className="min-w-64 py-2">
|
||||
<div className="grid gap-0.5">
|
||||
<span className="inline-flex items-center gap-1.5 font-medium">
|
||||
<Icon className="size-3.5 shrink-0 text-muted-foreground" />
|
||||
{option.label}
|
||||
</span>
|
||||
<span className="text-xs leading-4 text-muted-foreground">
|
||||
{option.description}
|
||||
</span>
|
||||
</div>
|
||||
</SelectItem>
|
||||
);
|
||||
})}
|
||||
</SelectPopup>
|
||||
</Select>
|
||||
}
|
||||
/>
|
||||
<SettingsRow
|
||||
serverScoped
|
||||
settingKeys={["defaultThreadEnvMode"]}
|
||||
|
||||
@@ -108,6 +108,15 @@ export const SETTINGS_SEARCH_ITEMS = [
|
||||
scope: "project-defaults",
|
||||
searchTerms: ["new thread project provider reasoning effort"],
|
||||
},
|
||||
{
|
||||
id: "default-permissions",
|
||||
title: "Permissions",
|
||||
to: "/settings/general",
|
||||
scope: "project-defaults",
|
||||
searchTerms: [
|
||||
"new thread default runtime mode supervised approvals auto accept edits full access",
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "color-scheme",
|
||||
title: "Color scheme",
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { describe, expect, it, vi } from "vite-plus/test";
|
||||
import type { RuntimeMode } from "@t3tools/contracts";
|
||||
|
||||
const testState = vi.hoisted(() => {
|
||||
let completeProjectFileRead: (value: null) => void = () => undefined;
|
||||
@@ -7,6 +8,7 @@ const testState = vi.hoisted(() => {
|
||||
defaultThreadEnvMode: "local" as "local" | "worktree",
|
||||
newWorktreesStartFromOrigin: false,
|
||||
defaultModelSelection: null,
|
||||
defaultRuntimeMode: "full-access" as RuntimeMode,
|
||||
};
|
||||
let storedDraft: {
|
||||
readonly draftId: string;
|
||||
@@ -55,6 +57,7 @@ const testState = vi.hoisted(() => {
|
||||
defaultThreadEnvMode: workspaceDefaults.envMode,
|
||||
newWorktreesStartFromOrigin: workspaceDefaults.startFromOrigin,
|
||||
defaultModelSelection: null,
|
||||
defaultRuntimeMode: "full-access",
|
||||
};
|
||||
router.state.location.href = "/";
|
||||
router.navigate.mockClear();
|
||||
@@ -184,6 +187,28 @@ describe.each([
|
||||
},
|
||||
],
|
||||
])("useNewThreadHandler with a %s draft", (_, draft) => {
|
||||
it.each(["approval-required", "auto-accept-edits", "auto", "full-access"] as const)(
|
||||
"uses the target environment's %s permissions for new threads",
|
||||
async (runtimeMode) => {
|
||||
testState.reset(draft);
|
||||
testState.targetSettings.defaultRuntimeMode = runtimeMode;
|
||||
const projectRef = {
|
||||
environmentId: "environment-ssh",
|
||||
projectId: "project-remote",
|
||||
} as never;
|
||||
const pendingOpen = useNewThreadHandler()(projectRef);
|
||||
testState.completeProjectFileRead(null);
|
||||
const opened = await pendingOpen;
|
||||
|
||||
expect(testState.draftStore.setLogicalProjectDraftThreadId).toHaveBeenCalledWith(
|
||||
"remote-project",
|
||||
projectRef,
|
||||
opened!.draftId,
|
||||
expect.objectContaining({ runtimeMode }),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
it("abandons a delayed draft open when the user navigates elsewhere", async () => {
|
||||
testState.reset(draft);
|
||||
const openThread = useNewThreadHandler();
|
||||
|
||||
@@ -4,12 +4,7 @@ import {
|
||||
scopeProjectRef,
|
||||
scopeThreadRef,
|
||||
} from "@t3tools/client-runtime/environment";
|
||||
import {
|
||||
DEFAULT_RUNTIME_MODE,
|
||||
DEFAULT_SERVER_SETTINGS,
|
||||
type ScopedProjectRef,
|
||||
type ThreadId,
|
||||
} from "@t3tools/contracts";
|
||||
import { DEFAULT_SERVER_SETTINGS, type ScopedProjectRef, type ThreadId } from "@t3tools/contracts";
|
||||
import { useParams, useRouter } from "@tanstack/react-router";
|
||||
import { useCallback, useMemo } from "react";
|
||||
import {
|
||||
@@ -100,8 +95,8 @@ export function useNewThreadHandler() {
|
||||
const routeChangedSinceRequest = () => router.state.location.href !== requestingRouteHref;
|
||||
const currentRouteTarget = getCurrentRouteTarget();
|
||||
// A new thread carries the user's working mode from the thread being
|
||||
// viewed. The target project's configured model still wins; runtime and
|
||||
// interaction modes carry independently. Branch, worktree, and env mode
|
||||
// viewed. The target project's configured model still wins; interaction
|
||||
// mode carries independently. Permissions, branch, worktree, and env mode
|
||||
// come from configured defaults unless the caller passes them explicitly.
|
||||
const carrySourceShell =
|
||||
currentRouteTarget?.kind === "server"
|
||||
@@ -124,11 +119,6 @@ export function useNewThreadHandler() {
|
||||
: null;
|
||||
const carryModelSelection =
|
||||
composerModelSelection ?? carrySourceShell?.modelSelection ?? null;
|
||||
const carryRuntimeMode =
|
||||
carrySourceComposer?.runtimeMode ??
|
||||
carrySourceShell?.runtimeMode ??
|
||||
carrySourceDraft?.runtimeMode ??
|
||||
null;
|
||||
const carryInteractionMode =
|
||||
carrySourceComposer?.interactionMode ??
|
||||
carrySourceShell?.interactionMode ??
|
||||
@@ -147,6 +137,7 @@ export function useNewThreadHandler() {
|
||||
project,
|
||||
);
|
||||
const projectDefaultModelSelection = projectSettings.settings.defaultModelSelection;
|
||||
const defaultRuntimeMode = projectSettings.settings.defaultRuntimeMode;
|
||||
const projectThreadEnvMode =
|
||||
projectSettings.sources.defaultThreadEnvMode === "project"
|
||||
? projectSettings.settings.defaultThreadEnvMode
|
||||
@@ -276,7 +267,7 @@ export function useNewThreadHandler() {
|
||||
if (workspaceContext) {
|
||||
setDraftThreadContext(emptyStoredDraftThread.draftId, {
|
||||
...workspaceContext,
|
||||
...(carryRuntimeMode ? { runtimeMode: carryRuntimeMode } : {}),
|
||||
...(!isDraftAlreadyOpen ? { runtimeMode: defaultRuntimeMode } : {}),
|
||||
...(carryInteractionMode ? { interactionMode: carryInteractionMode } : {}),
|
||||
});
|
||||
}
|
||||
@@ -313,7 +304,7 @@ export function useNewThreadHandler() {
|
||||
{
|
||||
threadId: emptyStoredDraftThread.threadId,
|
||||
...workspaceContext,
|
||||
...(carryRuntimeMode ? { runtimeMode: carryRuntimeMode } : {}),
|
||||
...(!isDraftAlreadyOpen ? { runtimeMode: defaultRuntimeMode } : {}),
|
||||
...(carryInteractionMode ? { interactionMode: carryInteractionMode } : {}),
|
||||
},
|
||||
);
|
||||
@@ -426,7 +417,7 @@ export function useNewThreadHandler() {
|
||||
envMode: initialEnvMode,
|
||||
newWorktreesStartFromOrigin: projectSettings.settings.newWorktreesStartFromOrigin,
|
||||
}),
|
||||
runtimeMode: carryRuntimeMode ?? DEFAULT_RUNTIME_MODE,
|
||||
runtimeMode: defaultRuntimeMode,
|
||||
...(carryInteractionMode ? { interactionMode: carryInteractionMode } : {}),
|
||||
});
|
||||
applyStickyState(draftId);
|
||||
|
||||
@@ -3,8 +3,10 @@
|
||||
Permission modes control when an agent needs your approval to act. Choose a mode in the message
|
||||
composer; it applies to that thread.
|
||||
|
||||
New threads start in **Full access** unless you choose another mode before sending. A thread
|
||||
created from another thread inherits its mode.
|
||||
Set the default for new threads in **Settings → General → New threads → Permissions**.
|
||||
Projects can override the environment default. New threads use this setting rather than the
|
||||
mode of the thread you were viewing. The initial default is **Full access**; existing threads
|
||||
and modes you choose in a draft keep their permissions.
|
||||
|
||||
| Mode | Behavior |
|
||||
| --------------------- | ------------------------------------------------------------------------------------- |
|
||||
|
||||
@@ -20,6 +20,35 @@ const decodeServerSettingsPatch = Schema.decodeUnknownSync(ServerSettingsPatch);
|
||||
const encodeServerSettings = Schema.encodeSync(ServerSettings);
|
||||
const decodeClaudeSettings = Schema.decodeUnknownSync(ClaudeSettings);
|
||||
|
||||
describe("ServerSettings default permissions", () => {
|
||||
it("keeps full access for settings saved before a default was configured", () => {
|
||||
expect(decodeServerSettings({}).defaultRuntimeMode).toBe("full-access");
|
||||
expect(DEFAULT_SERVER_SETTINGS.defaultRuntimeMode).toBe("full-access");
|
||||
});
|
||||
|
||||
it.each(["approval-required", "auto-accept-edits", "auto", "full-access"])(
|
||||
"round-trips %s as an environment default and project override",
|
||||
(defaultRuntimeMode) => {
|
||||
const input = {
|
||||
defaultRuntimeMode,
|
||||
projectSettingsOverrides: { project: { defaultRuntimeMode } },
|
||||
};
|
||||
expect(encodeServerSettings(decodeServerSettings(input))).toMatchObject(input);
|
||||
expect(decodeServerSettingsPatch(input)).toEqual(input);
|
||||
},
|
||||
);
|
||||
|
||||
it("rejects unsupported permission defaults", () => {
|
||||
expect(() => decodeServerSettings({ defaultRuntimeMode: "unsupported" })).toThrow();
|
||||
expect(() => decodeServerSettingsPatch({ defaultRuntimeMode: "unsupported" })).toThrow();
|
||||
expect(() =>
|
||||
decodeServerSettingsPatch({
|
||||
projectSettingsOverrides: { project: { defaultRuntimeMode: "unsupported" } },
|
||||
}),
|
||||
).toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
describe("ServerSettings usage price overrides", () => {
|
||||
const prices = { inputCostPerMillionTokens: 2, outputCostPerMillionTokens: 8 };
|
||||
|
||||
|
||||
@@ -18,7 +18,12 @@ import {
|
||||
DEFAULT_TEXT_GENERATION_REASONING_EFFORT,
|
||||
ProviderOptionSelections,
|
||||
} from "./model.ts";
|
||||
import { ModelSelection, ProjectScript } from "./orchestration.ts";
|
||||
import {
|
||||
DEFAULT_RUNTIME_MODE,
|
||||
ModelSelection,
|
||||
ProjectScript,
|
||||
RuntimeMode,
|
||||
} from "./orchestration.ts";
|
||||
import { BrowserProfile, BrowserProfileId, DEFAULT_BROWSER_PROFILE_ID } from "./browserProfile.ts";
|
||||
import {
|
||||
DEFAULT_PREVIEW_APPEARANCE,
|
||||
@@ -934,6 +939,7 @@ export type BackgroundActivitySettings = typeof BackgroundActivitySettings.Type;
|
||||
*/
|
||||
export const PROJECT_SCOPED_SERVER_SETTING_KEYS = [
|
||||
"defaultModelSelection",
|
||||
"defaultRuntimeMode",
|
||||
"defaultThreadEnvMode",
|
||||
"newWorktreesStartFromOrigin",
|
||||
"defaultAutoPull",
|
||||
@@ -958,6 +964,7 @@ export type ProjectScopedServerSettingKey = (typeof PROJECT_SCOPED_SERVER_SETTIN
|
||||
*/
|
||||
export const ProjectSettingsOverrides = Schema.Struct({
|
||||
defaultModelSelection: Schema.optionalKey(Schema.NullOr(ModelSelection)),
|
||||
defaultRuntimeMode: Schema.optionalKey(RuntimeMode),
|
||||
defaultThreadEnvMode: Schema.optionalKey(ThreadEnvMode),
|
||||
newWorktreesStartFromOrigin: Schema.optionalKey(Schema.Boolean),
|
||||
defaultAutoPull: Schema.optionalKey(Schema.Boolean),
|
||||
@@ -1015,6 +1022,9 @@ export const ServerSettings = Schema.Struct({
|
||||
defaultModelSelection: Schema.NullOr(ModelSelection).pipe(
|
||||
Schema.withDecodingDefault(Effect.succeed(null)),
|
||||
),
|
||||
defaultRuntimeMode: RuntimeMode.pipe(
|
||||
Schema.withDecodingDefault(Effect.succeed(DEFAULT_RUNTIME_MODE)),
|
||||
),
|
||||
/**
|
||||
* Per-project overrides of the keys in `PROJECT_SCOPED_SERVER_SETTING_KEYS`.
|
||||
* The source of truth for project settings; `projectAgentBrowserAccessOverrides`,
|
||||
@@ -1328,6 +1338,7 @@ export const ServerSettingsPatch = Schema.Struct({
|
||||
Schema.Record(ProjectId, Schema.NullOr(Schema.Boolean)),
|
||||
),
|
||||
defaultModelSelection: Schema.optionalKey(Schema.NullOr(ModelSelection)),
|
||||
defaultRuntimeMode: Schema.optionalKey(RuntimeMode),
|
||||
/**
|
||||
* Per-project entry replacement: each entry replaces that project's whole
|
||||
* override set and `null` removes it. Clearing one override means resending
|
||||
|
||||
Reference in new issue
Block a user