Skip to content

Commit 675b80c

Browse files
committed
Revert "fix(tauri): serialize startup navigation"
This reverts commit 5b957ca.
1 parent a334702 commit 675b80c

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

  • packages/ui/src/renderer/loading

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

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

2626
interface CliStatus {
2727
state?: string
28+
url?: string | null
2829
error?: string | null
2930
}
3031

@@ -35,6 +36,11 @@ function pickPhraseKey(previous?: PhraseKey) {
3536
return source[index]
3637
}
3738

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

5864
async function bootstrapTauri() {
5965
try {
60-
// Rust owns ready navigation so renderer access rotation stays serialized.
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+
})
6172
const errorUnlisten = await listen("cli:error", (event) => {
6273
const payload = (event?.payload as CliStatus) || {}
6374
if (payload.error) {
@@ -77,10 +88,12 @@ function LoadingApp() {
7788
setStatusKey(null)
7889
}
7990
})
80-
unsubscribers.push(errorUnlisten, statusUnlisten)
91+
unsubscribers.push(readyUnlisten, errorUnlisten, statusUnlisten)
8192

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

0 commit comments

Comments
 (0)