Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(utils): treat gateway core mode like cloud when skipping local user read

Steven Enamakeldfcbda837612
diff --git a/app/src/utils/bootstrapActiveUser.ts b/app/src/utils/bootstrapActiveUser.ts
index 71048e94f7..069d4cd412 100644
--- a/app/src/utils/bootstrapActiveUser.ts
+++ b/app/src/utils/bootstrapActiveUser.ts
@@ -4,7 +4,8 @@
*
* Three source shapes:
* 1. Mascot/notch native windows — no Tauri IPC, cannot invoke commands.
- * 2. Cloud/remote core mode — the local `~/.openhuman/active_user.toml`
+ * 2. Any remote core mode — cloud, or a gateway this app provisioned in a
+ * container or on another machine. The local `~/.openhuman/active_user.toml`
* is either empty (no prior local session) or bound to a prior LOCAL
* session's user id. In both cases it doesn't match the REMOTE core's
* authenticated user, and priming from it overwrites the correct
@@ -20,17 +21,25 @@
* `userScopedStorage.ts::primeActiveUserId` and the "cloud-mode reload
* survival" test.
*/
+/** Every core mode the picker and the gateway section can persist. */
+type StoredCoreMode = 'local' | 'cloud' | 'gateway' | null;
+
interface BootstrapContext {
isStandaloneNativeWindow: boolean;
- coreMode: 'local' | 'cloud' | null;
+ coreMode: StoredCoreMode;
getActiveUserIdFromCore: () => Promise<string | null>;
}
export function shouldSkipLocalActiveUserRead(opts: {
isStandaloneNativeWindow: boolean;
- coreMode: 'local' | 'cloud' | null;
+ coreMode: StoredCoreMode;
}): boolean {
- return opts.isStandaloneNativeWindow || opts.coreMode === 'cloud';
+ // `gateway` belongs with `cloud`, not with `local`: the reasoning above is
+ // about the local file describing a *different* core's user, and that is
+ // just as true of a core in a container as of one at a URL. Treating it as
+ // local would prime from a stale id and reintroduce the #4545 restart loop
+ // for exactly the users this feature exists for.
+ return opts.isStandaloneNativeWindow || opts.coreMode === 'cloud' || opts.coreMode === 'gateway';
}
export function resolveActiveUserBootstrap(ctx: BootstrapContext): Promise<string | null> {
diff --git a/app/src/utils/desktopDeepLinkListener.ts b/app/src/utils/desktopDeepLinkListener.ts
index 2f0a2d53f5..f422fc8777 100644
--- a/app/src/utils/desktopDeepLinkListener.ts
+++ b/app/src/utils/desktopDeepLinkListener.ts
@@ -423,13 +423,18 @@ export const classifyAuthStoreFailure = (message: string): string => {
*/
export const authStoreFailureUserMessage = (
kind: string,
- mode: 'local' | 'cloud' | null
+ mode: 'local' | 'cloud' | 'gateway' | null
): string => {
// NOTE: `config_unreadable` never reaches here — its copy is translated and
// is resolved from `CORE_CONFIG_UNREADABLE_I18N_KEY` at the rendering
// component instead (see the catch block in `handleAuthDeepLink`). It is
// mode-independent anyway: an unreadable config.toml is a property of
// whichever core answered, embedded or remote, and retrying never clears it.
+ // `gateway` deliberately takes this branch rather than the cloud copy below.
+ // The cloud text tells the user to check an RPC token and URL in Settings,
+ // which a gateway user never entered — their core is provisioned by this app.
+ // Restarting is also genuinely the right advice for them: it re-activates the
+ // gateway, which clears a transient provisioning failure.
if (mode !== 'cloud') {
return (
'Sign-in could not be completed right now. The session store did not respond in time ' +