Skip to content

fix(terminal): route quicktools inserts to active terminal(if opened)#2015

Merged
bajrangCoder merged 2 commits intoAcode-Foundation:mainfrom
bajrangCoder:fix/terminal-quicktools-insert
Apr 6, 2026
Merged

fix(terminal): route quicktools inserts to active terminal(if opened)#2015
bajrangCoder merged 2 commits intoAcode-Foundation:mainfrom
bajrangCoder:fix/terminal-quicktools-insert

Conversation

@bajrangCoder
Copy link
Copy Markdown
Member

No description provided.

@UnschooledGamer
Copy link
Copy Markdown
Member

Nice, I was also checking about it.

GGs.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Apr 6, 2026

Greptile Summary

This PR routes quicktools text insertions (button presses and keyboard input) to the active terminal when a terminal tab is open, instead of always targeting the code editor. It adds getActiveTerminalComponent, getActiveTerminalInput, and insertText helpers, fixes focusEditor to handle terminal tabs and null-safe activeFile access, and adds optional-chaining guards to resetKeys. It also widens the shift-key input path to correctly skip transformation when alt or meta modifiers are active.

Key changes:

  • New insertText helper routes text to terminal.paste() (preferred), falls back to WebSocket write in server mode, or falls through to editor.insert() for code files.
  • setInput now detects a terminal tab and sets the xterm.js textarea as the active input target.
  • focusEditor was inverted (was if (activeFile.focused), now if (!activeFile?.focused) return) and extended to call terminalComponent.focus() for terminal tabs.
  • resetKeys uses input?.focus?.() to avoid crashing when input is not yet set.
  • One minor regression: insertText returns editor.insert(text) (which is undefined) rather than true for the editor path, silently changing the return contract of actions('insert', value)."

Confidence Score: 4/5

Mostly safe to merge; one minor return-value regression in the editor insert path should be addressed.

The core terminal routing logic is sound and well-guarded. The only new finding is a P2 return-value change in the editor insert path (undefined instead of true), which does not affect current callers but breaks the existing return contract. Prior P1 findings from the previous review thread remain open (local PTY write vs display buffer, shift-key transformation in the insert action path). With those open threads, 4/5 is appropriate.

src/handlers/quickTools.js — insertText return value for editor path (line 754), and the previously flagged local terminal paste path.

Important Files Changed

Filename Overview
src/handlers/quickTools.js Adds terminal-aware text insertion routing and fixes focusEditor/resetKeys null-safety; one minor return-value regression in the editor insert path.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["actions('insert', value) / input event"] --> B["insertText(text)"]
    B --> C{Active terminal tab?}
    C -- Yes --> D{terminal.paste available?}
    D -- Yes --> E["terminal.paste(text) ✅ PTY input"]
    D -- No --> F{serverMode && isConnected?}
    F -- Yes --> G["terminalComponent.write(text) WebSocket"]
    F -- No --> H["return false ❌ (local mode, no insert)"]
    C -- No --> I{editor available?}
    I -- Yes --> J["editor.insert(text)"]
    I -- No --> K["return false"]
Loading

Reviews (2): Last reviewed commit: "fix" | Re-trigger Greptile

@bajrangCoder
Copy link
Copy Markdown
Member Author

@greptileai

@bajrangCoder bajrangCoder merged commit c143385 into Acode-Foundation:main Apr 6, 2026
7 checks passed
@bajrangCoder bajrangCoder deleted the fix/terminal-quicktools-insert branch April 6, 2026 17:59
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