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>
This commit is contained in:
Steve Biedermann 2026-11-03 19:29:54 +01:00
parent f5decbdea4
commit 938f447505
4 changed files with 24 additions and 6 deletions

View File

@ -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,

View File

@ -188,8 +188,21 @@ export async function run(): Promise<void> {
const unsaved = document.getText();
await vscode.commands.executeCommand("runa.refresh");
assert.equal(document.getText(), unsaved, "refresh must preserve unsaved inspection edits");
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 (

View File

@ -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) => {

View File

@ -128,9 +128,12 @@ export class SnapshotDocuments implements vscode.FileSystemProvider {
this.changed(uri);
}
async didSave(document: vscode.TextDocument): Promise<void> {
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 {