Skip to content

fix: show git worktrees as selectable projects#83

Open
Fr4nzz wants to merge 1 commit intogrinev:mainfrom
Fr4nzz:fix/show-git-worktrees-as-projects
Open

fix: show git worktrees as selectable projects#83
Fr4nzz wants to merge 1 commit intogrinev:mainfrom
Fr4nzz:fix/show-git-worktrees-as-projects

Conversation

@Fr4nzz
Copy link
Copy Markdown

@Fr4nzz Fr4nzz commented Apr 15, 2026

Summary

  • Git worktrees are currently filtered out of the project list by isLinkedGitWorktree(), making them invisible to the bot
  • Users working in worktrees cannot access their sessions — /projects doesn't list them and /open fails when navigating to a worktree directory
  • OpenCode stores worktree paths in the project's sandboxes field and supports listing sessions by worktree directory, but the bot ignores both

Changes

  • Remove the worktree exclusion filter in getProjects()
  • Include worktree paths from the sandboxes field returned by the OpenCode project API
  • Worktrees now appear as independent selectable projects with their own session histories
  • Remove the now-unused isLinkedGitWorktree() function and its fs/path imports

How to reproduce the bug

  1. Create a git worktree: git worktree add ../my-project-feature
  2. Open OpenCode in the worktree directory and create sessions
  3. Start the Telegram bot and run /projects — the worktree doesn't appear
  4. Try /open and navigate to the worktree — fails with "could not add project"

After this fix

  • /projects lists worktrees alongside regular projects
  • /open successfully adds worktree directories
  • /sessions shows sessions created in the worktree

Test plan

  • Tested on ARM64 Ubuntu with git worktree of an existing repo
  • /projects shows both parent repo and worktree
  • /sessions lists worktree-specific sessions
  • /open can navigate to and select a worktree directory
  • Build passes with zero errors

🤖 Generated with Claude Code

Git worktrees (linked via .git file pointing to parent's .git/worktrees/)
were explicitly filtered out of the project list by isLinkedGitWorktree().
This meant users working in worktrees could never access their sessions
via the bot — /projects didn't list them and /open failed when navigating
to a worktree directory.

The fix:
- Remove the worktree exclusion filter
- Include worktree paths from the project sandboxes field returned by
  the OpenCode API, so worktrees appear as independent selectable
  projects with their own session histories
- Remove the now-unused isLinkedGitWorktree() function

Closes grinev#68 (partially — worktree support was a prerequisite for the
group topics fork's multi-project workflow)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant