The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 22, 07:00 UTC
fix(web): keep saved sensitive variables from losing their value (#23168)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: maria-rcks <maria@kuuro.net>
Victor Vogel committed
Nov 1, 2026 at 15:57 UTC
2a9335680e3f7a369c6e5032f12ba4fb2f2cdaac
2 files changed
+60
apps/web/src/components/settings/ProviderInstanceCard.environment.browser.test.tsx
new
+55
@@ -0,0 +1,55 @@
1
+import { userEvent } from "vite-plus/test/browser";
2
+import { describe, expect, it, vi } from "vite-plus/test";
3
+
4
+import { render } from "../../../test/render";
5
+import { ProviderEnvironmentSection } from "./ProviderInstanceCard";
6
+
7
+const savedSecret = {
8
+ name: "FAKE_API_KEY",
9
+ value: "",
10
+ sensitive: true,
11
+ valueRedacted: true,
12
+} as const;
13
+
14
+describe("ProviderEnvironmentSection saved secrets", () => {
15
+ it("requires a replacement before renaming or unlocking a stored secret", async () => {
16
+ const onChange = vi.fn();
17
+ await using screen = await render(
18
+ <ProviderEnvironmentSection environment={[savedSecret]} onChange={onChange} />,
19
+ );
20
+ const name = screen.getByRole("textbox", { name: "Environment variable name 1" });
21
+ const value = screen.getByLabelText("Environment variable value 1");
22
+ const lock = screen.getByRole("button", {
23
+ name: "Mark environment variable FAKE_API_KEY as sensitive",
24
+ });
25
+
26
+ await expect.element(name).toBeDisabled();
27
+ await expect.element(lock).toBeDisabled();
28
+ await userEvent.fill(value, "unused-draft");
29
+ await userEvent.clear(value);
30
+ await userEvent.tab();
31
+ expect(onChange).not.toHaveBeenCalled();
32
+ await expect.element(name).toBeDisabled();
33
+ await expect.element(lock).toBeDisabled();
34
+
35
+ await userEvent.fill(value, "fake-replacement");
36
+ await userEvent.tab();
37
+ expect(onChange).toHaveBeenLastCalledWith([
38
+ { ...savedSecret, value: "fake-replacement", valueRedacted: false },
39
+ ]);
40
+ await expect.element(name).toBeEnabled();
41
+ await expect.element(lock).toBeEnabled();
42
+ await userEvent.fill(name, "RENAMED_KEY");
43
+ await userEvent.tab();
44
+ await userEvent.click(
45
+ screen.getByRole("button", { name: "Mark environment variable RENAMED_KEY as sensitive" }),
46
+ );
47
+ expect(onChange).toHaveBeenLastCalledWith([
48
+ { name: "RENAMED_KEY", value: "fake-replacement", sensitive: false, valueRedacted: false },
49
+ ]);
50
+ await userEvent.click(
51
+ screen.getByRole("button", { name: "Remove environment variable RENAMED_KEY" }),
52
+ );
53
+ expect(onChange).toHaveBeenLastCalledWith([]);
54
+ });
55
+});
apps/web/src/components/settings/ProviderInstanceCard.tsx
+5
@@ -453,6 +453,7 @@ export function ProviderEnvironmentSection(props: {
453
className="min-w-0 flex-1"
454
value={variable.name}
455
onCommit={(name) => updateVariable(variable.id, { name: name.trim() })}
456
+ disabled={variable.valueRedacted === true}
457
placeholder="VARIABLE_NAME"
458
spellCheck={false}
459
aria-label={`Environment variable name ${index + 1}`}
@@ -478,6 +479,7 @@ export function ProviderEnvironmentSection(props: {
479
type="button"
480
size="icon-micro"
481
variant="ghost-muted"
482
+ disabled={variable.valueRedacted === true}
483
onClick={() => {
484
const sensitive = !variable.sensitive;
485
updateVariable(variable.id, {
@@ -558,6 +560,9 @@ export function ProviderEnvironmentSection(props: {
560
})}
561
<p className="text-xs text-muted-foreground">
562
Sensitive values are stored separately and never returned to the app.
563
+ {rows.some((row) => row.valueRedacted === true)
564
+ ? " Enter a new value to rename a saved one or make it plain text."
565
+ : null}
566
</p>
567
</div>
568
) : null}