fix(web): stop empty diffs replacing pull requests (#9753)
This commit is contained in:
1 parent
bc03c3640d
commit
d115a96763
5 files changed
+109
-11
No files matched your search
@@ -41,6 +41,7 @@ import {
|
||||
resolveComposerInteractionMode,
|
||||
resolveComposerProviderSelection,
|
||||
resolveDraftPromotionNavigationTarget,
|
||||
resolveProactiveTurnDiffAction,
|
||||
resolveThreadMetadataUpdateForNextTurn,
|
||||
resolveSendEnvMode,
|
||||
resolveDraftHeroState,
|
||||
@@ -159,6 +160,80 @@ describe("proactive panels", () => {
|
||||
}),
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("opens a completed turn diff only for changed files", () => {
|
||||
const changedCheckpoint = {
|
||||
status: "ready",
|
||||
files: [{ path: "src/app.ts", kind: "modified", additions: 1, deletions: 0 }],
|
||||
} satisfies Pick<TurnDiffSummary, "status" | "files">;
|
||||
const unchangedCheckpoint = {
|
||||
status: "ready",
|
||||
files: [],
|
||||
} satisfies Pick<TurnDiffSummary, "status" | "files">;
|
||||
|
||||
expect(
|
||||
resolveProactiveTurnDiffAction({
|
||||
checkpoint: changedCheckpoint,
|
||||
isGitRepo: true,
|
||||
activeSurfaceKind: null,
|
||||
}),
|
||||
).toBe("open");
|
||||
expect(
|
||||
resolveProactiveTurnDiffAction({
|
||||
checkpoint: unchangedCheckpoint,
|
||||
isGitRepo: true,
|
||||
activeSurfaceKind: null,
|
||||
}),
|
||||
).toBe("ignore");
|
||||
});
|
||||
|
||||
it("waits for definitive checkpoint and repository state", () => {
|
||||
const missingCheckpoint = {
|
||||
status: "missing",
|
||||
files: [],
|
||||
} satisfies Pick<TurnDiffSummary, "status" | "files">;
|
||||
const changedCheckpoint = {
|
||||
status: "ready",
|
||||
files: [{ path: "src/app.ts", kind: "modified", additions: 1, deletions: 0 }],
|
||||
} satisfies Pick<TurnDiffSummary, "status" | "files">;
|
||||
|
||||
expect(
|
||||
resolveProactiveTurnDiffAction({
|
||||
checkpoint: undefined,
|
||||
isGitRepo: true,
|
||||
activeSurfaceKind: null,
|
||||
}),
|
||||
).toBe("defer");
|
||||
expect(
|
||||
resolveProactiveTurnDiffAction({
|
||||
checkpoint: missingCheckpoint,
|
||||
isGitRepo: true,
|
||||
activeSurfaceKind: null,
|
||||
}),
|
||||
).toBe("defer");
|
||||
expect(
|
||||
resolveProactiveTurnDiffAction({
|
||||
checkpoint: changedCheckpoint,
|
||||
isGitRepo: undefined,
|
||||
activeSurfaceKind: null,
|
||||
}),
|
||||
).toBe("defer");
|
||||
});
|
||||
|
||||
it("keeps an active pull request above a completed turn diff", () => {
|
||||
const changedCheckpoint = {
|
||||
status: "ready",
|
||||
files: [{ path: "src/app.ts", kind: "modified", additions: 1, deletions: 0 }],
|
||||
} satisfies Pick<TurnDiffSummary, "status" | "files">;
|
||||
|
||||
expect(
|
||||
resolveProactiveTurnDiffAction({
|
||||
checkpoint: changedCheckpoint,
|
||||
isGitRepo: true,
|
||||
activeSurfaceKind: "pull-request",
|
||||
}),
|
||||
).toBe("ignore");
|
||||
});
|
||||
});
|
||||
|
||||
describe("toolGroupConsumesUpwardNavigation", () => {
|
||||
|
||||
@@ -121,6 +121,24 @@ export function shouldOpenProactiveTurnDiff(input: {
|
||||
);
|
||||
}
|
||||
|
||||
export function resolveProactiveTurnDiffAction(input: {
|
||||
checkpoint: Pick<TurnDiffSummary, "status" | "files"> | undefined;
|
||||
isGitRepo: boolean | undefined;
|
||||
activeSurfaceKind: RightPanelSurface["kind"] | null;
|
||||
}): "defer" | "ignore" | "open" {
|
||||
if (input.activeSurfaceKind === "pull-request") return "ignore";
|
||||
if (input.checkpoint === undefined || input.checkpoint.status === "missing") return "defer";
|
||||
if (input.isGitRepo === undefined) return "defer";
|
||||
if (
|
||||
!input.isGitRepo ||
|
||||
input.checkpoint.status !== "ready" ||
|
||||
input.checkpoint.files.length === 0
|
||||
) {
|
||||
return "ignore";
|
||||
}
|
||||
return "open";
|
||||
}
|
||||
|
||||
export function codexArtifactTemplatePromptToAppend(
|
||||
currentDraft: string,
|
||||
template: CodexArtifactTemplate,
|
||||
|
||||
@@ -385,6 +385,7 @@ import {
|
||||
resolveComposerInteractionMode,
|
||||
resolveComposerProviderSelection,
|
||||
resolveDraftHeroState,
|
||||
resolveProactiveTurnDiffAction,
|
||||
resolveThreadMetadataUpdateForNextTurn,
|
||||
resolveSendEnvMode,
|
||||
revokeBlobPreviewUrl,
|
||||
@@ -3922,18 +3923,21 @@ export default function ChatView(props: ChatViewProps) {
|
||||
: null;
|
||||
const eligibleCompletion =
|
||||
settings.proactivePanelsEnabled && !shouldUseRightPanelSheet && newlyCompletedTurnId !== null;
|
||||
const checkpointReady =
|
||||
eligibleCompletion &&
|
||||
activeThread?.checkpoints.some((checkpoint) => checkpoint.turnId === newlyCompletedTurnId) ===
|
||||
true;
|
||||
const shouldOpenTurn = checkpointReady && gitStatusQuery.data?.isRepo === true;
|
||||
const shouldDeferCompletion =
|
||||
eligibleCompletion && !shouldOpenTurn && gitStatusQuery.data?.isRepo !== false;
|
||||
const completedCheckpoint = eligibleCompletion
|
||||
? activeThread?.checkpoints.find((checkpoint) => checkpoint.turnId === newlyCompletedTurnId)
|
||||
: undefined;
|
||||
const diffAction = eligibleCompletion
|
||||
? resolveProactiveTurnDiffAction({
|
||||
checkpoint: completedCheckpoint,
|
||||
isGitRepo: gitStatusQuery.data?.isRepo,
|
||||
activeSurfaceKind: activeRightPanelSurface?.kind ?? null,
|
||||
})
|
||||
: "ignore";
|
||||
proactiveTurnObservationRef.current = {
|
||||
threadKey: activeThreadKey,
|
||||
runningTurnId: shouldDeferCompletion ? (previousRunningTurnId ?? null) : activeRunningTurnId,
|
||||
runningTurnId: diffAction === "defer" ? (previousRunningTurnId ?? null) : activeRunningTurnId,
|
||||
};
|
||||
if (!shouldOpenTurn || newlyCompletedTurnId === null) return;
|
||||
if (diffAction !== "open" || newlyCompletedTurnId === null) return;
|
||||
|
||||
useDiffPanelStore.getState().selectTurn(activeThreadRef, newlyCompletedTurnId);
|
||||
useRightPanelStore.getState().open(activeThreadRef, "diff");
|
||||
@@ -3945,6 +3949,7 @@ export default function ChatView(props: ChatViewProps) {
|
||||
activeRunningTurnId,
|
||||
activeThreadKey,
|
||||
activeThreadRef,
|
||||
activeRightPanelSurface?.kind,
|
||||
clientSettingsHydrated,
|
||||
gitStatusQuery.data?.isRepo,
|
||||
isServerThread,
|
||||
|
||||
@@ -2308,7 +2308,7 @@ export function GeneralSettingsPanel() {
|
||||
|
||||
<SettingsRow
|
||||
{...searchableSetting("proactive-panels")}
|
||||
description="Open linked pull requests when found and turn diffs when work finishes."
|
||||
description="Open linked pull requests when found and turn diffs when work changes files."
|
||||
resetAction={
|
||||
settings.proactivePanelsEnabled !== DEFAULT_UNIFIED_SETTINGS.proactivePanelsEnabled ? (
|
||||
<SettingResetButton
|
||||
|
||||
@@ -64,7 +64,7 @@ T3 Code works with the platforms your team already uses:
|
||||
changed files as folders and jump straight to any of them. The toolbar toggle remembers your
|
||||
choice.
|
||||
- Enable **Settings → General → Proactive panels** to open a newly linked review automatically and
|
||||
switch to the completed turn's diff when agent work finishes
|
||||
switch to the completed turn's diff when agent work changes files. An open review stays in front
|
||||
- Open the review directly in your browser with one click
|
||||
- If T3 Code cannot load a GitHub pull request, including when GitHub rate limits requests, use
|
||||
**Open on GitHub** in the error view
|
||||
|
||||
Reference in new issue
Block a user