diff --git a/DESIGN.md b/DESIGN.md index b658bbcb92f..bc4d8150a1d 100644 --- a/DESIGN.md +++ b/DESIGN.md @@ -72,8 +72,10 @@ rejection and revision remain available. Live tool reviews keep their own approv Pending questions, confirmations, and other task-thread inputs appear in a separate card directly above the ordinary composer. The composer stays available for new -messages while the card is open. Dismissing a card leaves a pending indicator that -can reopen it; resolving or skipping the input removes that indicator. +messages while the card is open. Questions use their compact history entry as the +reminder; dismissing one clears the composer and stays effective after reload for +that person and task. Other inputs keep a pending indicator that can reopen them; +resolving or skipping the input removes that indicator. ## Enforcement (what "compliant" means for the extraction run) @@ -123,4 +125,4 @@ tokenize motion. Principles — reasoning only; values live in `ui/src/index.css block collapses the duration/stagger tokens to zero, cascading to every scoped token, in addition to each animation's own component-level guard. -Agent Chat keeps pending questions as compact “Unanswered question” entries at their original position in history. A newer user message dismisses the old question form without resolving it. Opening the history entry restores the original form and its draft; submitting later uses the same durable question response path. Actual permission reviews retain their permission checks. +Agent Chat and regular task chats keep pending questions as compact “Unanswered question” entries at their original position in history. Dismissing the form or sending a newer user message clears it from the composer without resolving it. Questions never contribute to composer pending counts or navigation. Opening the history entry restores the original form and its draft; submitting later uses the same durable question response path. Actual permission reviews retain their permission checks. diff --git a/doc/DEVELOPING.md b/doc/DEVELOPING.md index d4d86ee58f6..850081d3919 100644 --- a/doc/DEVELOPING.md +++ b/doc/DEVELOPING.md @@ -140,6 +140,12 @@ choices, item verdicts, suggested tasks, tool reviews, runtime questions, and ph the bottom navigation. The normal message composer remains usable below the pending card. +Use **Chat & Comments → Task Chat Unanswered Questions → Test Drive** to +try a regular task question: dismiss it, reload, reopen its compact feed entry, +and submit the preserved draft. The composer has no question pending badge. +The demo uses real thread/form components with fixture response callbacks. +The Agent Chat stories share the same component fixture. + Use **Composer → Model and effort picker** to review harness-specific model choices. Codex uses the curated adapter catalog unless the instance declares `PAPERCLIP_ADAPTER_MODELS`; general OpenAI API models are not Codex choices. diff --git a/doc/SPEC-implementation.md b/doc/SPEC-implementation.md index 821c0486fa1..e75d6f41b33 100644 --- a/doc/SPEC-implementation.md +++ b/doc/SPEC-implementation.md @@ -1502,6 +1502,13 @@ Required UX behaviors: - conflict toasts on atomic checkout failure - no silent background failures; every failed run visible in UI +Regular task chats and Agent Chat keep unanswered questions as compact, +reopenable entries at their original position in the feed. Dismissing a question +or sending a newer message clears its form from the composer without resolving +the saved question. Questions do not contribute to composer pending counts. +Dismissal persists locally for the person and task across reloads; reopening +restores the original form and draft. Approval and permission gates are unchanged. + ## 15. Operational Requirements ## 15.1 Environment diff --git a/tests/e2e/planning-mode-visual-verification.spec.ts b/tests/e2e/planning-mode-visual-verification.spec.ts index 564ae156d93..818f8de1bec 100644 --- a/tests/e2e/planning-mode-visual-verification.spec.ts +++ b/tests/e2e/planning-mode-visual-verification.spec.ts @@ -9,25 +9,20 @@ import { const AGENT_NAME = "CEO"; const TASK_TITLE = "Paperclip onboarding"; -/** - * The first task opens with the chief of staff's opening card sitting where - * the composer is. Cancel hands the plain composer back (the card stays - * pending), and the composer is where the mode chip lives. - * - * The card arrives with the interactions fetch, after the composer's first - * paint, so a bare `count()` right after navigation sees no card and skips - * the click; the card then lands on top of the composer and hides the mode - * chip. Wait for the card (or, if it is already dismissed, the pending - * strip it leaves behind) before deciding, and only return once the plain - * composer is back. - */ +/** Wait for the saved question before checking its dismissed presentation. */ +async function expectOpeningQuestionDismissed(page: import("@playwright/test").Page) { + await expect(page.getByTestId("task-chat-unanswered-question")).toBeVisible({ timeout: 30_000 }); + await expect(page.getByTestId("task-chat-composer-takeover")).toHaveCount(0); + await expect(page.getByTestId("task-chat-pending-input-indicator")).toHaveCount(0); + await expect(page.getByTestId("task-chat-composer-mode")).toBeVisible({ timeout: 30_000 }); +} + +/** The opening question arrives after the interactions fetch. Dismiss it once. */ async function dismissOpeningCard(page: import("@playwright/test").Page) { const takeover = page.getByTestId("task-chat-composer-takeover"); - const pendingStrip = page.getByTestId("task-chat-pending-input-indicator"); - await expect(takeover.or(pendingStrip).first()).toBeVisible({ timeout: 30_000 }); - const cancel = takeover.getByRole("button", { name: "Cancel", exact: true }); - if (await cancel.count()) await cancel.first().click(); - await expect(page.getByTestId("task-chat-composer-mode")).toBeVisible({ timeout: 30_000 }); + await expect(takeover).toBeVisible({ timeout: 30_000 }); + await takeover.getByRole("button", { name: "Cancel", exact: true }).click(); + await expectOpeningQuestionDismissed(page); } test("captures planning mode UI for desktop and mobile", async ({ page }) => { @@ -155,6 +150,8 @@ test("captures planning mode UI for desktop and mobile", async ({ page }) => { await page.goto(issuePath); await dismissOpeningCard(page); + await page.reload(); + await expectOpeningQuestionDismissed(page); await expect(page.getByText("Plan mode").first()).toBeVisible(); const desktopPlanningToggle = page.getByTestId("task-chat-composer-mode"); await expect(desktopPlanningToggle).toBeVisible(); @@ -174,7 +171,7 @@ test("captures planning mode UI for desktop and mobile", async ({ page }) => { }); await page.goto(issuePath); - await dismissOpeningCard(page); + await expectOpeningQuestionDismissed(page); await page.getByTestId("task-chat-composer-mode").click(); await expect(page.getByTestId("task-chat-composer-mode")).toHaveCount(0); await expect(page.getByTestId("task-chat-composer-add")).toBeVisible(); @@ -186,7 +183,7 @@ test("captures planning mode UI for desktop and mobile", async ({ page }) => { await setMode("planning"); await page.setViewportSize({ width: 390, height: 844 }); await page.goto(issuePath); - await dismissOpeningCard(page); + await expectOpeningQuestionDismissed(page); await expect(page.getByText("Plan mode").first()).toBeVisible(); const mobilePlanningToggle = page.getByTestId("task-chat-composer-mode"); await expect(mobilePlanningToggle).toBeVisible(); diff --git a/ui/src/components/TaskChatThread.test.tsx b/ui/src/components/TaskChatThread.test.tsx index f4d0f046ab1..51243236c1f 100644 --- a/ui/src/components/TaskChatThread.test.tsx +++ b/ui/src/components/TaskChatThread.test.tsx @@ -2873,11 +2873,11 @@ describe("TaskChatThread runtime transcript selection", () => { ); }); -describe("Agent Chat unanswered question history", () => { +describe.each([true, false])("Unanswered question history (conversationMode=%s)", conversationMode => { const old = questionInteraction("old", "Which color?", "2026-08-15T12:00:01Z"); const newer = questionInteraction("new", "Which tone?", "2026-08-15T12:05:00Z"); const movedOn = createLongThreadComments(); - const props = { conversationMode: true, issueId: "issue-1", onAdd: async () => {}, onSubmitInteractionAnswers: vi.fn() }; + const props = { conversationMode, issueId: "issue-1", currentUserId: "user-board", onAdd: async () => {}, onSubmitInteractionAnswers: vi.fn() }; const takeover = () => container.querySelector('[data-testid="task-chat-composer-takeover"]'); const pendingIndicator = () => container.querySelector('[data-testid="task-chat-pending-input-indicator"]'); const dismiss = async () => { @@ -2989,12 +2989,55 @@ describe("Agent Chat unanswered question history", () => { expect(container.querySelector('[data-testid="task-chat-unanswered-question"]')).not.toBeNull(); }); - it("does not change ordinary task question behavior", async () => { - render(); - expect(takeover()?.textContent).toContain("Which color?"); - expect(container.querySelector('[data-testid="task-chat-unanswered-question"]')).toBeNull(); + it.each(["Cancel", "dismiss"])("keeps a fresh question dismissed after remounting (%s)", async action => { + const show = () => render(); + show(); + await click("Yes"); + if (action === "Cancel") await click("Cancel"); + else await dismiss(); + flushSync(() => root!.unmount()); + root = createRoot(container); + show(); + expect(takeover()).toBeNull(); + expect(pendingIndicator()).toBeNull(); + await act(async () => container.querySelector('[aria-label="Answer question: Which color?"]')!.click()); + expect(takeover()?.querySelector('[role="radio"][aria-checked="true"]')?.textContent).toContain("Yes"); + }); + + it("shows a newly asked question after dismissing an older one", async () => { + render(); await dismiss(); - expect(pendingIndicator()?.textContent).toContain("1 pending input"); + await act(async () => render()); + expect(takeover()?.textContent).toContain("Which tone?"); + expect(takeover()?.textContent).not.toContain("Which color?"); + expect(container.querySelectorAll('[data-testid="task-chat-unanswered-question"]')).toHaveLength(2); + }); + + it("preserves a question dismissal saved by another tab", async () => { + render(); + // The other tab saves after this thread has loaded its dismissal state. + localStorage.setItem("paperclip:task-question-dismissals:user-board:issue-1", JSON.stringify([newer.id])); + await dismiss(); + flushSync(() => root!.unmount()); + root = createRoot(container); + render(); + expect(takeover()).toBeNull(); + expect(pendingIndicator()).toBeNull(); + expect(container.querySelectorAll('[data-testid="task-chat-unanswered-question"]')).toHaveLength(2); + }); + + it("scopes dismissal to the person and task", async () => { + const show = (userId: string, issueId: string) => render(); + show("user-board", "issue-1"); + await dismiss(); + flushSync(() => root!.unmount()); + root = createRoot(container); + show("another-user", "issue-1"); + expect(takeover()).not.toBeNull(); + flushSync(() => root!.unmount()); + root = createRoot(container); + show("user-board", "issue-2"); + expect(takeover()).not.toBeNull(); }); }); diff --git a/ui/src/components/TaskChatThread.tsx b/ui/src/components/TaskChatThread.tsx index 1c409845c90..8f27f9816bf 100644 --- a/ui/src/components/TaskChatThread.tsx +++ b/ui/src/components/TaskChatThread.tsx @@ -105,6 +105,7 @@ import { TaskChatQueuedMessages } from "@/components/task-chat/TaskChatQueuedMes import { TaskChatWindowScroll } from "@/components/task-chat/useWindowAutoFollow"; import { useSidebar } from "@/context/SidebarContext"; import { useStreamlinedUiEnabled } from "@/hooks/useStreamlinedUiEnabled"; +import { useDismissedTaskQuestions } from "@/hooks/useDismissedTaskQuestions"; import { cn } from "@/lib/utils"; import { Skeleton } from "@/components/ui/skeleton"; import { Button } from "@/components/ui/button"; @@ -2475,11 +2476,12 @@ export function TaskChatThread(props: TaskChatThreadProps) { } return result; }, [interactions, pendingRuntimeRequest]); - // Agent Chat questions already have an answerable history card, including + // Questions already have an answerable history card, including // when the user dismisses a fresh form without sending another message. const pendingReminderInputs = useMemo(() => pendingComposerInputs.filter(input => - !(conversationMode && input.kind === "durable" && input.interaction.kind === "ask_user_questions")), - [pendingComposerInputs, conversationMode]); + !(input.kind === "durable" && input.interaction.kind === "ask_user_questions")), + [pendingComposerInputs]); + const { dismissedQuestionIds, dismissQuestion } = useDismissedTaskQuestions(issueId, currentUserId); const latestUserComment = useMemo(() => comments .filter(comment => !comment.deletedAt && comment.authorUserId && !comment.authorAgentId && !comment.createdByRunId) .reduce<(typeof comments)[number] | null>((latest, comment) => @@ -2488,10 +2490,10 @@ export function TaskChatThread(props: TaskChatThreadProps) { // A later message leaves a question answerable in history, without reopening // its form on every render or reload. Explicit selection can still reopen it. const currentPendingInputs = useMemo(() => pendingComposerInputs.filter(input => - !(conversationMode && input.kind === "durable" - && input.interaction.kind === "ask_user_questions" && latestUserComment - && toMs(input.interaction.createdAt) < toMs(latestUserComment.createdAt))), - [pendingComposerInputs, conversationMode, latestUserComment]); + !(input.kind === "durable" && input.interaction.kind === "ask_user_questions" + && (dismissedQuestionIds.has(input.interaction.id) || (latestUserComment + && toMs(input.interaction.createdAt) < toMs(latestUserComment.createdAt))))), + [pendingComposerInputs, dismissedQuestionIds, latestUserComment]); const currentPendingKeys = useMemo(() => new Set(currentPendingInputs.map(input => input.key)), [currentPendingInputs]); const [takeoverMode, setTakeoverMode] = useState<"open" | "normal">("open"); const [selectedPendingKey, setSelectedPendingKey] = useState( @@ -2574,7 +2576,8 @@ export function TaskChatThread(props: TaskChatThreadProps) { if (assigneeUsesPaperclipRunner) setRunnerSubmissionPending(true); try { await onAdd(...args); - if (conversationMode && selectedPendingInput?.kind === "durable" && selectedPendingInput.interaction.kind === "ask_user_questions") { + if (selectedPendingInput?.kind === "durable" && selectedPendingInput.interaction.kind === "ask_user_questions") { + dismissQuestion(selectedPendingInput.interaction.id); setSelectedPendingKey(null); setTakeoverMode("normal"); } @@ -2583,7 +2586,7 @@ export function TaskChatThread(props: TaskChatThreadProps) { throw error; } }, - [assigneeUsesPaperclipRunner, onAdd, conversationMode, selectedPendingInput], + [assigneeUsesPaperclipRunner, onAdd, selectedPendingInput, dismissQuestion], ); const optimisticRunnerStartup = assigneeUsesPaperclipRunner && @@ -2670,7 +2673,7 @@ export function TaskChatThread(props: TaskChatThreadProps) { setTakeoverMode("normal"), + onDismiss: () => { + if (selectedPendingInput.kind === "durable" && selectedPendingInput.interaction.kind === "ask_user_questions") { + dismissQuestion(selectedPendingInput.interaction.id); + setSelectedPendingKey(null); + } + setTakeoverMode("normal"); + }, onSkip: () => skipPendingInput(selectedPendingInput), onShowNext: showNextPendingInput, inlineSkip: diff --git a/ui/src/hooks/useDismissedTaskQuestions.ts b/ui/src/hooks/useDismissedTaskQuestions.ts new file mode 100644 index 00000000000..facc097fcf9 --- /dev/null +++ b/ui/src/hooks/useDismissedTaskQuestions.ts @@ -0,0 +1,30 @@ +import { useCallback, useMemo, useState } from "react"; + +function loadDismissedQuestions(storageKey: string | null): Set { + try { + const value: unknown = JSON.parse(storageKey ? localStorage.getItem(storageKey) ?? "[]" : "[]"); + return new Set(Array.isArray(value) ? value.filter((id): id is string => typeof id === "string") : []); + } catch { + return new Set(); + } +} + +/** Presentation preference only: the original question remains answerable. */ +export function useDismissedTaskQuestions(issueId?: string | null, userId?: string | null) { + const storageKey = issueId ? `paperclip:task-question-dismissals:${userId ?? "board"}:${issueId}` : null; + const [state, setState] = useState(() => ({ storageKey, ids: loadDismissedQuestions(storageKey) })); + const dismissedQuestionIds = useMemo(() => state.storageKey === storageKey + ? state.ids : loadDismissedQuestions(storageKey), [state, storageKey]); + const dismissQuestion = useCallback((interactionId: string) => { + // Another tab may have saved more dismissals since this thread rendered. + const ids = new Set([...loadDismissedQuestions(storageKey), ...dismissedQuestionIds]); + ids.add(interactionId); + try { + if (storageKey) localStorage.setItem(storageKey, JSON.stringify([...ids])); + } catch { + // Keep dismissal effective for this mounted thread when storage is unavailable. + } + setState({ storageKey, ids }); + }, [dismissedQuestionIds, storageKey]); + return { dismissedQuestionIds, dismissQuestion }; +} diff --git a/ui/storybook/fixtures/unansweredQuestionChat.tsx b/ui/storybook/fixtures/unansweredQuestionChat.tsx new file mode 100644 index 00000000000..87bc6330dc8 --- /dev/null +++ b/ui/storybook/fixtures/unansweredQuestionChat.tsx @@ -0,0 +1,61 @@ +import { useState } from "react"; +import type { AskUserQuestionsInteraction, IssueComment } from "@paperclipai/shared"; +import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; +import { queryKeys } from "@/lib/queryKeys"; +import { TaskChatThread } from "@/components/TaskChatThread"; +import { pendingAskUserQuestionsInteraction } from "@/fixtures/issueThreadInteractionFixtures"; +import { storybookAgentMap } from "./paperclipData"; + +export const question: AskUserQuestionsInteraction = { + ...pendingAskUserQuestionsInteraction, + id: "unanswered-color", title: "Welcome note preference", sourceRunId: "original-run", + createdAt: new Date("2026-04-01T12:01:00Z"), + payload: { version: 1, runtimeRequestId: "color-request", questions: [{ id: "color", prompt: "Which color should the welcome note use?", + selectionMode: "single", required: true, options: [{ id: "blue", label: "Blue" }, { id: "green", label: "Green" }] }] }, +}; +const otherQuestion: AskUserQuestionsInteraction = { + ...question, id: "unanswered-tone", sourceRunId: "second-run", title: "Welcome note tone", + createdAt: new Date("2026-04-01T12:03:00Z"), + payload: { version: 1, questions: [{ id: "tone", prompt: "Which tone should the welcome note use?", + selectionMode: "single", required: true, options: [{ id: "friendly", label: "Friendly" }, { id: "formal", label: "Formal" }] }] }, +}; +function comment(id: string, body: string, at: string, agent = false): IssueComment { + return { id, companyId: question.companyId, issueId: question.issueId, body, authorType: agent ? "agent" : "user", + authorAgentId: agent ? question.createdByAgentId ?? null : null, authorUserId: agent ? null : "user-board", + presentation: null, metadata: null, createdAt: new Date(at), updatedAt: new Date(at) }; +} +export function QuestionChat({ movedOn = false, multiple = false, answered = false, conversationMode = true }: { movedOn?: boolean; multiple?: boolean; answered?: boolean; conversationMode?: boolean }) { + const [queryClient] = useState(() => { + const client = new QueryClient({ defaultOptions: { queries: { retry: false, staleTime: Infinity } } }); + // This conversation has no plan. Keep the real thread's plan query local + // to the fixture rather than requesting an API from the static publisher. + client.setQueryData([...queryKeys.issues.documents(conversationMode ? question.issueId : "task-unanswered-questions-demo"), "plan"], null); + return client; + }); + const [interactions, setInteractions] = useState([ + answered ? { ...question, status: "answered", resolvedAt: new Date("2026-04-01T12:06:00Z"), result: { version: 1, answers: [{ questionId: "color", optionIds: ["blue"] }] } } : question, + ...(multiple ? [otherQuestion] : []), + ]); + const [comments, setComments] = useState([ + comment("start", "Help me plan a welcome note for our garden club.", "2026-04-01T12:00:00Z"), + ...(movedOn || multiple || answered ? [ + comment("move-on", "Let's leave those choices for later. What can Paperclip tasks track?", "2026-04-01T12:04:00Z"), + comment("reply", "Tasks track ownership, progress, and the work needed to reach a goal.", "2026-04-01T12:05:00Z", true), + ] : []), + ...(answered ? [comment("late-answer", "Blue it is. I'll use that preference when we return to the welcome note.", "2026-04-01T12:07:00Z", true)] : []), + ]); + return
+

{conversationMode ? "Garden club chat" : "Draft the garden club welcome note"}

Questions can wait. Open an unanswered question in history whenever you're ready.

} + onAdd={async body => { + setComments(rows => [...rows, comment(`user-${rows.length}`, body, new Date().toISOString()), + comment(`agent-${rows.length}`, "We can come back to that question later. What would you like to work on next?", new Date(Date.now() + 1).toISOString(), true)]); + }} + onSubmitInteractionAnswers={async (interaction, answers) => { + setInteractions(rows => rows.map(row => row.id === interaction.id ? { ...row, status: "answered", resolvedAt: new Date(), result: { version: 1, answers } } : row)); + setComments(rows => [...rows, comment(`answer-${rows.length}`, "Thanks, I've received your answer to the earlier question.", new Date().toISOString(), true)]); + }} + /> +
; +} diff --git a/ui/storybook/stories/agent-chat-unanswered-questions.stories.tsx b/ui/storybook/stories/agent-chat-unanswered-questions.stories.tsx index c784ff88146..6d25d088789 100644 --- a/ui/storybook/stories/agent-chat-unanswered-questions.stories.tsx +++ b/ui/storybook/stories/agent-chat-unanswered-questions.stories.tsx @@ -1,68 +1,10 @@ -import { useState } from "react"; import type { Meta, StoryObj } from "@storybook/react-vite"; import { expect, userEvent, within, waitFor } from "storybook/test"; -import type { AskUserQuestionsInteraction, IssueComment } from "@paperclipai/shared"; -import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; -import { queryKeys } from "@/lib/queryKeys"; -import { TaskChatThread } from "@/components/TaskChatThread"; -import { pendingAskUserQuestionsInteraction } from "@/fixtures/issueThreadInteractionFixtures"; -import { storybookAgentMap } from "../fixtures/paperclipData"; +import { QuestionChat, question } from "../fixtures/unansweredQuestionChat"; -const question: AskUserQuestionsInteraction = { - ...pendingAskUserQuestionsInteraction, - id: "unanswered-color", title: "Welcome note preference", sourceRunId: "original-run", - createdAt: new Date("2026-04-01T12:01:00Z"), - payload: { version: 1, runtimeRequestId: "color-request", questions: [{ id: "color", prompt: "Which color should the welcome note use?", - selectionMode: "single", required: true, options: [{ id: "blue", label: "Blue" }, { id: "green", label: "Green" }] }] }, -}; -const otherQuestion: AskUserQuestionsInteraction = { - ...question, id: "unanswered-tone", sourceRunId: "second-run", title: "Welcome note tone", - createdAt: new Date("2026-04-01T12:03:00Z"), - payload: { version: 1, questions: [{ id: "tone", prompt: "Which tone should the welcome note use?", - selectionMode: "single", required: true, options: [{ id: "friendly", label: "Friendly" }, { id: "formal", label: "Formal" }] }] }, -}; -function comment(id: string, body: string, at: string, agent = false): IssueComment { - return { id, companyId: question.companyId, issueId: question.issueId, body, authorType: agent ? "agent" : "user", - authorAgentId: agent ? question.createdByAgentId ?? null : null, authorUserId: agent ? null : "user-board", - presentation: null, metadata: null, createdAt: new Date(at), updatedAt: new Date(at) }; -} -function QuestionChat({ movedOn = false, multiple = false, answered = false }: { movedOn?: boolean; multiple?: boolean; answered?: boolean }) { - const [queryClient] = useState(() => { - const client = new QueryClient({ defaultOptions: { queries: { retry: false, staleTime: Infinity } } }); - // This conversation has no plan. Keep the real thread's plan query local - // to the fixture rather than requesting an API from the static publisher. - client.setQueryData([...queryKeys.issues.documents(question.issueId), "plan"], null); - return client; - }); - const [interactions, setInteractions] = useState([ - answered ? { ...question, status: "answered", resolvedAt: new Date("2026-04-01T12:06:00Z"), result: { version: 1, answers: [{ questionId: "color", optionIds: ["blue"] }] } } : question, - ...(multiple ? [otherQuestion] : []), - ]); - const [comments, setComments] = useState([ - comment("start", "Help me plan a welcome note for our garden club.", "2026-04-01T12:00:00Z"), - ...(movedOn || multiple || answered ? [ - comment("move-on", "Let's leave those choices for later. What can Paperclip tasks track?", "2026-04-01T12:04:00Z"), - comment("reply", "Tasks track ownership, progress, and the work needed to reach a goal.", "2026-04-01T12:05:00Z", true), - ] : []), - ...(answered ? [comment("late-answer", "Blue it is. I'll use that preference when we return to the welcome note.", "2026-04-01T12:07:00Z", true)] : []), - ]); - return
-

Garden club chat

Questions can wait. Open an unanswered question in history whenever you're ready.

} - onAdd={async body => { - setComments(rows => [...rows, comment(`user-${rows.length}`, body, new Date().toISOString()), - comment(`agent-${rows.length}`, "We can come back to that question later. What would you like to work on next?", new Date(Date.now() + 1).toISOString(), true)]); - }} - onSubmitInteractionAnswers={async (interaction, answers) => { - setInteractions(rows => rows.map(row => row.id === interaction.id ? { ...row, status: "answered", resolvedAt: new Date(), result: { version: 1, answers } } : row)); - setComments(rows => [...rows, comment(`answer-${rows.length}`, "Thanks, I've received your answer to the earlier question.", new Date().toISOString(), true)]); - }} - /> -
; -} const meta = { title: "Chat & Comments/Agent Chat Unanswered Questions", parameters: { layout: "fullscreen" }, component: QuestionChat, beforeEach: () => { + localStorage.removeItem(`paperclip:task-question-dismissals:user-board:${question.issueId}`); for (const key of Object.keys(localStorage)) { if (key.includes(`paperclip:task-input:${question.issueId}:`)) localStorage.removeItem(key); } diff --git a/ui/storybook/stories/task-chat-unanswered-questions.stories.tsx b/ui/storybook/stories/task-chat-unanswered-questions.stories.tsx new file mode 100644 index 00000000000..a5b698086f3 --- /dev/null +++ b/ui/storybook/stories/task-chat-unanswered-questions.stories.tsx @@ -0,0 +1,37 @@ +import type { Meta, StoryObj } from "@storybook/react-vite"; +import { expect, userEvent, within, waitFor } from "storybook/test"; +import { QuestionChat } from "../fixtures/unansweredQuestionChat"; + +const meta = { + title: "Chat & Comments/Task Chat Unanswered Questions", + parameters: { layout: "fullscreen" }, + component: QuestionChat, + args: { conversationMode: false }, +} satisfies Meta; +export default meta; +type Story = StoryObj; + +// Keep the test-drive story's dismissal preference across actual page reloads. +export const TestDrive: Story = {}; +export const MovedOn: Story = { args: { movedOn: true } }; +export const MultipleUnanswered: Story = { args: { multiple: true } }; +export const AnsweredHistory: Story = { args: { answered: true } }; +export const Mobile: Story = { args: { movedOn: true }, globals: { viewport: { value: "mobile", isRotated: false } } }; +export const DismissAndAnswerLater: Story = { + beforeEach: () => { + localStorage.removeItem("paperclip:task-question-dismissals:user-board:task-unanswered-questions-demo"); + }, + play: async ({ canvasElement }) => { + const canvas = within(canvasElement); + await waitFor(() => expect(canvas.getByRole("radio", { name: "Green" })).toBeVisible()); + await userEvent.click(canvas.getByRole("radio", { name: "Green" })); + await userEvent.click(canvas.getByRole("button", { name: /^Dismiss / })); + await expect(canvas.getByTestId("task-chat-unanswered-question")).toBeVisible(); + await expect(canvas.queryByTestId("task-chat-composer-takeover")).not.toBeInTheDocument(); + await expect(canvas.queryByTestId("task-chat-pending-input-indicator")).not.toBeInTheDocument(); + await userEvent.click(canvas.getByTestId("task-chat-unanswered-question")); + await expect(canvas.getByRole("radio", { name: "Green" })).toBeChecked(); + await userEvent.click(canvas.getByRole("button", { name: /^(Send|Submit) answers$/ })); + await waitFor(() => expect(canvas.getByTestId("task-chat-answered-questions-receipt")).toBeVisible()); + }, +};