fix: hierarchical branch crash, git hangs, and adapter timeouts #136
+78
−34
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #135
Resolves a series of critical crashes and hangs when working in repositories with hierarchical branch names (e.g.,
feat/ui,fix/bug-123) and multiple conversation adapters.This PR addresses multiple root causes discovered during deep investigation:
feat/ui), sidecar attempted to create a directory.../feat/uiwithout ensuring the parentfeat/directory existed, causing a crash.sessionIndexmap that was written to concurrently by multiple goroutines during parallel loading. This map was actually dead code (never read), so I removed it to fix the race condition.detectDefaultBranchwas spawning new git processes on every update tick without caching, leading tosyscall.forkExecerrors (file descriptor exhaustion) in active repositories.git statuscommands could hang indefinitely on large repos/slow disks.Sessions()loading, causing the app to freeze on startup.Changes
internal/plugins/workspace/worktree.go: Useos.MkdirAllto ensure parent directories exist when creating worktrees for hierarchical branches.internal/adapter/opencode/adapter.go: Removed unusedsessionIndexmap that was causingfatal error: concurrent map writes.internal/plugins/workspace/diff.go: Added simple in-memory caching todetectDefaultBranchto prevent spawning thousands of git processes.internal/plugins/gitstatus/tree.go: Added 10s timeout togit statuscommands.internal/plugins/conversations/plugin_loading.go: Added timeouts (5s per worktree, 30s total) to adapter loading to prevent infinite startup hangs.internal/adapter/cursor/adapter.go: Added defensive JSON parsing to skip malformed messages instead of crashing.Testing
Verified manually in a repository with:
feat/a,fix/b)Before this fix, sidecar would crash immediately on startup (either segfault or concurrent map write). After these fixes, it launches successfully and handles all branch operations correctly.