Skip to content

setup --cwd and status --cwd read broker state from the invocation directory instead of the target workspace #30

Closed

Description

@VOIDXAI

Bug

setup --cwd <path> and status --cwd <path> can report the wrong session runtime because broker state is resolved from the current process directory instead of the target workspace.

Reproduction

  1. Start or persist a shared broker session for workspace A
  2. From a different directory B, run:
    node plugins/codex/scripts/codex-companion.mjs status --cwd /path/to/A
    node plugins/codex/scripts/codex-companion.mjs setup --cwd /path/to/A --json
  3. Observe that both commands can report direct startup
  4. Run the same commands from inside workspace A
  5. Observe that they report shared session

Root Cause

The --cwd-aware callers resolve the target workspace correctly, but then call getSessionRuntimeStatus(...) without passing that resolved workspace through, so the helper falls back to process.cwd().

Affected paths include:

  • plugins/codex/scripts/codex-companion.mjs
  • plugins/codex/scripts/lib/job-control.mjs
  • plugins/codex/scripts/lib/codex.mjs

Impact

  • Cross-workspace invocations can lie about whether a shared Codex runtime is active.
  • This makes debugging broker reuse confusing.
  • Any tooling that shells into one directory while targeting another can get misleading status output.

Suggested Fix

Thread the resolved workspace root into getSessionRuntimeStatus(...) everywhere --cwd is supported, and add regression coverage for invoking setup and status from a different directory than the target workspace.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions