Repository navigation
fix(macos): Stop leaves browser tabs loading during navigation startup - #193307
Conversation
Keep the pending WKNavigation in the native tab until its lifecycle callback, so an early Stop cancels that navigation once it starts instead of leaving WebKit loading indefinitely. Preserve immediate Stop for an already started navigation and retire only matching pending identities. Extend the real WKWebView interruption regression with early Stop and synchronize request arrival and the asynchronous URL projection. Related: #185432.
Use WebKit loading completion to retire same-document requests before later page-initiated navigation. Keep queued URL publication while clearing completed request state at its main-thread notification. Prove Stop after a fragment navigation, and share the existing article fixture to keep the expanded regression below its original test-line count.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review in progressClawSweeper is reviewing this revision. This supersedes any previous blocked status. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Codex review: needs maintainer review before merge. What this changesThis PR defers an early Stop until the matching WebKit navigation starts and clears completed pending navigation state. Example: A Mac tab displays /article, starts navigating to /pending, and immediately receives Stop.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open: it addresses a concrete native-browser cancellation failure still present on main, and the reviewed diff introduces no actionable correctness or security finding. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherThe macOS Browser bridge sends navigation actions to DashboardNativeBrowserHost; each DashboardBrowserTab owns its WKWebView lifecycle and publishes navigation state back to the dashboard. flowchart LR
A[Browser controls] --> B[Native browser host]
B --> C[Native tab owner]
C --> D[WKWebView]
D --> E[Navigation callbacks and KVO]
E --> C
C --> F[Published tab state]
Technical reviewBest possible solution: Keep pending cancellation in the existing tab owner, match navigation identities, and retire completed same-document requests through WebKit’s existing observation lifecycle. Do we have a high-confidence way to reproduce the issue? Current main exposes the direct early-stop path, and the PR reports baseline WebKit failures followed by passing stress runs; this read-only review did not execute the reproduction. Is this the best way to solve the issue? The repair uses the existing lifecycle owner, preserves immediate Stop after navigation starts, and covers the same-document cleanup needed to prevent stale pending state. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 07fce674fd42. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +35, Tests -12, Docs 0. Total +23 across 5 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 5, 2026, 3:22 AM ET / 08:22 UTC. |
|
Merged via squash.
|
openclaw#193307) * fix(macos): settle Stop before browser navigation starts Keep the pending WKNavigation in the native tab until its lifecycle callback, so an early Stop cancels that navigation once it starts instead of leaving WebKit loading indefinitely. Preserve immediate Stop for an already started navigation and retire only matching pending identities. Extend the real WKWebView interruption regression with early Stop and synchronize request arrival and the asynchronous URL projection. Related: openclaw#185432. * fix(macos): retire completed pending browser navigations Use WebKit loading completion to retire same-document requests before later page-initiated navigation. Keep queued URL publication while clearing completed request state at its main-thread notification. Prove Stop after a fragment navigation, and share the existing article fixture to keep the expanded regression below its original test-line count.
Adapt the asynchronous URL projection wait from upstream 91f796d (#193307). Keep the failure UI and URL assertions intact; do not import unrelated navigation changes. Native execution remains pending in release CI. Co-authored-by: RomneyDa <[email protected]> Co-authored-by: vincentkoc <[email protected]>
Adapt upstream #193307 (91f796d) to the release browser owner. Track pending navigation identities across native loads and retire them at lifecycle callbacks or same-document completion; defer early Stop until provisional startup. Keep the existing real WebKit regression and add early Stop and Stop after fragment navigation. The original Stop case failed in FRV 43419749868, macos-swift job 131879740732. Native compile/runtime validation remains pending hosted CI; this Linux host has no Swift, swiftlint, or swiftformat, and local/testbox proof is operator-skipped. Co-authored-by: RomneyDa <[email protected]> Co-authored-by: vincentkoc <[email protected]> (cherry picked from commit 789ae7b28f354f3b2c2b9549ff7cf42e7e6623f2)
Related: #185432, #191802
What Problem This Solves
Fixes: pressing Stop while a Mac browser tab is starting its next navigation can leave WebKit loading indefinitely instead of keeping the current page.
User Impact
Stop keeps the displayed page even when it arrives before the new navigation starts. Existing cancellation, failed-page Reload, history, and crash recovery remain covered.
Why This Change Was Made
Calling
WKWebView.stopLoading()before its queued navigation policy/start callbacks can strand the load. The tab now retains theWKNavigationreturned by each native navigation call and applies an early Stop at that navigation's provisional-start callback. Matching identities keep an older callback from retiring a newer request. Already-started loads still stop immediately.The regression covers both sides of that boundary, waits for real HTTP request arrival for the after-start case, and waits for the asynchronously projected URL before its unchanged final assertions. The old 60-second fixture sleep is replaced with a cancellation-aware gate. Completed same-document navigations retire pending state through WebKit’s loading notification; a fragment-then-page-navigation regression covers this path.
Evidence
Original test on main: repetition 14 failed the Stop URL projection assertion (
/pendingversus WebKit's restored/article).Before: five instrumented Stop-before-start trials timed out. The final regression also failed on unchanged production code; after its original 60-second limit, WebKit still reported
isLoading=true, URL/pending.The first review found stale pending state after fragment-only navigation. Its added regression failed at the original limit before the completion cleanup; the final stress run includes it.
After: 30 repetitions under four CPU load workers, 150 interruption cases passed, in 87.642 seconds wall time. All 36 tests in eight native-browser/fixture suites passed, 4.153 seconds test time / 5.909 seconds wall time.
Real AppKit, WKWebView, native Dashboard controller, and loopback fixtures inside the documented operator-desktop OS sandbox. macOS 27.0.1, Xcode 27.2 beta / Swift 6.4. No app launch/signing, Keychain access, operator Gateway or LaunchAgent changes, or local-model inference. The full loaded CI job itself was not replayed locally.
Native build passed. Pinned SwiftFormat passed. Standard SwiftLint reports only the three pre-existing length violations in unchanged
DashboardManager.swiftandGatewayConnection.swift; changed production files are clean.All baseline ratchets passed on an isolated index of the final committed head. The separate line-cap check passes. No baselines were changed.
Production delta +52/-17 (net +35); tests +64/-76 (net -12). The bounded per-tab pending-navigation state is necessary to retain Stop across the observed asynchronous start boundary; no unrelated deletion was used to offset it.
Codex autoreview of base
d595644b4c6c93b32ede7242bdf2a4f71b8a8c98through head7bbaf78a648e8a1b98459a9bb512abb2bed53fef: scoped-clean through P2, verdict patch is correct. The first review’s same-document finding was reproduced and fixed before this clean pass.Exact-head CI passed
openclaw/ci-gate, security-fast, native i18n, and docs. The macOS Swift jobs were skipped; native execution evidence above is local. Separate Periphery reports are still building.ClawSweeper returned no verdict during the 15-minute observation window; the hosted review check is canceled. The completed independent Codex review above is clean through P2.
No visual appearance or public configuration changes. #191802's test-only candidate does not repair the demonstrated production race; this PR includes the owner fix and its regression.