@devries-cameron20 / t3code-1 / commits / d3f6ace496
Fork 0

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

fix(web): respect provider permissions in bulk updates (#23183)

Co-authored-by: GPT-6.1 Sol <noreply@openai.com> Co-authored-by: maria-rcks <maria@kuuro.net>

Victor Vogel committed Oct 31, 2026 at 21:26 UTC d3f6ace49625708d054bd63642ee87c35a6dc5b5
2 files changed +160 -2
apps/web/src/components/ProviderUpdatesAction.browser.test.tsx new
+153
@@ -0,0 +1,153 @@
1 +import { RegistryContext } from "@effect/atom-react";
2 +import {
3 + AuthProvidersManageScope,
4 + type AuthSessionState,
5 + EnvironmentId,
6 + ProviderDriverKind,
7 + ProviderInstanceId,
8 + type ServerProvider,
9 +} from "@t3tools/contracts";
10 +import { AsyncResult, Atom } from "effect/reactivity";
11 +import { useEffect } from "react";
12 +import { expect, it, vi } from "vite-plus/test";
13 +
14 +import { act, render } from "../../test/render";
15 +
16 +const state = vi.hoisted(() => ({
17 + environments: [] as {
18 + environmentId: EnvironmentId;
19 + label: string;
20 + connection: { phase: "connected" | "disconnected" };
21 + }[],
22 + providers: new Map<EnvironmentId, ReadonlyArray<ServerProvider>>(),
23 + requests: [] as EnvironmentId[],
24 + sessions: new Map<EnvironmentId, Atom.Writable<AsyncResult.AsyncResult<AuthSessionState>>>(),
25 +}));
26 +
27 +vi.mock(import("~/state/environments"), () => ({
28 + useEnvironments: (() => ({ environments: state.environments })) as never,
29 + useEnvironmentProviders: () => state.providers,
30 +}));
31 +vi.mock(import("@t3tools/client-runtime/state/session"), async (original) => {
32 + const actual = await original();
33 + return {
34 + ...actual,
35 + createEnvironmentSessionAtoms: ((
36 + ...args: Parameters<typeof actual.createEnvironmentSessionAtoms>
37 + ) => ({
38 + ...actual.createEnvironmentSessionAtoms(...args),
39 + sessionStateAtom: (id: EnvironmentId) => state.sessions.get(id)!,
40 + })) as typeof actual.createEnvironmentSessionAtoms,
41 + };
42 +});
43 +vi.mock(import("~/state/server"), () => ({
44 + serverEnvironment: { updateProvider: {} } as never,
45 +}));
46 +vi.mock(import("~/state/use-atom-command"), () => ({
47 + useAtomCommand: (() =>
48 + async ({ environmentId }: { environmentId: EnvironmentId }) => {
49 + state.requests.push(environmentId);
50 + return AsyncResult.success(undefined);
51 + }) as never,
52 +}));
53 +
54 +import { appAtomRegistry } from "~/rpc/atomRegistry";
55 +import { useProviderUpdates } from "./ProviderUpdatesAction";
56 +
57 +const provider: ServerProvider = {
58 + instanceId: ProviderInstanceId.make("codex"),
59 + driver: ProviderDriverKind.make("codex"),
60 + enabled: true,
61 + installed: true,
62 + version: "1.0.0",
63 + status: "ready",
64 + auth: { status: "authenticated" },
65 + checkedAt: "2026-10-21T00:00:00.000Z",
66 + models: [],
67 + slashCommands: [],
68 + skills: [],
69 + versionAdvisory: {
70 + status: "behind_latest",
71 + currentVersion: "1.0.0",
72 + latestVersion: "1.1.0",
73 + updateCommand: "npm install -g @openai/codex",
74 + canUpdate: true,
75 + checkedAt: "2026-10-21T00:00:00.000Z",
76 + message: "Update available.",
77 + },
78 +};
79 +
80 +function session(
81 + scopes: NonNullable<AuthSessionState["scopes"]>,
82 +): AsyncResult.AsyncResult<AuthSessionState> {
83 + return AsyncResult.success<AuthSessionState>({
84 + authenticated: true,
85 + scopes,
86 + auth: {
87 + policy: "remote-reachable",
88 + bootstrapMethods: ["one-time-token"],
89 + sessionMethods: ["bearer-access-token"],
90 + sessionCookieName: "t3_session",
91 + },
92 + });
93 +}
94 +
95 +function setup() {
96 + state.environments = [
97 + { environmentId: EnvironmentId.make("read-only"), label: "Read only" },
98 + { environmentId: EnvironmentId.make("writable"), label: "Writable" },
99 + { environmentId: EnvironmentId.make("unresolved"), label: "Unresolved" },
100 + ].map((environment) => ({ ...environment, connection: { phase: "connected" } }));
101 + state.providers = new Map(
102 + state.environments.map(({ environmentId }) => [environmentId, [provider]]),
103 + );
104 + state.requests = [];
105 + const sessions = new Map<EnvironmentId, Atom.Writable<AsyncResult.AsyncResult<AuthSessionState>>>(
106 + [
107 + [state.environments[0]!.environmentId, Atom.make(session(["orchestration:read"]))],
108 + [state.environments[1]!.environmentId, Atom.make(session([AuthProvidersManageScope]))],
109 + [
110 + state.environments[2]!.environmentId,
111 + Atom.make<AsyncResult.AsyncResult<AuthSessionState>>(
112 + AsyncResult.initial<AuthSessionState>(),
113 + ),
114 + ],
115 + ],
116 + );
117 + state.sessions = sessions;
118 + return { sessions };
119 +}
120 +
121 +it("bulk provider updates exclude connections without a confirmed management grant", async () => {
122 + const fixture = setup();
123 + let updates!: ReturnType<typeof useProviderUpdates>;
124 + function Probe() {
125 + const nextUpdates = useProviderUpdates();
126 + useEffect(() => {
127 + updates = nextUpdates;
128 + }, [nextUpdates]);
129 + return null;
130 + }
131 + await using _screen = await render(
132 + <RegistryContext.Provider value={appAtomRegistry}>
133 + <Probe />
134 + </RegistryContext.Provider>,
135 + );
136 +
137 + const writableId = state.environments[1]!.environmentId;
138 + expect(updates.machines.map(({ environmentId }) => environmentId)).toEqual([writableId]);
139 + await act(async () => {
140 + await updates.updateAll({ quiet: true });
141 + });
142 + expect(state.requests).toEqual([writableId]);
143 +
144 + await act(() => {
145 + appAtomRegistry.set(fixture.sessions.get(writableId)!, session(["orchestration:read"]));
146 + });
147 + expect(updates.machines).toEqual([]);
148 + state.requests = [];
149 + await act(async () => {
150 + await updates.updateAll({ quiet: true });
151 + });
152 + expect(state.requests).toEqual([]);
153 +});
apps/web/src/components/ProviderUpdatesAction.tsx
+7 -2
@@ -1,9 +1,10 @@
1 -import { PROVIDER_DISPLAY_NAMES } from "@t3tools/contracts";
1 +import { AuthProvidersManageScope, PROVIDER_DISPLAY_NAMES } from "@t3tools/contracts";
2 import { settlePromise } from "@t3tools/client-runtime/state/runtime";
3 import { useRef, useState } from "react";
4
5 import { useEnvironmentProviders, useEnvironments } from "~/state/environments";
6 import { serverEnvironment } from "~/state/server";
7 +import { useEnvironmentsWithScope } from "~/state/session";
8 import { useAtomCommand } from "~/state/use-atom-command";
9 import {
10 canOneClickUpdateProviderCandidate,
@@ -17,13 +18,17 @@ import { Tooltip, TooltipPopup, TooltipTrigger } from "./ui/tooltip";
18
19 export function useProviderUpdates() {
20 const { environments } = useEnvironments();
21 + const manageableIds = useEnvironmentsWithScope(environments, AuthProvidersManageScope);
22 const providersByEnvironment = useEnvironmentProviders();
23 const updateProvider = useAtomCommand(serverEnvironment.updateProvider, {
24 reportFailure: false,
25 });
26 const machines = environments.flatMap((environment) => {
27 const providers = providersByEnvironment.get(environment.environmentId) ?? [];
26 - if (environment.connection.phase !== "connected") {
28 + if (
29 + environment.connection.phase !== "connected" ||
30 + !manageableIds.has(environment.environmentId)
31 + ) {
32 return [];
33 }
34 const candidates = collectProviderUpdateCandidates(providers).filter((candidate) =>