fix(web): restore v2 composer chrome
Co-authored-by: codex <[email protected]>
This commit is contained in:
1 parent
b75aa98050
commit
165ce66c97
6 files changed
+428
-197
No files matched your search
@@ -31,8 +31,7 @@ import {
|
||||
reconcileRetainedMountedThreadIds,
|
||||
resolveThreadMetadataUpdateForNextTurn,
|
||||
resolveSendEnvMode,
|
||||
startNewThreadForProject,
|
||||
shouldShowBranchMismatchBanner,
|
||||
shouldShowComposerContextStrip,
|
||||
shouldWriteThreadErrorToCurrentServerThread,
|
||||
} from "./ChatView.logic";
|
||||
|
||||
@@ -160,30 +159,44 @@ describe("resolveThreadMetadataUpdateForNextTurn", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("buildThreadTurnInterruptInput", () => {
|
||||
it("targets the session's active running turn", () => {
|
||||
const activeTurnId = TurnId.make("turn-running");
|
||||
|
||||
describe("shouldShowComposerContextStrip", () => {
|
||||
it("shows git context on a draft with an active project", () => {
|
||||
expect(
|
||||
buildThreadTurnInterruptInput(
|
||||
makeThread({
|
||||
session: {
|
||||
...readySession,
|
||||
status: "running",
|
||||
activeTurnId,
|
||||
},
|
||||
}),
|
||||
),
|
||||
).toEqual({ threadId, turnId: activeTurnId });
|
||||
shouldShowComposerContextStrip({
|
||||
routeKind: "draft",
|
||||
isGitRepo: true,
|
||||
hasActiveProject: true,
|
||||
}),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("omits a turn id when the session is not running", () => {
|
||||
expect(buildThreadTurnInterruptInput(makeThread({ session: readySession }))).toEqual({
|
||||
threadId,
|
||||
});
|
||||
it("hides git context after the draft becomes a thread", () => {
|
||||
expect(
|
||||
shouldShowComposerContextStrip({
|
||||
routeKind: "server",
|
||||
isGitRepo: true,
|
||||
hasActiveProject: true,
|
||||
}),
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("hides git context without a git-backed project", () => {
|
||||
expect(
|
||||
shouldShowComposerContextStrip({
|
||||
routeKind: "draft",
|
||||
isGitRepo: false,
|
||||
hasActiveProject: true,
|
||||
}),
|
||||
).toBe(false);
|
||||
expect(
|
||||
shouldShowComposerContextStrip({
|
||||
routeKind: "draft",
|
||||
isGitRepo: true,
|
||||
hasActiveProject: false,
|
||||
}),
|
||||
).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("deriveComposerSendState", () => {
|
||||
it("treats expired terminal pills as non-sendable content", () => {
|
||||
const state = deriveComposerSendState({
|
||||
|
||||
@@ -268,6 +268,14 @@ export function resolveSendEnvMode(input: {
|
||||
return input.isGitRepo ? input.requestedEnvMode : "local";
|
||||
}
|
||||
|
||||
export function shouldShowComposerContextStrip(input: {
|
||||
routeKind: "draft" | "server";
|
||||
isGitRepo: boolean;
|
||||
hasActiveProject: boolean;
|
||||
}): boolean {
|
||||
return input.routeKind === "draft" && input.isGitRepo && input.hasActiveProject;
|
||||
}
|
||||
|
||||
export function cloneComposerImageForRetry(
|
||||
image: ComposerImageAttachment,
|
||||
): ComposerImageAttachment {
|
||||
|
||||
@@ -298,8 +298,7 @@ import {
|
||||
resolveSendEnvMode,
|
||||
revokeBlobPreviewUrl,
|
||||
revokeUserMessagePreviewUrls,
|
||||
shouldWriteThreadErrorToCurrentServerThread,
|
||||
startNewThreadForProject,
|
||||
shouldShowComposerContextStrip,
|
||||
waitForStartedServerThread,
|
||||
} from "./ChatView.logic";
|
||||
import type { ThreadSyncPhase } from "../threadSync";
|
||||
@@ -449,14 +448,11 @@ type EnvironmentUnavailableState = {
|
||||
readonly connection: EnvironmentConnectionPresentation;
|
||||
};
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
type ThreadPlanCatalogEntry = {
|
||||
readonly id: ThreadId;
|
||||
readonly projection: OrchestrationV2ThreadProjection;
|
||||
};
|
||||
|
||||
>>>>>>> d454b3880e (Retire V1 client orchestration parity)
|
||||
function eventPathContainsSelector(event: Event, selector: string): boolean {
|
||||
const path = event.composedPath();
|
||||
if (path.length === 0 && event.target) {
|
||||
@@ -2334,15 +2330,6 @@ function ChatViewContent(props: ChatViewProps) {
|
||||
);
|
||||
const draftTimelineEntries = useMemo(
|
||||
() =>
|
||||
<<<<<<< HEAD
|
||||
deriveTimelineEntries(
|
||||
timelineMessages,
|
||||
activeThread?.proposedPlans ?? [],
|
||||
workLogEntries,
|
||||
turnPlans,
|
||||
),
|
||||
[activeThread?.proposedPlans, timelineMessages, turnPlans, workLogEntries],
|
||||
=======
|
||||
optimisticUserMessages.map(
|
||||
(message) =>
|
||||
({
|
||||
@@ -2353,7 +2340,6 @@ function ChatViewContent(props: ChatViewProps) {
|
||||
}) as const,
|
||||
),
|
||||
[optimisticUserMessages],
|
||||
>>>>>>> d454b3880e (Retire V1 client orchestration parity)
|
||||
);
|
||||
const timelineEntries = isServerThread ? serverTimelineEntries : draftTimelineEntries;
|
||||
const { turnDiffSummaries } = useTurnDiffSummaries(serverProjection);
|
||||
@@ -2449,9 +2435,9 @@ function ChatViewContent(props: ChatViewProps) {
|
||||
// Default true while loading to avoid toolbar flicker.
|
||||
const isGitRepo = gitStatusQuery.data?.isRepo ?? true;
|
||||
const showComposerContextStrip = shouldShowComposerContextStrip({
|
||||
hasActiveProject: activeProject !== null,
|
||||
routeKind,
|
||||
isGitRepo,
|
||||
showEnvironmentIndicator: showComposerEnvironmentIndicator,
|
||||
hasActiveProject: activeProject !== null,
|
||||
});
|
||||
const initialDiffPanelGitScope =
|
||||
gitStatusQuery.data?.hasWorkingTreeChanges === true ? "unstaged" : "branch";
|
||||
@@ -5491,27 +5477,11 @@ function ChatViewContent(props: ChatViewProps) {
|
||||
beginLocalDispatch({ preparingWorktree: false });
|
||||
setThreadError(threadIdForSend, null);
|
||||
|
||||
<<<<<<< HEAD
|
||||
// Position this sent row once LegendList has measured the anchored tail.
|
||||
isAtEndRef.current = true;
|
||||
timelineScrollModeRef.current = "anchoring-new-turn";
|
||||
liveFollowUserScrollGenerationRef.current = anchorUserScrollGenerationRef.current;
|
||||
setTimelineLiveFollowEnabled(true);
|
||||
pendingTimelineAnchorRef.current = messageIdForSend;
|
||||
activeTimelineAnchorIndexRef.current = null;
|
||||
showScrollDebouncer.current.cancel();
|
||||
setShowScrollToBottom(false);
|
||||
setTimelineAnchor({
|
||||
threadKey: scopedThreadKey(scopeThreadRef(activeThread.environmentId, threadIdForSend)),
|
||||
messageId: messageIdForSend,
|
||||
});
|
||||
=======
|
||||
// Scroll to the current end *before* adding the optimistic message.
|
||||
isAtEndRef.current = true;
|
||||
showScrollDebouncer.current.cancel();
|
||||
setShowScrollToBottom(false);
|
||||
await legendListRef.current?.scrollToEnd?.({ animated: false });
|
||||
>>>>>>> d454b3880e (Retire V1 client orchestration parity)
|
||||
|
||||
setOptimisticUserMessages((existing) => [
|
||||
...existing,
|
||||
@@ -5536,51 +5506,12 @@ function ChatViewContent(props: ChatViewProps) {
|
||||
let failure: AtomCommandResult<unknown, unknown> | null =
|
||||
settingsResult._tag === "Failure" ? settingsResult : null;
|
||||
|
||||
<<<<<<< HEAD
|
||||
const startResult = await startThreadTurn({
|
||||
environmentId,
|
||||
input: {
|
||||
threadId: threadIdForSend,
|
||||
message: {
|
||||
messageId: messageIdForSend,
|
||||
role: "user",
|
||||
text: outgoingMessageText,
|
||||
attachments: [],
|
||||
},
|
||||
modelSelection: ctxSelectedModelSelection,
|
||||
titleSeed: activeThread.title,
|
||||
runtimeMode,
|
||||
interactionMode: nextInteractionMode,
|
||||
...(nextInteractionMode === "default" && activeProposedPlan
|
||||
? {
|
||||
sourceProposedPlan: {
|
||||
threadId: activeThread.id,
|
||||
planId: activeProposedPlan.id,
|
||||
},
|
||||
}
|
||||
: {}),
|
||||
createdAt: messageCreatedAt,
|
||||
},
|
||||
});
|
||||
failure = startResult._tag === "Failure" ? startResult : null;
|
||||
}
|
||||
|
||||
if (failure === null) {
|
||||
acknowledgeActiveThreadWoke();
|
||||
sendInFlightRef.current = false;
|
||||
return;
|
||||
}
|
||||
|
||||
setOptimisticUserMessages((existing) =>
|
||||
existing.filter((message) => message.id !== messageIdForSend),
|
||||
=======
|
||||
if (failure === null) {
|
||||
// Keep the mode toggle and plan-follow-up banner in sync immediately
|
||||
// while the same-thread implementation turn is starting.
|
||||
setComposerDraftInteractionMode(
|
||||
scopeThreadRef(activeThread.environmentId, threadIdForSend),
|
||||
nextInteractionMode,
|
||||
>>>>>>> d454b3880e (Retire V1 client orchestration parity)
|
||||
);
|
||||
|
||||
const startResult = await startThreadTurn({
|
||||
@@ -5622,31 +5553,6 @@ function ChatViewContent(props: ChatViewProps) {
|
||||
}
|
||||
}
|
||||
sendInFlightRef.current = false;
|
||||
<<<<<<< HEAD
|
||||
resetLocalDispatch();
|
||||
},
|
||||
[
|
||||
activeThread,
|
||||
activeProposedPlan,
|
||||
acknowledgeActiveThreadWoke,
|
||||
beginLocalDispatch,
|
||||
isConnecting,
|
||||
isSendBusy,
|
||||
isServerThread,
|
||||
localCheckoutBranchMismatch,
|
||||
persistThreadSettingsForNextTurn,
|
||||
resetLocalDispatch,
|
||||
runtimeMode,
|
||||
setComposerDraftInteractionMode,
|
||||
setThreadError,
|
||||
startThreadTurn,
|
||||
activeThreadRef,
|
||||
autoOpenPlanSidebar,
|
||||
environmentId,
|
||||
composerRef,
|
||||
],
|
||||
);
|
||||
=======
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -5663,7 +5569,6 @@ function ChatViewContent(props: ChatViewProps) {
|
||||
sendInFlightRef.current = false;
|
||||
resetLocalDispatch();
|
||||
}
|
||||
>>>>>>> d454b3880e (Retire V1 client orchestration parity)
|
||||
|
||||
const onImplementPlanInNewThread = useCallback(async () => {
|
||||
if (
|
||||
@@ -6330,79 +6235,144 @@ function ChatViewContent(props: ChatViewProps) {
|
||||
threadId={activeThread.id}
|
||||
/>
|
||||
) : null}
|
||||
<div className="relative z-10">
|
||||
<ChatComposer
|
||||
composerRef={composerRef}
|
||||
composerDraftTarget={composerDraftTarget}
|
||||
environmentId={environmentId}
|
||||
routeKind={routeKind}
|
||||
routeThreadRef={routeThreadRef}
|
||||
draftId={draftId}
|
||||
activeThreadId={activeThreadId}
|
||||
activeThreadEnvironmentId={activeThread?.environmentId}
|
||||
activeThread={activeThread}
|
||||
isServerThread={isServerThread}
|
||||
isLocalDraftThread={isLocalDraftThread}
|
||||
phase={phase}
|
||||
isConnecting={isConnecting}
|
||||
isSendBusy={isSendBusy}
|
||||
isPreparingWorktree={isPreparingWorktree}
|
||||
environmentUnavailable={activeEnvironmentUnavailableState}
|
||||
activePendingApproval={activePendingApproval}
|
||||
pendingApprovals={pendingApprovals}
|
||||
pendingUserInputs={pendingUserInputs}
|
||||
activePendingProgress={activePendingProgress}
|
||||
activePendingResolvedAnswers={activePendingResolvedAnswers}
|
||||
activePendingIsResponding={activePendingIsResponding}
|
||||
activePendingDraftAnswers={activePendingDraftAnswers}
|
||||
activePendingQuestionIndex={activePendingQuestionIndex}
|
||||
respondingRequestIds={respondingRequestIds}
|
||||
showPlanFollowUpPrompt={showPlanFollowUpPrompt}
|
||||
activeProposedPlan={activeProposedPlan}
|
||||
activePlan={activePlan}
|
||||
sidebarProposedPlan={sidebarProposedPlan}
|
||||
planSidebarLabel={planSidebarLabel}
|
||||
planSidebarOpen={planSidebarOpen}
|
||||
runtimeMode={runtimeMode}
|
||||
interactionMode={interactionMode}
|
||||
lockedProvider={modelPickerLockedProvider}
|
||||
providerStatuses={providerStatuses as ServerProvider[]}
|
||||
activeProjectDefaultModelSelection={activeProject?.defaultModelSelection}
|
||||
activeThreadModelSelection={activeThread?.modelSelection}
|
||||
activeThreadVisibleTurnItems={serverVisibleTurnItems}
|
||||
resolvedTheme={resolvedTheme}
|
||||
settings={settings}
|
||||
keybindings={keybindings}
|
||||
terminalOpen={Boolean(terminalUiState.terminalOpen)}
|
||||
gitCwd={gitCwd}
|
||||
promptRef={promptRef}
|
||||
composerImagesRef={composerImagesRef}
|
||||
composerTerminalContextsRef={composerTerminalContextsRef}
|
||||
composerElementContextsRef={composerElementContextsRef}
|
||||
shouldAutoScrollRef={isAtEndRef}
|
||||
scheduleStickToBottom={scrollToEnd}
|
||||
onSend={onSend}
|
||||
onInterrupt={onInterrupt}
|
||||
onImplementPlanInNewThread={onImplementPlanInNewThread}
|
||||
onRespondToApproval={onRespondToApproval}
|
||||
onSelectActivePendingUserInputOption={onSelectActivePendingUserInputOption}
|
||||
onAdvanceActivePendingUserInput={onAdvanceActivePendingUserInput}
|
||||
onPreviousActivePendingUserInputQuestion={
|
||||
onPreviousActivePendingUserInputQuestion
|
||||
}
|
||||
onChangeActivePendingUserInputCustomAnswer={
|
||||
onChangeActivePendingUserInputCustomAnswer
|
||||
}
|
||||
onProviderModelSelect={onProviderModelSelect}
|
||||
getModelDisabledReason={getModelDisabledReason}
|
||||
toggleInteractionMode={toggleInteractionMode}
|
||||
handleRuntimeModeChange={handleRuntimeModeChange}
|
||||
handleInteractionModeChange={handleInteractionModeChange}
|
||||
togglePlanSidebar={togglePlanSidebar}
|
||||
focusComposer={focusComposer}
|
||||
scheduleComposerFocus={scheduleComposerFocus}
|
||||
setThreadError={setThreadError}
|
||||
onExpandImage={onExpandTimelineImage}
|
||||
<div
|
||||
ref={draftHeroTransition.composerAnchorRef}
|
||||
className="relative z-10"
|
||||
style={
|
||||
forceExpandedMobileComposer
|
||||
? { viewTransitionName: MOBILE_COMPOSER_VIEW_TRANSITION_NAME }
|
||||
: undefined
|
||||
}
|
||||
>
|
||||
<div
|
||||
className={cn(
|
||||
"chat-composer-glass-shell relative mx-auto w-full max-w-3xl",
|
||||
showComposerContextStrip && "chat-composer-glass-shell-with-context",
|
||||
)}
|
||||
>
|
||||
<div className="chat-composer-glass-host relative z-10 w-full rounded-[22px]">
|
||||
<div className="relative z-10">
|
||||
<ChatComposer
|
||||
composerRef={composerRef}
|
||||
composerDraftTarget={composerDraftTarget}
|
||||
environmentId={environmentId}
|
||||
routeKind={routeKind}
|
||||
routeThreadRef={routeThreadRef}
|
||||
draftId={draftId}
|
||||
activeThreadId={activeThreadId}
|
||||
activeThreadEnvironmentId={activeThread?.environmentId}
|
||||
activeThread={activeThread}
|
||||
isServerThread={isServerThread}
|
||||
isLocalDraftThread={isLocalDraftThread}
|
||||
forceExpandedOnMobile={forceExpandedMobileComposer && isDraftHeroState}
|
||||
projectSelectionRequired={isLocalDraftThread && activeProject === null}
|
||||
phase={phase}
|
||||
isConnecting={isConnecting}
|
||||
isSendBusy={isSendBusy}
|
||||
isPreparingWorktree={isPreparingWorktree}
|
||||
environmentUnavailable={activeEnvironmentUnavailableState}
|
||||
activePendingApproval={activePendingApproval}
|
||||
pendingApprovals={pendingApprovals}
|
||||
pendingUserInputs={pendingUserInputs}
|
||||
activePendingProgress={activePendingProgress}
|
||||
activePendingResolvedAnswers={activePendingResolvedAnswers}
|
||||
activePendingIsResponding={activePendingIsResponding}
|
||||
activePendingDraftAnswers={activePendingDraftAnswers}
|
||||
activePendingQuestionIndex={activePendingQuestionIndex}
|
||||
respondingRequestIds={respondingRequestIds}
|
||||
showPlanFollowUpPrompt={showPlanFollowUpPrompt}
|
||||
activeProposedPlan={activeProposedPlan}
|
||||
activePlan={activePlan}
|
||||
sidebarProposedPlan={sidebarProposedPlan}
|
||||
planSidebarLabel={planSidebarLabel}
|
||||
planSidebarOpen={planSidebarOpen}
|
||||
runtimeMode={runtimeMode}
|
||||
interactionMode={interactionMode}
|
||||
lockedProvider={modelPickerLockedProvider}
|
||||
providerStatuses={providerStatuses as ServerProvider[]}
|
||||
activeProjectDefaultModelSelection={
|
||||
activeProject?.defaultModelSelection
|
||||
}
|
||||
activeThreadModelSelection={activeThread?.modelSelection}
|
||||
activeThreadVisibleTurnItems={serverVisibleTurnItems}
|
||||
resolvedTheme={resolvedTheme}
|
||||
settings={settings}
|
||||
keybindings={keybindings}
|
||||
terminalOpen={Boolean(terminalUiState.terminalOpen)}
|
||||
gitCwd={gitCwd}
|
||||
promptRef={promptRef}
|
||||
composerImagesRef={composerImagesRef}
|
||||
composerTerminalContextsRef={composerTerminalContextsRef}
|
||||
composerElementContextsRef={composerElementContextsRef}
|
||||
shouldAutoScrollRef={isAtEndRef}
|
||||
scheduleStickToBottom={scrollToEnd}
|
||||
onSend={onSend}
|
||||
onInterrupt={onInterrupt}
|
||||
onImplementPlanInNewThread={onImplementPlanInNewThread}
|
||||
onRespondToApproval={onRespondToApproval}
|
||||
onSelectActivePendingUserInputOption={
|
||||
onSelectActivePendingUserInputOption
|
||||
}
|
||||
onAdvanceActivePendingUserInput={onAdvanceActivePendingUserInput}
|
||||
onPreviousActivePendingUserInputQuestion={
|
||||
onPreviousActivePendingUserInputQuestion
|
||||
}
|
||||
onChangeActivePendingUserInputCustomAnswer={
|
||||
onChangeActivePendingUserInputCustomAnswer
|
||||
}
|
||||
onProviderModelSelect={onProviderModelSelect}
|
||||
getModelDisabledReason={getModelDisabledReason}
|
||||
toggleInteractionMode={toggleInteractionMode}
|
||||
handleRuntimeModeChange={handleRuntimeModeChange}
|
||||
handleInteractionModeChange={handleInteractionModeChange}
|
||||
togglePlanSidebar={togglePlanSidebar}
|
||||
focusComposer={focusComposer}
|
||||
scheduleComposerFocus={scheduleComposerFocus}
|
||||
setThreadError={setThreadError}
|
||||
onExpandImage={onExpandTimelineImage}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div className="min-h-0">
|
||||
<div
|
||||
data-terminal-open={terminalUiState.terminalOpen ? "true" : undefined}
|
||||
className="relative z-0"
|
||||
>
|
||||
{showComposerContextStrip && (
|
||||
<div className="pointer-events-auto">
|
||||
<BranchToolbar
|
||||
environmentId={activeThread.environmentId}
|
||||
threadId={activeThread.id}
|
||||
{...(routeKind === "draft" && draftId ? { draftId } : {})}
|
||||
onEnvModeChange={onEnvModeChange}
|
||||
startFromOrigin={startFromOrigin}
|
||||
onStartFromOriginChange={onStartFromOriginChange}
|
||||
{...(canOverrideServerThreadEnvMode
|
||||
? { effectiveEnvModeOverride: envMode }
|
||||
: {})}
|
||||
{...(canOverrideServerThreadEnvMode
|
||||
? {
|
||||
activeThreadBranchOverride: activeThreadBranch,
|
||||
onActiveThreadBranchOverrideChange:
|
||||
setPendingServerThreadBranch,
|
||||
}
|
||||
: {})}
|
||||
envLocked={envLocked}
|
||||
onComposerFocusRequest={scheduleComposerFocus}
|
||||
{...(canCheckoutPullRequestIntoThread
|
||||
? { onCheckoutPullRequestRequest: openPullRequestDialog }
|
||||
: {})}
|
||||
{...(hasMultipleEnvironments ? { onEnvironmentChange } : {})}
|
||||
availableEnvironments={logicalProjectEnvironments}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
aria-hidden
|
||||
className="h-[calc(env(safe-area-inset-bottom)+1rem)] sm:h-[calc(env(safe-area-inset-bottom)+1.25rem)]"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -2680,7 +2680,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
|
||||
<form
|
||||
ref={composerFormRef}
|
||||
onSubmit={submitComposer}
|
||||
className="chat-content-lane"
|
||||
className="mx-auto w-full min-w-0 max-w-3xl"
|
||||
data-chat-composer-form="true"
|
||||
>
|
||||
<div
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { memo } from "react";
|
||||
import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
|
||||
|
||||
import { cn } from "~/lib/utils";
|
||||
import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
|
||||
|
||||
interface ChatHeaderProps {
|
||||
activeThreadTitle: string;
|
||||
|
||||
Reference in new issue
Block a user