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

+1 -15
View File
@@ -41,8 +41,6 @@ export class SyncFeature implements vscode.Disposable, LiveProvider {
private cursorTimer: ReturnType<typeof setTimeout> | undefined;
/** Servers with a session on this machine, for the status bar before any model is shared. */
private signedIn: string[] = [];
/** Whether the workspace has Archify files; elsewhere the entry stays hidden until a model is shared. */
private archifyHere = false;
constructor(
private readonly context: vscode.ExtensionContext,
@@ -80,7 +78,6 @@ export class SyncFeature implements vscode.Disposable, LiveProvider {
async start(): Promise<void> {
const found = await vscode.workspace.findFiles(`**/${LINK_FILE}`, SKIP, 50);
await Promise.all(found.map((uri) => this.open(uri, 'open')));
this.archifyHere = (await vscode.workspace.findFiles('**/*.{archify,archify-registry,archify-decision}', SKIP, 1)).length > 0;
await this.refreshSignedIn();
}
@@ -139,19 +136,8 @@ export class SyncFeature implements vscode.Disposable, LiveProvider {
private render(): void {
const spaces = [...this.spaces.values()];
if (!spaces.length) {
this.status.hide();
void vscode.commands.executeCommand('setContext', 'archify.sync.active', false);
// Nothing shared here yet: the way in, as before the sync bundle loaded.
if (!this.archifyHere || !vscode.workspace.getConfiguration('archify.sync').get<boolean>('statusBar', true)) {
this.status.hide();
return;
}
const hosts = this.signedIn.map((server) => new URL(server).host);
this.status.text = hosts.length ? `$(cloud) Archify Sync · ${hosts.join(', ')}` : '$(cloud) Archify Sync';
this.status.tooltip = hosts.length
? `Signed in to ${hosts.join(', ')}. Click to share a model, join one or sign out.`
: 'Archify Sync (optional): sign in, share a model with others or join one. Set the server under Settings › Archify › Sync.';
this.status.backgroundColor = undefined;
this.status.show();
this.bridge?.changed();
return;
}
-20
View File
@@ -27,26 +27,8 @@ 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');
@@ -63,8 +45,6 @@ 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)),