fix desktop runtime owner token refresh

This commit is contained in:
Benjamin Shafii
2026-04-24 15:29:55 -07:00
parent 7c306c7f88
commit e27801658c

View File

@@ -832,7 +832,12 @@ export function createRuntimeManager({ app, desktopRoot, listLocalWorkspacePaths
openworkServerState.lanUrl = connectUrls.lanUrl; openworkServerState.lanUrl = connectUrls.lanUrl;
await waitForHttpOk(`${baseUrl}/health`, 10_000); await waitForHttpOk(`${baseUrl}/health`, 10_000);
const ownerToken = tokens.ownerToken || (await issueOwnerToken(baseUrl, tokens.hostToken)); // Owner tokens live in the OpenWork server token store, which can be reset
// independently from the desktop runtime token cache. Always mint a fresh
// owner token for the newly-started server instead of trusting the cached
// value; otherwise the renderer can receive a stale bearer token and all
// workspace calls fail with 401.
const ownerToken = await issueOwnerToken(baseUrl, tokens.hostToken);
openworkServerState.ownerToken = ownerToken; openworkServerState.ownerToken = ownerToken;
if (ownerToken) { if (ownerToken) {
await persistWorkspaceOwnerToken(activeWorkspace, ownerToken); await persistWorkspaceOwnerToken(activeWorkspace, ownerToken);