fix(desktop): keep window title in sync with cluster context switches#604
Merged
nadaverell merged 2 commits intomainfrom May 3, 2026
Merged
fix(desktop): keep window title in sync with cluster context switches#604nadaverell merged 2 commits intomainfrom
nadaverell merged 2 commits intomainfrom
Conversation
The Wails window title was set once on DOM ready and never refreshed. After an in-page context switch via the cluster selector, the OS titlebar kept pointing at the previous cluster (commonly the prod one Radar booted with) while the in-page selector and data layer reflected the new cluster — exactly the kind of state mismatch that invites running destructive actions on the wrong cluster. Register an OnContextSwitch callback in startup() that re-renders the title from the same kubeconfig context the data layer is using. Extracted formatWindowTitle() so main.go's initial title and the live updates share one shape definition. Co-authored-by: Cursor <cursoragent@cursor.com>
Port the cluster-name parser from packages/k8s-ui/src/utils/context-name.ts
to a private Go helper and run the kubeconfig context name through it
before composing the window title. So instead of
Radar — arn:aws:eks:us-east-1:171782501968:cluster/packagear-prod-eks
the OS title bar now reads
Radar — packagear-prod-eks
— exactly what the in-page cluster selector shows for the same cluster.
This closes the residual cosmetic asymmetry: title and selector are now
literally identical for any GKE/EKS-ARN/eksctl/AKS-shaped context, with
graceful pass-through for user-named contexts and the in-cluster sentinel.
Tests mirror the TS suite case-for-case (cmd/desktop/context_name_test.go).
Co-authored-by: Cursor <cursoragent@cursor.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
Register an
OnContextSwitchcallback in the desktop app'sstartup()so the OS window title re-renders whenever the user switches kubeconfig contexts via the in-page cluster selector.cmd/desktop/app.go: extractformatWindowTitle(contextName), add injectablesetWindowTitlefield, register anOnContextSwitchcallback that callsupdateWindowTitle(newContext).cmd/desktop/main.go: use the new helper for the initial title (was duplicated inline).cmd/desktop/app_test.go: regression coverage forformatWindowTitle, the update sequence (initial → switch → disconnect), and the nil-ctx guard beforestartup.Why
The Wails window title was set exactly once in
domReadyand never refreshed. After switching contexts in-app, the OS titlebar kept pointing at the cluster Radar booted with (commonly prod) while the in-page selector and the data layer were on the new cluster — a state mismatch that's especially dangerous in a fleet UI: one of those moments where you click "Delete" thinking you're in dev. Hooking into the existingk8s.OnContextSwitchnotification (already used by the SSE broadcaster atinternal/server/sse.go:235) means the title now derives from the same source of truth as the data layer.Where to start reading
cmd/desktop/app.go:57-69— the newOnContextSwitchregistration instartup().cmd/desktop/app.go:43-55—formatWindowTitle+updateWindowTitle.Risky vs mechanical
startup(). The callback fires from another goroutine afterPerformContextSwitchcompletes; safe because (a)a.ctxis written before the registration call in the same goroutine, and (b)OnContextSwitchsynchronizes viacontextSwitchMu(Lock on register / RLock on dispatch), giving happens-before to the callback.formatWindowTitleextraction + the inlinedomReady/main.gocleanup.Not included
document.titledynamically, so there's nothing to fix there. If we ever start setting it, hook the existingcontext_changedSSE event the broadcaster already emits.Made with Cursor
Note
Low Risk
Low risk: desktop-only window title updates and new context-name parsing helpers; main behavior change is registering an additional
OnContextSwitchcallback and should not affect cluster operations beyond UI labeling.Overview
Keeps the desktop OS window title continuously in sync with kubeconfig context changes by registering a
k8s.OnContextSwitchcallback duringDesktopApp.startup()and routing all title updates through a newupdateWindowTitlehelper.Extracts
formatWindowTitleto centralize title rendering, including shortening provider-specific context strings via newclusterShortNameparsing (GKE/EKS ARN/eksctl/AKS) so the title matches the in-app cluster selector.Adds unit tests covering title formatting, successive context switches (including disconnect/empty context), and a nil-
ctxguard via an injectablesetWindowTitlefunction;main.gonow usesformatWindowTitlefor the initial WailsTitle.Reviewed by Cursor Bugbot for commit a2fee49. Bugbot is set up for automated code reviews on this repo. Configure here.