fix(web): open proactive panels when entering threads (#10610)

Co-authored-by: maria-rcks <[email protected]>
This commit is contained in:
mariaandmaria-rcks authored and GitHub committed 2026-09-07 22:40:40 -03:00
1 parent 299404a754
commit 8588d7f63b
4 files changed
+19 -12

No files matched your search

+10 -6
View File
@@ -190,7 +190,7 @@ describe("proactive panels", () => {
expect(selectActiveRightPanelSurface(useRightPanelStore.getState().byThreadKey, ref)).toEqual(
oldPr,
);
expect(shouldOpenProactivePullRequest(loaded.targetKey, "owner/repo:2")).toBe(false);
expect(shouldOpenProactivePullRequest(loaded.targetKey, "owner/repo:2")).toBe(true);
expect(
shouldOpenProactiveTurnDiff({
previousRunningTurnId: loaded.runningTurnId,
@@ -198,7 +198,10 @@ describe("proactive panels", () => {
settledTurnId: turnId,
turnCompleted: true,
}),
).toBe(false);
).toBe(true);
expect(panels.openProactive(ref, { id: "diff", kind: "diff" }, loaded.userActionRevision)).toBe(
false,
);
});
it.each(["idle", "loading", "observed"] as const)(
@@ -245,8 +248,9 @@ describe("proactive panels", () => {
},
);
it("opens a pull request only after a newly observed link appears", () => {
expect(shouldOpenProactivePullRequest(undefined, "project:repo:42")).toBe(false);
it("opens an existing pull request on entry and follows newly observed links", () => {
expect(shouldOpenProactivePullRequest(undefined, "project:repo:42")).toBe(true);
expect(shouldOpenProactivePullRequest(undefined, null)).toBe(false);
expect(shouldOpenProactivePullRequest(null, "project:repo:42")).toBe(true);
expect(shouldOpenProactivePullRequest("project:repo:42", "project:repo:42")).toBe(false);
expect(shouldOpenProactivePullRequest("project:repo:42", null)).toBe(false);
@@ -286,7 +290,7 @@ describe("proactive panels", () => {
).toBe(false);
});
it("opens the diff only when the observed running turn settles", () => {
it("opens a completed diff on entry or when the observed running turn settles", () => {
const turnId = TurnId.make("turn-1");
expect(
shouldOpenProactiveTurnDiff({
@@ -295,7 +299,7 @@ describe("proactive panels", () => {
settledTurnId: turnId,
turnCompleted: true,
}),
).toBe(false);
).toBe(true);
expect(
shouldOpenProactiveTurnDiff({
previousRunningTurnId: turnId,
+4 -4
View File
@@ -104,7 +104,7 @@ export function shouldOpenProactivePullRequest(
previousTargetKey: string | null | undefined,
targetKey: string | null,
): boolean {
return previousTargetKey !== undefined && targetKey !== null && targetKey !== previousTargetKey;
return targetKey !== null && targetKey !== previousTargetKey;
}
interface ProactivePanelObservation {
@@ -158,11 +158,11 @@ export function shouldOpenProactiveTurnDiff(input: {
turnCompleted: boolean;
}): boolean {
return (
input.previousRunningTurnId !== undefined &&
input.previousRunningTurnId !== null &&
input.runningTurnId === null &&
input.turnCompleted &&
input.settledTurnId === input.previousRunningTurnId
input.settledTurnId !== null &&
(input.previousRunningTurnId === undefined ||
input.settledTurnId === input.previousRunningTurnId)
);
}
+2 -1
View File
@@ -4095,7 +4095,8 @@ export default function ChatView(props: ChatViewProps) {
const shouldDeferLink = eligibleLink && !pullRequestsCapabilityKnown;
proactivePanelObservationRef.current = {
...observation,
runningTurnId: diffAction === "defer" ? (previousRunningTurnId ?? null) : activeRunningTurnId,
// Preserve first-entry eligibility while the checkpoint or repository is loading.
runningTurnId: diffAction === "defer" ? previousRunningTurnId : activeRunningTurnId,
targetKey: shouldDeferLink ? (previousTargetKey ?? null) : linkedThreadPullRequestKey,
};
+3 -1
View File
@@ -29,15 +29,17 @@ describe("rightPanelStore", () => {
});
it.each(["diff-first", "pull-request-first"])(
"keeps the linked pull request above the completed diff with %s delivery",
"prioritizes the linked pull request over browser and diff with %s delivery",
(order) => {
const store = useRightPanelStore.getState();
store.openBrowser(refA, "existing-browser");
const revision = store.getUserActionRevision(refA);
const requests =
order === "diff-first"
? [completedDiff, linkedPullRequest]
: [linkedPullRequest, completedDiff];
for (const surface of requests) store.openProactive(refA, surface, revision);
store.reconcileBrowserSurfaces(refA, ["existing-browser", "agent-browser"]);
expect(
selectActiveRightPanelSurface(useRightPanelStore.getState().byThreadKey, refA),