Skip to content

Harden layout validation, watcher lifecycle, and connection robustness - #7924

Merged
AmethystLiang merged 2 commits into
mainfrom
1.4.129-rc7-release-prep
Jul 9, 2026
Merged

Harden layout validation, watcher lifecycle, and connection robustness#7924
AmethystLiang merged 2 commits into
mainfrom
1.4.129-rc7-release-prep

Conversation

@AmethystLiang

Copy link
Copy Markdown
Contributor

Summary

Harden package layout validation, parcel watcher process lifecycle, WebSocket connection robustness, and editor tab restoration.

Key changes:

  • Layout Validation: Upgraded daemon entry verification from a silent skip to a strict assertion ('assertPackagedDaemonEntryExists'), catching packaged layout regressions across all platforms. Added unit tests for daemon entry boot verification.
  • Mac Build Script: Updated 'build:mac' and 'build:mac:release' scripts in 'package.json' to include macOS notification status building.
  • Watcher Lifecycle: Automatically kills idle parcel watcher child processes once the active subscription count drops to zero or the last pending subscription fails, freeing native handles and reclaiming memory.
  • WebSocket Connection Robustness (STA-1511): Binds the persisted fallback port first on launch (even if the preferred port is free) to prevent permanently stranding active mobile pairings. Falls through gracefully on non-'EADDRINUSE' failures (e.g., Windows 'EACCES' due to Hyper-V exclusions).
  • Tab Restoration Throttling: Restored sessions with many dirty tabs now queue and cap concurrent disk-verification reads to 3, preventing congestion and RPC timeouts on high-latency SSH/remote runtimes.

Screenshots

No visual change.

Testing

  • pnpm lint
  • pnpm typecheck
  • pnpm test
  • pnpm build
  • Added or updated high-quality tests that would catch regressions, or explained why tests were not needed

Note: Extensive unit testing added for daemon entry validation ('verify-packaged-daemon-entry.test.mjs'), parcel watcher lifecycle state machine ('parcel-watcher-process.test.ts'), WS port selection fallback strategies ('ws-transport.test.ts'), and tab scan queueing concurrency ('editor-restored-tab-conflict-scan.test.ts').

AI Review Report

The code review with the AI coding agent verified:

  • Cross-platform validation: Assured that cross-arch layout checks do not attempt to boot host-incompatible binaries but still assert correct filesystem placement.
  • Watcher state-machine safety: Verified that tearing down idle watcher child processes does not trigger infinite respawn loops or crash-fuse limits, and correctly flushes/resolves any remaining unsubscribe promises.
  • Socket error resilience: Inspected the port candidate waterfall loop. Confirmed that non-'EADDRINUSE' errors (like 'EACCES' on Windows) on the fallback port fall through correctly to the preferred port instead of crashing the process or disabling the transport entirely.

Security Audit

A security audit from the AI coding agent confirmed:

  • No sensitive keys or auth tokens are exposed via the WebSocket transport or fallback port store.
  • Command execution for process spawning ('verifyPackagedDaemonEntryBoots' and 'parcel-watcher-process') uses safe native APIs with rigid argument parsing, avoiding shell injection risks.
  • IPC and socket error handling are hardened against local port starvation and exclusion lists on Windows.

Notes

  • Persisting and prioritizing fallback ports resolves mobile pairing disconnection issues (STA-1511).
  • The Windows dynamic port exclusion problem ('Hyper-V EACCES') is now successfully mitigated.

@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: bd233b1d-a4a9-4fe7-a99b-96c14adb5ab1

📥 Commits

Reviewing files that changed from the base of the PR and between fa2ef4e and 6dfdb82.

📒 Files selected for processing (14)
  • config/electron-builder.config.cjs
  • config/scripts/electron-builder-config.test.mjs
  • config/scripts/verify-packaged-daemon-entry.cjs
  • config/scripts/verify-packaged-daemon-entry.test.mjs
  • package.json
  • src/main/index.ts
  • src/main/ipc/parcel-watcher-process.test.ts
  • src/main/ipc/parcel-watcher-process.ts
  • src/main/runtime/rpc/ws-fallback-port-store.ts
  • src/main/runtime/rpc/ws-transport.test.ts
  • src/main/runtime/rpc/ws-transport.ts
  • src/main/runtime/runtime-rpc.ts
  • src/renderer/src/components/editor/editor-restored-tab-conflict-scan.test.ts
  • src/renderer/src/components/editor/editor-restored-tab-conflict-scan.ts

📝 Walkthrough

Walkthrough

This PR adds a hard-failing existence check for the packaged daemon entry file during electron-builder's afterPack step, applies ORCA_MAC_RELEASE env var to an additional build script, refines WebSocketTransport's start-up port binding to prefer a persisted fallback port before the preferred port, adds idle teardown of the parcel-watcher child process once all subscriptions are removed, and introduces a concurrency-capped queue for restored-tab disk baseline verification in the editor. Corresponding tests and clarifying comments were added or updated across these areas.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The template sections are present, but the AI Review Report does not explicitly confirm macOS, Linux, and Windows checks across shortcuts, labels, paths, and shell behavior. Expand the AI Review Report to explicitly cover macOS, Linux, and Windows behavior, including shortcuts, labels, paths, shell behavior, and Electron-specific differences.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main changes: layout validation, watcher lifecycle, and WebSocket robustness.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: d70d6cb9-ae17-41f2-94d6-cdb27c6fc674

📥 Commits

Reviewing files that changed from the base of the PR and between 24d7f6b and fa2ef4e.

⛔ Files ignored due to path filters (1)
  • evidence-awaiting-permission.png is excluded by !**/*.png
📒 Files selected for processing (14)
  • config/electron-builder.config.cjs
  • config/scripts/electron-builder-config.test.mjs
  • config/scripts/verify-packaged-daemon-entry.cjs
  • config/scripts/verify-packaged-daemon-entry.test.mjs
  • package.json
  • src/main/index.ts
  • src/main/ipc/parcel-watcher-process.test.ts
  • src/main/ipc/parcel-watcher-process.ts
  • src/main/runtime/rpc/ws-fallback-port-store.ts
  • src/main/runtime/rpc/ws-transport.test.ts
  • src/main/runtime/rpc/ws-transport.ts
  • src/main/runtime/runtime-rpc.ts
  • src/renderer/src/components/editor/editor-restored-tab-conflict-scan.test.ts
  • src/renderer/src/components/editor/editor-restored-tab-conflict-scan.ts

Comment thread src/renderer/src/components/editor/editor-restored-tab-conflict-scan.ts Outdated
- Throw instead of silently skipping when the packaged daemon-entry is
  missing, preventing layout regressions from passing build checks.
- Terminate idle parcel-watcher processes to reclaim native handles and
  avoid crash-prone native node module teardowns on shutdown.
- Bind the persisted WS fallback port first to prevent orphaning active
  mobile pairings when the preferred port becomes free again.
- Cap concurrent disk reads for restored dirty tab verification at three
  to prevent startup connection bottlenecks on remote SSH workspaces.
This avoids using stale file snapshots (e.g., outdated disk signatures)
if a tab is saved, closed, or re-baselined while waiting in the queue
behind the concurrency limit. The live state is now fetched from the
store and validated immediately before initiating the disk read.
@AmethystLiang
AmethystLiang force-pushed the 1.4.129-rc7-release-prep branch from 5fb82ad to 6dfdb82 Compare July 9, 2026 23:07
@AmethystLiang
AmethystLiang merged commit 69befad into main Jul 9, 2026
8 checks passed
Jinwoo-H added a commit that referenced this pull request Jul 10, 2026
Clean auto-merge, no conflicts (109 files, +7490 from main). Brought in:
- Codex WSL runtime status hooks (#7969); WSL/SSH agent path resolution past
  shell aliases (#7867); WSL source-control path separators (#7966); WSL
  GitLab-auth wake fix (#7967); WSL Codex usage RPC refresh (#7567/#7658)
- Improve workspace cleanup list (#7053) + background removal
- mobile: per-host connection log + Tailscale wedge recovery (#7984/#7980),
  wake slept agents on mobile worktree open (#7906)
- Harden layout validation, watcher lifecycle, connection robustness (#7924)
- Disable experimental worktree card style by default (#7977)

Perf-branch structure preserved (clean auto-merge). typecheck 0 errors; lint 0
errors. CI is the release gate (local runs skipped per env lag).

Co-authored-by: Orca <help@stably.ai>
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