From e8465bd7f28cd961e49e015c6699e65bde860441 Mon Sep 17 00:00:00 2001 From: Shinto C V Date: Sat, 8 Aug 2026 01:27:31 +0530 Subject: [PATCH] fix(app): auto-register server working directory as a project MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On connecting to a server, open its working directory as a project so that a fresh `opencode web`/`serve` started in a folder surfaces that folder and its sessions in the UI, instead of an empty "Add project" screen. The web nav and session list are driven by the app's local open-projects store (keyed on worktree), not the server `/project` table. Previously nothing appeared until the user manually typed the folder path into the picker — a common first-run confusion that recurs across #39655, #39040, #27837 and others. Skip the user's home directory and the filesystem root, which the file finder cannot index and would otherwise render as empty projects. Fixes #39655 --- packages/app/src/context/global.tsx | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/packages/app/src/context/global.tsx b/packages/app/src/context/global.tsx index 83438898b54d..2033ef69e453 100644 --- a/packages/app/src/context/global.tsx +++ b/packages/app/src/context/global.tsx @@ -110,6 +110,22 @@ function createServerCtx( const sdk = createServerSdkContext(conn, scope) const sync = createServerSyncContext(sdk) + // Register the server's working directory as an open project so a fresh + // `opencode web`/`serve` in a folder surfaces that folder and its + // sessions in the UI without requiring a manual "Add project". Skip the + // user's home dir and the filesystem root, which the file finder cannot + // index and would otherwise appear empty. + createEffect(() => { + const directory = sync.data.path.directory + const home = sync.data.path.home + if (!directory || !home) return + const key = pathKey(directory) + if (key === pathKey(home) || key === "/") return + if (projects.list().some((project) => pathKey(project.worktree) === key)) return + projects.open(directory) + projects.touch(directory) + }) + function enrich(project: { worktree: string; expanded: boolean }) { const [childStore] = sync.child(project.worktree, { bootstrap: false }) const projectID = childStore.project