@devries-cameron20 / t3code Mirror · read-only / commits / dcaff67177
Fork 0

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 21, 07:15 UTC

fix(web): removing a connection withdraws its permission update notice (#38980)

Co-authored-by: Julius Marminge <julius0216@outlook.com>

Wout Stiens committed Nov 19, 2026 at 08:04 UTC dcaff67177bb4e37d3b715b230fa53832fb1010e
2 files changed +75 -5
apps/web/src/components/PermissionUpdateNotice.ts
+29 -5
@@ -29,12 +29,15 @@ const legacyPermissionEnvironmentsAtom = Atom.make((get) =>
29 const dismissalKey = (environmentId: EnvironmentId) =>
30 `t3code:permission-update:v1:${environmentId}`;
31
32 +/** Shows the notice and returns a withdraw that closes it without recording a dismissal. */
33 function showPermissionNotice(
34 router: AnyRouter,
35 { environmentId, label }: LegacyPermissionEnvironment,
36 ) {
37 const key = dismissalKey(environmentId);
38 + let withdrawn = false;
39 const persistDismissal = () => {
40 + if (withdrawn) return;
41 try {
42 setLocalStorageItem(key, true, Schema.Boolean);
43 } catch {}
@@ -65,12 +68,19 @@ function showPermissionNotice(
68 secondaryActionVariant: "ghost",
69 },
70 });
71 + return () => {
72 + withdrawn = true;
73 + toastManager.close(id);
74 + };
75 }
76
70 -/** Asks once per environment, until dismissed, to re-pair a connection that predates scoped permissions. */
77 +/**
78 + * Asks once per environment, until dismissed, to re-pair a connection that predates scoped
79 + * permissions. Removing the environment withdraws its notice.
80 + */
81 export function startPermissionUpdateNotices(router: AnyRouter): () => void {
72 - const shown = new Set<EnvironmentId>();
73 - return appAtomRegistry.subscribe(
82 + const shown = new Map<EnvironmentId, () => void>();
83 + const stopShowing = appAtomRegistry.subscribe(
84 legacyPermissionEnvironmentsAtom,
85 (environments) => {
86 for (const environment of environments) {
@@ -79,10 +89,24 @@ export function startPermissionUpdateNotices(router: AnyRouter): () => void {
89 if (getLocalStorageItem(dismissalKey(environment.environmentId), Schema.Boolean))
90 continue;
91 } catch {}
82 - shown.add(environment.environmentId);
83 - showPermissionNotice(router, environment);
92 + shown.set(environment.environmentId, showPermissionNotice(router, environment));
93 }
94 },
95 { immediate: true },
96 );
97 + const stopWithdrawing = appAtomRegistry.subscribe(
98 + environmentSummaries.environmentIdsAtom,
99 + (environmentIds) => {
100 + const present = new Set(environmentIds);
101 + for (const [environmentId, withdraw] of shown) {
102 + if (present.has(environmentId)) continue;
103 + shown.delete(environmentId);
104 + withdraw();
105 + }
106 + },
107 + );
108 + return () => {
109 + stopShowing();
110 + stopWithdrawing();
111 + };
112 }
scripts/scenarios/removing-environment-clears-permission-notice.e2e.ts new
+46
@@ -0,0 +1,46 @@
1 +import { expect } from "e2e";
2 +import * as Schema from "effect/Schema";
3 +
4 +import { SECOND_HOME, startSecondServer } from "./second-server.ts";
5 +import { makeState, runPromise, test, WEB } from "./t3.ts";
6 +
7 +const decodePairing = Schema.decodeEffect(
8 + Schema.fromJsonString(Schema.Struct({ credential: Schema.String })),
9 +);
10 +
11 +test(
12 + "Removing a connection clears its permission update notice",
13 + WEB,
14 + async ({ t3, app, screen }) => {
15 + await t3.project("demo");
16 + const server = startSecondServer(app.baseUrl ?? "");
17 + try {
18 + const { host } = await server.ready;
19 + const { cli } = makeState(SECOND_HOME);
20 + const issued = await runPromise(
21 + cli(["auth", "pairing", "create", "--scope", "orchestration:read", "--json"]),
22 + );
23 + const { credential } = await runPromise(decodePairing(issued.stdout));
24 +
25 + await t3.open("/settings/connections");
26 + await screen.getByRole("button", "Add environment").tap();
27 + const dialog = screen.getByRole("dialog");
28 + await dialog.getByPlaceholder("backend.example.com").fill(host);
29 + await dialog.getByPlaceholder("PAIRCODE").fill(credential);
30 + await dialog.getByRole("button", "Add environment").tap();
31 +
32 + const notice = screen.getByText("Permissions have changed for Scenario", { exact: true });
33 + await notice.waitFor({ timeout: 60_000 });
34 + const actions = screen.getByRole("button", "More actions for Scenario");
35 + await actions.press("Enter");
36 + await screen.getByRole("menuitem", "Remove from this device…").press("Enter");
37 + await screen.getByRole("button", "Confirm").press("Enter");
38 + await actions.waitFor({ state: "hidden" });
39 +
40 + await app.screenshot("after-removing-connection");
41 + await expect(notice).toBeHidden();
42 + } finally {
43 + await server.stop();
44 + }
45 + },
46 +);