:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(desktop): let the artifact version pager step off a commented version (#83386)
Peter Kirkham42d5edca6dc4
diff --git a/products/desktop/packages/ui/src/features/sessions/commentNavigationStore.ts b/products/desktop/packages/ui/src/features/sessions/commentNavigationStore.tsindex fba321bdbe3d..493376033a3b 100644--- a/products/desktop/packages/ui/src/features/sessions/commentNavigationStore.ts+++ b/products/desktop/packages/ui/src/features/sessions/commentNavigationStore.ts@@ -11,7 +11,10 @@ type CommentFocusIntent = "navigate" | "reveal-thread" | "focus-only";type CommentFocus = {target: CommentTarget;threadId: string;- /** Bumped on every request so re-picking the same thread scrolls again. */+ /** Bumped on every request so re-picking the same thread scrolls again.+ * A consumer that acts on focus takes each nonce once, and takes it only+ * once it can act — returning without taking leaves the request to apply+ * when the consumer is ready. */nonce: number;openCommentsTab: boolean;intent: CommentFocusIntent;diff --git a/products/desktop/packages/ui/src/features/sessions/components/ArtifactPreview.test.tsx b/products/desktop/packages/ui/src/features/sessions/components/ArtifactPreview.test.tsxindex 67da922c69ec..923ac6998332 100644--- a/products/desktop/packages/ui/src/features/sessions/components/ArtifactPreview.test.tsx+++ b/products/desktop/packages/ui/src/features/sessions/components/ArtifactPreview.test.tsx@@ -1119,6 +1119,11 @@ describe("ArtifactPreview", () => {expect(screen.getByText("v2/2")).toBeInTheDocument();lastCall = useQuery.mock.calls.at(-1)?.[0] as { queryKey: unknown[] };expect(lastCall.queryKey).toContain("artifact-1");++ // A focus request that already landed must not keep pulling the pager back.+ fireEvent.click(screen.getByRole("button", { name: "Older version" }));++ expect(screen.getByText("v1/2")).toBeInTheDocument();});it("saves edited source as a new output version under the same name", async () => {diff --git a/products/desktop/packages/ui/src/features/sessions/components/ArtifactPreview.tsx b/products/desktop/packages/ui/src/features/sessions/components/ArtifactPreview.tsxindex 7fdbb225a3e0..01b9a6ad427d 100644--- a/products/desktop/packages/ui/src/features/sessions/components/ArtifactPreview.tsx+++ b/products/desktop/packages/ui/src/features/sessions/components/ArtifactPreview.tsx@@ -167,17 +167,21 @@ export function ArtifactPreview({(state) => state.setCommentResolutions,);const focus = useCommentNavigationStore((state) => state.focusByTask[taskId]);+ // Take each request once: focus is durable, so otherwise stepping the pager+ // off a commented version snaps straight back to it.+ const takenNonce = useRef<number | null>(null);useEffect(() => {if (!focus ||focus.target.scope !== "task_artifact" ||- focus.target.itemId === activeArtifactId ||+ takenNonce.current === focus.nonce ||!versions.some((version) => version.id === focus.target.itemId)) {return;}+ takenNonce.current = focus.nonce;setSelectedVersionId(focus.target.itemId);- }, [activeArtifactId, focus, versions]);+ }, [focus, versions]);const editing = useArtifactEditing({sessionService,artifactResult,