Skip to content

Embedded terminal T2: panel, title-bar toggle and ⌃`, e2e on a real shell - #26

Merged
BunsDev merged 3 commits into
term-enginefrom
term-panel
Sep 28, 2026
Merged

BunsDev merged 3 commits into
term-enginefrom
term-panel

Conversation

@BunsDev

@BunsDev BunsDev commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #25 (T1). Base is term-engine; once #25 merges, this PR retargets to main (GitHub does that when the base branch is deleted), or I'll rebase it with -S.

The thread's shell from T1 now has UI.

Changes

  • Panel (TerminalPanel.tsx): a bottom panel in the main pane, on the design tokens and IconButton (new terminal / restart glyphs). Header shows the folder or worktree branch and "Exited (n)"; Restart, Close; drag or ↑/↓ to resize. xterm 6 + fit addon load lazily on first open. The native viewport scrollbar is hidden: xterm 6 draws its own, and wheel scrolling measured identical.
  • Toggle: a Terminal button in the title bar one 34 px step left of ⋯ (⋯ and Changes don't move), plus ⌃` from anywhere, including inside the shell.
  • Per thread: visibility is per thread; hiding keeps the shell running; reopening replays its output. Close ends the shell; deleting the thread ends it too (T1).
  • e2e shell: under MODEX_E2E the terminal starts /bin/bash --noprofile --norc (and silences bash's zsh notice). A user's rc files (zsh + nvm locally) redrew slower than the test typed after ⌃C. Real use still starts the login shell; a new unit test covers both paths.
  • Dropped as dead code (found by mutation): a guard keeping ⌃-keys from app shortcuts (xterm already consumes them) and a ⌃` pass-through (xterm maps no byte to it).

Tests

  • e2e/terminal.spec.ts, 6 tests on a real PTY: TTY in the thread's folder; ⌃` hides/shows and keeps env; ⌃C and ⌃J reach the shell (Changes unchanged); per-thread shells; taller panel = more stty rows; exit code, Restart, Close kills the pid; deleting a worktree thread with its terminal open ends the shell and removes the folder.
  • Layout gate: toggle position, panel spans the main pane under a 736 px composer, stays left of Changes.
  • Mutation-checked: removing the delete cleanup, the output replay, or the panel placement each fails a test.
  • Local: typecheck clean, unit 15 + 60, e2e 34/34 in 4 of 5 full runs since the last fix. One earlier local run had 5 app.spec failures that did not reproduce (including app.spec alone); CI is the clean check.

Copilot AI lite review requested due to automatic review settings September 27, 2026 04:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Terminal input remains active after PTY exit, and the resize control is missing aria-valuemax.

Review effort: Lite
Findings: 1 Medium severity · 1 Low severity

Open (2)
What changed in this PR

Adds an embedded per-thread PTY terminal with lazy xterm UI, toggles, resizing, lifecycle controls, and real-shell test coverage.

Changes:

  • Adds terminal panel, title-bar toggle, and keyboard shortcut.
  • Supports replay, restart, close, resizing, and per-thread visibility.
  • Adds shell configuration, icons, styling, dependencies, and unit/e2e tests.
File Reviewed changes
package-lock.json Locked terminal dependencies
apps/​desktop/​test/​terminal.test.ts Shell selection tests
apps/​desktop/​src/​renderer/​styles.css Terminal panel styling
apps/​desktop/​src/​renderer/​components/​ui/​Icon.tsx Terminal and restart icons
apps/​desktop/​src/​renderer/​components/​TitleBar.tsx Title-bar terminal toggle
apps/​desktop/​src/​renderer/​components/​TerminalPanel.tsx Terminal UI and PTY lifecycle handling; exit input handling and aria-valuemax remain to be addressed
apps/​desktop/​src/​renderer/​App.tsx Per-thread state and shortcut integration
apps/​desktop/​src/​main/​index.ts E2E shell configuration and cleanup
apps/​desktop/​src/​main/​engine/​terminal.ts Configurable shell startup
apps/​desktop/​package.json Terminal dependencies
apps/​desktop/​e2e/​terminal.spec.ts Real-shell terminal coverage
apps/​desktop/​e2e/​layout.spec.ts Terminal layout assertions

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Copilot AI commented Sep 27, 2026

Copy link
Copy Markdown
Contributor

Copilot review overview...

Both findings are already addressed: bb09ecb updates snapshot.exitCode so input is ignored after PTY exit; 92094f5 adds aria-valuemax matching the resize limit. Verified both fixes in the current checkout; no additional changes needed.

BunsDev and others added 3 commits September 28, 2026 03:47
…hell

Stacked on T1 (#25). The thread's shell, from the T1 engine, now has UI.

- TerminalPanel: a bottom panel in the main pane on the design tokens and
  IconButton (new terminal/restart glyphs): folder or worktree branch,
  "Exited (n)", Restart, Close, drag or arrow-key resize. xterm 6 + fit
  addon load lazily on first open. The native viewport scrollbar is hidden
  (xterm 6 draws its own; wheel scrolling measured identical).
- Title-bar Terminal toggle one 34 px step left of ⋯ (⋯ and Changes do not
  move), and ⌃` from anywhere, including inside the shell. Visibility is per
  thread; hiding keeps the shell running and reopening replays its output.
- Under MODEX_E2E the shell is /bin/bash --noprofile --norc: a user's rc
  files (zsh + nvm here) raced the test's typing. Real use still starts the
  login shell; a unit test covers both paths.

Tests: e2e/terminal.spec.ts (6: real TTY in the thread folder, hide keeps
state, ⌃C/⌃J reach the shell, per-thread shells, taller panel = more rows,
exit/Restart/Close, worktree delete ends the shell) and a layout gate for
the toggle and panel. Mutation-checked: dropping the delete cleanup,
the output replay, or the panel's placement each fail a test.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Update exit code handling in TerminalPanel component.

Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
@BunsDev
BunsDev merged commit 9ba7651 into term-engine Sep 28, 2026
2 of 3 checks passed
@BunsDev
BunsDev deleted the term-panel branch September 28, 2026 23:16
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.

3 participants