From 938f447505868a5f607ff1bbb0730bc2369fffce Mon Sep 17 00:00:00 2001 From: Steve Biedermann Date: Tue, 3 Nov 2026 19:29:54 +0100 Subject: [PATCH] fix: refresh actor snapshots without unavailable revert command Send a post-save filesystem change notification with a newer mtime so clean inspection editors reload the canonical server snapshot. Assert the real VS Code save restores protected fields without reporting refresh errors. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- CHANGELOG.md | 2 ++ vscode/integration/host.ts | 17 +++++++++++++++-- vscode/src/extension.ts | 2 +- vscode/src/snapshotProvider.ts | 9 ++++++--- 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e0a6cae..a67d4ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,8 @@ All notable changes to this project will be documented in this file. ### Fixed +- Refresh saved actor inspection JSON through filesystem notifications instead + of an unavailable VS Code revert command. - Always prompt for JSON state when Spawn with State is invoked from a source context menu, including multi-selection menu arguments. - Close extension connections with a WebSocket handshake on disconnect, diff --git a/vscode/integration/host.ts b/vscode/integration/host.ts index ae23264..925e476 100644 --- a/vscode/integration/host.ts +++ b/vscode/integration/host.ts @@ -188,8 +188,21 @@ export async function run(): Promise { const unsaved = document.getText(); await vscode.commands.executeCommand("runa.refresh"); assert.equal(document.getText(), unsaved, "refresh must preserve unsaved inspection edits"); - assert.equal(await document.save(), true); - await canonical; + const window = vscode.window as { showErrorMessage: (...args: unknown[]) => unknown }; + const showError = window.showErrorMessage; + const saveErrors: unknown[][] = []; + window.showErrorMessage = async (...args: unknown[]) => { + saveErrors.push(args); + return undefined; + }; + try { + assert.equal(await document.save(), true); + await canonical; + assert.deepEqual(saveErrors, [], "successful inspection save must not report refresh errors"); + assert.equal(document.isDirty, false); + } finally { + window.showErrorMessage = showError; + } const recovered = documentChanged(document, (text) => { const actor = JSON.parse(text).actor; return ( diff --git a/vscode/src/extension.ts b/vscode/src/extension.ts index e987ec0..cc47fcf 100644 --- a/vscode/src/extension.ts +++ b/vscode/src/extension.ts @@ -662,7 +662,7 @@ export function activate(context: vscode.ExtensionContext): { sourceTree: ImageS vscode.workspace.registerFileSystemProvider(SOURCE_SCHEME, sources, { isCaseSensitive: true }), vscode.workspace.registerFileSystemProvider("runa", documents, { isCaseSensitive: true }), vscode.workspace.onDidSaveTextDocument((document) => { - void documents.didSave(document).catch(report); + documents.didSave(document); }), vscode.workspace.registerTextDocumentContentProvider(REVISION_SCHEME, revisions), vscode.workspace.onDidCloseTextDocument((document) => { diff --git a/vscode/src/snapshotProvider.ts b/vscode/src/snapshotProvider.ts index 1ba8fb1..896c3bc 100644 --- a/vscode/src/snapshotProvider.ts +++ b/vscode/src/snapshotProvider.ts @@ -128,9 +128,12 @@ export class SnapshotDocuments implements vscode.FileSystemProvider { this.changed(uri); } - async didSave(document: vscode.TextDocument): Promise { - if (document.uri.scheme === "runa" && !document.isDirty) - await vscode.commands.executeCommand("workbench.action.files.revertResource", document.uri); + didSave(document: vscode.TextDocument): void { + if (document.uri.scheme !== "runa" || document.isDirty) return; + const snapshot = this.snapshot(document.uri); + // Notify after the save completes so VS Code reloads the now-clean editor. + snapshot.mtime = Math.max(Date.now(), snapshot.mtime + 1); + this.changed(document.uri); } watch(): vscode.Disposable {