Skip to content

TUI autocomplete and session filter mishandle "/" worktree for non-git projects #29537

@crimsondhaks

Description

@crimsondhaks

Description

For non-git projects, the project worktree is intentionally set to "/"
(see packages/opencode/src/project/project.ts where worktree gets that
sentinel value when there's no VCS).

Two TUI sites don't account for this:

  1. packages/opencode/src/cli/cmd/tui/component/prompt/autocomplete.tsx
    line 337: worktree: sync.path.worktree || sync.path.directory || process.cwd()
    "/" is truthy so it's used directly, instead of falling back to the
    project directory.

  2. packages/opencode/src/cli/cmd/tui/context/sync.tsx
    line 119: the guard !project.data.instance.path.worktree || ...
    doesn't catch "/", so the session list filter computes
    path.relative("/", "/tmp/foo") = "tmp/foo" and sends that as a
    path scope to the server instead of falling through to scope: "project".

Same root cause as PR #29180 (fix(tui): handle non-git project paths
when opening editor), which fixed three other call sites but missed
these two.

Plugins

No response

OpenCode version

1.15.11

Steps to reproduce

  1. Run opencode in a directory that has no .git folder (mkdir /tmp/test && cd /tmp/test && opencode)
  2. autocomplete: configure a local "reference" entry in opencode.json — when @-referencing, paths are resolved against "/" instead of the project directory
  3. session filter: opencode session list query includes a path scope derived from "/" rather than the expected "project" scope

Screenshot and/or share link

No response

Operating System

macOS

Terminal

iTerm2

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions