feat(codegraff): wire all REPL tiers into TUI dispatcher (Tiers 2-7 of #22)#24
Closed
justrach wants to merge 4 commits into
Closed
feat(codegraff): wire all REPL tiers into TUI dispatcher (Tiers 2-7 of #22)#24justrach wants to merge 4 commits into
justrach wants to merge 4 commits into
Conversation
Adds a fuzzy slash command palette to the codegraff TUI. Typing `/` when the composer is empty opens a centered overlay listing all slash commands ported from graff's REPL AppCommand enum, plus codegraff-specific commands (/workflow, /image, /logs, etc.). Implementation notes: - New Overlay::CommandPalette variant with CommandPaletteState (query + selected_index) lives next to the existing overlay types in main.rs to avoid risky refactors. - Static PALETTE_COMMANDS table holds (name, description). The list mirrors crates/forge_main/src/model.rs, excluding REPL-only entries (:exit, :edit, :retry). - Fuzzy ranking uses the workspace `nucleo` dep (already declared in Cargo.toml). Items with score 0 are filtered out; ties preserve catalogue order. - `dispatch_command_palette` writes "/<name>" into self.composer and reuses the existing handle_enter dispatch path, so commands like /workflow keep their parser unchanged. - Keybindings: Up/Down navigate, Tab autocompletes, Enter dispatches, Esc closes, Backspace deletes (closes when query empty), any other char appends to the query. - Render path calls Clear over the overlay rect; full-frame Clear at the top of render() prevents close artifacts. overlay_area is recomputed each frame, so resize re-clamps automatically. Tests cover empty-query catalogue, fuzzy match, zero-score filter, catalogue uniqueness, REPL-only exclusion, and rendered line content. All 118 codegraff bin tests pass; clippy and release build are clean. Closes #17 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…utes Pre-merge review caught that ~30 entries in PALETTE_COMMANDS exposed commands the codegraff TUI dispatcher does not yet handle locally (`/new`, `/info`, `/agent`, `/commit`, `/dump`, `/skill`, `/tools`, `/copy`, `/clone`, `/conversation*`, `/workspace-*`, `/index`, `/update`, `/compact`, `/sage`, `/help`, `/plan`, `/act`, `/rename`, `/fast`, `/config-*`, `/suggest`, etc.). Selecting any of those from the palette would silently send the literal slash text to the LLM as a chat message, which is strictly worse UX than not exposing them. Restrict the palette to the 8 commands `handle_enter` does route: `/connect`, `/image`, `/login`, `/logs`, `/model`, `/models`, `/usage`, `/workflow`. Wiring the rest into the TUI dispatcher is tracked in a follow-up issue under the parity tracker. Also tighten `palette_command_names_are_unique_and_lowercase` to actually assert lowercase (it didn't before — name was misleading) and add a sanity test confirming every locally-handled command is in the palette so the dispatcher stays in sync. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adds local handlers for the three highest-traffic Tier 1 commands from the parity tracker (#22), plus the corresponding palette entries: - `/new` — calls `Conversation::generate()` + `upsert_conversation`, then resets transcript, image attachments, pending pastes, usage, and any in-flight workflow. Active model is preserved. - `/info` — pushes status entries for active agent, model label, conversation id, and log path. TUI equivalent of the REPL `:info` Info widget. - `/help` — opens the command palette (the discovery surface). Cheap alias so `/help` does the natural thing in a TUI. The `palette_includes_locally_handled_commands` test is updated to require these three names. This keeps PALETTE_COMMANDS in lockstep with handle_enter — no ghost commands. Remaining tiers (agent switching, conversation management, config, workspace, git) tracked in #22. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Closes Tiers 2-7 of #22. Adds 32 new slash commands to the codegraff TUI dispatcher with full PALETTE_COMMANDS coverage and matching test entries. Rough split: - Tier 2 (agent switching): /act, /plan, /sage, /agent. /agent without args lists available agents; with arg switches. - Tier 3 (conversation): /conversation(s), /rename, /conversation-rename, /dump (json or --html), /compact. /clone and /copy are deferred with helpful status messages. - Tier 4 (config): /config, /config-edit (opens $EDITOR on ~/forge/.forge.toml), /fast (toggle), /reasoning-effort and /config-reasoning-effort (arg form), /config-model, /config-commit-model, /config-suggest-model (provider resolved from current session). /config-reload deferred. - Tier 5 (workspace + tools): /workspace-sync, /sync, /index, /workspace-status, /workspace-info, /workspace-init, /skill, /tools, /suggest. - Tier 6 (git): /commit, /commit-preview. - Tier 7 (admin): /logout (removes default provider creds), /update (runs the install script). Adds chrono, dirs, serde_json to the codegraff-tui Cargo.toml; all are already in workspace deps. New code shares the same pattern as the existing /usage / /new / /info handlers. Note: most workspace + tools handlers print debug-formatted results (using {:?}) for now; richer rendering can land as follow-ups under the parity tracker. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Owner
Author
|
Superseded by a rebased branch — see new PR. Stack reshuffle after squash-merging palette base. |
3 tasks
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.
Summary
Closes Tiers 2-7 of #22. Stacks on PR #23 (Tier 1).
Adds 32 new slash commands to the codegraff TUI dispatcher with full PALETTE_COMMANDS coverage. PR is one big commit because the changes are mechanical — same handler pattern repeated, all touching the same
main.rs.Wired commands (functional)
Tier 2 — agent switching
/act,/plan,/sage— direct switches viaset_active_agent/agent(no arg lists,/agent <id>switches)Tier 3 — conversation management
/conversation//conversations— list viaget_conversations/rename <title>,/conversation-rename <title>—rename_conversation/compact—compact_conversation/dump(--htmlfor HTML wrapper) — serialize to~/forge/dumps/<id>-<ts>.<ext>Tier 4 — config
/config— print effective session config/config-edit— open~/forge/.forge.tomlin$EDITOR/$FORGE_EDITOR/fast— toggle Priority Processing/reasoning-effort <level>,/config-reasoning-effort <level>— set effort/config-model <id>,/config-commit-model <id>,/config-suggest-model <id>— arg-form setters; provider resolved from current session configTier 5 — workspace + tools
/workspace-sync//sync,/index—sync_workspace, consume progress stream/workspace-status//sync-status—get_workspace_status/workspace-info//sync-info—get_workspace_info/workspace-init//sync-init—init_workspace/skill//skills—get_skills/tools—get_tools/suggest <description>—generate_commandTier 6 — git
/commit-preview,/commit—commit(preview, ...)Tier 7 — admin
/logout—remove_providerfor the default provider/update— runs install script viaexecute_shell_command_rawDeferred with helpful status messages
/clone— no API method available; user routed to graff REPL:clone./copy— Context message-walker not threaded into the TUI; deferred with hint to use terminal selection or graff REPL:copy./config-reload— no clean reload API; user told to restart codegraff.Tests
cargo test -p codegraff --bin codegraff palette— 8 tests pass.palette_includes_locally_handled_commandsrequires all 43 commands to be in PALETTE_COMMANDS (catches drift between dispatcher and palette).Test plan
/→ palette shows all 43 commands, fuzzy filter works/act,/plan,/sage→ status entry confirms agent switch/agent(no arg) → lists agents;/agent forgeswitches/conversation→ lists workspace conversations/rename hello→ renames; verify/conversationshows new title/dump→ JSON file written to~/forge/dumps/;/dump --htmlwraps in HTML/compact→ status entry shows compaction result/config→ effective config printed/fast→ toggles, status confirms/reasoning-effort high→ status confirms/skill,/tools,/suggest list files→ outputs printed/commit-preview→ message preview without committing/clone,/copy,/config-reload→ helpful "deferred, see Wire remaining REPL commands into codegraff TUI handle_enter #22" statusOut of scope
🤖 Generated with Claude Code