From ca23bd00e0867deb531bb67aca9e1f51a10f4eb7 Mon Sep 17 00:00:00 2001 From: anntnzrb Date: Fri, 19 Dec 2025 14:24:54 -0500 Subject: [PATCH 1/2] fix: prioritize session list loading when resuming with -c When using 'opencode -c' to resume a session, the session list is now loaded in the blocking phase instead of non-blocking. This eliminates the confusing flash of the dashboard before the resumed session appears. The continue effect now triggers at 'partial' status since the session data is already available at that point. --- packages/opencode/src/cli/cmd/tui/app.tsx | 3 +- .../opencode/src/cli/cmd/tui/context/sync.tsx | 28 +++++++++++++------ 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/packages/opencode/src/cli/cmd/tui/app.tsx b/packages/opencode/src/cli/cmd/tui/app.tsx index 028905fc3ab..e81de188943 100644 --- a/packages/opencode/src/cli/cmd/tui/app.tsx +++ b/packages/opencode/src/cli/cmd/tui/app.tsx @@ -229,7 +229,8 @@ function App() { let continued = false createEffect(() => { - if (continued || sync.status !== "complete" || !args.continue) return + // When using -c, session list is loaded in blocking phase, so we can navigate at "partial" + if (continued || sync.status === "loading" || !args.continue) return const match = sync.data.session .toSorted((a, b) => b.time.updated - a.time.updated) .find((x) => x.parentID === undefined)?.id diff --git a/packages/opencode/src/cli/cmd/tui/context/sync.tsx b/packages/opencode/src/cli/cmd/tui/context/sync.tsx index f74f787db8c..06f29bb22d7 100644 --- a/packages/opencode/src/cli/cmd/tui/context/sync.tsx +++ b/packages/opencode/src/cli/cmd/tui/context/sync.tsx @@ -22,6 +22,7 @@ import { Binary } from "@opencode-ai/util/binary" import { createSimpleContext } from "./helper" import type { Snapshot } from "@/snapshot" import { useExit } from "./exit" +import { useArgs } from "./args" import { batch, onMount } from "solid-js" import { Log } from "@/util/log" import type { Path } from "@opencode-ai/sdk" @@ -256,8 +257,16 @@ export const { use: useSync, provider: SyncProvider } = createSimpleContext({ const exit = useExit() async function bootstrap() { - // blocking - await Promise.all([ + const args = useArgs() + const sessionListPromise = sdk.client.session.list().then((x) => + setStore( + "session", + (x.data ?? []).toSorted((a, b) => a.id.localeCompare(b.id)), + ), + ) + + // blocking - include session.list when continuing a session + const blockingRequests: Promise[] = [ sdk.client.config.providers({}, { throwOnError: true }).then((x) => { batch(() => { setStore("provider", x.data!.providers) @@ -271,17 +280,18 @@ export const { use: useSync, provider: SyncProvider } = createSimpleContext({ }), sdk.client.app.agents({}, { throwOnError: true }).then((x) => setStore("agent", x.data ?? [])), sdk.client.config.get({}, { throwOnError: true }).then((x) => setStore("config", x.data!)), - ]) + ] + + if (args.continue) { + blockingRequests.push(sessionListPromise) + } + + await Promise.all(blockingRequests) .then(() => { if (store.status !== "complete") setStore("status", "partial") // non-blocking Promise.all([ - sdk.client.session.list().then((x) => - setStore( - "session", - (x.data ?? []).toSorted((a, b) => a.id.localeCompare(b.id)), - ), - ), + ...(args.continue ? [] : [sessionListPromise]), sdk.client.command.list().then((x) => setStore("command", x.data ?? [])), sdk.client.lsp.status().then((x) => setStore("lsp", x.data!)), sdk.client.mcp.status().then((x) => setStore("mcp", x.data!)), From 62839f7e32fb0d2114811967df33cdf33c9f1ec0 Mon Sep 17 00:00:00 2001 From: anntnzrb Date: Fri, 19 Dec 2025 17:48:40 -0500 Subject: [PATCH 2/2] refactor: apply review suggestions - Move useArgs() to init top-level for safer SolidJS hook pattern - Use spread syntax instead of .push() to avoid mutation --- packages/opencode/src/cli/cmd/tui/context/sync.tsx | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/packages/opencode/src/cli/cmd/tui/context/sync.tsx b/packages/opencode/src/cli/cmd/tui/context/sync.tsx index 06f29bb22d7..2528a499896 100644 --- a/packages/opencode/src/cli/cmd/tui/context/sync.tsx +++ b/packages/opencode/src/cli/cmd/tui/context/sync.tsx @@ -255,9 +255,9 @@ export const { use: useSync, provider: SyncProvider } = createSimpleContext({ }) const exit = useExit() + const args = useArgs() async function bootstrap() { - const args = useArgs() const sessionListPromise = sdk.client.session.list().then((x) => setStore( "session", @@ -280,12 +280,9 @@ export const { use: useSync, provider: SyncProvider } = createSimpleContext({ }), sdk.client.app.agents({}, { throwOnError: true }).then((x) => setStore("agent", x.data ?? [])), sdk.client.config.get({}, { throwOnError: true }).then((x) => setStore("config", x.data!)), + ...(args.continue ? [sessionListPromise] : []), ] - if (args.continue) { - blockingRequests.push(sessionListPromise) - } - await Promise.all(blockingRequests) .then(() => { if (store.status !== "complete") setStore("status", "partial")