Skip to content

Fix work.stopRuntime no-op and supervised PTY IPC write drops#434

Draft
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-correctness-bugs-5498
Draft

Fix work.stopRuntime no-op and supervised PTY IPC write drops#434
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-correctness-bugs-5498

Conversation

@cursor
Copy link
Copy Markdown
Contributor

@cursor cursor Bot commented May 30, 2026

Bug 1: iOS/sync "Stop runtime" can leave the terminal running

Impact: User-facing breakage — iOS Work tab "Stop runtime" (and any work.stopRuntime sync caller) could return { ok: true } while the shell/agent kept running.

Root cause: work.stopRuntime used raw sessionService.get() and only disposed when session.ptyId was set in the DB. work.listSessions already uses ptyService.enrichSessions() to attach live in-memory PTY ids; stop did not. When the DB row had pty_id = null but a local PTY was attached (the same scenario deleteTerminalSession guards via enrich), disposal was skipped.

Fix: Enrich the session before resolving ptyId, matching the delete-terminal path.

Trigger: Stop a running terminal from iOS after the session list showed it as running (enriched ptyId) but the persisted row had not yet been resynced.

Bug 2: Supervised PTY host silently drops input under IPC backpressure

Impact: Data loss — fast typing or large paste could lose keystrokes with no error.

Root cause: SupervisedPtyHost.sendToChild called child.send(); when Node returns false (channel full), the code only logged at debug level. Node documents that unsent messages must wait for drain.

Fix: Queue requests per host child and flush on drain.

Trigger: Large paste or burst input while the PTY worker IPC channel is backpressured (introduced with supervised PTY host in d68fee7).

Validation

  • npx vitest run src/main/services/sync/syncRemoteCommandService.test.ts -t "work.stopRuntime"
  • npx vitest run src/main/services/pty/supervisedPtyHost.test.ts -t "backpressured"

Other findings (not fixed here — existing open PRs)

Open in Web View Automation 

- work.stopRuntime: enrich session before dispose so iOS/sync stop reaches
  live PTYs when the DB row still has ptyId null (matches delete flow).
- supervisedPtyHost: queue IPC writes on channel backpressure and flush on
  drain instead of dropping keystrokes/pastes silently.

Co-authored-by: Arul Sharma <arul28@users.noreply.github.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 30, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
ade Ignored Ignored May 30, 2026 6:11am

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