Skip to content

: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.

fix(desktop): clear stale PR status on task switch (#80376)

Alessandro Pogliaghi664f807b49f5
diff --git a/products/desktop/packages/ui/src/features/sidebar/useTaskPrStatus.test.ts b/products/desktop/packages/ui/src/features/sidebar/useTaskPrStatus.test.ts
index 0e16f9904a40..8d1f5480ddf4 100644
--- a/products/desktop/packages/ui/src/features/sidebar/useTaskPrStatus.test.ts
+++ b/products/desktop/packages/ui/src/features/sidebar/useTaskPrStatus.test.ts
@@ -108,4 +108,14 @@ describe("useTaskPrStatus", () => {
);
expect(lastQueryOptions?.enabled).toBe(true);
});
+
+ it("ignores placeholder data when the query is disabled", () => {
+ queryData = { prState: "open", hasDiff: true };
+ const { result } = renderHook(() =>
+ useTaskPrStatus(
+ makeTask({ taskRunEnvironment: "cloud", cloudPrUrl: null }),
+ ),
+ );
+ expect(result.current).toEqual({ prState: null, hasDiff: false });
+ });
});
diff --git a/products/desktop/packages/ui/src/features/sidebar/useTaskPrStatus.ts b/products/desktop/packages/ui/src/features/sidebar/useTaskPrStatus.ts
index d0db43aa62fe..deb83767e62d 100644
--- a/products/desktop/packages/ui/src/features/sidebar/useTaskPrStatus.ts
+++ b/products/desktop/packages/ui/src/features/sidebar/useTaskPrStatus.ts
@@ -35,6 +35,8 @@ export function useTaskPrStatus(task: {
),
);
- if (!data || (!data.prState && !data.hasDiff)) return EMPTY;
+ // A disabled query can retain placeholder data from the previously selected
+ // task. Ignore it so a cloud task without a PR never shows stale PR status.
+ if (skipQuery || !data || (!data.prState && !data.hasDiff)) return EMPTY;
return data;
}