Skip to content

fix(desktop): treat nonempty relative XDG bases as unset, fall back to home - #10496

Open
LexLuthorPrimero wants to merge 1 commit into
morluto:mainfrom
LexLuthorPrimero:fix/xdg-relative-state-base
Open

LexLuthorPrimero wants to merge 1 commit into
morluto:mainfrom
LexLuthorPrimero:fix/xdg-relative-state-base

Conversation

@LexLuthorPrimero

@LexLuthorPrimero LexLuthorPrimero commented Nov 14, 2026 •

Copy link
Copy Markdown

Summary

Fixes #9702.

A nonempty relative XDG_CONFIG_HOME/XDG_DATA_HOME/XDG_STATE_HOME/XDG_CACHE_HOME was being treated as an absolute state-directory base, so the inventory resolved XDG_*=relative/ against REA's working directory — producing spurious state bases and concrete mistakes (e.g. reporting notes.desktop missing). The XDG Base Directory spec requires an absolute path; a relative value is out-of-contract and must not escape the caller's filesystem scope.

Change and scope

  • New module src/desktop/absoluteStateBase.ts: absoluteStateBase(value, fallback) — returns the fallback when the value is unset/empty/relative; returns the absolute value otherwise.
  • src/desktop/ApplicationStateDirectories.ts: the four bases in stateDirectories honor it.
  • src/desktop/LinuxApplicationInventory.ts: desktopEntryDirectories also honors it (same root cause, second call site).
  • src/desktop/ApplicationStateDirectories.test.ts: regression test — the relative XDG_CONFIG_HOME="relative-config" case falls back to home, and the relative-config/notes candidate no longer leaks.
  • Schema/output unchanged; behavior unchanged in the absolute-path case.

Evidence

  • npx vitest run src/desktop — 267 passed, 5 skipped.
  • npx vitest run src/desktop/ApplicationStateDirectories.test.ts — 2 passed including new regression.
  • npm run typecheck, npm run format:check, npm run lint — passed.

Known gaps / honest limitations

  • No macOS or Windows runtime check (Linux only).
  • No desktop capture end-to-end exercise with a real desktop session; the implementation is in the source-production Linux path and is exercised through the inventory boundary.
  • The fix is conservative: it does not attempt to re-root a relative XDG under HOME; it ignores the out-of-contract value and uses the default.
  • $XDG_DATA_HOME="foo" becomes <home>/.local/share, exactly the same behavior as an unset $XDG_DATA_HOME.

Compatibility

Breaking changes: none operationally; arguably the previous behavior (silently using CWD-rooted candidates) was the defect this fixes.

Author readiness

Human owner: @LexLuthorPrimero

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-14T08:01:00.833114Z
We couldn’t complete this review. Comment @codex review to try again.
2c951c6 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@greptile-apps

greptile-apps Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] The change reaches Linux desktop discovery and the state paths used by desktop capture.

The PR appears safe to merge, with a non-blocking gap in regression coverage for desktop-entry lookup.

Findings

  1. P2 Desktop-entry fallback remains untested ▶
Fix with agent prompt
### Issue 1
src/desktop/ApplicationStateDirectories.test.ts:62-66
The new regression only exercises `stateDirectories` with a relative `XDG_CONFIG_HOME`. It never reaches the changed desktop-entry search, so removing the fix in `desktopEntryDirectories` would still leave it passing. Add an `inspectLinuxApplication` test with relative `XDG_DATA_HOME` and a desktop entry found only under `<home>/.local/share/applications`.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

Relative XDG bases now use the default folders under the user's home.

  • Linux inventory uses home defaults for relative XDG paths.

Reviews (1) · Last reviewed commit: "fix(desktop): treat nonempty relative XD..." · Reviewed by Greptile

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.

[Bug] Relative XDG bases make desktop capture inventory use working-directory paths

1 participant