Skip to content

fix: replace isomorphic-git status with direct git diff for worktree support - #1706

Merged
adamdotdevin merged 2 commits into
anomalyco:devfrom
ndraiman:ndraiman/read-file-git-worktree
Aug 28, 2025
Merged

adamdotdevin merged 2 commits into
anomalyco:devfrom
ndraiman:ndraiman/read-file-git-worktree

Conversation

@ndraiman

@ndraiman ndraiman commented Aug 8, 2025 •

Copy link
Copy Markdown
Contributor

Replace complex isomorphic-git status detection with direct git diff command to properly handle git worktrees.

At first, I tried detecting the git root dir using git rev-parse --git-dir and passing it as the gitDir arg to isomorphic-git
But git.status() returned incorrect status.

I saw that packages/opencode/src/file/index.ts already uses direct git commands in the status function,
so I updated the read function to do the same.

the git diff command works correctly in worktrees

Before:

image

After:

image

Closes #891

…support

Replace complex isomorphic-git status detection with direct git diff command to properly handle git worktrees.

fix
@ndraiman
ndraiman force-pushed the ndraiman/read-file-git-worktree branch from 64f40b8 to a8f8bf2 Compare August 8, 2025 16:07
@adamdotdevin
adamdotdevin requested a review from thdxr August 13, 2025 12:17
@adamdotdevin
adamdotdevin merged commit 7fab12d into anomalyco:dev Aug 28, 2025
@ndraiman
ndraiman deleted the ndraiman/read-file-git-worktree branch December 26, 2025 07:46
Rwanbt pushed a commit to Rwanbt/unifia that referenced this pull request May 5, 2026
bussard76 pushed a commit to bussard76/openwork that referenced this pull request May 12, 2026
…co#1706)

After PR anomalyco#1702 introduced `localServerRef` to give `endpointForWorkspace`
a stable identity, `refreshRouteState` synchronously fired
`activateWorkspace` and `loadWorkspaceSessionsInBackground` immediately
after `setBaseUrl`/`setToken`. The `useEffect` that mirrors
`[baseUrl, token]` into the ref runs after the next React commit, so
both calls saw an empty ref and `resolveWorkspaceEndpoint` returned
null for local workspaces:

- listSessions never fired -> sidebar stuck on per-workspace loading
  forever (`retryingWorkspaceIds` never cleared).
- activateWorkspace never fired (but the workspace was still recorded
  as activated, so no retry) -> OpenCode runtime never bound to the
  workspace -> sending a message stayed on "Thinking" indefinitely.

Update `localServerRef.current` synchronously inside refreshRouteState
both on the disconnected path and on the connected path, before any
synchronous `endpointForWorkspace` use. Verified end-to-end via Chrome
MCP: sidebar loads sessions on first paint and a fresh message gets a
streamed reply.

Co-authored-by: src-opn <[email protected]>
AIALRA-0 pushed a commit to AIALRA-0/opencode-turn-engine that referenced this pull request Jun 10, 2026
meSingh pushed a commit to meSingh/opencode that referenced this pull request Sep 6, 2026
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.

/files throws error upon selecting a file if you are in a git worktree

3 participants