Show the cause of session-list failures and survive code-less IPC errors (0.2.1)

- Detect an older session.list contract also by message when the
  JSON-RPC code was lost across the desktop IPC bridge
- Show a short technical cause under the load error and log it
  with a [hermes-canopy] prefix

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Mikei386andClaude Opus 5.5 committed 2026-11-20 19:37:30 +01:00
1 parent e0a147e2e8
commit 551913254c
3 files changed
+47 -7

No files matched your search

+19 -1
View File
@@ -7,7 +7,7 @@ const hooks = registerHooks({resolve(specifier, context, next) {
if (specifier === 'react/jsx-runtime') return {url: 'data:text/javascript,export const jsx=(type,props)=>({type,props}),jsxs=(type,props)=>({type,props})', shortCircuit:true}
return next(specifier, context)
}})
const {default: plugin, routesFor, loadBot, openExisting, openBotChat, botChatOf, avatarSource, CanopyError} = await import('../plugin.js')
const {default: plugin, routesFor, loadBot, openExisting, openBotChat, botChatOf, avatarSource, CanopyError, unsupportedList, errorDetail} = await import('../plugin.js')
hooks.deregister()
const route = {connectionId:'g', profile:'work',targetProfile:'work',mode:'remote'}
const state = name => ({get:()=>name})
@@ -170,3 +170,21 @@ test('Bot Chat open refuses a disconnected gateway or a vanished route', async (
await assert.rejects(openBotChat(moved.host,'g',route,route),/Profilroute/)
assert.equal(offline.calls.open.length+moved.calls.open.length,0)
})
test('fallback detection survives errors that lost their JSON-RPC code across IPC', async () => {
assert.equal(unsupportedList({code:-32601}),true)
assert.equal(unsupportedList({code:4001,data:{reason:'invalid_params'}}),true)
assert.equal(unsupportedList({code:4001,data:{reason:'permission_denied'}}),false)
assert.equal(unsupportedList({code:4003,message:'invalid_params'}),false)
assert.equal(unsupportedList(Error("Error invoking remote method 'hermes:gateway': Error: invalid_params")),true)
assert.equal(unsupportedList(Error('Method not found: session.list')),true)
assert.equal(unsupportedList(Error('permission_denied')),false)
const empty=async()=>({sessions:[],total:0,limit:500,offset:0,errors:[]})
const res=await loadBot({requestProfile:async()=>{throw Error('Error: invalid_params')},listPersistedSessions:empty},route)
assert.equal(res.sessions.length,0)
})
test('error detail names the technical cause compactly', () => {
assert.equal(errorDetail({message:' request timed out\nafter 20s ',code:4001,data:{reason:'invalid_params'}}),
'request timed out after 20s (4001) [invalid_params]')
assert.equal(errorDetail({name:'AbortError',message:'x'}),'')
assert.equal(errorDetail(Error('x'.repeat(300))).length,178)
})