Skip to content

Terminal block hover overlay#17308

Open
Fangoling wants to merge 23 commits intoeclipse-theia:masterfrom
EduIDE:terminal-block-hover-overlay
Open

Terminal block hover overlay#17308
Fangoling wants to merge 23 commits intoeclipse-theia:masterfrom
EduIDE:terminal-block-hover-overlay

Conversation

@Fangoling
Copy link
Copy Markdown
Contributor

@Fangoling Fangoling commented Apr 5, 2026

What it does

Adds experimental terminal block hover actions on top of command history.

When terminal.integrated.enableCommandHistory and the new terminal.integrated.enableHoverActions preference are enabled, executed command blocks get a hover affordance that opens a block action menu. The menu lets users copy the command, copy the output, copy both, and scroll to the top or bottom of the block.

For AI-enabled setups, this also adds an Ask AI about Command action for terminal blocks with command/output content. That action opens an inline Ask AI overlay in the terminal, submits the selected block context to a new chat session, and includes cleanup fixes for the overlay, widget disposal, and child DI container lifecycle.
When #17312 is merged, we can also pass in the terminal AI Variable instead of the command content as plain text.

The implementation also places the hover overlay logic into a dedicated TerminalBlockHoverOverlayController to keep marker tracking, viewport updates, and disposal isolated.

The hover effect only appears when hovering over the ellipsis button at the far right of each command block, this is a limitation since the hover effect would conflict with the existing terminal hover links.

How to test

  1. Start Theia with AI Terminal available.
  2. Open Settings and enable:
    • terminal.integrated.enableCommandHistory
    • terminal.integrated.enableHoverActions
  3. Open a user terminal and run a few commands that produce visible output, for example:
    • echo hello
    • ls
    • pwd
  4. Hover over the action button of a completed command blocks and verify the hover action button appears.
  5. Open the block menu and verify:
    • Copy Command and Output copies both values
    • Copy Command copies only the command
    • Copy Output copies only the output
    • Scroll to Top of Block and Scroll to Bottom of Block move the viewport to the expected location
  6. With AI enabled, verify Ask AI about Command appears for blocks that have command and output.
  7. Trigger Ask AI about Command, confirm the inline overlay appears in the terminal, submit a prompt, and verify a chat session opens with the terminal command/output prepended to the request.
  8. Reopen the overlay, cancel it, and close the terminal while the overlay is open to confirm there are no disposal errors or duplicate-dispose issues.

Follow-ups

  • Add automated frontend coverage for terminal block hover actions and overlay lifecycle/disposal behavior.
  • Evaluate whether the Ask AI overlay should support richer block formatting or block truncation for very large outputs.
  • Consider additional terminal block actions if this experimental UI proves useful.

Breaking changes

  • This PR introduces breaking changes and requires careful review. If yes, the breaking changes section in the changelog has been updated.

Attribution

Review checklist

Reminder for reviewers

@github-project-automation github-project-automation Bot moved this to Waiting on reviewers in PR Backlog Apr 5, 2026
@Fangoling Fangoling force-pushed the terminal-block-hover-overlay branch from 826e0ea to db8eebc Compare April 5, 2026 23:06
Introduces an opt-in hover overlay (terminal.integrated.enableHoverActions,
requires enableCommandHistory) that renders a context menu button when hovering
over executed command blocks. Adds block-scoped commands for copying command,
output, or both, and for scrolling to the top/bottom boundary of a block.
Introduces TerminalBlockBoundary enum and abstract scrollToBlockBoundary API

Signed-off-by: Fangxing Liu <[email protected]>
Adds an inline AI chat overlay triggered from the terminal block action menu,
pre-filling the chat session with the selected command and its output as context.
Registers the AskAITerminalInputWidget factory via a child DI container and
cleans up the overlay when the terminal is disposed.

Signed-off-by: Fangxing Liu <[email protected]>
missing on last commit

Signed-off-by: Fangxing Liu <[email protected]>
…nd use onDidDispose for cleanup

Signed-off-by: Fangxing Liu <[email protected]>
…yController and fix disposal registration

Signed-off-by: Fangxing Liu <[email protected]>
Signed-off-by: Fangxing Liu <[email protected]>
- scroll to bottom now correctly scrolls to the bottom of the block
  instead the start of the next block
- extract the terminalBlockHoveraly as an interface
- extract the add button code into a function

Signed-off-by: Fangxing Liu <[email protected]>
Signed-off-by: Fangxing Liu <[email protected]>
@Fangoling Fangoling force-pushed the terminal-block-hover-overlay branch from 977bc10 to c97e8e5 Compare April 13, 2026 22:37
@Fangoling Fangoling marked this pull request as ready for review April 13, 2026 22:37
Signed-off-by: Fangxing Liu <[email protected]>
  Five terminal block commands (copy-all, copy-command, copy-output,
  scroll-to-top, scroll-to-bottom) were registered in registerMenus but
  missing from registerCommands after a rebase conflict, leaving them
  silently unresponsive. Also restores the TERMINAL_CONTRIBUTIONS context
  menu submenu registration and the TerminalBlock/TerminalBlockBoundary
  imports required by the command handlers.

Signed-off-by: Fangxing Liu <[email protected]>
Copy link
Copy Markdown
Member

@sdirix sdirix left a comment

Choose a reason for hiding this comment

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

Generally it works for me.

The name "Enable Hover Actions" seems off as the ... button is always shown, not only on hover. So maybe it should be called "Enable Command Block Actions"? Or we should show the ... buttons only on hover, for now they are always shown for me.

When enabling the preference, the first ... button is only shown for the 2nd next block, not the next block. Can this be improved?

When disabling the preference and enabling it again, the ... buttons are not shown for blocks for which they were shown in the past. Can this be improved?

Comment thread packages/ai-terminal/src/browser/ask-ai-terminal-widget.ts Outdated
Comment thread packages/terminal/src/browser/terminal-frontend-contribution.ts Outdated
Comment thread packages/terminal/src/browser/terminal-frontend-contribution.ts
Comment thread packages/terminal/src/browser/terminal-widget-impl.ts
Comment thread packages/terminal/src/browser/terminal-frontend-module.ts Outdated
Comment thread packages/ai-terminal/src/browser/style/ai-terminal.css
Comment thread packages/ai-terminal/src/browser/ai-terminal-contribution.ts Outdated
Comment thread packages/ai-terminal/src/browser/ai-terminal-contribution.ts Outdated
Comment thread packages/ai-terminal/src/browser/ai-terminal-contribution.ts Outdated
@github-project-automation github-project-automation Bot moved this from Waiting on reviewers to Waiting on author in PR Backlog Apr 15, 2026
- rename hover actions to command block actions
- rename ask ai to generate command via ai
- rename ask ai about command to ask ai about this command
- add missing localization key
- use clipboardBoard service

Signed-off-by: Fangxing Liu <[email protected]>
Signed-off-by: Fangxing Liu <[email protected]>
- controller was previously disposed on each preference trigger
- controller is now only enabled/disabled
- blocks tracked before this preference was disabled are still visible after
  enablement

Signed-off-by: Fangxing Liu <[email protected]>
- terminal clear now adds a prompt start marker after clearing the
  terminal
- first command after clearing is now tracked

Signed-off-by: Fangxing Liu <[email protected]>
@Fangoling Fangoling requested a review from sdirix April 21, 2026 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Waiting on author

Development

Successfully merging this pull request may close these issues.

2 participants