feat(web): add proactive panels (#9276)

Co-authored-by: maria-rcks <[email protected]>
This commit is contained in:
mariaandmaria-rcks authored and GitHub committed 2026-09-02 18:51:21 -04:00
1 parent 535557b3f7
commit fb93902ee2
9 files changed
+244 -3

No files matched your search

@@ -43,6 +43,7 @@ const clientSettings: ClientSettings = {
glassOpacity: 80,
panelAnimationDurationMs: 0,
planModeEnabled: false,
proactivePanelsEnabled: true,
showSkillsInSlashMenu: false,
providerModelPreferences: {},
sidebarProjectGroupingMode: "repository_path",
@@ -40,6 +40,8 @@ import {
codexArtifactTemplatePromptToAppend,
shouldDockDraftHeroForSubmission,
shouldReleaseTimelineAnchorForToolActivity,
shouldOpenProactivePullRequest,
shouldOpenProactiveTurnDiff,
shouldShowBranchMismatchBanner,
shouldShowPlanFollowUpPrompt,
shouldWriteThreadErrorToCurrentServerThread,
@@ -83,6 +85,51 @@ describe("agent browser close confirmation", () => {
});
});
describe("proactive panels", () => {
it("opens a pull request only after a newly observed link appears", () => {
expect(shouldOpenProactivePullRequest(undefined, "project:repo:42")).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);
});
it("opens the diff only when the observed running turn settles", () => {
const turnId = TurnId.make("turn-1");
expect(
shouldOpenProactiveTurnDiff({
previousRunningTurnId: undefined,
runningTurnId: null,
settledTurnId: turnId,
turnCompleted: true,
}),
).toBe(false);
expect(
shouldOpenProactiveTurnDiff({
previousRunningTurnId: turnId,
runningTurnId: null,
settledTurnId: turnId,
turnCompleted: true,
}),
).toBe(true);
expect(
shouldOpenProactiveTurnDiff({
previousRunningTurnId: turnId,
runningTurnId: TurnId.make("turn-2"),
settledTurnId: turnId,
turnCompleted: true,
}),
).toBe(false);
expect(
shouldOpenProactiveTurnDiff({
previousRunningTurnId: turnId,
runningTurnId: null,
settledTurnId: turnId,
turnCompleted: false,
}),
).toBe(false);
});
});
describe("isVideoPreviewRequestCurrent", () => {
it("rejects changed threads and replaced previews", () => {
expect(isVideoPreviewRequestCurrent("thread-1", "thread-2", 1, 1)).toBe(false);
+22
View File
@@ -78,6 +78,28 @@ export function agentControlledBrowserCloseConfirmation(
].join("\n");
}
export function shouldOpenProactivePullRequest(
previousTargetKey: string | null | undefined,
targetKey: string | null,
): boolean {
return previousTargetKey !== undefined && targetKey !== null && targetKey !== previousTargetKey;
}
export function shouldOpenProactiveTurnDiff(input: {
previousRunningTurnId: TurnId | null | undefined;
runningTurnId: TurnId | null;
settledTurnId: TurnId | null;
turnCompleted: boolean;
}): boolean {
return (
input.previousRunningTurnId !== undefined &&
input.previousRunningTurnId !== null &&
input.runningTurnId === null &&
input.turnCompleted &&
input.settledTurnId === input.previousRunningTurnId
);
}
export function codexArtifactTemplatePromptToAppend(
currentDraft: string,
template: CodexArtifactTemplate,
+124 -3
View File
@@ -361,6 +361,8 @@ import {
shouldReleaseTimelineAnchorForToolActivity,
shouldShowBranchMismatchBanner,
shouldShowPlanFollowUpPrompt,
shouldOpenProactivePullRequest,
shouldOpenProactiveTurnDiff,
getStartedThreadModelChangeBlockReason,
LAST_INVOKED_SCRIPT_BY_PROJECT_KEY,
LastInvokedScriptByProjectSchema,
@@ -1766,6 +1768,7 @@ function ChatViewContent(props: ChatViewProps) {
[activeThreadEnvironmentId, activeThreadId],
);
const activeThreadKey = activeThreadRef ? scopedThreadKey(activeThreadRef) : null;
const activeThreadShell = useThreadShell(isServerThread ? activeThreadRef : null);
const changeRequestSnapshotByKey = useAtomValue(threadChangeRequestSnapshotsAtom);
const [timelineAnchor, setTimelineAnchor] = useState<{
readonly threadKey: string | null;
@@ -3665,7 +3668,16 @@ function ChatViewContent(props: ChatViewProps) {
);
// The thread's own change request, placed against the project it belongs to. Without a
// project there is nothing to resolve it against, so the caller falls back to the browser.
const linkedThreadPullRequest = activeThread?.linkedPullRequest ?? null;
const linkedThreadPullRequest = isServerThread
? (activeThreadShell?.linkedPullRequest ?? activeThread?.linkedPullRequest ?? null)
: (activeThread?.linkedPullRequest ?? null);
const linkedThreadPullRequestKey = linkedThreadPullRequest
? JSON.stringify([
linkedThreadPullRequest.projectId,
linkedThreadPullRequest.repository,
linkedThreadPullRequest.number,
])
: null;
const activeProjectRepository = activeProject?.repositoryIdentity?.displayName ?? null;
const threadRepository = linkedThreadPullRequest?.repository ?? activeProjectRepository;
const openThreadPullRequest = useCallback(
@@ -3708,6 +3720,117 @@ function ChatViewContent(props: ChatViewProps) {
},
[activeProject, activeProjectRepository, activeThreadRef, supportsPullRequests],
);
const proactiveTurnObservationRef = useRef<{
threadKey: string;
runningTurnId: TurnId | null;
} | null>(null);
const proactivePullRequestObservationRef = useRef<{
threadKey: string;
targetKey: string | null;
} | null>(null);
useEffect(() => {
if (!isServerThread || activeThreadKey === null || activeThreadRef === null) {
proactiveTurnObservationRef.current = null;
return;
}
if (!clientSettingsHydrated || threadDetailLoading) {
return;
}
const previousObservation = proactiveTurnObservationRef.current;
const observingSameThread = previousObservation?.threadKey === activeThreadKey;
const previousRunningTurnId = observingSameThread
? previousObservation.runningTurnId
: undefined;
const settledTurnId = latestTurnSettled ? (activeLatestTurn?.turnId ?? null) : null;
const newlyCompletedTurnId = shouldOpenProactiveTurnDiff({
previousRunningTurnId,
runningTurnId: activeRunningTurnId,
settledTurnId,
turnCompleted: activeLatestTurn?.state === "completed",
})
? settledTurnId
: 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;
proactiveTurnObservationRef.current = {
threadKey: activeThreadKey,
runningTurnId: shouldDeferCompletion ? (previousRunningTurnId ?? null) : activeRunningTurnId,
};
if (!shouldOpenTurn || newlyCompletedTurnId === null) return;
useDiffPanelStore.getState().selectTurn(activeThreadRef, newlyCompletedTurnId);
useRightPanelStore.getState().open(activeThreadRef, "diff");
onDiffPanelOpen?.();
}, [
activeThread?.checkpoints,
activeLatestTurn?.turnId,
activeLatestTurn?.state,
activeRunningTurnId,
activeThreadKey,
activeThreadRef,
clientSettingsHydrated,
gitStatusQuery.data?.isRepo,
isServerThread,
latestTurnSettled,
onDiffPanelOpen,
settings.proactivePanelsEnabled,
shouldUseRightPanelSheet,
threadDetailLoading,
]);
useEffect(() => {
if (!isServerThread || activeThreadKey === null || activeThreadRef === null) {
proactivePullRequestObservationRef.current = null;
return;
}
if (!clientSettingsHydrated || threadDetailLoading) {
return;
}
const previousObservation = proactivePullRequestObservationRef.current;
const observingSameThread = previousObservation?.threadKey === activeThreadKey;
const previousTargetKey = observingSameThread ? previousObservation.targetKey : undefined;
const newlyLinkedPullRequest = shouldOpenProactivePullRequest(
previousTargetKey,
linkedThreadPullRequestKey,
);
const eligibleLink =
settings.proactivePanelsEnabled && !shouldUseRightPanelSheet && newlyLinkedPullRequest;
const shouldOpenLink =
eligibleLink &&
pullRequestsCapabilityKnown &&
supportsPullRequests &&
linkedThreadPullRequest !== null;
const shouldDeferLink = eligibleLink && !pullRequestsCapabilityKnown;
proactivePullRequestObservationRef.current = {
threadKey: activeThreadKey,
targetKey: shouldDeferLink ? (previousTargetKey ?? null) : linkedThreadPullRequestKey,
};
if (!shouldOpenLink || linkedThreadPullRequest === null) return;
useRightPanelStore.getState().openPullRequest(activeThreadRef, linkedThreadPullRequest);
}, [
activeThreadKey,
activeThreadRef,
clientSettingsHydrated,
isServerThread,
linkedThreadPullRequest,
linkedThreadPullRequestKey,
pullRequestsCapabilityKnown,
settings.proactivePanelsEnabled,
shouldUseRightPanelSheet,
supportsPullRequests,
threadDetailLoading,
]);
const togglePreviewPanel = useCallback(() => {
if (!activeThreadRef || !isPreviewSupportedInRuntime()) return;
if (previewPanelOpen) {
@@ -4612,8 +4735,6 @@ function ChatViewContent(props: ChatViewProps) {
: null,
[activeThreadBranch, activeWorktreePath, envMode, gitStatusQuery.data?.refName, isServerThread],
);
// The server-projected settled state keeps the banner and sidebar in sync.
const activeThreadShell = useThreadShell(isServerThread ? activeThreadRef : null);
const activeComposerTasksProgress = useMemo(() => {
if (!activeLatestTurn || latestTurnSettled || activePlan?.turnId !== activeLatestTurn.turnId) {
return null;
@@ -525,6 +525,9 @@ export function useSettingsRestore(onRestored?: () => void) {
...(settings.diffIgnoreWhitespace !== DEFAULT_UNIFIED_SETTINGS.diffIgnoreWhitespace
? ["Diff whitespace changes"]
: []),
...(settings.proactivePanelsEnabled !== DEFAULT_UNIFIED_SETTINGS.proactivePanelsEnabled
? ["Proactive panels"]
: []),
...(settings.showSkillsInSlashMenu !== DEFAULT_UNIFIED_SETTINGS.showSkillsInSlashMenu
? ["Show skills in slash menu"]
: []),
@@ -588,6 +591,7 @@ export function useSettingsRestore(onRestored?: () => void) {
settings.defaultThreadEnvMode,
settings.newWorktreesStartFromOrigin,
settings.diffIgnoreWhitespace,
settings.proactivePanelsEnabled,
settings.environmentIdentificationMode,
settings.contextWindowMeterEnabled,
settings.fontFamilyCode,
@@ -683,6 +687,7 @@ export function useSettingsRestore(onRestored?: () => void) {
timestampFormat: DEFAULT_UNIFIED_SETTINGS.timestampFormat,
wordWrap: DEFAULT_UNIFIED_SETTINGS.wordWrap,
diffIgnoreWhitespace: DEFAULT_UNIFIED_SETTINGS.diffIgnoreWhitespace,
proactivePanelsEnabled: DEFAULT_UNIFIED_SETTINGS.proactivePanelsEnabled,
showSkillsInSlashMenu: DEFAULT_UNIFIED_SETTINGS.showSkillsInSlashMenu,
contextWindowMeterEnabled: DEFAULT_UNIFIED_SETTINGS.contextWindowMeterEnabled,
environmentIdentificationMode: DEFAULT_UNIFIED_SETTINGS.environmentIdentificationMode,
@@ -2206,6 +2211,32 @@ export function GeneralSettingsPanel() {
}
/>
<SettingsRow
{...searchableSetting("proactive-panels")}
description="Automatically open the linked pull request when it appears and the turn diff when agent work finishes."
resetAction={
settings.proactivePanelsEnabled !== DEFAULT_UNIFIED_SETTINGS.proactivePanelsEnabled ? (
<SettingResetButton
label="proactive panels"
onClick={() =>
updateSettings({
proactivePanelsEnabled: DEFAULT_UNIFIED_SETTINGS.proactivePanelsEnabled,
})
}
/>
) : null
}
control={
<Switch
checked={settings.proactivePanelsEnabled}
onCheckedChange={(checked) =>
updateSettings({ proactivePanelsEnabled: Boolean(checked) })
}
aria-label="Proactive panels"
/>
}
/>
<SettingsRow
{...searchableSetting("skills-in-slash-menu")}
description="Also include skills in the / command menu. Skills always appear when you type $."
@@ -184,6 +184,12 @@ export const SETTINGS_SEARCH_ITEMS = [
to: "/settings/general",
searchTerms: ["diff ignore spaces edits default"],
},
{
id: "proactive-panels",
title: "Proactive panels",
to: "/settings/general",
searchTerms: ["automatically open diff pull request pr right panel agent completion"],
},
{
id: "skills-in-slash-menu",
title: "Show skills in slash menu",
+2
View File
@@ -46,6 +46,8 @@ T3 Code works with the platforms your team already uses:
time, or change size
- While working in a thread, open linked reviews in the same compact right-panel tabs without
leaving the conversation
- Enable **Settings → General → Proactive panels** to open a newly linked review automatically and
switch to the completed turn's diff when agent work finishes
- 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
+9
View File
@@ -67,6 +67,15 @@ describe("ClientSettings word wrap", () => {
});
});
describe("ClientSettings proactive panels", () => {
it("is opt-in and accepts client-local updates", () => {
expect(decodeClientSettings({}).proactivePanelsEnabled).toBe(false);
expect(decodeClientSettingsPatch({ proactivePanelsEnabled: true }).proactivePanelsEnabled).toBe(
true,
);
});
});
describe("ClientSettings quit confirmation", () => {
it("defaults to hold", () => {
expect(decodeClientSettings({}).confirmQuit).toBe("hold");
+2
View File
@@ -299,6 +299,7 @@ export const ClientSettingsSchema = Schema.Struct({
// Legacy context window meter. The composer hides it by default; users who
// still want the old usage indicator can restore it from Settings.
contextWindowMeterEnabled: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(false))),
proactivePanelsEnabled: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(false))),
showSkillsInSlashMenu: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(true))),
// Legacy sidebar (the original per-project tree). Deliberately a fresh key
// (was `sidebarV2Enabled` + `sidebarV2ConfiguredByUser`): decoding drops the
@@ -1029,6 +1030,7 @@ export const ClientSettingsPatch = Schema.Struct({
),
planModeEnabled: Schema.optionalKey(Schema.Boolean),
contextWindowMeterEnabled: Schema.optionalKey(Schema.Boolean),
proactivePanelsEnabled: Schema.optionalKey(Schema.Boolean),
showSkillsInSlashMenu: Schema.optionalKey(Schema.Boolean),
legacySidebarEnabled: Schema.optionalKey(Schema.Boolean),
sidebarProjectGroupingMode: Schema.optionalKey(SidebarProjectGroupingMode),