Skip to content

feat(terminal): add touch selection "More" menu API and wire select dialog#1905

Merged
bajrangCoder merged 2 commits intoAcode-Foundation:mainfrom
bajrangCoder:feat/terminal-touch-more-options-api
Feb 26, 2026
Merged

feat(terminal): add touch selection "More" menu API and wire select dialog#1905
bajrangCoder merged 2 commits intoAcode-Foundation:mainfrom
bajrangCoder:feat/terminal-touch-more-options-api

Conversation

@bajrangCoder
Copy link
Member

@bajrangCoder bajrangCoder commented Feb 26, 2026

Fixes: #1835

Implements the terminal touch-selection More action and exposes a plugin-facing API to add/remove/list menu options.

Plugin API

Available via:

  • acode.require("terminal").moreOptions.add(option)
  • acode.require("terminal").moreOptions.remove(id)
  • acode.require("terminal").moreOptions.list()

Alias:

  • acode.require("terminal").touchSelection.moreOptions.add/remove/list

option shape:

  • id?: string
  • label | text | title: string | (context) => string
  • icon?: string
  • enabled?: boolean | (context) => boolean
  • action | onselect | onclick: (context) => void | Promise<void>

context includes:

  • terminal
  • touchSelection
  • selection
  • helpers: clearSelection, copySelection, pasteFromClipboard, selectAll

@github-actions github-actions bot added the enhancement New feature or request label Feb 26, 2026
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 26, 2026

Greptile Summary

Implements a plugin-facing "More" menu API for terminal touch selection. Plugins can register/remove/list custom menu options via acode.require("terminal").moreOptions, and the built-in "Select All" action is wired as the default entry. The showMoreOptions stub is replaced with a real select dialog, and showContextMenu is refactored for null-safety to support the selectAllText() flow (which nullifies selection coordinates).

  • Adds a Map-backed option registry with validation, normalization, and label/enabled resolvers
  • Wires the select dialog to display and execute registered options, with proper error handling
  • Exposes the API through TerminalManager instance methods and acode.js module definitions
  • Regression: The showContextMenu positioning refactor drops the logic that flips the menu above the selection when it would overflow the bottom of the container, which can cause the menu to overlap selected text

Confidence Score: 3/5

  • PR is generally safe but contains a positioning regression that may impact usability for selections near the bottom of the terminal
  • The new API is well-designed with thorough input validation, defensive error handling, and proper context isolation. However, the showContextMenu refactor introduces a positioning regression by removing the "flip above selection" overflow logic, which could cause the context menu to overlap selected text at the bottom of the terminal.
  • src/components/terminal/terminalTouchSelection.js — the showContextMenu positioning logic needs the overflow-flip behavior restored

Important Files Changed

Filename Overview
src/components/terminal/terminalTouchSelection.js Core implementation of the "More" menu API. Adds static registry (Map-backed), normalization, context builder, select-dialog wiring, and selectAllText(). Positioning refactor in showContextMenu introduces a regression by dropping the "flip above selection" logic for bottom-overflow cases.
src/components/terminal/terminalManager.js Thin pass-through wrapper: adds three instance methods delegating to TerminalTouchSelection static methods. Clean and correct.
src/lib/acode.js Exposes the new moreOptions API on the terminal module (with an alias at touchSelection.moreOptions). Consistent with existing patterns in the file.

Sequence Diagram

sequenceDiagram
    participant Plugin
    participant Acode as acode.js (terminal module)
    participant TM as TerminalManager
    participant TTS as TerminalTouchSelection (static)
    participant Map as terminalMoreOptions Map
    participant Dialog as select dialog

    Note over Plugin,Map: Registration Flow
    Plugin->>Acode: moreOptions.add(option)
    Acode->>TM: addTouchSelectionMoreOption(option)
    TM->>TTS: addMoreOption(option)
    TTS->>TTS: ensureDefaultMoreOption()
    TTS->>TTS: normalizeMoreOption(option)
    TTS->>Map: set(id, normalized)
    TTS-->>Plugin: id

    Note over Plugin,Dialog: User Interaction Flow
    Plugin->>TTS: User taps "More..." in context menu
    TTS->>TTS: getResolvedMoreOptions()
    TTS->>Map: values()
    TTS->>TTS: resolve labels & enabled state
    TTS->>Dialog: select(title, items, true)
    Dialog-->>TTS: selectedId
    TTS->>TTS: executeMoreOption(option)
    TTS->>Plugin: option.action(context)
Loading

Last reviewed commit: f024ecd

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

3 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Copy link
Member

@RohitKushvaha01 RohitKushvaha01 left a comment

Choose a reason for hiding this comment

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

LGTM

@bajrangCoder bajrangCoder merged commit 78ede8b into Acode-Foundation:main Feb 26, 2026
6 checks passed
@bajrangCoder bajrangCoder deleted the feat/terminal-touch-more-options-api branch February 26, 2026 12:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Please implement select all text & copy in acode x terminal

2 participants