Skip to content

feat: add SlashCommand descriptor registry#131

Draft
yamaceay wants to merge 3 commits into
stippi:mainfrom
yamaceay:feat/slash-command-descriptors
Draft

feat: add SlashCommand descriptor registry#131
yamaceay wants to merge 3 commits into
stippi:mainfrom
yamaceay:feat/slash-command-descriptors

Conversation

@yamaceay

@yamaceay yamaceay commented Jun 10, 2026

Copy link
Copy Markdown

Context

PR 1 of 5 — slash-command autocomplete series.

Dependency / merge order:

#136 (gpui optional feature, already open) → #131 → #132 → #133 → #134 → #135

Each PR in this series is self-contained and reviewable on its own. They stack
on top of feat/optional-gpui-feature (the TUI-only build fix), which must
land in main first.


Why

The slash-command processor handled commands as raw string matches with no
machine-readable metadata attached. Adding an autocomplete popup (PR #134)
needs to enumerate all available commands at runtime — their names, aliases,
and human-readable descriptions — without duplicating the list in a second
place.

This PR is a pure data-model prerequisite: no behaviour change whatsoever.

What

commands.rs — only file changed.

  • New SlashCommand struct with name, aliases, and description fields
    (all &'static str / &'static [&'static str]).
  • New all_commands() -> &'static [SlashCommand] function that returns a static
    slice of every registered command. This becomes the single source of truth
    for command discovery across the codebase.
  • get_help_text() now iterates all_commands() instead of a hardcoded string,
    so the help output stays in sync automatically when new commands are added.

Scope

commands.rs only. No runtime behaviour change.

Test plan

yamaceay added 2 commits June 11, 2026 10:40
The GPUI desktop UI depends on Metal shader compilation, which requires
Xcode developer tools to be installed (xcrun must find the `metal` binary).
On machines without Xcode this hard-blocked every `cargo build`, even when
only the terminal TUI was needed.

Introduce a `gpui-ui` Cargo feature that gates all GPUI-related code:

- `Cargo.toml`: `gpui`, `gpui_platform`, and `gpui-component` are now
  optional dependencies, activated only by `--features gpui-ui`.
  The gpui entry in `[dev-dependencies]` is removed (it was unused in
  the unit-test suite).

- `src/app/mod.rs`, `src/ui/mod.rs`: `pub mod gpui` gated behind
  `#[cfg(feature = "gpui-ui")]`.

- `src/ui/backend.rs`: The `GpuiTerminalCommandExecutor` import and its
  single usage site are gated; the TUI-only path falls back to
  `DefaultCommandExecutor` (which `GpuiTerminalCommandExecutor` itself
  delegates to internally).

- `src/main.rs`: The `--ui` code paths (logging setup, model resolution,
  `app::gpui::run()`) are gated.  Passing `--ui` without the feature
  produces a clear error message rather than a linker crash.

- `src/cli.rs`: The `UiSettings::load()` call that reads the GPUI-
  persisted default model is gated; TUI-only builds fall through to the
  alphabetical-first-model fallback.

Build commands:
  # TUI only (no Xcode required):
  cargo build --no-default-features

  # With GPUI desktop UI (requires Xcode / Metal):
  cargo build --features gpui-ui
Introduce a `SlashCommand` struct (name, aliases, description) and an
`all_commands()` function that returns a static slice of all registered
commands.  This gives the rest of the codebase — in particular the
upcoming autocomplete popup — a single, authoritative place to discover
what slash commands exist, without needing to duplicate the match arms
in `process_command`.

The help text is now derived from the registry instead of being a hard-
coded string, so adding a new command in one place is sufficient.

No behavior change: all existing commands keep the same names, aliases,
and runtime behaviour.

@stippi stippi left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work. Will just check on the comment below.

Comment thread crates/code_assistant/Cargo.toml
Comment thread crates/code_assistant/Cargo.toml Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants