Skip to content

fix: restore agent input after full restart#172

Merged
DeadWaveWave merged 41 commits intomainfrom
fix/terminal-recovery
Apr 16, 2026
Merged

fix: restore agent input after full restart#172
DeadWaveWave merged 41 commits intomainfrom
fix/terminal-recovery

Conversation

@DeadWaveWave
Copy link
Copy Markdown
Owner

💡 Change Scope

  • Small Change: Fast feedback, localized UI/logic, low-risk.
  • Large Change: New feature, cross-boundary logic, runtime-risk (persistence, IPC, lifecycle, recovery).

📝 What Does This PR Do?

This PR merges the terminal-recovery branch on top of main and keeps the split TerminalNode recovery architecture while carrying forward main's newer terminal/workspace changes.

User-visible outcomes:

  • restore full-restart agent input reliably after cold start
  • keep durable placeholder/history behavior aligned with restart recovery
  • preserve OpenCode embedded theme synchronization in the split runtime session path
  • move debugging specifics into docs/cases/* so docs/DEBUGGING.md stays reusable

🏗️ Large Change Spec (Required if "Large Change" is checked)

1. Context & Business Logic

This change is about restart/recovery correctness across Main, Preload, Renderer, persisted workspace state, and live PTY sessions. On a full app restart, restored terminal/agent nodes must show durable history immediately, drop stale runtime ownership, attach to a fresh live session, and remain interactive once recovery finishes. The merge also preserves OpenCode-specific embedded TUI theme sync so the split terminal runtime stays behaviorally equivalent to the newer main branch behavior.

2. State Ownership & Invariants

  • Main process owns live PTY/runtime session identity; the renderer must not keep sending input to a stale pre-restart sessionId.
  • Persisted workspace state owns durable placeholder/history; it may render before runtime recovery completes, but placeholder visibility must not imply ownership of live stdin.
  • OpenCode theme bridge messages must only be reported from the active restored runtime path and must not break hydration or alternate-screen behavior.

3. Verification Plan & Regression Layer

Lowest meaningful regression layers used here:

  • Unit: tests/unit/app/mainProcessPid.spec.ts, tests/unit/app/useHydrateAppState.helpers.spec.ts, tests/unit/terminalNode/opencodeTuiThemeBridge.spec.ts, tests/unit/terminalNode/opencodeOscColorQueryResponder.spec.ts
  • Electron E2E: tests/e2e/recovery.agent-focus-after-restart.spec.ts, tests/e2e/recovery.agent-reopen.spec.ts, tests/e2e/recovery.agent-reopen.gemini-opencode.spec.ts
  • Full gate: pnpm pre-commit

✅ Delivery & Compliance Checklist

  • My code passes the ultimate gatekeeper: pnpm pre-commit is completely green.
  • I have signed the CLA if required (see CLA.md).
  • I have included new tests to lock down the behavior (or explicitly stated why it's untestable).
  • I have strictly adhered to the DEVELOPMENT.md architectural boundaries.
  • I have attached a screenshot or screen recording (if this touches the UI).
  • I have updated the documentation accordingly (if adding a feature or changing a contract).

📸 Screenshots / Visual Evidence

Not attached via CLI. I will add any needed screenshots in the GitHub PR UI.

- Stop persisting/hydrating agent node scrollback; agent history is restored by Agent CLI

- Stabilize terminal worktree reopen E2E by waiting for terminal hydration
Add a stdin-echo agent stub scenario and shared worker helpers. Extend DEBUGGING.md with a visual color-debug checklist.
@DeadWaveWave DeadWaveWave merged commit 485cd63 into main Apr 16, 2026
7 checks passed
@DeadWaveWave DeadWaveWave deleted the fix/terminal-recovery branch April 16, 2026 02:38
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.

1 participant