Skip to content

The agent that grows with you

fix(desktop): every explicitly scoped api/ read dials its profile backend foreground

teknium153517082c8ef
diff --git a/apps/desktop/src/api/client.ts b/apps/desktop/src/api/client.ts
index 07e2ceaef37..e82d3274fca 100644
--- a/apps/desktop/src/api/client.ts
+++ b/apps/desktop/src/api/client.ts
@@ -56,10 +56,20 @@ export function setApiRequestProfile(profile: null | string): void {
_apiProfile = profile || null
}
-export function profileScoped(profile?: null | string): { profile?: string } {
+// An explicit scope (string or object, not `undefined`/`null`) is a user
+// pointing a scope selector (Settings "Applies to", Capabilities, Messaging)
+// at another profile — a visible action whose cold dial may take the pool's
+// reserved foreground slot (#111651). The ambient path and the deliberate
+// `null` → primary path stay untagged (main's background default) so
+// hydration cannot consume that slot. The tag rides on the scope helper itself
+// so no api/ helper can carry a scope without it.
+export function profileScoped(profile?: null | string): { priority?: 'foreground'; profile?: string } {
const selected = profile === undefined ? _apiProfile : profile
- return selected ? { profile: selected } : {}
+ return {
+ ...(selected ? { profile: selected } : {}),
+ ...(profile == null ? {} : { priority: 'foreground' as const })
+ }
}
/** Profile that profile-scoped REST/WS calls should target (null → primary).
@@ -147,29 +157,25 @@ export function hermesApi<T>(request: HermesApiRequest): Promise<T> {
// this machine (see apiRequestRegistryConnectionId in Electron main).
export type ProfileScope = undefined | null | string | { connectionId?: null | string; profile?: null | string }
-export function capabilityScoped(scope?: ProfileScope): { connectionId?: string; profile?: string } {
+export function capabilityScoped(scope?: ProfileScope): {
+ connectionId?: string
+ priority?: 'foreground'
+ profile?: string
+} {
if (scope && typeof scope === 'object') {
const profile = (scope.profile ?? '').trim()
const connectionId = (scope.connectionId ?? '').trim()
return {
...(profile ? { profile } : {}),
- ...(connectionId ? { connectionId } : {})
+ ...(connectionId ? { connectionId } : {}),
+ priority: 'foreground'
}
}
return { ...profileScoped(scope), ...connectionScoped() }
}
-/** Spawn priority for a REST call that may cold-start a pooled backend. An
- * explicit scope is a user pointing a scope selector (Settings "Applies to",
- * Capabilities) at another profile — a visible action that may take the
- * pool's reserved foreground slot (#111651). The ambient path stays untagged,
- * main's background default, so hydration cannot consume that slot. */
-export function scopedDialPriority(scope?: ProfileScope): { priority?: 'foreground' } {
- return scope == null ? {} : { priority: 'foreground' }
-}
-
/** Stable cache-key for a capability scope: `profile` for the ambient/legacy
* path, `connectionId::profile` for ANY explicit pin — `local` included. An
* explicit "This device" pick and the ambient path are no longer guaranteed
diff --git a/apps/desktop/src/api/config.ts b/apps/desktop/src/api/config.ts
index 64818f58c20..bd64712cbd2 100644
--- a/apps/desktop/src/api/config.ts
+++ b/apps/desktop/src/api/config.ts
@@ -19,7 +19,6 @@ import {
hermesApi,
type ProfileScope,
profileScoped,
- scopedDialPriority,
STARTUP_REQUEST_TIMEOUT_MS
} from './client'
@@ -81,7 +80,6 @@ export function getHermesConfigRecord(
): Promise<HermesConfigRecord> {
return window.hermesDesktop.api<HermesConfigRecord>({
...capabilityScoped(profile),
- ...scopedDialPriority(profile),
path: includeDefaults ? '/api/config' : '/api/config?include_defaults=false'
})
}
@@ -97,7 +95,6 @@ export function getHermesConfigDefaults(): Promise<HermesConfigRecord> {
export function getHermesConfigSchema(profile?: null | string): Promise<ConfigSchemaResponse> {
return hermesApi<ConfigSchemaResponse>({
...profileScoped(profile),
- ...scopedDialPriority(profile),
path: '/api/config/schema'
})
}
@@ -109,7 +106,6 @@ export function saveHermesConfig(
): Promise<{ ok: boolean }> {
return hermesApi<{ ok: boolean }>({
...profileScoped(profile),
- ...scopedDialPriority(profile),
path: preserveLanguage ? '/api/config?preserve_language=true' : '/api/config',
method: 'PUT',
body: { config }
@@ -122,7 +118,6 @@ export function saveHermesConfig(
export function saveHermesConfigRecord(config: HermesConfigRecord, profile?: ProfileScope): Promise<{ ok: boolean }> {
return window.hermesDesktop.api<{ ok: boolean }>({
...capabilityScoped(profile),
- ...scopedDialPriority(profile),
path: '/api/config',
method: 'PUT',
body: { config }
@@ -132,7 +127,6 @@ export function saveHermesConfigRecord(config: HermesConfigRecord, profile?: Pro
export function getEnvVars(profile?: null | string): Promise<Record<string, EnvVarInfo>> {
return hermesApi<Record<string, EnvVarInfo>>({
...profileScoped(profile),
- ...scopedDialPriority(profile),
path: '/api/env'
})
}
@@ -140,7 +134,6 @@ export function getEnvVars(profile?: null | string): Promise<Record<string, EnvV
export function setEnvVar(key: string, value: string, profile?: ProfileScope): Promise<{ ok: boolean }> {
return window.hermesDesktop.api<{ ok: boolean }>({
...capabilityScoped(profile),
- ...scopedDialPriority(profile),
path: '/api/env',
method: 'PUT',
body: { key, value }
@@ -150,7 +143,6 @@ export function setEnvVar(key: string, value: string, profile?: ProfileScope): P
export function deleteEnvVar(key: string, profile?: ProfileScope): Promise<{ ok: boolean }> {
return window.hermesDesktop.api<{ ok: boolean }>({
...capabilityScoped(profile),
- ...scopedDialPriority(profile),
path: '/api/env',
method: 'DELETE',
body: { key }
@@ -160,7 +152,6 @@ export function deleteEnvVar(key: string, profile?: ProfileScope): Promise<{ ok:
export function revealEnvVar(key: string, profile?: ProfileScope): Promise<{ key: string; value: string }> {
return window.hermesDesktop.api<{ key: string; value: string }>({
...capabilityScoped(profile),
- ...scopedDialPriority(profile),
path: '/api/env/reveal',
method: 'POST',
body: { key }
@@ -223,7 +214,6 @@ export function deleteCustomEndpoint(id: string): Promise<CustomEndpointsRespons
export function listOAuthProviders(profile?: null | string): Promise<OAuthProvidersResponse> {
return hermesApi<OAuthProvidersResponse>({
...profileScoped(profile),
- ...scopedDialPriority(profile),
path: '/api/providers/oauth'
})
}
@@ -234,7 +224,6 @@ export function disconnectOAuthProvider(
): Promise<{ ok: boolean; provider: string }> {
return hermesApi<{ ok: boolean; provider: string }>({
...profileScoped(profile),
- ...scopedDialPriority(profile),
path: `/api/providers/oauth/${encodeURIComponent(providerId)}`,
method: 'DELETE'
})
@@ -243,7 +232,6 @@ export function disconnectOAuthProvider(
export function startOAuthLogin(providerId: string, profile?: ProfileScope): Promise<OAuthStartResponse> {
return window.hermesDesktop.api<OAuthStartResponse>({
...capabilityScoped(profile),
- ...scopedDialPriority(profile),
path: `/api/providers/oauth/${encodeURIComponent(providerId)}/start`,
method: 'POST',
body: {}
@@ -258,7 +246,6 @@ export function submitOAuthCode(
): Promise<OAuthSubmitResponse> {
return hermesApi<OAuthSubmitResponse>({
...profileScoped(profile),
- ...scopedDialPriority(profile),
path: `/api/providers/oauth/${encodeURIComponent(providerId)}/submit`,
method: 'POST',
body: { session_id: sessionId, code }
@@ -272,7 +259,6 @@ export function pollOAuthSession(
): Promise<OAuthPollResponse> {
return window.hermesDesktop.api<OAuthPollResponse>({
...capabilityScoped(profile),
- ...scopedDialPriority(profile),
path: `/api/providers/oauth/${encodeURIComponent(providerId)}/poll/${encodeURIComponent(sessionId)}`
})
}
@@ -280,7 +266,6 @@ export function pollOAuthSession(
export function cancelOAuthSession(sessionId: string, profile?: null | string): Promise<{ ok: boolean }> {
return hermesApi<{ ok: boolean }>({
...profileScoped(profile),
- ...scopedDialPriority(profile),
path: `/api/providers/oauth/sessions/${encodeURIComponent(sessionId)}`,
method: 'DELETE'
})
diff --git a/apps/desktop/src/api/mcp.ts b/apps/desktop/src/api/mcp.ts
index 27dd56c3f2b..764a4828e4e 100644
--- a/apps/desktop/src/api/mcp.ts
+++ b/apps/desktop/src/api/mcp.ts
@@ -1,6 +1,6 @@
import type { McpCatalogResponse, McpServerSummary } from '@/types/hermes'
-import { capabilityScoped, hermesApi, type ProfileScope, profileScoped, scopedDialPriority } from './client'
+import { capabilityScoped, hermesApi, type ProfileScope, profileScoped } from './client'
export interface McpTestResult {
ok: boolean
@@ -117,7 +117,6 @@ export function setMcpServerEnabled(name: string, enabled: boolean): Promise<{ o
export function getMcpCatalog(profile?: ProfileScope, detectApps = false): Promise<McpCatalogResponse> {
return window.hermesDesktop.api<McpCatalogResponse>({
...capabilityScoped(profile),
- ...scopedDialPriority(profile),
path: `/api/mcp/catalog${detectApps ? '?detect_apps=true' : ''}`,
...(detectApps ? { timeoutMs: 5000 } : {})
})
diff --git a/apps/desktop/src/api/messaging.ts b/apps/desktop/src/api/messaging.ts
index f7ec18642ef..bca8d7e68f2 100644
--- a/apps/desktop/src/api/messaging.ts
+++ b/apps/desktop/src/api/messaging.ts
@@ -86,11 +86,13 @@ export function applyTelegramOnboarding(
allowedUserIds: string[],
profile?: null | string
): Promise<TelegramOnboardingApplyResponse> {
+ const scope = profileScoped(profile)
+
return hermesApi<TelegramOnboardingApplyResponse>({
- ...profileScoped(profile),
+ ...scope,
path: `/api/messaging/telegram/onboarding/${encodeURIComponent(pairingId)}/apply`,
method: 'POST',
- body: { allowed_user_ids: allowedUserIds, ...profileScoped(profile) }
+ body: { allowed_user_ids: allowedUserIds, profile: scope.profile }
})
}
@@ -121,22 +123,26 @@ export function approvePairing(
requestId: string,
profile?: null | string
): Promise<{ ok: boolean; user: PairingUser }> {
+ const scope = profileScoped(profile)
+
return hermesApi<{ ok: boolean; user: PairingUser }>({
- ...profileScoped(profile),
+ ...scope,
path: '/api/pairing/approve',
method: 'POST',
// These endpoints read the profile off the body, not the query string —
- // `profileScoped()` alone would approve into the wrong profile's store.
- body: { platform, request_id: requestId, ...profileScoped(profile) }
+ // the request scope alone would approve into the wrong profile's store.
+ body: { platform, request_id: requestId, profile: scope.profile }
})
}
export function revokePairing(platform: string, userId: string, profile?: null | string): Promise<{ ok: boolean }> {
+ const scope = profileScoped(profile)
+
return hermesApi<{ ok: boolean }>({
- ...profileScoped(profile),
+ ...scope,
path: '/api/pairing/revoke',
method: 'POST',
- body: { platform, user_id: userId, ...profileScoped(profile) }
+ body: { platform, user_id: userId, profile: scope.profile }
})
}
diff --git a/apps/desktop/src/api/models.ts b/apps/desktop/src/api/models.ts
index 0c350c22c00..22a85a7c732 100644
--- a/apps/desktop/src/api/models.ts
+++ b/apps/desktop/src/api/models.ts
@@ -14,14 +14,12 @@ import {
hermesApi,
type ProfileScope,
profileScoped,
- scopedDialPriority,
STARTUP_REQUEST_TIMEOUT_MS
} from './client'
export function getGlobalModelInfo(profile?: null | string): Promise<ModelInfoResponse> {
return hermesApi<ModelInfoResponse>({
...profileScoped(profile),
- ...scopedDialPriority(profile),
path: '/api/model/info',
timeoutMs: STARTUP_REQUEST_TIMEOUT_MS
})
@@ -58,7 +56,6 @@ export function getGlobalModelOptions(
return hermesApi<ModelOptionsResult>({
...profileScoped(profile),
- ...scopedDialPriority(profile),
path: params.size > 0 ? `/api/model/options?${params.toString()}` : '/api/model/options',
timeoutMs: STARTUP_REQUEST_TIMEOUT_MS
})
@@ -80,7 +77,6 @@ export function getRecommendedDefaultModel(
): Promise<RecommendedDefaultModel> {
return hermesApi<RecommendedDefaultModel>({
...profileScoped(profile),
- ...scopedDialPriority(profile),
path: `/api/model/recommended-default?provider=${encodeURIComponent(provider)}`
})
}
@@ -104,7 +100,6 @@ export function setGlobalModel(
export function getAuxiliaryModels(profile?: null | string): Promise<AuxiliaryModelsResponse> {
return hermesApi<AuxiliaryModelsResponse>({
...profileScoped(profile),
- ...scopedDialPriority(profile),
path: '/api/model/auxiliary'
})
}
@@ -112,7 +107,6 @@ export function getAuxiliaryModels(profile?: null | string): Promise<AuxiliaryMo
export function getMoaModels(profile?: null | string): Promise<MoaConfigResponse> {
return hermesApi<MoaConfigResponse>({
...profileScoped(profile),
- ...scopedDialPriority(profile),
path: '/api/model/moa'
})
}
@@ -123,7 +117,6 @@ export function saveMoaModels(
): Promise<MoaConfigResponse & { ok: boolean }> {
return hermesApi<MoaConfigResponse & { ok: boolean }>({
...profileScoped(profile),
- ...scopedDialPriority(profile),
path: '/api/model/moa',
method: 'PUT',
body
@@ -136,7 +129,6 @@ export function setModelAssignment(
): Promise<ModelAssignmentResponse> {
return hermesApi<ModelAssignmentResponse>({
...profileScoped(profile),
- ...scopedDialPriority(profile),
path: '/api/model/set',
method: 'POST',
body
diff --git a/apps/desktop/src/api/session-transcript-paging.test.ts b/apps/desktop/src/api/session-transcript-paging.test.ts
index 4dbe26976e3..e505d638c0f 100644
--- a/apps/desktop/src/api/session-transcript-paging.test.ts
+++ b/apps/desktop/src/api/session-transcript-paging.test.ts
@@ -73,9 +73,12 @@ describe('session transcript pagination ownership', () => {
).toBe(true)
// Resolve the owner for lookup, but replay the exact ambient read route.
+ // A backfill is a user's "Show earlier" click on an explicit route, so
+ // it carries the foreground dial tag (#111651).
expect(api).toHaveBeenLastCalledWith({
...(connectionId ? { connectionId } : {}),
- path: `/api/sessions/stored-session/messages?limit=${LATEST_SESSION_MESSAGES_LIMIT}&offset=${tail.length}&order=latest&include_compacted=true`
+ path: `/api/sessions/stored-session/messages?limit=${LATEST_SESSION_MESSAGES_LIMIT}&offset=${tail.length}&order=latest&include_compacted=true`,
+ priority: 'foreground'
})
expect(messages.map(message => message.rowId)).toEqual([...older, ...tail].map(message => message.id))
expect(transcriptBackfillAvailable('stored-session', owner)).toBe(false)
@@ -111,7 +114,8 @@ describe('session transcript pagination ownership', () => {
// An explicit local pin would bypass Electron's per-profile remote override.
expect.soft(api).toHaveBeenLastCalledWith({
profile,
- path: `/api/sessions/stored-session/messages?profile=${profile}&limit=${LATEST_SESSION_MESSAGES_LIMIT}&order=latest&include_compacted=true`
+ path: `/api/sessions/stored-session/messages?profile=${profile}&limit=${LATEST_SESSION_MESSAGES_LIMIT}&order=latest&include_compacted=true`,
+ priority: 'foreground'
})
expect(transcriptBackfillAvailable('stored-session', owner)).toBe(true)
@@ -128,7 +132,8 @@ describe('session transcript pagination ownership', () => {
expect(api).toHaveBeenLastCalledWith({
profile,
- path: `/api/sessions/stored-session/messages?profile=${profile}&limit=${LATEST_SESSION_MESSAGES_LIMIT}&offset=${tail.length}&order=latest&include_compacted=true`
+ path: `/api/sessions/stored-session/messages?profile=${profile}&limit=${LATEST_SESSION_MESSAGES_LIMIT}&offset=${tail.length}&order=latest&include_compacted=true`,
+ priority: 'foreground'
})
expect(applyOlderPage).toHaveBeenCalledWith(toChatMessages([row(1)]))
expect(transcriptTailState('stored-session', owner)).toMatchObject({
@@ -186,7 +191,8 @@ describe('session transcript pagination ownership', () => {
// Serving-profile metadata selects the cache entry, not the request route.
expect(api).toHaveBeenLastCalledWith({
connectionId: 'source-a',
- path: `/api/sessions/stored-session/messages?limit=${LATEST_SESSION_MESSAGES_LIMIT}&offset=${tail.messages.length}&order=latest&include_compacted=true`
+ path: `/api/sessions/stored-session/messages?limit=${LATEST_SESSION_MESSAGES_LIMIT}&offset=${tail.messages.length}&order=latest&include_compacted=true`,
+ priority: 'foreground'
})
expect(applyOlderPage).toHaveBeenCalledWith(toChatMessages([row(0)]))
expect(transcriptTailState('stored-session', ownerA)).toEqual({
diff --git a/apps/desktop/src/api/skills.ts b/apps/desktop/src/api/skills.ts
index 656c073ca14..f4d32f4dcca 100644
--- a/apps/desktop/src/api/skills.ts
+++ b/apps/desktop/src/api/skills.ts
@@ -9,12 +9,11 @@ import type {
} from '@/types/hermes'
import type { ActionResponse } from '@/types/hermes'
-import { capabilityScoped, hermesApi, type ProfileScope, profileScoped, scopedDialPriority } from './client'
+import { capabilityScoped, hermesApi, type ProfileScope, profileScoped } from './client'
export function getSkills(profile?: ProfileScope): Promise<SkillInfo[]> {
return window.hermesDesktop.api<SkillInfo[]>({
...capabilityScoped(profile),
- ...scopedDialPriority(profile),
path: '/api/skills'
})
}
diff --git a/apps/desktop/src/api/toolsets.ts b/apps/desktop/src/api/toolsets.ts
index af0d27b2aa8..862c0fc521d 100644
--- a/apps/desktop/src/api/toolsets.ts
+++ b/apps/desktop/src/api/toolsets.ts
@@ -7,7 +7,7 @@ import type {
ToolsetModelsResponse
} from '@/types/hermes'
-import { capabilityScoped, hermesApi, type ProfileScope, profileScoped, scopedDialPriority } from './client'
+import { capabilityScoped, hermesApi, type ProfileScope, profileScoped } from './client'
// The optional trailing `profile` on every capability fetcher below is the
// Capabilities view's profile-scope override: it lets the Skills/Tools/MCP
@@ -17,7 +17,6 @@ import { capabilityScoped, hermesApi, type ProfileScope, profileScoped, scopedDi
export function getToolsets(profile?: ProfileScope): Promise<ToolsetInfo[]> {
return window.hermesDesktop.api<ToolsetInfo[]>({
...capabilityScoped(profile),
- ...scopedDialPriority(profile),
path: '/api/tools/toolsets'
})
}
diff --git a/apps/desktop/src/app/contrib/hooks/use-desktop-integrations.test.tsx b/apps/desktop/src/app/contrib/hooks/use-desktop-integrations.test.tsx
index f4c324e957c..fdfa65c57ee 100644
--- a/apps/desktop/src/app/contrib/hooks/use-desktop-integrations.test.tsx
+++ b/apps/desktop/src/app/contrib/hooks/use-desktop-integrations.test.tsx
@@ -641,10 +641,10 @@ describe('useDesktopIntegrations', () => {
settleConfirm(true)
await waitFor(() => expect($hubInstalledOverride.get()[identifier]).toBe(true))
expect(installs()).toEqual([[{
- connectionId: connection, profile, path: '/api/skills/hub/install', method: 'POST', body: { identifier }
+ connectionId: connection, profile, priority: 'foreground', path: '/api/skills/hub/install', method: 'POST', body: { identifier }
}]])
expect(api).toHaveBeenCalledWith({
- connectionId: connection, profile, path: '/api/actions/skill-link-test/status?lines=200'
+ connectionId: connection, profile, priority: 'foreground', path: '/api/actions/skill-link-test/status?lines=200'
})
}
diff --git a/apps/desktop/src/hermes-capability-scope.test.ts b/apps/desktop/src/hermes-capability-scope.test.ts
index e1f24cfe046..e7c7b097983 100644
--- a/apps/desktop/src/hermes-capability-scope.test.ts
+++ b/apps/desktop/src/hermes-capability-scope.test.ts
@@ -1,6 +1,9 @@
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
+import { approvePairing, getMessagingPlatforms } from './api/messaging'
import { getAuxiliaryModels, getGlobalModelInfo } from './api/models'
+import { getOfficialSkills, getSkillHubSources } from './api/skills'
+import { getToolsetConfig } from './api/toolsets'
import {
getHermesConfigRecord,
getMcpCatalog,
@@ -93,6 +96,38 @@ describe('capability helpers are connection-scoped', () => {
expect(last()).toMatchObject({ profile: 'coder', priority: 'foreground' })
})
+ it('every explicitly scoped api/ helper dials foreground, not only the Settings pages (#111651)', () => {
+ // The class rule lives in the scope helpers themselves, so a helper in
+ // any api/ module inherits it — Capabilities hub/toolset-config reads and
+ // the Messaging page were left queueing as background work when the rule
+ // was spread per call site.
+ void getOfficialSkills('coder')
+ expect(last()).toMatchObject({ profile: 'coder', priority: 'foreground' })
+
+ void getSkillHubSources('coder')
+ expect(last()).toMatchObject({ profile: 'coder', priority: 'foreground' })
+
+ void getToolsetConfig('browser', { connectionId: 'homelab', profile: 'coder' })
+ expect(last()).toMatchObject({ connectionId: 'homelab', profile: 'coder', priority: 'foreground' })
+
+ void getMessagingPlatforms('coder')
+ expect(last()).toMatchObject({ profile: 'coder', priority: 'foreground' })
+
+ // `null` deliberately targets the primary — that backend is always warm,
+ // so it stays untagged like the ambient path.
+ void getOfficialSkills(null)
+ expect(last()).not.toHaveProperty('priority')
+ })
+
+ it('a foreground tag never leaks into a request body that carries the profile', () => {
+ void approvePairing('telegram', 'req-1', 'coder')
+
+ const call = api.mock.calls.at(-1)?.[0] as { body?: Record<string, unknown>; priority?: string }
+
+ expect(call.priority).toBe('foreground')
+ expect(call.body).toEqual({ platform: 'telegram', request_id: 'req-1', profile: 'coder' })
+ })
+
it('keeps ambient config reads unprioritized for background hydration', () => {
getHermesConfigRecord()
expect(last()).not.toHaveProperty('priority')
diff --git a/apps/desktop/src/hermes.test.ts b/apps/desktop/src/hermes.test.ts
index bb06f19468f..c0794c585a6 100644
--- a/apps/desktop/src/hermes.test.ts
+++ b/apps/desktop/src/hermes.test.ts
@@ -509,6 +509,9 @@ describe('Hermes REST helpers', () => {
expect(call.timeoutMs).toBeUndefined()
})
+ // An explicit profile/connection scope is a user action (opening another
+ // profile's session, deleting a profile), so the request also carries the
+ // foreground dial tag (#111651).
it('tags cross-profile message reads for Electron routing and backend lookup', async () => {
api.mockResolvedValue({ messages: [], session_id: 'session-1' })
@@ -516,6 +519,7 @@ describe('Hermes REST helpers', () => {
expect(api).toHaveBeenCalledWith({
path: '/api/sessions/session-1/messages?profile=xiaoxuxu',
+ priority: 'foreground',
profile: 'xiaoxuxu'
})
})
@@ -530,11 +534,13 @@ describe('Hermes REST helpers', () => {
expect(api).toHaveBeenNthCalledWith(1, {
connectionId: 'source-a',
path: '/api/sessions/session-1?profile=backend-default',
+ priority: 'foreground',
profile: 'backend-default'
})
expect(api).toHaveBeenNthCalledWith(2, {
connectionId: 'source-a',
path: '/api/sessions/session-1/messages?profile=backend-default',
+ priority: 'foreground',
profile: 'backend-default'
})
})
@@ -552,6 +558,7 @@ describe('Hermes REST helpers', () => {
connectionId: 'source-a',
method: 'DELETE',
path: '/api/profiles/backend-worker',
+ priority: 'foreground',
profile: 'backend-worker'
})
})
@@ -568,6 +575,7 @@ describe('Hermes REST helpers', () => {
expect(LATEST_SESSION_MESSAGES_LIMIT).toBe(120)
expect(api).toHaveBeenCalledWith({
path: '/api/sessions/session-1/messages?profile=xiaoxuxu&limit=120&order=latest&include_compacted=true',
+ priority: 'foreground',
profile: 'xiaoxuxu'
})
})
@@ -593,6 +601,7 @@ describe('Hermes REST helpers', () => {
expect(api).toHaveBeenCalledWith({
path: '/api/sessions/session-1/messages?profile=xiaoxuxu&limit=120&offset=240&order=latest&include_compacted=true',
+ priority: 'foreground',
profile: 'xiaoxuxu'
})
})
@@ -608,6 +617,7 @@ describe('Hermes REST helpers', () => {
expect(api).toHaveBeenCalledWith({
path: '/api/sessions/session-1/messages?profile=xiaoxuxu&limit=500&offset=1000&order=latest',
+ priority: 'foreground',
profile: 'xiaoxuxu'
})
})
@@ -630,10 +640,12 @@ describe('Hermes REST helpers', () => {
expect(result.messages).toEqual([{ id: 1 }, { id: 2 }, { id: 3 }])
expect(api).toHaveBeenNthCalledWith(1, {
path: '/api/sessions/session-1/messages?profile=xiaoxuxu&limit=500&offset=0&order=oldest&include_compacted=true',
+ priority: 'foreground',
profile: 'xiaoxuxu'
})
expect(api).toHaveBeenNthCalledWith(2, {
path: '/api/sessions/session-1/messages?profile=xiaoxuxu&limit=500&offset=2&order=oldest&include_compacted=true',
+ priority: 'foreground',
profile: 'xiaoxuxu'
})
})