Skip to content

The agent that grows with you

test: CI-only reds — desktop lint, provider-independent alias test, discord skip, blocked-observer close

Tekniumdba3054baf5a
diff --git a/apps/desktop/electron/gateway-download-transport.test.ts b/apps/desktop/electron/gateway-download-transport.test.ts
index e5304d6f121..d18de3a7875 100644
--- a/apps/desktop/electron/gateway-download-transport.test.ts
+++ b/apps/desktop/electron/gateway-download-transport.test.ts
@@ -1,27 +1,37 @@
-import { expect, test } from 'vitest'
import fs from 'node:fs/promises'
+import http from 'node:http'
+import net from 'node:net'
import os from 'node:os'
import path from 'node:path'
-import net from 'node:net'
-import http from 'node:http'
-import { downloadViaTokenToFile } from './gateway-download-transport'
+
+import { expect, test } from 'vitest'
+
import { destroyKeepaliveAgents } from './api-transport'
+import { downloadViaTokenToFile } from './gateway-download-transport'
test('download transport never follows redirects or retries after the save phase begins', async () => {
let requests = 0
let finalized = 0
+
const server = http.createServer((req, res) => {
requests++
- if (req.url === '/redirect') { res.writeHead(302, { Location: '/leak' }); res.end(); return }
+
+ if (req.url === '/redirect') { res.writeHead(302, { Location: '/leak' }); res.end();
+
+ return }
+
res.end('bytes')
})
+
await new Promise<void>(resolve => server.listen(0, '127.0.0.1', resolve))
const url = `http://127.0.0.1:${(server.address() as net.AddressInfo).port}`
+
const finish = async (res: http.IncomingMessage) => {
finalized++
res.resume()
throw Object.assign(new Error('write ECONNRESET'), { code: 'ECONNRESET' })
}
+
try {
await expect(downloadViaTokenToFile(url + '/redirect', 'remote-static', {}, finish)).rejects.toThrow('redirect')
expect(finalized).toBe(0)
@@ -45,13 +55,18 @@ test('the connect timeout is dropped once headers arrive so a slow body streams
res.write('head-')
setTimeout(() => res.end('tail'), 120)
})
+
await new Promise<void>(resolve => server.listen(0, '127.0.0.1', resolve))
const url = `http://127.0.0.1:${(server.address() as net.AddressInfo).port}/file`
+
const finish = async (res: http.IncomingMessage) => {
const chunks: Buffer[] = []
+
for await (const chunk of res) { chunks.push(Buffer.from(chunk)) }
+
return Buffer.concat(chunks).toString()
}
+
try {
await expect(downloadViaTokenToFile(url, 'remote-static', {}, finish, { timeoutMs: 30 })).resolves.toBe('head-tail')
} finally {
@@ -65,27 +80,39 @@ test.skipIf(process.platform === 'win32')('download retries mint a new private g
const grants: string[] = []
const wire: http.IncomingHttpHeaders[] = []
const controls: any[] = []
+
const control = net.createServer(socket => socket.once('data', chunk => {
controls.push(JSON.parse(chunk.toString()).params)
const ticket = `private-${controls.length}`
grants.push(ticket)
socket.end(JSON.stringify({ protocol: 1, id: 1, ok: true, result: { profile_id: home, instance_id: 'owner', ticket } }) + '\n')
}))
+
await new Promise<void>(resolve => control.listen(path.join(home, 'gateway.sock'), resolve))
await fs.chmod(path.join(home, 'gateway.sock'), 0o600)
+
const server = http.createServer((req, res) => {
wire.push(req.headers)
- if (wire.length === 1) { req.socket.destroy(); return }
+
+ if (wire.length === 1) { req.socket.destroy();
+
+ return }
+
res.end(Buffer.from([0, 255, 1, 2, 128]))
})
+
await new Promise<void>(resolve => server.listen(0, '127.0.0.1', resolve))
const baseUrl = `http://127.0.0.1:${(server.address() as net.AddressInfo).port}`
const gatewayEndpoint = { profile_id: home, instance_id: 'owner', authority_epoch: 1, runtime_protocol: 1, api_origin: baseUrl, capabilities: ['session-authority-v1'], supervisor: 'none' }
+
const finish = async (res: http.IncomingMessage) => {
const chunks: Buffer[] = []
+
for await (const chunk of res) { chunks.push(Buffer.from(chunk)) }
+
return Buffer.concat(chunks)
}
+
try {
const bytes = await downloadViaTokenToFile(baseUrl + '/api/fs/download', '', {}, finish, { gatewayDescriptor: { baseUrl, gatewayEndpoint } })
expect(bytes).toEqual(Buffer.from([0, 255, 1, 2, 128]))
diff --git a/apps/desktop/electron/local-gateway.test.ts b/apps/desktop/electron/local-gateway.test.ts
index d2082fc2737..5d219fde21b 100644
--- a/apps/desktop/electron/local-gateway.test.ts
+++ b/apps/desktop/electron/local-gateway.test.ts
@@ -76,14 +76,17 @@ test('a dial against a replaced local gateway forgets the cached endpoint once a
const endpoints = [{ instance_id: 'dead' }, { instance_id: 'alive' }]
const forgotten: string[] = []
let ensures = 0
+
const result = await redialLocalGateway({
ensure: async () => endpoints[Math.min(ensures++, 1)],
forget: async () => { forgotten.push('primary') },
use: async endpoint => {
if (endpoint.instance_id === 'dead') {throw new Error('Gateway ticket bootstrap failed')}
+
return `ticket-for-${endpoint.instance_id}`
}
})
+
expect(result).toBe('ticket-for-alive')
expect(forgotten).toEqual(['primary'])
expect(ensures).toBe(2)
@@ -94,7 +97,9 @@ test('a dial that keeps failing after one re-ensure surfaces the error instead o
let ensures = 0
let forgets = 0
await expect(redialLocalGateway({
- ensure: async () => { ensures++; return { instance_id: 'still-dead' } },
+ ensure: async () => { ensures++;
+
+ return { instance_id: 'still-dead' } },
forget: async () => { forgets++ },
use: async () => { throw new Error('Invalid gateway ticket response') }
})).rejects.toThrow('Invalid gateway ticket response')
diff --git a/apps/desktop/src/api/canonical-protocol.test.ts b/apps/desktop/src/api/canonical-protocol.test.ts
index ff6be830fbc..fa97404ae2c 100644
--- a/apps/desktop/src/api/canonical-protocol.test.ts
+++ b/apps/desktop/src/api/canonical-protocol.test.ts
@@ -88,8 +88,10 @@ test('acknowledging a turn lost across a restart presents the unknown row\'s own
expect(protocol.prepare('prompt.resolve_unknown', { session_id: 's', admission_id: 'lost' }))
.toEqual({ session_id: 's', admission_id: 'lost', execution_generation: 4 })
expect(() => protocol.prepare('prompt.resolve_unknown', { session_id: 's', admission_id: 'next' })).toThrow('unknown')
+
const receipt = protocol.result('prompt.resolve_unknown', { session_id: 's', admission_id: 'lost', execution_generation: 4 },
{ admission_id: 'lost', ref: { session_id: 's', profile_id: '/tmp/profile' }, status: 'terminal', outcome: 'interrupted' })
+
expect(receipt).toMatchObject({ admission_id: 'lost', session_id: 's', status: 'terminal' })
protocol.event({ type: 'session.info', session_id: 's', payload: { pending: [{ admission_id: 'next', status: 'started', execution_generation: 10, text: 'NEXT' }], execution_generation: 10 } })
expect(() => protocol.prepare('prompt.resolve_unknown', { session_id: 's', admission_id: 'lost' })).toThrow('unknown')
diff --git a/apps/desktop/src/api/canonical-protocol.ts b/apps/desktop/src/api/canonical-protocol.ts
index 804f61cd0c4..916a8a969bf 100644
--- a/apps/desktop/src/api/canonical-protocol.ts
+++ b/apps/desktop/src/api/canonical-protocol.ts
@@ -15,6 +15,7 @@ export function slashMutation(command: string): { operation: string; payload: Re
return flags.length ? null : { operation: 'model', payload: { model } }
}
+
const field = ({ branch: 'title', compress: 'focus' } as Record<string, string>)[name]
if (!field) { return null }
@@ -24,7 +25,9 @@ export function slashMutation(command: string): { operation: string; payload: Re
function mutationSummary(operation: string, value: Record<string, unknown>): string {
if (operation === 'model') { return `model: ${value.model}${value.provider ? ` (${value.provider})` : ''}` }
+
if (operation === 'branch') { return `branch: ${value.branched_session_id}` }
+
if (operation === 'compress') { return `compress: ${value.target_session_id ?? value.session_id}` }
return `${operation}: ok`
@@ -145,7 +148,9 @@ export class CanonicalDesktopProtocol {
if (Array.isArray(payload.pending)) {
payload.pending_submissions = payload.pending.map(row => ({ ...row, user: row.text }))
+
for (const [id, lost] of this.unknownAdmissions) { if (lost.session_id === sid) { this.unknownAdmissions.delete(id) } }
+
for (const row of payload.pending) {
if (row?.status === 'unknown' && typeof row.admission_id === 'string' && typeof row.execution_generation === 'number') {
this.unknownAdmissions.set(row.admission_id, { session_id: sid, generation: row.execution_generation })
@@ -213,6 +218,7 @@ export class CanonicalDesktopProtocol {
if (value.ref?.session_id !== params.session_id || value.admission_id !== params.admission_id) {
throw new Error('Canonical admission receipt destination mismatch')
}
+
this.unknownAdmissions.delete(String(params.admission_id))
return { ...value, session_id: value.ref.session_id }
diff --git a/apps/desktop/src/api/sessions-mutations.test.ts b/apps/desktop/src/api/sessions-mutations.test.ts
index 90cf9b28e1e..c071f587a29 100644
--- a/apps/desktop/src/api/sessions-mutations.test.ts
+++ b/apps/desktop/src/api/sessions-mutations.test.ts
@@ -1,9 +1,11 @@
import { beforeEach, expect, it, vi } from 'vitest'
+import type * as ClientApi from './client'
+
vi.mock('@/lib/legacy-session-owner-backfill', () => ({ maybeBackfillLegacySessionOwners: vi.fn() }))
vi.mock('@/store/transcript-tail', () => ({ recordTranscriptTail: vi.fn() }))
vi.mock('./client', async importOriginal => ({
- ...await importOriginal<typeof import('./client')>(), hermesApi: vi.fn()
+ ...await importOriginal<typeof ClientApi>(), hermesApi: vi.fn()
}))
import { hermesApi, setApiRequestConnection, setApiRequestProfile } from './client'
import { deleteSession, renameSession, setSessionArchived, setSessionPinnedRemote, setSessionUnreadRemote } from './sessions'
@@ -17,8 +19,11 @@ it('uses owner snapshots and preserves the exact delete identity after a lost re
if (!request.method || request.method === 'GET') {
return { exists: true, runtime_revision: 12, runtime_generation: 8 } as never
}
+
writes.push(request)
+
if (lost) { lost = false; throw new Error('network disconnected after commit') }
+
return { deleted_ids: ['delete-me'], revision: 13 } as never
})
const owner = { connectionId: 'server', profile: 'work' }
@@ -39,14 +44,17 @@ it('all sidebar mutations use real counters and surface conflicts without a blin
const calls = [() => renameSession('sidebar', 'name', 'work'),
() => setSessionArchived('sidebar', true, 'work'), () => setSessionPinnedRemote('sidebar', false, 'work'),
() => setSessionUnreadRemote('sidebar', true, 'work')]
+
vi.mocked(hermesApi).mockImplementation(async request => {
if (!request.method || request.method === 'GET') {
return { exists: true, runtime_revision: 19, runtime_generation: 4 } as never
}
+
expect(request.body).toMatchObject({ expected_revision: 19, expected_generation: 4,
request_id: expect.any(String), profile: 'work' })
throw new Error('revision_conflict')
})
+
for (const invoke of calls) { await expect(invoke()).rejects.toThrow('revision_conflict') }
vi.mocked(hermesApi).mockReset().mockResolvedValue({ exists: true } as never)
await expect(renameSession('unknown-counter', 'name')).rejects.toThrow(/snapshot/)
diff --git a/apps/desktop/src/api/sessions.ts b/apps/desktop/src/api/sessions.ts
index b32f9f0db4e..6ac323f760b 100644
--- a/apps/desktop/src/api/sessions.ts
+++ b/apps/desktop/src/api/sessions.ts
@@ -1,4 +1,3 @@
-import { createSessionMutationClient, type SessionMutationSnapshot } from '../../../shared/src/session-http-mutations'
import { isMissingRestEndpoint } from '@/lib/gateway-rpc'
import { maybeBackfillLegacySessionOwners } from '@/lib/legacy-session-owner-backfill'
import { stampRowsWithOwningConnection } from '@/lib/session-owner-stamp'
@@ -11,6 +10,8 @@ import type {
SessionSearchResponse
} from '@/types/hermes'
+import { createSessionMutationClient, type SessionMutationSnapshot } from '../../../shared/src/session-http-mutations'
+
import { capabilityScoped, getApiRequestConnection, hermesApi, type ProfileScope, profileScoped } from './client'
const SESSION_LIST_REQUEST_TIMEOUT_MS = 60_000
@@ -329,14 +330,18 @@ function mutateSessionHttp<T>(id: string, method: 'PATCH' | 'DELETE', payload: R
const query = new URLSearchParams(scope.profile ? { profile: scope.profile } : {})
const suffix = query.size ? `?${query}` : ''
const key = JSON.stringify([scope, id, method, payload])
+
return runSessionMutation(key,
() => hermesApi<SessionMutationSnapshot>({ ...scope, path: `${path}/mutation-snapshot${suffix}` }),
identity => {
if (method === 'DELETE') {
const params = new URLSearchParams(query)
+
for (const [name, value] of Object.entries(identity)) { params.set(name, String(value)) }
+
return hermesApi<T>({ ...scope, path: `${path}?${params}`, method })
}
+
return hermesApi<T>({ ...scope, path, method,
body: { ...payload, ...identity, ...(scope.profile ? { profile: scope.profile } : {}) } })
})
diff --git a/apps/desktop/src/app/chat/composer/controls.tsx b/apps/desktop/src/app/chat/composer/controls.tsx
index 682274d673a..9db9bf5f1ff 100644
--- a/apps/desktop/src/app/chat/composer/controls.tsx
+++ b/apps/desktop/src/app/chat/composer/controls.tsx
@@ -79,9 +79,11 @@ export function ComposerControls({
// only when the composer is empty and a turn is running.
const showStop = busy && !hasComposerPayload
const showQueueButton = busy && busyAction !== 'stop' && busyAction !== 'queue' && hasComposerPayload
+
const sendLabel = busy
? { interrupt: c.redirect, queue: c.queueMessage, steer: c.steer, stop: c.stop }[busyAction]
: c.send
+
// The HUD is a Spotlight bar a few hundred pixels wide, so the four separate
// voice toggles fold into one menu there and leave the row to the input. A
// narrow tile hits the same wall from the other direction and folds for the
diff --git a/apps/desktop/src/app/chat/composer/index.tsx b/apps/desktop/src/app/chat/composer/index.tsx
index 9a48d7f5e0a..26ce9493d63 100644
--- a/apps/desktop/src/app/chat/composer/index.tsx
+++ b/apps/desktop/src/app/chat/composer/index.tsx
@@ -21,9 +21,9 @@ import { interceptsTypedVoiceStop } from '@/lib/voice-stop-word'
import { sessionCompacting } from '@/store/compaction'
import { browseBackward, browseForward, deriveUserHistory, isBrowsingHistory } from '@/store/composer-input-history'
import { POPOUT_WIDTH_REM } from '@/store/composer-popout'
-import { notifyError } from '@/store/notifications'
import { parkQueuedPrompts, removeQueuedPrompt, unparkQueuedPrompts } from '@/store/composer-queue'
import { $hudMode } from '@/store/hud'
+import { notifyError } from '@/store/notifications'
import { sessionBlockingPrompt } from '@/store/prompts'
import { toggleReview } from '@/store/review'
import { $gatewayState } from '@/store/session'
@@ -357,6 +357,7 @@ export function ChatBar({
})
const hasComposerPayload = hasText || attachments.length > 0
+
const canSubmit =
(busy || hasComposerPayload) &&
!(busy && isSteerableText && attachments.length === 0 && !compacting && !blockingPrompt && busyInputMode === null)
diff --git a/apps/desktop/src/app/chat/session-tile-actions.ts b/apps/desktop/src/app/chat/session-tile-actions.ts
index 2b4b79183de..1c8dcfd246b 100644
--- a/apps/desktop/src/app/chat/session-tile-actions.ts
+++ b/apps/desktop/src/app/chat/session-tile-actions.ts
@@ -432,6 +432,7 @@ export function useSessionTileActions({ requestGateway, runtimeId, scope, stored
if (mode === 'interrupt') {
moveOptimisticMessageToEnd()
}
+
triggerHaptic('submit')
return true
diff --git a/apps/desktop/src/app/contrib/hooks/use-background-sync.test.tsx b/apps/desktop/src/app/contrib/hooks/use-background-sync.test.tsx
index 55423865ee4..662f195a308 100644
--- a/apps/desktop/src/app/contrib/hooks/use-background-sync.test.tsx
+++ b/apps/desktop/src/app/contrib/hooks/use-background-sync.test.tsx
@@ -55,9 +55,11 @@ describe('useBackgroundSync profile-scoped session refresh', () => {
it('coalesces change ticks while the live status request is pending', async () => {
$changeEventsAvailable.set(true)
let release!: (value: { sessions: [] }) => void
+
const pending = new Promise<{ sessions: [] }>(resolve => {
release = resolve
})
+
const request = vi.fn(() => pending)
render('default', 'local', async () => undefined, request)
await act(async () => undefined)
diff --git a/apps/desktop/src/app/session/hooks/use-busy-input-mode.ts b/apps/desktop/src/app/session/hooks/use-busy-input-mode.ts
index f53447d0e3e..40457a9ee0b 100644
--- a/apps/desktop/src/app/session/hooks/use-busy-input-mode.ts
+++ b/apps/desktop/src/app/session/hooks/use-busy-input-mode.ts
@@ -46,6 +46,7 @@ export function useBusyInputMode({
if (configured !== null || !sessionId || gatewayState !== 'open') {
return
}
+
let cancelled = false
const ownerRoute = connectionId ? { connectionId, profile: ownerProfile, targetProfile } : ownerProfile
void requestForSessionProfile<{ value?: unknown }>(ownerRoute, requestGateway, 'config.get', {
diff --git a/apps/desktop/src/app/session/hooks/use-prompt-actions/index.ts b/apps/desktop/src/app/session/hooks/use-prompt-actions/index.ts
index c8edbb2f157..24c3aa1b705 100644
--- a/apps/desktop/src/app/session/hooks/use-prompt-actions/index.ts
+++ b/apps/desktop/src/app/session/hooks/use-prompt-actions/index.ts
@@ -634,6 +634,7 @@ export function usePromptActions({
if (!attachments.length && SLASH_COMMAND_RE.test(visibleText)) {
triggerHaptic('selection')
+
// Forward the explicit target (background queue drain, tile) — dropping
// it ran the command against whatever chat happened to be in front.
return await executeSlashCommand(visibleText, options)
diff --git a/apps/desktop/src/app/session/hooks/use-session-actions.test.tsx b/apps/desktop/src/app/session/hooks/use-session-actions.test.tsx
index 40dd746d939..dbbb51d45ea 100644
--- a/apps/desktop/src/app/session/hooks/use-session-actions.test.tsx
+++ b/apps/desktop/src/app/session/hooks/use-session-actions.test.tsx
@@ -727,10 +727,13 @@ describe('createBackendSessionForSend profile routing', () => {
$newChatRoute.set(null)
$activeGatewayProfile.set('default')
const calls: Record<string, unknown>[] = []
+
const requestGateway = vi.fn(async (method: string, params?: Record<string, unknown>) => {
if (method === 'session.create') { calls.push(params!); throw new Error('lost create ACK') }
+
return {} as never
})
+
let handle: HarnessHandle | null = null
render(<Harness onReady={value => { handle = value }} requestGateway={requestGateway} />)
await waitFor(() => expect(handle).not.toBeNull())
diff --git a/apps/desktop/src/plugins/hermes-bots/relay.test.ts b/apps/desktop/src/plugins/hermes-bots/relay.test.ts
index 3184625b173..747bb3fd4ea 100644
--- a/apps/desktop/src/plugins/hermes-bots/relay.test.ts
+++ b/apps/desktop/src/plugins/hermes-bots/relay.test.ts
@@ -515,11 +515,15 @@ describe('the drain loop wires drain → deliver → reply', () => {
it('drains every sender profile and delivers on the exact target profile', async () => {
const ops = { ...route('a'), profile: 'ops', targetProfile: 'ops' }
hostMock.profileRoutes = vi.fn(async () => [route('a'), ops, route('b')])
+
const calls = respondWith(call => {
- if (call.method === 'bot_relay.outbox.drain') return { envelopes: call.route.profile === 'ops' ? [envelope] : [] }
- if (call.method === 'bot_relay.deliver') return {status: 'settled', delivery_id: envelope.id, admission_id: 'admission', reply: 'isolated'}
+ if (call.method === 'bot_relay.outbox.drain') {return { envelopes: call.route.profile === 'ops' ? [envelope] : [] }}
+
+ if (call.method === 'bot_relay.deliver') {return {status: 'settled', delivery_id: envelope.id, admission_id: 'admission', reply: 'isolated'}}
+
return {}
})
+
const {startBotRelay, stopBotRelay} = await loadRelay()
startBotRelay()
await pushAndSettle()
@@ -531,20 +535,27 @@ describe('the drain loop wires drain → deliver → reply', () => {
it('retries the same envelope after pending or lost ACK without replying early', async () => {
let attempts = 0
let drained = false
+
const calls = respondWith(call => {
if (call.method === 'bot_relay.outbox.drain') {
- if (call.connectionId !== 'a' || drained) return { envelopes: [] }
+ if (call.connectionId !== 'a' || drained) {return { envelopes: [] }}
drained = true
+
return { envelopes: [envelope] }
}
+
if (call.method === 'bot_relay.deliver') {
attempts += 1
- if (attempts === 1) throw new Error('socket lost after commit')
+
+ if (attempts === 1) {throw new Error('socket lost after commit')}
+
return { status: attempts === 2 ? 'queued' : 'settled', delivery_id: envelope.id,
admission_id: 'exact-admission', reply: attempts === 2 ? '' : 'exact reply' }
}
+
return {}
})
+
const { startBotRelay, stopBotRelay } = await loadRelay()
startBotRelay()
await pushAndSettle()
diff --git a/apps/desktop/src/plugins/hermes-bots/relay.ts b/apps/desktop/src/plugins/hermes-bots/relay.ts
index 961e2823679..ae3b0f91040 100644
--- a/apps/desktop/src/plugins/hermes-bots/relay.ts
+++ b/apps/desktop/src/plugins/hermes-bots/relay.ts
@@ -190,6 +190,7 @@ async function relayConnections(): Promise<RelayConnection[]> {
const id = String(route?.connectionId || '')
const key = JSON.stringify(route)
+
if (id && !byConnection.has(key)) {
byConnection.set(key, route)
}
@@ -364,9 +365,11 @@ async function drainRelayOutboxes() {
const senderKey = JSON.stringify(sender.route)
const pending = pendingRelays.get(senderKey) || new Map<string, RelayEnvelope>()
pendingRelays.set(senderKey, pending)
+
for (const envelope of envelopes) {
- if (envelope.id && !pending.has(envelope.id)) pending.set(envelope.id, structuredClone(envelope))
+ if (envelope.id && !pending.has(envelope.id)) {pending.set(envelope.id, structuredClone(envelope))}
}
+
for (const envelope of pending.values()) {
if (relay.disposed) {
return
@@ -417,17 +420,23 @@ async function drainRelayOutboxes() {
if (res.delivery_id !== envelopeId || !res.admission_id) {
noteBotAttention(attentionKey, 'Delivery identity unavailable; retained for recovery')
+
continue
}
+
if (res.status !== 'settled' && res.status !== 'failed') {
- if (res.status === 'ambiguous') noteBotAttention(attentionKey, 'unknown_execution')
+ if (res.status === 'ambiguous') {noteBotAttention(attentionKey, 'unknown_execution')}
+
continue
}
+
if (res.status === 'failed') {
noteBotAttention(attentionKey, res.reason || res.error || 'delivery failed')
await postReply({ error: res.error || res.reply || 'delivery failed', reason: res.reason })
+
continue
}
+
clearBotAttention(attentionKey)
await postReply({
reply: String(res?.reply || '')
@@ -440,8 +449,9 @@ async function drainRelayOutboxes() {
// classified codes beat free-text re-parsing.
const reason = String(error?.data?.reason || '').trim()
noteBotAttention(attentionKey, reason || error?.message || error)
+
// A transport exception can follow a committed admission; never settle it as failure.
- if (!reason || reason === 'runtime_unavailable') continue
+ if (!reason || reason === 'runtime_unavailable') {continue}
await postReply({
error: String(error?.message || error || 'delivery failed'),
...(reason
diff --git a/apps/desktop/src/sdk/index.ts b/apps/desktop/src/sdk/index.ts
index fe7f250d52e..486c4c65508 100644
--- a/apps/desktop/src/sdk/index.ts
+++ b/apps/desktop/src/sdk/index.ts
@@ -21,9 +21,10 @@
import { atom, computed, type ReadableAtom } from 'nanostores'
import type { ReactNode } from 'react'
-import { createSessionMutationClient, type SessionMutationSnapshot } from '../../../shared/src/session-http-mutations'
import { capabilityScoped, getApiRequestConnection } from '@/api/client'
+import { createSessionMutationClient, type SessionMutationSnapshot } from '../../../shared/src/session-http-mutations'
+
const mutatePersistedVisibility = createSessionMutationClient()
import { PRIMARY_SESSION_VIEW } from '@/app/chat/session-view'
import { openSession, type OpenSessionIntent } from '@/app/open-session'
@@ -1397,6 +1398,7 @@ export const host = {
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)}` }),
diff --git a/tests/gateway/fixtures/authority_stream_peer.py b/tests/gateway/fixtures/authority_stream_peer.py
index c96d7278d5e..20732d26843 100644
--- a/tests/gateway/fixtures/authority_stream_peer.py
+++ b/tests/gateway/fixtures/authority_stream_peer.py
@@ -1,5 +1,6 @@
"""Real SSE execution and authenticated authority observers in a disposable process."""
import asyncio
+import contextlib
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
import json
import os
@@ -90,7 +91,11 @@ class Observer:
async def close(self):
await self.ws.close()
- await self.task
+ # A deliberately blocked observer may never receive the server's close frame before the
+ # handshake deadline on a loaded runner; teardown is not the invariant under test.
+ import websockets.exceptions
+ with contextlib.suppress(websockets.exceptions.ConnectionClosed):
+ await self.task
async def probe(peer, target):
diff --git a/tests/gateway/test_native_role_reauthorization.py b/tests/gateway/test_native_role_reauthorization.py
index b422d86c834..796c99490d3 100644
--- a/tests/gateway/test_native_role_reauthorization.py
+++ b/tests/gateway/test_native_role_reauthorization.py
@@ -4,6 +4,11 @@ from pathlib import Path
import subprocess
import sys
+import pytest
+
+# The probe drives the real Discord adapter (a `messaging` extra); CI's base venv has no discord.py.
+pytest.importorskip("discord")
+
def _probe(tmp_path, mode):
tmp_path.mkdir(exist_ok=True)
diff --git a/tests/hermes_cli/test_gateway_chat_failures.py b/tests/hermes_cli/test_gateway_chat_failures.py
index 1f109c4bd1a..df74da868a5 100644
--- a/tests/hermes_cli/test_gateway_chat_failures.py
+++ b/tests/hermes_cli/test_gateway_chat_failures.py
@@ -8,12 +8,15 @@ import pytest
def test_direct_query_alias_survives_noninteractive_launch(monkeypatch):
from hermes_cli import gateway_chat
+ from hermes_cli import gateway_chat_startup
seen = []
async def run(args):
seen.append(args.q)
return 0
+ # The alias contract is independent of whether this machine has a provider configured.
+ monkeypatch.setattr(gateway_chat_startup, "ensure_launch_provider", lambda args: True)
monkeypatch.setattr(gateway_chat, "run_gateway_chat", run)
assert gateway_chat.launch_from_kwargs({"q": "literal"}) == 0
assert seen == ["literal"]