Repository navigation
fix(macos): Mac node misses Claude Code sessions when CLAUDE_CONFIG_DIR is set - #163787
Conversation
…IR is set The native macOS node catalog (anthropic.claude.sessions.list.v1/read.v1) always read ~/.claude/projects, while the TypeScript scan honors CLAUDE_CONFIG_DIR. Resolve the projects root once per entry point with the same precedence (trimmed CLAUDE_CONFIG_DIR, else HOME/.claude) and share it across list, read, read-lease store/lookup, and advertisement, so the existing root-containment checks apply to the resolved root. Claude Desktop metadata stays HOME/Library-scoped, matching the TS node commands. Tests now inject an explicit environment instead of inheriting the runner's.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed October 2, 2026, 5:14 PM ET / 21:14 UTC. ClawSweeper reviewWhat this changesThe macOS node honors CLAUDE_CONFIG_DIR when advertising, listing, and reading Claude Code sessions, with regression coverage and updated documentation. Merge readiness✅ Ready for maintainer review This repair remains useful: current main still uses the default Claude directory. Codex found no introduced blocking defect. Likely related people: steipete and vincentkoc, suggested from prior work on this catalog; routing confidence is low. Priority: P2 Review scores
Verification
How this fits togetherThe macOS session catalog reads local Claude transcripts and exposes bounded listings and transcript pages to a paired Gateway. Those results populate OpenClaw's session browser. flowchart LR
A[App environment and home directory] --> B[Resolve Claude projects directory]
B --> C[Discover eligible sessions]
D[Claude Desktop metadata] --> C
C --> E[Validate transcript paths and read leases]
E --> F[Paired Gateway]
F --> G[Session browser]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceDocs +5, Other +94. Total +99 across 4 files. View PR surface stats
Review metricsNone. Technical reviewBest possible solution: Keep native discovery and transcript reads aligned with the existing Claude configuration-directory contract while preserving home-scoped Desktop metadata. Do we have a high-confidence way to reproduce the issue? Yes, from source: launch the macOS node with CLAUDE_CONFIG_DIR pointing to a populated custom projects directory while the default directory is absent; current main checks only the default directory. This review did not execute that scenario. Is this the best way to solve the issue? Yes. Resolving the root once per entrypoint and carrying it through discovery, containment checks, and leases is a focused repair consistent with the existing TypeScript catalog. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 887c62b8edac. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
…IR is set (openclaw#163787) The native macOS node catalog (anthropic.claude.sessions.list.v1/read.v1) always read ~/.claude/projects, while the TypeScript scan honors CLAUDE_CONFIG_DIR. Resolve the projects root once per entry point with the same precedence (trimmed CLAUDE_CONFIG_DIR, else HOME/.claude) and share it across list, read, read-lease store/lookup, and advertisement, so the existing root-containment checks apply to the resolved root. Claude Desktop metadata stays HOME/Library-scoped, matching the TS node commands. Tests now inject an explicit environment instead of inheriting the runner's.
What Problem This Solves
Fixes: a paired macOS app node shows no Claude Code sessions (and does not advertise the Claude session commands) when the user runs Claude Code with
CLAUDE_CONFIG_DIRpointing somewhere other than~/.claude.User Impact
User impact: the Mac node now lists and opens Claude Code sessions from
$CLAUDE_CONFIG_DIR/projects/, the same root the Gateway and headless TypeScript node already use. Behavior is unchanged when the variable is unset or blank. The macOS app reads its own process environment, so a Finder-launched app only seesCLAUDE_CONFIG_DIRwhen it is part of the app's launch environment.Why This Change Was Made
The TypeScript scan (
extensions/anthropic/session-catalog-scan.ts) resolves the projects root as trimmedCLAUDE_CONFIG_DIR, elseHOME/.claude, following Claude Code's "respect CLAUDE_CONFIG_DIR everywhere" convention. The native catalog hardcoded~/.claude/projectsand recomputed it separately for list, read, read-lease store/lookup, and advertisement. It now resolves the root once per entry point with the same precedence and passes it down, so the existing root-containment and symlink checks apply to the resolved root and read pagination leases stay bound to it. Claude Desktop metadata staysHOME/Library-scoped, matching the TypeScript node commands. Tests now pass an explicit environment instead of inheriting the runner's.Evidence
swift test --package-path apps/macos --build-system native --filter MacNodeClaudeSessionCatalogTests: 11/11 passed on this head's base. The new cases cover env set (whitespace-padded): custom root listed and readable, decoy in~/.claude/projectsexcluded, an index entry escaping into~/.clauderejected, Desktop title still applied, page two served from the lease without re-enumeration, advertisement following the custom root. They also cover unset, empty, and whitespace-only env falling back to~/.claude/projects.CLAUDE_CONFIG_DIRtest fails with 5 issues while the fallback cases pass.swift build --package-path apps/macos --build-system native --product OpenClaw: passed.swiftlint --strict --config config/swiftlint.yml,swiftformat --lint, oxfmt on the docs, andgit diff --check: clean.