Skip to content

Enhance Shell V2 with completion, history search, and robust input handling#1816

Merged
KCarretto merged 2 commits intofeat/shellv2from
feature/shellv2-enhancements-15701777579932583425
Feb 16, 2026
Merged

Enhance Shell V2 with completion, history search, and robust input handling#1816
KCarretto merged 2 commits intofeat/shellv2from
feature/shellv2-enhancements-15701777579932583425

Conversation

@KCarretto
Copy link
Collaborator

This PR enhances the Shell V2 (Headless REPL) with a more robust and feature-rich terminal experience.

Key Changes:

  1. Responsive Design: Integrated xterm-addon-fit to ensure the terminal automatically resizes to fill its container.
  2. Advanced Input Handling:
    • Navigation: Arrow keys, Home (Ctrl+A), End (Ctrl+E).
    • Editing: Backspace, Delete Word (Ctrl+W), Clear Line (Ctrl+U).
    • History: Up/Down arrows to navigate command history.
    • Search: Reverse history search (Ctrl+R).
    • Control: Clear Screen (Ctrl+L), Reset/Cancel (Ctrl+C).
  3. Auto-Completion:
    • Pressing Tab now triggers completion.
    • If multiple options exist, a dropdown menu appears at the cursor location (simulated).
    • Selection via Enter or Tab cycling.
    • Backend updated to return start index for correct suffix replacement.
  4. Backend Updates:
    • Exposed reset() in HeadlessRepl to support Ctrl+C.
    • Updated complete() signature for better frontend integration.

Verification:

  • eldritch-wasm tests passed.
  • Frontend builds successfully.
  • Manual/Visual verification of terminal rendering via Playwright screenshot.

PR created automatically by Jules for task 15701777579932583425 started by @KCarretto

…arch, and resizing

- Frontend:
    - Added `xterm-addon-fit` for responsive terminal resizing.
    - Implemented shell state management (input buffer, cursor, history).
    - Added key bindings: Ctrl+C (reset), Ctrl+L (clear), Ctrl+A/E (home/end), Ctrl+U/W (delete line/word).
    - Implemented Tab completion with a custom dropdown UI overlay.
    - Implemented Ctrl+R for basic reverse history search.
    - Updated `HeadlessWasmAdapter` to support `reset()` and structured completion results.

- Backend (`eldritch-wasm`):
    - Added `HeadlessRepl::reset()` to clear the internal buffer.
    - Updated `HeadlessRepl::complete()` to return `{ suggestions: [...], start: usize }` instead of a flat list, enabling correct inline replacement.
    - Added tests for reset and completion structure.
    - Rebuilt WASM artifacts with `fake_bindings` feature.

Co-authored-by: KCarretto <16250309+KCarretto@users.noreply.github.com>
@google-labs-jules
Copy link
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

- **Cursor Flicker:** Optimized `redrawLine` to avoid clearing the entire line (including prompt) and rewrite only the input buffer using `\r` + content + `\x1b[K`. Added fast-path logic in `onData` for appending characters or backspacing at the end of the line, bypassing `redrawLine` entirely for the most common typing scenarios.
- **Tab Indenting:** Updated Tab handler to insert 4 spaces if the input buffer is empty or consists only of whitespace, enabling standard indentation behavior.
- **Function Termination:** Ensured `state.prompt` is reset to `>>> ` when a command returns `"complete"` status, fixing an issue where the prompt would remain `.. ` after finishing a multi-line function definition.

Co-authored-by: KCarretto <16250309+KCarretto@users.noreply.github.com>
@KCarretto KCarretto marked this pull request as ready for review February 16, 2026 18:43
@KCarretto KCarretto merged commit 1cd4451 into feat/shellv2 Feb 16, 2026
@KCarretto KCarretto deleted the feature/shellv2-enhancements-15701777579932583425 branch February 16, 2026 18:43
github-merge-queue bot pushed a commit that referenced this pull request Feb 17, 2026
* Implement Headless REPL Architecture with WASM and Shell V2 UI (#1811)

* Implement Headless REPL Architecture with WASM and Shell V2 UI

- Add `HeadlessRepl` to `eldritch-wasm` for input buffering and parsing.
- Create `headless-adapter.ts` for frontend WASM/WebSocket integration.
- Implement `/shellv2` page with xterm.js.
- Add `/shellv2/ws` dummy backend route.
- Fix WASM build dependencies in `eldritch` libraries.

Co-authored-by: KCarretto <16250309+KCarretto@users.noreply.github.com>

* Implement Headless REPL with WASM, Shell V2 UI, Indentation, and Autocompletion

- Add `HeadlessRepl` struct to `eldritch-wasm` with input buffering and fake library bindings for completion.
- Create `HeadlessWasmAdapter` in frontend to bridge WASM and WebSocket.
- Implement `/shellv2` page using xterm.js with support for indentation (Tab key) and autocompletion display.
- Add dummy backend route `/shellv2/ws` in `tavern` for echo testing.
- Update build scripts to deploy WASM artifacts to public assets.
- Fix dependencies in `eldritch` libraries for WASM compatibility.

Co-authored-by: KCarretto <16250309+KCarretto@users.noreply.github.com>

---------

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Co-authored-by: KCarretto <16250309+KCarretto@users.noreply.github.com>

* Enhance Shell V2 with completion, history search, and robust input handling (#1816)

* Implement enhanced Shell V2 features: completion dropdown, history search, and resizing

- Frontend:
    - Added `xterm-addon-fit` for responsive terminal resizing.
    - Implemented shell state management (input buffer, cursor, history).
    - Added key bindings: Ctrl+C (reset), Ctrl+L (clear), Ctrl+A/E (home/end), Ctrl+U/W (delete line/word).
    - Implemented Tab completion with a custom dropdown UI overlay.
    - Implemented Ctrl+R for basic reverse history search.
    - Updated `HeadlessWasmAdapter` to support `reset()` and structured completion results.

- Backend (`eldritch-wasm`):
    - Added `HeadlessRepl::reset()` to clear the internal buffer.
    - Updated `HeadlessRepl::complete()` to return `{ suggestions: [...], start: usize }` instead of a flat list, enabling correct inline replacement.
    - Added tests for reset and completion structure.
    - Rebuilt WASM artifacts with `fake_bindings` feature.

Co-authored-by: KCarretto <16250309+KCarretto@users.noreply.github.com>

* Fix Shell V2 cursor flicker, tab indent, and function termination

- **Cursor Flicker:** Optimized `redrawLine` to avoid clearing the entire line (including prompt) and rewrite only the input buffer using `\r` + content + `\x1b[K`. Added fast-path logic in `onData` for appending characters or backspacing at the end of the line, bypassing `redrawLine` entirely for the most common typing scenarios.
- **Tab Indenting:** Updated Tab handler to insert 4 spaces if the input buffer is empty or consists only of whitespace, enabling standard indentation behavior.
- **Function Termination:** Ensured `state.prompt` is reset to `>>> ` when a command returns `"complete"` status, fixing an issue where the prompt would remain `.. ` after finishing a multi-line function definition.

Co-authored-by: KCarretto <16250309+KCarretto@users.noreply.github.com>

---------

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Co-authored-by: KCarretto <16250309+KCarretto@users.noreply.github.com>

* feat(shellv2): improve REPL history, autocomplete and redraw (#1817)

- Fix duplicated prompt on Ctrl+L by using explicit ANSI clear+home sequence.
- Implement multi-line history support by accumulating input blocks until complete.
- Improve autocomplete: trigger on '.', allow typing while open, and fix looping index.
- Refactor redrawLine to support multi-line buffers.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Co-authored-by: KCarretto <16250309+KCarretto@users.noreply.github.com>

* Fix ShellV2 REPL: reverse search, indentation, and scrolling (#1819)

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Co-authored-by: KCarretto <16250309+KCarretto@users.noreply.github.com>

* default font size and rebuild

* slight cleanup

* npm run build

* cargo fmt

---------

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Co-authored-by: KCarretto <16250309+KCarretto@users.noreply.github.com>
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