Skip to content

Commit a334702

Browse files
committed
fix(tauri): serialize startup navigation
Let the native CLI manager exclusively navigate the loading window once the managed server is ready. This prevents the loading renderer from racing the native client-state navigation and replacing a document after its access token has been rotated. Error and status reporting remain in the loading renderer, while native navigation continues to preserve authentication redirects. Validated with UI typecheck/build and packaged-resource smoke checks.
1 parent 5d522d4 commit a334702

1 file changed

Lines changed: 3 additions & 16 deletions

File tree

  • packages/ui/src/renderer/loading

packages/ui/src/renderer/loading/main.tsx

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ type PhraseKey = (typeof phraseKeys)[number]
2525

2626
interface CliStatus {
2727
state?: string
28-
url?: string | null
2928
error?: string | null
3029
}
3130

@@ -36,11 +35,6 @@ function pickPhraseKey(previous?: PhraseKey) {
3635
return source[index]
3736
}
3837

39-
function navigateTo(url?: string | null) {
40-
if (!url) return
41-
window.location.replace(url)
42-
}
43-
4438
function annotateDocument() {
4539
if (typeof document === "undefined") {
4640
return
@@ -63,12 +57,7 @@ function LoadingApp() {
6357

6458
async function bootstrapTauri() {
6559
try {
66-
const readyUnlisten = await listen("cli:ready", (event) => {
67-
const payload = (event?.payload as CliStatus) || {}
68-
setError(null)
69-
setStatusKey(null)
70-
navigateTo(payload.url)
71-
})
60+
// Rust owns ready navigation so renderer access rotation stays serialized.
7261
const errorUnlisten = await listen("cli:error", (event) => {
7362
const payload = (event?.payload as CliStatus) || {}
7463
if (payload.error) {
@@ -88,12 +77,10 @@ function LoadingApp() {
8877
setStatusKey(null)
8978
}
9079
})
91-
unsubscribers.push(readyUnlisten, errorUnlisten, statusUnlisten)
80+
unsubscribers.push(errorUnlisten, statusUnlisten)
9281

9382
const result = await invoke<CliStatus>("cli_get_status")
94-
if (result?.state === "ready" && result.url) {
95-
navigateTo(result.url)
96-
} else if (result?.state === "error" && result.error) {
83+
if (result?.state === "error" && result.error) {
9784
setError(result.error)
9885
setStatusKey("loadingScreen.status.issue")
9986
}

0 commit comments

Comments
 (0)