Skip to content

--continue resumes latest session across root-level git worktrees instead of current worktree #25963

Closed as not planned

Description

@scotthaleen

Description

I run opencode as a long-lived local server, then attach to a specific checkout/worktree by passing --dir:

opencode serve --hostname 0.0.0.0 --port 4069 --mdns --print-logs
opencode attach http://localhost:4069 --dir /Users/scott/worktree/opencode-feature-a -c

I use --dir as the explicit target checkout/worktree directory. This workflow previously resumed the latest session for the --dir worktree, but that behavior seems to have changed recently.

With root-level git worktrees for the same repo:

/Users/scott/Source/opencode               [dev]
/Users/scott/worktree/opencode-feature-a   [feat/opencode-feature-a]
/Users/scott/worktree/opencode-feature-b   [feat/opencode-feature-b]

-c appears to continue the most recently updated session across all of those root-level worktrees, instead of the latest session for the --dir directory. For example, attaching with --dir /Users/scott/worktree/opencode-feature-a -c can resume a session whose directory is /Users/scott/Source/opencode.

This seems related to the session filtering change in #24849 / v1.14.30, where TUI session filtering moved to project-relative paths. For root-level worktrees, the relative path is "" for every worktree, so all of these checkouts match the same continuation scope:

/Users/scott/Source/opencode              -> ""
/Users/scott/worktree/opencode-feature-a  -> ""
/Users/scott/worktree/opencode-feature-b  -> ""

Expected: --continue should prefer the latest session whose stored directory exactly matches the attached/current --dir directory.

Actual: --continue can resume the latest root-level session from another worktree/checkout of the same repo.

Related: possibly related to #18890, and likely introduced by or exposed after #24849.

Plugins

None

OpenCode version

1.14.39

Steps to reproduce

  1. Start opencode as a long-lived local server:
opencode serve --hostname 0.0.0.0 --port 4069 --mdns --print-logs
  1. Create two git worktrees for the same repository:
git worktree add ~/worktree/opencode-feature-a -b feat/opencode-feature-a
git worktree add ~/worktree/opencode-feature-b -b feat/opencode-feature-b

Example layout:

/Users/scott/Source/opencode               [dev]
/Users/scott/worktree/opencode-feature-a   [feat/opencode-feature-a]
/Users/scott/worktree/opencode-feature-b   [feat/opencode-feature-b]
  1. Create a session in one worktree, send any prompt, then exit:
opencode attach http://localhost:4069 --dir /Users/scott/worktree/opencode-feature-a
  1. Create or update a session in the main checkout so it is the most recently updated root-level session, then exit:
opencode attach http://localhost:4069 --dir /Users/scott/Source/opencode
  1. Try to continue the latest session for the feature worktree:
opencode attach http://localhost:4069 --dir /Users/scott/worktree/opencode-feature-a -c
  1. Observe that opencode can resume the most recently updated root-level session from /Users/scott/Source/opencode instead of the session from /Users/scott/worktree/opencode-feature-a.

Screenshot and/or share link

No response

Operating System

macOS 26.4.1

Terminal

Ghostty

Activity

  1. github-actions commented on Jul 8, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions