Skip to content

Commit e0f1c3c

Browse files
committed
cleanup desktop loading page
1 parent dec304a commit e0f1c3c

2 files changed

Lines changed: 9 additions & 23 deletions

File tree

packages/desktop/src-tauri/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,8 @@ async fn initialize(app: AppHandle) {
665665
}
666666

667667
let _ = server_ready_rx.await;
668+
669+
tracing::info!("Loading task finished");
668670
}
669671
})
670672
.map_err(|_| ())

packages/desktop/src/loading.tsx

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { Font } from "@opencode-ai/ui/font"
55
import { Splash } from "@opencode-ai/ui/logo"
66
import { Progress } from "@opencode-ai/ui/progress"
77
import "./styles.css"
8-
import { createEffect, createMemo, createSignal, onCleanup } from "solid-js"
8+
import { createEffect, createMemo, createSignal, onCleanup, onMount } from "solid-js"
99
import { commands, events, InitStep } from "./bindings"
1010
import { Channel } from "@tauri-apps/api/core"
1111

@@ -29,36 +29,20 @@ render(() => {
2929
channel.onmessage = (next) => setStep(next)
3030
commands.awaitInitialization(channel as any).catch(() => undefined)
3131

32-
createEffect(() => {
33-
if (phase() !== "sqlite_waiting") return
34-
32+
onMount(() => {
3533
setLine(0)
3634
setPercent(0)
3735

3836
const timers = delays.map((ms, i) => setTimeout(() => setLine(i + 1), ms))
3937

40-
let stop: (() => void) | undefined
41-
let active = true
42-
43-
void events.sqliteMigrationProgress
44-
.listen((e) => {
45-
if (e.payload.type === "InProgress") setPercent(Math.max(0, Math.min(100, e.payload.value)))
46-
if (e.payload.type === "Done") setPercent(100)
47-
})
48-
.then((unlisten) => {
49-
if (active) {
50-
stop = unlisten
51-
return
52-
}
53-
54-
unlisten()
55-
})
56-
.catch(() => undefined)
38+
const listener = events.sqliteMigrationProgress.listen((e) => {
39+
if (e.payload.type === "InProgress") setPercent(Math.max(0, Math.min(100, e.payload.value)))
40+
if (e.payload.type === "Done") setPercent(100)
41+
})
5742

5843
onCleanup(() => {
59-
active = false
44+
listener.then((cb) => cb())
6045
timers.forEach(clearTimeout)
61-
stop?.()
6246
})
6347
})
6448

0 commit comments

Comments
 (0)