@devries-cameron20 / t3code Mirror · read-only / commits / a1e7ac2b24
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 06:00 UTC

fix(web): the Compact chip no longer shows after /clear (#39133)

Co-authored-by: Julius Marminge <julius0216@outlook.com>

Viktor Leukocyte committed Nov 19, 2026 at 15:35 UTC a1e7ac2b24f53e372fa5f9bcdd53c55c607e74ea
3 files changed +53 -8
apps/web/src/components/ChatView.handoffCompaction.browser.test.tsx
+44 -2
@@ -47,8 +47,8 @@ const CLAUDE = ProviderInstanceId.make("claudeAgent");
47 const CLAUDE_DRIVER = ProviderDriverKind.make("claudeAgent");
48
49 /** A Claude thread whose 250k-token context went cold long ago, with its native thread kept for handoff. */
50 -function coldClaudeThread() {
51 - const thread = threadWithHistory("thread-claude", 3, {
50 +function coldClaudeThread(threadId = "thread-claude") {
51 + const thread = threadWithHistory(threadId, 3, {
52 instanceId: CLAUDE,
53 model: "claude-opus-4-6",
54 });
@@ -123,3 +123,45 @@ it("sends a Codex follow-up on a cold Claude thread without compacting first", a
123 await vi.waitFor(() => expect(messages()).toContainEqual(sent));
124 expect(messages()).toEqual([sent]);
125 });
126 +
127 +it("drops the compact offer on a cold Claude thread while /clear is armed", async () => {
128 + // At phone width, dismissing the fresh-session notice collapses the composer and hides the chip.
129 + const viewport = { width: window.innerWidth, height: window.innerHeight };
130 + await page.viewport(1280, 800);
131 + await using _viewport = {
132 + [Symbol.asyncDispose]: () => page.viewport(viewport.width, viewport.height),
133 + };
134 + // The first test's model pick stays on thread-claude's draft, so this one uses its own thread.
135 + const thread = coldClaudeThread("thread-claude-cleared");
136 + using _environment = installFakeEnvironment([thread], { providers: [CLAUDE_PROVIDER] });
137 + __setClientSettingsForTests({
138 + ...DEFAULT_CLIENT_SETTINGS,
139 + onboardingCompletedAt: "2026-01-01T00:00:00.000Z",
140 + });
141 + const router = getRouter(
142 + createMemoryHistory({ initialEntries: [`/${ENVIRONMENT_ID}/${thread.id}`] }),
143 + );
144 + await router.load();
145 + await using _app = await render(<AppRoot router={router} />, {
146 + // AppRoot brings its own router.
147 + router: false,
148 + });
149 + await expect.element(page.getByText(`Answer 2 for ${thread.id}.`)).toBeVisible();
150 + const chip = page.getByRole("button", { name: "Compact 250k tokens of history before sending" });
151 + const compactAndSend = page.getByRole("button", { name: "Compact and send" });
152 + await expect.element(chip).toBeVisible();
153 + await expect.element(compactAndSend).toBeVisible();
154 +
155 + const editor = page.getByTestId("composer-editor");
156 + await userEvent.click(editor);
157 + await userEvent.type(editor, "/clear");
158 + await userEvent.keyboard("{Enter}");
159 + await expect.element(page.getByText("Your next message starts a fresh session")).toBeVisible();
160 + await expect.element(chip).not.toBeInTheDocument();
161 + await expect.element(compactAndSend).not.toBeInTheDocument();
162 + await expect.element(page.getByRole("button", { name: "Submit message" })).toBeVisible();
163 +
164 + await page.getByRole("button", { name: "Keep the current session" }).click();
165 + await expect.element(chip).toBeVisible();
166 + await expect.element(compactAndSend).toBeVisible();
167 +});
apps/web/src/components/ChatView.tsx
+8 -5
@@ -2540,10 +2540,16 @@ export default function ChatView(props: ChatViewProps) {
2540 pendingApprovals.length > 0 ||
2541 pendingUserInputs.length > 0;
2542 const compactDisabled = compactThreadUnavailable;
2543 - // The context window is the current conversation's, so a handoff destination never inherits it.
2543 + const freshSessionAvailable =
2544 + activeMessageCount > 0 && serverConfig?.environment.capabilities.freshContext === true;
2545 + const freshSessionArmed = useFreshSessionArmed(routeThreadKey);
2546 + const freshSessionPending = freshSessionAvailable && freshSessionArmed;
2547 + // The context window is the current conversation's, so neither a handoff destination nor
2548 + // the fresh session armed by /clear inherits it.
2549 const resumeCompactionTokens =
2550 activeContextWindow &&
2551 pendingHandoff === null &&
2552 + !freshSessionPending &&
2553 resolveIdleCompaction(
2554 settings,
2555 activeProviderInstanceId ?? ProviderInstanceId.make("claudeAgent"),
@@ -2575,12 +2581,9 @@ export default function ChatView(props: ChatViewProps) {
2581 return next;
2582 });
2583 };
2578 - const freshSessionAvailable =
2579 - activeMessageCount > 0 && serverConfig?.environment.capabilities.freshContext === true;
2584 // While a question or approval owns the composer, its text answers that, not the agent.
2585 const freshSessionCommandAvailable =
2586 freshSessionAvailable && activePendingApproval === null && pendingUserInputs.length === 0;
2583 - const freshSessionArmed = useFreshSessionArmed(routeThreadKey);
2587 const toggleKeepFullHistory = () => setKeepFullHistory(routeThreadKey, !keepFullHistory);
2588 const toggleKeepFullHistoryStable = useStableCallback(toggleKeepFullHistory);
2589 const armFreshSessionStable = useStableCallback(() => armFreshSession(routeThreadKey));
@@ -2690,7 +2693,7 @@ export default function ChatView(props: ChatViewProps) {
2693 const projectCloneItems = projectCloneBannerItem === null ? [] : [projectCloneBannerItem];
2694 // An approval's feedback goes to that approval; the armed session waits for the next message.
2695 const freshSessionItems =
2693 - freshSessionAvailable && freshSessionArmed && activePendingApproval === null
2696 + freshSessionPending && activePendingApproval === null
2697 ? [freshSessionBannerItem(() => disarmFreshSession(routeThreadKey), messages)]
2698 : [];
2699 if (!localCheckoutBranchMismatch || !showBranchMismatchBanner || !activeBranchMismatchKey) {
apps/web/test/fakeEnvironment.ts
+1 -1
@@ -67,7 +67,7 @@ const descriptor = {
67 // A matching version, since a mismatch adds an update banner a typical user never sees.
68 serverVersion: APP_VERSION,
69 orchestrationProtocolVersion: ORCHESTRATION_PROTOCOL_VERSION,
70 - capabilities: { repositoryIdentity: true, sideChats: true },
70 + capabilities: { repositoryIdentity: true, sideChats: true, freshContext: true },
71 };
72 const auth = {
73 policy: "loopback-browser",