Skip to content

fix(dashboard): run OpenCode model probes from the Magic Context data folder - #969

Open
iceteaSA wants to merge 3 commits into
cortexkit:masterfrom
iceteaSA:fix/964-probe-cwd
Open

iceteaSA wants to merge 3 commits into
cortexkit:masterfrom
iceteaSA:fix/964-probe-cwd

Conversation

@iceteaSA

@iceteaSA iceteaSA commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

The dashboard started opencode models without a working directory, so OpenCode inherited the dashboard's own. For the AppImage that is a temporary mount, and OpenCode opened a project location there on every start.

All OpenCode probes now run in the Magic Context data folder: the verbose and plain model listings, the Windows where fallback, the login-shell fallback, and the version check that also runs at start. The folder uses the same resolution as the rest of the dashboard (MAGIC_CONTEXT_STORAGE_DIR, then XDG_DATA_HOME, then the default XDG data folder) and is created owner-only if it is missing. If it cannot be created, the probe runs from the home folder and logs a warning; it never falls back to the dashboard's own directory.

Tests: unit tests check that the probe command and the login-shell command carry this working directory, and that the folder is created and falls back as described. A stub CLI also records its real working directory for each probe path through the real probe functions. Removing current_dir from the probe builder fails two of them. Pi and OMP probes are unchanged. cargo fmt --check, cargo clippy --lib -- -D warnings and cargo test --lib (440 passed) pass.

Approved issue: #964
Refs #964


Summary by cubic

Fixes the dashboard's OpenCode model probes running in the dashboard's own working directory, which for the AppImage is a temporary mount that OpenCode opened as a project location on every start.

  • All OpenCode probes (opencode models verbose and plain, the Windows where fallback, the login-shell fallback, and the --version install check) now run in the Magic Context data folder.
  • The folder uses the same resolution as the rest of the dashboard, is created owner-only, and must be absolute: a blank XDG_DATA_HOME counts as unset, and a relative data folder falls back to the home folder with a warning—never the dashboard's directory.
  • Pi and OMP probes are unchanged.

Written for commit 93a73fa. Summary will update on new commits.

View guided diff

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge; both previous findings are fixed.

Summary

OpenCode model and version probes now run from the Magic Context data folder instead of the dashboard's launch folder.

  • OpenCode checks now run from the Magic Context data folder.
  • Blank XDG data-home settings now use the default folder.

Reviews (3) · Last reviewed commit: "test(dashboard): check the blank XDG_DAT..." · Reviewed by Greptile

… folder

The OpenCode probes started without a working directory, so the CLI
inherited the dashboard's own. For the AppImage that is a temporary
mount, and OpenCode opens a project location there on each start.

Every OpenCode probe now runs in the Magic Context data folder: the
verbose and plain `opencode models` attempts, the Windows `where`
fallback probe, the login-shell fallback, and the `--version`
install check. The folder follows the same resolution as the log
reader (MAGIC_CONTEXT_STORAGE_DIR, then XDG_DATA_HOME, then
the default XDG data folder) and is created owner-only when missing. If it cannot
be created, the probe runs from the home folder and logs a warning.
Pi and OMP probes are unchanged.

Refs cortexkit#964
@github-actions

Copy link
Copy Markdown

Waiting for design-approved on #964.

This PR needs a linked issue with the design-approved label before it can be reviewed or merged. Link the approved issue with Approved issue: #<issue> (or Refs #<issue>) in the description. A maintainer will apply the design-approved label on the issue, or trivial on the pull request when there is genuinely no design to agree. The issue stays open until the change ships; maintainers take care of it then.

@magic-alfonso

magic-alfonso Bot commented Nov 23, 2026

Copy link
Copy Markdown

Thanks, this is the shape we asked for: every OpenCode probe runs from the data folder, with a test that fails without current_dir.

Greptile's finding is real, and it's the same bug through a side door. With XDG_DATA_HOME set but empty (or relative), resolve_storage_dir() returns the relative path cortexkit/magic-context. opencode_probe_dir_from then creates it under the process's own working directory, which for the AppImage is the temporary mount, and runs the probe there. Please accept the storage folder only when it's absolute, and otherwise take the home-folder branch with its warning, plus a test for an empty and a relative XDG_DATA_HOME. Keep the fix inside the probe helper; the shared resolver also drives database and log discovery and is out of scope here.

One small thing: the comment that is the location #964 removes reads better as the reason itself, for example "the dashboard's own working directory, which for an AppImage is a temporary mount".

The merge also waits on a maintainer label on #964; that's on our side, and we'll post here when it's done.

A blank XDG_DATA_HOME now counts as unset, as in the plugin's storage resolver, so the probe uses the default data folder. A relative data folder is refused and the probe runs from the home folder: a relative path would resolve under the launch directory again. Tests cover both cases; with the fix removed, both fail and the probe creates the folder under the launch directory.
…home

The test now checks the storage resolver and creates no folder. On Windows, dirs ignores HOME, so the probe would have created the folder in the real profile and the test would have failed.

This branch has not been deployed

No deployments
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