@devries-cameron20 / t3code Mirror · read-only / commits / 35dcdfb945
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 23, 08:00 UTC

perf(web): source control action hooks compile with the React Compiler (#20456)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Julius Marminge committed Oct 16, 2026 at 18:46 UTC 35dcdfb945374b3baf417b99b157d4d202020d62
2 files changed +123 -131
apps/web/reactCompiledFiles.ts
+1
@@ -31,4 +31,5 @@ export const REACT_COMPILED_FILES = [
31 "apps/web/src/components/ui/toggle-group.tsx",
32 "apps/web/src/components/ThreadNotificationCoordinator.tsx",
33 "apps/web/src/state/queries.ts",
34 + "apps/web/src/state/sourceControlActions.ts",
35 ] as const;
apps/web/src/state/sourceControlActions.ts
+122 -131
@@ -23,7 +23,6 @@ import {
23 import * as Cause from "effect/Cause";
24 import * as Option from "effect/Option";
25 import { AsyncResult } from "effect/reactivity";
26 -import { useCallback } from "react";
26
27 import { appAtomRegistry } from "../rpc/atomRegistry";
28 import { gitEnvironment } from "./git";
@@ -87,48 +86,45 @@ function useAction<
86 const state = useAtomValue(vcsActionManager.stateAtom(input.scope));
87 const ownsState = state.operation === operation;
88
90 - const resetError = useCallback(() => {
89 + const resetError = () => {
90 vcsActionManager.resetError(appAtomRegistry, input.scope, operation);
92 - }, [input.scope, operation]);
91 + };
92
94 - const run = useCallback(
95 - async (...args: TArgs) => {
96 - if (
97 - input.scope.environmentId === null ||
98 - !readEnvironmentScope(input.scope.environmentId, AuthSourceControlWriteScope)
99 - ) {
100 - return AsyncResult.failure<never, EnvironmentAuthorizationError>(
101 - Cause.fail(
102 - new EnvironmentAuthorizationError({
103 - requiredScope: AuthSourceControlWriteScope,
104 - message: "This connection cannot change source control.",
105 - }),
106 - ),
107 - );
93 + const run = async (...args: TArgs) => {
94 + if (
95 + input.scope.environmentId === null ||
96 + !readEnvironmentScope(input.scope.environmentId, AuthSourceControlWriteScope)
97 + ) {
98 + return AsyncResult.failure<never, EnvironmentAuthorizationError>(
99 + Cause.fail(
100 + new EnvironmentAuthorizationError({
101 + requiredScope: AuthSourceControlWriteScope,
102 + message: "This connection cannot change source control.",
103 + }),
104 + ),
105 + );
106 + }
107 + const execute = async (): Promise<
108 + AtomCommandResult<AtomCommandSuccess<R>, AtomCommandFailure<R>>
109 + > => {
110 + const result = await input.action(...args);
111 + if (AsyncResult.isSuccess(result)) {
112 + input.onSuccess?.();
113 }
109 - const execute = async (): Promise<
110 - AtomCommandResult<AtomCommandSuccess<R>, AtomCommandFailure<R>>
111 - > => {
112 - const result = await input.action(...args);
113 - if (AsyncResult.isSuccess(result)) {
114 - input.onSuccess?.();
115 - }
116 - return result as AtomCommandResult<AtomCommandSuccess<R>, AtomCommandFailure<R>>;
117 - };
118 - return input.managedExternally === true
119 - ? execute()
120 - : vcsActionManager.track(
121 - appAtomRegistry,
122 - input.scope,
123 - {
124 - operation,
125 - label: input.label,
126 - },
127 - execute,
128 - );
129 - },
130 - [input.action, input.label, input.managedExternally, input.onSuccess, input.scope, operation],
131 - );
114 + return result as AtomCommandResult<AtomCommandSuccess<R>, AtomCommandFailure<R>>;
115 + };
116 + return input.managedExternally === true
117 + ? execute()
118 + : vcsActionManager.track(
119 + appAtomRegistry,
120 + input.scope,
121 + {
122 + operation,
123 + label: input.label,
124 + },
125 + execute,
126 + );
127 + };
128
129 return {
130 isAllowed,
@@ -163,7 +159,7 @@ export function useSourceControlActionRunning(
159
160 export function useVcsInitAction(scope: SourceControlActionScope) {
161 const init = useAtomCommand(vcsEnvironment.init, { reportFailure: false });
166 - const action = useCallback(async () => {
162 + const action = async () => {
163 const target = resolveScope(scope);
164 if (target === null) {
165 return AsyncResult.failure<never, VcsActionUnavailableError>(
@@ -180,7 +176,7 @@ export function useVcsInitAction(scope: SourceControlActionScope) {
176 environmentId: target.environmentId,
177 input: { cwd: target.cwd },
178 });
183 - }, [init, scope]);
179 + };
180 return useAction({ kind: "init", label: "Initializing repository", scope, action });
181 }
182
@@ -194,7 +190,7 @@ export function useVcsPullAction(scope: SourceControlActionScope) {
190 })
191 : null,
192 );
197 - const action = useCallback(async () => {
193 + const action = async () => {
194 const target = resolveScope(scope);
195 if (target === null) {
196 return AsyncResult.failure<never, VcsActionUnavailableError>(
@@ -211,7 +207,7 @@ export function useVcsPullAction(scope: SourceControlActionScope) {
207 environmentId: target.environmentId,
208 input: { cwd: target.cwd },
209 });
214 - }, [pull, scope]);
210 + };
211 return useAction({
212 kind: "pull",
213 label: "Pulling latest changes...",
@@ -234,23 +230,20 @@ export function useGitStackedAction(scope: SourceControlActionScope) {
230 : null,
231 );
232
237 - const action = useCallback(
238 - async (input: RunVcsStackedActionInput) => {
239 - if (resolveScope(scope) === null) {
240 - return AsyncResult.failure<never, VcsActionUnavailableError>(
241 - Cause.fail(
242 - new VcsActionUnavailableError({
243 - operation: "run_change_request",
244 - environmentId: scope.environmentId,
245 - cwd: scope.cwd,
246 - }),
247 - ),
248 - );
249 - }
250 - return runStackedAction(input);
251 - },
252 - [runStackedAction, scope],
253 - );
233 + const action = async (input: RunVcsStackedActionInput) => {
234 + if (resolveScope(scope) === null) {
235 + return AsyncResult.failure<never, VcsActionUnavailableError>(
236 + Cause.fail(
237 + new VcsActionUnavailableError({
238 + operation: "run_change_request",
239 + environmentId: scope.environmentId,
240 + cwd: scope.cwd,
241 + }),
242 + ),
243 + );
244 + }
245 + return runStackedAction(input);
246 + };
247
248 return useAction({
249 kind: "runStackedAction",
@@ -274,36 +267,33 @@ export function useSourceControlPublishRepositoryAction(scope: SourceControlActi
267 })
268 : null,
269 );
277 - const action = useCallback(
278 - async (input: {
279 - provider: SourceControlProviderKind;
280 - repository: string;
281 - visibility: SourceControlRepositoryVisibility;
282 - remoteName: string;
283 - protocol: SourceControlCloneProtocol;
284 - }) => {
285 - const target = resolveScope(scope);
286 - if (target === null) {
287 - return AsyncResult.failure<never, VcsActionUnavailableError>(
288 - Cause.fail(
289 - new VcsActionUnavailableError({
290 - operation: "publish_repository",
291 - environmentId: scope.environmentId,
292 - cwd: scope.cwd,
293 - }),
294 - ),
295 - );
296 - }
297 - return publishRepository({
298 - environmentId: target.environmentId,
299 - input: {
300 - cwd: target.cwd,
301 - ...input,
302 - },
303 - });
304 - },
305 - [publishRepository, scope],
306 - );
270 + const action = async (input: {
271 + provider: SourceControlProviderKind;
272 + repository: string;
273 + visibility: SourceControlRepositoryVisibility;
274 + remoteName: string;
275 + protocol: SourceControlCloneProtocol;
276 + }) => {
277 + const target = resolveScope(scope);
278 + if (target === null) {
279 + return AsyncResult.failure<never, VcsActionUnavailableError>(
280 + Cause.fail(
281 + new VcsActionUnavailableError({
282 + operation: "publish_repository",
283 + environmentId: scope.environmentId,
284 + cwd: scope.cwd,
285 + }),
286 + ),
287 + );
288 + }
289 + return publishRepository({
290 + environmentId: target.environmentId,
291 + input: {
292 + cwd: target.cwd,
293 + ...input,
294 + },
295 + });
296 + };
297 return useAction({
298 kind: "publishRepository",
299 label: "Publishing repository",
@@ -317,46 +307,47 @@ export function usePreparePullRequestThreadAction(scope: SourceControlActionScop
307 const preparePullRequestThread = useAtomCommand(gitEnvironment.preparePullRequestThread, {
308 reportFailure: false,
309 });
320 - const action = useCallback(
321 - async (input: { reference: string; mode: "local" | "worktree"; threadId?: ThreadId }) => {
322 - const target = resolveScope(scope);
323 - if (target === null) {
324 - return AsyncResult.failure<never, VcsActionUnavailableError>(
325 - Cause.fail(
326 - new VcsActionUnavailableError({
327 - operation: "prepare_pull_request_thread",
328 - environmentId: scope.environmentId,
329 - cwd: scope.cwd,
330 - }),
331 - ),
332 - );
333 - }
334 - if (
335 - input.mode === "worktree" &&
336 - input.threadId !== undefined &&
337 - !readEnvironmentScope(target.environmentId, AuthOrchestrationOperateScope)
338 - ) {
339 - return AsyncResult.failure<never, EnvironmentAuthorizationError>(
340 - Cause.fail(
341 - new EnvironmentAuthorizationError({
342 - requiredScope: AuthOrchestrationOperateScope,
343 - message: "This connection cannot change threads.",
344 - }),
345 - ),
346 - );
347 - }
348 - return preparePullRequestThread({
349 - environmentId: target.environmentId,
350 - input: {
351 - cwd: target.cwd,
352 - reference: input.reference,
353 - mode: input.mode,
354 - ...(input.threadId ? { threadId: input.threadId } : {}),
355 - },
356 - });
357 - },
358 - [preparePullRequestThread, scope],
359 - );
310 + const action = async (input: {
311 + reference: string;
312 + mode: "local" | "worktree";
313 + threadId?: ThreadId;
314 + }) => {
315 + const target = resolveScope(scope);
316 + if (target === null) {
317 + return AsyncResult.failure<never, VcsActionUnavailableError>(
318 + Cause.fail(
319 + new VcsActionUnavailableError({
320 + operation: "prepare_pull_request_thread",
321 + environmentId: scope.environmentId,
322 + cwd: scope.cwd,
323 + }),
324 + ),
325 + );
326 + }
327 + if (
328 + input.mode === "worktree" &&
329 + input.threadId !== undefined &&
330 + !readEnvironmentScope(target.environmentId, AuthOrchestrationOperateScope)
331 + ) {
332 + return AsyncResult.failure<never, EnvironmentAuthorizationError>(
333 + Cause.fail(
334 + new EnvironmentAuthorizationError({
335 + requiredScope: AuthOrchestrationOperateScope,
336 + message: "This connection cannot change threads.",
337 + }),
338 + ),
339 + );
340 + }
341 + return preparePullRequestThread({
342 + environmentId: target.environmentId,
343 + input: {
344 + cwd: target.cwd,
345 + reference: input.reference,
346 + mode: input.mode,
347 + ...(input.threadId ? { threadId: input.threadId } : {}),
348 + },
349 + });
350 + };
351 return useAction({
352 kind: "preparePullRequestThread",
353 label: "Preparing pull request thread",