You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
tui: current-directory session picker includes sibling Git worktrees #58108
In the TUI session picker, “Show current directory sessions” also shows sessions from other Git worktrees of the same repository.
Expected: only sessions whose working directory matches the selected directory. Actual: sessions at the same relative subpath in sibling worktrees appear too.
The scoped request in packages/tui/src/component/dialog-session-list.tsx sends project and subpath instead of directory. Worktree roots share a project ID and an empty subpath, so they all match. The local fallback uses exact-directory filtering, making the two paths inconsistent.
Proposed fix: use the existing directory API filter for current-directory mode, with regression coverage for sibling worktrees and the all-projects toggle.
Plugins
No explicit plugin entries found in inspected global/project configs. Local global plugin file: notify.js; runtime activation not verified.
OpenCode version
2.1.2 (latest channel)
Steps to reproduce
Create two Git worktrees of the same repository.
Create a top-level OpenCode session at each worktree root with distinct titles.
In one worktree, open /sessions and select “Show current directory sessions” with Ctrl+A if necessary.
Observe sessions from both worktrees rather than only the selected directory.
Reported by a user and confirmed by tracing the request and backend filters in the source. No manual reproduction recording is available.
Screenshot
Not available.
Operating System
Linux x86_64, kernel 7.1.12-200.fc44.x86_64; shell /bin/bash.
Thanks for the detailed report. I can confirm this on 2.1.2, and it still happens on the latest dev (b42c316).
Steps I used:
Created a git repo and a second worktree with git worktree add.
Created one top-level session in each worktree root. Both sessions get the same project ID.
Opened /sessions in the main worktree. The picker is in current-directory mode (header "Sessions for ", hint "all projects ctrl+a").
The session from the sibling worktree is still listed, labelled with the sibling's directory. The recording and screenshot below show this, and the script below reproduces it.
The cause matches what you traced: for non-global projects, the scoped request sends project + subpath instead of directory, while the local fallback filters on the exact directory.
Related: #51514 (empty subpath handling) and #57635 (only the flat directory filter is honoured by GET /api/session).
recording.mp4
Reproduction script (drive.ts)
// Repro for #58108: "current directory" session picker shows sessions from sibling git worktrees.import{Effect}from"effect"import{join}from"node:path"import{OpenCodeDriver}from"opencode-drive"exportdefaultOpenCodeDriver.use({
...(process.env.OC_DEV ? {opencode: {dev: process.env.OC_DEV}} : {}),project: {git: true,files: {"README.md": "main\n"}},tui: {recording: true,keypressOverlay: true},},({ ui, opencode, artifacts })=>Effect.gen(function*(){constmain=join(artifacts,"files")constsibling=join(artifacts,"sibling-worktree")// Second git worktree of the same repositoryyield*Effect.promise(async()=>{constr=Bun.spawnSync(["git","-C",main,"worktree","add","-q","-b","other",sibling])if(r.exitCode!==0)thrownewError(r.stderr.toString())})consta=yield*opencode.session.create({title: "SESSION-IN-MAIN-WORKTREE",location: {directory: mainasany}})constb=yield*opencode.session.create({title: "SESSION-IN-SIBLING-WORKTREE",location: {directory: siblingasany}})yield*Effect.log(`main=${a.projectID}${JSON.stringify(a.location)} sibling=${b.projectID}${JSON.stringify(b.location)}`)yield*Effect.sleep(1000)yield*ui.submit("/sessions")yield*ui.waitFor("SESSION-IN-MAIN-WORKTREE")yield*Effect.sleep(800)constframe1=yield*ui.capture()yield*ui.screenshot("picker-initial")consttext1=JSON.stringify(frame1)if(!text1.includes("current directory")){// currently in current-directory mode already if hint says "all projects"}yield*Effect.log(`initial frame includes sibling: ${text1.includes("SESSION-IN-SIBLING-WORKTREE")}; hint all projects: ${text1.includes("all projects")}`)// Toggle scope and capture again, so both modes are shownyield*ui.press("a",{ctrl: true})yield*Effect.sleep(1500)constframe2=yield*ui.capture()yield*ui.screenshot("picker-toggled")consttext2=JSON.stringify(frame2)yield*Effect.log(`toggled frame includes sibling: ${text2.includes("SESSION-IN-SIBLING-WORKTREE")}; hint all projects: ${text2.includes("all projects")}`)yield*Effect.sleep(1000)}),)
Run it with opencode-drive: opencode-drive run ./drive.ts. It drives opencode from your PATH; set OC_DEV to the path of an OpenCode checkout to run that from source instead.
Activity
opencode-agent commentedon Oct 22, 2026
Thanks for the detailed report. I can confirm this on 2.1.2, and it still happens on the latest
dev(b42c316).Steps I used:
git worktree add./sessionsin the main worktree. The picker is in current-directory mode (header "Sessions for ", hint "all projects ctrl+a").The session from the sibling worktree is still listed, labelled with the sibling's directory. The recording and screenshot below show this, and the script below reproduces it.
The cause matches what you traced: for non-global projects, the scoped request sends
project+subpathinstead ofdirectory, while the local fallback filters on the exact directory.Related: #51514 (empty subpath handling) and #57635 (only the flat
directoryfilter is honoured byGET /api/session).recording.mp4
Reproduction script (drive.ts)
Run it with opencode-drive:
opencode-drive run ./drive.ts. It drivesopencodefrom yourPATH; setOC_DEVto the path of an OpenCode checkout to run that from source instead.