@devries-cameron20 / t3code-1 / commits / 7a4f5b6188
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

feat(settings): add and list 1Password secret providers behind T3CODE_FEATURE_SECRETS (#25709)

Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com> Co-authored-by: Julius Marminge <julius0216@outlook.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Yordis Prieto committed Oct 29, 2026 at 13:15 UTC 7a4f5b6188fed54ddc866723e39446a198b5835c
19 files changed +782 -5
apps/server/src/auth/RpcAuthorization.test.ts
+7 -1
@@ -6,6 +6,7 @@ import {
6 AuthSettingsWriteScope,
7 DEFAULT_SERVER_SETTINGS,
8 ProviderInstanceId,
9 + SecretProviderId,
10 ThreadId,
11 AuthOrchestrationOperateScope,
12 AuthOrchestrationReadScope,
@@ -173,7 +174,7 @@ describe("settings mutation authorization", () => {
174 }).pipe(Effect.scoped),
175 );
176
176 - it.effect("does not let a settings grant create or remove providers", () =>
177 + it.effect("does not let a settings grant create or remove providers or secret providers", () =>
178 Effect.gen(function* () {
179 let handled = false;
180 const client = yield* RpcTest.makeClient(group).pipe(
@@ -195,6 +196,11 @@ describe("settings mutation authorization", () => {
196 providerInstanceMutation,
197 }).pipe(Effect.flip),
198 ).toMatchObject({ requiredPermission: AuthProvidersManageScope });
199 + expect(
200 + yield* client[WS_METHODS.serverUpdateSettings]({
201 + patch: { secretProviders: { [SecretProviderId.make("personal")]: null } },
202 + }).pipe(Effect.flip),
203 + ).toMatchObject({ requiredPermission: AuthProvidersManageScope });
204 expect(handled).toBe(false);
205 }).pipe(Effect.scoped),
206 );
apps/web/src/components/Icons.tsx
+9
@@ -505,3 +505,12 @@ export const MacAccessibilityIcon: Icon = (props) => {
505 </svg>
506 );
507 };
508 +
509 +export const OnePasswordIcon: Icon = (props) => (
510 + <svg {...props} viewBox="0 0 24 24" fill="none">
511 + <path
512 + d="M12 0c6.627 0 12 5.373 12 12 0 6.628-5.373 12-12 12S0 18.628 0 12C0 5.373 5.373 0 12 0m-.893 4.86c-.485 0-.727.001-.913.095a.87.87 0 0 0-.378.379c-.094.185-.095.428-.095.912v2.747c0 .12 0 .182.016.238q.02.075.065.138a1 1 0 0 0 .175.162l.695.564c.113.092.17.139.19.194a.22.22 0 0 1 0 .15c-.02.056-.077.102-.19.194l-.695.564a1 1 0 0 0-.175.162.4.4 0 0 0-.065.138 1 1 0 0 0-.016.238v6.019c0 .485 0 .728.095.913a.87.87 0 0 0 .378.378c.186.094.428.094.913.094h1.786c.485 0 .727 0 .913-.094a.87.87 0 0 0 .378-.378c.095-.185.095-.428.095-.913v-2.747c0-.12 0-.182-.016-.238a.4.4 0 0 0-.065-.138 1 1 0 0 0-.175-.162l-.695-.564c-.113-.092-.17-.138-.191-.193a.22.22 0 0 1 0-.152c.02-.055.078-.1.19-.193l.696-.564a1 1 0 0 0 .175-.162.4.4 0 0 0 .065-.138 1 1 0 0 0 .016-.238V6.246c0-.484 0-.727-.095-.912a.87.87 0 0 0-.378-.379c-.186-.094-.428-.094-.913-.094Z"
513 + fill="currentColor"
514 + />
515 + </svg>
516 +);
apps/web/src/components/settings/SecretProviderDialog.logic.test.ts new
+51
@@ -0,0 +1,51 @@
1 +import { SecretProviderId } from "@t3tools/contracts";
2 +import * as Result from "effect/Result";
3 +import { describe, expect, it } from "vite-plus/test";
4 +
5 +import { secretProviderFromDraft } from "./SecretProviderDialog.logic";
6 +
7 +describe("secretProviderFromDraft", () => {
8 + it("adds a provider keyed by its name and reports every field that blocks it", () => {
9 + expect(
10 + secretProviderFromDraft({ name: " 1Password! ", account: "my.1password.com" }, new Set(), {
11 + mode: "add",
12 + }),
13 + ).toEqual(
14 + Result.succeed({
15 + id: "1password",
16 + config: {
17 + kind: "one_password",
18 + label: "1Password!",
19 + config: { account: "my.1password.com" },
20 + },
21 + }),
22 + );
23 +
24 + const blocked = secretProviderFromDraft(
25 + { name: "1Password", account: "--help" },
26 + new Set(["1password"]),
27 + { mode: "add" },
28 + );
29 + expect(Result.isFailure(blocked) && Object.keys(blocked.failure).toSorted()).toEqual([
30 + "account",
31 + "name",
32 + ]);
33 + });
34 +
35 + it("keeps the id when an edit renames the provider", () => {
36 + const id = SecretProviderId.make("personal");
37 + const result = secretProviderFromDraft(
38 + { name: "Personal (team)", account: "team.1password.com" },
39 + new Set(["personal"]),
40 + { mode: "edit", id },
41 + );
42 + expect(Result.isSuccess(result) && result.success).toEqual({
43 + id,
44 + config: {
45 + kind: "one_password",
46 + label: "Personal (team)",
47 + config: { account: "team.1password.com" },
48 + },
49 + });
50 + });
51 +});
apps/web/src/components/settings/SecretProviderDialog.logic.ts new
+117
@@ -0,0 +1,117 @@
1 +import {
2 + OnePasswordSecretProviderConfig,
3 + SecretProviderId,
4 + SecretProviderKind,
5 + SecretProviderLabel,
6 + type OnePasswordAccount,
7 + type SecretProviderConfig,
8 +} from "@t3tools/contracts";
9 +import * as Option from "effect/Option";
10 +import * as Result from "effect/Result";
11 +import * as Schema from "effect/Schema";
12 +
13 +const decodeSecretProviderId = Schema.decodeOption(SecretProviderId);
14 +const decodeOnePasswordConfig = Schema.decodeUnknownOption(OnePasswordSecretProviderConfig);
15 +
16 +export type ClassifiedSecretProvider =
17 + | { readonly kind: "one_password"; readonly account: OnePasswordAccount }
18 + | { readonly kind: "unsupported" };
19 +
20 +/** Unknown kinds and configs that no longer decode are shown read-only; removal stays available. */
21 +export function classifySecretProvider(provider: SecretProviderConfig): ClassifiedSecretProvider {
22 + if (provider.kind !== "one_password") return { kind: "unsupported" };
23 + const decoded = decodeOnePasswordConfig(provider.config);
24 + return decoded._tag === "Some"
25 + ? { kind: "one_password", account: decoded.value.account }
26 + : { kind: "unsupported" };
27 +}
28 +
29 +/** Stable and readable in settings.json, so re-adding a provider under the same name restores its variables. */
30 +function secretProviderIdFromName(name: string): SecretProviderId | null {
31 + const slug = name
32 + .toLowerCase()
33 + .replace(/[^a-z0-9]+/g, "-")
34 + .replace(/^-|-$/g, "")
35 + .slice(0, 64)
36 + .replace(/-$/, "");
37 + return Option.getOrNull(decodeSecretProviderId(slug));
38 +}
39 +
40 +export interface SecretProviderDraft {
41 + readonly name: string;
42 + readonly account: string;
43 +}
44 +
45 +export function draftFromSecretProvider(provider: SecretProviderConfig): SecretProviderDraft {
46 + const classified = classifySecretProvider(provider);
47 + return {
48 + name: provider.label,
49 + account: classified.kind === "one_password" ? classified.account : "",
50 + };
51 +}
52 +
53 +export type SecretProviderTarget =
54 + | { readonly mode: "add" }
55 + | { readonly mode: "edit"; readonly id: SecretProviderId };
56 +
57 +export type SecretProviderDraftIssues = {
58 + readonly [Field in keyof SecretProviderDraft]?: string;
59 +};
60 +
61 +function decodeField<S extends Schema.ConstraintDecoder<unknown>>(
62 + schema: S,
63 + value: string,
64 + emptyMessage: string,
65 +): Result.Result<S["Type"], string> {
66 + const trimmed = value.trim();
67 + if (trimmed.length === 0) return Result.fail(emptyMessage);
68 + return Result.mapError(Schema.decodeResult(schema)(trimmed), (error) => error.message);
69 +}
70 +
71 +/** The settings entry a draft adds or replaces, or every field that blocks it, one message each. */
72 +export function secretProviderFromDraft(
73 + draft: SecretProviderDraft,
74 + existingIds: ReadonlySet<string>,
75 + target: SecretProviderTarget,
76 +): Result.Result<
77 + { readonly id: SecretProviderId; readonly config: SecretProviderConfig },
78 + SecretProviderDraftIssues
79 +> {
80 + const label = decodeField(SecretProviderLabel, draft.name, "Enter a name.");
81 + const account = decodeField(
82 + OnePasswordSecretProviderConfig.fields.account,
83 + draft.account,
84 + "Enter the 1Password account.",
85 + );
86 +
87 + let id: SecretProviderId | null = null;
88 + let nameIssue: string | undefined;
89 + if (Result.isFailure(label)) {
90 + nameIssue = label.failure;
91 + } else {
92 + id = target.mode === "edit" ? target.id : secretProviderIdFromName(label.success);
93 + if (id === null) nameIssue = "The name needs at least one letter or digit.";
94 + else if (target.mode === "add" && existingIds.has(id))
95 + nameIssue = "A secret provider with this name exists.";
96 + }
97 +
98 + if (
99 + id === null ||
100 + nameIssue !== undefined ||
101 + Result.isFailure(label) ||
102 + Result.isFailure(account)
103 + ) {
104 + return Result.fail({
105 + ...(nameIssue === undefined ? {} : { name: nameIssue }),
106 + ...(Result.isFailure(account) ? { account: account.failure } : {}),
107 + });
108 + }
109 + return Result.succeed({
110 + id,
111 + config: {
112 + kind: SecretProviderKind.make("one_password"),
113 + label: label.success,
114 + config: { account: account.success },
115 + },
116 + });
117 +}
apps/web/src/components/settings/SecretProviderDialog.tsx new
+155
@@ -0,0 +1,155 @@
1 +import type { EnvironmentId, SecretProviderConfig, SecretProviderId } from "@t3tools/contracts";
2 +import * as Result from "effect/Result";
3 +import { useState } from "react";
4 +
5 +import { useUpdateEnvironmentSettings } from "../../hooks/useSettings";
6 +import { Button } from "../ui/button";
7 +import {
8 + Dialog,
9 + DialogDescription,
10 + DialogFooter,
11 + DialogHeader,
12 + DialogPanel,
13 + DialogPopup,
14 + DialogTitle,
15 +} from "../ui/dialog";
16 +import { Input } from "../ui/input";
17 +import { Label } from "../ui/label";
18 +import {
19 + draftFromSecretProvider,
20 + secretProviderFromDraft,
21 + type SecretProviderDraft,
22 +} from "./SecretProviderDialog.logic";
23 +
24 +/** Mounted per open, so each open starts from a fresh draft. */
25 +export function SecretProviderDialog({
26 + onClose,
27 + environmentId,
28 + environmentLabel,
29 + existingIds,
30 + existing,
31 +}: {
32 + readonly onClose: () => void;
33 + readonly environmentId: EnvironmentId;
34 + readonly environmentLabel: string;
35 + readonly existingIds: ReadonlySet<string>;
36 + readonly existing?: { readonly id: SecretProviderId; readonly config: SecretProviderConfig };
37 +}) {
38 + const updateSettings = useUpdateEnvironmentSettings(environmentId);
39 + const [draft, setDraft] = useState<SecretProviderDraft>(
40 + existing ? draftFromSecretProvider(existing.config) : { name: "", account: "" },
41 + );
42 + const [submitted, setSubmitted] = useState(false);
43 + const result = secretProviderFromDraft(
44 + draft,
45 + existingIds,
46 + existing ? { mode: "edit", id: existing.id } : { mode: "add" },
47 + );
48 + const issues = Result.isFailure(result) ? result.failure : {};
49 + const nameError = submitted ? issues.name : undefined;
50 + const accountError = submitted ? issues.account : undefined;
51 +
52 + const update = (patch: Partial<SecretProviderDraft>) => setDraft({ ...draft, ...patch });
53 + const save = () => {
54 + setSubmitted(true);
55 + if (Result.isFailure(result)) return;
56 + updateSettings({ secretProviders: { [result.success.id]: result.success.config } });
57 + onClose();
58 + };
59 +
60 + return (
61 + <Dialog
62 + open
63 + onOpenChange={(next) => {
64 + if (!next) onClose();
65 + }}
66 + >
67 + <DialogPopup className="max-w-md">
68 + <DialogHeader>
69 + <DialogTitle>
70 + {existing ? `Edit ${existing.config.label}` : "Add a 1Password provider"}
71 + </DialogTitle>
72 + <DialogDescription>
73 + Provider variables on {environmentLabel} can read values from it by name. Values are
74 + read with the op CLI on that server when a provider starts.
75 + </DialogDescription>
76 + </DialogHeader>
77 + <DialogPanel>
78 + <form
79 + id="secret-provider-form"
80 + className="grid gap-4"
81 + onSubmit={(event) => {
82 + event.preventDefault();
83 + save();
84 + }}
85 + >
86 + <div className="grid gap-1.5">
87 + <Label htmlFor="secret-provider-name">Name</Label>
88 + <Input
89 + id="secret-provider-name"
90 + placeholder="Personal"
91 + value={draft.name}
92 + onChange={(event) => update({ name: event.target.value })}
93 + maxLength={64}
94 + aria-invalid={nameError !== undefined}
95 + aria-describedby={
96 + nameError !== undefined ? "secret-provider-name-error" : undefined
97 + }
98 + autoFocus
99 + />
100 + {nameError !== undefined ? (
101 + <p
102 + id="secret-provider-name-error"
103 + role="alert"
104 + className="text-xs text-destructive"
105 + >
106 + {nameError}
107 + </p>
108 + ) : null}
109 + </div>
110 + <div className="grid gap-1.5">
111 + <Label htmlFor="secret-provider-account">Account</Label>
112 + <Input
113 + id="secret-provider-account"
114 + placeholder="my.1password.com"
115 + value={draft.account}
116 + onChange={(event) => update({ account: event.target.value })}
117 + maxLength={253}
118 + spellCheck={false}
119 + aria-invalid={accountError !== undefined}
120 + aria-describedby={
121 + accountError !== undefined ? "secret-provider-account-error" : undefined
122 + }
123 + />
124 + {accountError !== undefined ? (
125 + <p
126 + id="secret-provider-account-error"
127 + role="alert"
128 + className="text-xs text-destructive"
129 + >
130 + {accountError}
131 + </p>
132 + ) : null}
133 + <p className="text-xs text-muted-foreground">
134 + The account shorthand, sign-in address without https://, or ID that op account list
135 + shows.
136 + </p>
137 + </div>
138 + </form>
139 + </DialogPanel>
140 + <DialogFooter variant="bare">
141 + <Button variant="outline" onClick={onClose}>
142 + Cancel
143 + </Button>
144 + <Button
145 + type="submit"
146 + form="secret-provider-form"
147 + disabled={submitted && Result.isFailure(result)}
148 + >
149 + {existing ? "Save changes" : "Add provider"}
150 + </Button>
151 + </DialogFooter>
152 + </DialogPopup>
153 + </Dialog>
154 + );
155 +}
apps/web/src/components/settings/SecretsSettings.tsx new
+220
@@ -0,0 +1,220 @@
1 +import type { SecretProviderConfig, SecretProviderId } from "@t3tools/contracts";
2 +import { PlusIcon } from "lucide-react";
3 +import { useState } from "react";
4 +
5 +import { useEnvironmentSettings, useUpdateEnvironmentSettings } from "../../hooks/useSettings";
6 +import type { EnvironmentPresentation } from "../../state/environments";
7 +import { useEnvironmentSessionState } from "../../state/session";
8 +import { OnePasswordIcon, type Icon } from "../Icons";
9 +import {
10 + AlertDialog,
11 + AlertDialogClose,
12 + AlertDialogDescription,
13 + AlertDialogFooter,
14 + AlertDialogHeader,
15 + AlertDialogPopup,
16 + AlertDialogTitle,
17 +} from "../ui/alert-dialog";
18 +import { Button } from "../ui/button";
19 +import { SecretProviderDialog } from "./SecretProviderDialog";
20 +import { classifySecretProvider } from "./SecretProviderDialog.logic";
21 +import {
22 + classifyProviderEnvironmentAccess,
23 + resolveRemoteOperateAccess,
24 +} from "./ProviderSettingsPanel.logic";
25 +import { useSettingsScope } from "./SettingsScopeContext";
26 +import { RedactedSensitiveText } from "./RedactedSensitiveText";
27 +import { searchableSetting } from "./settingsSearch";
28 +import { SettingsPageContainer, SettingsRow, SettingsSection } from "./settingsLayout";
29 +
30 +const SECRET_PROVIDER_KINDS: Readonly<
31 + Record<string, { readonly name: string; readonly icon: Icon }>
32 +> = {
33 + one_password: { name: "1Password", icon: OnePasswordIcon },
34 +};
35 +
36 +export function SecretsSettingsPanel() {
37 + const { scope, environment } = useSettingsScope();
38 + return (
39 + <SettingsPageContainer>
40 + {environment?.connection.phase === "connected" ? (
41 + <EnvironmentSecretProviders
42 + key={environment.environmentId}
43 + environment={environment}
44 + projectScoped={scope.kind === "project" || scope.kind === "checkout"}
45 + />
46 + ) : (
47 + <SettingsSection {...searchableSetting("secret-providers")}>
48 + <p className="px-4 py-3 text-sm text-muted-foreground">
49 + Connect an environment to manage the secret providers its provider variables read from.
50 + </p>
51 + </SettingsSection>
52 + )}
53 + </SettingsPageContainer>
54 + );
55 +}
56 +
57 +function EnvironmentSecretProviders({
58 + environment,
59 + projectScoped,
60 +}: {
61 + readonly environment: EnvironmentPresentation;
62 + readonly projectScoped: boolean;
63 +}) {
64 + const environmentId = environment.environmentId;
65 + const sessionState = useEnvironmentSessionState(environmentId);
66 + // The server requires the same grant for secret providers as for provider settings.
67 + const access = classifyProviderEnvironmentAccess({
68 + connectionPhase: environment.connection.phase,
69 + hasServerConfig: environment.serverConfig !== null,
70 + operateAccess: resolveRemoteOperateAccess({
71 + session: sessionState.data,
72 + isPending: sessionState.isPending,
73 + hasError: sessionState.hasError,
74 + }),
75 + });
76 + const readOnly = access.kind !== "editable" || projectScoped;
77 + const providers = useEnvironmentSettings(environmentId, (settings) => settings.secretProviders);
78 + const updateSettings = useUpdateEnvironmentSettings(environmentId);
79 + const [dialog, setDialog] = useState<
80 + null | { readonly mode: "add" } | { readonly mode: "edit"; readonly id: SecretProviderId }
81 + >(null);
82 + const entries = Object.entries(providers) as Array<[SecretProviderId, SecretProviderConfig]>;
83 + const editingConfig = dialog?.mode === "edit" ? providers[dialog.id] : undefined;
84 + const editing =
85 + dialog?.mode === "edit" && editingConfig !== undefined
86 + ? { id: dialog.id, config: editingConfig }
87 + : undefined;
88 + return (
89 + <>
90 + <SettingsSection
91 + {...searchableSetting("secret-providers")}
92 + headerAction={
93 + !readOnly ? (
94 + <Button size="xs" variant="outline" onClick={() => setDialog({ mode: "add" })}>
95 + <PlusIcon className="size-3" aria-hidden />
96 + Add provider
97 + </Button>
98 + ) : null
99 + }
100 + >
101 + {projectScoped ? (
102 + <p className="px-4 pt-3 text-xs text-muted-foreground">
103 + Environment-wide setting. Select an environment to change it.
104 + </p>
105 + ) : null}
106 + {entries.length === 0 ? (
107 + <SettingsRow
108 + title="No secret providers configured."
109 + description="Add a 1Password account, then pick it as the source of a provider variable."
110 + />
111 + ) : (
112 + entries.map(([id, config]) => {
113 + const classified = classifySecretProvider(config);
114 + const kind =
115 + classified.kind === "unsupported"
116 + ? undefined
117 + : SECRET_PROVIDER_KINDS[classified.kind];
118 + return (
119 + <SettingsRow
120 + key={id}
121 + title={
122 + <span className="flex min-w-0 items-center gap-2">
123 + {kind ? (
124 + <kind.icon className="size-4.5 shrink-0 text-foreground/80" aria-hidden />
125 + ) : null}
126 + <span className="min-w-0 wrap-anywhere">{config.label}</span>
127 + </span>
128 + }
129 + description={
130 + classified.kind === "one_password" && kind ? (
131 + <span className="flex min-w-0 items-center gap-1">
132 + <span className="shrink-0">{kind.name} ·</span>
133 + <RedactedSensitiveText
134 + value={classified.account}
135 + ariaLabel="Toggle account visibility"
136 + revealTooltip="Click to reveal account"
137 + hideTooltip="Click to hide account"
138 + className="max-w-full truncate"
139 + />
140 + </span>
141 + ) : (
142 + `Unsupported provider (${config.kind})`
143 + )
144 + }
145 + control={
146 + !readOnly ? (
147 + <div className="flex items-center gap-1">
148 + {kind ? (
149 + <Button
150 + size="xs"
151 + variant="ghost"
152 + onClick={() => setDialog({ mode: "edit", id })}
153 + >
154 + Edit
155 + </Button>
156 + ) : null}
157 + <RemoveSecretProviderButton
158 + label={config.label}
159 + onConfirm={() => updateSettings({ secretProviders: { [id]: null } })}
160 + />
161 + </div>
162 + ) : null
163 + }
164 + />
165 + );
166 + })
167 + )}
168 + </SettingsSection>
169 + {dialog !== null && !readOnly && (dialog.mode === "add" || editing !== undefined) ? (
170 + <SecretProviderDialog
171 + onClose={() => setDialog(null)}
172 + environmentId={environmentId}
173 + environmentLabel={environment.label}
174 + existingIds={new Set(Object.keys(providers))}
175 + {...(editing === undefined ? {} : { existing: editing })}
176 + />
177 + ) : null}
178 + </>
179 + );
180 +}
181 +
182 +function RemoveSecretProviderButton({
183 + label,
184 + onConfirm,
185 +}: {
186 + readonly label: string;
187 + readonly onConfirm: () => void;
188 +}) {
189 + const [open, setOpen] = useState(false);
190 + return (
191 + <>
192 + <Button size="xs" variant="ghost" onClick={() => setOpen(true)}>
193 + Remove
194 + </Button>
195 + <AlertDialog open={open} onOpenChange={setOpen}>
196 + <AlertDialogPopup>
197 + <AlertDialogHeader>
198 + <AlertDialogTitle>Remove {label}?</AlertDialogTitle>
199 + <AlertDialogDescription>
200 + Provider variables that read from {label} stop resolving until a provider with the
201 + same name is added again. The secrets themselves are untouched.
202 + </AlertDialogDescription>
203 + </AlertDialogHeader>
204 + <AlertDialogFooter>
205 + <AlertDialogClose render={<Button variant="outline" />}>Cancel</AlertDialogClose>
206 + <Button
207 + variant="destructive"
208 + onClick={() => {
209 + setOpen(false);
210 + onConfirm();
211 + }}
212 + >
213 + Remove provider
214 + </Button>
215 + </AlertDialogFooter>
216 + </AlertDialogPopup>
217 + </AlertDialog>
218 + </>
219 + );
220 +}
apps/web/src/components/settings/SettingsSidebarNav.tsx
+2
@@ -22,6 +22,7 @@ import {
22 MessagesSquareIcon,
23 PanelsTopLeftIcon,
24 KeyboardIcon,
25 + KeyRoundIcon,
26 PaletteIcon,
27 SearchIcon,
28 ServerIcon,
@@ -102,6 +103,7 @@ const SETTINGS_SECTION_ICONS: Readonly<
103 "/settings/worktrees": FolderTreeIcon,
104 "/settings/connections": ServerIcon,
105 "/settings/access": ShieldCheckIcon,
106 + "/settings/secrets": KeyRoundIcon,
107 "/settings/maintenance": WrenchIcon,
108 "/settings/labs": FlaskConicalIcon,
109 "/settings/about": InfoIcon,
apps/web/src/components/settings/settingsSearch.test.ts
+11
@@ -14,12 +14,18 @@ import {
14 isSettingsSearchScopeAvailable,
15 movedSettingsPath,
16 searchSettings,
17 + SETTINGS_NAV_GROUPS,
18 SETTINGS_SEARCH_ITEMS,
19 sourceControlHostSearchItems,
20 sourceControlHostSettingsSearchId,
21 type SettingsSearchItem,
22 } from "./settingsSearch";
23
24 +vi.mock("~/env", async (importOriginal) => ({
25 + ...(await importOriginal<typeof import("~/env")>()),
26 + isSecretsFeatureEnabled: false,
27 +}));
28 +
29 const ITEMS: ReadonlyArray<SettingsSearchItem> = [
30 {
31 id: "word-wrap",
@@ -60,6 +66,11 @@ describe("searchSettings", () => {
66 expect(searchSettings("long lines", ITEMS).map((item) => item.id)).toEqual(["word-wrap"]);
67 });
68
69 + it("hides the Secrets page from nav and search while the secrets feature is disabled", () => {
70 + expect(SETTINGS_NAV_GROUPS.flatMap((group) => group.paths)).not.toContain("/settings/secrets");
71 + expect(searchSettings("1password").map((item) => item.to)).not.toContain("/settings/secrets");
72 + });
73 +
74 it("matches normalized title substrings", () => {
75 expect(searchSettings(" WORD WRAP ", ITEMS).map((item) => item.id)).toEqual(["word-wrap"]);
76 expect(searchSettings("glass").map((item) => item.id)).toEqual(["setting-glass-opacity"]);
apps/web/src/components/settings/settingsSearch.ts
+29 -2
@@ -1,5 +1,5 @@
1 import { HOSTED_APP_CHANNEL } from "~/branding";
2 -import { isElectron } from "~/env";
2 +import { isElectron, isSecretsFeatureEnabled } from "~/env";
3 import { isMacPlatform, isWindowsPlatform, normalizeSearchText } from "~/lib/utils";
4 import { STATIC_KEYBINDING_COMMANDS, type KeybindingCommand } from "@t3tools/contracts";
5 import type { EnvironmentId } from "@t3tools/contracts";
@@ -33,6 +33,7 @@ export type SettingsPath =
33 | "/settings/worktrees"
34 | "/settings/connections"
35 | "/settings/access"
36 + | "/settings/secrets"
37 | "/settings/maintenance"
38 | "/settings/labs"
39 | "/settings/about"
@@ -57,6 +58,7 @@ export interface SettingsSearchItem {
58 readonly macOnly?: boolean;
59 readonly windowsOnly?: boolean;
60 readonly releaseChannelOnly?: boolean;
61 + readonly secretsFeatureOnly?: boolean;
62 readonly cloudOnly?: boolean;
63 readonly environmentOnly?: boolean;
64 readonly providerSettingsOnly?: boolean;
@@ -101,6 +103,7 @@ export const SETTINGS_SECTION_LABELS: Readonly<Record<SettingsPath, string>> = {
103 "/settings/worktrees": "Worktrees",
104 "/settings/connections": "Environments",
105 "/settings/access": "Sharing & access",
106 + "/settings/secrets": "Secrets",
107 "/settings/maintenance": "Maintenance",
108 "/settings/labs": "Labs",
109 "/settings/about": "About",
@@ -137,7 +140,14 @@ export const SETTINGS_NAV_GROUPS: ReadonlyArray<{
140 heading: "Code",
141 paths: ["/settings/projects", "/settings/source-control", "/settings/worktrees"],
142 },
140 - { heading: "Connections", paths: ["/settings/connections", "/settings/access"] },
143 + {
144 + heading: "Connections",
145 + paths: [
146 + "/settings/connections",
147 + "/settings/access",
148 + ...(isSecretsFeatureEnabled ? (["/settings/secrets"] as const) : []),
149 + ],
150 + },
151 {
152 heading: null,
153 paths: ["/settings/maintenance", "/settings/labs", "/settings/about", "/settings/archived"],
@@ -1142,6 +1152,21 @@ export const SETTINGS_SEARCH_ITEMS = [
1152 `pull request routing trusted environments shared credentials permissions read actions source control ${SOURCE_CONTROL_HOST_LABELS}`,
1153 ],
1154 },
1155 + {
1156 + id: "secret-providers",
1157 + title: "Secret providers",
1158 + to: "/settings/secrets",
1159 + searchTerms: ["1password vault credentials api key"],
1160 + secretsFeatureOnly: true,
1161 + },
1162 + {
1163 + id: "secret-providers-add",
1164 + title: "Add secret provider",
1165 + to: "/settings/secrets",
1166 + targetId: "secret-providers",
1167 + searchTerms: ["new 1password vault op cli account"],
1168 + secretsFeatureOnly: true,
1169 + },
1170 {
1171 id: "archive",
1172 title: "Archived threads",
@@ -1171,6 +1196,7 @@ const SETTINGS_CATEGORY_SCOPES: Readonly<Record<SettingsPath, SettingsSearchScop
1196 "/settings/worktrees": "project-defaults",
1197 "/settings/connections": "connections",
1198 "/settings/access": "connections",
1199 + "/settings/secrets": null,
1200 "/settings/scheduled-tasks": null,
1201 "/settings/maintenance": null,
1202 "/settings/labs": null,
@@ -1313,6 +1339,7 @@ export function settingsForThisPlatform(
1339 (item) =>
1340 (isElectron || item.desktopOnly !== true) &&
1341 (!item.releaseChannelOnly || isElectron || HOSTED_APP_CHANNEL !== null) &&
1342 + (!item.secretsFeatureOnly || isSecretsFeatureEnabled) &&
1343 (!item.macOnly || isMacPlatform(platform)) &&
1344 (!item.windowsOnly || isWindowsPlatform(platform)),
1345 );
apps/web/src/env.ts
+4
@@ -1,2 +1,6 @@
1 // Preload installs desktopBridge before web code runs, so module-load detection is reliable.
2 export const isElectron = typeof window !== "undefined" && window.desktopBridge !== undefined;
3 +
4 +export const isSecretsFeatureEnabled = ["1", "true"].includes(
5 + import.meta.env.T3CODE_FEATURE_SECRETS?.trim().toLowerCase() ?? "",
6 +);
apps/web/src/routeTree.gen.ts
+21
@@ -26,6 +26,7 @@ import { Route as ChatSettingsThreadsRouteImport } from './routes/_chat.settings
26 import { Route as ChatSettingsStorageRouteImport } from './routes/_chat.settings.storage'
27 import { Route as ChatSettingsSourceControlRouteImport } from './routes/_chat.settings.source-control'
28 import { Route as ChatSettingsSnapShotRouteImport } from './routes/_chat.settings.snap-shot'
29 +import { Route as ChatSettingsSecretsRouteImport } from './routes/_chat.settings.secrets'
30 import { Route as ChatSettingsScheduledTasksRouteImport } from './routes/_chat.settings.scheduled-tasks'
31 import { Route as ChatSettingsProvidersRouteImport } from './routes/_chat.settings.providers'
32 import { Route as ChatSettingsProjectsRouteImport } from './routes/_chat.settings.projects'
@@ -134,6 +135,11 @@ const ChatSettingsSnapShotRoute = ChatSettingsSnapShotRouteImport.update({
135 path: '/snap-shot',
136 getParentRoute: () => ChatSettingsRoute,
137 } as any)
138 +const ChatSettingsSecretsRoute = ChatSettingsSecretsRouteImport.update({
139 + id: '/secrets',
140 + path: '/secrets',
141 + getParentRoute: () => ChatSettingsRoute,
142 +} as any)
143 const ChatSettingsScheduledTasksRoute =
144 ChatSettingsScheduledTasksRouteImport.update({
145 id: '/scheduled-tasks',
@@ -283,6 +289,7 @@ export interface FileRoutesByFullPath {
289 '/settings/projects': typeof ChatSettingsProjectsRoute
290 '/settings/providers': typeof ChatSettingsProvidersRoute
291 '/settings/scheduled-tasks': typeof ChatSettingsScheduledTasksRoute
292 + '/settings/secrets': typeof ChatSettingsSecretsRoute
293 '/settings/snap-shot': typeof ChatSettingsSnapShotRoute
294 '/settings/source-control': typeof ChatSettingsSourceControlRoute
295 '/settings/storage': typeof ChatSettingsStorageRoute
@@ -323,6 +330,7 @@ export interface FileRoutesByTo {
330 '/settings/projects': typeof ChatSettingsProjectsRoute
331 '/settings/providers': typeof ChatSettingsProvidersRoute
332 '/settings/scheduled-tasks': typeof ChatSettingsScheduledTasksRoute
333 + '/settings/secrets': typeof ChatSettingsSecretsRoute
334 '/settings/snap-shot': typeof ChatSettingsSnapShotRoute
335 '/settings/source-control': typeof ChatSettingsSourceControlRoute
336 '/settings/storage': typeof ChatSettingsStorageRoute
@@ -365,6 +373,7 @@ export interface FileRoutesById {
373 '/_chat/settings/projects': typeof ChatSettingsProjectsRoute
374 '/_chat/settings/providers': typeof ChatSettingsProvidersRoute
375 '/_chat/settings/scheduled-tasks': typeof ChatSettingsScheduledTasksRoute
376 + '/_chat/settings/secrets': typeof ChatSettingsSecretsRoute
377 '/_chat/settings/snap-shot': typeof ChatSettingsSnapShotRoute
378 '/_chat/settings/source-control': typeof ChatSettingsSourceControlRoute
379 '/_chat/settings/storage': typeof ChatSettingsStorageRoute
@@ -407,6 +416,7 @@ export interface FileRouteTypes {
416 | '/settings/projects'
417 | '/settings/providers'
418 | '/settings/scheduled-tasks'
419 + | '/settings/secrets'
420 | '/settings/snap-shot'
421 | '/settings/source-control'
422 | '/settings/storage'
@@ -447,6 +457,7 @@ export interface FileRouteTypes {
457 | '/settings/projects'
458 | '/settings/providers'
459 | '/settings/scheduled-tasks'
460 + | '/settings/secrets'
461 | '/settings/snap-shot'
462 | '/settings/source-control'
463 | '/settings/storage'
@@ -488,6 +499,7 @@ export interface FileRouteTypes {
499 | '/_chat/settings/projects'
500 | '/_chat/settings/providers'
501 | '/_chat/settings/scheduled-tasks'
502 + | '/_chat/settings/secrets'
503 | '/_chat/settings/snap-shot'
504 | '/_chat/settings/source-control'
505 | '/_chat/settings/storage'
@@ -626,6 +638,13 @@ declare module '@tanstack/react-router' {
638 preLoaderRoute: typeof ChatSettingsSnapShotRouteImport
639 parentRoute: typeof ChatSettingsRoute
640 }
641 + '/_chat/settings/secrets': {
642 + id: '/_chat/settings/secrets'
643 + path: '/secrets'
644 + fullPath: '/settings/secrets'
645 + preLoaderRoute: typeof ChatSettingsSecretsRouteImport
646 + parentRoute: typeof ChatSettingsRoute
647 + }
648 '/_chat/settings/scheduled-tasks': {
649 id: '/_chat/settings/scheduled-tasks'
650 path: '/scheduled-tasks'
@@ -804,6 +823,7 @@ interface ChatSettingsRouteChildren {
823 ChatSettingsProjectsRoute: typeof ChatSettingsProjectsRoute
824 ChatSettingsProvidersRoute: typeof ChatSettingsProvidersRoute
825 ChatSettingsScheduledTasksRoute: typeof ChatSettingsScheduledTasksRoute
826 + ChatSettingsSecretsRoute: typeof ChatSettingsSecretsRoute
827 ChatSettingsSnapShotRoute: typeof ChatSettingsSnapShotRoute
828 ChatSettingsSourceControlRoute: typeof ChatSettingsSourceControlRoute
829 ChatSettingsStorageRoute: typeof ChatSettingsStorageRoute
@@ -832,6 +852,7 @@ const ChatSettingsRouteChildren: ChatSettingsRouteChildren = {
852 ChatSettingsProjectsRoute: ChatSettingsProjectsRoute,
853 ChatSettingsProvidersRoute: ChatSettingsProvidersRoute,
854 ChatSettingsScheduledTasksRoute: ChatSettingsScheduledTasksRoute,
855 + ChatSettingsSecretsRoute: ChatSettingsSecretsRoute,
856 ChatSettingsSnapShotRoute: ChatSettingsSnapShotRoute,
857 ChatSettingsSourceControlRoute: ChatSettingsSourceControlRoute,
858 ChatSettingsStorageRoute: ChatSettingsStorageRoute,
apps/web/src/routes/_chat.settings.secrets.tsx new
+11
@@ -0,0 +1,11 @@
1 +import { createFileRoute, redirect } from "@tanstack/react-router";
2 +
3 +import { SecretsSettingsPanel } from "../components/settings/SecretsSettings";
4 +import { isSecretsFeatureEnabled } from "../env";
5 +
6 +export const Route = createFileRoute("/_chat/settings/secrets")({
7 + beforeLoad: () => {
8 + if (!isSecretsFeatureEnabled) throw redirect({ to: "/settings/general", replace: true });
9 + },
10 + component: SecretsSettingsPanel,
11 +});
apps/web/src/routes/_chat.settings.tsx
+1 -1
@@ -150,7 +150,7 @@ function SettingsRouteLayout() {
150 return (
151 <SettingsScopeProvider
152 search={rawSearch}
153 - singleEnvironment={pathname === "/settings/providers"}
153 + singleEnvironment={pathname === "/settings/providers" || pathname === "/settings/secrets"}
154 onChange={(next) => {
155 // Send every axis so retain middleware recognizes "all" as an explicit target.
156 void navigate({
apps/web/src/vite-env.d.ts
+1
@@ -15,6 +15,7 @@ interface ImportMetaEnv {
15 readonly VITE_RELAY_OTLP_TRACES_DATASET: string;
16 readonly VITE_RELAY_OTLP_TRACES_TOKEN: string;
17 readonly T3CODE_DESKTOP_UPDATE_REPOSITORY: string;
18 + readonly T3CODE_FEATURE_SECRETS: string;
19 readonly APP_VERSION: string;
20 }
21
apps/web/vite.config.ts
+2
@@ -49,6 +49,7 @@ const configuredDesktopUpdateRepository =
49 process.env.T3CODE_DESKTOP_UPDATE_REPOSITORY?.trim() ||
50 process.env.GITHUB_REPOSITORY?.trim() ||
51 "";
52 +const configuredFeatureSecrets = process.env.T3CODE_FEATURE_SECRETS?.trim() || "";
53 const configuredHostedAppUrl = (() => {
54 const explicitHostedAppUrl = process.env.VITE_HOSTED_APP_URL?.trim();
55 if (explicitHostedAppUrl) {
@@ -316,6 +317,7 @@ export default defineConfig(() => {
317 "import.meta.env.T3CODE_DESKTOP_UPDATE_REPOSITORY": JSON.stringify(
318 configuredDesktopUpdateRepository,
319 ),
320 + "import.meta.env.T3CODE_FEATURE_SECRETS": JSON.stringify(configuredFeatureSecrets),
321 "import.meta.env.VITE_RELEASE_CHANNEL": JSON.stringify(configuredReleaseChannel),
322 "import.meta.env.APP_VERSION": JSON.stringify(configuredAppVersion),
323 },
packages/contracts/src/settings.test.ts
+50
@@ -15,6 +15,7 @@ import {
15 resolveProjectProviderInstanceEnabled,
16 resolveProviderInstanceEnabled,
17 ServerSettings,
18 + OnePasswordSecretProviderConfig,
19 ServerSettingsPatch,
20 withIdleCompaction,
21 } from "./settings.ts";
@@ -25,6 +26,7 @@ const encodeClientSettings = Schema.encodeSync(ClientSettingsSchema);
26 const decodeServerSettings = Schema.decodeUnknownSync(ServerSettings);
27 const decodeServerSettingsPatch = Schema.decodeUnknownSync(ServerSettingsPatch);
28 const encodeServerSettings = Schema.encodeSync(ServerSettings);
29 +const decodeOnePasswordConfig = Schema.decodeUnknownSync(OnePasswordSecretProviderConfig);
30 const decodeClaudeSettings = Schema.decodeUnknownSync(ClaudeSettings);
31
32 describe("storage cleanup settings", () => {
@@ -115,6 +117,54 @@ describe("ServerSettings usage price overrides", () => {
117 });
118 });
119
120 +describe("ServerSettings secret providers", () => {
121 + const onePassword = (account: string) => ({
122 + kind: "one_password",
123 + label: "Personal",
124 + config: { account },
125 + });
126 +
127 + it("keeps an unknown kind or a longer label from invalidating the rest of the settings", () => {
128 + const openbao = { kind: "openbao", label: "V".repeat(65), config: { address: "https://x" } };
129 + const decoded = decodeServerSettings({
130 + worktreesDirectory: "/work",
131 + secretProviders: { vault: openbao, personal: onePassword("my.1password.com") },
132 + });
133 + expect(decoded.worktreesDirectory).toBe("/work");
134 + expect(encodeServerSettings(decoded).secretProviders).toEqual({
135 + vault: openbao,
136 + personal: onePassword("my.1password.com"),
137 + });
138 + });
139 +
140 + it("accepts slug ids and null removals but no id that is not a slug", () => {
141 + expect(
142 + decodeServerSettingsPatch({
143 + secretProviders: { "1password": onePassword("my.1password.com"), work: null },
144 + }).secretProviders,
145 + ).toEqual({ "1password": onePassword("my.1password.com"), work: null });
146 + for (const id of ["", "My Vault", "a/b", "-vault"]) {
147 + expect(() =>
148 + decodeServerSettingsPatch({ secretProviders: { [id]: onePassword("my.1password.com") } }),
149 + ).toThrow();
150 + }
151 + expect(() =>
152 + decodeServerSettingsPatch({
153 + secretProviders: { work: { ...onePassword("my.1password.com"), label: "V".repeat(65) } },
154 + }),
155 + ).toThrow();
156 + });
157 +
158 + it("rejects a 1Password account op could misread", () => {
159 + for (const account of ["", "my account", "--help"]) {
160 + expect(() => decodeOnePasswordConfig({ account })).toThrow();
161 + }
162 + expect(decodeOnePasswordConfig({ account: "my.1password.com" }).account).toBe(
163 + "my.1password.com",
164 + );
165 + });
166 +});
167 +
168 describe("custom model settings", () => {
169 const capabilities = {
170 optionDescriptors: [
packages/contracts/src/settings.ts
+62 -1
@@ -859,6 +859,56 @@ export const UsageLimitSourceConfig = Schema.Struct({
859 });
860 export type UsageLimitSourceConfig = typeof UsageLimitSourceConfig.Type;
861
862 +// Final once shipped: a key or field that fails here fails the whole settings decode on older builds.
863 +// Unlike provider slugs it may start with a digit, so a provider named "1Password" fits.
864 +const SecretProviderSlug = TrimmedNonEmptyString.check(
865 + Schema.isMaxLength(64),
866 + Schema.isPattern(/^[a-zA-Z0-9][a-zA-Z0-9_-]*$/),
867 +);
868 +
869 +export const SecretProviderId = SecretProviderSlug.pipe(Schema.brand("SecretProviderId"));
870 +export type SecretProviderId = typeof SecretProviderId.Type;
871 +
872 +export const SecretProviderKind = SecretProviderSlug.pipe(Schema.brand("SecretProviderKind"));
873 +export type SecretProviderKind = typeof SecretProviderKind.Type;
874 +
875 +const ONE_PASSWORD_ACCOUNT_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
876 +
877 +/**
878 + * Any value `op --account` accepts: shorthand, sign-in address, account ID, or user ID.
879 + * It is passed to the CLI as an argument, so it can never start with `-`.
880 + */
881 +export const OnePasswordAccount = Schema.String.check(
882 + Schema.isMaxLength(253),
883 + Schema.makeFilter((value: string) =>
884 + ONE_PASSWORD_ACCOUNT_PATTERN.test(value)
885 + ? true
886 + : "1Password account must be a shorthand, sign-in address, or ID with no spaces.",
887 + ),
888 +).pipe(Schema.brand("OnePasswordAccount"));
889 +export type OnePasswordAccount = typeof OnePasswordAccount.Type;
890 +
891 +export const SecretProviderLabel = TrimmedNonEmptyString.check(Schema.isMaxLength(64));
892 +
893 +export const OnePasswordSecretProviderConfig = Schema.Struct({
894 + account: OnePasswordAccount,
895 +});
896 +export type OnePasswordSecretProviderConfig = typeof OnePasswordSecretProviderConfig.Type;
897 +
898 +/** Kinds decode their own config; unknown-kind envelopes round-trip verbatim across versions. */
899 +export const SecretProviderConfig = Schema.Struct({
900 + kind: SecretProviderKind,
901 + label: TrimmedNonEmptyString,
902 + config: Schema.optionalKey(Schema.Unknown),
903 +});
904 +export type SecretProviderConfig = typeof SecretProviderConfig.Type;
905 +
906 +// Limits that may change later are enforced on writes only, never on the stored envelope.
907 +const SecretProviderConfigWrite = Schema.Struct({
908 + ...SecretProviderConfig.fields,
909 + label: SecretProviderLabel,
910 +});
911 +
912 export const SourceControlHostSettings = Schema.Record(Schema.String, Schema.Unknown);
913 export type SourceControlHostSettings = typeof SourceControlHostSettings.Type;
914
@@ -1313,6 +1363,9 @@ export const ServerSettings = Schema.Struct({
1363 usageLimitSources: Schema.Record(UsageLimitSourceId, UsageLimitSourceConfig).pipe(
1364 Schema.withDecodingDefault(Effect.succeed({})),
1365 ),
1366 + secretProviders: Schema.Record(SecretProviderId, SecretProviderConfig).pipe(
1367 + Schema.withDecodingDefault(Effect.succeed({})),
1368 + ),
1369 cursorKeychainUsageEnabled: Schema.Boolean.pipe(
1370 Schema.withDecodingDefault(Effect.succeed(false)),
1371 ),
@@ -1626,6 +1679,9 @@ export const ServerSettingsPatch = Schema.Struct({
1679 usageLimitSources: Schema.optionalKey(
1680 Schema.Record(UsageLimitSourceId, Schema.NullOr(UsageLimitSourceConfig)),
1681 ),
1682 + secretProviders: Schema.optionalKey(
1683 + Schema.Record(SecretProviderId, Schema.NullOr(SecretProviderConfigWrite)),
1684 + ),
1685 cursorKeychainUsageEnabled: Schema.optionalKey(Schema.Boolean),
1686
1687 usagePriceOverrides: Schema.optionalKey(
@@ -1645,7 +1701,12 @@ export function requiredScopesForServerSettingsPatch(
1701 let changesSettings = false;
1702 for (const [key, value] of Object.entries(patch)) {
1703 if (value === undefined) continue;
1648 - if (key === "providers" || key === "providerInstances" || key === "usageLimitSources") {
1704 + if (
1705 + key === "providers" ||
1706 + key === "providerInstances" ||
1707 + key === "usageLimitSources" ||
1708 + key === "secretProviders"
1709 + ) {
1710 changesProviders = true;
1711 } else {
1712 changesSettings = true;
packages/shared/src/serverSettings.test.ts
+25
@@ -1,8 +1,11 @@
1 import {
2 DEFAULT_SERVER_SETTINGS,
3 + OnePasswordAccount,
4 ProjectId,
5 ProviderDriverKind,
6 ProviderInstanceId,
7 + SecretProviderId,
8 + SecretProviderKind,
9 UsageLimitSourceId,
10 type ServerProvider,
11 } from "@t3tools/contracts";
@@ -544,6 +547,28 @@ describe("serverSettings helpers", () => {
547 expect(Object.keys(removed.usageLimitSources)).toEqual([hubB]);
548 });
549
550 + it("upserts and removes secretProviders per entry so concurrent edits cannot clobber", () => {
551 + const personal = SecretProviderId.make("personal");
552 + const work = SecretProviderId.make("work");
553 + const onePassword = (label: string, account: string) => ({
554 + kind: SecretProviderKind.make("one_password"),
555 + label,
556 + config: { account: OnePasswordAccount.make(account) },
557 + });
558 + const current = {
559 + ...DEFAULT_SERVER_SETTINGS,
560 + secretProviders: { [personal]: onePassword("Personal", "my.1password.com") },
561 + };
562 +
563 + const added = applyServerSettingsPatch(current, {
564 + secretProviders: { [work]: onePassword("Work", "team.1password.com") },
565 + });
566 + expect(Object.keys(added.secretProviders)).toEqual([personal, work]);
567 +
568 + const removed = applyServerSettingsPatch(added, { secretProviders: { [personal]: null } });
569 + expect(Object.keys(removed.secretProviders)).toEqual([work]);
570 + });
571 +
572 it("replaces and removes individual usage prices without clobbering other models", () => {
573 const prices = { inputCostPerMillionTokens: 2, outputCostPerMillionTokens: 8 };
574 const current = applyServerSettingsPatch(DEFAULT_SERVER_SETTINGS, {
packages/shared/src/serverSettings.ts
+4
@@ -357,6 +357,7 @@ export function applyServerSettingsPatch(
357 worktreeCleanup: worktreeCleanupPatch,
358 // Merged per entry below; its `null` removals must not reach deepMerge.
359 usageLimitSources: usageLimitSourcesPatch,
360 + secretProviders: secretProvidersPatch,
361 sourceControlHosts: sourceControlHostsPatch,
362 usagePriceOverrides: usagePriceOverridesPatch,
363 usageModelAliases: usageModelAliasesPatch,
@@ -554,6 +555,9 @@ export function applyServerSettingsPatch(
555 ),
556 }
557 : {}),
558 + ...(secretProvidersPatch !== undefined
559 + ? { secretProviders: mergeSettingsEntries(current.secretProviders, secretProvidersPatch) }
560 + : {}),
561 ...(usagePriceOverridesPatch !== undefined
562 ? {
563 usagePriceOverrides: mergeSettingsEntries(