Skip to content

Commit 824c12c

Browse files
authored
refactor(file): destroy FileWatcher facade (#22091)
1 parent 17b2900 commit 824c12c

4 files changed

Lines changed: 6 additions & 11 deletions

File tree

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { Layer, ManagedRuntime } from "effect"
22
import { memoMap } from "./run-service"
33

4+
import { FileWatcher } from "@/file/watcher"
45
import { Format } from "@/format"
56
import { ShareNext } from "@/share/share-next"
67

7-
export const BootstrapLayer = Layer.mergeAll(Format.defaultLayer, ShareNext.defaultLayer)
8+
export const BootstrapLayer = Layer.mergeAll(Format.defaultLayer, ShareNext.defaultLayer, FileWatcher.defaultLayer)
89

910
export const BootstrapRuntime = ManagedRuntime.make(BootstrapLayer, { memoMap })

packages/opencode/src/file/watcher.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import z from "zod"
88
import { Bus } from "@/bus"
99
import { BusEvent } from "@/bus/bus-event"
1010
import { InstanceState } from "@/effect/instance-state"
11-
import { makeRuntime } from "@/effect/run-service"
1211
import { Flag } from "@/flag/flag"
1312
import { Git } from "@/git"
1413
import { Instance } from "@/project/instance"
@@ -161,10 +160,4 @@ export namespace FileWatcher {
161160
)
162161

163162
export const defaultLayer = layer.pipe(Layer.provide(Config.defaultLayer), Layer.provide(Git.defaultLayer))
164-
165-
const { runPromise } = makeRuntime(Service, defaultLayer)
166-
167-
export function init() {
168-
return runPromise((svc) => svc.init())
169-
}
170163
}

packages/opencode/src/project/bootstrap.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { Plugin } from "../plugin"
22
import { Format } from "../format"
33
import { LSP } from "../lsp"
44
import { File } from "../file"
5-
import { FileWatcher } from "../file/watcher"
65
import { Snapshot } from "../snapshot"
76
import { Project } from "./project"
87
import { Vcs } from "./vcs"
@@ -11,6 +10,7 @@ import { Command } from "../command"
1110
import { Instance } from "./instance"
1211
import { Log } from "@/util/log"
1312
import { BootstrapRuntime } from "@/effect/bootstrap-runtime"
13+
import { FileWatcher } from "@/file/watcher"
1414
import { ShareNext } from "@/share/share-next"
1515

1616
export async function InstanceBootstrap() {
@@ -20,7 +20,7 @@ export async function InstanceBootstrap() {
2020
void BootstrapRuntime.runPromise(Format.Service.use((svc) => svc.init()))
2121
await LSP.init()
2222
File.init()
23-
FileWatcher.init()
23+
void BootstrapRuntime.runPromise(FileWatcher.Service.use((svc) => svc.init()))
2424
Vcs.init()
2525
Snapshot.init()
2626

packages/opencode/test/project/vcs.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { afterEach, describe, expect, test } from "bun:test"
33
import fs from "fs/promises"
44
import path from "path"
55
import { tmpdir } from "../fixture/fixture"
6+
import { AppRuntime } from "../../src/effect/app-runtime"
67
import { FileWatcher } from "../../src/file/watcher"
78
import { Instance } from "../../src/project/instance"
89
import { GlobalBus } from "../../src/bus/global"
@@ -19,7 +20,7 @@ async function withVcs(directory: string, body: () => Promise<void>) {
1920
return Instance.provide({
2021
directory,
2122
fn: async () => {
22-
FileWatcher.init()
23+
void AppRuntime.runPromise(FileWatcher.Service.use((svc) => svc.init()))
2324
Vcs.init()
2425
await Bun.sleep(500)
2526
await body()

0 commit comments

Comments
 (0)