Skip to content

[Bug]: Sending /clear on a stale Claude thread compacts the old context first, then clears #31092

Open

Description

@DmitriyAlergant

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/web - composer send path (compact-before-send on stale Claude threads)

Steps to reproduce

  1. Use a Claude thread until its context is above the compaction suggestion minimum (COMPACTION_SUGGESTION_MIN_TOKENS).
  2. Leave it idle past its prompt-cache TTL, so the composer shows the "Compact" chip (compact-before-send is on).
  3. Type /clear and press Enter.

Expected behavior

/clear is sent on its own. The old conversation is discarded, so nothing should be compacted first.

Actual behavior

The composer sends /compact first, then /clear. The thread shows "Context compacted before sending 345K -> 14.1K tokens", and then the clear runs. The compaction re-reads the whole cold context (345K uncached input tokens in my case) to produce a summary that /clear throws away the next moment.

Impact

Pure waste of plan usage and wall-clock time on exactly the action a user takes to avoid paying for the old context. On a 1M-context model with a stale thread this is hundreds of thousands of uncached tokens per /clear.

Diagnosis

planComposerTurn in apps/web/src/components/ChatView.logic.ts (main @ 8ab024f) exempts only /compact from compact-before-send:

const compactBeforeSend =
  input.resumeCompactionTokens !== null &&
  !input.keepFullHistory &&
  !COMPACT_COMMAND_PATTERN.test(input.messageText);

COMPACT_COMMAND_PATTERN is /^\/compact(?:\s|$)/i. There is no equivalent check for /clear (or other local commands that reset or do not use the conversation), so useComposerSend.ts dispatches the /compact turn before it.

Suggested fix: skip compact-before-send when the message is /clear (and probably any local slash command that does not send the conversation to the model). Also hide or disable the "Compact" chip while the composer holds /clear.

Version or commit

T3 Code (Beta) desktop 0.1.6. Code path confirmed unchanged on main @ 8ab024f.

Environment

macOS 27 (Apple Silicon), desktop app with local server, Claude Code 2.1.316, provider claudeAgent with claude-opus-5-5.

Workaround

Turn off the "Compact" chip before sending /clear, set "Compact idle threads" to "Never", or start a new thread instead of /clear.

Related

Activity

  1. Sharad-Patel1 commented on Nov 16, 2026

    @Sharad-Patel1
    Contributor

    Note

    Generated by claude-opus-5-5
    RESPONDING ON BEHALF OF SHARAD

    This can be closed: #30325 (99e361e) fixed this on main, and it shipped in v0.1.8. /clear is now T3's own command. Sent on its own or picked from the slash menu, it arms a fresh session and sends nothing, because useComposerSend.ts returns before planComposerTurn runs. There is no /clear turn left to compact first. The message after it is a fresh-context turn, which planComposerTurn never compacts.

    The attached script plans the issue's case, /clear on a stale thread with 345K tokens, on the commit before #30325, and gets compactBeforeSend: true. On current main, useComposerSend intercepts a lone /clear before planning any turn, and the next message plans compactBeforeSend: false.

    I also ran it in the real app with the free Replay provider, in a thread with one finished turn, typing /clear and pressing Enter. Before #30325, /clear went out as an ordinary message and started a turn. On a stale Claude thread, that send is the one that compacted first. On main the slash menu offers T3's /clear, nothing is sent, and the composer says the next message starts a fresh session. A Replay thread can't be a stale Claude thread, so the compaction step itself is covered by the script rather than the recording.

    Before #30325 (e139768a7e) main (e5b6c96a46)
    Before #30325 (e139768a7e) main (e5b6c96a46)
    📹 Screen recording 📹 Screen recording

    To reproduce, run bash prove-issue-31092.sh from a clean t3code checkout after vp i.

    Result
    PASS  #30325 (99e361e415) is on main: feat: /clear starts a fresh session in the same thread (#30325)
    PASS  main apps/web/src/components/chat/useComposerSend.ts:748: a lone /clear calls armFreshSession and returns (line 749) before planComposerTurn (line 812), so no /compact or /clear turn is sent
    PASS  before #30325 apps/web/src/components/chat/useComposerSend.ts has no /clear intercept: /clear went through planComposerTurn like any message
    PASS  before #30325 (e139768a7e): "/clear" on a stale thread (345K tokens) plans compactBeforeSend=true
    PASS  main (16695c812f): /clear is T3's command, and the message after it plans compactBeforeSend=false
    VERDICT: #31092 is fixed on main by #30325
    
  2. viktorce commented on Nov 19, 2026

    @viktorce
    Contributor

    As noted above, #30325 fixed the compaction half. The chip still shows. On main as of 475ae52, on a cold Claude thread that offers to compact, pressing Enter on /clear empties the composer and says the next message starts a fresh session, but the Compact chip stays, and Send's tooltip still offers to summarize the history first. That next message never compacts.

    In the web app at phone width, with a message typed after /clear, the first tap on the collapsed composer's send button opens the composer to offer the compaction instead of sending.

    #39133 hides the offer after /clear until the next message is sent, and brings it back if you keep the current session. Mobile already hides it once /clear is armed, so only web needed the change. It doesn't cover the moment this issue names, while /clear is still typed in the composer. The chip shows then too, on web and mobile. Pressing Enter there compacts nothing, so the offer misleads for that moment but costs nothing.

    #31100 auto-closes this issue on merge, and its body leaves the chip as a follow-up, so the chip half would be left untracked. Could this issue stay open for the chip if #31100 merges, or should I file the chip separately?

    Before the fix, after /clear With the fix
    Before, the Compact chip stays next to Send after /clear With the fix, the chip is gone after /clear

    Demo data in dark mode, rendered in a browser test on 8cf97b5. The compaction offer code they show is unchanged on 475ae52, where the new browser test in #39133 fails with the chip still showing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions