Skip to content

fix(terminal-trail): stabilize sizing and session removal - #1839

Merged
FresnelR27 merged 2 commits into
org2AI:developfrom
Harry19081:dev/terminal-trail-lifecycle
Sep 15, 2026
Merged

FresnelR27 merged 2 commits into
org2AI:developfrom
Harry19081:dev/terminal-trail-lifecycle

Conversation

@Harry19081

@Harry19081 Harry19081 commented Sep 15, 2026 •

Copy link
Copy Markdown
Member

Problem

Docked terminal trails could start with mismatched shell and display dimensions, leaving zsh's inverse % marker above the prompt. The single-terminal title used a separate chevron button and the terminal content had a 12px left inset but no right inset. Stopping a docked session released its claim before native termination removed it from the session list, briefly exposing it as a workstation trail row.

Solution

Improve the terminal trail's startup, presentation, and close lifecycle as one focused change:

  • Select the renderer before fitting; read current rows/columns at PTY startup boundaries; dispatch grid resizes without the extra 50ms delay; reconcile resizes that arrive during native creation.
  • Reuse the workstation trail's title toggle for a single terminal and add a scoped 12px right inset. Multiple-terminal controls retain their existing behavior.
  • Keep dock ownership until canonical session removal completes. Deduplicate pending Stop requests per store and clear operation state afterward. Adapt the async action through a shared synchronous UI handler that catches failures for both close callbacks.
  • Add regression coverage at the startup and close writers, including captured zsh prompt sequences parsed by xterm, ownership transitions, duplicate Stop, store isolation, and cleanup. Include UI and lifecycle audit notes.

Potential risks

The startup code is shared by other TerminalInteractive hosts, so renderer sizing and prompt behavior in those hosts also use the corrected order. Actual Tauri GPU/font behavior, fractional display scaling, platform-specific shells, and desktop visible/hidden CPU/RSS measurements remain unverified. Screenshots/recordings were not captured because desktop computer control requires explicit user opt-in.

Stop retains the dock claim while native termination is pending; this prevents the transient handoff but means a slow native close leaves the terminal in the dock until it completes. Existing native-error cleanup behavior is unchanged. Already-written scrollback is preserved, so this does not remove old prompt artifacts.

No dependencies, shell configuration, IPC/wire schema, persistence format, or database migrations change. Reverting this commit restores the previous behavior without data migration or cleanup.

Verification

The CI follow-up fixes both no-misused-promises findings at the UI close callbacks. No lint rule or baseline was changed. Follow-up verification:

  • NODE_OPTIONS=--max-old-space-size=6144 pnpm check:typed-lint — passed, 1097 existing findings and 0 new or increased findings.
  • pnpm test:typed-lint — 6 tests passed.
  • pnpm exec eslint --no-eslintrc --config config/eslint.typed.cjs src/modules/shared/layouts/FocusedChatWorkstationRail/WorkstationTrailTerminal.tsx --max-warnings 0 — passed.
  • pnpm test src/store/ui/__tests__/miniTerminalAtom.test.ts src/store/workstation/codeEditor/terminal/__tests__/terminalAtoms.close.test.ts src/modules/shared/layouts/FocusedChatWorkstationRail/WorkstationTrailTerminal.test.ts — 27 tests passed after the handler change.
  • pnpm typecheck:fast and changed-file regular ESLint — passed after the handler change.

Executed on the isolated PR branch:

  • pnpm test src/engines/TerminalCore/components/TerminalInteractive/__tests__ src/store/ui/__tests__/miniTerminalAtom.test.ts src/store/workstation/codeEditor/terminal/__tests__/terminalAtoms.close.test.ts src/modules/shared/layouts/FocusedChatWorkstationRail/WorkstationTrailTerminal.test.ts src/modules/shared/layouts/blocks/WorkstationTrailSurface.test.ts — 18 files, 177 tests passed.
  • pnpm typecheck:fast — passed. Earlier type failures in the shared checkout came from unrelated changes and are absent on this branch.
  • pnpm exec sass src/engines/TerminalCore/components/TerminalInteractive/index.scss /tmp/orgii-terminal-trail.css --no-source-map — passed; the scoped right inset also passed an explicit compiled-CSS assertion.
  • git diff --cached --name-only --diff-filter=ACMR -z | node scripts/ci/check-changed-file-length.cjs — all 6 changed production TypeScript files are within 700 lines.
  • git diff --cached --check — passed.
  • Normal commit hooks passed: staged-file oxlint, ESLint, Prettier, full-project tsgo, and commitlint. The hooks were not bypassed.
  • Reproduced the highlighted marker with real /bin/zsh -f -i output from a 64-column PTY: the installed xterm parser erased it at 64 columns and retained it at 62 columns. The new delayed-startup tests exercise the corrected production boundary.
  • The close ownership regression failed before the fix for both successful and rejected native-close replies, then passed after the writer ordering changed.

Desktop visual/performance checks and the full repository test suite were not run. No Rust implementation changed.

Audit

UI audit: 1 fix, 3 kept with reason, 0 abstractions. Shared Button usage and panel labels are preserved. Lifecycle tests cover cleanup and isolation; the performance audit remains blocked on real desktop measurements and makes no CPU/RAM improvement claim.

Fit the active renderer and use live PTY dimensions to prevent stale
startup geometry. Forward grid resizes without a second debounce and
reconcile resizes that race native creation.

Use the shared trail heading for one terminal and balance content insets.
Retain dock ownership until the canonical session removal completes, with
per-store duplicate-stop protection, so stopped terminals do not flash
in the workstation trail.

Verified 177 focused tests, full TypeScript checking, and SCSS compilation
on the isolated branch. Desktop visual and CPU/RSS checks remain unrun.

Pre-commit hook ran. Total eslint: 0, total circular: 5
Adapt the async close atom through a shared synchronous UI handler that
catches failures. Wire both the Stop control and TerminalCore close
callback to it, preserving their void-returning contracts.

The complete type-aware lint gate now reports zero new findings. Verified
27 close/dock tests, 6 lint-gate tests, TypeScript, and changed-file ESLint.

Pre-commit hook ran. Total eslint: 0, total circular: 5
@FresnelR27
FresnelR27 merged commit 350e8d2 into org2AI:develop Sep 15, 2026
15 checks passed
@Harry19081 Harry19081 added bug Something isn't working workstation Workstation, editor, source control, LSP, or status bar labels Sep 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working workstation Workstation, editor, source control, LSP, or status bar

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants