Tighten browser devtools close timing

This commit is contained in:
austinpower1258 2026-03-17 17:37:01 -07:00
parent 8397b32067
commit 48426bf1ec
2 changed files with 10 additions and 3 deletions

View file

@ -4221,11 +4221,18 @@ extension BrowserPanel {
func noteDeveloperToolsHostAttached() {
cancelPendingDeveloperToolsVisibilityLossCheck()
developerToolsLastAttachedHostAt = Date()
developerToolsLastKnownVisibleAt = isDeveloperToolsVisible() ? Date() : nil
if isDeveloperToolsVisible() {
developerToolsLastKnownVisibleAt = Date()
}
}
func scheduleDeveloperToolsVisibilityLossCheck() {
developerToolsVisibilityLossCheckWorkItem?.cancel()
let attachedAge = developerToolsLastAttachedHostAt.map { Date().timeIntervalSince($0) } ?? 0
let delay = max(
developerToolsTransitionSettleDelay,
developerToolsAttachedManualCloseDetectionDelay - attachedAge
)
let workItem = DispatchWorkItem { [weak self] in
guard let self else { return }
self.developerToolsVisibilityLossCheckWorkItem = nil
@ -4233,7 +4240,7 @@ extension BrowserPanel {
}
developerToolsVisibilityLossCheckWorkItem = workItem
DispatchQueue.main.asyncAfter(
deadline: .now() + developerToolsTransitionSettleDelay,
deadline: .now() + max(0, delay),
execute: workItem
)
}

View file

@ -542,7 +542,7 @@ struct BrowserPanelView: View {
// `isVisibleInUI` never flips to false. Check for an attached-inspector
// X-close when focus leaves as well so the persisted intent stays in sync.
DispatchQueue.main.async {
_ = panel.consumeAttachedDeveloperToolsManualCloseIfNeeded()
panel.scheduleDeveloperToolsVisibilityLossCheck()
}
}
syncWebViewResponderPolicyWithViewState(