0.10.4: a real Sync button on every Archify page

A labelled Sync button sits top right on every Archify page, also in Source, and opens the Sync menu. On a shared model it turns green and reads Shared. The title-bar icon and the pre-share status bar entry are gone, with their settings.
This commit is contained in:
root-at-skic committed 2026-11-07 01:25:34 +02:00
1 parent 7d2d55543e
commit 90c7be06de
10 files changed
+88 -58

No files matched your search

+32
View File
@@ -17,6 +17,8 @@ export type WebviewMessage =
| { type: 'showModel' }
| { type: 'liveReady' }
| { type: 'liveAction'; action: LiveAction }
| { type: 'syncMenu' }
| { type: 'syncReady' }
| { type: 'error'; message: string };
/** Column for opening files next to a webview without covering it. */
@@ -66,6 +68,28 @@ async function openSource(
vscode.window.showWarningMessage(`Archify: source file "${message.path}" was not found in the workspace.`);
}
/**
* Whether the file's model is shared: an .archify-sync file next to its
* main.archify. Read from disk, so the sync bundle stays unloaded.
*/
async function isShared(file: vscode.Uri): Promise<boolean> {
const folder = vscode.workspace.getWorkspaceFolder(file);
let dir = vscode.Uri.joinPath(file, '..');
for (let depth = 0; depth < 16; depth++) {
if (await exists(vscode.Uri.joinPath(dir, '.archify-sync'))) return true;
if (await exists(vscode.Uri.joinPath(dir, 'main.archify'))) return false;
const parent = vscode.Uri.joinPath(dir, '..');
if (!folder || dir.path === folder.uri.path || parent.path === dir.path) return false;
dir = parent;
}
return false;
}
async function postSyncState(file: vscode.Uri, panel: vscode.WebviewPanel): Promise<void> {
const shared = file.scheme === 'file' && (await isShared(file));
await Promise.resolve(panel.webview.postMessage({ type: 'syncState', shared })).catch(() => undefined);
}
export async function handleWebviewMessage(
message: WebviewMessage,
context: vscode.Uri,
@@ -99,6 +123,14 @@ export async function handleWebviewMessage(
case 'error':
vscode.window.showErrorMessage(`Archify: ${message.message}`);
break;
case 'syncReady':
await postSyncState(context, panel);
break;
case 'syncMenu':
await vscode.commands.executeCommand('archify.sync.menu');
// Share or Stop may have changed it.
await postSyncState(context, panel);
break;
case 'hash':
case 'openDiagram':
case 'showGraph':