Skip to content

Commit 00bd3b2

Browse files
longtngoclaude
andcommitted
feat(composer): cap ask-question options height + add Cancel button
The AskUserQuestion panel grew unbounded with many long-described options, covering the chat behind the composer. Cap the options list at min(50vh,22rem) and let it scroll, keeping the question header pinned above it. Add a Cancel button beside Submit (X icon in compact mode) that interrupts the turn — the runtime already aborts a pending AskUserQuestion on interrupt, resolving it with empty answers — so users can dismiss a question instead of being forced to answer. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
1 parent a683623 commit 00bd3b2

2 files changed

Lines changed: 26 additions & 2 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ const ComposerPendingUserInputCard = memo(function ComposerPendingUserInputCard(
141141
{activeQuestion.multiSelect ? (
142142
<p className="mt-1 text-xs text-muted-foreground/65">Select one or more options.</p>
143143
) : null}
144-
<div className="mt-3 space-y-1">
144+
<div className="mt-3 max-h-[min(50vh,22rem)] space-y-1 overflow-y-auto pr-1">
145145
{activeQuestion.options.map((option, index) => {
146146
const isSelected = progress.selectedOptionLabels.includes(option.label);
147147
const shortcutKey = index < 9 ? index + 1 : null;

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

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { memo, type PointerEventHandler } from "react";
2-
import { ChevronDownIcon, ChevronLeftIcon } from "lucide-react";
2+
import { ChevronDownIcon, ChevronLeftIcon, XIcon } from "lucide-react";
33
import { cn } from "~/lib/utils";
44
import { Button } from "../ui/button";
55
import { Menu, MenuItem, MenuPopup, MenuTrigger } from "../ui/menu";
@@ -134,6 +134,30 @@ export const ComposerPrimaryActions = memo(function ComposerPrimaryActions({
134134
if (pendingAction) {
135135
return (
136136
<div className={cn("flex items-center justify-end", compact ? "gap-1.5" : "gap-2")}>
137+
{compact ? (
138+
<Button
139+
size="icon-sm"
140+
variant="ghost"
141+
className="rounded-full"
142+
{...pointerFocusProps}
143+
onClick={onInterrupt}
144+
disabled={pendingAction.isResponding}
145+
aria-label="Cancel question"
146+
>
147+
<XIcon className="size-3.5" />
148+
</Button>
149+
) : (
150+
<Button
151+
size="sm"
152+
variant="ghost"
153+
className="rounded-full"
154+
{...pointerFocusProps}
155+
onClick={onInterrupt}
156+
disabled={pendingAction.isResponding}
157+
>
158+
Cancel
159+
</Button>
160+
)}
137161
{pendingAction.questionIndex > 0 ? (
138162
compact ? (
139163
<Button

0 commit comments

Comments
 (0)