Skip to content

The agent that grows with you

fix: fence persisted bot visibility without activating profiles

Teknium7fab399a7cde
diff --git a/apps/desktop/src/sdk/index.ts b/apps/desktop/src/sdk/index.ts
index d6cbf207b65..f01cf6f1578 100644
--- a/apps/desktop/src/sdk/index.ts
+++ b/apps/desktop/src/sdk/index.ts
@@ -21,7 +21,10 @@
import { atom, computed, type ReadableAtom } from 'nanostores'
import type { ReactNode } from 'react'
-import { capabilityScoped } from '@/api/client'
+import { createSessionMutationClient, type SessionMutationSnapshot } from '../../../shared/src/session-http-mutations'
+import { capabilityScoped, getApiRequestConnection } from '@/api/client'
+
+const mutatePersistedVisibility = createSessionMutationClient()
import { PRIMARY_SESSION_VIEW } from '@/app/chat/session-view'
import { openSession, type OpenSessionIntent } from '@/app/open-session'
import type { ClientSessionState } from '@/app/types'
@@ -1394,12 +1397,14 @@ export const host = {
throw new Error('Persisted session updates require a profile and session id')
}
- return hermesApi<{ ok: boolean; hidden: boolean }>({
- ...(route ? { connectionId: route.connectionId } : {}),
- path: `/api/sessions/${encodeURIComponent(options.sessionId)}`,
- method: 'PATCH',
- body: { hidden: options.hidden, profile }
- })
+ const scope = { connectionId: route?.connectionId || getApiRequestConnection() || 'local' }
+ const path = `/api/sessions/${encodeURIComponent(options.sessionId)}`
+ const payload = { hidden: options.hidden, profile }
+ return mutatePersistedVisibility(JSON.stringify([scope, options.sessionId, payload]),
+ () => hermesApi<SessionMutationSnapshot>({ ...scope,
+ path: `${path}/mutation-snapshot?profile=${encodeURIComponent(profile)}` }),
+ identity => hermesApi<{ ok: boolean; hidden: boolean }>({ ...scope, path,
+ method: 'PATCH', body: { ...payload, ...identity } }))
},
/** Gateway JSON-RPC — sessions, config, skills, cron, kanban, everything
diff --git a/apps/desktop/src/sdk/profile-routing.test.ts b/apps/desktop/src/sdk/profile-routing.test.ts
index c79f6081ed4..ae9d54ec100 100644
--- a/apps/desktop/src/sdk/profile-routing.test.ts
+++ b/apps/desktop/src/sdk/profile-routing.test.ts
@@ -312,6 +312,7 @@ describe('connection-aware plugin host APIs', () => {
vi.mocked(hermesApi)
.mockResolvedValueOnce({ sessions: [{ id: 'bot-chat', profile: 'backend-worker', title: 'Bot Chat' }] })
+ .mockResolvedValueOnce({ exists: true, runtime_revision: 31, runtime_generation: 5 })
.mockResolvedValueOnce({ ok: true, hidden: true })
await expect(host.listPersistedSessions(route, { profile: 'backend-worker', limit: 200 })).resolves.toMatchObject({
@@ -329,10 +330,14 @@ describe('connection-aware plugin host APIs', () => {
})
)
expect(hermesApi).toHaveBeenNthCalledWith(2, {
+ connectionId: 'source-a', path: '/api/sessions/bot-chat/mutation-snapshot?profile=backend-worker'
+ })
+ expect(hermesApi).toHaveBeenNthCalledWith(3, {
connectionId: 'source-a',
path: '/api/sessions/bot-chat',
method: 'PATCH',
- body: { hidden: true, profile: 'backend-worker' }
+ body: { hidden: true, profile: 'backend-worker', expected_revision: 31,
+ expected_generation: 5, request_id: expect.any(String) }
})
expect(vi.mocked(hermesApi).mock.calls.every(([request]) => !('profile' in request))).toBe(true)
expect(requestGatewayForAgent).not.toHaveBeenCalled()