Repository navigation
Embedded terminal T1: PTY engine, IPC, lifecycle and packaging (no UI yet) - #25
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Four moderate findings in terminal sizing, stale-ID handling, byte-limit enforcement, and replay bounds must be fixed.
Review effort: Lite
Findings: 2
Open (2)
What changed in this PR
Adds the backend infrastructure for embedded per-thread terminals, including PTY management, IPC, lifecycle cleanup, trust checks, and packaging support, without UI changes.
Changes:
- Adds terminal session management, replay, validation, and lifecycle handling.
- Exposes terminal IPC and renderer bridge APIs.
- Adds
node-ptypackaging configuration and tests.
| File | Summary |
|---|---|
package-lock.json |
Locks PTY dependencies. |
apps/desktop/test/terminal.test.ts |
Adds terminal and trust tests. |
apps/desktop/src/shared/types.ts |
Defines terminal IPC contracts; includes a documentation nit. |
apps/desktop/src/renderer/bridge.ts |
Adds terminal bridge support. |
apps/desktop/src/main/preload.cjs |
Exposes terminal event subscriptions. |
apps/desktop/src/main/index.ts |
Registers IPC handlers and lifecycle cleanup. |
apps/desktop/src/main/engine/terminal.ts |
Implements PTY sessions; has four moderate findings around sizing, session IDs, byte limits, and replay bounds. |
apps/desktop/scripts/prepare-terminal.mjs |
Restores PTY helper executable permissions. |
apps/desktop/package.json |
Configures PTY dependency, build, and packaging. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Contributor
Author
|
@copilot resolve the merge conflicts in this pull request |
Contributor
… yet) Ports the shell engine from the parked chat-workspace branch onto current main. Nothing visible changes; the panel and its title-bar toggle are T2. - engine/terminal.ts (from 3bc4ca6, unchanged): one login shell per thread in the thread's cwd (the worktree for worktree threads), 128 KB replay history, session id + sequence so a reopened panel catches up without duplicates, validated sizes and input, idempotent close. - IPC terminal:open/write/resize/close + a terminal:event push channel. isTrustedTerminalSender: only the live app window's top frame may drive a shell. will-navigate is blocked so the window (and its preload) never leaves the app page. - Shells close on thread delete (before its worktree is removed), project remove, window closed, renderer gone and app quit. - node-pty 1.1.0 (N-API prebuilds; no Electron rebuild). prepare-terminal.mjs restores spawn-helper's exec bit (npm installs it 0644). asarUnpack node-pty kept explicit; electron-builder also unpacks it on its own. - The external "Open terminal here" action is unchanged. Tests: 3 unit tests from the parked branch + a trust-check test (mutation-checked: dropping the top-frame condition fails it). A local probe opened a real PTY through IPC in both the dev build and a packaged Modex.app: tty=yes, cwd = thread folder, exit code delivered. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Co-authored-by: BunsDev <[email protected]>
Co-authored-by: BunsDev <[email protected]>
Co-authored-by: BunsDev <[email protected]>
Co-authored-by: BunsDev <[email protected]>
Co-authored-by: BunsDev <[email protected]>
BunsDev
added a commit
that referenced
this pull request
Sep 28, 2026
…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]>
BunsDev
force-pushed
the
term-engine
branch
from
September 28, 2026 08:53
b8c834f to
ff3292b
Compare
BunsDev
added a commit
that referenced
this pull request
Sep 28, 2026
…hell (#26) * Embedded terminal T2: panel, title-bar toggle and ⌃`, e2e on a real shell 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]> * Refactor exit code assignment in TerminalPanel Update exit code handling in TerminalPanel component. Co-authored-by: Copilot Autofix powered by AI <[email protected]> * Update aria-valuemax for terminal resize Co-authored-by: Copilot Autofix powered by AI <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Copilot Autofix powered by AI <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

First of two PRs porting the embedded terminal from the parked
chat-workspacebranch (3bc4ca6) onto current main. Plan: T1 engine (this PR, no visible change), T2 panel + ⌃` toggle.Changes
engine/terminal.ts(taken unchanged from the parked branch): one login shell per thread, started in the thread's cwd (the worktree for worktree threads); 128 KB replay history; session id + sequence numbers so a reopened panel catches up without duplicates; validated sizes (2–500 × 2–300) and input (≤64 KB); idempotent close that ignores stale session ids.terminal:open/write/resize/close+ aterminal:eventpush channel (preload, bridge, shared types).isTrustedTerminalSenderallows only the live app window's top frame to drive a shell.will-navigateis blocked so the window, which keeps its preload across navigations, never leaves the app page. The renderer has no in-page links, so nothing else is affected.node-pty1.1.0 (N-API prebuilds, so no Electron rebuild).scripts/prepare-terminal.mjsruns inbuild:mainand restoresspawn-helper's exec bit (npm installs it0644).asarUnpack: node-pty/**is explicit; electron-builder also unpacks it on its own (verified by packaging without it).Tests
subframe)..probes/pty-smoke.mjs, local only) on the dev build and a packagedModex.app:tty=yes, cwd = the thread's folder,exit 7delivered as an exit event.