Skip to content

Fix terminal PTY interruptions during remounts#138

Merged
johannesjo merged 1 commit into
johannesjo:mainfrom
brooksc:terminal-hmr-lifecycle
May 26, 2026
Merged

Fix terminal PTY interruptions during remounts#138
johannesjo merged 1 commit into
johannesjo:mainfrom
brooksc:terminal-hmr-lifecycle

Conversation

@brooksc

@brooksc brooksc commented May 24, 2026

Copy link
Copy Markdown
Collaborator

Problem

Task AI terminals currently terminate their backend PTY when the TerminalView component cleans up. In dev/HMR or other renderer remounts, that kills an active Codex session, then the renderer respawns it with resume args. Codex sees that as an interrupted conversation and waits for manual continuation.

Fix

Task AI terminals now preserve their PTY across component cleanup and reattach to the existing process on remount. Intentional replacement remains explicit: restart and agent switch set attachExisting=false, so those actions still replace the running process. Standalone close/cleanup paths continue to own termination.

Verification

  • git diff --check
  • npm run check
  • npm test
  • Push hook reran npm run check and npm test
  • Confirmed this branch is rebased on latest johannesjo/main
  • Confirmed the PR contains one commit touching only:
    • electron/ipc/pty.test.ts
    • electron/mcp/coordinator.ts
    • src/components/TaskAITerminal.tsx
    • src/components/TerminalView.tsx
    • src/store/agents.test.ts
    • src/store/agents.ts

@johannesjo

Copy link
Copy Markdown
Owner

Thank you!

@johannesjo johannesjo merged commit 0e365b4 into johannesjo:main May 26, 2026
2 checks passed
brooksc added a commit to brooksc/parallel-code that referenced this pull request May 27, 2026
Users can now type into any coordinator or sub-task session without
first taking control. Coordinator and system prompts queue and deliver
automatically when the target session is safe: agent idle, no user
draft, no pending terminal input, no recent user activity.

Backend (electron/mcp):
- Backend-owned initial prompt delivery with scheduling/retry so
  sub-tasks no longer depend on a mounted renderer panel.
- Improved terminal prompt detection: Working(...), background
  terminal running, q-corrupted variants, trust dialogs.
- New 'landed' PendingNotification state so successful land_self
  queues a "self-landed successfully" notification.
- Suppress coordinator notifications while children are still active.

Renderer:
- Per-tick autofire arbiter with explicit wait reasons (paused,
  waiting-for-user-draft, waiting-for-terminal-input,
  waiting-for-user-activity, no-prompt, fire).
- Prompt draft and terminal pending-input tracking so queued
  automation can't overwrite half-typed user input.
- Per-task user activity leases — typing pauses automation without
  taking durable ownership.
- Removed Take/Release control UI from TaskPanel.

Tooling:
- scripts/check-coordinator-run.mjs — log checker for regression
  triage from captured app logs.
- scripts/fake-agent.mjs — PTY mock for integration tests.
- Real-PTY and real-CLI integration suites for Codex/Claude/Gemini
  /Copilot.

Dead-code cleanup:
- Removed src/lib/terminalDisableStdin.ts; both helpers had become
  constant-wrapping shims after the take/release removal.

OpenSpec: new capability spec session-prompt-delivery.

Stacked on johannesjo#138 (terminal PTY remount lifecycle) and johannesjo#145 (sub-task
self-landing).

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
johannesjo pushed a commit that referenced this pull request May 28, 2026
Users can now type into any coordinator or sub-task session without
first taking control. Coordinator and system prompts queue and deliver
automatically when the target session is safe: agent idle, no user
draft, no pending terminal input, no recent user activity.

Backend (electron/mcp):
- Backend-owned initial prompt delivery with scheduling/retry so
  sub-tasks no longer depend on a mounted renderer panel.
- Improved terminal prompt detection: Working(...), background
  terminal running, q-corrupted variants, trust dialogs.
- New 'landed' PendingNotification state so successful land_self
  queues a "self-landed successfully" notification.
- Suppress coordinator notifications while children are still active.

Renderer:
- Per-tick autofire arbiter with explicit wait reasons (paused,
  waiting-for-user-draft, waiting-for-terminal-input,
  waiting-for-user-activity, no-prompt, fire).
- Prompt draft and terminal pending-input tracking so queued
  automation can't overwrite half-typed user input.
- Per-task user activity leases — typing pauses automation without
  taking durable ownership.
- Removed Take/Release control UI from TaskPanel.

Tooling:
- scripts/check-coordinator-run.mjs — log checker for regression
  triage from captured app logs.
- scripts/fake-agent.mjs — PTY mock for integration tests.
- Real-PTY and real-CLI integration suites for Codex/Claude/Gemini
  /Copilot.

Dead-code cleanup:
- Removed src/lib/terminalDisableStdin.ts; both helpers had become
  constant-wrapping shims after the take/release removal.

OpenSpec: new capability spec session-prompt-delivery.

Stacked on #138 (terminal PTY remount lifecycle) and #145 (sub-task
self-landing).

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
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.

2 participants