Skip to content

The agent that grows with you

fix(desktop): an older headless hermes serve counts as missing the snapshot route

Tekniume34a5ac3e43e
diff --git a/apps/desktop/src/api/sessions-mutations.test.ts b/apps/desktop/src/api/sessions-mutations.test.ts
index f70f162823f..ef687e71d0e 100644
--- a/apps/desktop/src/api/sessions-mutations.test.ts
+++ b/apps/desktop/src/api/sessions-mutations.test.ts
@@ -132,3 +132,36 @@ it('sidebar edits fall back to the base write only when the backend lacks the fe
expect(writes).toEqual([])
}
})
+
+// N21: an older headless `hermes serve` (SSH remotes) answers an unmatched GET with its own fixed
+// catch-all body, formatted by Electron's httpStatusError. That is the same route verdict.
+it('sidebar edits on an older headless serve fall back to the base write', async () => {
+ const headless = '404: {"error":"Headless backend (hermes serve): web UI disabled \u2014 use `hermes dashboard` for the browser UI."}'
+ const writes: Array<{ method?: string; body?: unknown }> = []
+ vi.mocked(hermesApi).mockReset().mockImplementation(async request => {
+ if (!request.method || request.method === 'GET') { throw new Error(headless) }
+ writes.push(request as never)
+
+ return { ok: true } as never
+ })
+
+ await renameSession('ssh', 'name', 'work')
+ await setSessionArchived('ssh', true, 'work')
+ await setSessionPinnedRemote('ssh', true, 'work')
+ await setSessionUnreadRemote('ssh', false, 'work')
+ await deleteSession('ssh', { connectionId: 'server', profile: 'work' })
+ expect(writes.map(write => [write.method, write.body])).toEqual([
+ ['PATCH', { title: 'name', profile: 'work' }], ['PATCH', { archived: true, profile: 'work' }],
+ ['PATCH', { pinned: true, profile: 'work' }], ['PATCH', { unread: false, profile: 'work' }], ['DELETE', undefined]])
+
+ // FastAPI's bare 404 is no route verdict: it keeps the fenced path and writes nothing.
+ writes.length = 0
+ vi.mocked(hermesApi).mockReset().mockImplementation(async request => {
+ if (!request.method || request.method === 'GET') { throw new Error('404: {"detail":"Not Found"}') }
+ writes.push(request as never)
+
+ return { ok: true } as never
+ })
+ await expect(renameSession('ssh', 'name', 'work')).rejects.toThrow('Not Found')
+ expect(writes).toEqual([])
+})
diff --git a/apps/desktop/src/lib/gateway-rpc.ts b/apps/desktop/src/lib/gateway-rpc.ts
index c30f5a0458b..e9628b9bcb6 100644
--- a/apps/desktop/src/lib/gateway-rpc.ts
+++ b/apps/desktop/src/lib/gateway-rpc.ts
@@ -38,13 +38,20 @@ export function isMissingRestEndpoint(error: unknown): boolean {
)
}
-/** Narrow twin of isMissingRestEndpoint for routes with path params: only the
- * backend's catch-all verdict (or the Electron HTML guard) proves the ROUTE is
- * absent; a handler's own 404 (unknown session/profile) never matches. */
+/** Narrow twin of isMissingRestEndpoint for routes with path params: only a
+ * backend catch-all verdict (or the Electron HTML guard) proves the ROUTE is
+ * absent; a handler's own 404 (unknown session/profile) never matches. Two
+ * catch-alls exist: `hermes dashboard` answers unmatched `/api/*` with
+ * "No such API endpoint", and headless `hermes serve` (what Desktop's SSH
+ * remotes launch) answers every unmatched GET with its fixed "web UI disabled"
+ * body. A bare `{"detail":"Not Found"}` is not a route verdict. */
export function isUnroutedRestPath(error: unknown): boolean {
const message = error instanceof Error ? error.message : String(error)
- return /no such api endpoint|endpoint is likely missing/i.test(message)
+ return (
+ /no such api endpoint|endpoint is likely missing/i.test(message) ||
+ /(?:^\s*|error:\s*)404:.*headless backend \(hermes serve\): web ui disabled/i.test(message)
+ )
}
/** True when the backend refused a request because it owns the profile and the