Skip to content

refactor(daemon): consolidate listener fanout - #11119

Closed
MumuTW wants to merge 1 commit into
stablyai:mainfrom
MumuTW:task/10984-listener-fanout
Closed

MumuTW wants to merge 1 commit into
stablyai:mainfrom
MumuTW:task/10984-listener-fanout

Conversation

@MumuTW

@MumuTW MumuTW commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Centralize snapshot-safe listener fanout in DaemonPtyAdapter.
  • Reuse one exit-payload constructor for synthetic and daemon exit paths.
  • Preserve the original payload identity semantics: data, exit, and write-unavailable listeners receive independent payload objects, while background-stream listeners retain their existing shared payload.

Closes #10984.

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

Targeted validation:

  • daemon-pty-adapter.test.ts: 138 tests passed
  • Touched-file oxlint and oxfmt --check passed
  • git diff --check passed after rebasing onto current origin/main

The full Node typecheck was attempted but the isolated worktree environment was missing unrelated existing esbuild modules referenced by plugin/relay test files.

AI Review Report

The adversarial review checked listener mutation, unsubscribe-during-emission behavior, payload parity, and exception semantics. It caught that an initial abstraction shared one mutable payload across listeners where the old loops created one per listener. The implementation now accepts a payload factory, and a regression test proves one listener cannot mutate the next listener's payload.

Cross-platform compatibility was reviewed for macOS, Linux, and Windows. This change does not alter shortcuts, labels, paths, shells, Electron platform branches, or host-specific behavior.

Security Audit

No input parsing, command execution, path handling, authentication, secrets, dependencies, or IPC contracts changed. Listener exceptions still propagate with the same semantics, and fanout still snapshots before callbacks can unsubscribe.

Notes

Current main contains five listener-fanout sites in this adapter; all five now use the common primitive.

@MumuTW
MumuTW marked this pull request as ready for review July 28, 2026 07:27
@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The adapter adds a typed exit-listener payload, centralized payload creation, and snapshot-based listener fan-out. Synthetic exits, daemon exits, data events, background stream events, and write-unavailable events use the shared dispatch helper. Tests cover listener unsubscription during dispatch, payload mutation isolation, and matching synthetic and daemon exit payloads including incarnationId.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed It concisely describes the main change: consolidating daemon listener fanout.
Description check ✅ Passed All required sections are present, and the content covers summary, testing, AI review, security, and notes.
Linked Issues check ✅ Passed The refactor matches #10984 by centralizing snapshot-safe fanout and sharing exit-payload construction.
Out of Scope Changes check ✅ Passed The diff stays within daemon-pty-adapter and its tests; no unrelated code changes are indicated.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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 Plus

Run ID: 7ede8368-b499-47b0-af39-44b1470504a0

📥 Commits

Reviewing files that changed from the base of the PR and between df9f559 and 8ddc0f8.

📒 Files selected for processing (2)
  • src/main/daemon/daemon-pty-adapter.test.ts
  • src/main/daemon/daemon-pty-adapter.ts

@MumuTW

MumuTW commented Sep 10, 2026

Copy link
Copy Markdown
Contributor Author

Closing to reduce review load; happy to reopen if this is useful.

@MumuTW MumuTW closed this Sep 10, 2026
@MumuTW
MumuTW deleted the task/10984-listener-fanout branch September 12, 2026 13:16
nwparker added a commit that referenced this pull request Sep 16, 2026
Consolidate snapshot-safe daemon PTY listener delivery and exit payload construction. Reuse listener removal and event types while preserving callback ordering, payload isolation, optional exit fields, and recovery exception handling.

Fixes #10984. Adapted from #11119.

Co-authored-by: MumuTW <[email protected]>
ivanvykopal pushed a commit to ivanvykopal/orca that referenced this pull request Sep 20, 2026
…ai#20945)

Consolidate snapshot-safe daemon PTY listener delivery and exit payload construction. Reuse listener removal and event types while preserving callback ordering, payload isolation, optional exit fields, and recovery exception handling.

Fixes stablyai#10984. Adapted from stablyai#11119.

Co-authored-by: MumuTW <[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.

refactor: daemon-pty-adapter writes the same listener-fanout idiom four times, each with its own copy of the same lint suppression

2 participants