Keep the remote daemon's Claude restore preload out of TMPDIR
Merged
TE
2mo ago+95+95+01234567890123456789-32-32-01234567890123456789
#14814 moved Claude's NODE_OPTIONS restore preload from $TMPDIR to ~/.cmuxterm/cmux-claude-node-options/ on the Mac side. cmuxd-remote still wrote it under os.TempDir(), so remote Claude sessions keep the #12022 failure: once the OS purges the temp directory, every new Node child exits with MODULE_NOT_FOUND.
daemon/remote/cmd/cmuxd-remote/agent_launch.go:ensureClaudeNodeOptionsRestoreModulewrites to~/.cmuxterm/cmux-claude-node-options/restore-node-options.cjs, same rules as the wrapper: absolute home required, symlinked directory or module refused, directory0700, atomic write throughwriteShimIfChanged.mergeNodeOptionsquotes--requirewhen the path has whitespace. The old randomMkdirTempdirectory guarded against same-UID tampering in a shared/tmp; a0700directory in the user's home gives the same protection without being purged.CLI/cmux.swift:createClaudeNodeOptionsRestoreModulefalls back toNSHomeDirectory()whenHOMEis empty or relative and refuses a symlinked directory or module, matching the wrapper. Callers already skip injection when it throws.
Validation
go test ./cmd/cmuxd-remote -run 'NodeOptions'andgo vet ./cmd/cmuxd-remotepass locally.agent_launch_temp_test.gonow checks the home path (with a space in it),0700, stable reuse with a separateTMPDIR, the quoted--require, and symlink refusal.- The Swift change is not compiled locally (no local app builds on this machine); CI compiles
cmux-cli.
🤖 Generated with Claude Code
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.
Summary by cubic
Moves the remote daemon's Claude NODE_OPTIONS restore preload from $TMPDIR to ~/.cmuxterm/cmux-claude-node-options/, fixing the MODULE_NOT_FOUND failures that occurred once the OS purged the temp directory during long-lived remote Claude sessions.
- The daemon now matches the macOS wrapper's rules: absolute
HOMErequired, symlinked directory or module refused, directory mode0700, atomic write viawriteShimIfChanged. - The restore module no longer deletes itself on load, which would break concurrent launches that share the file.
mergeNodeOptionsquotes--requirewhen the path contains whitespace.- The CLI writer now falls back to
NSHomeDirectory()whenHOMEis empty or relative and refuses symlinked paths, matching the wrapper.
Summary by CodeRabbit
- Bug Fixes
- Claude restore support now falls back to the system home directory when the configured home path is not absolute, and reports an error if no valid absolute path is available.
- Restore files use a consistent, private user directory with restricted access across launches. Symlinked restore locations are rejected.
- Launch configuration correctly handles restore paths containing spaces, tabs, or newlines.