feat: add SlashCommand descriptor registry#131
Draft
yamaceay wants to merge 3 commits into
Draft
Conversation
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.
7b260b0 to
4b4a221
Compare
This was referenced Jun 11, 2026
stippi
reviewed
Jun 11, 2026
stippi
reviewed
Jun 11, 2026
stippi
approved these changes
Jun 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
PR 1 of 5 — slash-command autocomplete series.
Dependency / merge order:
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 mustland in
mainfirst.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.SlashCommandstruct withname,aliases, anddescriptionfields(all
&'static str/&'static [&'static str]).all_commands() -> &'static [SlashCommand]function that returns a staticslice of every registered command. This becomes the single source of truth
for command discovery across the codebase.
get_help_text()now iteratesall_commands()instead of a hardcoded string,so the help output stays in sync automatically when new commands are added.
Scope
commands.rsonly. No runtime behaviour change.Test plan
cargo build --no-default-featurespasses (no Xcode / Metal required)./helpin the TUI still lists all commands correctly.all_commands()is callable from outside the module (needed by PR feat: wire autocomplete state and input handling #134).