diff --git a/apps/web/components/task/chat/chat-input-area.tsx b/apps/web/components/task/chat/chat-input-area.tsx index f3175211c4..a166a2a293 100644 --- a/apps/web/components/task/chat/chat-input-area.tsx +++ b/apps/web/components/task/chat/chat-input-area.tsx @@ -1,6 +1,6 @@ "use client"; -import { useCallback, useState } from "react"; +import { useCallback, useState, type ReactNode } from "react"; import { IconArrowRight, IconGitMerge, IconX } from "@tabler/icons-react"; import { Button } from "@kandev/ui/button"; import { Tooltip, TooltipContent, TooltipTrigger } from "@kandev/ui/tooltip"; @@ -306,6 +306,7 @@ function ChatStatusBar({ onProceed, isAgentBusy, isMoving, + queueChip, }: { todoItems: TodoDisplayItem[]; taskId: string | null; @@ -315,6 +316,7 @@ function ChatStatusBar({ onProceed: () => void; isAgentBusy: boolean; isMoving: boolean; + queueChip?: ReactNode; }) { const showTodos = todoItems.length > 0; const showProceed = !!nextStepName && !isAgentBusy; @@ -327,6 +329,7 @@ function ChatStatusBar({ > {showTodos && } + {queueChip} {taskId && } {canShare && taskId && sessionId && (
@@ -440,17 +443,22 @@ export function ChatInputArea({ const { implementPlanHandler, proceedStepName, proceed, isMoving } = planActions; return (
- - + renderStatusBar={(queueChip) => ( + + )} + > { fireEvent.click(screen.getByTestId("queue-clear-all")); expect(state.clearAll).toHaveBeenCalledTimes(1); }); +}); +describe("QueueAffordance — renderStatusBar prop", () => { + it("calls renderStatusBar with null when there are no queued entries", () => { + useQueueMock.mockReturnValue(queueState([])); + const renderStatusBar = vi.fn(() =>
); + render( + + {CHILD} + , + ); + expect(renderStatusBar).toHaveBeenCalledWith(null); + expect(screen.getByTestId("status-bar-slot")).toBeTruthy(); + }); + + it("calls renderStatusBar with a chip node when entries exist and panel is closed", () => { + useQueueMock.mockReturnValue(queueState([entry()])); + const renderStatusBar = vi.fn((chip) =>
{chip}
); + render( + + {CHILD} + , + ); + const callArg = renderStatusBar.mock.calls[0][0]; + expect(callArg).not.toBeNull(); + // The chip lives inside the caller-supplied slot, not as a separate + // inline element above the input. + const slot = screen.getByTestId("status-bar-slot"); + expect(slot.contains(screen.getByTestId(CHIP_ID))).toBe(true); + }); + + it("calls renderStatusBar with null when entries exist and the panel is open", () => { + useQueueMock.mockReturnValue(queueState([entry()])); + const renderStatusBar = vi.fn((chip) =>
{chip}
); + render( + + {CHILD} + , + ); + // Open the panel — the chip should drop out of the status bar. + fireEvent.click(screen.getByTestId(CHIP_ID)); + expect(screen.getByTestId(PANEL_ID)).toBeTruthy(); + const lastCall = renderStatusBar.mock.calls.at(-1); + expect(lastCall?.[0]).toBeNull(); + }); +}); + +describe("QueueAffordance — workflow entries", () => { it("workflow queued entries are read-only", () => { useQueueMock.mockReturnValue( queueState([ diff --git a/apps/web/components/task/chat/queued-ghost-list.tsx b/apps/web/components/task/chat/queued-ghost-list.tsx index eebc7545d9..f260220ec2 100644 --- a/apps/web/components/task/chat/queued-ghost-list.tsx +++ b/apps/web/components/task/chat/queued-ghost-list.tsx @@ -57,16 +57,24 @@ function useEscToClose(open: boolean, onClose: () => void): void { type QueueAffordanceProps = { sessionId: string | null; children: ReactNode; + /** + * Optional render slot for placing the chip inside an external row (e.g. the + * chat status bar). The callback receives the chip node (or `null` when no + * chip should be shown) and returns the row markup. When omitted, the chip + * falls back to rendering inline above the input. + */ + renderStatusBar?: (queueChip: ReactNode) => ReactNode; }; /** * Wraps the chat input with the per-session queue affordance: * - When there are no queued entries, just renders `children` (the input). - * - Otherwise a small floating "n queued" chip sits over the input frame and - * clicking it expands a panel above the input. Drained or session-switched - * queues auto-collapse. + * - Otherwise a small "n queued" chip is exposed (either inline above the + * input, or via `renderStatusBar` into a caller-controlled row); clicking + * it expands a panel above the input. Drained or session-switched queues + * auto-collapse. */ -export function QueueAffordance({ sessionId, children }: QueueAffordanceProps) { +export function QueueAffordance({ sessionId, children, renderStatusBar }: QueueAffordanceProps) { const { entries, count, max, isFull, clearAll, editEntry, removeEntry } = useQueue(sessionId); const [isOpen, setIsOpen] = useState(false); @@ -114,10 +122,30 @@ export function QueueAffordance({ sessionId, children }: QueueAffordanceProps) { }); }, [clearAll]); - if (!sessionId || entryCount === 0) return <>{children}; + const hasEntries = !!sessionId && entryCount > 0; + const chipNode = + hasEntries && !isOpen ? ( + setIsOpen((v) => !v)} + /> + ) : null; + + if (!hasEntries) { + return ( + <> + {/* Call renderStatusBar even with null so the status bar stays mounted when the queue is empty. */} + {renderStatusBar?.(null)} + {children} + + ); + } return ( <> + {renderStatusBar?.(chipNode)} - {!isOpen && ( + {!renderStatusBar && chipNode && (
- setIsOpen((v) => !v)} - /> + {chipNode}
)} {children} @@ -161,9 +184,9 @@ type QueueChipProps = { function chipPalette(isFull: boolean): string { if (isFull) { - return "text-amber-600 dark:text-amber-400 border-amber-500/40 hover:bg-amber-500/10"; + return "text-amber-600 dark:text-amber-400 border-amber-500/60 hover:bg-amber-500/10"; } - return "text-muted-foreground border-border hover:text-foreground hover:border-border/80"; + return "text-muted-foreground border-muted-foreground/40 hover:text-foreground hover:border-muted-foreground/60"; } function QueueChip({ count, isFull, previewText, onToggle }: QueueChipProps) {