fix(server): set opencode serve cwd to home dir to stop full-filesystem scan (#1626)

When the Paseo daemon is launched as a macOS GUI app (via launchd), its
working directory is `/`. The `opencode serve` process inherited that cwd,
causing opencode's fff_search to scan and watch the entire filesystem,
leading to 300%+ CPU and 1GB+ RAM usage.

Fix: pass `cwd: os.homedir()` when spawning `opencode serve` so it never
inherits `/`. The per-session working directory is unaffected — it is
passed separately via the OpenCode SDK's `session.create({ directory })`.

Fixes #1617
This commit is contained in:
Mohamed Boudra
2026-06-20 15:21:40 +08:00
committed by GitHub
parent 4534754617
commit ba8fe261ee

View File

@@ -1,5 +1,6 @@
import type { ChildProcess } from "node:child_process";
import net from "node:net";
import os from "node:os";
import type { Logger } from "pino";
import { findExecutable } from "../../../../executable-resolution/executable-resolution.js";
@@ -201,6 +202,7 @@ export class OpenCodeServerManager implements OpenCodeServerManagerLike {
launchPrefix.command,
[...launchPrefix.args, "serve", "--port", String(port)],
{
cwd: os.homedir(),
detached: process.platform !== "win32",
stdio: ["ignore", "pipe", "pipe"],
...createProviderEnvSpec({