opencode-mission-control icon indicating copy to clipboard operation
opencode-mission-control copied to clipboard

bug: mc_report detection fails for jobs with custom worktreeBasePath

Open nigel-dev opened this issue 9 months ago • 1 comments

Description

`mc_report` auto-detects which job is calling by checking if the current working directory is inside a managed worktree. However, the detection logic in `isInManagedWorktree()` only checks against the default XDG data directory — jobs launched with a custom `worktreeBasePath` config won't be detected.

Steps to Reproduce

  1. Configure a custom worktree base path: ```json { "worktreeBasePath": "/tmp/mc-worktrees" } ```
  2. Launch a job — it creates a worktree under `/tmp/mc-worktrees/`.
  3. The spawned agent calls `mc_report` from within the worktree.
  4. `isInManagedWorktree()` checks against the default path, doesn't find a match.
  5. Agent gets: "mc_report can only be used from within a managed Mission Control worktree."

Expected Behavior

`mc_report` should detect jobs in worktrees at any configured base path, not just the default.

Actual Behavior

```typescript // src/lib/worktree.ts:183 if (!resolvedPath.startsWith(XDG_DATA_DIR)) { return { isManaged: false }; } ```

Only checks the hardcoded XDG data directory.

Proposed Fix

  1. Read the MC config to get the actual `worktreeBasePath`.
  2. Check the CWD against both the default path AND the configured custom path.
  3. Alternatively, match the CWD against known job worktree paths from `jobs.json` — this is more robust and handles any path configuration.

Files Involved

  • `src/lib/worktree.ts:183` — `isInManagedWorktree()` path check
  • `src/tools/report.ts` — calls `isInManagedWorktree()`
  • `src/lib/config.ts` — `worktreeBasePath` config

Additional Context

From audit report Appendix B: "mc_report — Only works for worktrees in the default basePath. Custom paths break detection."

nigel-dev avatar Feb 12 '26 03:02 nigel-dev

Closing as obsolete with Mission Control 2.0 (#94): worktrees are always created under Mission Control's data directory and worktreeBasePath is no longer read; job detection also canonicalizes both paths now.

nigel-dev avatar Nov 20 '26 19:11 nigel-dev