Skip to content

fix: reuse opencode control session across orch-monitor --new#425

Open
proboscis wants to merge 1 commit intomainfrom
issue/orch-440/run-20260212-221930
Open

fix: reuse opencode control session across orch-monitor --new#425
proboscis wants to merge 1 commit intomainfrom
issue/orch-440/run-20260212-221930

Conversation

@proboscis
Copy link
Owner

Summary

  • Add retry/backoff session lookup in getOrCreateOpenCodeControlSession() so transient opencode server restarts during orch-monitor --new do not immediately force a new control session.
  • Make recovery more robust by normalizing directories (clean + symlink resolution) and adding a global title-based fallback (orch-control) when directory-scoped lookup cannot recover.
  • Add explicit daemon log reasons for reuse/recovery failures and extend daemon tests for retry behavior, global fallback recovery, path normalization, and fresh-session creation.

Testing

  • go test -v ./internal/daemon -run "TestGetOrCreateOpenCodeControlSession(ReusesExisting|CreatesNewWhenNoStoredSession|RetriesLookupBeforeReuse|RecoversAfterServerRestart|RecoversFromGlobalListWhenDirectoryLookupEmpty|CreatesWhenRecoveryFindsNoSession)|TestFindBestOpenCodeControlSessionNormalizesProjectRootPath" -count=1
  • go test ./internal/daemon -count=1
  • go build ./...

Acceptance Criteria Evidence

  • orch-monitor --new preserves control session history when opencode server is still running
    • Verified by TestGetOrCreateOpenCodeControlSessionReusesExisting
    • Verified by TestGetOrCreateOpenCodeControlSessionRetriesLookupBeforeReuse (transient not-found before successful reuse)
  • Session reuse works even if paths differ by trailing slash or symlink resolution
    • Verified by TestFindBestOpenCodeControlSessionNormalizesProjectRootPath (symlink root + trailing slash)
  • --new-control-agent still correctly creates a fresh session
    • Verified by TestGetOrCreateOpenCodeControlSessionCreatesNewWhenNoStoredSession (no stored session => direct fresh create path)
  • Add daemon log messages when session reuse fails (with reason) for debuggability
    • Verified by TestGetOrCreateOpenCodeControlSessionCreatesWhenRecoveryFindsNoSession (asserts failure-reason log output)
  • Add test for path normalization in findBestOpenCodeControlSession()
    • Added TestFindBestOpenCodeControlSessionNormalizesProjectRootPath

Refs: orch-440

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