Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
fix(inbox): keep the issue header's Inbox actions until the next page arrives (MUL-9352) (#10689)
Jiayuan Zhang6b4d04fd2741
diff --git a/packages/core/inbox/selection-store.ts b/packages/core/inbox/selection-store.tsindex 590193ba25..2736f0b14e 100644--- a/packages/core/inbox/selection-store.ts+++ b/packages/core/inbox/selection-store.ts@@ -8,6 +8,14 @@ interface InboxSelectionState {/** The issue last opened from the Work panel's Inbox section. */sidebarIssueByWorkspace: Record<string, string | null>;rememberSidebarIssue: (wsId: string, issueId: string | null) => void;+ /**+ * Issues the Inbox section opened in another tab of this window. Desktop+ * tabs share this store, so each of these keeps counting as opened from+ * the Inbox beside the issue the current tab last opened from it.+ */+ sidebarTabIssuesByWorkspace: Record<string, string[]>;+ rememberSidebarTabIssue: (wsId: string, issueId: string) => void;+ forgetSidebarTabIssue: (wsId: string, issueId: string) => void;/*** The issue a notification row was last clicked for, with a counter that* moves on every click. The issue page replays its landing (the comment or@@ -31,6 +39,24 @@ export const useInboxSelectionStore = create<InboxSelectionState>()((set) => ({set((state) => (state.sidebarIssueByWorkspace[wsId] ?? null) === issueId ? state : {sidebarIssueByWorkspace: { ...state.sidebarIssueByWorkspace, [wsId]: issueId },}),+ sidebarTabIssuesByWorkspace: {},+ rememberSidebarTabIssue: (wsId, issueId) =>+ set((state) => {+ const issueIds = state.sidebarTabIssuesByWorkspace[wsId] ?? [];+ return issueIds.includes(issueId) ? state : {+ sidebarTabIssuesByWorkspace: { ...state.sidebarTabIssuesByWorkspace, [wsId]: [...issueIds, issueId] },+ };+ }),+ forgetSidebarTabIssue: (wsId, issueId) =>+ set((state) => {+ const issueIds = state.sidebarTabIssuesByWorkspace[wsId] ?? [];+ return issueIds.includes(issueId) ? {+ sidebarTabIssuesByWorkspace: {+ ...state.sidebarTabIssuesByWorkspace,+ [wsId]: issueIds.filter((id) => id !== issueId),+ },+ } : state;+ }),landing: null,requestLanding: (issueId) =>set((state) => ({ landing: { issueId, token: (state.landing?.token ?? 0) + 1 } })),diff --git a/packages/views/inbox/components/use-sidebar-inbox-issue.ts b/packages/views/inbox/components/use-sidebar-inbox-issue.tsnew file mode 100644index 0000000000..42ab8ef5cd--- /dev/null+++ b/packages/views/inbox/components/use-sidebar-inbox-issue.ts@@ -0,0 +1,22 @@+"use client";++import { useInboxSelectionStore } from "@multica/core/inbox/selection-store";+import { useHeldUntilArrival } from "../../navigation";++/**+ * Whether the open issue was opened from the Work panel's Inbox section: the+ * issue this page last opened from it, or one it opened in another tab.+ *+ * A row click or the issue header moving on to the next notification records+ * that issue before its page arrives; until then the open issue keeps the+ * record it had. `holding` keeps it for another click the caller knows has+ * named the next issue.+ */+export function useSidebarInboxIssue(wsId: string | undefined, openIssueId: string | null, holding = false) {+ const live = useInboxSelectionStore((s) => (wsId ? (s.sidebarIssueByWorkspace[wsId] ?? null) : null));+ const openedInTab = useInboxSelectionStore(+ (s) => !!wsId && !!openIssueId && !!s.sidebarTabIssuesByWorkspace[wsId]?.includes(openIssueId),+ );+ const held = useHeldUntilArrival(openIssueId, live, holding || (!!live && live !== openIssueId));+ return { fromInbox: !!openIssueId && (held.value === openIssueId || openedInTab), movingOn: held.movingOn };+}diff --git a/packages/views/issues/actions/__tests__/issue-inbox-actions.test.tsx b/packages/views/issues/actions/__tests__/issue-inbox-actions.test.tsxindex 3fd9c6c017..e50946c833 100644--- a/packages/views/issues/actions/__tests__/issue-inbox-actions.test.tsx+++ b/packages/views/issues/actions/__tests__/issue-inbox-actions.test.tsx@@ -1,5 +1,5 @@import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";-import { cleanup, fireEvent, screen } from "@testing-library/react";+import { act, cleanup, fireEvent, screen } from "@testing-library/react";import { QueryClient, QueryClientProvider } from "@tanstack/react-query";import { agentTaskSnapshotOptions } from "@multica/core/agents";import { useInboxFilterStore } from "@multica/core/inbox/filter-store";@@ -82,19 +82,22 @@ function setup({qc.setQueryData(inboxListOptions("ws").queryKey, rows);qc.setQueryData(snoozedInboxOptions("ws").queryKey, snoozed);qc.setQueryData(agentTaskSnapshotOptions("ws").queryKey, []);- renderWithI18n(+ const page = (id: string) => (<QueryClientProvider client={qc}><NavigationProvider value={nav}>- <IssueInboxActions issueId={issueId} onMarkDone={onMarkDone} />+ <IssueInboxActions issueId={id} onMarkDone={onMarkDone} /></NavigationProvider>- </QueryClientProvider>,+ </QueryClientProvider>);- return nav;+ const { rerender } = renderWithI18n(page(issueId));+ /** The route reaching another issue, which the same header then shows. */+ const arrive = (id: string) => rerender(page(id));+ return Object.assign(nav, { arrive });}beforeEach(() => {vi.clearAllMocks();- useInboxSelectionStore.setState({ sidebarIssueByWorkspace: { ws: "issue-1" } });+ useInboxSelectionStore.setState({ sidebarIssueByWorkspace: { ws: "issue-1" }, sidebarTabIssuesByWorkspace: {} });useInboxFilterStore.getState().clearFilters("ws");});afterEach(cleanup);@@ -106,6 +109,37 @@ describe("IssueInboxActions", () => {expect(screen.queryByRole("button", { name: "Archive" })).toBeNull();});+ it("stays on the open issue until the next notification's issue arrives", () => {+ const nav = setup();+ act(() => {+ useInboxSelectionStore.getState().rememberSidebarIssue("ws", "issue-2");+ });+ fireEvent.click(screen.getByRole("button", { name: "Archive" }));+ expect(state.archive).toHaveBeenLastCalledWith("n-1", expect.anything());++ nav.arrive("issue-2");+ fireEvent.click(screen.getByRole("button", { name: "Archive" }));+ expect(state.archive).toHaveBeenLastCalledWith("n-2", expect.anything());+ });++ it("shows on an issue the Inbox opened in another tab", () => {+ useInboxSelectionStore.setState({+ sidebarIssueByWorkspace: { ws: "issue-1" },+ sidebarTabIssuesByWorkspace: { ws: ["issue-2"] },+ });+ setup({ issueId: "issue-2" });+ fireEvent.click(screen.getByRole("button", { name: "Archive" }));+ expect(state.archive).toHaveBeenCalledWith("n-2", expect.anything());+ });++ it("leaves once the issue is opened from outside the Inbox", () => {+ setup();+ act(() => {+ useInboxSelectionStore.getState().rememberSidebarIssue("ws", null);+ });+ expect(screen.queryByRole("button", { name: "Archive" })).toBeNull();+ });+it("stays out once the issue has left the Inbox", () => {setup({ rows: [ROWS[1]!] });expect(screen.queryByRole("button", { name: "Archive" })).toBeNull();diff --git a/packages/views/issues/actions/issue-inbox-actions.tsx b/packages/views/issues/actions/issue-inbox-actions.tsxindex 1be1956810..39162deb99 100644--- a/packages/views/issues/actions/issue-inbox-actions.tsx+++ b/packages/views/issues/actions/issue-inbox-actions.tsx@@ -25,6 +25,7 @@ import { InboxSnoozeMenu } from "../../inbox/components/inbox-snooze-menu";import { formatSnoozeTime } from "../../inbox/components/inbox-snooze-time";import { useInboxSnooze } from "../../inbox/components/use-inbox-snooze";import { useFilteredInboxRows } from "../../inbox/components/use-filtered-inbox-rows";+import { useSidebarInboxIssue } from "../../inbox/components/use-sidebar-inbox-issue";import { useNavigation } from "../../navigation";import { useLocale, useT } from "../../i18n";@@ -52,7 +53,7 @@ export function IssueInboxActions({const wsId = useWorkspaceId();const p = useWorkspacePaths();const { push } = useNavigation();- const fromInbox = useInboxSelectionStore((s) => s.sidebarIssueByWorkspace[wsId] === issueId);+ const { fromInbox } = useSidebarInboxIssue(wsId, issueId);const rememberSidebarIssue = useInboxSelectionStore((s) => s.rememberSidebarIssue);const { rows } = useFilteredInboxRows(wsId, issueId, fromInbox);const index = fromInbox ? rows.findIndex((row) => row.issue_id === issueId) : -1;diff --git a/packages/views/issues/components/issue-detail.test.tsx b/packages/views/issues/components/issue-detail.test.tsxindex 87c3362580..3af23af2c7 100644--- a/packages/views/issues/components/issue-detail.test.tsx+++ b/packages/views/issues/components/issue-detail.test.tsx@@ -134,7 +134,11 @@ vi.mock("@multica/core/paths", async () => {const settingsPush = vi.hoisted(() => vi.fn());// Mock navigation-vi.mock("../../navigation", () => ({+vi.mock("../../navigation", async () => ({+ // Real hold hook (pure React) the header's Inbox actions read through.+ ...(await vi.importActual<typeof import("../../navigation/use-held-until-arrival")>(+ "../../navigation/use-held-until-arrival",+ )),AppLink: ({ children, href, ...props }: any) => (<a href={href} {...props}>{children}diff --git a/packages/views/layout/panel-nav.tsx b/packages/views/layout/panel-nav.tsxindex f2c192d3e4..df409426b6 100644--- a/packages/views/layout/panel-nav.tsx+++ b/packages/views/layout/panel-nav.tsx@@ -65,9 +65,11 @@ export function PanelHeader({export function PanelBody({children,onClickCapture,+ onAuxClickCapture,}: {children: React.ReactNode;onClickCapture?: React.MouseEventHandler<HTMLDivElement>;+ onAuxClickCapture?: React.MouseEventHandler<HTMLDivElement>;}) {const ref = useRef<HTMLDivElement>(null);const fadeStyle = useScrollFade(ref, 24);@@ -76,6 +78,7 @@ export function PanelBody({ref={ref}style={fadeStyle}onClickCapture={onClickCapture}+ onAuxClickCapture={onAuxClickCapture}className="scrollbar-slim min-h-0 flex-1 overflow-y-auto overscroll-contain px-2 pb-4 [&>section:first-child]:mt-0">{children}diff --git a/packages/views/layout/panels/work-panel.test.tsx b/packages/views/layout/panels/work-panel.test.tsxindex c3888907bb..fd94ae66c1 100644--- a/packages/views/layout/panels/work-panel.test.tsx+++ b/packages/views/layout/panels/work-panel.test.tsx@@ -31,6 +31,7 @@ import type {} from "@multica/core/types";import { renderWithI18n } from "../../test/i18n";import { NavigationProvider, type NavigationAdapter } from "../../navigation";+import { IssueInboxActions } from "../../issues/actions/issue-inbox-actions";import { KeptRowsRelease, WorkPanel } from "./work-panel";const apiMock = vi.hoisted(() => ({ listIssueTableRows: vi.fn(), getIssue: vi.fn() }));@@ -156,6 +157,8 @@ function renderPanel(inbox: InboxItem[] = [],/** As on web, a push lands only once the next page has loaded ("Finish loading"). */deferPush = false,+ /** As on desktop: links can open tabs, and an issue page shows its header. */+ desktop = false,) {const qc = new QueryClient({ defaultOptions: { queries: { staleTime: Infinity, retry: false } } });qc.setQueryData(inboxListOptions("ws-1").queryKey, inbox);@@ -183,7 +186,15 @@ function renderPanel(// A compact sheet unmounts the panel whenever it closes.const [sheetOpen, setSheetOpen] = useState(true);const [loading, setLoading] = useState<string | null>(null);+ const [newTab, setNewTab] = useState<string | null>(null);+ const openTab = (path: string) => setPathname(new URL(path, "http://x").pathname);const adapter: NavigationAdapter = {+ openInNewTab: desktop+ ? (path, _title, opts) => {+ setNewTab(path);+ if (opts?.activate) openTab(path);+ }+ : undefined,push: deferPush ? setLoading : setPathname,replace: setPathname,back: vi.fn(),@@ -195,7 +206,16 @@ function renderPanel(return (<NavigationProvider value={adapter}><KeptRowsRelease />+ {/* Each desktop tab mounts its own page. */}+ {desktop && pathname.startsWith("/acme/issues/") && (+ <div data-testid="issue-header">+ <IssueInboxActions key={pathname} issueId={pathname.split("/").at(-1)!} onMarkDone={() => {}} />+ </div>+ )}{sheetOpen && spaceForPath(pathname) === "work" && <WorkPanel />}+ <button type="button" onClick={() => newTab && openTab(newTab)}>+ Switch to new tab+ </button><button type="button" onClick={() => setPathname("/acme/agents")}>Leave Work</button>@@ -242,7 +262,7 @@ beforeEach(() => {});useActiveIssueViewStore.setState({ active: {} });useSidebarKeptStore.setState({ held: {} });- useInboxSelectionStore.setState({ sidebarIssueByWorkspace: {} });+ useInboxSelectionStore.setState({ sidebarIssueByWorkspace: {}, sidebarTabIssuesByWorkspace: {} });apiMock.listIssueTableRows.mockResolvedValue({rows: [ISSUE, OTHER].map((issue) => ({ issue })),total: 2,@@ -409,6 +429,24 @@ describe("WorkPanel Inbox highlight while the next page loads", () => {expect(inboxRow(ISSUE)).not.toHaveAttribute("aria-current");});+ it.each([{ metaKey: true }, { ctrlKey: true }, { metaKey: true, shiftKey: true }])(+ "keeps the open issue's records when another notification opens in a new tab (%o)",+ async (modifiers) => {+ await openFromInbox([]);+ fireEvent.click(inboxRow(OTHER), modifiers);++ expect(inboxRow(ISSUE)).toHaveAttribute("aria-current", "page");+ expect(useInboxSelectionStore.getState().sidebarIssueByWorkspace["ws-1"]).toBe(ISSUE.id);+ // A browser tab has a store of its own.+ expect(useInboxSelectionStore.getState().sidebarTabIssuesByWorkspace["ws-1"]).toBeUndefined();++ // Nothing was left pending for a later page to settle.+ fireEvent.click(screen.getByRole("button", { name: "Leave Work" }));+ fireEvent.click(screen.getByRole("button", { name: "Return to issue" }));+ expect(inboxRow(ISSUE)).toHaveAttribute("aria-current", "page");+ },+ );+it("lights nothing else while the issue header moves on from an archived notification", async () => {const qc = await openFromInbox([]);act(() => {@@ -421,6 +459,71 @@ describe("WorkPanel Inbox highlight while the next page loads", () => {});});+describe("WorkPanel Inbox across desktop tabs", () => {+ const inInbox = () => document.querySelector('[data-sidebar-list="inbox"]') as HTMLElement;+ const inMyIssues = () => document.querySelector('[data-sidebar-list="builtin:my_work"]') as HTMLElement;+ const inboxRow = (issue: Issue) => within(inInbox()).getByRole("link", { name: new RegExp(`^${issue.title}`) });+ const offersInboxActions = () => !!within(screen.getByTestId("issue-header")).queryByRole("button", { name: "Archive" });+ const switchToNewTab = () => fireEvent.click(screen.getByRole("button", { name: "Switch to new tab" }));+ const switchBack = () => fireEvent.click(screen.getByRole("button", { name: "Return to issue" }));++ async function openFromInbox() {+ useSidebarTreeStore.setState({ expanded: ["builtin:my_work"], projectsCollapsed: true });+ const qc = renderPanel("/acme/my-issues", [], [], [], [inboxItem(ISSUE), inboxItem(OTHER)], false, true);+ act(() => {+ qc.setQueryData(issueDetailOptions("ws-1", ISSUE.id).queryKey, ISSUE);+ qc.setQueryData(issueDetailOptions("ws-1", OTHER.id).queryKey, OTHER);+ });+ fireEvent.click(inboxRow(ISSUE));+ expect(offersInboxActions()).toBe(true);+ }++ it.each([+ ["Cmd-click", (link: HTMLElement) => fireEvent.click(link, { metaKey: true })],+ ["Ctrl-click", (link: HTMLElement) => fireEvent.click(link, { ctrlKey: true })],+ [+ "middle click",+ (link: HTMLElement) => fireEvent(link, new MouseEvent("auxclick", { bubbles: true, cancelable: true, button: 1 })),+ ],+ ])("keeps both issues opened from the Inbox after a %s opens a background tab", async (_, open) => {+ await openFromInbox();+ open(inboxRow(OTHER));++ expect(offersInboxActions()).toBe(true);+ expect(inboxRow(ISSUE)).toHaveAttribute("aria-current", "page");++ switchToNewTab();+ expect(offersInboxActions()).toBe(true);+ expect(inboxRow(OTHER)).toHaveAttribute("aria-current", "page");++ switchBack();+ expect(offersInboxActions()).toBe(true);+ expect(inboxRow(ISSUE)).toHaveAttribute("aria-current", "page");+ });++ it("keeps both issues opened from the Inbox after a Cmd+Shift-click opens a foreground tab", async () => {+ await openFromInbox();+ fireEvent.click(inboxRow(OTHER), { metaKey: true, shiftKey: true });++ expect(offersInboxActions()).toBe(true);+ expect(inboxRow(OTHER)).toHaveAttribute("aria-current", "page");++ switchBack();+ expect(offersInboxActions()).toBe(true);+ expect(inboxRow(ISSUE)).toHaveAttribute("aria-current", "page");+ });++ it("stops counting a tab's issue as opened from the Inbox once it is opened from another list", async () => {+ await openFromInbox();+ fireEvent.click(inboxRow(OTHER), { metaKey: true });+ switchToNewTab();+ fireEvent.click(await within(inMyIssues()).findByRole("link", { name: OTHER.title }));++ expect(offersInboxActions()).toBe(false);+ expect(within(inMyIssues()).getByRole("link", { name: OTHER.title })).toHaveAttribute("aria-current", "page");+ });+});+describe("WorkPanel issue highlight", () => {it("lights a clicked tree issue at once, never All issues first", async () => {renderPanel("/acme/my-issues");diff --git a/packages/views/layout/panels/work-panel.tsx b/packages/views/layout/panels/work-panel.tsxindex 39029d58fb..39e610cb1b 100644--- a/packages/views/layout/panels/work-panel.tsx+++ b/packages/views/layout/panels/work-panel.tsx@@ -13,7 +13,8 @@ import { useSidebarKeptStore } from "@multica/core/issues/stores/sidebar-kept-stimport { useSidebarTreeStore } from "@multica/core/issues/stores/sidebar-tree-store";import { projectListOptions } from "@multica/core/projects/queries";import type { Project } from "@multica/core/types";-import { useNavigation } from "../../navigation";+import { resolveClickIntent, useHeldUntilArrival, useNavigation } from "../../navigation";+import { useSidebarInboxIssue } from "../../inbox/components/use-sidebar-inbox-issue";import { IssueContextMenuProvider } from "../../issues/actions";import { useIssueViewActions } from "../../issue-views/use-view-actions";import { useT } from "../../i18n";@@ -35,13 +36,6 @@ interface ClickedIssue {list: string | null;}-/** The highlight records the open issue had before a click or the issue header moved on. */-interface SettledIssue {- issueId: string | null;- clickedIssue: ClickedIssue | null;- inboxIssueId: string | null;-}-/*** The `{id}` of a `{base}/{id}` route — for `/issues/{id}`, a UUID or an* identifier like `MUL-123`.@@ -80,7 +74,7 @@ export function KeptRowsRelease() {export function WorkPanel() {const { t } = useT("layout");const p = useWorkspacePaths();- const { pathname, searchParams } = useNavigation();+ const { pathname, searchParams, openInNewTab } = useNavigation();const wsId = useCurrentWorkspace()?.id;const userId = useAuthStore((s) => s.user?.id);const viewActions = useIssueViewActions();@@ -107,56 +101,44 @@ export function WorkPanel() {const [liveClickedIssue, setClickedIssue] = useState<ClickedIssue | null>(null);const isOpenIssue = (segment: string) =>!!currentIssueId && (segment === currentIssueId || segment === currentIssue?.identifier);+ // Until the route reaches the issue a click names, the open issue keeps the+ // records it had, or its highlight would fall through to another list, or+ // All issues, for the length of the load.+ const clicked = useHeldUntilArrival(+ currentIssueId,+ liveClickedIssue,+ !!liveClickedIssue && !isOpenIssue(liveClickedIssue.segment),+ );// An issue opened from the Inbox, by a row or by the issue header moving on// to the next notification, lights there while the section still shows it;// once archived, it falls back to the other lists.- const liveInboxIssueId = useInboxSelectionStore((s) => (wsId ? (s.sidebarIssueByWorkspace[wsId] ?? null) : null));- // A click, or the issue header moving on, names the next issue before the- // route reaches it, which on web waits for the next page to load. Until- // then the open issue keeps the record it had, or its highlight would fall- // through to another list, or All issues, for the length of the load.- const [settled, setSettled] = useState<SettledIssue>({- issueId: currentIssueId,- clickedIssue: liveClickedIssue,- inboxIssueId: liveInboxIssueId,- });- const movingOn =- settled.issueId === currentIssueId &&- ((liveClickedIssue !== settled.clickedIssue && !!liveClickedIssue && !isOpenIssue(liveClickedIssue.segment)) ||- (liveInboxIssueId !== settled.inboxIssueId && !!liveInboxIssueId && liveInboxIssueId !== currentIssueId));- if (- !movingOn &&- (settled.issueId !== currentIssueId ||- settled.clickedIssue !== liveClickedIssue ||- settled.inboxIssueId !== liveInboxIssueId)- ) {- setSettled({ issueId: currentIssueId, clickedIssue: liveClickedIssue, inboxIssueId: liveInboxIssueId });- }- const clickedIssue = movingOn ? settled.clickedIssue : liveClickedIssue;- const inboxIssueId = movingOn ? settled.inboxIssueId : liveInboxIssueId;+ const inbox = useSidebarInboxIssue(wsId, currentIssueId, clicked.movingOn);+ const movingOn = clicked.movingOn || inbox.movingOn;+ const clickedIssue = clicked.value;const clickedList = clickedIssue && isOpenIssue(clickedIssue.segment) ? clickedIssue.list : undefined;// The notification open beside the section: an issue opened from it, or an// issue-less one on the Inbox page.const inboxOpenKey =pathname === p.inbox()? searchParams.get("issue")- : currentIssueId && inboxIssueId === currentIssueId+ : currentIssueId && inbox.fromInbox? currentIssueId: null;const inboxRows = useInboxSectionRows(wsId, inboxOpenKey);const rememberSidebarIssue = useInboxSelectionStore((s) => s.rememberSidebarIssue);+ const rememberSidebarTabIssue = useInboxSelectionStore((s) => s.rememberSidebarTabIssue);+ const forgetSidebarTabIssue = useInboxSelectionStore((s) => s.forgetSidebarTabIssue);// Moving on from an archived row keeps the issue lit nowhere rather than elsewhere.const inboxClaimsIssue =- !!currentIssueId &&- inboxIssueId === currentIssueId &&- (movingOn || inboxRows.shownIssueIds.has(currentIssueId));+ !!currentIssueId && inbox.fromInbox && (movingOn || inboxRows.shownIssueIds.has(currentIssueId));const treeClaimsIssue = inboxClaimsIssue || (clickedList !== undefined && clickedList !== PINS_LIST);const pins = usePanelPins(wsId, userId, pathname, treeClaimsIssue ? null : currentIssueId);const requestLocate = useSidebarTreeStore((s) => s.requestLocate);const rememberClickedIssue = (event: React.MouseEvent) => {+ // A middle click opens a tab; other buttons open nothing.+ if (event.type === "auxclick" && event.button !== 1) return;const link = (event.target as HTMLElement).closest("a[href]");if (!link) return;- requestLocate(null);const path = new URL(link.getAttribute("href") ?? "", window.location.href).pathname;const segment = routeSegment(path, p.issues());// An Inbox row's hover card renders in a portal, outside the row's list.@@ -165,9 +147,20 @@ export function WorkPanel() {: link.closest("[data-inbox-card]")? INBOX_LIST: (link.closest("[data-sidebar-list]")?.getAttribute("data-sidebar-list") ?? null);+ // A click that opens a tab or window, as AppLink resolves it, leaves this+ // page and its records where they are. A desktop tab shares this page's+ // store, so an issue the Inbox opens there is recorded beside them.+ if (resolveClickIntent(event) !== "push" || (event.shiftKey && !openInNewTab)) {+ if (openInNewTab && segment && wsId && list === INBOX_LIST) rememberSidebarTabIssue(wsId, segment);+ return;+ }+ requestLocate(null);setClickedIssue(segment ? { segment, list } : null);// Inbox rows link by issue id, which is what the issue header compares.- if (segment && wsId) rememberSidebarIssue(wsId, list === INBOX_LIST ? segment : null);+ if (segment && wsId) {+ rememberSidebarIssue(wsId, list === INBOX_LIST ? segment : null);+ forgetSidebarTabIssue(wsId, segment);+ }};const { projectSettings, projectOrder } = useSidebarProjectPrefs(wsId ?? "");@@ -238,7 +231,7 @@ export function WorkPanel() {{/* Outside PanelBody: clicks inside the menu's portal still bubblethrough the React tree, and must not reach rememberClickedIssue. */}<IssueContextMenuProvider variant="sidebar">- <PanelBody onClickCapture={rememberClickedIssue}>+ <PanelBody onClickCapture={rememberClickedIssue} onAuxClickCapture={rememberClickedIssue}>{wsId && (<InboxSectionwsId={wsId}diff --git a/packages/views/navigation/index.ts b/packages/views/navigation/index.tsindex c7e9a496db..82ef44e2f4 100644--- a/packages/views/navigation/index.ts+++ b/packages/views/navigation/index.ts@@ -18,4 +18,5 @@ export { useAppOrigin } from "./use-app-origin";export { useRowLink, rowLinkInteractiveProps } from "./use-row-link";export { useIntentNavigate } from "./use-intent-navigate";export { useBackOrReplace } from "./use-back-or-replace";+export { useHeldUntilArrival } from "./use-held-until-arrival";export type { NavigationAdapter } from "./types";diff --git a/packages/views/navigation/use-held-until-arrival.ts b/packages/views/navigation/use-held-until-arrival.tsnew file mode 100644index 0000000000..22c544a162--- /dev/null+++ b/packages/views/navigation/use-held-until-arrival.ts@@ -0,0 +1,19 @@+"use client";++import { useState } from "react";++/**+ * `live` as the open issue sees it. A click, or the issue header moving on,+ * names the next issue before the route reaches it, which on web waits for+ * the next page to load. While `namesNext` says `live` has named another+ * issue, the open issue keeps the value it had; once the route reaches+ * another issue, or `live` stops naming one, `live` takes over.+ */+export function useHeldUntilArrival<T>(openIssueId: string | null, live: T, namesNext: boolean) {+ const [settled, setSettled] = useState({ issueId: openIssueId, value: live });+ const movingOn = settled.issueId === openIssueId && live !== settled.value && namesNext;+ if (!movingOn && (settled.issueId !== openIssueId || settled.value !== live)) {+ setSettled({ issueId: openIssueId, value: live });+ }+ return { value: movingOn ? settled.value : live, movingOn };+}