@@ -441,7 +441,7 @@ import { ThreadDetailsPanel } from "./chat/ThreadDetailsPanel"; |
441 | 441 | import { NoActiveThreadState } from "./NoActiveThreadState"; |
442 | 442 | import { |
443 | 443 | resolveEffectiveEnvMode, |
444 | | - resolveCheckoutBranchMismatch, |
| 444 | + resolveLocalCheckoutBranchMismatch, |
445 | 445 | shouldShowComposerContextStrip, |
446 | 446 | shouldShowEnvironmentIndicator, |
447 | 447 | } from "./BranchToolbar.logic"; |
@@ -3456,6 +3456,26 @@ export default function ChatView(props: ChatViewProps) { |
3456 | 3456 | scheduleComposerFocus(); |
3457 | 3457 | }; |
3458 | 3458 | 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); |
3459 | 3479 | const queuedRunsControlRef = useRef<QueuedRunsControlHandle>(null); |
3460 | 3480 | const addTerminalContextToDraft = (selection: TerminalContextSelection) => { |
3461 | 3481 | composerRef.current?.addTerminalContext(selection); |
@@ -4769,8 +4789,8 @@ export default function ChatView(props: ChatViewProps) { |
4769 | 4789 | requestedEnvMode: envMode, |
4770 | 4790 | isGitRepo, |
4771 | 4791 | }); |
4772 | | - const checkoutBranchMismatch = isServerThread |
4773 | | - ? resolveCheckoutBranchMismatch({ |
| 4792 | + const localCheckoutBranchMismatch = isServerThread |
| 4793 | + ? resolveLocalCheckoutBranchMismatch({ |
4774 | 4794 | effectiveEnvMode: envMode, |
4775 | 4795 | activeWorktreePath, |
4776 | 4796 | activeThreadBranch, |
@@ -5099,10 +5119,10 @@ export default function ChatView(props: ChatViewProps) { |
5099 | 5119 | const nowMinute = useNowMinute(); |
5100 | 5120 | const activeBranchMismatchKey = branchMismatchKey( |
5101 | 5121 | activeThread?.id ?? null, |
5102 | | - checkoutBranchMismatch, |
| 5122 | + localCheckoutBranchMismatch, |
5103 | 5123 | ); |
5104 | 5124 | const showBranchMismatchBanner = shouldShowBranchMismatchBanner({ |
5105 | | - hasMismatch: checkoutBranchMismatch !== null, |
| 5125 | + hasMismatch: localCheckoutBranchMismatch !== null, |
5106 | 5126 | isDismissed: isBranchMismatchDismissedForSession(activeBranchMismatchKey), |
5107 | 5127 | composerHasContent: composerHasDraftContent, |
5108 | 5128 | wasShownForCurrentMismatch: |
@@ -5121,7 +5141,7 @@ export default function ChatView(props: ChatViewProps) { |
5121 | 5141 | if ( |
5122 | 5142 | !activeProjectCwd || |
5123 | 5143 | !activeThread || |
5124 | | - !checkoutBranchMismatch?.canRestoreThreadBranch || |
| 5144 | + !localCheckoutBranchMismatch || |
5125 | 5145 | isRestoringThreadBranch |
5126 | 5146 | ) { |
5127 | 5147 | return; |
@@ -5131,7 +5151,7 @@ export default function ChatView(props: ChatViewProps) { |
5131 | 5151 | environmentId, |
5132 | 5152 | input: { |
5133 | 5153 | cwd: activeProjectCwd, |
5134 | | - refName: checkoutBranchMismatch.threadBranch, |
| 5154 | + refName: localCheckoutBranchMismatch.threadBranch, |
5135 | 5155 | }, |
5136 | 5156 | }); |
5137 | 5157 | if (checkoutResult._tag === "Failure") { |
@@ -5152,7 +5172,7 @@ export default function ChatView(props: ChatViewProps) { |
5152 | 5172 | setIsRestoringThreadBranch(false); |
5153 | 5173 | return; |
5154 | 5174 | } |
5155 | | - const nextBranch = checkoutResult.value.refName ?? checkoutBranchMismatch.threadBranch; |
| 5175 | + const nextBranch = checkoutResult.value.refName ?? localCheckoutBranchMismatch.threadBranch; |
5156 | 5176 | if (nextBranch !== activeThread.branch) { |
5157 | 5177 | const updateResult = await updateThreadMetadata({ |
5158 | 5178 | environmentId, |
@@ -5269,37 +5289,6 @@ export default function ChatView(props: ChatViewProps) { |
5269 | 5289 | }; |
5270 | 5290 | })() as ComposerBannerStackItem | null; |
5271 | 5291 |
|
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 | | - |
5303 | 5292 | const sendStandaloneCommand = async (text: string, failureMessage: string) => { |
5304 | 5293 | if (!activeThread || !clientSettingsHydrated || sendInFlightRef.current) return; |
5305 | 5294 | const context = composerRef.current?.getSendContext(); |
@@ -5328,7 +5317,7 @@ export default function ChatView(props: ChatViewProps) { |
5328 | 5317 | const settingsResult = await persistThreadSettingsForNextTurn({ |
5329 | 5318 | threadId, |
5330 | 5319 | createdAt, |
5331 | | - ...(checkoutBranchMismatch ? { branch: checkoutBranchMismatch.currentBranch } : {}), |
| 5320 | + ...(localCheckoutBranchMismatch ? { branch: localCheckoutBranchMismatch.currentBranch } : {}), |
5332 | 5321 | runtimeMode, |
5333 | 5322 | interactionMode: context.interactionMode, |
5334 | 5323 | }); |
@@ -5612,7 +5601,7 @@ export default function ChatView(props: ChatViewProps) { |
5612 | 5601 | ].filter((item) => item !== null); |
5613 | 5602 | const usageLimitsItems = usageLimitsBanner === null ? [] : [usageLimitsBanner]; |
5614 | 5603 | const projectCloneItems = projectCloneBannerItem === null ? [] : [projectCloneBannerItem]; |
5615 | | - if (!checkoutBranchMismatch || !showBranchMismatchBanner || !activeBranchMismatchKey) { |
| 5604 | + if (!localCheckoutBranchMismatch || !showBranchMismatchBanner || !activeBranchMismatchKey) { |
5616 | 5605 | return [ |
5617 | 5606 | ...feedbackBannerItems, |
5618 | 5607 | ...limitRecoveryItems, |
@@ -5641,18 +5630,18 @@ export default function ChatView(props: ChatViewProps) { |
5641 | 5630 | <TooltipTrigger |
5642 | 5631 | render={ |
5643 | 5632 | <code className="min-w-0 truncate font-medium text-foreground"> |
5644 | | - {checkoutBranchMismatch.threadBranch} |
| 5633 | + {localCheckoutBranchMismatch.threadBranch} |
5645 | 5634 | </code> |
5646 | 5635 | } |
5647 | 5636 | /> |
5648 | 5637 | <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}. |
5651 | 5640 | </TooltipPopup> |
5652 | 5641 | </Tooltip> |
5653 | 5642 | </span> |
5654 | 5643 | ), |
5655 | | - actions: checkoutBranchMismatch.canRestoreThreadBranch ? ( |
| 5644 | + actions: ( |
5656 | 5645 | <Button |
5657 | 5646 | size="xs" |
5658 | 5647 | variant="ghost" |
@@ -5661,7 +5650,7 @@ export default function ChatView(props: ChatViewProps) { |
5661 | 5650 | > |
5662 | 5651 | {isRestoringThreadBranch ? "Restoring..." : "Restore branch"} |
5663 | 5652 | </Button> |
5664 | | - ) : null, |
| 5653 | + ), |
5665 | 5654 | dismissLabel: "Dismiss branch change notice", |
5666 | 5655 | onDismiss: () => { |
5667 | 5656 | dismissBranchMismatchForSession(activeBranchMismatchKey); |
@@ -6128,7 +6117,9 @@ export default function ChatView(props: ChatViewProps) { |
6128 | 6117 | const settingsResult = await persistThreadSettingsForNextTurn({ |
6129 | 6118 | threadId, |
6130 | 6119 | createdAt, |
6131 | | - ...(checkoutBranchMismatch ? { branch: checkoutBranchMismatch.currentBranch } : {}), |
| 6120 | + ...(localCheckoutBranchMismatch |
| 6121 | + ? { branch: localCheckoutBranchMismatch.currentBranch } |
| 6122 | + : {}), |
6132 | 6123 | runtimeMode, |
6133 | 6124 | interactionMode, |
6134 | 6125 | }); |
@@ -7103,7 +7094,9 @@ export default function ChatView(props: ChatViewProps) { |
7103 | 7094 | const settingsResult = await persistThreadSettingsForNextTurn({ |
7104 | 7095 | threadId: threadIdForSend, |
7105 | 7096 | createdAt: messageCreatedAt, |
7106 | | - ...(checkoutBranchMismatch ? { branch: checkoutBranchMismatch.currentBranch } : {}), |
| 7097 | + ...(localCheckoutBranchMismatch |
| 7098 | + ? { branch: localCheckoutBranchMismatch.currentBranch } |
| 7099 | + : {}), |
7107 | 7100 | runtimeMode, |
7108 | 7101 | interactionMode: sendInteractionMode, |
7109 | 7102 | }); |
@@ -7457,7 +7450,7 @@ export default function ChatView(props: ChatViewProps) { |
7457 | 7450 | const settingsResult = await persistThreadSettingsForNextTurn({ |
7458 | 7451 | threadId: threadIdForSend, |
7459 | 7452 | createdAt: messageCreatedAt, |
7460 | | - ...(checkoutBranchMismatch ? { branch: checkoutBranchMismatch.currentBranch } : {}), |
| 7453 | + ...(localCheckoutBranchMismatch ? { branch: localCheckoutBranchMismatch.currentBranch } : {}), |
7461 | 7454 | runtimeMode, |
7462 | 7455 | interactionMode: nextInteractionMode, |
7463 | 7456 | }); |
@@ -7577,7 +7570,7 @@ export default function ChatView(props: ChatViewProps) { |
7577 | 7570 | modelSelection: nextThreadModelSelection, |
7578 | 7571 | runtimeMode: defaultRuntimeMode, |
7579 | 7572 | interactionMode: "default", |
7580 | | - branch: checkoutBranchMismatch?.currentBranch ?? activeThreadBranch, |
| 7573 | + branch: activeThreadBranch, |
7581 | 7574 | worktreePath: activeThread.worktreePath, |
7582 | 7575 | createdAt, |
7583 | 7576 | }, |
@@ -8669,7 +8662,7 @@ export default function ChatView(props: ChatViewProps) { |
8669 | 8662 |
|
8670 | 8663 | <BranchRestoreConfirmHost |
8671 | 8664 | threadKey={activeThreadKey} |
8672 | | - threadBranch={checkoutBranchMismatch?.threadBranch ?? ""} |
| 8665 | + threadBranch={localCheckoutBranchMismatch?.threadBranch ?? ""} |
8673 | 8666 | canWriteSourceControl={canWriteSourceControl} |
8674 | 8667 | onConfirm={handleSwitchCheckoutToThreadStable} |
8675 | 8668 | /> |
|