(
baseUrl: string,
authToken?: string | null,
options: { persist?: boolean; profileId?: string | null; vaultPath?: string | null } = {}
)
| 1364 | } |
| 1365 | |
| 1366 | async function setRemoteWorkspace( |
| 1367 | baseUrl: string, |
| 1368 | authToken?: string | null, |
| 1369 | options: { persist?: boolean; profileId?: string | null; vaultPath?: string | null } = {} |
| 1370 | ): Promise<{ vault: VaultInfo | null; capabilities: ServerCapabilities }> { |
| 1371 | const client = new RemoteServerClient({ baseUrl, authToken }) |
| 1372 | const capabilities = await client.getCapabilities() |
| 1373 | let vault = await client.getCurrentVault() |
| 1374 | const preferredVaultPath = options.vaultPath?.trim() || null |
| 1375 | if ( |
| 1376 | capabilities.supportsVaultSelection && |
| 1377 | preferredVaultPath && |
| 1378 | vault?.root !== preferredVaultPath |
| 1379 | ) { |
| 1380 | vault = await client.selectVaultPath(preferredVaultPath) |
| 1381 | } |
| 1382 | |
| 1383 | const win = currentIpcWindow() ?? mainWindow |
| 1384 | currentWorkspaceMode = 'remote' |
| 1385 | currentVault = vault |
| 1386 | if (win && !win.isDestroyed()) { |
| 1387 | windowVaults.setRemoteVault(win.id, vault) |
| 1388 | } |
| 1389 | remoteWorkspaceClient = client |
| 1390 | remoteServerCapabilities = capabilities |
| 1391 | currentRemoteWorkspaceProfileId = options.profileId ?? null |
| 1392 | remoteWorkspaceConfig = { |
| 1393 | baseUrl: client.baseUrl |
| 1394 | } |
| 1395 | startRemoteWatch(client, capabilities) |
| 1396 | |
| 1397 | if (options.persist !== false) { |
| 1398 | await updateConfig((cfg) => ({ |
| 1399 | ...cfg, |
| 1400 | workspaceMode: 'remote', |
| 1401 | remoteWorkspace: remoteWorkspaceConfig, |
| 1402 | remoteWorkspaceProfileId: currentRemoteWorkspaceProfileId |
| 1403 | })) |
| 1404 | } |
| 1405 | |
| 1406 | return { vault, capabilities } |
| 1407 | } |
| 1408 | |
| 1409 | async function disconnectRemoteWorkspace(): Promise<VaultInfo | null> { |
| 1410 | const cfg = await loadConfig() |
no test coverage detected