Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
fix(inbox): close the Work panel Inbox hover card when a row is pressed (MUL-9337) (#10672)
Bohan Jiang1b426d4b640e
diff --git a/packages/views/layout/panels/inbox-section.test.tsx b/packages/views/layout/panels/inbox-section.test.tsxindex 16608b81c7..50aee7bfb8 100644--- a/packages/views/layout/panels/inbox-section.test.tsx+++ b/packages/views/layout/panels/inbox-section.test.tsx@@ -1,5 +1,5 @@import type { ReactNode } from "react";-import { fireEvent, screen, within } from "@testing-library/react";+import { fireEvent, screen, waitFor, within } from "@testing-library/react";import { QueryClient, QueryClientProvider } from "@tanstack/react-query";import { beforeEach, describe, expect, it, vi } from "vitest";import {@@ -326,6 +326,31 @@ describe("InboxSection", () => {expect(state.archive).toHaveBeenCalledWith("n1");});+ it("closes the card when the row is pressed, and keeps a pending hover from reopening it", async () => {+ renderSection([item({ id: "n1", issue_id: "issue-a", title: "Commented", body: "Ship it on Friday" })]);+ const trigger = rows()[0]!.firstElementChild!;+ const card = () => document.querySelector("[data-inbox-card]");++ fireEvent.mouseEnter(trigger);+ await screen.findByText("Ship it on Friday", { selector: "[data-inbox-card] p" }, { timeout: 2000 });+ fireEvent.pointerDown(trigger);+ await waitFor(() => expect(card()).toBeNull());++ // Pressed before the hover delay ran out: the card stays shut.+ fireEvent.mouseLeave(trigger);+ fireEvent.pointerLeave(trigger);+ fireEvent.mouseEnter(trigger);+ fireEvent.pointerDown(trigger);+ await new Promise((resolve) => setTimeout(resolve, 700));+ expect(card()).toBeNull();++ // Leaving the row lets the next hover show it again.+ fireEvent.mouseLeave(trigger);+ fireEvent.pointerLeave(trigger);+ fireEvent.mouseEnter(trigger);+ await screen.findByText("Ship it on Friday", { selector: "[data-inbox-card] p" }, { timeout: 2000 });+ });+it("archives a row from its hover button", () => {renderSection([item({ id: "n1", issue_id: "issue-a", title: "Commented" })]);fireEvent.click(within(rows()[0]!).getByRole("button", { name: "Archive" }));diff --git a/packages/views/layout/panels/inbox-section.tsx b/packages/views/layout/panels/inbox-section.tsxindex e16c2a9e43..831a5161d1 100644--- a/packages/views/layout/panels/inbox-section.tsx+++ b/packages/views/layout/panels/inbox-section.tsx@@ -343,6 +343,16 @@ function InboxRow({writeViewState(issueHighlightMementoKey(item.issue_id), undefined);requestLanding(item.issue_id);};+ // The card previews a notification you have not opened. A press opens it,+ // so the card goes at once, with no exit animation to compete with the+ // issue's first render, and a hover delay already running must not bring it+ // back over the opened issue. It may return once the pointer leaves the row.+ const [cardOpen, setCardOpen] = useState(false);+ const [cardDismissed, setCardDismissed] = useState(false);+ const dismissCard = () => {+ setCardDismissed(true);+ setCardOpen(false);+ };const agents = useIssueAgentState(item.workspace_id, item.issue_id ?? "");const running = !!agents?.running;const unread = item.read !== true;@@ -388,11 +398,24 @@ function InboxRow({return (<li data-inbox-row data-read={unread ? "false" : "true"} className="group/inbox relative">- <HoverCard>+ <HoverCard+ open={cardOpen}+ onOpenChange={(open) => {+ if (open && cardDismissed) return;+ setCardOpen(open);+ }}+ ><HoverCardTriggerdelay={500}closeDelay={100}render={<div />}+ onPointerDown={dismissCard}+ onPointerLeave={() => setCardDismissed(false)}+ // Enter on the focused link opens the issue too. Focus does not+ // move, so the card stays shut without the dismissed flag.+ onKeyDown={(event) => {+ if (event.key === "Enter") setCardOpen(false);+ }}{...panelRowAnchor(active)}className={cn(PANEL_ROW_CLASS, panelRowStateClass(active), "relative", !compact && "items-start py-[5px]")}>@@ -444,8 +467,23 @@ function InboxRow({)}</AppLink></HoverCardTrigger>- <HoverCardContent side="right" align="start" sideOffset={12} alignOffset={-8} className="w-72 p-3">- <InboxRowCard item={item} href={href} title={title} onOpen={land} onArchive={onArchive} />+ <HoverCardContent+ side="right"+ align="start"+ sideOffset={12}+ alignOffset={-8}+ className={cn("w-72 p-3", cardDismissed && "data-closed:duration-0")}+ >+ <InboxRowCard+ item={item}+ href={href}+ title={title}+ onOpen={() => {+ dismissCard();+ land();+ }}+ onArchive={onArchive}+ /></HoverCardContent></HoverCard><TooltipHint label={archiveLabel}>