diff options
| author | Dax Raad <[email protected]> | 2025-07-03 20:16:16 -0400 |
|---|---|---|
| committer | Dax Raad <[email protected]> | 2025-07-03 20:16:25 -0400 |
| commit | cdb25656d545034ec08aa970c8b1366452f30fd6 (patch) | |
| tree | f36c98875ea730042a350566d031ad97acfa4fa2 | |
| parent | 25c876caa2b5f308cf400a8b0747276cba04d177 (diff) | |
| download | opencode-cdb25656d545034ec08aa970c8b1366452f30fd6.tar.gz opencode-cdb25656d545034ec08aa970c8b1366452f30fd6.zip | |
improve snapshot speed
| -rw-r--r-- | packages/opencode/src/lsp/client.ts | 16 | ||||
| -rw-r--r-- | packages/opencode/src/lsp/index.ts | 2 | ||||
| -rw-r--r-- | packages/opencode/src/snapshot/index.ts | 27 |
3 files changed, 33 insertions, 12 deletions
diff --git a/packages/opencode/src/lsp/client.ts b/packages/opencode/src/lsp/client.ts index f06a8c68c..5aff437dd 100644 --- a/packages/opencode/src/lsp/client.ts +++ b/packages/opencode/src/lsp/client.ts @@ -92,11 +92,20 @@ export namespace LSPClient { }, }), 5_000, - ).catch(() => { - throw new InitializeError({ serverID }) + ).catch((err) => { + log.error("initialize error", { error: err }) + throw new InitializeError( + { serverID }, + { + cause: err, + }, + ) }) + await connection.sendNotification("initialized", {}) - log.info("initialized") + log.info("initialized", { + serverID, + }) const files: { [path: string]: number @@ -174,7 +183,6 @@ export namespace LSPClient { log.info("shutting down", { serverID }) connection.end() connection.dispose() - server.process.kill("SIGTERM") log.info("shutdown", { serverID }) }, } diff --git a/packages/opencode/src/lsp/index.ts b/packages/opencode/src/lsp/index.ts index 2c73feb81..88e549bbe 100644 --- a/packages/opencode/src/lsp/index.ts +++ b/packages/opencode/src/lsp/index.ts @@ -47,7 +47,7 @@ export namespace LSP { const handle = await server.spawn(App.info()) if (!handle) break const client = await LSPClient.create(server.id, handle).catch( - () => {}, + (err) => log.error("", { error: err }), ) if (!client) break clients.set(server.id, client) diff --git a/packages/opencode/src/snapshot/index.ts b/packages/opencode/src/snapshot/index.ts index bf8ea05f6..fcf77c459 100644 --- a/packages/opencode/src/snapshot/index.ts +++ b/packages/opencode/src/snapshot/index.ts @@ -16,12 +16,14 @@ export namespace Snapshot { const log = Log.create({ service: "snapshot" }) export async function create(sessionID: string) { + log.info("creating snapshot") const app = App.info() const git = gitdir(sessionID) const files = await Ripgrep.files({ cwd: app.path.cwd, limit: app.git ? undefined : 1000, }) + log.info("found files", { count: files.length }) // not a git repo and too big to snapshot if (!app.git && files.length === 1000) return await init({ @@ -29,19 +31,17 @@ export namespace Snapshot { gitdir: git, fs, }) + log.info("initialized") const status = await statusMatrix({ fs, gitdir: git, dir: app.path.cwd, }) - await add({ - fs, - gitdir: git, - parallel: true, - dir: app.path.cwd, - filepath: files, + log.info("matrix", { + count: status.length, }) - for (const [file, _head, workdir, stage] of status) { + const added = [] + for (const [file, head, workdir, stage] of status) { if (workdir === 0 && stage === 1) { log.info("remove", { file }) await remove({ @@ -50,8 +50,21 @@ export namespace Snapshot { dir: app.path.cwd, filepath: file, }) + continue + } + if (workdir !== head) { + added.push(file) } } + log.info("removed files") + await add({ + fs, + gitdir: git, + parallel: true, + dir: app.path.cwd, + filepath: added, + }) + log.info("added files") const result = await commit({ fs, gitdir: git, |
