Merge PR #4462: fix(lsp): notify servers about harness file writes (@roboomp)

This commit is contained in:
can1357
2026-07-05 13:10:26 +02:00
9 changed files with 214 additions and 16 deletions
@@ -7,6 +7,8 @@
* URLs) are always written directly to disk — those are OMP-owned and should
* never be pushed into the editor.
*/
import { FileChangeType, notifyWorkspaceWatchedFiles } from "../lsp/client";
import type { ToolSession } from ".";
import { invalidateFsScanAfterWrite } from "./fs-cache-invalidation";
import { isInternalUrlPath } from "./path-utils";
@@ -53,18 +55,22 @@ export async function routeWriteThroughBridge(
requestedPath: string,
absolutePath: string,
content: string,
signal?: AbortSignal,
): Promise<boolean> {
if (!shouldRouteWriteThroughBridge(session, requestedPath, absolutePath)) return false;
const bridge = session.getClientBridge?.();
if (!bridge?.capabilities.writeTextFile || !bridge.writeTextFile) return false;
const changeType = (await Bun.file(absolutePath).exists()) ? FileChangeType.Changed : FileChangeType.Created;
try {
await bridge.writeTextFile({ path: absolutePath, content });
} catch (error) {
throw new ToolError(error instanceof Error ? error.message : String(error));
}
if (session.enableLsp ?? true) {
await notifyWorkspaceWatchedFiles(session.cwd, [{ filePath: absolutePath, type: changeType }], signal);
}
invalidateFsScanAfterWrite(absolutePath);
session.bumpFileMutationVersion?.(absolutePath);
return true;
+1 -1
View File
@@ -914,7 +914,7 @@ export class WriteTool implements AgentTool<typeof writeSchema, WriteToolDetails
// Try ACP bridge first for editor-visible filesystem paths. Internal
// artifacts such as local:// plans are owned by OMP, not the editor.
if (await routeWriteThroughBridge(this.session, path, absolutePath, cleanContent)) {
if (await routeWriteThroughBridge(this.session, path, absolutePath, cleanContent, signal)) {
const madeExecutable = await maybeMarkExecutableForShebang(absolutePath, cleanContent);
const header = maybeWriteSnapshotHeader(this.session, absolutePath, cleanContent);
const writeLine = `Successfully wrote ${cleanContent.length} bytes to ${displayPath}`;