Skip to content

feat(terminal): expandable mini terminal — full-screen modal view#1424

Merged
arnestrickmann merged 5 commits intogeneralaction:mainfrom
shreyaspapi:feat/expandable-mini-terminal
Mar 12, 2026
Merged

feat(terminal): expandable mini terminal — full-screen modal view#1424
arnestrickmann merged 5 commits intogeneralaction:mainfrom
shreyaspapi:feat/expandable-mini-terminal

Conversation

@shreyaspapi
Copy link
Contributor

@shreyaspapi shreyaspapi commented Mar 11, 2026

Summary

Adds the ability to expand the mini terminal in the right sidebar into a full-screen modal overlay. The terminal session (PTY, scrollback, scroll position) is fully preserved across expand/collapse — no restart, no lost output.

  • Expand button (maximize icon) added to the terminal toolbar
  • Full-screen modal with backdrop blur, dark/light theme support
  • Session preservation via SessionRegistry.reattach() — the xterm.js Terminal instance is physically moved between DOM containers
  • Escape key closes the modal (when terminal textarea is not focused)
  • Click backdrop to dismiss

How it works

  1. User clicks the expand button next to the close (X) button in the terminal toolbar
  2. ExpandedTerminalModal mounts as a portal on document.body
  3. The existing terminal session is detached from the sidebar container and re-attached to the modal container via terminalSessionRegistry.reattach()
  4. On close, the session detaches from the modal and the sidebar TerminalPane re-mounts to reclaim it (via a reattachKey bump)

No new dependencies. Uses the existing TerminalSessionManager attach/detach lifecycle.

Fixes

Fixes #1378

Snapshot

Screen.Recording.2026-03-12.at.12.46.29.AM.mov

Type of change

  • New feature (non-breaking change which adds functionality)

Mandatory Tasks

  • I have self-reviewed the code
  • A decent size PR without self-review might be rejected

Checklist

  • I have read the contributing guide
  • My code follows the style guidelines of this project (pnpm run format)
  • I have commented my code, particularly in hard-to-understand areas
  • I have checked if my changes generate no new warnings (pnpm run lint)
  • I have checked if new and existing unit tests pass locally with my changes

@vercel
Copy link

vercel bot commented Mar 11, 2026

@shreyaspapi is attempting to deploy a commit to the General Action Team on Vercel.

A member of the Team first needs to authorize it.

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 11, 2026

Greptile Summary

This PR adds an expand-to-fullscreen capability for the mini terminal in the right sidebar. Clicking the new maximize icon renders ExpandedTerminalModal as a React portal on document.body, which physically moves the xterm.js Terminal DOM node (and its live PTY session, scrollback, and viewport position) into the modal container via SessionRegistry.reattach(). On close, the session is detached and the sidebar TerminalPane remounts via a reattachKey bump to reclaim it. The implementation correctly leverages the existing attach/detach lifecycle of TerminalSessionManager — scroll position capture, ResizeObserver teardown, and viewport restoration are all handled automatically.

Key observations:

  • The Minimize2 (collapse) and X (close) buttons in the modal header both call the same onClose handler. The X icon conventionally signals "terminate", but here it merely collapses the session back to the sidebar — the same action as Minimize2. This is likely to confuse users.
  • reattachKey is applied to every TerminalPane key, so closing the modal causes all open terminal tabs to detach and reattach unnecessarily. Only the previously-expanded terminal needs to remount.
  • The explicit terminalSessionRegistry.detach(terminalId) call before reattach() in ExpandedTerminalModal is redundant, since TerminalSessionManager.attach() already calls detach() internally as its first step.

Confidence Score: 4/5

  • Safe to merge with minor UX and performance improvements recommended.
  • The core session-preservation mechanism is sound — the attach/detach lifecycle in TerminalSessionManager handles DOM movement, viewport restoration, and ResizeObserver cleanup correctly, and the React commit ordering ensures the modal's cleanup runs before sidebar TerminalPane remounts. The identified issues are style/UX concerns (duplicate button behaviour, over-broad reattachKey, redundant detach call) rather than correctness bugs.
  • src/renderer/components/ExpandedTerminalModal.tsx (duplicate button behaviour) and src/renderer/components/TaskTerminalPanel.tsx (global reattachKey causing all terminals to remount).

Important Files Changed

Filename Overview
src/renderer/components/ExpandedTerminalModal.tsx New full-screen modal component that physically moves an xterm.js session between DOM containers via SessionRegistry.reattach(); two header buttons (Minimize2 and X) both call onClose with identical behaviour, and the explicit detach() before reattach() is redundant since attach() already calls detach() internally.
src/renderer/components/TaskTerminalPanel.tsx Adds expand-button toolbar entry and wires ExpandedTerminalModal; the global reattachKey approach forces all TerminalPane instances to remount on modal close rather than only the one that was expanded.
src/renderer/terminal/SessionRegistry.ts Adds reattach() helper that delegates directly to session.attach(container) — minimal, correct addition that fits cleanly into the existing registry pattern.

Sequence Diagram

sequenceDiagram
    participant User
    participant TaskTerminalPanel
    participant ExpandedTerminalModal
    participant SessionRegistry
    participant TerminalSessionManager

    User->>TaskTerminalPanel: Click Maximize button
    TaskTerminalPanel->>TaskTerminalPanel: setExpandedTerminalId(activeTerminalId)
    TaskTerminalPanel->>ExpandedTerminalModal: Mount (portal on document.body)
    ExpandedTerminalModal->>SessionRegistry: detach(terminalId)
    SessionRegistry->>TerminalSessionManager: detach() → moves DOM to terminalHost
    ExpandedTerminalModal->>SessionRegistry: reattach(terminalId, modalContainer)
    SessionRegistry->>TerminalSessionManager: attach(modalContainer) → moves DOM to modal
    TerminalSessionManager-->>ExpandedTerminalModal: session (with PTY/scrollback intact)
    ExpandedTerminalModal->>TerminalSessionManager: focus() [via rAF]

    User->>ExpandedTerminalModal: Click Minimize / Esc
    ExpandedTerminalModal->>TaskTerminalPanel: onClose()
    TaskTerminalPanel->>TaskTerminalPanel: setExpandedTerminalId(null) + setReattachKey(k+1)
    ExpandedTerminalModal->>SessionRegistry: detach(terminalId) [cleanup effect]
    SessionRegistry->>TerminalSessionManager: detach() → moves DOM to terminalHost
    Note over TaskTerminalPanel: All TerminalPane keys change (reattachKey bump)
    TaskTerminalPanel->>SessionRegistry: attach(terminalId, sidebarContainer)
    SessionRegistry->>TerminalSessionManager: attach(sidebarContainer) → session restored
Loading

Last reviewed commit: ffdd9c1

@shreyaspapi
Copy link
Contributor Author

All three review comments addressed in 17372ad:

  • Duplicate buttons: Removed the X button, keeping only the Minimize2 collapse button
  • Redundant detach: Removed the explicit detach() before reattach() since attach() handles it internally
  • Over-broad reattachKey: Replaced global counter with scoped reattachId + ref counter — only the previously-expanded terminal remounts

Copy link
Contributor

@yashdev9274 yashdev9274 left a comment

Choose a reason for hiding this comment

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

hey @shreyaspapi

expanded terminal is overlapping with window's action button, pls address this

try to expand it upto certain extend

Image

@shreyaspapi
Copy link
Contributor Author

shreyaspapi commented Mar 11, 2026

Additional fixes in latest commits:

  • Titlebar overlap
Screenshot 2026-03-12 at 1 03 26 AM

…i-terminal

# Conflicts:
#	src/renderer/components/TaskTerminalPanel.tsx
@shreyaspapi
Copy link
Contributor Author

@arnestrickmann fixed the merge conflict!

@arnestrickmann
Copy link
Contributor

Thx!

@arnestrickmann arnestrickmann merged commit de8d1da into generalaction:main Mar 12, 2026
2 of 3 checks passed
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.

Feature: Expandable mini terminal — modal view for full-screen terminal access

3 participants