GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — revert: "fix(web): worktree threads warn when the checkout branch cha… · pingdotgg/t3code@90c3f83

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • apps/web/src/components
    • BranchToolbar.logic.test.ts
    • BranchToolbar.logic.ts
    • ChatView.logic.test.ts
    • ChatView.logic.ts
    • ChatView.tsx
    • Sidebar.tsx
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎apps/web/src/components/BranchToolbar.logic.test.ts‎

Copy file name to clipboardExpand all lines: apps/web/src/components/BranchToolbar.logic.test.ts
+11-26Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
resolveBranchToolbarPrBranch,
1414
resolveBranchToolbarValue,
1515
resolveLockedWorkspaceLabel,
16-
resolveCheckoutBranchMismatch,
16+
resolveLocalCheckoutBranchMismatch,
1717
resolvePreviousWorktreeLabel,
1818
resolvePreviousWorktreeSeed,
1919
sanitizeNewRefName,
@@ -301,10 +301,10 @@ describe("resolveBranchToolbarPrBranch", () => {
301301
});
302302
});
303303

304-
describe("resolveCheckoutBranchMismatch", () => {
304+
describe("resolveLocalCheckoutBranchMismatch", () => {
305305
it("detects when a local thread is associated with a different branch than the checkout", () => {
306306
expect(
307-
resolveCheckoutBranchMismatch({
307+
resolveLocalCheckoutBranchMismatch({
308308
effectiveEnvMode: "local",
309309
activeWorktreePath: null,
310310
activeThreadBranch: "feature/thread",
@@ -313,13 +313,12 @@ describe("resolveCheckoutBranchMismatch", () => {
313313
).toEqual({
314314
threadBranch: "feature/thread",
315315
currentBranch: "feature/current",
316-
canRestoreThreadBranch: true,
317316
});
318317
});
319318

320319
it("ignores matching local checkout state", () => {
321320
expect(
322-
resolveCheckoutBranchMismatch({
321+
resolveLocalCheckoutBranchMismatch({
323322
effectiveEnvMode: "local",
324323
activeWorktreePath: null,
325324
activeThreadBranch: "feature/thread",
@@ -328,34 +327,20 @@ describe("resolveCheckoutBranchMismatch", () => {
328327
).toBeNull();
329328
});
330329

331-
it("warns about worktree branch drift without restore, but ignores a pending rename status", () => {
332-
const worktree = {
333-
effectiveEnvMode: "worktree" as const,
334-
activeWorktreePath: "/repo/.t3/worktrees/feature-thread",
335-
activeThreadBranch: "t3code/fix-sidebar",
336-
};
337-
330+
it("ignores dedicated worktrees because their checkout is already thread-scoped", () => {
338331
expect(
339-
resolveCheckoutBranchMismatch({
340-
...worktree,
341-
currentGitBranch: "t3code/1a2b3c4d",
332+
resolveLocalCheckoutBranchMismatch({
333+
effectiveEnvMode: "worktree",
334+
activeWorktreePath: "/repo/.t3/worktrees/feature-thread",
335+
activeThreadBranch: "feature/thread",
336+
currentGitBranch: "feature/current",
342337
}),
343338
).toBeNull();
344-
expect(
345-
resolveCheckoutBranchMismatch({
346-
...worktree,
347-
currentGitBranch: "feature/checkout",
348-
}),
349-
).toEqual({
350-
threadBranch: worktree.activeThreadBranch,
351-
currentBranch: "feature/checkout",
352-
canRestoreThreadBranch: false,
353-
});
354339
});
355340

356341
it("ignores new-worktree base selection before a worktree exists", () => {
357342
expect(
358-
resolveCheckoutBranchMismatch({
343+
resolveLocalCheckoutBranchMismatch({
359344
effectiveEnvMode: "worktree",
360345
activeWorktreePath: null,
361346
activeThreadBranch: "feature/base",
Collapse file

‎apps/web/src/components/BranchToolbar.logic.ts‎

Copy file name to clipboardExpand all lines: apps/web/src/components/BranchToolbar.logic.ts
+5-20Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type {
66
WorktreeSubmodules,
77
} from "@t3tools/contracts";
88
import * as Schema from "effect/Schema";
9-
import { isTemporaryWorktreeBranch, sanitizeNewRefName } from "@t3tools/shared/git";
9+
import { sanitizeNewRefName } from "@t3tools/shared/git";
1010
import { toSortableTimestamp } from "../lib/threadSort";
1111
export {
1212
dedupeRemoteBranchesWithLocalMatches,
@@ -238,35 +238,20 @@ export function resolveBranchToolbarPrBranch(input: {
238238
return input.activeThreadBranch === input.resolvedActiveBranch ? input.activeThreadBranch : null;
239239
}
240240

241-
export function resolveCheckoutBranchMismatch(input: {
241+
export function resolveLocalCheckoutBranchMismatch(input: {
242242
effectiveEnvMode: EnvMode;
243243
activeWorktreePath: string | null;
244244
activeThreadBranch: string | null;
245245
currentGitBranch: string | null;
246-
}) {
246+
}): { threadBranch: string; currentBranch: string } | null {
247247
const { effectiveEnvMode, activeWorktreePath, activeThreadBranch, currentGitBranch } = input;
248-
const isLocalCheckout = effectiveEnvMode === "local" && activeWorktreePath === null;
249-
const isEstablishedWorktree = effectiveEnvMode === "worktree" && activeWorktreePath !== null;
250-
if (!isLocalCheckout && !isEstablishedWorktree) {
248+
if (effectiveEnvMode !== "local" || activeWorktreePath !== null) {
251249
return null;
252250
}
253251
if (!activeThreadBranch || !currentGitBranch || activeThreadBranch === currentGitBranch) {
254252
return null;
255253
}
256-
// Cached status can predate the automatic rename of a temporary worktree branch.
257-
if (
258-
isEstablishedWorktree &&
259-
!isTemporaryWorktreeBranch(activeThreadBranch) &&
260-
isTemporaryWorktreeBranch(currentGitBranch)
261-
) {
262-
return null;
263-
}
264-
return {
265-
threadBranch: activeThreadBranch,
266-
currentBranch: currentGitBranch,
267-
// Restoring a worktree checkout could switch the branch for sibling threads.
268-
canRestoreThreadBranch: isLocalCheckout,
269-
};
254+
return { threadBranch: activeThreadBranch, currentBranch: currentGitBranch };
270255
}
271256

272257
export function resolveBranchSelectionTarget(input: {
Collapse file

‎apps/web/src/components/ChatView.logic.test.ts‎

Copy file name to clipboardExpand all lines: apps/web/src/components/ChatView.logic.test.ts
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,14 +261,14 @@ describe("resolveThreadMetadataUpdateForNextTurn", () => {
261261
model: "gpt-5.4",
262262
};
263263

264-
it("adopts the checkout branch without clearing the worktree attachment", () => {
264+
it("updates a stale local thread branch to the active checkout", () => {
265265
expect(
266266
resolveThreadMetadataUpdateForNextTurn({
267267
currentModelSelection: modelSelection,
268268
currentBranch: "feature/thread",
269269
nextBranch: "feature/checkout",
270270
}),
271-
).toEqual({ branch: "feature/checkout" });
271+
).toEqual({ branch: "feature/checkout", worktreePath: null });
272272
});
273273

274274
it("does not write metadata when the model and branch are unchanged", () => {
Collapse file

‎apps/web/src/components/ChatView.logic.ts‎

Copy file name to clipboardExpand all lines: apps/web/src/components/ChatView.logic.ts
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,7 @@ export function resolveThreadMetadataUpdateForNextTurn(input: {
474474
}): {
475475
modelSelection?: ModelSelection;
476476
branch?: string;
477+
worktreePath?: null;
477478
} | null {
478479
const nextModelSelection = input.nextModelSelection;
479480
const modelSelectionChanged =
@@ -488,7 +489,7 @@ export function resolveThreadMetadataUpdateForNextTurn(input: {
488489
}
489490
return {
490491
...(modelSelectionChanged ? { modelSelection: nextModelSelection } : {}),
491-
...(branchChanged ? { branch: input.nextBranch } : {}),
492+
...(branchChanged ? { branch: input.nextBranch, worktreePath: null } : {}),
492493
};
493494
}
494495

Collapse file

‎apps/web/src/components/ChatView.tsx‎

Copy file name to clipboardExpand all lines: apps/web/src/components/ChatView.tsx
+44-51Lines changed: 44 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ import { ThreadDetailsPanel } from "./chat/ThreadDetailsPanel";
441441
import { NoActiveThreadState } from "./NoActiveThreadState";
442442
import {
443443
resolveEffectiveEnvMode,
444-
resolveCheckoutBranchMismatch,
444+
resolveLocalCheckoutBranchMismatch,
445445
shouldShowComposerContextStrip,
446446
shouldShowEnvironmentIndicator,
447447
} from "./BranchToolbar.logic";
@@ -3456,6 +3456,26 @@ export default function ChatView(props: ChatViewProps) {
34563456
scheduleComposerFocus();
34573457
};
34583458
const insertArtifactTemplateStable = useStableCallback(insertArtifactTemplate);
3459+
const sendAppMessage = async (text: string) => {
3460+
if (!isServerThread || activeThreadId === null) {
3461+
throw new Error("Messages from apps need a started thread.");
3462+
}
3463+
const result = await startThreadTurn({
3464+
environmentId,
3465+
input: {
3466+
threadId: activeThreadId,
3467+
message: { messageId: newMessageId(), role: "user", text, attachments: [] },
3468+
runtimeMode,
3469+
interactionMode,
3470+
dispatchMode: "queue",
3471+
},
3472+
});
3473+
if (result._tag === "Failure") {
3474+
const error = squashAtomCommandFailure(result);
3475+
throw error instanceof Error ? error : new Error("Could not send the app's message.");
3476+
}
3477+
};
3478+
const sendAppMessageStable = useStableCallback(sendAppMessage);
34593479
const queuedRunsControlRef = useRef<QueuedRunsControlHandle>(null);
34603480
const addTerminalContextToDraft = (selection: TerminalContextSelection) => {
34613481
composerRef.current?.addTerminalContext(selection);
@@ -4769,8 +4789,8 @@ export default function ChatView(props: ChatViewProps) {
47694789
requestedEnvMode: envMode,
47704790
isGitRepo,
47714791
});
4772-
const checkoutBranchMismatch = isServerThread
4773-
? resolveCheckoutBranchMismatch({
4792+
const localCheckoutBranchMismatch = isServerThread
4793+
? resolveLocalCheckoutBranchMismatch({
47744794
effectiveEnvMode: envMode,
47754795
activeWorktreePath,
47764796
activeThreadBranch,
@@ -5099,10 +5119,10 @@ export default function ChatView(props: ChatViewProps) {
50995119
const nowMinute = useNowMinute();
51005120
const activeBranchMismatchKey = branchMismatchKey(
51015121
activeThread?.id ?? null,
5102-
checkoutBranchMismatch,
5122+
localCheckoutBranchMismatch,
51035123
);
51045124
const showBranchMismatchBanner = shouldShowBranchMismatchBanner({
5105-
hasMismatch: checkoutBranchMismatch !== null,
5125+
hasMismatch: localCheckoutBranchMismatch !== null,
51065126
isDismissed: isBranchMismatchDismissedForSession(activeBranchMismatchKey),
51075127
composerHasContent: composerHasDraftContent,
51085128
wasShownForCurrentMismatch:
@@ -5121,7 +5141,7 @@ export default function ChatView(props: ChatViewProps) {
51215141
if (
51225142
!activeProjectCwd ||
51235143
!activeThread ||
5124-
!checkoutBranchMismatch?.canRestoreThreadBranch ||
5144+
!localCheckoutBranchMismatch ||
51255145
isRestoringThreadBranch
51265146
) {
51275147
return;
@@ -5131,7 +5151,7 @@ export default function ChatView(props: ChatViewProps) {
51315151
environmentId,
51325152
input: {
51335153
cwd: activeProjectCwd,
5134-
refName: checkoutBranchMismatch.threadBranch,
5154+
refName: localCheckoutBranchMismatch.threadBranch,
51355155
},
51365156
});
51375157
if (checkoutResult._tag === "Failure") {
@@ -5152,7 +5172,7 @@ export default function ChatView(props: ChatViewProps) {
51525172
setIsRestoringThreadBranch(false);
51535173
return;
51545174
}
5155-
const nextBranch = checkoutResult.value.refName ?? checkoutBranchMismatch.threadBranch;
5175+
const nextBranch = checkoutResult.value.refName ?? localCheckoutBranchMismatch.threadBranch;
51565176
if (nextBranch !== activeThread.branch) {
51575177
const updateResult = await updateThreadMetadata({
51585178
environmentId,
@@ -5269,37 +5289,6 @@ export default function ChatView(props: ChatViewProps) {
52695289
};
52705290
})() as ComposerBannerStackItem | null;
52715291

5272-
const sendAppMessage = async (text: string) => {
5273-
if (!isServerThread || activeThreadId === null) {
5274-
throw new Error("Messages from apps need a started thread.");
5275-
}
5276-
const settingsResult = await persistThreadSettingsForNextTurn({
5277-
threadId: activeThreadId,
5278-
createdAt: new Date().toISOString(),
5279-
...(checkoutBranchMismatch ? { branch: checkoutBranchMismatch.currentBranch } : {}),
5280-
runtimeMode,
5281-
interactionMode,
5282-
});
5283-
const result =
5284-
settingsResult._tag === "Failure"
5285-
? settingsResult
5286-
: await startThreadTurn({
5287-
environmentId,
5288-
input: {
5289-
threadId: activeThreadId,
5290-
message: { messageId: newMessageId(), role: "user", text, attachments: [] },
5291-
runtimeMode,
5292-
interactionMode,
5293-
dispatchMode: "queue",
5294-
},
5295-
});
5296-
if (result._tag === "Failure") {
5297-
const error = squashAtomCommandFailure(result);
5298-
throw error instanceof Error ? error : new Error("Could not send the app's message.");
5299-
}
5300-
};
5301-
const sendAppMessageStable = useStableCallback(sendAppMessage);
5302-
53035292
const sendStandaloneCommand = async (text: string, failureMessage: string) => {
53045293
if (!activeThread || !clientSettingsHydrated || sendInFlightRef.current) return;
53055294
const context = composerRef.current?.getSendContext();
@@ -5328,7 +5317,7 @@ export default function ChatView(props: ChatViewProps) {
53285317
const settingsResult = await persistThreadSettingsForNextTurn({
53295318
threadId,
53305319
createdAt,
5331-
...(checkoutBranchMismatch ? { branch: checkoutBranchMismatch.currentBranch } : {}),
5320+
...(localCheckoutBranchMismatch ? { branch: localCheckoutBranchMismatch.currentBranch } : {}),
53325321
runtimeMode,
53335322
interactionMode: context.interactionMode,
53345323
});
@@ -5612,7 +5601,7 @@ export default function ChatView(props: ChatViewProps) {
56125601
].filter((item) => item !== null);
56135602
const usageLimitsItems = usageLimitsBanner === null ? [] : [usageLimitsBanner];
56145603
const projectCloneItems = projectCloneBannerItem === null ? [] : [projectCloneBannerItem];
5615-
if (!checkoutBranchMismatch || !showBranchMismatchBanner || !activeBranchMismatchKey) {
5604+
if (!localCheckoutBranchMismatch || !showBranchMismatchBanner || !activeBranchMismatchKey) {
56165605
return [
56175606
...feedbackBannerItems,
56185607
...limitRecoveryItems,
@@ -5641,18 +5630,18 @@ export default function ChatView(props: ChatViewProps) {
56415630
<TooltipTrigger
56425631
render={
56435632
<code className="min-w-0 truncate font-medium text-foreground">
5644-
{checkoutBranchMismatch.threadBranch}
5633+
{localCheckoutBranchMismatch.threadBranch}
56455634
</code>
56465635
}
56475636
/>
56485637
<TooltipPopup side="top">
5649-
This thread last ran on {checkoutBranchMismatch.threadBranch}. Sending will continue
5650-
on {checkoutBranchMismatch.currentBranch}.
5638+
This thread last ran on {localCheckoutBranchMismatch.threadBranch}. Sending will
5639+
continue on {localCheckoutBranchMismatch.currentBranch}.
56515640
</TooltipPopup>
56525641
</Tooltip>
56535642
</span>
56545643
),
5655-
actions: checkoutBranchMismatch.canRestoreThreadBranch ? (
5644+
actions: (
56565645
<Button
56575646
size="xs"
56585647
variant="ghost"
@@ -5661,7 +5650,7 @@ export default function ChatView(props: ChatViewProps) {
56615650
>
56625651
{isRestoringThreadBranch ? "Restoring..." : "Restore branch"}
56635652
</Button>
5664-
) : null,
5653+
),
56655654
dismissLabel: "Dismiss branch change notice",
56665655
onDismiss: () => {
56675656
dismissBranchMismatchForSession(activeBranchMismatchKey);
@@ -6128,7 +6117,9 @@ export default function ChatView(props: ChatViewProps) {
61286117
const settingsResult = await persistThreadSettingsForNextTurn({
61296118
threadId,
61306119
createdAt,
6131-
...(checkoutBranchMismatch ? { branch: checkoutBranchMismatch.currentBranch } : {}),
6120+
...(localCheckoutBranchMismatch
6121+
? { branch: localCheckoutBranchMismatch.currentBranch }
6122+
: {}),
61326123
runtimeMode,
61336124
interactionMode,
61346125
});
@@ -7103,7 +7094,9 @@ export default function ChatView(props: ChatViewProps) {
71037094
const settingsResult = await persistThreadSettingsForNextTurn({
71047095
threadId: threadIdForSend,
71057096
createdAt: messageCreatedAt,
7106-
...(checkoutBranchMismatch ? { branch: checkoutBranchMismatch.currentBranch } : {}),
7097+
...(localCheckoutBranchMismatch
7098+
? { branch: localCheckoutBranchMismatch.currentBranch }
7099+
: {}),
71077100
runtimeMode,
71087101
interactionMode: sendInteractionMode,
71097102
});
@@ -7457,7 +7450,7 @@ export default function ChatView(props: ChatViewProps) {
74577450
const settingsResult = await persistThreadSettingsForNextTurn({
74587451
threadId: threadIdForSend,
74597452
createdAt: messageCreatedAt,
7460-
...(checkoutBranchMismatch ? { branch: checkoutBranchMismatch.currentBranch } : {}),
7453+
...(localCheckoutBranchMismatch ? { branch: localCheckoutBranchMismatch.currentBranch } : {}),
74617454
runtimeMode,
74627455
interactionMode: nextInteractionMode,
74637456
});
@@ -7577,7 +7570,7 @@ export default function ChatView(props: ChatViewProps) {
75777570
modelSelection: nextThreadModelSelection,
75787571
runtimeMode: defaultRuntimeMode,
75797572
interactionMode: "default",
7580-
branch: checkoutBranchMismatch?.currentBranch ?? activeThreadBranch,
7573+
branch: activeThreadBranch,
75817574
worktreePath: activeThread.worktreePath,
75827575
createdAt,
75837576
},
@@ -8669,7 +8662,7 @@ export default function ChatView(props: ChatViewProps) {
86698662

86708663
<BranchRestoreConfirmHost
86718664
threadKey={activeThreadKey}
8672-
threadBranch={checkoutBranchMismatch?.threadBranch ?? ""}
8665+
threadBranch={localCheckoutBranchMismatch?.threadBranch ?? ""}
86738666
canWriteSourceControl={canWriteSourceControl}
86748667
onConfirm={handleSwitchCheckoutToThreadStable}
86758668
/>

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.