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:
parent
f5decbdea4
commit
938f447505
|
|
@ -33,6 +33,8 @@ All notable changes to this project will be documented in this file.
|
||||||
|
|
||||||
### Fixed
|
### 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
|
- Always prompt for JSON state when Spawn with State is invoked from a source
|
||||||
context menu, including multi-selection menu arguments.
|
context menu, including multi-selection menu arguments.
|
||||||
- Close extension connections with a WebSocket handshake on disconnect,
|
- Close extension connections with a WebSocket handshake on disconnect,
|
||||||
|
|
|
||||||
|
|
@ -188,8 +188,21 @@ export async function run(): Promise<void> {
|
||||||
const unsaved = document.getText();
|
const unsaved = document.getText();
|
||||||
await vscode.commands.executeCommand("runa.refresh");
|
await vscode.commands.executeCommand("runa.refresh");
|
||||||
assert.equal(document.getText(), unsaved, "refresh must preserve unsaved inspection edits");
|
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);
|
assert.equal(await document.save(), true);
|
||||||
await canonical;
|
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 recovered = documentChanged(document, (text) => {
|
||||||
const actor = JSON.parse(text).actor;
|
const actor = JSON.parse(text).actor;
|
||||||
return (
|
return (
|
||||||
|
|
|
||||||
|
|
@ -662,7 +662,7 @@ export function activate(context: vscode.ExtensionContext): { sourceTree: ImageS
|
||||||
vscode.workspace.registerFileSystemProvider(SOURCE_SCHEME, sources, { isCaseSensitive: true }),
|
vscode.workspace.registerFileSystemProvider(SOURCE_SCHEME, sources, { isCaseSensitive: true }),
|
||||||
vscode.workspace.registerFileSystemProvider("runa", documents, { isCaseSensitive: true }),
|
vscode.workspace.registerFileSystemProvider("runa", documents, { isCaseSensitive: true }),
|
||||||
vscode.workspace.onDidSaveTextDocument((document) => {
|
vscode.workspace.onDidSaveTextDocument((document) => {
|
||||||
void documents.didSave(document).catch(report);
|
documents.didSave(document);
|
||||||
}),
|
}),
|
||||||
vscode.workspace.registerTextDocumentContentProvider(REVISION_SCHEME, revisions),
|
vscode.workspace.registerTextDocumentContentProvider(REVISION_SCHEME, revisions),
|
||||||
vscode.workspace.onDidCloseTextDocument((document) => {
|
vscode.workspace.onDidCloseTextDocument((document) => {
|
||||||
|
|
|
||||||
|
|
@ -128,9 +128,12 @@ export class SnapshotDocuments implements vscode.FileSystemProvider {
|
||||||
this.changed(uri);
|
this.changed(uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
async didSave(document: vscode.TextDocument): Promise<void> {
|
didSave(document: vscode.TextDocument): void {
|
||||||
if (document.uri.scheme === "runa" && !document.isDirty)
|
if (document.uri.scheme !== "runa" || document.isDirty) return;
|
||||||
await vscode.commands.executeCommand("workbench.action.files.revertResource", document.uri);
|
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 {
|
watch(): vscode.Disposable {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue