From 992fb0336f8165cb76539b79d35f3f4372c94753 Mon Sep 17 00:00:00 2001 From: dhaksdhakshin Date: Wed, 27 May 2026 13:03:32 +0530 Subject: [PATCH] fix(tui): handle non-git project paths in autocomplete and session filter For non-git projects worktree is set to "/". Two TUI sites used this value directly: autocomplete passed "/" to Reference.resolveAll, and the session list filter computed a relative path against "/" instead of falling through to scope=project. Treat "/" as invalid in both, matching the pattern from #29180. Closes #29537 --- .../src/cli/cmd/tui/component/prompt/autocomplete.tsx | 3 ++- packages/opencode/src/cli/cmd/tui/context/sync.tsx | 7 +++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/opencode/src/cli/cmd/tui/component/prompt/autocomplete.tsx b/packages/opencode/src/cli/cmd/tui/component/prompt/autocomplete.tsx index 2bda73cff76d..911f00aa5e42 100644 --- a/packages/opencode/src/cli/cmd/tui/component/prompt/autocomplete.tsx +++ b/packages/opencode/src/cli/cmd/tui/component/prompt/autocomplete.tsx @@ -334,7 +334,8 @@ export function Autocomplete(props: { Reference.resolveAll({ references: ConfigReference.normalize(sync.data.config.reference ?? {}), directory: sync.path.directory || process.cwd(), - worktree: sync.path.worktree || sync.path.directory || process.cwd(), + worktree: + (sync.path.worktree === "/" ? undefined : sync.path.worktree) || sync.path.directory || process.cwd(), }), ) diff --git a/packages/opencode/src/cli/cmd/tui/context/sync.tsx b/packages/opencode/src/cli/cmd/tui/context/sync.tsx index 9f8a384f777f..95f04358fbef 100644 --- a/packages/opencode/src/cli/cmd/tui/context/sync.tsx +++ b/packages/opencode/src/cli/cmd/tui/context/sync.tsx @@ -116,11 +116,10 @@ export const { use: useSync, provider: SyncProvider } = createSimpleContext({ function sessionListQuery(): { scope?: "project"; path?: string } { if (!kv.get("session_directory_filter_enabled", true)) return { scope: "project" } - if (!project.data.instance.path.worktree || !project.data.instance.path.directory) return { scope: "project" } + const worktree = project.data.instance.path.worktree + if (!worktree || worktree === "/" || !project.data.instance.path.directory) return { scope: "project" } return { - path: path - .relative(path.resolve(project.data.instance.path.worktree), project.data.instance.path.directory) - .replaceAll("\\", "/"), + path: path.relative(path.resolve(worktree), project.data.instance.path.directory).replaceAll("\\", "/"), } }