Skip to content

bug(web): slash command autocomplete swallows args — Enter after "/cmd arg" replaces input with /cmd #748

@swear01

Description

@swear01

What version of HAPI is running?

main (verified at 1f1e5f3)

What platform is your computer?

Linux x86_64, browser web UI (also reproduces on PWA)

What issue are you seeing?

The slash-command autocomplete in the web composer treats anything after /cmd as if the user were still typing the command name, so pressing Enter replaces the entire input with the suggested command and the args are lost.

Concretely, with a HAPI Codex or OpenCode session:

  1. Open the composer.
  2. Type /plan off (or /permissions yolo, /model auto, etc. — any builtin slash command that takes an argument).
  3. Press Enter to send.

Expected: the message /plan off is sent to the agent; the slash resolver applies the off argument.

Actual: the composer replaces the input with /plan (the highlighted suggestion) instead of sending. The user has to dismiss the suggestion box (Escape) first, then press Enter again.

The same problem happens for any slash command that accepts arguments — Codex's /plan off, /permissions yolo, /model gpt-5.4, and the equivalent OpenCode commands all reproduce it.

Root cause

The composer treats Enter as "accept the highlighted suggestion" whenever the suggestion list is open. The suggestion list stays open while typing args because findActiveWord treats the entire /cmd args as one active word:

  • web/src/utils/findActiveWord.ts:60-66 — for non-@ prefixes, findActiveWordStart returns the prefix position even when the cursor is several spaces past the slash command, so the active word becomes e.g. /plan off.
  • web/src/hooks/queries/useSlashCommands.ts:82-105 — the query text /plan off then fuzzy-matches /plan (Levenshtein 4, within maxDistance), so /plan stays in the suggestion list.
  • web/src/components/AssistantChat/HappyComposer.tsx:329-334 — with a suggestion visible, Enter always selects it instead of sending. The input is replaced with /plan, dropping off.

This affects all agents (Claude, Codex, Gemini, OpenCode, Cursor) since the composer behaviour is shared.

Suggested fix

Two reasonable scopes:

  1. Small fix: make findActiveWord return undefined (or only the current word, without the slash prefix) once the cursor has moved past a space following a /-prefixed token. That keeps the composer from offering /plan as a completion while the user is typing args, so Enter sends as usual.
  2. Bigger UX win: turn the suggestion popup into an argument suggestion box once the user is past the command name — show the expected arg shape (e.g. off | default | exit, or default | plan | yolo). The slash command list could declare arg specs alongside name / description. This needs a small schema bump on SlashCommand.

If the maintainers prefer (2), I'm happy to take a stab — file this issue first to confirm direction.

Repro env

  • HAPI hub & runner from source, branch main (commit 1f1e5f3)
  • Web served by the hub at port 43006
  • Browser: Chromium / Firefox, both reproduce

Additional information

Discovered while working on #671 (OpenCode slash commands). The behaviour is not OpenCode-specific — Codex's existing /plan off, /permissions yolo etc. have the same issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions