[BUG] Slash command typed during a pending background-task notification renders twice (echo + dispatch), looks like /compact ran twice

Status Open
Reported on v2.1.217
Maintainer reply None cached
Activity 0 comments · opened Jul 25, 2026

What's Wrong?

In a long-running session that receives background task notifications (for example a persistent Monitor task), typing /compact while a notification turn is pending produces a confusing double render:

  1. The typed > /compact bar is echoed immediately.
  2. The queued notification turn is processed first (the assistant responds to the background event).
  3. The queued /compact then dispatches, and the CLI renders a second, identical > /compact bar, followed by the actual compaction output.

The user sees two /compact command bars with an assistant turn between them, and reasonably concludes the command was issued twice or that compaction ran twice. The first bar carries no "queued" indicator in this path, and only the second bar carries the "Compacted" result.

The session transcript proves the command executed exactly once per keypress. Accounting across 7 manual compactions in one session: 7 user command events, 7 compact_boundary entries (all trigger: "manual"), 7 "Compacted" stdout confirmations. The command event is written at dispatch time, and compactMetadata.durationMs spans dispatch to boundary exactly.

Example timeline from the transcript (UTC):

  • 19:11:00 the assistant turn for the queued background notification ends (stop_hook_summary); the user had typed /compact around this window and its bar was already rendered
  • 19:11:50 the queued /compact dispatches: user command event written, second bar rendered, compaction starts
  • 19:14:38 compact_boundary written (durationMs 166809 matches 19:11:50 to 19:14:38 to the second)

What Should Happen?

Either render the queued command once (at dispatch time only), or clearly mark the first render as queued (dimmed or a "queued" badge) so the second render is recognizable as the same command reaching execution, not a new invocation.

Steps to Reproduce

  1. Run a long session with a background task that posts task notifications (for example a persistent Monitor watching a file).
  2. Type /compact while a notification turn is pending (easiest to hit when notifications arrive frequently).
  3. Observe: the command bar renders at type time, the notification turn runs, then the same command re-renders at dispatch and executes once.

Related (checked, different shapes)

  • #17808: re-compaction after exiting and claude --continue
  • #55293: assistant response duplicated in scrollback after compaction (closed as duplicate)

Claude Code Version

2.1.217

Platform

Claude Max (claude.ai login)

Operating System

Linux

Terminal/Shell

bash, daemon-managed background session attached in the terminal UI

View original on GitHub ↗