diff --git a/scripts/helpers/main-composer-keyboard-smoke.mjs b/scripts/helpers/main-composer-keyboard-smoke.mjs index a171f225..040d4e12 100644 --- a/scripts/helpers/main-composer-keyboard-smoke.mjs +++ b/scripts/helpers/main-composer-keyboard-smoke.mjs @@ -102,6 +102,9 @@ export async function mainComposerKeyboardSmoke(page, fixture, capture) { el.scrollTop = 0; }); await expect(dock.getByLabel("Agent recipient")).toBeInViewport(); + await expect( + dock.getByRole("group", { name: "Quick recipient", exact: true }), + ).toBeInViewport(); await page.evaluate(() => { Object.defineProperty(window, "scrollY", window.__composerScroll); delete window.__composerScroll; diff --git a/scripts/helpers/profile-photos-recipient-smoke.mjs b/scripts/helpers/profile-photos-recipient-smoke.mjs index e4004463..b2d83547 100644 --- a/scripts/helpers/profile-photos-recipient-smoke.mjs +++ b/scripts/helpers/profile-photos-recipient-smoke.mjs @@ -29,10 +29,54 @@ export async function profilePhotosRecipientSmoke(page, fixture) { .click(); } await openTab(page, "Feed"); + // Tapping the already-selected recipient pill must preserve reply context; + // tapping a different pill clears it like the recipient dropdown does. + await page.evaluate( + ({ owner, agentId }) => { + sessionStorage.setItem( + `loop-workspace-draft:${JSON.stringify([owner, "", "composer", ""])}`, + JSON.stringify({ + selected: agentId, + replyContext: { + agentId, + conversationId: "", + messageId: "fixture-reply", + content: "Preserve this reply context", + mine: false, + }, + folderChoice: "", + }), + ); + }, + { owner: fixture.owner, agentId: first.id }, + ); + await page.reload({ waitUntil: "networkidle" }); await page .getByRole("button", { name: "Compose a message", exact: true }) .click(); - await page.getByLabel("Agent recipient").selectOption(second.id); + const replyChip = page.locator(".composer-reply-chip"); + await expect(replyChip).toContainText("Preserve this reply context"); + const pills = page.getByRole("group", { + name: "Quick recipient", + exact: true, + }); + await expect( + pills.getByRole("button", { name: `@${first.name}`, exact: true }), + ).toHaveAttribute("aria-pressed", "true"); + await pills + .getByRole("button", { name: `@${first.name}`, exact: true }) + .click(); + await expect(replyChip).toContainText("Preserve this reply context"); + // Quick recipient pills mirror the recipient picker with one tap and clear + // reply context only when switching to a different recipient. + await pills + .getByRole("button", { name: `@${second.name}`, exact: true }) + .click(); + await expect(replyChip).toHaveCount(0); + await expect(page.getByLabel("Agent recipient")).toHaveValue(second.id); + await expect( + pills.getByRole("button", { name: `@${second.name}`, exact: true }), + ).toHaveAttribute("aria-pressed", "true"); await page .getByLabel("Message your agent", { exact: true }) .fill("Remember this recipient"); diff --git a/scripts/helpers/workspace-project-smoke.mjs b/scripts/helpers/workspace-project-smoke.mjs index 01697d59..5994ca39 100644 --- a/scripts/helpers/workspace-project-smoke.mjs +++ b/scripts/helpers/workspace-project-smoke.mjs @@ -89,6 +89,92 @@ export async function workspaceProjectSmoke(page, fixture, _engine, capture) { await expect(reading).toContainText("Workspace notes are ready."); await reading.getByRole("button", { name: "Close", exact: true }).click(); await expect(reading).toHaveCount(0); + // One-tap Done clears a sealed result from Done (both on the card and from + // the reading sheet) and restores it cleanly via Undo. + const doneCard = page + .locator(".feed-results .feed-item-card") + .filter({ hasText: title }); + const dismissedToast = page + .getByRole("status") + .filter({ hasText: "Removed from Done" }); + // The menu can still invoke dismissal while the quick action is disabled. + // Only one hide request may proceed while the first is pending. + let releaseFirstDismiss; + const firstDismissHeld = new Promise((resolve) => { + releaseFirstDismiss = resolve; + }); + let hidePatchCount = 0; + const holdHideDismiss = async (route) => { + if ( + route.request().method() === "PATCH" && + route.request().postDataJSON()?.hidden === true + ) { + hidePatchCount += 1; + if (hidePatchCount === 1) await firstDismissHeld; + } + await route.continue(); + }; + await page.route("**/api/feed/*", holdHideDismiss); + try { + const doneButton = doneCard.getByRole("button", { + name: "Done", + exact: true, + }); + await doneButton.click(); + await expect.poll(() => hidePatchCount).toBe(1); + await expect(doneButton).toBeDisabled(); + await doneCard.getByRole("button", { name: "Thread actions" }).click(); + await page + .getByRole("menuitem", { name: "Remove from Done", exact: true }) + .click(); + releaseFirstDismiss(); + await expect(doneCard).toHaveCount(0); + await expect(dismissedToast).toBeVisible(); + await dismissedToast + .getByRole("button", { name: "Undo", exact: true }) + .click(); + await expect(doneCard).toHaveCount(1); + assert.equal( + hidePatchCount, + 1, + "Undo must not be raced by a second pending hide request", + ); + } finally { + releaseFirstDismiss(); + await page.unroute("**/api/feed/*", holdHideDismiss); + } + await doneCard.getByRole("button", { name: title }).click(); + await expect(reading).toBeVisible(); + // A dismissal failure after closing the reading sheet surfaces an alert + // and keeps the card in Done. + const failDismiss = (route) => + route.request().method() === "PATCH" + ? route.fulfill({ + status: 503, + json: { error: "Could not dismiss card" }, + }) + : route.continue(); + await page.route("**/api/feed/*", failDismiss); + try { + await reading.getByRole("button", { name: "Done", exact: true }).click(); + await expect(reading).toHaveCount(0); + await expect(page.getByRole("alert")).toContainText( + "Could not dismiss card", + ); + await expect(doneCard).toHaveCount(1); + } finally { + await page.unroute("**/api/feed/*", failDismiss); + } + await doneCard.getByRole("button", { name: title }).click(); + await expect(reading).toBeVisible(); + await reading.getByRole("button", { name: "Done", exact: true }).click(); + await expect(reading).toHaveCount(0); + await expect(doneCard).toHaveCount(0); + await expect(dismissedToast).toBeVisible(); + await dismissedToast + .getByRole("button", { name: "Undo", exact: true }) + .click(); + await expect(doneCard).toHaveCount(1); await page.evaluate((project) => { sessionStorage.setItem("loop-project-tab", "brief"); sessionStorage.setItem("loop-project-tab:" + project, "brief"); diff --git a/src/client/Feed.tsx b/src/client/Feed.tsx index 059087e2..0a0c1c3f 100644 --- a/src/client/Feed.tsx +++ b/src/client/Feed.tsx @@ -96,6 +96,7 @@ import { Bookmark, BookmarkCheck, ArrowUpRight, + Check, MoreHorizontal, ArrowUp, FileText, @@ -241,6 +242,7 @@ function FeedCard({ onAgent, onMenu, onDismiss, + dismissing = false, dismissLabel = "Remove from Done", onLater, readAsCard, @@ -267,6 +269,7 @@ function FeedCard({ onAgent?: () => void; onMenu: () => void; onDismiss?: () => void; + dismissing?: boolean; dismissLabel?: string; onLater: () => void; readAsCard: boolean; @@ -312,6 +315,14 @@ function FeedCard({ ? item.run.error : ""; const name = item.agent_name || agent?.name; + const canQuickDismiss = + !!onDismiss && !groupCount && dismissLabel !== "Dismiss from Needs you"; + const quickDismissLabel = item.reply ? "Archive" : "Done"; + const quickDismissIcon = item.reply ? ( +