From 665d46bdc1bce70dd0602d0f01c4a59624c0c815 Mon Sep 17 00:00:00 2001 From: Janghoon Lee <44862514+savagemanage@users.noreply.github.com> Date: Wed, 28 Oct 2026 06:36:30 +0000 Subject: [PATCH] daemon: run from an empty folder of our own, not the home folder A request without a directory falls back to the daemon's cwd. With the cwd at ~, the first such request (Redrob Desktop starts the daemon) indexed and watched the whole home folder with rg, and macOS asked for Desktop, Documents, Downloads and every other protected folder at app start. The registered daemon now chdirs to /daemon instead. --- packages/redrob/src/cli/cmd/serve.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/redrob/src/cli/cmd/serve.ts b/packages/redrob/src/cli/cmd/serve.ts index cccd2624a1..14bf4580b6 100644 --- a/packages/redrob/src/cli/cmd/serve.ts +++ b/packages/redrob/src/cli/cmd/serve.ts @@ -1,4 +1,6 @@ -import os from "node:os" +import fs from "node:fs" +import path from "node:path" +import { Global } from "@redrob-code/core/global" import { Effect } from "effect" import { effectCmd } from "../effect-cmd" import { withNetworkOptions, resolveNetworkOptions } from "../network" @@ -45,9 +47,14 @@ export const ServeCommand = effectCmd({ // The shared daemon outlives whoever started it. A caller that spawned it from an app's // install folder (older SDKs did) would otherwise have that folder held open for the daemon's // whole life, blocking the app's Windows update. Requests carry their own directory. + // A request without one falls back to the cwd, so the cwd is an empty folder of our own, not + // the home folder: on macOS, indexing and watching ~ asks for Desktop, Documents, Downloads, + // Photos and every other protected folder the moment an app starts the daemon. if (register) { try { - process.chdir(os.homedir()) + const idle = path.join(Global.Path.data, "daemon") + fs.mkdirSync(idle, { recursive: true }) + process.chdir(idle) } catch { /* keep the inherited cwd */ }