fix: relaunch a killed opencode on local create #523
No reviewers
Labels
No labels
backend
bug
chore
duplication
effort:complex
effort:medium
effort:trivial
enhancement
follow-up
frontend
fullstack
priority:high
ready-for-agent
refactor
security
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
dries/ocman!523
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/ensure-opencode-on-local-create"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
When a project's opencode instance is killed outside ocman, creating a new
session in that project fails forever:
handleCreateSessionpre-ensured the project's instance only for remotesessions:
That comment was wrong. Local
CreateSessiononly ever discovers a port vialsof— it never launches. So a killed instance left the local path with norecovery at all, while remote sessions recovered fine. Message sends already
self-heal through
sendNow->relaunchOpencodeForSession; create-session wasthe one remaining hole.
Change
Run
EnsureProjectOpencodefor local creates too, routed through the sameresolveOwnerseam (an empty remote id resolves to the hub's local host).projectRootForDirectory, so ensuring a worktree path cannot launch asecond instance for the same project.
so Create would fail anyway.
launch, still creates against whatever discovery finds. Unchanged behaviour
for those cases.
Tests
Three new tests in
internal/server/integration_test.go:TestHandleCreateSession_LocalEnsuresBeforeCreateTestHandleCreateSession_EnsuresProjectRootNotWorktreeTestHandleCreateSession_LocalEnsureFailureFallsBackToDiscoveryThe first two fail on the unpatched handler (verified red before the fix):
go test ./internal/...,go vet ./...andgolangci-lint runare clean.Coverage ratchet: ✅ pass
Tolerance: -0.1%. Baseline stored on
gh-pages.