Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

fix(inbox): land notification clicks on their comment below long descriptions (MUL-9492) (#10872)

Multica Eve36c11d17c41a
diff --git a/e2e/issue-timeline-scroll.spec.ts b/e2e/issue-timeline-scroll.spec.ts
index 00a4d9d4a9..992dd4944a 100644
--- a/e2e/issue-timeline-scroll.spec.ts
+++ b/e2e/issue-timeline-scroll.spec.ts
@@ -229,3 +229,65 @@ test("Inbox landing survives a comment that arrives while it is still aligning",
await api.cleanup();
}
});
+
+test("a notification under a long description lands on its reply, and again from another page", async ({ page }) => {
+ test.setTimeout(180_000);
+ await page.setViewportSize({ width: 1100, height: 620 });
+ const api = await createTestApi();
+ try {
+ const slug = await loginAsDefault(page);
+ const title = "Landing below a long description";
+ // MUL-9492: the description alone is several viewports tall, so the
+ // timeline starts far below the fold and Virtuoso has measured nothing yet.
+ const description = Array.from({ length: 7 }, (_, i) => [
+ `## Section ${i}`,
+ `Opening paragraph ${i}, see [MUL-${9000 + i}](mention://issue/01a1e252-c081-7b00-b653-${String(100000000000 + i)}). ${"The description runs long. ".repeat(4)}`,
+ ...Array.from({ length: 6 }, (_, j) => `- Point ${i}.${j}: ${"a clause that wraps. ".repeat(3)}`),
+ ["| Term | Value | Notes |", "|---|---|---|", ...Array.from({ length: 4 }, (_, j) => `| Row ${j} | ${j * 25}% | ${"A table cell that wraps. ".repeat(3)} |`)].join("\n"),
+ ].join("\n\n")).join("\n\n");
+ const issue = await api.createIssue(title, { description });
+ const first = await api.createComment(issue.id, "First thread root");
+ await api.createComment(issue.id, `Short reply. ${"Some context. ".repeat(10)}`, first.id);
+ const root = await api.createComment(issue.id, "Long discussion root");
+ let targetId = "";
+ for (let i = 0; i < 24; i++) {
+ const body = Array.from({ length: 3 + (i % 5) }, (_, j) => `Paragraph ${j}. ${"A long agent reply in a long thread. ".repeat(8)}`).join("\n\n");
+ targetId = (await api.createComment(issue.id, `Reply ${i}\n\n${body}`, root.id)).id;
+ }
+ const other = await api.createIssue("Another notification", { description: "Short." });
+ await api.seedCommentNotification(other.id, (await api.createComment(other.id, "Other comment")).id, "Another notification");
+ await api.seedCommentNotification(issue.id, targetId, title);
+
+ const landed = () => page.evaluate((id) => {
+ const container = [...document.querySelectorAll<HTMLElement>('[data-tab-scroll-root^="main:"]')].find((el) => el.clientHeight > 0);
+ const target = container?.querySelector<HTMLElement>(`[id="comment-${id}"]`);
+ if (!container || !target || target.dataset.virtualThreadMounted === "false") return null;
+ return Math.round(target.getBoundingClientRect().top - container.getBoundingClientRect().top);
+ }, targetId);
+ const expectLanded = async (message: string) => {
+ let stable = 0;
+ await expect.poll(async () => {
+ const offset = await landed();
+ stable = offset !== null && offset >= 0 && offset < 120 ? stable + 1 : 0;
+ return stable;
+ }, { message, timeout: 10_000, intervals: [100] }).toBeGreaterThanOrEqual(5);
+ };
+
+ await page.goto(`/${slug}/inbox`);
+ const notification = page.getByText(title, { exact: true }).first();
+ await notification.click();
+ await expectLanded("first click");
+
+ // Read elsewhere, leave, and click the same notification from another issue.
+ await page.evaluate(() => {
+ const container = [...document.querySelectorAll<HTMLElement>('[data-tab-scroll-root^="main:"]')].find((el) => el.clientHeight > 0)!;
+ container.scrollTop = 1500;
+ });
+ await page.getByText("Another notification", { exact: true }).first().click();
+ await expect(page.getByText("Other comment")).toBeVisible();
+ await notification.click();
+ await expectLanded("click from another issue");
+ } finally {
+ await api.cleanup();
+ }
+});
diff --git a/packages/core/inbox/selection-store.ts b/packages/core/inbox/selection-store.ts
index 1667ab2e60..510710bd20 100644
--- a/packages/core/inbox/selection-store.ts
+++ b/packages/core/inbox/selection-store.ts
@@ -22,9 +22,15 @@ interface InboxSelectionState {
* moves on every click. The issue page replays its landing (the comment or
* app request the link names) when the counter moves, which a click on the
* row already open needs: the page neither remounts nor sees a new link.
+ *
+ * Until the page reports it `landed`, the click outranks the page's record
+ * that it already landed on that comment. The record belongs to the issue's
+ * route, which a click on another page cannot reach before it navigates.
*/
- landing: { issueId: string; token: number } | null;
+ landing: { issueId: string; token: number; landed: boolean } | null;
requestLanding: (issueId: string) => void;
+ /** The issue page landed the click with this token. */
+ completeLanding: (token: number) => void;
/**
* The open notification's row as each list last showed it, by
* `${wsId}:${list}`, so the list can keep it in place (`keepOpenInboxRow`).
@@ -83,7 +89,11 @@ export const useInboxSelectionStore = create<InboxSelectionState>()((set) => ({
}),
landing: null,
requestLanding: (issueId) =>
- set((state) => ({ landing: { issueId, token: (state.landing?.token ?? 0) + 1 } })),
+ set((state) => ({ landing: { issueId, token: (state.landing?.token ?? 0) + 1, landed: false } })),
+ completeLanding: (token) =>
+ set((state) => state.landing?.token === token && !state.landing.landed
+ ? { landing: { ...state.landing, landed: true } }
+ : state),
heldRows: {},
holdRow: (wsId, list, row) =>
set((state) => {
diff --git a/packages/views/issues/components/issue-detail-route.tsx b/packages/views/issues/components/issue-detail-route.tsx
index 1ef963927d..0a5bd4ea4f 100644
--- a/packages/views/issues/components/issue-detail-route.tsx
+++ b/packages/views/issues/components/issue-detail-route.tsx
@@ -91,9 +91,12 @@ export function IssueDetailRoute({ routeId, onDelete, deliverable }: IssueDetail
canonicalId, issue, isResolving, notFound, loadFailed, isRetrying, retry, hasLoaded,
} = useCanonicalIssue(wsId, routeId);
const highlight = useHighlightHash();
- const landingToken = useInboxSelectionStore((s) =>
- s.landing && s.landing.issueId === canonicalId ? s.landing.token : 0,
+ const landing = useInboxSelectionStore((s) =>
+ s.landing && s.landing.issueId === canonicalId ? s.landing : null,
);
+ const completeLanding = useInboxSelectionStore((s) => s.completeLanding);
+ const landingToken = landing?.token ?? 0;
+ const onHighlightLanded = useCallback(() => completeLanding(landingToken), [completeLanding, landingToken]);
const paths = useWorkspacePaths();
const navigation = useNavigation();
@@ -138,6 +141,8 @@ export function IssueDetailRoute({ routeId, onDelete, deliverable }: IssueDetail
highlightCommentId={landsHere ? highlight.commentId : undefined}
highlightAppRequestId={landsHere ? highlight.appRequestId : undefined}
highlightRequestToken={landingToken}
+ highlightRequestPending={!!landing && !landing.landed}
+ onHighlightLanded={onHighlightLanded}
openDeliverable={deliverable}
onDeliverableLinkDone={deliverable ? onDeliverableLinkDone : undefined}
/>
diff --git a/packages/views/issues/components/issue-detail.test.tsx b/packages/views/issues/components/issue-detail.test.tsx
index bc545a37e7..24db9f0b51 100644
--- a/packages/views/issues/components/issue-detail.test.tsx
+++ b/packages/views/issues/components/issue-detail.test.tsx
@@ -501,7 +501,7 @@ const scrollIntoViewSpy = vi.hoisted(() => vi.fn());
const scrollToIndexSpy = vi.hoisted(() => vi.fn());
const scrollIntoViewIndexSpy = vi.hoisted(() => vi.fn());
const mockVirtualWindow = vi.hoisted(() => ({
- enabled: false, delayedViewport: false, lateScrollReset: false, offscreenViewport: false, pendingSizeCorrection: false, holdAtIndex: false,
+ enabled: false, delayedViewport: false, lateScrollReset: false, offscreenViewport: false, contentSettlesAbove: false, pendingSizeCorrection: false, holdAtIndex: false,
targetId: "", targetHeight: 100, scrollParent: null as HTMLElement | null,
}));
@@ -532,8 +532,14 @@ vi.mock("react-virtuoso", () => ({
if (mockVirtualWindow.offscreenViewport && customScrollParent) {
const list = document.querySelector('[data-testid="virtuoso-mock"]')?.parentElement;
if (list) list.getBoundingClientRect = () => new DOMRect(0, 1000 - customScrollParent.scrollTop, 400, 100);
+ // Content above the list can still grow once after the first reveal
+ // and push the list back out of view before it measures.
+ let settled = !mockVirtualWindow.contentSettlesAbove;
const timer = window.setInterval(() => {
- if (customScrollParent.scrollTop > 0) { window.clearInterval(timer); measured(); }
+ if (customScrollParent.scrollTop <= 0) return;
+ if (!settled) { settled = true; customScrollParent.scrollTop = 0; return; }
+ window.clearInterval(timer);
+ measured();
}, 10);
return () => window.clearInterval(timer);
}
@@ -593,6 +599,7 @@ beforeEach(() => {
mockVirtualWindow.holdAtIndex = false;
mockVirtualWindow.delayedViewport = false;
mockVirtualWindow.offscreenViewport = false;
+ mockVirtualWindow.contentSettlesAbove = false;
mockVirtualWindow.lateScrollReset = false;
mockVirtualWindow.targetId = "";
mockVirtualWindow.targetHeight = 100;
@@ -711,6 +718,7 @@ const mockTimeline: TimelineEntry[] = [
// ---------------------------------------------------------------------------
import { IssueDetail, groupSubIssuesByStage } from "./issue-detail";
+import { ScrollRestorationProvider, type ScrollRestorationAdapter } from "../../platform";
import { READING_COLUMN } from "../../layout/reading-column";
import {
IssueSurfaceSelectionProvider,
@@ -2895,14 +2903,16 @@ describe("IssueDetail (shared)", () => {
{ kind: "root", delayedViewport: true, lateScrollReset: false },
{ kind: "reply", delayedViewport: false, lateScrollReset: true },
{ kind: "reply", delayedViewport: false, lateScrollReset: false, offscreenViewport: true },
+ { kind: "reply", delayedViewport: false, lateScrollReset: false, offscreenViewport: true, contentSettlesAbove: true },
{ kind: "reply", delayedViewport: false, lateScrollReset: false, pendingSizeCorrection: true },
{ kind: "reply", delayedViewport: false, lateScrollReset: false, holdAtIndex: true },
- ])("keeps long history virtualized for a $kind (late viewport: $delayedViewport, late scroll: $lateScrollReset, below fold: $offscreenViewport)", async ({ kind, delayedViewport, lateScrollReset, offscreenViewport, pendingSizeCorrection, holdAtIndex }) => {
+ ])("keeps long history virtualized for a $kind (late viewport: $delayedViewport, late scroll: $lateScrollReset, below fold: $offscreenViewport, settling above: $contentSettlesAbove)", async ({ kind, delayedViewport, lateScrollReset, offscreenViewport, contentSettlesAbove, pendingSizeCorrection, holdAtIndex }) => {
mockVirtualWindow.holdAtIndex = !!holdAtIndex;
mockVirtualWindow.pendingSizeCorrection = !!pendingSizeCorrection;
mockVirtualWindow.enabled = true;
mockVirtualWindow.delayedViewport = delayedViewport;
mockVirtualWindow.offscreenViewport = !!offscreenViewport;
+ mockVirtualWindow.contentSettlesAbove = !!contentSettlesAbove;
mockVirtualWindow.lateScrollReset = lateScrollReset;
const history = Array.from({ length: 120 }, (_, index) => ({
...mockTimeline[0]!,
@@ -2949,6 +2959,46 @@ describe("IssueDetail (shared)", () => {
expect(landedBeforeGrouping).toBe(false);
});
+ describe("on a route that already recorded the landing", () => {
+ function renderOverLandedRoute(props: Partial<React.ComponentProps<typeof IssueDetail>> = {}) {
+ mockApiObj.listTasksByIssue.mockResolvedValue([]);
+ const viewState = new Map([["highlight:issue-1", "comment-2"]]);
+ const adapter: ScrollRestorationAdapter = {
+ get: () => undefined,
+ getViewState: (key) => viewState.get(key),
+ setViewState: (key, value) => {
+ if (value === undefined) viewState.delete(key);
+ else viewState.set(key, value);
+ },
+ };
+ render(
+ <I18nProvider locale="en" resources={TEST_RESOURCES}>
+ <QueryClientProvider client={createTestQueryClient()}>
+ <ScrollRestorationProvider adapter={adapter}>
+ <IssueDetail issueId="issue-1" highlightCommentId="comment-2" {...props} />
+ </ScrollRestorationProvider>
+ </QueryClientProvider>
+ </I18nProvider>,
+ );
+ }
+
+ it("does not replay it when the view merely remounts", async () => {
+ renderOverLandedRoute();
+ await waitFor(() => expect(document.getElementById("comment-comment-2")).not.toBeNull());
+ await act(async () => { await new Promise((resolve) => window.setTimeout(resolve, 100)); });
+ expect(hasHighlightedCommentBackground(document.getElementById("comment-comment-2"))).toBe(false);
+ });
+
+ // MUL-9492: a Work panel click on another page cannot clear the issue
+ // route's record before it navigates there.
+ it("lands a pending request anyway and reports it", async () => {
+ const onHighlightLanded = vi.fn();
+ renderOverLandedRoute({ highlightRequestToken: 3, highlightRequestPending: true, onHighlightLanded });
+ await waitFor(() => expect(hasHighlightedCommentBackground(document.getElementById("comment-comment-2"))).toBe(true));
+ expect(onHighlightLanded).toHaveBeenCalledTimes(1);
+ });
+ });
+
it("restarts a comment landing that a timeline update cancels while it is still aligning", async () => {
mockApiObj.listTasksByIssue.mockResolvedValue([]);
// The anchor keeps moving for 300ms, like reply heights settling, so the
diff --git a/packages/views/issues/components/issue-detail.tsx b/packages/views/issues/components/issue-detail.tsx
index bba03b2761..a930c6f81f 100644
--- a/packages/views/issues/components/issue-detail.tsx
+++ b/packages/views/issues/components/issue-detail.tsx
@@ -213,7 +213,7 @@ import { IssueSidebarSections, letSidebarSettingsDragKeysThrough } from "./issue
import { useT } from "../../i18n";
import { useIssueDetailScrollRestore } from "../hooks/use-issue-detail-scroll-restore";
import { useIssueTimelineAnchor } from "../hooks/use-issue-timeline-anchor";
-import { scrollToTimelineComment } from "../utils/scroll-to-timeline-comment";
+import { revealTimelineList, scrollToTimelineComment } from "../utils/scroll-to-timeline-comment";
import { buildTimelineFindUnits, type TimelineFindUnit } from "../utils/timeline-find-units";
import { useJumpToLatest } from "../hooks/use-jump-to-latest";
import { useNewCommentsWhileAway } from "../hooks/use-new-comments-while-away";
@@ -233,7 +233,8 @@ import {
* issue already landed on the current route (value: the consumed comment
* id). Lets a remount that merely restores the view (tab switch back) skip
* the jump-and-highlight, while a fresh selection — which clears the entry
- * (see InboxPage.handleSelect) — runs it again.
+ * (see InboxPage.handleSelect) — or a pending landing request (a Work panel
+ * notification click) runs it again.
*/
export function issueHighlightMementoKey(issueId: string): string {
return `highlight:${issueId}`;
@@ -1246,6 +1247,13 @@ interface IssueDetailProps {
* forces the render that re-reads the cleared memento entry.
*/
highlightRequestToken?: number;
+ /**
+ * The host asked for this landing and has not seen it land (a notification
+ * clicked on another page). It runs even where this route records the
+ * comment as already landed; `onHighlightLanded` reports when it did.
+ */
+ highlightRequestPending?: boolean;
+ onHighlightLanded?: () => void;
/** The app confirmation an Inbox notification points at; its card scrolls
* into view and flashes, replayed by `highlightRequestToken`. */
highlightAppRequestId?: string;
@@ -1486,7 +1494,7 @@ export function IssueDetailSkeleton({
// IssueDetail
-export function IssueDetail({ issueId, onDelete, onDone, onUnsubscribeArchive, defaultSidebarOpen = true, layoutId = ISSUE_DETAIL_LAYOUT_ID, highlightCommentId: linkedCommentId, highlightRequestToken: linkedRequestToken, highlightAppRequestId, leadingAction, variant = "page", trailingActions, notice, readsInbox = true, skipInitialRefetch = false, openDeliverable, onDeliverableLinkDone }: IssueDetailProps) {
+export function IssueDetail({ issueId, onDelete, onDone, onUnsubscribeArchive, defaultSidebarOpen = true, layoutId = ISSUE_DETAIL_LAYOUT_ID, highlightCommentId: linkedCommentId, highlightRequestToken: linkedRequestToken, highlightRequestPending = false, onHighlightLanded, highlightAppRequestId, leadingAction, variant = "page", trailingActions, notice, readsInbox = true, skipInitialRefetch = false, openDeliverable, onDeliverableLinkDone }: IssueDetailProps) {
const isPeek = variant === "peek";
const { t } = useT("issues");
const { t: tCommon } = useT("common");
@@ -1627,9 +1635,15 @@ export function IssueDetail({ issueId, onDelete, onDone, onUnsubscribeArchive, d
// landing already re-runs the effect through another dependency (mount,
// items arriving, token bump), and the render that precedes it refreshes
// this ref.
+ //
+ // A pending request ignores the entry: the host has not seen it land.
const consumedHighlightId = useRestoredViewState(issueHighlightMementoKey(id));
- const consumedHighlightRef = useRef(consumedHighlightId);
- consumedHighlightRef.current = consumedHighlightId;
+ const highlightConsumed =
+ !!highlightCommentId && !highlightRequestPending && consumedHighlightId === highlightCommentId;
+ const highlightConsumedRef = useRef(highlightConsumed);
+ highlightConsumedRef.current = highlightConsumed;
+ const onHighlightLandedRef = useRef(onHighlightLanded);
+ onHighlightLandedRef.current = onHighlightLanded;
const writeViewState = useViewStateWriter();
const rightSidebarShortcutTargetRef = useRef<HTMLDivElement | null>(null);
const attachScrollContainer = useCallback(
@@ -2139,8 +2153,7 @@ export function IssueDetail({ issueId, onDelete, onDone, onUnsubscribeArchive, d
// to land on, so the issue opens where the reader left off instead of at
// the top. If it arrives later, the landing still runs.
const highlightMissing = timelineReady && targetIdx < 0;
- const pendingHighlight =
- !!highlightCommentId && consumedHighlightId !== highlightCommentId && !highlightMissing;
+ const pendingHighlight = !!highlightCommentId && !highlightConsumed && !highlightMissing;
const { pending: readingAnchor, complete: completeAnchorRestore } = useIssueTimelineAnchor({
containerKey: scrollContainerKey,
container: scrollContainerEl,
@@ -2158,8 +2171,7 @@ export function IssueDetail({ issueId, onDelete, onDone, onUnsubscribeArchive, d
if (index < 0) { completeAnchorRestore(); return; }
if (measuredTimelineId !== id) {
const list = virtualTimelineRef.current;
- if (list) container.scrollTop += list.getBoundingClientRect().top - container.getBoundingClientRect().top;
- return;
+ return list ? revealTimelineList(container, list) : undefined;
}
return scrollToTimelineComment({
container, virtualizer: virtuosoRef.current, index,
@@ -2576,7 +2588,7 @@ export function IssueDetail({ issueId, onDelete, onDone, onUnsubscribeArchive, d
// switch back or an in-tab return). The restored scroll offset is the
// state the user left, and the jump must not fight it. A fresh selection
// clears the entry, so this only ever suppresses a *repeat* landing.
- if (!resuming && !activeDeliverableJump && consumedHighlightRef.current === highlightCommentId) {
+ if (!resuming && !activeDeliverableJump && highlightConsumedRef.current) {
didHighlightRef.current = highlightCommentId;
return;
}
@@ -2620,11 +2632,9 @@ export function IssueDetail({ issueId, onDelete, onDone, onUnsubscribeArchive, d
if (!container) return;
if (targetIdx < 0) return;
if (measuredTimelineId !== id) {
- // A long description can put the whole list below the scroll viewport.
- // Bring its probe row into view so Virtuoso can measure before jumping.
+ // Virtuoso measures nothing while the list is below the viewport.
const list = virtualTimelineRef.current;
- if (list) container.scrollTop += list.getBoundingClientRect().top - container.getBoundingClientRect().top;
- return;
+ return list ? revealTimelineList(container, list) : undefined;
}
interruptedLandingRef.current = null;
@@ -2635,6 +2645,7 @@ export function IssueDetail({ issueId, onDelete, onDone, onUnsubscribeArchive, d
onMounted: () => {
didHighlightRef.current = highlightCommentId;
writeViewState(issueHighlightMementoKey(id), highlightCommentId);
+ onHighlightLandedRef.current?.();
// Timer owned outside this effect, so a re-run cannot leave the
// highlight on.
flashJumpTarget(landingId, 2500);
diff --git a/packages/views/issues/utils/scroll-to-timeline-comment.test.ts b/packages/views/issues/utils/scroll-to-timeline-comment.test.ts
index d5ed57de1b..ad36ef6c81 100644
--- a/packages/views/issues/utils/scroll-to-timeline-comment.test.ts
+++ b/packages/views/issues/utils/scroll-to-timeline-comment.test.ts
@@ -1,5 +1,5 @@
import { afterEach, describe, expect, it, vi } from "vitest";
-import { scrollToTimelineComment } from "./scroll-to-timeline-comment";
+import { revealTimelineList, scrollToTimelineComment } from "./scroll-to-timeline-comment";
const frame = () => new Promise((resolve) => requestAnimationFrame(resolve));
@@ -38,3 +38,39 @@ describe("scrollToTimelineComment", () => {
expect(container.scrollTop).toBe(4750);
});
});
+
+describe("revealTimelineList", () => {
+ afterEach(() => { vi.unstubAllGlobals(); });
+
+ it("keeps one frame budget per list across the effect re-runs that restart it", () => {
+ const pending = new Map<number, FrameRequestCallback>();
+ let nextId = 0;
+ vi.stubGlobal("requestAnimationFrame", (cb: FrameRequestCallback) => { pending.set(++nextId, cb); return nextId; });
+ vi.stubGlobal("cancelAnimationFrame", (id: number) => { pending.delete(id); });
+ const runFrames = (count: number) => {
+ for (let i = 0; i < count && pending.size; i++) {
+ const [id, cb] = pending.entries().next().value!;
+ pending.delete(id);
+ cb(0);
+ }
+ };
+ let writes = 0;
+ const container = { getBoundingClientRect: () => new DOMRect(0, 0, 400, 600) } as HTMLElement;
+ Object.defineProperty(container, "scrollTop", { get: () => 0, set: () => { writes++; } });
+ // Content above keeps the list below the viewport, so the reveal never ends on its own.
+ const list = { getBoundingClientRect: () => new DOMRect(0, 2000, 400, 100) } as HTMLElement;
+
+ let cancel = revealTimelineList(container, list);
+ runFrames(50);
+ for (let restart = 0; restart < 20; restart++) {
+ cancel();
+ cancel = revealTimelineList(container, list);
+ runFrames(10);
+ }
+ runFrames(500);
+ cancel();
+
+ expect(writes).toBe(120);
+ expect(pending.size).toBe(0);
+ });
+});
diff --git a/packages/views/issues/utils/scroll-to-timeline-comment.ts b/packages/views/issues/utils/scroll-to-timeline-comment.ts
index a7a9be7a00..495f1de9c9 100644
--- a/packages/views/issues/utils/scroll-to-timeline-comment.ts
+++ b/packages/views/issues/utils/scroll-to-timeline-comment.ts
@@ -1,5 +1,39 @@
import type { VirtuosoHandle } from "react-virtuoso";
+/** About two seconds of frames: content above the list settles well within it. */
+const REVEAL_LIST_MAX_FRAMES = 120;
+
+/**
+ * Frames each list has left. The budget belongs to the list, not to one call:
+ * every commit that re-runs the caller's effect (a realtime comment, a
+ * timeline refresh) restarts the reveal, and must not restart its limit.
+ */
+const revealFramesLeft = new WeakMap<HTMLElement, number>();
+
+/**
+ * Hold the virtualized timeline's top at the top of the viewport until the
+ * caller sees the list report a measured height and cancels.
+ *
+ * A long description can put the whole list below the viewport, where
+ * Virtuoso renders nothing and never measures, and a landing waits on that
+ * measurement. One write is not enough: content above the list can still
+ * change height right after it (an editor filling in, a page mounting twice
+ * while its address is canonicalized), which leaves the list out of range
+ * again and the reader parked in the description.
+ */
+export function revealTimelineList(container: HTMLElement, list: HTMLElement) {
+ let rafId = 0;
+ const reveal = () => {
+ const left = revealFramesLeft.get(list) ?? REVEAL_LIST_MAX_FRAMES;
+ if (left <= 0) return;
+ revealFramesLeft.set(list, left - 1);
+ container.scrollTop += list.getBoundingClientRect().top - container.getBoundingClientRect().top;
+ rafId = requestAnimationFrame(reveal);
+ };
+ reveal();
+ return () => cancelAnimationFrame(rafId);
+}
+
/** Reveal a nested anchor before aligning it against measured reply content. */
export function scrollToTimelineComment({
container, virtualizer, index, commentId, offset, onMounted, onComplete,
diff --git a/packages/views/layout/panels/inbox-section.test.tsx b/packages/views/layout/panels/inbox-section.test.tsx
index bfdd138dc7..0cb4f67760 100644
--- a/packages/views/layout/panels/inbox-section.test.tsx
+++ b/packages/views/layout/panels/inbox-section.test.tsx
@@ -257,7 +257,7 @@ describe("InboxSection", () => {
fireEvent.click(screen.getByRole("link", { name: /^Commented/ }));
expect(first?.issueId).toBe("issue-a");
- expect(useInboxSelectionStore.getState().landing).toEqual({ issueId: "issue-a", token: first!.token + 1 });
+ expect(useInboxSelectionStore.getState().landing).toEqual({ issueId: "issue-a", token: first!.token + 1, landed: false });
});
it("lists under the Inbox filters, keeping the open row once reading it", () => {
diff --git a/packages/views/layout/panels/inbox-section.tsx b/packages/views/layout/panels/inbox-section.tsx
index b5d69477b8..d8004ff3cb 100644
--- a/packages/views/layout/panels/inbox-section.tsx
+++ b/packages/views/layout/panels/inbox-section.tsx
@@ -38,8 +38,6 @@ import { useWorkspacePaths } from "@multica/core/paths";
import type { InboxItem } from "@multica/core/types";
import { useActorName } from "@multica/core/workspace/hooks";
import { AppLink, useNavigation } from "../../navigation";
-import { useViewStateWriter } from "../../platform";
-import { issueHighlightMementoKey } from "../../issues/components/issue-detail";
import { useT } from "../../i18n";
import { INBOX_TYPE_ICONS } from "../../inbox/components/inbox-filter-options";
import { getInboxDisplayTitle, inboxRowHref, isAutopilotQuotaNotice } from "../../inbox/components/inbox-display";
@@ -457,14 +455,11 @@ function InboxRow({
const statusLabelOf = useStatusLabel(item.workspace_id);
const status = item.issue_status;
const title = inboxRowTitle(item, typeLabels);
- const writeViewState = useViewStateWriter();
const requestLanding = useInboxSelectionStore((s) => s.requestLanding);
// Every click is a fresh intent to land on what the notification is about,
// even on the issue already open, or one whose landing ran before.
const land = () => {
- if (!item.issue_id) return;
- writeViewState(issueHighlightMementoKey(item.issue_id), undefined);
- requestLanding(item.issue_id);
+ if (item.issue_id) 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