Repository navigation
ktop Release v0.7.10
ktop v0.7.10 resolves UI freezes in long-running TUI sessions caused by lock inversion between health.APIHealthTracker state transitions and tview.Application.QueueUpdateDraw, synchronous reconnect execution on the UI event thread, and unsynchronized toast identifier handling in application.
Detailed Changes by Category
1. API Health Tracking & Deadlock Prevention (health, application)
Lock-Free Callback Dispatch & Structured Logging (health/api_health.go)
- Problem / Context:
APIHealthTrackerpreviously heldh.mu.Lock()while logging viaslogand invokingonStateChange,onHealthy,onDisconnected, andonTryReconnect. BecauseonStateChangedispatches closures onto thetviewUI loop viaQueueUpdateDraw, and the UI draw loop readsIsAPIDisconnected()/IsAPIHealthy()(acquiringh.mu.RLock()), transient Kubernetes API errors could trigger an AB-BA deadlock freezing the TUI. - Implementation Details: Updated
ReportSuccess,ReportError,scheduleRetry, andTryReconnectto snapshot pending callback references and transition state underh.mu, releaseh.mu.Unlock(), and then invokeslogand callbacks outside the lock. - Impact & Behavioral Notes: Background Kubernetes API disconnect retries, recovery transitions, and retry-timer callbacks no longer block or invert locks with the TUI render loop.
Asynchronous Reconnect Input Handling (application/app_ctrl.go)
- Problem / Context: Pressing
RorrwhileAPIDisconnectedpreviously calledapp.apiHealthTracker.TryReconnect()synchronously insidehandleInputEventon thetviewUI goroutine, whereonStateChangecallstapp.QueueUpdateDrawand self-deadlocks waiting for the UI thread. In addition, the earlyif app.HasActiveToast()guard returned key events before reaching the reconnect handler when the persistent disconnect toast ("API disconnected. Press R to reconnect") was visible. - Implementation Details: Dispatched
go app.apiHealthTracker.TryReconnect()off the UI event thread insideif app.HasActiveToast()wheneverapp.IsAPIDisconnected()is true, and updated the standard'R'/'r'reconnect handler to dispatchgo app.apiHealthTracker.TryReconnect()while guarding with!app.isFilterEditing(). - Impact & Behavioral Notes: Pressing
Rorrfrom the disconnect banner triggers immediate asynchronous reconnection without blocking UI input processing or interfering with active/filter input.
2. Toast Notification Locking (application)
Scoped toastMutex Synchronization (application/app_ui.go)
- Problem / Context: Toast creation and dismissal paths mutated
p.currentToastIDacrossdismissToastInternalwithout acquiringp.toastMutex, andshowToastWithButtons/dismissToastheldp.toastMutexacrossp.root.RemovePage,p.root.AddPage,p.root.SwitchToPage,p.tviewApp.SetFocus, andfocusRestorationCallback. - Implementation Details: Removed
dismissToastInternal, guarded every read and update ofp.currentToastIDdirectly underp.toastMutexinshowToastWithButtons,dismissToast, andhasActiveToast, and releasedp.toastMutexbefore invoking anytviewpage or focus operations. - Impact & Behavioral Notes: Concurrent toast timeouts, button callbacks, and UI draw updates operate without lock-order cycles or data races under
-race.
3. Concurrency Regression Tests (health, application)
- Health Tracker Concurrency Test (
health/api_health_test.go): AddedTestAPIHealthTracker_NoDeadlockAcrossCallbacksAndReaderssimulating a single-threadedQueueUpdateDrawloop alongside concurrent state readers, error transitions, reconnects, and recovery cycles. - Reconnect Key Deadlock Test (
application/health_deadlock_test.go): AddedTestApplication_ReconnectKeyDoesNotSelfDeadlockverifying that pressing'R'while the disconnect toast is displayed triggersTryReconnectasynchronously without blocking the simulation UI loop.
Upgrade & Compatibility Notes
- Backward Compatibility: Fully compatible with existing CLI flags,
kubectl ktopplugin invocation,~/.ktop/config.yaml, and--nouiJSON/JSONL consumers. - Deprecations & Migration Actions: None.
Repository Metrics
5 files changed, 309 insertions(+), 63 deletions(-)
- Documentation: