From 481c4b3709532c1b4723eb1ea98febb61232771b Mon Sep 17 00:00:00 2001 From: viktorce Date: Wed, 18 Nov 2026 10:56:41 +0000 Subject: [PATCH 1/3] fix(web): the Compact chip no longer shows after /clear On a Claude thread left idle past its prompt cache, the composer shows a Compact chip and gives Send the accessible name "Compact and send". After /clear, the next message starts a fresh session, which never compacts, yet the chip and that name stayed. Mobile already hides its chip in this state, and web now does too. The offer hides until the next message is sent, and comes back if the user keeps the current session. At phone width, the collapsed composer's button now sends in this state instead of opening the composer to offer a compaction. The web fake environment advertises freshContext, as the real server does, so browser tests can use /clear. --- ...hatView.handoffCompaction.browser.test.tsx | 46 ++++++++++++++++++- apps/web/src/components/ChatView.tsx | 13 ++++-- apps/web/test/fakeEnvironment.ts | 2 +- 3 files changed, 53 insertions(+), 8 deletions(-) diff --git a/apps/web/src/components/ChatView.handoffCompaction.browser.test.tsx b/apps/web/src/components/ChatView.handoffCompaction.browser.test.tsx index ca6cc6ab95c00..40ad071fc958d 100644 --- a/apps/web/src/components/ChatView.handoffCompaction.browser.test.tsx +++ b/apps/web/src/components/ChatView.handoffCompaction.browser.test.tsx @@ -47,8 +47,8 @@ const CLAUDE = ProviderInstanceId.make("claudeAgent"); const CLAUDE_DRIVER = ProviderDriverKind.make("claudeAgent"); /** A Claude thread whose 250k-token context went cold long ago, with its native thread kept for handoff. */ -function coldClaudeThread() { - const thread = threadWithHistory("thread-claude", 3, { +function coldClaudeThread(threadId = "thread-claude") { + const thread = threadWithHistory(threadId, 3, { instanceId: CLAUDE, model: "claude-opus-4-6", }); @@ -123,3 +123,45 @@ it("sends a Codex follow-up on a cold Claude thread without compacting first", a await vi.waitFor(() => expect(messages()).toContainEqual(sent)); expect(messages()).toEqual([sent]); }); + +it("drops the compact offer on a cold Claude thread while /clear is armed", async () => { + // At phone width, dismissing the fresh-session notice collapses the composer and hides the chip. + const viewport = { width: window.innerWidth, height: window.innerHeight }; + await page.viewport(1280, 800); + await using _viewport = { + [Symbol.asyncDispose]: () => page.viewport(viewport.width, viewport.height), + }; + // The first test's model pick stays on thread-claude's draft, so this one uses its own thread. + const thread = coldClaudeThread("thread-claude-cleared"); + using _environment = installFakeEnvironment([thread], { providers: [CLAUDE_PROVIDER] }); + __setClientSettingsForTests({ + ...DEFAULT_CLIENT_SETTINGS, + onboardingCompletedAt: "2026-01-01T00:00:00.000Z", + }); + const router = getRouter( + createMemoryHistory({ initialEntries: [`/${ENVIRONMENT_ID}/${thread.id}`] }), + ); + await router.load(); + await using _app = await render(, { + // AppRoot brings its own router. + router: false, + }); + await expect.element(page.getByText(`Answer 2 for ${thread.id}.`)).toBeVisible(); + const chip = page.getByRole("button", { name: "Compact 250k tokens of history before sending" }); + const compactAndSend = page.getByRole("button", { name: "Compact and send" }); + await expect.element(chip).toBeVisible(); + await expect.element(compactAndSend).toBeVisible(); + + const editor = page.getByTestId("composer-editor"); + await userEvent.click(editor); + await userEvent.type(editor, "/clear"); + await userEvent.keyboard("{Enter}"); + await expect.element(page.getByText("Your next message starts a fresh session")).toBeVisible(); + await expect.element(chip).not.toBeInTheDocument(); + await expect.element(compactAndSend).not.toBeInTheDocument(); + await expect.element(page.getByRole("button", { name: "Submit message" })).toBeVisible(); + + await page.getByRole("button", { name: "Keep the current session" }).click(); + await expect.element(chip).toBeVisible(); + await expect.element(compactAndSend).toBeVisible(); +}); diff --git a/apps/web/src/components/ChatView.tsx b/apps/web/src/components/ChatView.tsx index a731a5798e191..e6f0fc79ecb62 100644 --- a/apps/web/src/components/ChatView.tsx +++ b/apps/web/src/components/ChatView.tsx @@ -2540,10 +2540,16 @@ export default function ChatView(props: ChatViewProps) { pendingApprovals.length > 0 || pendingUserInputs.length > 0; const compactDisabled = compactThreadUnavailable; - // The context window is the current conversation's, so a handoff destination never inherits it. + const freshSessionAvailable = + activeMessageCount > 0 && serverConfig?.environment.capabilities.freshContext === true; + const freshSessionArmed = useFreshSessionArmed(routeThreadKey); + const freshSessionPending = freshSessionAvailable && freshSessionArmed; + // The context window is the current conversation's, so neither a handoff destination nor + // the fresh session armed by /clear inherits it. const resumeCompactionTokens = activeContextWindow && pendingHandoff === null && + !freshSessionPending && resolveIdleCompaction( settings, activeProviderInstanceId ?? ProviderInstanceId.make("claudeAgent"), @@ -2575,12 +2581,9 @@ export default function ChatView(props: ChatViewProps) { return next; }); }; - const freshSessionAvailable = - activeMessageCount > 0 && serverConfig?.environment.capabilities.freshContext === true; // While a question or approval owns the composer, its text answers that, not the agent. const freshSessionCommandAvailable = freshSessionAvailable && activePendingApproval === null && pendingUserInputs.length === 0; - const freshSessionArmed = useFreshSessionArmed(routeThreadKey); const toggleKeepFullHistory = () => setKeepFullHistory(routeThreadKey, !keepFullHistory); const toggleKeepFullHistoryStable = useStableCallback(toggleKeepFullHistory); const armFreshSessionStable = useStableCallback(() => armFreshSession(routeThreadKey)); @@ -2690,7 +2693,7 @@ export default function ChatView(props: ChatViewProps) { const projectCloneItems = projectCloneBannerItem === null ? [] : [projectCloneBannerItem]; // An approval's feedback goes to that approval; the armed session waits for the next message. const freshSessionItems = - freshSessionAvailable && freshSessionArmed && activePendingApproval === null + freshSessionPending && activePendingApproval === null ? [freshSessionBannerItem(() => disarmFreshSession(routeThreadKey), messages)] : []; if (!localCheckoutBranchMismatch || !showBranchMismatchBanner || !activeBranchMismatchKey) { diff --git a/apps/web/test/fakeEnvironment.ts b/apps/web/test/fakeEnvironment.ts index 3146de25b1c45..7fd89bf48a9f5 100644 --- a/apps/web/test/fakeEnvironment.ts +++ b/apps/web/test/fakeEnvironment.ts @@ -67,7 +67,7 @@ const descriptor = { // A matching version, since a mismatch adds an update banner a typical user never sees. serverVersion: APP_VERSION, orchestrationProtocolVersion: ORCHESTRATION_PROTOCOL_VERSION, - capabilities: { repositoryIdentity: true, sideChats: true }, + capabilities: { repositoryIdentity: true, sideChats: true, freshContext: true }, }; const auth = { policy: "loopback-browser", From 1f6d96b75ab7e29f442b896affbbcacfbb856738 Mon Sep 17 00:00:00 2001 From: viktorce Date: Thu, 19 Nov 2026 14:15:43 +0000 Subject: [PATCH 2/3] fix(web): the /clear notice stays while an approval is held While you type, the composer holds an approval that arrives, so the composer still sends a normal message, and with /clear armed that message starts a fresh session. The fresh-session notice checked the raw approval, so it hid in that state. It now treats a held approval like no approval, as the composer does. --- apps/web/src/components/ChatView.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/web/src/components/ChatView.tsx b/apps/web/src/components/ChatView.tsx index e6f0fc79ecb62..3d3217b53c369 100644 --- a/apps/web/src/components/ChatView.tsx +++ b/apps/web/src/components/ChatView.tsx @@ -2692,8 +2692,11 @@ export default function ChatView(props: ChatViewProps) { const usageLimitsItems = usageLimitsBanner === null ? [] : [usageLimitsBanner]; const projectCloneItems = projectCloneBannerItem === null ? [] : [projectCloneBannerItem]; // An approval's feedback goes to that approval; the armed session waits for the next message. + // An approval held while you type doesn't own the composer, so a send still starts fresh. const freshSessionItems = - freshSessionPending && activePendingApproval === null + freshSessionPending && + (activePendingApproval === null || + heldApprovalRequestIds.has(activePendingApproval.requestId)) ? [freshSessionBannerItem(() => disarmFreshSession(routeThreadKey), messages)] : []; if (!localCheckoutBranchMismatch || !showBranchMismatchBanner || !activeBranchMismatchKey) { From 89496a2e2728361b6be097631392e8f508490084 Mon Sep 17 00:00:00 2001 From: viktorce Date: Thu, 19 Nov 2026 14:32:14 +0000 Subject: [PATCH 3/3] Revert "fix(web): the /clear notice stays while an approval is held" While an approval is pending, held or not, the send path gets freshSessionCommandAvailable, which is false then, so a send keeps the old context and leaves /clear armed. Hiding the notice in that state matched what the send does, so the earlier condition was right. This reverts commit 1f6d96b75ab7e29f442b896affbbcacfbb856738. --- apps/web/src/components/ChatView.tsx | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/apps/web/src/components/ChatView.tsx b/apps/web/src/components/ChatView.tsx index 3d3217b53c369..e6f0fc79ecb62 100644 --- a/apps/web/src/components/ChatView.tsx +++ b/apps/web/src/components/ChatView.tsx @@ -2692,11 +2692,8 @@ export default function ChatView(props: ChatViewProps) { const usageLimitsItems = usageLimitsBanner === null ? [] : [usageLimitsBanner]; const projectCloneItems = projectCloneBannerItem === null ? [] : [projectCloneBannerItem]; // An approval's feedback goes to that approval; the armed session waits for the next message. - // An approval held while you type doesn't own the composer, so a send still starts fresh. const freshSessionItems = - freshSessionPending && - (activePendingApproval === null || - heldApprovalRequestIds.has(activePendingApproval.requestId)) + freshSessionPending && activePendingApproval === null ? [freshSessionBannerItem(() => disarmFreshSession(routeThreadKey), messages)] : []; if (!localCheckoutBranchMismatch || !showBranchMismatchBanner || !activeBranchMismatchKey) {