Bot context menu, live new conversations and bot sorting (0.3.0)

- Right-click on a bot: new conversation (host.newChat on the bot
  route), open Bot Chat, expand/collapse, refresh
- The focused conversation of a bot shows immediately as "Aktuelle
  Unterhaltung" and the list is re-read until Hermes has stored it;
  sessions.changed also refreshes Bot Chat and activity data
- Sort bots A–Z by display name or by latest activity, persisted

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Mikei386andClaude Opus 5.5 committed 2026-11-20 20:02:55 +01:00
1 parent a0f6c8bb1d
commit 352df21ff0
5 files changed
+149 -21

No files matched your search

+20 -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, unsupportedList, errorDetail} = await import('../plugin.js')
const {default: plugin, routesFor, loadBot, openExisting, openBotChat, botChatOf, avatarSource, CanopyError, unsupportedList, errorDetail, sortBots, newConversation} = await import('../plugin.js')
hooks.deregister()
const route = {connectionId:'g', profile:'work',targetProfile:'work',mode:'remote'}
const state = name => ({get:()=>name})
@@ -207,3 +207,22 @@ test('empty sessions and cron runs are hidden like in the native sidebar', async
{id:'unknown',source:'gui',profile:'work'}],total:6,limit:500,offset:0,errors:[]})},route)
assert.deepEqual(res.sessions.map(s=>s.id).sort(),['chat','live','unknown'])
})
test('bots sort by display name or by latest activity', () => {
const a={connectionId:'g',profile:'default',targetProfile:'default',mode:'remote'}
const b={...a,profile:'athena-deck',targetProfile:'athena-deck'}
const c={...a,profile:'zulu',targetProfile:'zulu'}
const meta={default:{name:'Athena',lastActive:10},'athena-deck':{name:'Athena Deck',lastActive:30},zulu:{name:'Bravo'}}
const of=r=>meta[r.targetProfile]
assert.deepEqual(sortBots([c,b,a],'name',of).map(r=>r.profile),['default','athena-deck','zulu'])
assert.deepEqual(sortBots([a,b,c],'recent',of).map(r=>r.profile),['athena-deck','default','zulu'])
assert.deepEqual(sortBots([a,b,c],'recent',of,r=>r.profile==='zulu'?99:0).map(r=>r.profile),['zulu','athena-deck','default'])
})
test('a new conversation starts on the bot route after checking it is still current', async () => {
const calls=[]
const host={state:{connectionId:state('g'),gateway:state('open')},profileRoutes:async()=>[route],newChat:r=>calls.push(r)}
await newConversation(host,'g',route)
assert.deepEqual(calls,[route])
await assert.rejects(newConversation({...host,newChat:undefined},'g',route),CanopyError)
await assert.rejects(newConversation({...host,profileRoutes:async()=>[]},'g',route),/Profil/)
assert.equal(calls.length,1)
})