MCPcopy Create free account
hub / github.com/ZenNotes/zennotes / setRemoteWorkspace

Function setRemoteWorkspace

apps/desktop/src/main/index.ts:1366–1407  ·  view source on GitHub ↗
(
  baseUrl: string,
  authToken?: string | null,
  options: { persist?: boolean; profileId?: string | null; vaultPath?: string | null } = {}
)

Source from the content-addressed store, hash-verified

1364}
1365
1366async 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
1409async function disconnectRemoteWorkspace(): Promise<VaultInfo | null> {
1410 const cfg = await loadConfig()

Callers 3

loadRemoteFunction · 0.85
registerIpcFunction · 0.85

Calls 7

getCapabilitiesMethod · 0.95
getCurrentVaultMethod · 0.95
selectVaultPathMethod · 0.95
updateConfigFunction · 0.90
currentIpcWindowFunction · 0.85
startRemoteWatchFunction · 0.85
setRemoteVaultMethod · 0.80

Tested by

no test coverage detected