0.10.1: Archify Sync in the status bar, server address as a setting

In workspaces with Archify files, Archify Sync sits in the status bar and
opens a menu: sign in, share, join, server address, settings. The new
archify.sync.server setting (empty by default) is used without asking,
and in workspace settings gives a project one server.
archify.sync.statusBar hides the entry.
This commit is contained in:
root-at-skic committed 2026-11-06 23:21:56 +02:00
1 parent d02c331155
commit 9ccd67b2dd
7 files changed
+135 -19

No files matched your search

+21
View File
@@ -16,6 +16,7 @@ const COMMANDS = [
'archify.sync.versions',
'archify.sync.stop',
'archify.sync.menu',
'archify.sync.setServer',
] as const;
/**
@@ -26,8 +27,26 @@ const COMMANDS = [
*/
export function registerSync(context: vscode.ExtensionContext, models: ModelService): vscode.Disposable[] {
let feature: Promise<SyncFeature> | undefined;
// Until the sync bundle loads, this entry is the way in; then the bundle's own one takes over.
const entry = vscode.window.createStatusBarItem('archify.sync', vscode.StatusBarAlignment.Left, 50);
entry.name = 'Archify Sync';
entry.text = '$(cloud) Archify Sync';
entry.tooltip = 'Archify Sync (optional): sign in, share a model with others or join one. Set the server under Settings › Archify › Sync.';
entry.command = 'archify.sync.menu';
// Only where there are Archify files: the extension also starts for JSON and HTML.
let archifyHere = false;
const showEntry = () => {
const wanted = archifyHere && !feature && vscode.workspace.getConfiguration('archify.sync').get<boolean>('statusBar', true);
if (wanted) entry.show();
else entry.hide();
};
void Promise.resolve(vscode.workspace.findFiles('**/*.{archify,archify-registry,archify-decision}', '{**/node_modules/**,**/.git/**}', 1)).then((found) => {
archifyHere = found.length > 0;
showEntry();
});
const load = (): Promise<SyncFeature> =>
(feature ??= (async () => {
showEntry();
// A runtime path, so esbuild leaves the sync bundle out of this one.
const bundle = path.join(__dirname, 'sync.js');
const mod = require(bundle) as typeof import('./index');
@@ -44,6 +63,8 @@ export function registerSync(context: vscode.ExtensionContext, models: ModelServ
})();
return [
entry,
vscode.workspace.onDidChangeConfiguration((e) => e.affectsConfiguration('archify.sync.statusBar') && showEntry()),
liveBridge,
...COMMANDS.map((id) =>
vscode.commands.registerCommand(id, async (...args: unknown[]) => (await load()).run(id, ...args)),