@devries-cameron20 / t3code Mirror · read-only / commits / c5badf4e40
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, 06:00 UTC

fix(web): scope Git controls to the active checkout (#39305)

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

Wout Stiens committed Nov 19, 2026 at 21:24 UTC c5badf4e408ef55d1352040e2fb557d8f36d411a
3 files changed +79 -12
apps/web/src/components/GitActionsControl.tsx
+8 -8
@@ -26,7 +26,7 @@ import type {
26 } from "@t3tools/contracts";
27 import { useNavigate } from "@tanstack/react-router";
28 import * as Option from "effect/Option";
29 -import { useEffect, useEffectEvent, useId, useRef, useState } from "react";
29 +import { memo, useEffect, useEffectEvent, useId, useRef, useState } from "react";
30 import { useDeadlinePassed } from "../hooks/useDeadline";
31 import { useNowSecond } from "../hooks/useNowSecond";
32 import { flushSync } from "react-dom";
@@ -169,7 +169,6 @@ interface RunGitActionWithToastInput {
169 interface InlineGitActionSuccess {
170 readonly title: string;
171 readonly description: string | null;
172 - readonly scopeKey: string;
172 readonly expiresAtMs: number;
173 }
174
@@ -962,7 +961,12 @@ export function PublishRepositoryDialog(props: PublishRepositoryDialogProps) {
961 );
962 }
963
965 -export default function GitActionsControl({
964 +export default memo(function GitActionsControl(props: GitActionsControlProps) {
965 + const checkoutKey = JSON.stringify([props.activeThreadRef?.environmentId ?? null, props.gitCwd]);
966 + return <CheckoutGitActionsControl key={checkoutKey} {...props} />;
967 +});
968 +
969 +function CheckoutGitActionsControl({
970 gitCwd,
971 activeThreadRef,
972 draftId,
@@ -981,7 +985,6 @@ export default function GitActionsControl({
985 "thread branch metadata update",
986 );
987 const activeEnvironmentId = activeThreadRef?.environmentId ?? null;
984 - const successScopeKey = `${activeEnvironmentId ?? ""}\u0000${gitCwd ?? ""}`;
988 const canWriteSourceControl = useEnvironmentScope(
989 activeEnvironmentId,
990 AuthSourceControlWriteScope,
@@ -1020,8 +1023,7 @@ export default function GitActionsControl({
1023 const sourceControlScope = { environmentId: activeEnvironmentId, cwd: gitCwd };
1024 const vcsActionState = useAtomValue(vcsActionManager.stateAtom(sourceControlScope));
1025 const inlineSuccessExpired = useDeadlinePassed(inlineSuccess?.expiresAtMs ?? null);
1023 - const visibleInlineSuccess =
1024 - inlineSuccess?.scopeKey === successScopeKey && !inlineSuccessExpired ? inlineSuccess : null;
1026 + const visibleInlineSuccess = inlineSuccessExpired ? null : inlineSuccess;
1027
1028 const persistThreadBranchSync = (branch: string | null, manualSelection = false) => {
1029 if (!activeThreadRef) {
@@ -1351,7 +1353,6 @@ export default function GitActionsControl({
1353 })
1354 : actionResult.toast.title,
1355 description: createdPullRequest ? null : (actionResult.toast.description ?? null),
1354 - scopeKey: successScopeKey,
1356 expiresAtMs: inlineSuccessExpiresAt(),
1357 });
1358 return true;
@@ -1438,7 +1439,6 @@ export default function GitActionsControl({
1439 setInlineSuccess({
1440 title,
1441 description,
1441 - scopeKey: successScopeKey,
1442 expiresAtMs: inlineSuccessExpiresAt(),
1443 });
1444 })();
apps/web/src/components/chat/ThreadDetailsPanel.tsx
+2 -4
@@ -14,13 +14,13 @@ import type { ComposerThreadTarget, DraftId } from "../../composerDraftStore";
14 import { useT3ProjectFileScripts } from "../../hooks/useT3ProjectFileScripts";
15 import { type EnvMode, type EnvironmentOption } from "../BranchToolbar.logic";
16 import { BranchToolbar } from "../BranchToolbar";
17 -import BaseGitActionsControl from "../GitActionsControl";
17 +import GitActionsControl from "../GitActionsControl";
18 import ProjectScriptsControl, {
19 type NewProjectScriptInput,
20 type ProjectScriptActionResult,
21 } from "../ProjectScriptsControl";
22 import { T, useGT } from "gt-react";
23 -import { memo, useState, type ComponentProps } from "react";
23 +import { useState, type ComponentProps } from "react";
24 import { ThreadDetailsCard } from "./ThreadDetailsCard";
25 import { OpenInPicker } from "./OpenInPicker";
26 import { ThreadDetailsSection } from "./ThreadDetailsSection";
@@ -46,8 +46,6 @@ import {
46 } from "./threadDetailsPanelStyles";
47 import { Menu, MenuPopup } from "../ui/menu";
48
49 -const GitActionsControl = memo(BaseGitActionsControl);
50 -
49 interface ThreadDetailsPanelProps extends Pick<
50 ComponentProps<typeof ThreadDetailsCard>,
51 "anchor" | "handle"
scripts/scenarios/failed-commit-message-stays-in-its-repository.e2e.ts new
+69
@@ -0,0 +1,69 @@
1 +/// <reference lib="dom" />
2 +import { expect } from "e2e";
3 +import * as Effect from "effect/Effect";
4 +import * as FileSystem from "effect/FileSystem";
5 +
6 +import { run } from "./shell.ts";
7 +import { runPromise, test, WEB } from "./t3.ts";
8 +
9 +test(
10 + "A failed commit message stays in the repository it was written for",
11 + WEB,
12 + async ({ t3, app, browser, screen }) => {
13 + const first = await t3.project("first-repository");
14 + const second = await t3.project("second-repository");
15 + const firstThread = await t3.thread({
16 + project: first,
17 + title: "First checkout",
18 + messages: ["First"],
19 + });
20 + await t3.thread({ project: second, title: "Second checkout", messages: ["Second"] });
21 +
22 + await runPromise(
23 + Effect.gen(function* () {
24 + const fs = yield* FileSystem.FileSystem;
25 + const hook = `${first}/.git/hooks/pre-commit`;
26 + yield* fs.writeFileString(
27 + hook,
28 + "#!/bin/sh\necho 'Scenario hook rejected the commit' >&2\nexit 1\n",
29 + );
30 + yield* fs.chmod(hook, 0o755);
31 + yield* run("git", ["config", "core.hooksPath", ".git/hooks"], { cwd: first });
32 + yield* run("git", ["config", "user.name", "Scenario"], { cwd: first });
33 + yield* run("git", ["config", "user.email", "scenario@example.invalid"], { cwd: first });
34 + yield* fs.writeFileString(`${first}/first.txt`, "A new change in the first repository\n");
35 + yield* fs.writeFileString(
36 + `${second}/second.txt`,
37 + "A new change in the second repository\n",
38 + );
39 + }),
40 + );
41 +
42 + await browser.setViewport({ width: 1920, height: 1000 });
43 + await t3.open(firstThread);
44 + const openCommit = async (file: string) => {
45 + await screen.getByRole("button", "Git action options").tap();
46 + await screen.getByRole("menuitem", "Commit", { exact: true }).tap();
47 + await screen.getByRole("button", `Open ${file} in editor`, { exact: true }).waitFor();
48 + };
49 + await openCommit("first.txt");
50 + await screen
51 + .getByPlaceholder("Leave empty to auto-generate")
52 + .fill("Describe the first checkout");
53 + await screen.getByRole("button", "Commit", { exact: true }).tap();
54 + await screen.getByText("Action failed", { exact: true }).waitFor();
55 +
56 + // Navigate in the running app so the shared thread view stays mounted.
57 + await screen.getByRole("button", /^Second checkout(?:,|$)/).tap();
58 + await openCommit("second.txt");
59 + await app.screenshot("commit-message-in-second-repository");
60 + const message = await browser.evaluate(
61 + () =>
62 + "" +
63 + document.querySelector<HTMLTextAreaElement>(
64 + 'textarea[placeholder="Leave empty to auto-generate"]',
65 + )?.value,
66 + );
67 + expect(message, "The second repository starts with a blank commit message").toBe("");
68 + },
69 +);