Skip to content

Suppress Pi notifications after interrupted turns - #9451

Merged
lawrencecchen merged 3 commits into
mainfrom
fix/pi-interrupt-notification
Aug 4, 2026
Merged

lawrencecchen merged 3 commits into
mainfrom
fix/pi-interrupt-notification

Conversation

@lawrencecchen

@lawrencecchen lawrencecchen commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • suppress Pi completion notifications for native aborted turns and extension-declared immediate-submit interruptions
  • still emit Stop lifecycle bookkeeping while marking the native cmux fallback as already handled
  • preserve normal completion notifications and fallback behavior when notification delivery genuinely fails
  • keep agent_end inspection to one reverse pass and leave all subprocess work on the existing detached lifecycle queue

This is a narrow alternative to the broader unsuccessful-outcome work in #9021, and additionally covers input extensions that normalize an abort to stop to avoid Pi's aborted-message UI.

Testing

  • added generated-extension integration coverage for native Pi aborts and double-Enter/immediate-submit interruption markers
  • test-only ebac29cf20: CI app-host shard 4 failed in the new interrupted-turn assertion, proving the regression
  • fixed 0bac41fa56: full dispatched CI passed, including tests/test_pi_extension_install.py, aggregate tests, and the universal Release build
  • git diff --check
  • existing tests/test_pi_extension_dispatch.py covers immediate lifecycle-handler return and serialized detached hook delivery
  • /autoreview: local codex review --base origin/main found no actionable regressions; CodeRabbit found no actionable comments and passed its blocking-runtime and algorithmic-complexity checks
  • installed-extension TypeScript check passed after mirroring the interruption detector locally
  • tagged Debug build attempted with ./scripts/reload.sh --tag piintnotif; package resolution hit a transient Sentry artifact HTTP 500, then the retry was blocked by the repository's non-bypassable 250 GiB free-space floor. CI's macOS test and universal Release-build lanes passed instead.

Demo Video

  • Video URL or attachment: N/A — hook integration behavior with no UI changes

Review Trigger (Copy/Paste as PR comment)

@codex review
@coderabbitai review
@greptile-apps review
@cubic-dev-ai review

Checklist

  • I tested the change locally
  • I added or updated tests for behavior changes
  • I updated docs/changelog if needed (not needed; no user-facing strings or documented API changed)
  • I requested bot reviews after my latest commit (copy/paste block above or equivalent)
  • All code review bot comments are resolved
  • All human review comments are resolved (none received)

Summary by CodeRabbit

  • Bug Fixes
    • Improved handling of aborted and immediately submitted turns.
    • Prevented duplicate stop events, shutdown hooks, and completion handling.
    • Suppressed redundant notifications when stop events have already been routed.
    • Improved resume-operation event ordering and lifecycle consistency.
    • Added safeguards to ensure aborted completions do not trigger unwanted notifications.

@lawrencecchen
lawrencecchen marked this pull request as ready for review August 3, 2026 11:06
@coderabbitai

coderabbitai Bot commented Aug 3, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The Pi extension suppresses duplicate completion notifications for aborted and explicitly marked completions. Regression tests verify single routed Stop events and updated asynchronous lifecycle behavior.

Changes

Pi completion lifecycle

Layer / File(s) Summary
Completion notification routing
CLI/CMUXCLI+PiExtensionSourcePart1.swift, CLI/CMUXCLI+PiExtensionSourcePart2.swift
Pending completions record notification suppression. Aborted or explicitly marked completions skip explicit notification dispatch and mark the Stop payload as routed.
Lifecycle regression coverage
tests/test_pi_extension_install.py
Tests cover aborted and immediate-submit sessions, duplicate-settlement prevention, updated lifecycle counts, resume binding operations, and routed Stop payloads.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant AgentEnd
  participant PendingCompletion
  participant publishPendingCompletion
  participant StopHook
  AgentEnd->>PendingCompletion: record completion and suppression state
  PendingCompletion->>publishPendingCompletion: publish pending completion
  publishPendingCompletion->>StopHook: emit routed Stop payload
  publishPendingCompletion-->>StopHook: suppress duplicate notification
Loading

Possibly related PRs

Suggested reviewers: austinywang, mrohan-sq


Important

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Cmux Cache Substitution Correctness ❓ Inconclusive The working tree has no diff, so the production changes cannot yet be compared with the cache-substitution rule. Provide the pull request diff or checkout the PR head and rerun the check.
✅ Passed checks (24 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
Cmux Swift Actor Isolation ✅ Passed The PR changes only TypeScript inside existing Swift raw-string constants; no Swift models, protocols, Sendable references, actors, or UI-bound accesses changed.
Cmux Swift Blocking Runtime ✅ Passed The PR-local Swift diff only changes generated Pi completion metadata and async hook dispatch; it adds no semaphore, wait, sleep, timer, polling, sync, or lock primitive.
Cmux Browser Automation Off-Main ✅ Passed The complete PR diff changes only two Pi extension Swift sources and one Pi integration test; it does not touch browser socket routing, WebKit waits, or policy tests.
Cmux Expensive Synchronous Load ✅ Passed The Swift diff only changes in-memory Pi completion inspection and notification state; it adds no agent-history loader, file read, JSON decode, directory scan, or main-actor synchronous load.
Cmux No Hacky Sleeps ✅ Passed The PR changes only Swift production code and Python test scaffolding; no new production sleep, timer, polling, delayed dispatch, or wall-clock wait appears in the diff.
Cmux Algorithmic Complexity ✅ Passed The production change uses one reverse pass over messages and scans each message's content once; it adds no per-target rescans, sorting, filtering, joins, or superlinear work.
Cmux Swift Concurrency ✅ Passed The PR adds only generated TypeScript inside Swift raw-string constants and test code; added Swift lines introduce no DispatchQueue, Combine, completion-handler, or fire-and-forget Task pattern.
Cmux Swift @Concurrent ✅ Passed The Swift diff only changes embedded TypeScript string literals; it adds no Swift async, nonisolated, @concurrent, or actor-isolation code or call sites.
Cmux Swift Package Boundaries ✅ Passed The production diff only updates embedded Pi extension TypeScript in CLI source; it is Pi/Node and cmux lifecycle glue, not reusable Swift domain logic requiring a SwiftPM target.
Cmux Swiftpm Lockfiles ✅ Passed The PR diff contains only tests/test_pi_extension_install.py and two CLI Swift sources; it changes no Package.swift, Package.resolved, .gitignore, workflow, or Xcode project files.
Cmux Swift Logging ✅ Passed The PR Swift diff adds no print, debugPrint, dump, NSLog, Logger, file/stdout diagnostics, or sensitive logging; it only changes notification state and routing.
Cmux User-Facing Error Privacy ✅ Passed The production diff changes notification routing and stop metadata only; it adds no user-facing error text, while new failure messages are test-only.
Cmux Full Internationalization ✅ Passed The production diff only adds interruption state, protocol markers, and developer comments in the embedded Pi extension; it adds no user-facing copy or catalog/web locale changes. Tests are allowed.
Cmux Swiftui State Layout ✅ Passed The PR changes embedded TypeScript raw strings in two CMUXCLI extensions and Python tests; no SwiftUI views, state wrappers, GeometryReader, lazy rows, or render-time state writes were added.
Cmux Architecture Rethink ✅ Passed The PR adds no production timing, blocking, polling, observer, lock, or duplicate UI wiring; suppression stays in the existing per-session PendingCompletion owner with explicit settlement invariants.
Cmux Swift Auxiliary Window Close Shortcuts ✅ Passed The PR adds no NSWindow, NSPanel, NSWindowController, Window, or WindowGroup code. The auxiliary-window lint passes.
Cmux Source Artifacts ✅ Passed The PR changes only two Xcode-tracked Swift source files and one existing Python regression test; no logs, caches, build output, scratch directories, or copied artifacts enter the diff.
Cmux No Test Or Debug Seam In Production Source ✅ Passed The PR changes only CLI/*.swift and tests/test_pi_extension_install.py; no changed Swift file is under a production Sources/ path, and no in-scope seam was added.
Cmux No Ambient Global State ✅ Passed The only changed Swift declarations are static source constants inside extension CMUXCLI; the added interface and function are inside embedded TypeScript raw strings, not Swift global state.
Title check ✅ Passed The title clearly and concisely describes the primary change: suppressing Pi notifications after interrupted turns.
Description check ✅ Passed The description follows the repository template and documents the change, testing, demo status, review trigger, and checklist.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/pi-interrupt-notification

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.

@chatgpt-codex-connector

Copy link
Copy Markdown

Summary

Testing

  • ✅ git diff --check
  • ✅ bun build "$tmpfile" --target=bun --external='@earendil-works/pi-coding-agent' --outfile=/tmp/cmux-pi-extension-check.js
  • ⚠️ ./scripts/reload.sh --tag pr9451-pi-interrupt (environment limitation: Zig is not installed)
  • ⚠️ python3 tests/test_pi_extension_install.py (environment limitation: no built cmux CLI was available because the tagged build could not run)

View task →

@cursor

cursor Bot commented Aug 3, 2026

Copy link
Copy Markdown

Bugbot is paused — on-demand spend limit reached

Bugbot uses usage-based billing for this team and has hit its on-demand spend limit.

A team admin can raise the spend limit in the Cursor dashboard, or wait for the next billing cycle to continue.

@lawrencecchen

Copy link
Copy Markdown
Contributor Author

@codex review
@coderabbitai review
@greptile-apps review
@cubic-dev-ai review

@cubic-dev-ai

cubic-dev-ai Bot commented Aug 3, 2026

Copy link
Copy Markdown

@codex review
@coderabbitai review
@greptile-apps review
@cubic-dev-ai review

@lawrencecchen I can't start this review because your workspace has reached its free monthly review limit. cubic has reviewed 245,275 of the 240,000 allowed lines of code this month. Reviews resume on 1 September 2026 (in 29 days). Paid plans include much higher monthly review limits. Upgrade now to resume reviews.

To help optimise your usage, you can tune cubic to get the most out of your usage limits:

Learn more →

@coderabbitai

coderabbitai Bot commented Aug 3, 2026 •

Copy link
Copy Markdown

@lawrencecchen I will review the changes in #9451.

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create a Codex account and connect to github.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

Reviewed commit: 0bac41fa56

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@lawrencecchen

Copy link
Copy Markdown
Contributor Author

Regression proof:

  • Test-only ebac29cf20: app-host shard 4 failed in test_pi_extension_install.py because an interrupted turn emitted the extra completion path.
  • Fixed 0bac41fa56: app-host shard 4 passed, including the generated Pi extension integration test; the aggregate tests gate is green.

@lawrencecchen

Copy link
Copy Markdown
Contributor Author

Fixed-head CI completed successfully: https://github.com/manaflow-ai/cmux/actions/runs/30810176184

@lawrencecchen

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: 61886e4ab8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@lawrencecchen
lawrencecchen merged commit cec7ac3 into main Aug 4, 2026
24 checks passed
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