Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions scripts/helpers/main-composer-keyboard-smoke.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
46 changes: 45 additions & 1 deletion scripts/helpers/profile-photos-recipient-smoke.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
86 changes: 86 additions & 0 deletions scripts/helpers/workspace-project-smoke.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
89 changes: 79 additions & 10 deletions src/client/Feed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ import {
Bookmark,
BookmarkCheck,
ArrowUpRight,
Check,
MoreHorizontal,
ArrowUp,
FileText,
Expand Down Expand Up @@ -241,6 +242,7 @@ function FeedCard({
onAgent,
onMenu,
onDismiss,
dismissing = false,
dismissLabel = "Remove from Done",
onLater,
readAsCard,
Expand All @@ -267,6 +269,7 @@ function FeedCard({
onAgent?: () => void;
onMenu: () => void;
onDismiss?: () => void;
dismissing?: boolean;
dismissLabel?: string;
onLater: () => void;
readAsCard: boolean;
Expand Down Expand Up @@ -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 ? (
<Archive size={16} aria-hidden="true" />
) : (
<Check size={16} aria-hidden="true" />
);
const awaitingUpdate =
item.run &&
WORKING_RUN_DISPLAY_STATES.includes(item.run.state) &&
Expand Down Expand Up @@ -631,6 +642,18 @@ function FeedCard({
{next.label}
</button>
)}
{canQuickDismiss && (
<button
type="button"
className="card-action-done"
title={dismissLabel ?? "Remove from Done"}
disabled={dismissing}
onClick={onDismiss}
>
{quickDismissIcon}
{quickDismissLabel}
</button>
)}
{next?.kind !== "draft" && (
<button onClick={onReply}>
<MessageSquare size={16} />
Expand Down Expand Up @@ -795,6 +818,18 @@ function FeedCard({
)}
</div>
<div className="result-edit-actions">
{canQuickDismiss && (
<button
type="button"
className="secondary card-action-done"
title={dismissLabel ?? "Remove from Done"}
disabled={dismissing}
onClick={() => leaveReading(onDismiss!)}
>
{quickDismissIcon}
{quickDismissLabel}
</button>
)}
<button
className="primary"
onClick={() => leaveReading(onReply)}
Expand Down Expand Up @@ -1300,6 +1335,23 @@ export function Feed({
const agent = doneAgent?.id ?? scopedAgent;
const doneRead = filter === "done" ? selection.read : "all";
const doneFiltered = filter === "done" && (doneRead !== "all" || !!doneAgent);
const dismissingRef = useRef(new Set<string>());
const [dismissingCards, setDismissingCards] = useState<Set<string>>(
() => new Set(),
);
const feedDismissKey = (item: FeedItem, owner = viewOwner()) =>
JSON.stringify([owner, feedItemKey(item, item.sourceId ?? scopedSource)]);
const markDismissing = (key: string, pending: boolean) => {
if (pending) dismissingRef.current.add(key);
else dismissingRef.current.delete(key);
setDismissingCards((prev) => {
if (pending ? prev.has(key) : !prev.has(key)) return prev;
const next = new Set(prev);
if (pending) next.add(key);
else next.delete(key);
return next;
});
};
const readRecovery = useRef(
new FeedReadRecovery<RouteResponse<typeof workspaceApi.feed>>(),
);
Expand Down Expand Up @@ -2680,6 +2732,9 @@ export function Feed({
const owner = viewOwner(),
key = shownKey();
const source = item.sourceId ?? scopedSource;
const dismissKey = feedDismissKey(item, owner);
if (dismissingRef.current.has(dismissKey)) return;
markDismissing(dismissKey, true);
const current = () =>
owner === viewOwner() &&
doneRefresh.current.key === JSON.stringify([owner, key]);
Expand Down Expand Up @@ -2760,21 +2815,34 @@ export function Feed({
notify({
text: item.reply ? "Reply archived." : "Removed from Done.",
undo: async () => {
if (owner !== viewOwner()) return;
await setHidden(false);
updateCard(false);
update((old) =>
[
...old.filter((row) => feedItemKey(row) !== feedItemKey(item)),
item,
].sort(feedItemOrder),
);
if (current()) await load();
if (owner !== viewOwner() || dismissingRef.current.has(dismissKey))
return;
markDismissing(dismissKey, true);
try {
await setHidden(false);
if (owner !== viewOwner()) return;
updateCard(false);
update((old) =>
[
...old.filter(
(row) =>
feedItemKey(row, row.sourceId ?? scopedSource) !==
feedItemKey(item, source),
),
item,
].sort(feedItemOrder),
);
if (current()) await load();
} finally {
markDismissing(dismissKey, false);
}
},
});
if (current()) void load();
} catch (e) {
setError((e as Error).message);
} finally {
markDismissing(dismissKey, false);
}
}
async function markReplyRead(item: FeedItem) {
Expand Down Expand Up @@ -3509,6 +3577,7 @@ export function Feed({
? () => void dismissFeedCard(item)
: undefined
}
dismissing={dismissingCards.has(feedDismissKey(item))}
dismissLabel={
dismissFailure
? "Dismiss from Needs you"
Expand Down
Loading