Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
fix(inbox): keep open issue when switching Work panel Inbox tabs (MUL-9968) (#11302)
Jiayuan Zhangb31a24bea797
diff --git a/packages/core/inbox/selection-store.ts b/packages/core/inbox/selection-store.tsindex b0e69831a1..5ac1b24a35 100644--- a/packages/core/inbox/selection-store.ts+++ b/packages/core/inbox/selection-store.ts@@ -71,11 +71,17 @@ interface InboxSelectionState {lastResolvedKeyByWorkspace: Record<string, string>;rememberResolvedKey: (wsId: string, key: string) => void;/**- * The tab the Work panel's Inbox section last showed, per workspace, for- * pages other than the Inbox, whose own `?view=` sets the tab there.+ * The tab the Work panel's Inbox section last showed, per workspace.*/sectionTabByWorkspace: Record<string, InboxTab>;- setSectionTab: (wsId: string, tab: InboxTab) => void;+ /**+ * The `/inbox` route key (`${view}:${issue}`) the section tab last followed,+ * so switching sidebar tabs while an item stays open is preserved across+ * remounts and hover peeks while any new `/inbox` navigation syncs again.+ */+ sectionTabSyncedUrlByWorkspace: Record<string, string>;+ setSectionTab: (wsId: string, tab: InboxTab, syncedUrl?: string) => void;+ clearSectionTabSync: (wsId: string) => void;/*** Pending directional transition into the next (or undone) Inbox item.* Consumed once when that destination mounts; stale entries expire.@@ -137,9 +143,26 @@ export const useInboxSelectionStore = create<InboxSelectionState>()((set, get) =lastResolvedKeyByWorkspace: { ...state.lastResolvedKeyByWorkspace, [wsId]: key },}),sectionTabByWorkspace: {},- setSectionTab: (wsId, tab) =>- set((state) => (state.sectionTabByWorkspace[wsId] ?? "inbox") === tab ? state : {- sectionTabByWorkspace: { ...state.sectionTabByWorkspace, [wsId]: tab },+ sectionTabSyncedUrlByWorkspace: {},+ setSectionTab: (wsId, tab, syncedUrl) =>+ set((state) => {+ const tabSame = (state.sectionTabByWorkspace[wsId] ?? "inbox") === tab;+ const syncSame = syncedUrl === undefined || state.sectionTabSyncedUrlByWorkspace[wsId] === syncedUrl;+ if (tabSame && syncSame) return state;+ return {+ sectionTabByWorkspace: tabSame+ ? state.sectionTabByWorkspace+ : { ...state.sectionTabByWorkspace, [wsId]: tab },+ sectionTabSyncedUrlByWorkspace: syncSame+ ? state.sectionTabSyncedUrlByWorkspace+ : { ...state.sectionTabSyncedUrlByWorkspace, [wsId]: syncedUrl! },+ };+ }),+ clearSectionTabSync: (wsId) =>+ set((state) => {+ if (!(wsId in state.sectionTabSyncedUrlByWorkspace)) return state;+ const { [wsId]: _cleared, ...sectionTabSyncedUrlByWorkspace } = state.sectionTabSyncedUrlByWorkspace;+ return { sectionTabSyncedUrlByWorkspace };}),transitionByWorkspace: {},recordTransition: (wsId, targetKey, direction) =>diff --git a/packages/views/inbox/components/inbox-page.test.tsx b/packages/views/inbox/components/inbox-page.test.tsxindex 284348c57d..6c532d6f2e 100644--- a/packages/views/inbox/components/inbox-page.test.tsx+++ b/packages/views/inbox/components/inbox-page.test.tsx@@ -379,6 +379,20 @@ describe("InboxPage", () => {expect(issueDetailProps.at(-1)?.highlightCommentId).toBe("c2");});+ it("keeps an archived notification open on desktop when filters change in the sidebar", () => {+ reset();+ layout.width = DESKTOP;+ searchParams = new URLSearchParams("view=archived&issue=issue-9");+ listData.archived = [item({ id: "archived-1", issue_id: "issue-9", type: "new_comment", archived: true })];+ render(<InboxPage />);+ expect(screen.getByTestId("issue-detail")).toHaveTextContent("issue-9");++ act(() => useInboxFilterStore.getState().toggleFilterValue("workspace-1", "type", "mention"));++ expect(screen.getByTestId("issue-detail")).toHaveTextContent("issue-9");+ expect(replace).not.toHaveBeenCalled();+ });+it("opens a notification the Work panel offered despite a type filter", () => {reset();layout.width = DESKTOP;diff --git a/packages/views/inbox/components/inbox-page.tsx b/packages/views/inbox/components/inbox-page.tsxindex f9b2013312..192472b2fd 100644--- a/packages/views/inbox/components/inbox-page.tsx+++ b/packages/views/inbox/components/inbox-page.tsx@@ -261,10 +261,12 @@ export function InboxPage() {});const lookupItems = useMemo(() => deduplicateArchivedInboxItems(lookup.data?.items ?? []), [lookup.data]);const presenceItems = lookupMissed ? presence.data?.items ?? [] : [];- // On desktop the live list is the Work panel's Inbox section, which applies+ // On desktop the lists live in the Work panel's Inbox section, which applies// the filters itself. The page only opens the notification the URL names,- // so a filter can never refuse to open a row the section offered.+ // so changing a filter in the sidebar (even on another tab) never closes the+ // open detail.const opensAnyLiveRow = !isCompact && tab === "inbox";+ const opensAnyArchivedRow = !isCompact && isArchivedView;// The open notification stays in place when something other than an Inbox// action takes it out of the live list (`keepOpenInboxRow`). On desktop// that list is the Work panel section's; a phone keeps it in the page's own.@@ -287,12 +289,37 @@ export function InboxPage() {if (isSnoozedView) return [];if (opensAnyLiveRow) return settledRow ? [...items, settledRow.item] : items;if (!isArchivedView) return pageList.rows;- if (selectedOnPage) return filteredItems;+ if (selectedOnPage) {+ return opensAnyArchivedRow && !filteredItems.some((i) => (i.issue_id ?? i.id) === selectedKey)+ ? [...filteredItems, selectedOnPage]+ : filteredItems;+ }+ const matchedLookup = filterInboxItems(lookupItems, effectiveFilters, filterContext);+ const fallbackLookup =+ opensAnyArchivedRow && matchedLookup.length === 0+ ? deduplicateArchivedInboxItems([...lookupItems, ...presenceItems])+ : [];return deduplicateArchivedInboxItems([...filteredItems,- ...filterInboxItems(lookupItems, effectiveFilters, filterContext),+ ...matchedLookup,+ ...fallbackLookup,]);- }, [isSnoozedView, opensAnyLiveRow, settledRow, items, isArchivedView, pageList.rows, selectedOnPage, filteredItems, lookupItems, effectiveFilters, filterContext]);+ }, [+ isSnoozedView,+ opensAnyLiveRow,+ settledRow,+ items,+ isArchivedView,+ pageList.rows,+ selectedOnPage,+ opensAnyArchivedRow,+ filteredItems,+ selectedKey,+ lookupItems,+ effectiveFilters,+ filterContext,+ presenceItems,+ ]);const visibleItems =isArchivedView && pinnedKey ? selectionItems : isArchivedView || opensAnyLiveRow ? filteredItems : pageList.rows;@@ -310,7 +337,7 @@ export function InboxPage() {const selectedInView = selectedOnPage ?? (isArchivedView? [...lookupItems, ...presenceItems].find((i) => (i.issue_id ?? i.id) === selectedKey): null);- const selectionFilteredOut = !isSnoozedView && !!selectedKey && !!selectedInView && !selected;+ const selectionFilteredOut = isCompact && !isSnoozedView && !!selectedKey && !!selectedInView && !selected;// What the DETAIL pane shows, one React transition behind the click.//@@ -1021,6 +1048,7 @@ export function InboxPage() {// The issue the detail shows: the open notification's, or on the Snoozed// tab the snoozed issue itself.const detailIssueId = isSnoozedView ? detailKey || null : (detailItem?.issue_id ?? null);+ const TabIcon = tab === "archived" ? Archive : tab === "snoozed" ? AlarmClock : Inbox;const inboxHost = (issueId: string): IssueDetailInboxHost => ({// A phone's back control already names the list.crumb: isCompact@@ -1030,8 +1058,8 @@ export function InboxPage() {className: "flex min-w-0 items-center gap-1",label: (<>- <Inbox className="size-3.5 shrink-0" />- <span className="truncate">{t(($) => $.page.title)}</span>+ <TabIcon className="size-3.5 shrink-0" />+ <span className="truncate">{tabLabel}</span></>),},@@ -1040,7 +1068,7 @@ export function InboxPage() {isArchivedView && detailItem ? (<InboxArchivedBar item={detailItem} onRestore={() => handleUnarchive(detailItem.id)} />) : (- <IssueInboxBar issueId={issueId} issueActions={issueActions} movingOn={detailSwapping} />+ <IssueInboxBar issueId={issueId} issueActions={issueActions} movingOn={detailSwapping} isSnoozedView={isSnoozedView} />),});diff --git a/packages/views/issues/actions/issue-inbox-actions.tsx b/packages/views/issues/actions/issue-inbox-actions.tsxindex 0958360312..272e708cf8 100644--- a/packages/views/issues/actions/issue-inbox-actions.tsx+++ b/packages/views/issues/actions/issue-inbox-actions.tsx@@ -56,10 +56,13 @@ export function IssueInboxBar({issueId,issueActions,movingOn = false,+ isSnoozedView = false,}: {issueId: string;issueActions?: ReactNode;movingOn?: boolean;+ /** Opened from the Snoozed tab: show only its snooze bar without touching the live Inbox list. */+ isSnoozedView?: boolean;}) {const { t } = useT("inbox");const wsId = useWorkspaceId();@@ -67,7 +70,7 @@ export function IssueInboxBar({const { push } = useNavigation();const builtinNav = useBuiltinViewNavigation();const guest = useIsGuest(wsId);- const { rows, kept, filtered } = useFilteredInboxRows(wsId, issueId);+ const { rows, kept, filtered } = useFilteredInboxRows(wsId, isSnoozedView ? null : issueId, !isSnoozedView);const index = rows.findIndex((row) => row.issue_id === issueId);const row = index >= 0 ? rows[index]! : null;// A row kept after it left the Inbox on its own is no longer there to act on.diff --git a/packages/views/layout/panels/guest-work-panel.tsx b/packages/views/layout/panels/guest-work-panel.tsxindex b2386df994..d401ad267f 100644--- a/packages/views/layout/panels/guest-work-panel.tsx+++ b/packages/views/layout/panels/guest-work-panel.tsx@@ -9,6 +9,7 @@ import { projectListOptions } from "@multica/core/projects/queries";import type { Project } from "@multica/core/types";import { useNavigation } from "../../navigation";import { AutoArchivePromptDialog } from "../../inbox/components/auto-archive-prompt-dialog";+import { inboxTabFromParam } from "../../inbox/components/inbox-view";import { ProjectIcon } from "../../projects/components/project-icon";import { useT } from "../../i18n";import { PanelBody, PanelCount, PanelHeader, PanelLink, PanelList, PanelSection, isPathWithin } from "../panel-nav";@@ -38,8 +39,11 @@ export function GuestWorkPanel() {const shared = projects.filter((project) => !project.archived_at);const InvolvedIcon = routeIconForPath(p.myIssues());- // The notification open on the Inbox page beside the section.- const inboxOpenKey = pathname === p.inbox() ? searchParams.get("issue") : null;+ // The live notification open on the Inbox page beside the section.+ const inboxOpenKey =+ pathname === p.inbox() && inboxTabFromParam(searchParams.get("view")) === "inbox"+ ? searchParams.get("issue")+ : null;const inboxRows = useInboxSectionRows(wsId, inboxOpenKey);return (diff --git a/packages/views/layout/panels/inbox-section.test.tsx b/packages/views/layout/panels/inbox-section.test.tsxindex 8fb6c59ee9..d966fac79c 100644--- a/packages/views/layout/panels/inbox-section.test.tsx+++ b/packages/views/layout/panels/inbox-section.test.tsx@@ -182,7 +182,14 @@ beforeEach(() => {// Rows with the actor line; the compact default has tests of its own.useSidebarTreeStore.setState({ inboxCollapsed: false, inboxSettings: { ...DEFAULT_SIDEBAR_INBOX_SETTINGS, compact: false } });useInboxFilterStore.getState().clearFilters("ws-1");- useInboxSelectionStore.setState({ landing: null, heldRows: {}, leftRowKeyByWorkspace: {}, sectionTabByWorkspace: {} });+ useInboxSelectionStore.setState({+ landing: null,+ heldRows: {},+ leftRowKeyByWorkspace: {},+ sectionTabByWorkspace: {},+ sectionTabSyncedUrlByWorkspace: {},+ transitionByWorkspace: {},+ });});describe("InboxSection", () => {@@ -733,9 +740,14 @@ describe("InboxSection", () => {fireEvent.click(restoreOpen!);expect(nav.replace).toHaveBeenCalledWith("/acme/inbox?view=archived&issue=issue-y");expect(state.unarchive).toHaveBeenCalledWith("a1");+ expect(useInboxSelectionStore.getState().leftRowKeyByWorkspace["ws-1"]).toBe("issue-x");+ expect(useInboxSelectionStore.getState().transitionByWorkspace["ws-1"]).toMatchObject({+ targetKey: "issue-y",+ direction: "next",+ });});- it("follows the Inbox page's tab there, and switches the page's tab from the header", () => {+ it("follows the Inbox page's tab there, and switches the page's tab from the header when nothing is open", () => {const { nav } = renderSection([item({ id: "n1", issue_id: "issue-a" })], null, "/acme/inbox?view=archived");expect(screen.getByRole("tab", { name: /^Archived/ })).toHaveAttribute("aria-selected", "true");@@ -743,6 +755,111 @@ describe("InboxSection", () => {expect(nav.replace).toHaveBeenCalledWith("/acme/inbox");expect(useInboxSelectionStore.getState().sectionTabByWorkspace["ws-1"]).toBe("inbox");});++ it("keeps an open archived issue on screen when switching sidebar tabs, and keeps it lit when switching back", async () => {+ useAppearanceStore.getState().set({ reduceMotion: true });+ apiMock.listArchivedInboxPage.mockResolvedValue({+ items: [item({ id: "a1", issue_id: "issue-x", title: "Archived one", archived: true })],+ nextCursor: null,+ hasMore: false,+ });+ try {+ const { nav } = renderSection(+ [item({ id: "n1", issue_id: "issue-a", title: "Live one" })],+ null,+ "/acme/inbox?view=archived&issue=issue-x",+ );+ expect(await screen.findByRole("link", { name: /^Archived one/ })).toHaveAttribute("aria-current", "page");++ fireEvent.click(screen.getByRole("tab", { name: /^Inbox/ }));+ expect(nav.replace).not.toHaveBeenCalled();+ expect(screen.getByRole("tab", { name: /^Inbox/ })).toHaveAttribute("aria-selected", "true");+ expect(screen.getByRole("link", { name: /^Live one/ })).not.toHaveAttribute("aria-current");++ fireEvent.click(screen.getByRole("tab", { name: /^Archived/ }));+ expect(nav.replace).not.toHaveBeenCalled();+ expect(screen.getByRole("tab", { name: /^Archived/ })).toHaveAttribute("aria-selected", "true");+ expect(await screen.findByRole("link", { name: /^Archived one/ })).toHaveAttribute("aria-current", "page");+ } finally {+ useAppearanceStore.getState().reset();+ }+ });++ it("keeps an open live Inbox or Snoozed issue on screen when switching sidebar tabs", async () => {+ useAppearanceStore.getState().set({ reduceMotion: true });+ apiMock.listArchivedInboxPage.mockResolvedValue({+ items: [item({ id: "a1", issue_id: "issue-x", title: "Archived one", archived: true })],+ nextCursor: null,+ hasMore: false,+ });+ try {+ const first = renderSection([item({ id: "n1", issue_id: "issue-a", title: "Live one" })], "issue-a");+ fireEvent.click(screen.getByRole("tab", { name: /^Archived/ }));+ expect(first.nav.replace).not.toHaveBeenCalled();+ expect(await screen.findByRole("link", { name: /^Archived one/ })).toBeInTheDocument();+ first.unmount();++ useInboxSelectionStore.setState({ sectionTabByWorkspace: {}, sectionTabSyncedUrlByWorkspace: {} });+ const second = renderSection(+ [item({ id: "n1", issue_id: "issue-a", title: "Live one" })],+ null,+ "/acme/inbox?view=snoozed&issue=issue-z",+ [],+ [+ {+ issue_id: "issue-z",+ issue_identifier: "MUL-26",+ item_id: "z1",+ snoozed_until: "2099-01-01T09:00:00Z",+ snoozed_at: "2026-11-10T09:00:00Z",+ updates: 0,+ },+ ],+ );+ fireEvent.click(screen.getByRole("tab", { name: /^Inbox/ }));+ expect(second.nav.replace).not.toHaveBeenCalled();+ expect(screen.getByRole("link", { name: /^Live one/ })).toBeInTheDocument();+ } finally {+ useAppearanceStore.getState().reset();+ }+ });++ it("keeps an open archived row visible past the limit and offers Load more when more pages exist within the limit", async () => {+ useSidebarTreeStore.setState({ inboxSettings: { ...DEFAULT_SIDEBAR_INBOX_SETTINGS, limit: 5 } });+ apiMock.listArchivedInboxPage.mockResolvedValue({+ items: [+ ...Array.from({ length: 5 }, (_, i) =>+ item({ id: `a${i + 1}`, issue_id: `issue-${i + 1}`, title: `Row ${i + 1}`, archived: true }),+ ),+ item({ id: "a6", issue_id: "issue-6", title: "Open archived", archived: true }),+ ],+ nextCursor: "c2",+ hasMore: true,+ });+ const first = renderSection([], null, "/acme/inbox?view=archived&issue=issue-6");+ expect(await screen.findByRole("link", { name: /^Open archived/ })).toHaveAttribute("aria-current", "page");+ expect(screen.getByRole("button", { name: "Show 1 more..." })).toBeInTheDocument();+ first.unmount();++ useSidebarTreeStore.setState({ inboxSettings: { ...DEFAULT_SIDEBAR_INBOX_SETTINGS, limit: 10 } });+ apiMock.listArchivedInboxPage.mockResolvedValue({+ items: [item({ id: "a1", issue_id: "issue-1", title: "Only page row", archived: true })],+ nextCursor: "c2",+ hasMore: true,+ });+ renderSection([], null, "/acme/inbox?view=archived");+ expect(await screen.findByRole("button", { name: "Load more" })).toBeInTheDocument();+ });++ it("says when filters hide every archived row and offers to clear them", async () => {+ useInboxFilterStore.getState().toggleFilterValue("ws-1", "type", "mentions");+ apiMock.listArchivedInboxPage.mockResolvedValue({ items: [], nextCursor: null, hasMore: false });+ renderSection([], null, "/acme/inbox?view=archived");++ expect(await screen.findByText("No notifications match your filters")).toBeInTheDocument();+ fireEvent.click(screen.getByRole("button", { name: "Clear filters" }));+ expect(useInboxFilterStore.getState().filtersByWorkspace["ws-1"]).toBeUndefined();+ });});describe("InboxSection with every row shown", () => {diff --git a/packages/views/layout/panels/inbox-section.tsx b/packages/views/layout/panels/inbox-section.tsxindex 14d48daf7c..3a7c3b2fc5 100644--- a/packages/views/layout/panels/inbox-section.tsx+++ b/packages/views/layout/panels/inbox-section.tsx@@ -22,7 +22,7 @@ import {DropdownMenuSeparator,DropdownMenuTrigger,} from "@multica/ui/components/ui/dropdown-menu";-import { inboxTypeGroup, useInboxFilterStore } from "@multica/core/inbox/filter-store";+import { inboxFilterCount, inboxTypeGroup, useInboxFilterStore } from "@multica/core/inbox/filter-store";import {useArchiveAllInbox,useArchiveAllReadInbox,@@ -156,16 +156,26 @@ export function InboxSection({const { list, rows: all, displayed, expanded, limit, setExpanded } = rows;const keptText = useKeptInboxRowText(wsId);const clearFilters = useInboxFilterStore((state) => state.clearFilters);- // On the Inbox page its URL names the tab; elsewhere the section keeps the- // one picked last.+ // Follow the Inbox page's URL whenever navigation arrives at a new `/inbox`+ // state, while letting the user switch sidebar tabs freely without closing+ // an issue/notification currently open on the right.const onInboxPage = pathname === p.inbox();const pageTab = inboxTabFromParam(searchParams.get("view"));+ // What the Inbox page has open, keyed as its tab groups rows.+ const pageKey = onInboxPage ? searchParams.get("issue") : null;+ const inboxUrl = onInboxPage ? `${pageTab}:${pageKey ?? ""}` : null;const storedTab = useInboxSelectionStore((s) => s.sectionTabByWorkspace[wsId] ?? "inbox");+ const syncedUrl = useInboxSelectionStore((s) => s.sectionTabSyncedUrlByWorkspace[wsId]);const setSectionTab = useInboxSelectionStore((s) => s.setSectionTab);- const tab = onInboxPage ? pageTab : storedTab;+ const clearSectionTabSync = useInboxSelectionStore((s) => s.clearSectionTabSync);+ const tab = onInboxPage && syncedUrl !== inboxUrl ? pageTab : storedTab;useEffect(() => {- if (onInboxPage) setSectionTab(wsId, pageTab);- }, [onInboxPage, pageTab, setSectionTab, wsId]);+ if (onInboxPage && inboxUrl !== null) {+ if (syncedUrl !== inboxUrl) setSectionTab(wsId, pageTab, inboxUrl);+ } else if (syncedUrl !== undefined) {+ clearSectionTabSync(wsId);+ }+ }, [onInboxPage, inboxUrl, syncedUrl, pageTab, setSectionTab, clearSectionTabSync, wsId]);const selectTab = (next: InboxTab) => {// The open tab is the section's title: selecting it again folds the// section, as a click on another section's title does.@@ -173,12 +183,12 @@ export function InboxSection({setCollapsed(!collapsed);return;}- setSectionTab(wsId, next);+ setSectionTab(wsId, next, inboxUrl ?? undefined);if (collapsed) setCollapsed(false);- if (onInboxPage && next !== pageTab) replace(inboxTabHref(p, next));+ // Keep an empty `/inbox` canvas in sync with the tab, but never dismiss an+ // open issue/notification just because the user browsed another tab.+ if (onInboxPage && !pageKey && next !== pageTab) replace(inboxTabHref(p, next));};- // What the Inbox page has open, keyed as its tab groups rows.- const pageKey = onInboxPage ? searchParams.get("issue") : null;const openRowKey = pageTab === "inbox" ? pageKey : null;const snoozed = useSnoozedInboxRows(wsId);const archived = useArchivedInboxRows(wsId, tab === "archived" && !collapsed);@@ -351,6 +361,7 @@ export function InboxSection({/>) : tab === "archived" ? (<ArchivedSectionList+ wsId={wsId}archived={archived}limit={limit}openKey={pageTab === "archived" ? pageKey : null}@@ -1074,12 +1085,18 @@ const InboxRow = memo(function InboxRow({);});-/** A tab's rows past the section's limit wait behind "Show N more". */-function useSectionLimit<T>(rows: readonly T[], limit: number) {+/** A tab's rows past the section's limit wait behind "Show N more", keeping the open row visible. */+function useSectionLimit<T>(rows: readonly T[], limit: number, openIndex = -1) {const [expanded, setExpanded] = useState(false);+ const shown = expanded+ ? rows+ : openIndex >= limit+ ? [...rows.slice(0, limit - 1), rows[openIndex]!]+ : rows.slice(0, limit);return {- shown: expanded ? rows : rows.slice(0, limit),+ shown,more: rows.length > limit,+ hidden: Math.max(0, rows.length - shown.length),expanded,toggle: () => setExpanded((value) => !value),};@@ -1132,7 +1149,8 @@ function SnoozedSectionList({}) {const { t } = useT("inbox");const { unsnooze } = useInboxSnooze();- const { shown, more, expanded, toggle } = useSectionLimit(list.rows, limit);+ const openIndex = openKey ? list.rows.findIndex((entry) => entry.issue_id === openKey) : -1;+ const { shown, more, hidden, expanded, toggle } = useSectionLimit(list.rows, limit, openIndex);if (list.rows.length === 0) {if (list.load === "failed") {return (@@ -1158,7 +1176,7 @@ function SnoozedSectionList({))}</AnimatePresence></PanelList>- {more && <SectionMoreButton expanded={expanded} hidden={list.rows.length - limit} onToggle={toggle} />}+ {more && <SectionMoreButton expanded={expanded} hidden={hidden} onToggle={toggle} />}</>);}@@ -1248,10 +1266,12 @@ function SnoozedSectionRow({/** The Archived tab, a page at a time under the Inbox filters. */function ArchivedSectionList({+ wsId,archived,limit,openKey,}: {+ wsId: string;archived: ReturnType<typeof useArchivedInboxRows>;limit: number;openKey: string | null;@@ -1259,16 +1279,24 @@ function ArchivedSectionList({const { t } = useT("inbox");const p = useWorkspacePaths();const { replace } = useNavigation();- const { query, items } = archived;+ const { query, items, filters } = archived;+ const filtered = inboxFilterCount(filters) > 0;+ const clearFilters = useInboxFilterStore((state) => state.clearFilters);+ const leaveRow = useInboxSelectionStore((s) => s.leaveRow);+ const recordTransition = useInboxSelectionStore((s) => s.recordTransition);const restoreInbox = useRestoreInbox();- const { shown, more, expanded, toggle } = useSectionLimit(items, limit);+ const openIndex = openKey ? items.findIndex((item) => inboxRowKey(item) === openKey) : -1;+ const { shown, more, hidden, expanded, toggle } = useSectionLimit(items, limit, openIndex);// Restoring the open row moves the page on to the next archived one, as// its own bar's restore does.const restore = (item: InboxItem) => {const key = inboxRowKey(item);if (key === openKey) {+ leaveRow(wsId, key);const next = nextInboxRow(items, key);- replace(inboxTabHref(p, "archived", next ? inboxRowKey(next) : null));+ const nextKey = next ? inboxRowKey(next) : "";+ recordTransition(wsId, nextKey, "next");+ replace(inboxTabHref(p, "archived", nextKey || null));}void restoreInbox(item.id);};@@ -1280,6 +1308,20 @@ function ArchivedSectionList({</SectionNote>);}+ if (filtered && query.isSuccess) {+ return (+ <div className={cn(PANEL_ROW_CLASS, "pl-[2.375rem] text-caption text-faint-foreground")}>+ <span className="min-w-0 flex-1 truncate">{t(($) => $.filters.empty)}</span>+ <button+ type="button"+ className="shrink-0 rounded-md px-1 font-medium text-muted-foreground outline-none hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring"+ onClick={() => clearFilters(wsId)}+ >+ {t(($) => $.filters.clear)}+ </button>+ </div>+ );+ }return query.isSuccess ? <SectionNote>{t(($) => $.list.archived_empty)}</SectionNote> : null;}return (@@ -1296,15 +1338,19 @@ function ArchivedSectionList({))}</AnimatePresence></PanelList>- {more && <SectionMoreButton expanded={expanded} hidden={items.length - limit} onToggle={toggle} />}- {expanded && query.hasNextPage && (+ {more && <SectionMoreButton expanded={expanded} hidden={hidden} onToggle={toggle} />}+ {(!more || expanded) && query.hasNextPage && (<buttontype="button"disabled={query.isFetchingNextPage}className={cn(PANEL_ROW_CLASS, panelRowStateClass(false), "pl-[2.375rem] text-caption disabled:opacity-50")}onClick={() => void query.fetchNextPage()}>- {query.isFetchingNextPage ? t(($) => $.list.loading_more) : t(($) => $.list.load_more)}+ {query.isFetchingNextPage+ ? t(($) => $.list.loading_more)+ : query.isFetchNextPageError+ ? t(($) => $.list.retry)+ : t(($) => $.list.load_more)}</button>)}</>diff --git a/packages/views/layout/panels/work-panel.test.tsx b/packages/views/layout/panels/work-panel.test.tsxindex 66986e05ae..caeeaeeb74 100644--- a/packages/views/layout/panels/work-panel.test.tsx+++ b/packages/views/layout/panels/work-panel.test.tsx@@ -220,6 +220,9 @@ function renderPanel(<button type="button" onClick={() => setPathname(`/acme/issues/${ISSUE.id}`)}>Return to issue</button>+ <button type="button" onClick={() => setPathname(`/acme/inbox?view=archived&issue=${ISSUE.id}`)}>+ Open archived issue+ </button><button type="button" onClick={() => loading && setPathname(loading)}>Finish loading</button>@@ -263,6 +266,8 @@ beforeEach(() => {useInboxSelectionStore.setState({heldRows: {},leftRowKeyByWorkspace: {},+ sectionTabByWorkspace: {},+ sectionTabSyncedUrlByWorkspace: {},});apiMock.listIssueTableRows.mockResolvedValue({rows: [ISSUE, OTHER].map((issue) => ({ issue })),@@ -807,4 +812,34 @@ describe("KeptRowsRelease Inbox Zero undo", () => {fireEvent.click(screen.getByRole("button", { name: "Return to issue" }));expect(cleared()).toBeUndefined();});++ it("releases a held live Inbox row when opening the same issue in Archived, so switching back to Inbox does not ghost it", () => {+ const qc = renderPanel(`/acme/inbox?issue=${ISSUE.id}`, [], [], [], [inboxItem(ISSUE)]);+ expect(screen.getByRole("link", { name: INBOX_ROW_NAME })).toHaveAttribute("aria-current", "page");+ expect(useInboxSelectionStore.getState().heldRows["ws-1:section"]?.key).toBe(ISSUE.id);++ // Archive removes it from the live list, then opening it from Archived must release the live held row.+ act(() => {+ qc.setQueryData(inboxListOptions("ws-1").queryKey, []);+ });+ expect(screen.getByRole("link", { name: INBOX_ROW_NAME })).toBeInTheDocument();++ fireEvent.click(screen.getByRole("button", { name: "Open archived issue" }));+ expect(useInboxSelectionStore.getState().heldRows["ws-1:section"]).toBeUndefined();++ fireEvent.click(screen.getByRole("tab", { name: /^Inbox/ }));+ expect(screen.queryByRole("link", { name: INBOX_ROW_NAME })).toBeNull();+ });++ it("preserves a manual sidebar tab switch across hover-peek mounts while an archived issue stays open", () => {+ renderPanel(`/acme/inbox?view=archived&issue=${ISSUE.id}`, [], [], [], [inboxItem(OTHER)]);+ expect(screen.getByRole("tab", { name: /^Archived/ })).toHaveAttribute("aria-selected", "true");++ fireEvent.click(screen.getByRole("tab", { name: /^Inbox/ }));+ expect(screen.getByRole("tab", { name: /^Inbox/ })).toHaveAttribute("aria-selected", "true");++ fireEvent.click(screen.getByRole("button", { name: "Open peek" }));+ const peek = screen.getByTestId("peek");+ expect(within(peek).getByRole("tab", { name: /^Inbox/ })).toHaveAttribute("aria-selected", "true");+ });});diff --git a/packages/views/layout/panels/work-panel.tsx b/packages/views/layout/panels/work-panel.tsxindex da831e8ce9..da9ae8c17e 100644--- a/packages/views/layout/panels/work-panel.tsx+++ b/packages/views/layout/panels/work-panel.tsx@@ -15,6 +15,7 @@ import { projectListOptions } from "@multica/core/projects/queries";import type { Project } from "@multica/core/types";import { resolveClickIntent, useHeldUntilArrival, useNavigation } from "../../navigation";import { AutoArchivePromptDialog } from "../../inbox/components/auto-archive-prompt-dialog";+import { inboxTabFromParam } from "../../inbox/components/inbox-view";import { IssueContextMenuProvider } from "../../issues/actions";import { useIssueViewActions } from "../../issue-views/use-view-actions";import { useT } from "../../i18n";@@ -65,11 +66,15 @@ export function KeptRowsRelease() {// `undefined` while an identifier route waits for the page to load its issue.const issueId = issueSegment ? (issue?.id ?? (isIssueUuid(issueSegment) ? issueSegment : undefined)) : null;const projectId = routeSegment(pathname, p.projects());- // The notification the Inbox page has open, as its rows are keyed.+ // The notification the Inbox page has open, as its rows are keyed. Only the+ // live Inbox tab keeps open rows in place; archived/snoozed selections must+ // not hold or ghost rows in the live Inbox list.const onInbox = pathname === p.inbox();- const inboxKey = onInbox ? searchParams.get("issue") : null;+ const pageKey = onInbox ? searchParams.get("issue") : null;+ const inboxKey = onInbox && inboxTabFromParam(searchParams.get("view")) === "inbox" ? pageKey : null;const wasOnInbox = useRef(false);useLayoutEffect(() => {+ if (wsId && !onInbox) useInboxSelectionStore.getState().clearSectionTabSync(wsId);if (issueId === undefined) return;useSidebarKeptStore.getState().release([issueId, projectId].filter((id) => id !== null));if (wsId) {@@ -83,7 +88,7 @@ export function KeptRowsRelease() {}}wasOnInbox.current = onInbox;- }, [wsId, issueId, projectId, inboxKey, onInbox]);+ }, [wsId, issueId, projectId, inboxKey, onInbox, pageKey]);return null;}@@ -127,9 +132,13 @@ export function WorkPanel() {);const clickedIssue = clicked.value;const clickedList = clickedIssue && isOpenIssue(clickedIssue.segment) ? clickedIssue.list : undefined;- // The notification open on the Inbox page beside the section. Every Inbox- // row opens there, so an issue page is never the Inbox's.- const inboxOpenKey = pathname === p.inbox() ? searchParams.get("issue") : null;+ // The live notification open on the Inbox page beside the section. Every+ // Inbox row opens there, so an issue page — or an archived/snoozed item — is+ // never a live Inbox row.+ const inboxOpenKey =+ pathname === p.inbox() && inboxTabFromParam(searchParams.get("view")) === "inbox"+ ? searchParams.get("issue")+ : null;const inboxRows = useInboxSectionRows(wsId, inboxOpenKey);const treeClaimsIssue = clickedList !== undefined && clickedList !== PINS_LIST;const pins = usePanelPins(wsId, userId, pathname, treeClaimsIssue ? null : currentIssueId);