fix(host-service): preserve consumed Claude prompts in handoffs

Merged
OW
2mo ago
+102-0

What & why

I found this while testing Claude Code inside Superset: if you send another instruction while Claude is busy, Claude can receive it and respond, but Superset leaves that instruction out of the conversation it passes to another agent.

For example, you might tell Claude to leave a particular file alone. If you later hand the work to another agent, that agent could receive Claude's response without your instruction to leave the file alone.

This fix keeps those instructions in the conversation Superset prepares for the next agent. Claude saves instructions received while busy in a different format, which Superset was skipping. The fix reads that format and includes instructions Claude has consumed; it excludes input that is only queued or has been removed.

How I tested it

  • Bun 1.3.14: 21 focused transcript tests pass.
  • The new consumed-follow-up regression fails against unchanged upstream main; the other 13 harness-reader tests pass there.
  • Replayed a native Claude Code 2.1.263 trace captured through Superset: main retains the response but omits the consumed follow-up; the candidate retains both. The same difference is verified through the shared handoff prompt builder.
  • Tests cover consumed prompt ordering, exclusion of queue-only records, unrelated attachments, empty and malformed prompt values, and existing transcript behavior.
  • Repository lint passes locally. All 11 exact-commit CI jobs pass: tests, terminal node-tests, typechecking, desktop build, lint/i18n/plugin checks, release checks, and four CLI builds.
  • CodeRabbit reviewed commit 89e57c310e3a74130e1c5d6784e2bc443cf669dd with no actionable comments.

The native trace was replayed through the reader and shared prompt builder. A live destination agent and the desktop handoff dialog were not exercised. No UI layout changes are included. Local broad typechecking was stopped under memory pressure; hosted CI runs the full checks. The separate preview deployment cannot run because this fork has no Neon API key.

Checklist

  • PR title follows conventional commits
  • One independently useful behavior; two files changed
  • Failing-before / passing-after evidence
  • Full repository validation complete in exact-commit hosted CI

Validated against upstream main at b4e5d618e5f44309b80f735a7a3448cb3681089a.


Summary by cubic

Fixes Claude Code handoffs dropping prompts received while Claude was busy, so the next agent now sees those instructions in the conversation.

  • Reads consumed busy-session prompts from queued_command attachments.
  • Still excludes input that was only queued, removed, or malformed.

Summary by CodeRabbit

  • Bug Fixes

    • Claude conversation transcripts now preserve valid queued follow-up prompts in the correct order.
    • Non-prompt commands, unrelated attachments, blank or null prompts, and malformed prompt entries are excluded from transcripts.
    • Transcript history more accurately reflects the conversation by including only valid user prompts and relevant assistant exchanges.
  • Tests

    • Added regression coverage for queued follow-up handling, conversation ordering, and transcript filtering.