[Bug]: `/compact <instructions>` sent with the Compact chip on runs two compactions, and the first one ignores the instructions#20222

opened25d agobyPpahan35

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

Steps to reproduce

  1. Open a Claude thread that shows the Compact {tokens} chip next to the send button (≥100K tokens, prompt cache expired).
  2. Leave the chip on. Type /compact Keep the interface decisions, drop the debugging output and press Enter.

Expected behavior

A single compaction that uses the typed instructions. That's what a bare /compact already does: compact-before-send skips a draft that is itself /compact.

Actual behavior

The client dispatches two turns about 15 ms apart:

  1. a bare /compact from compact-before-send, then
  2. the typed /compact <instructions>, queued behind it.

The first compaction summarizes the full history without the instructions. The second one then runs the instructions against a summary that's already been made. So the instructions can't keep anything the first pass dropped, and the user pays for two compactions.

The cause is that the skip check in ChatView.tsx only matches the exact text /compact:

https://github.com/pingdotgg/t3code/blob/v0.1.0/apps/web/src/components/ChatView.tsx#L9149-L9152

ts
1const compactBeforeSend =
2 resumeCompactionTokens !== null &&
3 !keepFullHistory &&
4 messageTextForSend.toLowerCase() !== "/compact";

/compact <instructions> doesn't equal "/compact", so it still gets a bare /compact placed in front of it (L9747-L9753). The check is the same on main @ cfafb4bb54 (line 8879).

Observed three times in one day. In T3's event log, both turns of each pair are separate message.dispatch commands from the web client. Token counts are from Claude Code's compaction records:

Gap between the two dispatchesCompaction 1 (bare)Compaction 2 (with instructions)
15 ms130,532 → 12,896 tokens12,998 → 17,156 tokens
18 ms201,213 → 16,089 tokens16,191 → 20,362 tokens
13 ms122,302 → 9,672 tokens9,774 → 8,215 tokens

On the same day, 12 other /compact <instructions> sends ran a single compaction as expected. In each of those, the chip wasn't on (the thread was under the token threshold or its cache was still warm).

Impact

Minor bug or occasional failure

Version or commit

0.1.0 (81493efb71e8); the check is unchanged on main @ cfafb4bb54

Environment

macOS, T3 Code (Beta) desktop, Claude provider

Workaround

Click the chip to switch it to Full before sending /compact <instructions>.

Suggested fix

Skip compact-before-send for any draft that is a /compact command, not only the exact text /compact. For example, use /^\/compact(\s|$)/i.test(messageTextForSend.trim()), plus a test for /compact <args> with the chip on.

Related, but not the same: #17467 / discussion #17170 (whether the chip should default to on), and discussion #19939 (routing /compact <text> through the server's compactThread).

Note

Grok responding on behalf of Julius.

Confirmed on main: the compact-before-send skip in apps/web/src/components/ChatView.tsx only matches the exact text /compact (messageTextForSend.toLowerCase() !== "/compact"). So with the Compact chip on, /compact <instructions> still gets a bare /compact queued in front of it. The first compaction then runs without your instructions.

Until there's a fix, switch the chip to Full before sending /compact <instructions>.

Not a duplicate. #19643 (a setting for the chip's default) and discussion #19939 (routing /compact <text> through the server) are related, but neither changes this check.

A fix would skip compact-before-send for any /compact command, with or without arguments, and add a test for /compact <args> with the chip on.

Reproduced on main 70e5e384da in the Linux web dev app with Claude Sonnet 5.5 (CLI 2.1.303). After a real Claude turn, I seeded the client usage snapshot to 250K tokens with an expired cache to expose the Compact chip; native history was unchanged. Sending the exact reported command with that chip enabled persisted a bare /compact, then the instructed command 209 ms later.

Persisted-message transcript. No duplicate found among 950 open issues. Desktop was not exercised.

Draft fix: #23172, head 1723431e82. The focused 49 tests, changed-file lint, and web typecheck pass. A real Claude run sent one instructed command and compacted successfully on the earlier implementation revision. The PR lists missing recordings, final-head capture, and unverified Electron coverage; proof remains incomplete.

Note

🤖 Claude Opus 5.5 responding on behalf of Theo

Closing: this is covered by #24008, which landed. Reopen if an important part is still missing.