Skip to content

Fix opencode control-session reuse for monitor layout restarts#421

Open
proboscis wants to merge 2 commits intomainfrom
issue/orch-440/run-20260211-150446
Open

Fix opencode control-session reuse for monitor layout restarts#421
proboscis wants to merge 2 commits intomainfrom
issue/orch-440/run-20260211-150446

Conversation

@proboscis
Copy link
Owner

Summary

  • harden opencode control-session reuse in daemon by retrying stored-session lookup with backoff before giving up
  • normalize directory matching in findBestOpenCodeControlSession (clean + symlink resolution fallback) to handle trailing slash/symlink differences
  • extend recovery flow to try project-scoped session listing first, then unscoped listing with title-based fallback (orch-control)
  • add explicit reuse-failure logging paths with concrete reasons for troubleshooting
  • add/extend daemon tests to cover retries, normalized-path reuse, title fallback recovery, and fresh-session creation when no stored control session exists

Acceptance Criteria Evidence

1) orch-monitor --new preserves control session history when server still running

Verified via daemon reuse and recovery tests:

go test ./internal/daemon -run "TestGetOrCreateOpenCodeControlSessionReusesExisting|TestGetOrCreateOpenCodeControlSessionRetriesStoredLookup|TestGetOrCreateOpenCodeControlSessionRecoversAfterServerRestart" -v

All pass and show stored session is reused/recovered (no new session creation in those paths).

2) Session reuse works with trailing slash/symlink path differences

Verified via normalized path tests:

go test ./internal/daemon -run "TestGetOrCreateOpenCodeControlSessionRecoversWithNormalizedDirectory|TestFindBestOpenCodeControlSessionNormalizesPathComparison" -v

Both pass.

3) --new-control-agent still creates a fresh session

--new-control-agent clears .orch/control-session.json; daemon behavior when no stored session now verified by:

go test ./internal/daemon -run "TestGetOrCreateOpenCodeControlSessionCreatesWhenNoStoredSession" -v

Passes and confirms immediate fresh session creation.

4) Daemon logs include reuse-failure reasons

Verified via:

go test ./internal/daemon -run "TestGetOrCreateOpenCodeControlSessionLogsReuseFailureReason" -v

Passes and asserts log output includes explicit failure reasons for reuse and recovery listing failures.

5) Add test for path normalization in findBestOpenCodeControlSession

Added and verified:

go test ./internal/daemon -run "TestFindBestOpenCodeControlSessionNormalizesPathComparison" -v

Passes.

Validation Run

  • go test ./internal/daemon -run "Test(GetOrCreateOpenCodeControlSession|FindBestOpenCodeControlSession)"
  • go build ./...
  • make lint
  • go test ./... ❌ (pre-existing unrelated failure in internal/cli):
    • TestApplyConfigDefaultsFallbacks fails with invalid config schema ... config.yaml: EOF

Refs: orch-440

@proboscis proboscis force-pushed the issue/orch-440/run-20260211-150446 branch from 6cdf8cd to 99d865e Compare February 11, 2026 06:59
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