Skip to content

feat: slash command scrolling & tab completion (SEA-170)#697

Open
fluxdiv wants to merge 4 commits into
06-22-sea-83from
06-24-sea-170
Open

feat: slash command scrolling & tab completion (SEA-170)#697
fluxdiv wants to merge 4 commits into
06-22-sea-83from
06-24-sea-170

Conversation

@fluxdiv

@fluxdiv fluxdiv commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Pull request

Summary

Adds keyboard-navigable slash command autocomplete to the TUI composer with inline ghost text and Tab/Enter to accept completions.

Related issues

Refs SEA-170

Changes

  • Slash command suggestion popup now highlights the currently selected row, navigable with Up/Down arrow keys
  • Inline ghost text renders after the cursor in a dim style, previewing the completion suffix with [hit \tab` to accept]`
  • Tab or plain Enter accepts the selected completion; Enter in paste mode inserts a newline instead
  • Exact command match on Enter dispatches the command rather than triggering completion
  • Selection index resets when the typed prefix changes and is clamped to the suggestion list size
  • Up arrow after typing command arguments moves the composer cursor to the start of the line
  • Slash command popup is suppressed when the path mention popup is open
  • Introduced SlashCommandCompletion struct carrying the replacement range, replacement text, and ghost text
  • Added slash_command_completion, slash_command_selection_key, and active_slash_command helpers in slash_commands.rs
  • Added layout_with_ghost to Composer to inject inline ghost text spans at the cursor position without a second layout walk

Test plan

  • slash_command_down_and_tab_accept_selected_completion: Down then Tab replaces prefix with full command
  • slash_command_enter_accepts_selected_completion: Down then Enter completes without dispatching
  • slash_command_enter_in_paste_mode_inserts_newline: Enter in paste mode does not complete
  • slash_command_up_after_command_args_moves_composer_cursor: Up with args present moves cursor to start
  • slash_command_enter_on_exact_match_still_dispatches: Exact match Enter dispatches the slash command action
  • slash_completion_renders_inline_ghost_text: Renderer test confirms ghost text appears after typed prefix
  • layout_with_ghost_inserts_text_after_cursor: Composer layout unit test confirms ghost span position and cursor column
  • completion_returns_replacement_and_ghost_text, completion_is_none_after_command_token, completion_is_none_inside_command_token, completion_is_none_for_exact_match: Unit tests for slash_command_completion edge cases

@linear-code

linear-code Bot commented Jun 24, 2026

Copy link
Copy Markdown

SEA-170

@coderabbitai

coderabbitai Bot commented Jun 24, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds slash-command completion state, completion lookup helpers, ghost-text composer layout, renderer selection highlighting, and app key handling for navigating or accepting completions. New tests cover completion resolution, ghost rendering, and popup behavior.

Changes

Slash-command completion UI

Layer / File(s) Summary
Completion contract and lookup
crates/seal-tui/src/slash_commands.rs
Adds completion data, cursor-aware activation, completion resolution, and related tests.
App state and popup keys
crates/seal-tui/src/app.rs
Adds completion selection state to ChatState, resyncs it after paste and key handling, and handles popup navigation and completion insertion.
Composer ghost text layout
crates/seal-tui/src/composer.rs
Adds layout_with_ghost and inline ghost-text insertion paths for wrapped and unwrapped composer layout.
Renderer integration
crates/seal-tui/src/renderer.rs
Passes completion ghost text into composer layout, suppresses it when path mentions are shown, highlights the selected suggestion row, and adds a rendering test.

Sequence Diagram(s)

Keyboard handling

sequenceDiagram
  participant User
  participant handle_key
  participant sync_slash_command_selection
  participant handle_slash_command_popup_keys
  participant slash_command_completion
  participant Composer

  User->>handle_key: paste or press popup key
  handle_key->>sync_slash_command_selection: resync selection key
  handle_key->>handle_slash_command_popup_keys: route Up / Down / Tab / Enter
  handle_slash_command_popup_keys->>slash_command_completion: resolve selected completion
  handle_slash_command_popup_keys->>Composer: insert completion or newline
Loading

Render-time ghost text

sequenceDiagram
  participant Renderer
  participant slash_command_completion
  participant Composer
  participant render_slash_command_suggestions

  Renderer->>slash_command_completion: compute ghost_text for current slash prefix
  Renderer->>Composer: layout_with_ghost(ghost_text)
  Renderer->>render_slash_command_suggestions: render selected row
Loading

Estimated review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Poem

I hopped by /re with a twitchy nose,
A ghost-text carrot in the cursor glows 🥕
Tab went thump, and Enter went bright,
My bunny paws approve this slashy light.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description check ✅ Passed The description is directly related to the changeset and accurately describes the autocomplete, ghost text, and key handling updates.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly matches the main change: slash command autocomplete with keyboard navigation and Tab completion.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 06-24-sea-170

Comment @coderabbitai help to get the list of available commands.

fluxdiv commented Jun 24, 2026

Copy link
Copy Markdown
Contributor Author

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • Merge Queue - adds this PR to the back of the merge queue
  • Merge Queue Fast Track - for urgent changes, fast-track this PR to the front of the merge queue

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has required the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@fluxdiv fluxdiv marked this pull request as ready for review June 24, 2026 22:15
@fluxdiv fluxdiv requested a review from mattwilkinsonn as a code owner June 24, 2026 22:15
@greptile-apps

greptile-apps Bot commented Jun 24, 2026

Copy link
Copy Markdown

Greptile Summary

This PR adds keyboard-navigable slash command autocomplete to the TUI composer: Up/Down navigate a highlighted suggestion popup, inline ghost text previews the completion suffix, and Tab or Enter accepts the selected item. An exact-match Enter falls through to dispatch the command rather than completing it, and the slash popup is suppressed when the path-mention popup is open.

  • slash_commands.rs: New SlashCommandCompletion struct and slash_command_completion / active_slash_command helpers drive selection and ghost-text generation; coverage is solid.
  • composer.rs: layout_with_ghost injects dim ghost-text spans at the cursor position without a second layout walk; chunk boundary logic and byte-to-char indexing are correct.
  • app.rs: Selection state and sync are wired into every key-handling path; insert_selected_slash_command_or_newline introduces a double-tick_paste_fsm issue on the exact-match Enter path (see inline comment).

Confidence Score: 4/5

Safe to merge with awareness of the exact-match Enter / paste-FSM interaction; fix before shipping to users who type rapidly or use terminal macros.

The new ghost-text layout and suggestion-list logic are well-tested and correct. The one issue is in insert_selected_slash_command_or_newline: it ticks the paste FSM and then, for an exact command match, returns None so the key re-enters handle_composer_keys, which ticks the FSM a second time. The sub-millisecond gap between the two ticks always qualifies as a rapid keystroke, so one extra paste_burst_count increment is added on every exact-match Enter — under the right pre-existing burst state this silently activates paste mode and inserts a newline instead of dispatching the command. No test covers this path with the FSM enabled.

crates/seal-tui/src/app.rs — specifically insert_selected_slash_command_or_newline and its interaction with the paste-detection FSM on the exact-match Enter path.

Important Files Changed

Filename Overview
crates/seal-tui/src/app.rs Adds slash command popup key handling, selection state, and sync; exact-match Enter path double-ticks the paste-detection FSM
crates/seal-tui/src/slash_commands.rs Adds SlashCommandCompletion struct, slash_command_completion, active_slash_command helpers, and selection key; logic and edge-case tests are thorough
crates/seal-tui/src/composer.rs Adds layout_with_ghost and push_text_with_inline_ghost for cursor-position ghost text injection; chunk boundary handling and byte/char indexing are correct
crates/seal-tui/src/renderer.rs Wires slash_command_selected into the suggestion popup renderer and routes ghost text into layout_with_ghost; selection highlight is bold-only on command name

Reviews (3): Last reviewed commit: "fix: fix `/reload` then down arrow not s..." | Re-trigger Greptile

Comment thread crates/seal-tui/src/app.rs Outdated
Comment thread crates/seal-tui/src/renderer.rs

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/seal-tui/src/app.rs`:
- Around line 523-529: The navigation handler in app.rs is returning early from
slash_command_completion before processing the key event, which prevents Down
from moving off an exact-match suggestion like /reload. Update the logic around
App::sync_slash_command_selection and slash_command_completion so the result is
not required for navigation handling; only use the completion outcome when
needed for rendering or selection state, and allow the match on key.code to
continue even when slash_command_completion returns None.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: d09df8ee-3ffa-4362-9625-f9768dac335a

📥 Commits

Reviewing files that changed from the base of the PR and between 413c93a and d50983f.

📒 Files selected for processing (4)
  • crates/seal-tui/src/app.rs
  • crates/seal-tui/src/composer.rs
  • crates/seal-tui/src/renderer.rs
  • crates/seal-tui/src/slash_commands.rs

Comment thread crates/seal-tui/src/app.rs
@sealedsecurity-ci

Copy link
Copy Markdown

Docs preview: https://06-24-sea-170.seal-docs.pages.dev

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

1 issue found across 2 files (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Fix all with cubic | Re-trigger cubic

Comment thread crates/seal-tui/src/app.rs
Comment thread crates/seal-tui/src/app.rs
@fluxdiv fluxdiv changed the title feat: slash command scrolling & tab completion feat: slash command scrolling & tab completion (SEA-170) Jun 24, 2026
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.

1 participant