mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-21 16:18:55 +00:00
refactor(desktop): extract isRemoteConfig from the reauth predicate
Factor the "remote/cloud with a URL" check out of isRemoteReauthFailure into a shared isRemoteConfig helper so the boot-failure overlay can tell any remote failure apart from a local one.
This commit is contained in:
parent
79c0806456
commit
e1fa54d367
2 changed files with 27 additions and 19 deletions
|
|
@ -2,7 +2,7 @@ import { describe, expect, it } from 'vitest'
|
|||
|
||||
import type { DesktopConnectionConfig } from '@/global'
|
||||
|
||||
import { deriveProviderShape, isRemoteReauthFailure, signInLabel } from './boot-failure-reauth'
|
||||
import { deriveProviderShape, isRemoteConfig, isRemoteReauthFailure, signInLabel } from './boot-failure-reauth'
|
||||
|
||||
function config(overrides: Partial<DesktopConnectionConfig> = {}): DesktopConnectionConfig {
|
||||
return {
|
||||
|
|
@ -19,6 +19,19 @@ function config(overrides: Partial<DesktopConnectionConfig> = {}): DesktopConnec
|
|||
}
|
||||
}
|
||||
|
||||
describe('isRemoteConfig', () => {
|
||||
it('true for remote/cloud with a URL, regardless of auth mode or connection', () => {
|
||||
expect(isRemoteConfig(config({ remoteAuthMode: 'token', remoteOauthConnected: false }))).toBe(true)
|
||||
expect(isRemoteConfig(config({ mode: 'cloud', remoteOauthConnected: true }))).toBe(true)
|
||||
})
|
||||
|
||||
it('false for local, for a remote with no URL, and for nullish', () => {
|
||||
expect(isRemoteConfig(config({ mode: 'local' }))).toBe(false)
|
||||
expect(isRemoteConfig(config({ remoteUrl: '' }))).toBe(false)
|
||||
expect(isRemoteConfig(null)).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
describe('isRemoteReauthFailure', () => {
|
||||
it('true for a remote, gated, disconnected gateway with a URL', () => {
|
||||
expect(isRemoteReauthFailure(config())).toBe(true)
|
||||
|
|
|
|||
|
|
@ -26,25 +26,20 @@ const DEFAULT_SIGN_IN_COPY: SignInCopy = {
|
|||
withProvider: provider => `Sign in with ${provider}`
|
||||
}
|
||||
|
||||
// A remote, gated (oauth-bucket), not-currently-connected gateway is a
|
||||
// remote-reauth boot failure: the access cookie lapsed (e.g. the remote
|
||||
// dashboard restarted) and the local-recovery buttons (Retry/Repair) can't
|
||||
// fix it — only re-establishing the remote session can. A connected oauth
|
||||
// session, or a token/local gateway, boots for some other reason the
|
||||
// local-recovery buttons address, so those return false here. 'cloud' counts
|
||||
// as remote here — it resolves to a remote oauth backend (cloud-auto-discovery
|
||||
// Q6), so a lapsed cloud session is the same reauth failure.
|
||||
export function isRemoteReauthFailure(config: DesktopConnectionConfig | null | undefined): boolean {
|
||||
if (!config) {
|
||||
return false
|
||||
}
|
||||
// True when the app is pointed at a remote/cloud backend (either resolves to a
|
||||
// remote URL). Any boot failure in this shape is fixable from Settings →
|
||||
// Gateway (edit URL / token / sign in) — the local Retry/Repair buttons target
|
||||
// the bundled backend and can't help. Drives the escape-hatch emphasis.
|
||||
export function isRemoteConfig(config: DesktopConnectionConfig | null | undefined): boolean {
|
||||
return Boolean(config && (config.mode === 'remote' || config.mode === 'cloud') && config.remoteUrl)
|
||||
}
|
||||
|
||||
return (
|
||||
(config.mode === 'remote' || config.mode === 'cloud') &&
|
||||
config.remoteAuthMode === 'oauth' &&
|
||||
!config.remoteOauthConnected &&
|
||||
Boolean(config.remoteUrl)
|
||||
)
|
||||
// A remote, gated (oauth-bucket), not-currently-connected gateway is a
|
||||
// remote-reauth boot failure: the access cookie lapsed and the local Retry/Repair
|
||||
// buttons can't fix it — only re-establishing the remote session can. 'cloud'
|
||||
// counts as remote (it resolves to a remote oauth backend).
|
||||
export function isRemoteReauthFailure(config: DesktopConnectionConfig | null | undefined): boolean {
|
||||
return isRemoteConfig(config) && config!.remoteAuthMode === 'oauth' && !config!.remoteOauthConnected
|
||||
}
|
||||
|
||||
// Derive the password flag + display label from the probed providers. A
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue