fix(sessions): keep the question card within the space above the prompt

This commit is contained in:
Chris Scott committed 2026-10-19 23:12:40 -04:00
1 parent 32a2cd1b85
commit 1a5776dd5b
3 files changed
+25 -10

No files matched your search

@@ -328,10 +328,10 @@ export function FormPrompt({ form, onReply, onCancel, onMinimize, onAskSideQuest
return (
<div
className="flex flex-1 min-h-0 flex-col overflow-hidden rounded-t-[22px] border-t border-primary/40 bg-background bg-gradient-to-b from-primary/15 to-card mb-1 md:flex-none md:rounded-xl md:border-2 md:border-primary/40 md:bg-gradient-to-br md:from-primary/10 md:to-primary/20 md:shadow-lg md:shadow-primary/20"
className="flex flex-1 min-h-0 flex-col overflow-hidden rounded-t-[22px] border-t border-primary/40 bg-background bg-gradient-to-b from-primary/15 to-card mb-1 md:flex-initial md:rounded-xl md:border-2 md:border-primary/40 md:bg-gradient-to-br md:from-primary/10 md:to-primary/20 md:shadow-lg md:shadow-primary/20"
style={isMobile ? swipeStyles : undefined}
>
<div ref={mobileHeaderRef} className="shrink-0 md:hidden">
<div ref={mobileHeaderRef} className="shrink-0 border-b border-primary/25 bg-primary/10 md:hidden">
<button
type="button"
onClick={handleMinimize}
@@ -349,7 +349,7 @@ export function FormPrompt({ form, onReply, onCancel, onMinimize, onAskSideQuest
>
Dismiss
</button>
<span className="min-w-0 flex-1 truncate text-center text-[13px] font-semibold uppercase tracking-wide text-muted-foreground">
<span className="min-w-0 flex-1 truncate text-center text-[13px] font-semibold uppercase tracking-wide text-primary">
{form.title || 'Form'}
</span>
<button
@@ -387,7 +387,7 @@ export function FormPrompt({ form, onReply, onCancel, onMinimize, onAskSideQuest
</div>
{!isMinimized && (
<div className="flex-1 min-h-0 overflow-y-auto overflow-x-hidden overscroll-contain px-4 pt-2 pb-6 space-y-7 md:flex-none md:p-3 md:max-h-[70vh] md:space-y-3 md:bg-background/60 dark:md:bg-background/30">
<div className="flex-1 min-h-0 overflow-y-auto overflow-x-hidden overscroll-contain px-4 pt-4 pb-6 space-y-7 bg-background/60 dark:bg-background/30 md:flex-initial md:p-3 md:max-h-[70vh] md:space-y-3">
{renderFields.map((field) =>
field.type === 'external' ? (
<ExternalFieldCard key={field.key} field={field} />
+9 -6
View File
@@ -331,7 +331,8 @@ export function SessionDetail() {
const { getForSession: getFormForSession, reply: replyToForm, cancel: cancelForm, syncForSession: syncFormsForSession } = useForms();
const currentForm = sessionId ? getFormForSession(sessionId) : null;
const minimizedForm = currentForm && currentForm.id === minimizedFormId ? currentForm : null;
const isFormSheetOpen = isMobile && !!currentForm && !minimizedForm;
const isFormOpen = !!currentForm && !minimizedForm;
const isFormSheetOpen = isMobile && isFormOpen;
const lastAssistantMessage = messages.filter(m => m.type === 'assistant').at(-1);
const lastAssistantText = getAssistantText(lastAssistantMessage);
@@ -876,18 +877,20 @@ export function SessionDetail() {
</div>
{sessionDirectory && !isEditingMessage && (
<div
ref={promptOverlayRef}
data-testid="prompt-overlay"
className={cn(
"absolute left-0 right-0 flex justify-center",
isFormSheetOpen && "top-0 flex-col items-center justify-start",
isFormOpen && "top-0 flex-col items-center justify-end pointer-events-none md:pt-3",
)}
style={{ bottom: inputBottomOffset }}
>
<div
ref={promptOverlayRef}
className={cn(
"relative",
isFormSheetOpen ? "flex w-full flex-1 min-h-0 flex-col" : "w-[94%] md:max-w-4xl",
"relative pointer-events-auto",
isFormSheetOpen
? "flex w-full flex-1 min-h-0 flex-col"
: cn("w-[94%] md:max-w-4xl", isFormOpen && "flex max-h-full min-h-0 flex-col"),
)}
>
{!isFormSheetOpen && (
@@ -945,7 +948,7 @@ export function SessionDetail() {
onAskSideQuestion={() => handleAskSideQuestion('')}
/>
)}
<div className={cn(isFormSheetOpen && "shrink-0 px-[3%]")}>
<div className={cn(isFormSheetOpen && "shrink-0 bg-background px-[3%]")}>
<SessionSendErrorBanner sessionId={sessionId} isConnected={streamConnected} isReconnecting={streamReconnecting} />
<SessionGoalBar sessionID={sessionId} />
<BackgroundWorkBar
@@ -369,6 +369,18 @@ describe('SessionDetail form prompt session scoping', () => {
expect(screen.getByTestId('prompt-overlay')).toHaveClass('top-0')
})
it('bounds the form card by the space above the prompt on desktop so its header stays visible', async () => {
mocks.useMobile.mockReturnValue(false)
formsState.bySession[VIEWED_SESSION_ID] = viewedSessionForm
render(renderTree())
await waitFor(() => expect(screen.getAllByText('Continue A')[0]).toBeInTheDocument())
const overlay = screen.getByTestId('prompt-overlay')
expect(overlay).toHaveClass('top-0', 'justify-end', 'pointer-events-none')
expect(overlay.firstElementChild).toHaveClass('max-h-full', 'min-h-0', 'pointer-events-auto')
})
it('keeps the prompt overlay anchored without an open form or once the form is minimized', async () => {
mocks.useMobile.mockReturnValue(true)