Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/desktop/src-tauri/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,11 @@ pub fn spawn_command(
cmd
};

let home = std::env::var_os("HOME").or_else(|| std::env::var_os("USERPROFILE"));
if let Some(home) = home {
cmd.current_dir(home);
}
Comment on lines +332 to +335
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using HOME/USERPROFILE env vars can be unset (or even empty) in some launch contexts (notably GUI apps), which would silently leave the process working directory unchanged and undermine the goal of avoiding / as the CWD. This crate already depends on dirs and uses dirs::home_dir() elsewhere; consider switching to dirs::home_dir() (and/or filtering out empty values) and only calling current_dir when the resolved path exists/is a directory.

Copilot uses AI. Check for mistakes.

cmd.stdout(Stdio::piped());
cmd.stderr(Stdio::piped());
cmd.stdin(Stdio::null());
Expand Down
5 changes: 5 additions & 0 deletions packages/opencode/src/file/watcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ export namespace FileWatcher {
const subs: ParcelWatcher.AsyncSubscription[] = []
const cfgIgnores = cfg.watcher?.ignore ?? []

if (Instance.directory === path.parse(Instance.directory).root) {
log.warn("skipping watcher for filesystem root", { directory: Instance.directory })
return { subs }
}

if (Flag.OPENCODE_EXPERIMENTAL_FILEWATCHER) {
const pending = w.subscribe(Instance.directory, subscribe, {
ignore: [...FileIgnore.PATTERNS, ...cfgIgnores],
Expand Down
Loading