Repository navigation
cmux-next agent pane: cap crash reloads; a closed pane is not held by its handshake #16463
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
15bc3f7
cmux-next agent pane: tests for the crash reload loop and a closed pa…
teamleaderleo e2a8687
cmux-next agent pane: crash reload test calls the mutating check outs…
teamleaderleo d33888d
cmux-next agent pane: the bridge test holds the pane until its handsh…
teamleaderleo c57ecf8
cmux-next agent pane: cap crash reloads; a closed pane is not held by…
teamleaderleo ef89546
cmux-next agent pane: review follow-ups for the crash notice
teamleaderleo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
Packages/macOS/CmuxNext/Sources/CmuxNextAgentPane/AgentPaneCrashReloads.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| import Foundation | ||
|
|
||
| /// Decides whether a pane reloads its page after the web content process | ||
| /// crashes. A page that crashes as it loads would otherwise reload forever. | ||
| nonisolated struct AgentPaneCrashReloads: Equatable, Sendable { | ||
| /// Reloads allowed within ``window``. The window is long because one | ||
| /// load-to-crash cycle can take 20 seconds or more (the handshake waits | ||
| /// for acpmux), and a slow crash loop must stop too. | ||
| static let limit = 3 | ||
| static let window: TimeInterval = 600 | ||
|
|
||
| private var crashes: [Date] = [] | ||
|
|
||
| /// Records a crash at `now`; true when the page should reload. | ||
| mutating func shouldReload(at now: Date) -> Bool { | ||
| crashes.removeAll { now.timeIntervalSince($0) >= Self.window } | ||
| crashes.append(now) | ||
| return crashes.count <= Self.limit | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -24,10 +24,10 @@ final class AgentPaneNavigation: NSObject, WKNavigationDelegate { | |||||||||
| view?.replayCustomization() | ||||||||||
| } | ||||||||||
|
|
||||||||||
| /// A crashed web content process leaves a blank pane; reload the page, | ||||||||||
| /// which asks for a fresh handshake and reattaches the session. | ||||||||||
| /// A crashed web content process leaves a blank pane; the view reloads | ||||||||||
| /// the page, which asks for a fresh handshake and reattaches the session. | ||||||||||
|
Comment on lines
+27
to
+28
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P3: This comment still describes an unconditional reload, but Prompt for AI agents
Suggested change
|
||||||||||
| func webViewWebContentProcessDidTerminate(_ webView: WKWebView) { | ||||||||||
| view?.source.load(into: webView) | ||||||||||
| view?.webContentProcessDidTerminate() | ||||||||||
| } | ||||||||||
|
|
||||||||||
| enum Decision: Equatable { | ||||||||||
|
|
||||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2: This elapsed-time cap uses wall-clock
Date, so system-clock corrections can suppress reloads for too long or allow them too soon. Track crashes withContinuousClock.Instant(or uptime) instead.Prompt for AI agents