Skip to content

Commit 2a04a5b

Browse files
fix(web): re-clicking an open PR link pulses the side panel
Opening a pull request that is already focused looked like a no-op. Bump an attention request and flash the panel so the click is obvious. Co-authored-by: Cursor <[email protected]>
1 parent 240446e commit 2a04a5b

4 files changed

Lines changed: 109 additions & 19 deletions

File tree

‎apps/web/src/components/RightPanelTabs.tsx‎

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1024,6 +1024,43 @@ function RightPanelTab(
10241024

10251025
export function RightPanelTabs(props: RightPanelTabsProps) {
10261026
const focusedSurface = props.surfaces.find((surface) => surface.id === props.activeSurfaceId);
1027+
const focusedPullRequestAttention =
1028+
focusedSurface?.kind === "pull-request"
1029+
? { id: focusedSurface.id, requestId: focusedSurface.attentionRequestId ?? 0 }
1030+
: null;
1031+
// Same PR still focused with a bumped request id: the link did something; pulse the panel.
1032+
const [pullRequestAttentionPulse, setPullRequestAttentionPulse] = useState({
1033+
surfaceId: null as string | null,
1034+
requestId: 0,
1035+
key: 0,
1036+
});
1037+
if (focusedPullRequestAttention) {
1038+
if (
1039+
pullRequestAttentionPulse.surfaceId === focusedPullRequestAttention.id &&
1040+
pullRequestAttentionPulse.requestId !== focusedPullRequestAttention.requestId
1041+
) {
1042+
setPullRequestAttentionPulse({
1043+
surfaceId: focusedPullRequestAttention.id,
1044+
requestId: focusedPullRequestAttention.requestId,
1045+
key: pullRequestAttentionPulse.key + 1,
1046+
});
1047+
} else if (
1048+
pullRequestAttentionPulse.surfaceId !== focusedPullRequestAttention.id ||
1049+
pullRequestAttentionPulse.requestId !== focusedPullRequestAttention.requestId
1050+
) {
1051+
setPullRequestAttentionPulse({
1052+
surfaceId: focusedPullRequestAttention.id,
1053+
requestId: focusedPullRequestAttention.requestId,
1054+
key: pullRequestAttentionPulse.key,
1055+
});
1056+
}
1057+
} else if (pullRequestAttentionPulse.surfaceId !== null) {
1058+
setPullRequestAttentionPulse({
1059+
surfaceId: null,
1060+
requestId: 0,
1061+
key: pullRequestAttentionPulse.key,
1062+
});
1063+
}
10271064
const ownsDesktopTitleBar = isElectron && props.mode === "inline";
10281065
const browserProfiles = useBrowserDefaults().profiles;
10291066
const { resolvedTheme } = useTheme();
@@ -1521,7 +1558,14 @@ export function RightPanelTabs(props: RightPanelTabsProps) {
15211558
/>
15221559
) : null}
15231560
</div>
1524-
<div className="flex min-h-0 flex-1 flex-col" data-right-panel-surface-content>
1561+
<div className="relative flex min-h-0 flex-1 flex-col" data-right-panel-surface-content>
1562+
{pullRequestAttentionPulse.key > 0 ? (
1563+
<div
1564+
key={pullRequestAttentionPulse.key}
1565+
aria-hidden
1566+
className="pointer-events-none absolute inset-0 z-20 motion-safe:animate-right-panel-attention-pulse"
1567+
/>
1568+
) : null}
15251569
{props.activeSurfaceId === null ? (
15261570
<RightPanelEmptyState
15271571
onAddBrowser={props.onAddBrowser}

‎apps/web/src/index.css‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ html[data-mobile-composer-route-transition="true"]::view-transition-old(t3-mobil
230230
--animate-stash-pulse-row: stash-pulse-row 1400ms;
231231
--animate-stash-pulse-row-alt: stash-pulse-row-alt 1400ms;
232232
--animate-stash-pulse-count: stash-pulse-count 1400ms step-start;
233+
--animate-right-panel-attention-pulse: right-panel-attention-pulse 650ms ease-in-out 2;
233234
--color-warning-foreground: var(--warning-foreground);
234235
--color-warning: var(--warning);
235236
--color-warning-surface: var(--warning-surface);
@@ -329,6 +330,15 @@ html[data-mobile-composer-route-transition="true"]::view-transition-old(t3-mobil
329330
color: var(--color-primary);
330331
}
331332
}
333+
@keyframes right-panel-attention-pulse {
334+
0%,
335+
100% {
336+
box-shadow: inset 0 0 0 0 transparent;
337+
}
338+
50% {
339+
box-shadow: inset 0 0 0 2px color-mix(in oklab, var(--color-primary) 70%, transparent);
340+
}
341+
}
332342
@keyframes status-pulse {
333343
0%,
334344
40% {

‎apps/web/src/rightPanelStore.test.ts‎

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -359,9 +359,10 @@ describe("rightPanelStore", () => {
359359
const revision = store.getUserActionRevision(refA);
360360

361361
expect(store.openProactive(refA, relinkedPullRequest, revision, true)).toBe(true);
362-
expect(selectActiveRightPanelSurface(useRightPanelStore.getState().byThreadKey, refA)).toEqual(
363-
relinkedPullRequest,
364-
);
362+
expect(selectActiveRightPanelSurface(useRightPanelStore.getState().byThreadKey, refA)).toEqual({
363+
...relinkedPullRequest,
364+
attentionRequestId: 1,
365+
});
365366

366367
store.close(refA);
367368
expect(store.openProactive(refA, linkedPullRequest, revision, true)).toBe(false);
@@ -609,6 +610,7 @@ describe("rightPanelStore", () => {
609610
projectId: "project-a",
610611
repository: "pingdotgg/t3code",
611612
number: 4909,
613+
attentionRequestId: 0,
612614
},
613615
],
614616
},
@@ -633,6 +635,7 @@ describe("rightPanelStore", () => {
633635
projectId: "project-a",
634636
repository: "pingdotgg/t3code",
635637
number: 4909,
638+
attentionRequestId: 0,
636639
},
637640
],
638641
};
@@ -1007,10 +1010,24 @@ describe("rightPanelStore", () => {
10071010
expect(state.activeSurfaceId).toBe(pullRequestSurfaceId(first));
10081011
expect(
10091012
selectActiveRightPanelSurface(useRightPanelStore.getState().byThreadKey, refA),
1010-
).toMatchObject({ url });
1013+
).toMatchObject({ url, attentionRequestId: 3 });
1014+
expect(state.surfaces[1]).toMatchObject({ attentionRequestId: 1 });
10111015
expect(state.surfaces[1]).not.toHaveProperty("url");
10121016
});
10131017

1018+
it("bumps attention when reopening the pull request already in the panel", () => {
1019+
const pr = { projectId: "project-a", repository: "pingdotgg/t3code", number: 4909 };
1020+
useRightPanelStore.getState().openPullRequest(refA, pr);
1021+
expect(
1022+
selectActiveRightPanelSurface(useRightPanelStore.getState().byThreadKey, refA),
1023+
).toMatchObject({ attentionRequestId: 1 });
1024+
1025+
useRightPanelStore.getState().openPullRequest(refA, pr);
1026+
expect(
1027+
selectActiveRightPanelSurface(useRightPanelStore.getState().byThreadKey, refA),
1028+
).toMatchObject({ attentionRequestId: 2 });
1029+
});
1030+
10141031
it("restores each environment, thread and PR surface's detail tab after reload and URL reopen", async () => {
10151032
const pr = { projectId: "project-a", repository: "pingdotgg/t3code", number: 4909 };
10161033
const otherPr = { ...pr, projectId: "project-b" };
@@ -1073,7 +1090,10 @@ describe("rightPanelStore", () => {
10731090
useRightPanelStore.getState().openPullRequest(refA, first);
10741091
useRightPanelStore.getState().openPullRequest(refA, second);
10751092
const state = selectThreadRightPanelState(useRightPanelStore.getState().byThreadKey, refA);
1076-
expect(state.surfaces).toEqual([pullRequestSurface(first), pullRequestSurface(second)]);
1093+
expect(state.surfaces).toEqual([
1094+
pullRequestSurface({ ...first, attentionRequestId: 1 }),
1095+
pullRequestSurface({ ...second, attentionRequestId: 1 }),
1096+
]);
10771097
expect(pullRequestSurfaceId({ ...first, host: "GITHUB.COM" })).toBe(
10781098
pullRequestSurfaceId(first),
10791099
);

‎apps/web/src/rightPanelStore.ts‎

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,14 @@ export type RightPanelSurface =
7474
number: number;
7575
url?: string;
7676
detailTab?: PullRequestDetailTab;
77+
/** Bumped on each open so a re-click can pulse the already-visible panel. */
78+
attentionRequestId: number;
7779
}
7880
| { id: "pull-requests"; kind: "pull-requests" }
7981
| { id: `side-chat:${string}`; kind: "side-chat"; threadId: ThreadId };
8082

8183
const RIGHT_PANEL_STORAGE_KEY = "t3code:right-panel-state:v2";
82-
const RIGHT_PANEL_STORAGE_VERSION = 14;
84+
const RIGHT_PANEL_STORAGE_VERSION = 15;
8385

8486
export const PULL_REQUESTS_PANEL_REF = scopeThreadRef(
8587
EnvironmentId.make("pull-requests-panel"),
@@ -279,6 +281,7 @@ export function pullRequestSurface(target: {
279281
number: number;
280282
url?: string;
281283
detailTab?: PullRequestDetailTab;
284+
attentionRequestId?: number;
282285
}): PullRequestSurface {
283286
return {
284287
id: pullRequestSurfaceId(target),
@@ -290,6 +293,12 @@ export function pullRequestSurface(target: {
290293
number: target.number,
291294
...(typeof target.url === "string" ? { url: target.url } : {}),
292295
...(target.detailTab === undefined ? {} : { detailTab: target.detailTab }),
296+
attentionRequestId:
297+
typeof target.attentionRequestId === "number" &&
298+
Number.isSafeInteger(target.attentionRequestId) &&
299+
target.attentionRequestId >= 0
300+
? target.attentionRequestId
301+
: 0,
293302
};
294303
}
295304

@@ -522,11 +531,12 @@ export function migratePersistedRightPanelState(persistedState: unknown): {
522531
) {
523532
return [];
524533
}
525-
const { environmentId, ...rest } = surface;
534+
const { environmentId, attentionRequestId, ...rest } = surface;
526535
return [
527536
pullRequestSurface({
528537
...rest,
529538
...(typeof environmentId === "string" ? { environmentId } : {}),
539+
...(typeof attentionRequestId === "number" ? { attentionRequestId } : {}),
530540
}),
531541
];
532542
}
@@ -750,18 +760,24 @@ export const useRightPanelStore = create<RightPanelStoreState>()(
750760
openPullRequest: (ref, target) =>
751761
set((state) =>
752762
userAction(state, scopedThreadKey(ref), (current) => {
753-
const surface = pullRequestSurface(target);
763+
const surfaceId = pullRequestSurfaceId(target);
764+
const existing = current.surfaces.find(
765+
(entry): entry is PullRequestSurface =>
766+
entry.kind === "pull-request" && entry.id === surfaceId,
767+
);
768+
const surface = pullRequestSurface({
769+
...target,
770+
attentionRequestId: (existing?.attentionRequestId ?? 0) + 1,
771+
});
754772
const next = upsertSurface(current, surface);
755-
return target.url
756-
? {
757-
...next,
758-
surfaces: next.surfaces.map((entry) =>
759-
entry.id === surface.id && entry.kind === "pull-request"
760-
? { ...entry, ...surface }
761-
: entry,
762-
),
763-
}
764-
: next;
773+
return {
774+
...next,
775+
surfaces: next.surfaces.map((entry) =>
776+
entry.id === surface.id && entry.kind === "pull-request"
777+
? { ...entry, ...surface }
778+
: entry,
779+
),
780+
};
765781
}),
766782
),
767783
setPullRequestDetailTab: (ref, surfaceId, detailTab) =>

0 commit comments

Comments
 (0)