Skip to content

Feature request: trigger slash command palette at any caret position, not only at input start #319

Description

@ffftttft

Problem

The slash command palette only opens when the entire input starts with / and contains no whitespace:

  • Palette query: value.startsWith("/") && !/\s/.test(value.slice(1)) in components/ChatInput.tsx
  • Built-in command dispatch also only fires when the message starts with /

This means you can't describe your task first and then attach a skill. In Codex CLI / Claude Code, a common flow is:

refactor the auth module to use refresh tokens /my-skill

…where typing / after a space (or anywhere at the caret) opens the skill palette, and selecting a skill inserts the command at the caret. In pi-web today that flow is impossible — you have to open the palette first, before typing anything.

Proposal

Make the slash trigger caret-based, mirroring how the @ file autocomplete already works in the same component ("recomputed from the text before the caret on every change/caret move"):

  1. Detect a / token at the caret — i.e. / at position 0, or preceded by whitespace, and the token up to the caret contains no whitespace.
  2. Open the palette anchored to that token; filter as the user keeps typing within the token.
  3. On select, replace only the /query token at the caret with the chosen command, preserving the surrounding text.
  4. Keep the existing start-of-input behavior unchanged (it becomes a special case of the above).

Open question: should built-in command dispatch (onBuiltinCommand) also accept mid-message /command, or stay start-of-message only? I'd lean toward keeping dispatch as-is (start only) and only widening the palette trigger — inserting a skill mid-text expands to text the model sees, which matches CLI behavior.

Notes

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