summaryrefslogtreecommitdiffhomepage
path: root/packages
diff options
context:
space:
mode:
authorAiden Cline <[email protected]>2025-12-16 14:31:09 -0600
committerAiden Cline <[email protected]>2025-12-16 14:31:09 -0600
commit7e3ad770ac340da1589da1d6a9f182e56e3da619 (patch)
tree3aef02f2feefbbefa634fedb920963a4763cc0b0 /packages
parent87524de26563f67f0627b767d35ab3ae12762ea6 (diff)
downloadopencode-7e3ad770ac340da1589da1d6a9f182e56e3da619.tar.gz
opencode-7e3ad770ac340da1589da1d6a9f182e56e3da619.zip
fix: git branch filewatcher, add flag to completely disable watcher
Diffstat (limited to 'packages')
-rw-r--r--packages/opencode/src/file/watcher.ts28
-rw-r--r--packages/opencode/src/flag/flag.ts2
-rw-r--r--packages/web/src/content/docs/cli.mdx1
3 files changed, 23 insertions, 8 deletions
diff --git a/packages/opencode/src/file/watcher.ts b/packages/opencode/src/file/watcher.ts
index 80e524349..50a310d96 100644
--- a/packages/opencode/src/file/watcher.ts
+++ b/packages/opencode/src/file/watcher.ts
@@ -5,11 +5,13 @@ import { Instance } from "../project/instance"
import { Log } from "../util/log"
import { FileIgnore } from "./ignore"
import { Config } from "../config/config"
+import path from "path"
// @ts-ignore
import { createWrapper } from "@parcel/watcher/wrapper"
import { lazy } from "@/util/lazy"
import type ParcelWatcher from "@parcel/watcher"
import { $ } from "bun"
+import { Flag } from "@/flag/flag"
declare const OPENCODE_LIBC: string | undefined
@@ -57,17 +59,24 @@ export namespace FileWatcher {
}
}
- const subs = []
+ const subs: ParcelWatcher.AsyncSubscription[] = []
const cfgIgnores = cfg.watcher?.ignore ?? []
- subs.push(
- await watcher().subscribe(Instance.directory, subscribe, {
- ignore: [...FileIgnore.PATTERNS, ...cfgIgnores],
- backend,
- }),
- )
+ if (Flag.OPENCODE_EXPERIMENTAL_FILEWATCHER) {
+ subs.push(
+ await watcher().subscribe(Instance.directory, subscribe, {
+ ignore: [...FileIgnore.PATTERNS, ...cfgIgnores],
+ backend,
+ }),
+ )
+ }
- const vcsDir = await $`git rev-parse --git-dir`.quiet().nothrow().cwd(Instance.worktree).text()
+ const vcsDir = await $`git rev-parse --git-dir`
+ .quiet()
+ .nothrow()
+ .cwd(Instance.worktree)
+ .text()
+ .then((x) => path.resolve(Instance.worktree, x.trim()))
if (vcsDir && !cfgIgnores.includes(".git") && !cfgIgnores.includes(vcsDir)) {
subs.push(
await watcher().subscribe(vcsDir, subscribe, {
@@ -86,6 +95,9 @@ export namespace FileWatcher {
)
export function init() {
+ if (Flag.OPENCODE_EXPERIMENTAL_DISABLE_FILEWATCHER) {
+ return
+ }
state()
}
}
diff --git a/packages/opencode/src/flag/flag.ts b/packages/opencode/src/flag/flag.ts
index d7a24708a..544188d4e 100644
--- a/packages/opencode/src/flag/flag.ts
+++ b/packages/opencode/src/flag/flag.ts
@@ -17,6 +17,8 @@ export namespace Flag {
// Experimental
export const OPENCODE_EXPERIMENTAL = truthy("OPENCODE_EXPERIMENTAL")
+ export const OPENCODE_EXPERIMENTAL_FILEWATCHER = truthy("OPENCODE_EXPERIMENTAL_FILEWATCHER")
+ export const OPENCODE_EXPERIMENTAL_DISABLE_FILEWATCHER = truthy("OPENCODE_EXPERIMENTAL_DISABLE_FILEWATCHER")
export const OPENCODE_EXPERIMENTAL_ICON_DISCOVERY =
OPENCODE_EXPERIMENTAL || truthy("OPENCODE_EXPERIMENTAL_ICON_DISCOVERY")
export const OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECT = truthy("OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECT")
diff --git a/packages/web/src/content/docs/cli.mdx b/packages/web/src/content/docs/cli.mdx
index 777d377a7..6fd7307b2 100644
--- a/packages/web/src/content/docs/cli.mdx
+++ b/packages/web/src/content/docs/cli.mdx
@@ -325,3 +325,4 @@ These environment variables enable experimental features that may change or be r
| `OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECT` | boolean | Disable copy on select in TUI |
| `OPENCODE_EXPERIMENTAL_BASH_MAX_OUTPUT_LENGTH` | number | Max output length for bash commands |
| `OPENCODE_EXPERIMENTAL_BASH_DEFAULT_TIMEOUT_MS` | number | Default timeout for bash commands in ms |
+| `OPENCODE_EXPERIMENTAL_FILEWATCHER` | boolean | Enable file watcher for entire dir |