Skip to content

Commit 2be1c57

Browse files
committed
feat(web): move question navigation into the tab row
1 parent 5ce8d13 commit 2be1c57

5 files changed

Lines changed: 46 additions & 60 deletions

File tree

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

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10478,13 +10478,6 @@ export default function ChatView(props: ChatViewProps) {
1047810478
setActivePendingUserInputQuestionIndex,
1047910479
]);
1048010480

10481-
const onPreviousActivePendingUserInputQuestion = useCallback(() => {
10482-
if (!activePendingProgress) {
10483-
return;
10484-
}
10485-
setActivePendingUserInputQuestionIndex(Math.max(activePendingProgress.questionIndex - 1, 0));
10486-
}, [activePendingProgress, setActivePendingUserInputQuestionIndex]);
10487-
1048810481
async function onSubmitPlanFollowUp({
1048910482
text,
1049010483
context,
@@ -11887,9 +11880,6 @@ export default function ChatView(props: ChatViewProps) {
1188711880
}
1188811881
onAdvanceActivePendingUserInput={onAdvanceActivePendingUserInput}
1188911882
onDismissActivePendingUserInput={onDismissUserInput}
11890-
onPreviousActivePendingUserInputQuestion={
11891-
onPreviousActivePendingUserInputQuestion
11892-
}
1189311883
onSelectActivePendingUserInputQuestion={
1189411884
setActivePendingUserInputQuestionIndex
1189511885
}

‎apps/web/src/components/chat/ChatComposer.tsx‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1389,7 +1389,6 @@ const ComposerFooterPrimaryActions = memo(function ComposerFooterPrimaryActions(
13891389
isEditingQueuedMessage: boolean;
13901390
onSubmitMessage: React.MouseEventHandler<HTMLButtonElement>;
13911391
onResume: () => void;
1392-
onPreviousPendingQuestion: () => void;
13931392
onInterrupt: () => void;
13941393
onImplementPlanInNewThread: () => void;
13951394
onCompactContext?: (() => void) | undefined;
@@ -1433,7 +1432,6 @@ const ComposerFooterPrimaryActions = memo(function ComposerFooterPrimaryActions(
14331432
isEditingQueuedMessage={props.isEditingQueuedMessage}
14341433
onSubmitMessage={props.onSubmitMessage}
14351434
onResume={props.onResume}
1436-
onPreviousPendingQuestion={props.onPreviousPendingQuestion}
14371435
onInterrupt={props.onInterrupt}
14381436
onImplementPlanInNewThread={props.onImplementPlanInNewThread}
14391437
compactBeforeSendTokens={props.compactBeforeSendTokens}
@@ -1683,7 +1681,6 @@ export interface ChatComposerProps {
16831681
onSelectActivePendingUserInputOption: (questionId: string, optionValue: string) => void;
16841682
onAdvanceActivePendingUserInput: () => void;
16851683
onDismissActivePendingUserInput: (requestId: RuntimeRequestId) => void;
1686-
onPreviousActivePendingUserInputQuestion: () => void;
16871684
onSelectActivePendingUserInputQuestion: (questionIndex: number) => void;
16881685
onChangeActivePendingUserInputCustomAnswer: (
16891686
questionId: string,
@@ -1803,7 +1800,6 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
18031800
onSelectActivePendingUserInputOption,
18041801
onAdvanceActivePendingUserInput,
18051802
onDismissActivePendingUserInput,
1806-
onPreviousActivePendingUserInputQuestion,
18071803
onSelectActivePendingUserInputQuestion,
18081804
onChangeActivePendingUserInputCustomAnswer,
18091805
onProviderModelSelect,
@@ -6959,7 +6955,6 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
69596955
isPreparingWorktree={false}
69606956
hasSendableContent={false}
69616957
preserveComposerFocusOnPointerDown
6962-
onPreviousPendingQuestion={onPreviousActivePendingUserInputQuestion}
69636958
onInterrupt={handleInterruptPrimaryAction}
69646959
onImplementPlanInNewThread={
69656960
handleImplementPlanInNewThreadPrimaryAction
@@ -7649,7 +7644,6 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
76497644
isPreparingWorktree={false}
76507645
hasSendableContent={false}
76517646
preserveComposerFocusOnPointerDown
7652-
onPreviousPendingQuestion={onPreviousActivePendingUserInputQuestion}
76537647
onInterrupt={handleInterruptPrimaryAction}
76547648
onImplementPlanInNewThread={handleImplementPlanInNewThreadPrimaryAction}
76557649
/>
@@ -7779,7 +7773,6 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
77797773
isEditingQueuedMessage={isEditingQueuedMessage}
77807774
onSubmitMessage={handleSubmitMessage}
77817775
onResume={onResume}
7782-
onPreviousPendingQuestion={onPreviousActivePendingUserInputQuestion}
77837776
onInterrupt={handleInterruptPrimaryAction}
77847777
onImplementPlanInNewThread={handleImplementPlanInNewThreadPrimaryAction}
77857778
compactBeforeSendTokens={props.resumeCompactionTokens}

‎apps/web/src/components/chat/ComposerPendingUserInputPanel.tsx‎

Lines changed: 45 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import {
66
summarizePendingUserInputAnswer,
77
type PendingUserInputDraftAnswer,
88
} from "../../pendingUserInput";
9-
import { CheckIcon } from "lucide-react";
9+
import { CheckIcon, ChevronLeftIcon, ChevronRightIcon } from "lucide-react";
10+
import { Button } from "../ui/button";
1011
import { Collapsible, CollapsiblePanel, CollapsibleTrigger } from "../ui/collapsible";
1112
import { cn } from "~/lib/utils";
1213
import { ComposerBanner } from "./ComposerBanner";
@@ -268,11 +269,11 @@ const ComposerPendingUserInputCard = memo(function ComposerPendingUserInputCard(
268269
</CollapsibleTrigger>
269270
<CollapsiblePanel>
270271
{prompt.questions.length > 1 ? (
271-
<ComposerBanner.Body className="pe-1 pb-2">
272+
<ComposerBanner.Body className="flex items-center justify-between gap-2 pe-1 pb-2">
272273
<div
273274
role="tablist"
274275
aria-label="Questions"
275-
className="flex gap-1 overflow-x-auto [scrollbar-width:none]"
276+
className="flex w-fit min-w-0 gap-0.5 overflow-x-auto rounded-lg bg-input/40 p-0.5 [scrollbar-width:none]"
276277
>
277278
{prompt.questions.map((question, index) => {
278279
const summary = summarizePendingUserInputAnswer(question, answers[question.id]);
@@ -287,23 +288,54 @@ const ComposerPendingUserInputCard = memo(function ComposerPendingUserInputCard(
287288
data-pending-user-input-tab={summary === null ? "unanswered" : "answered"}
288289
onClick={() => onSelectQuestion(index)}
289290
className={cn(
290-
"flex max-w-48 min-w-0 shrink-0 cursor-pointer items-center gap-1 rounded-md px-2 py-1 text-2xs outline-none transition-colors duration-150 focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-primary/25",
291+
// Matches the segmented toggle; the marker matches the setup wizard's steps.
292+
"flex h-6 max-w-56 min-w-0 shrink-0 cursor-pointer items-center gap-1.5 rounded-md px-2 text-xs font-medium outline-none transition-colors focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",
291293
isActive
292-
? "bg-muted/70 text-foreground"
293-
: "text-muted-foreground hover:bg-muted/30 hover:text-foreground/85",
294+
? "bg-background text-foreground shadow-xs/10 dark:bg-input/72"
295+
: "text-muted-foreground hover:bg-background/55 hover:text-foreground dark:hover:bg-input/32",
294296
)}
295297
>
296-
<span className="shrink-0 font-medium">{question.header}</span>
297-
{summary !== null ? (
298-
<>
299-
<CheckIcon className="size-3 shrink-0 text-primary" />
300-
<span className="min-w-0 truncate text-secondary-label">{summary}</span>
301-
</>
302-
) : null}
298+
<span
299+
aria-hidden
300+
className={cn(
301+
"grid size-3.5 shrink-0 place-items-center rounded-full text-3xs tabular-nums ring-1",
302+
summary !== null
303+
? "bg-primary text-primary-foreground ring-primary"
304+
: "ring-black/10 dark:ring-white/10",
305+
)}
306+
>
307+
{summary !== null ? <CheckIcon className="size-2.5" /> : index + 1}
308+
</span>
309+
<span className="min-w-0 truncate">
310+
{question.header}
311+
{summary !== null ? (
312+
<span className="font-normal text-muted-foreground">: {summary}</span>
313+
) : null}
314+
</span>
303315
</button>
304316
);
305317
})}
306318
</div>
319+
<div className="flex shrink-0 items-center">
320+
<Button
321+
size="icon-xs"
322+
variant="ghost"
323+
aria-label="Previous question"
324+
disabled={progress.questionIndex === 0}
325+
onClick={() => onSelectQuestion(progress.questionIndex - 1)}
326+
>
327+
<ChevronLeftIcon className="size-3.5" />
328+
</Button>
329+
<Button
330+
size="icon-xs"
331+
variant="ghost"
332+
aria-label="Next question"
333+
disabled={progress.isLastQuestion}
334+
onClick={() => onSelectQuestion(progress.questionIndex + 1)}
335+
>
336+
<ChevronRightIcon className="size-3.5" />
337+
</Button>
338+
</div>
307339
</ComposerBanner.Body>
308340
) : null}
309341
<ComposerBanner.Scroll>

‎apps/web/src/components/chat/ComposerPrimaryActions.test.tsx‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ function renderPendingActions(isRunning: boolean) {
4040
isEnvironmentUnavailable: false,
4141
isPreparingWorktree: false,
4242
hasSendableContent: false,
43-
onPreviousPendingQuestion: () => {},
4443
onInterrupt: () => {},
4544
onImplementPlanInNewThread: () => {},
4645
}),
@@ -63,7 +62,6 @@ function renderSendButton(sendDisabledReason: string | null = null) {
6362
isEnvironmentUnavailable: false,
6463
isPreparingWorktree: false,
6564
hasSendableContent: true,
66-
onPreviousPendingQuestion: () => {},
6765
onInterrupt: () => {},
6866
onImplementPlanInNewThread: () => {},
6967
}),

‎apps/web/src/components/chat/ComposerPrimaryActions.tsx‎

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import { memo, type MouseEventHandler, type PointerEventHandler } from "react";
2-
import { CheckIcon, ChevronDownIcon, ChevronLeftIcon, Minimize2Icon, PlayIcon } from "lucide-react";
2+
import { CheckIcon, ChevronDownIcon, Minimize2Icon, PlayIcon } from "lucide-react";
33
import { CornerUpRight, ListPlus } from "lucide";
44
import { MorphIcon } from "~/components/MorphIcon";
55
import { useEnvironmentIdentificationMode } from "~/hooks/useSettings";
66
import { formatContextWindowTokens } from "~/lib/contextWindow";
77
import { cn } from "~/lib/utils";
88
import { useShortcutModifierState } from "../../shortcutModifierState";
99
import { StageBackdropButtonArt, useSidebarStageBackdropVariant } from "../SidebarStageBackdrop";
10-
import { Button } from "../ui/button";
1110
import { Menu, MenuItem, MenuPopup, MenuTrigger } from "../ui/menu";
1211
import { Spinner } from "../ui/spinner";
1312
import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
@@ -49,7 +48,6 @@ interface ComposerPrimaryActionsProps {
4948
isEditingQueuedMessage?: boolean;
5049
onSubmitMessage?: MouseEventHandler<HTMLButtonElement>;
5150
onResume?: () => void;
52-
onPreviousPendingQuestion: () => void;
5351
onInterrupt: () => void;
5452
onImplementPlanInNewThread: () => void;
5553
/** Tokens a stale session would re-read. When set, a Compact chip shows the count and Enter compacts first. */
@@ -112,7 +110,6 @@ export const ComposerPrimaryActions = memo(function ComposerPrimaryActions({
112110
isEditingQueuedMessage = false,
113111
onSubmitMessage,
114112
onResume,
115-
onPreviousPendingQuestion,
116113
onInterrupt,
117114
onImplementPlanInNewThread,
118115
compactBeforeSendTokens = null,
@@ -168,30 +165,6 @@ export const ComposerPrimaryActions = memo(function ComposerPrimaryActions({
168165
return (
169166
<div className={cn("flex items-center justify-end", compact ? "gap-1.5" : "gap-2")}>
170167
{canInterrupt ? renderStopGenerationButton(true) : null}
171-
{pendingAction.questionIndex > 0 ? (
172-
compact ? (
173-
<Button
174-
size="icon-sm"
175-
variant="outline"
176-
{...pointerFocusProps}
177-
onClick={onPreviousPendingQuestion}
178-
disabled={pendingAction.isResponding}
179-
aria-label="Previous question"
180-
>
181-
<ChevronLeftIcon className="size-3.5" />
182-
</Button>
183-
) : (
184-
<Button
185-
size="sm"
186-
variant="outline"
187-
{...pointerFocusProps}
188-
onClick={onPreviousPendingQuestion}
189-
disabled={pendingAction.isResponding}
190-
>
191-
Previous
192-
</Button>
193-
)
194-
) : null}
195168
<button
196169
type="submit"
197170
className={cn(messageActionPillClassName, "h-8 sm:h-7", compact ? "px-3" : "px-4")}

0 commit comments

Comments
 (0)