Skip to content

Claude provider: /clear and /new slash commands don't clear h-code context #54

@harrryyd

Description

@harrryyd

Problem

When using the Claude Code provider, typing /clear or /new in the composer sends the command through to Claude CLI (which natively handles them), but h-code does not observe the context-clearing event and does not clear its own conversation history.

Steps to reproduce

  1. Start a thread with Claude Code provider
  2. Have a multi-turn conversation
  3. Type /clear and send it
  4. Observe the UI still shows all prior messages
  5. Follow up with a new message — Claude CLI has no prior context, but h-code still renders the full history

Root cause

  • /clear and /new are sent to Claude CLI as regular user messages. Claude CLI clears its internal context and returns a result.
  • The Claude adapter (ClaudeAdapter.ts) treats the turn like any other — it calls completeTurn() and moves on. It does not inspect result messages for context-cleared semantics.
  • h-code independently stores and displays turn history. It never learns that the provider cleared its context.

Expected behavior

Options (needs discussion):

  1. Client-side interception: Treat /clear and /new like /plan / /default — intercept before sending, and create a new thread (or clear turns from the current thread).
  2. Server-side sync: Have the Claude adapter detect when Claude CLI clears context (via result message subtype or system message) and emit a domain event that clears stored turns.
  3. Both: Intercept client-side for immediate UI feedback + server-side sync as a safety net.

Area

  • apps/server/src/provider/Layers/ClaudeAdapter.tssendTurn, handleResultMessage, handleSystemMessage
  • apps/web/src/composer-logic.tsparseStandaloneComposerSlashCommand
  • apps/web/src/components/ChatView.tsxonSend message dispatch

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-refiningNeeds human refinement before agent execution

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions