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

+24 -3
View File
@@ -9,9 +9,18 @@ const src = (await readFile(new URL('../plugin.js',import.meta.url),'utf8'))
.replace(/^import .+\n/gm,'').replace(/^export (?=(?:async )?function|class)/gm,'').replace(/^export default /m,'const plugin = ')
const fixture = `
const {useEffect,useId,useRef,useState}=React;
const sdk={
ContextMenu:({children})=>React.createElement(React.Fragment,null,...children),
ContextMenuTrigger:({children})=>children,
ContextMenuContent:({children})=>React.createElement('menu',{'data-menu':''},...children),
ContextMenuItem:({children,onSelect,disabled})=>React.createElement('button',{type:'button','data-menuitem':'',disabled,onClick:onSelect},children),
ContextMenuSeparator:()=>React.createElement('hr'),
};
const newChats=[];
const h=(type,props,key)=>React.createElement(type,{...props,key});
const jsxs=h;
const owner={connectionId:'fixture',profile:'ops',targetProfile:'ops',mode:'remote'};
const other={connectionId:'fixture',profile:'aaa-zeta',targetProfile:'aaa-zeta',mode:'remote'};
const atom=v=>({get:()=>v});
const actions=[], storage=new Map();
const useLegacy=${JSON.stringify(mode === 'legacy')};
@@ -19,7 +28,7 @@ const avatar='data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAAB
const fixtureSessions=Array.from({length:27},(_,i)=>({id:String(i+1),session_id:String(i+1),title:'Chat '+(i+1),source:'local',profile:'ops',started_at:1760000000}));
const host={state:{connectionId:atom('fixture'),profile:atom('ops'),gateway:atom('open'),
focusedStoredSessionId:atom('1'),focusedSessionOwner:atom(owner)},
profileRoutes:async()=>[owner],openSession:async(id,o)=>actions.push([id,o.route,o.workspaceMode]),
profileRoutes:async()=>[owner,other],newChat:r=>newChats.push(r),openSession:async(id,o)=>actions.push([id,o.route,o.workspaceMode]),
focusOpenWorkspaceSession:()=>null,
listPersistedSessions:async(route,opts)=>{
if(!useLegacy||route!==owner||opts.profile!=='ops')throw Error('Unexpected fallback');
@@ -27,7 +36,8 @@ const host={state:{connectionId:atom('fixture'),profile:atom('ops'),gateway:atom
},
requestProfile:async(_route,method,p)=>{
if(method==='profiles.list')return {profiles:[{name:'ops',display_name:'Athena',has_avatar:true,
canonical_session:{id:'bot-chat',resolved_id:'bot-chat-tip',preview:'Hallo',last_active:1760000100,message_count:2}}]};
canonical_session:{id:'bot-chat',resolved_id:'bot-chat-tip',preview:'Hallo',last_active:1760000100,message_count:2}},
{name:'aaa-zeta',display_name:'Zeta',has_avatar:false,last_session:{id:'z',last_active:1760009999}}]};
if(method==='profiles.get_asset')return {found:true,data:avatar};
if(method!=='session.list')throw Error('Unexpected RPC');
if(useLegacy)return {sessions:[]};
@@ -72,12 +82,23 @@ window.addEventListener('error',e=>{document.body.dataset.renderError=e.message;
first.click();
await wait(()=>actions.length);
check(actions.length===1&&actions[0][0]==='1'&&actions[0][1]===owner,'Routed existing session');
const rows=[...document.querySelectorAll('[aria-controls] + div button')].map(b=>b.textContent);
const rows=[...document.getElementById(bot.getAttribute('aria-controls')).querySelectorAll('button')].map(b=>b.textContent);
check(rows[0]?.startsWith('★ Bot Chat')&&rows.filter(t=>t.startsWith('★')).length===1,'Bot Chat is the first row');
await wait(()=>!button('Hallo').disabled);
button('Hallo').click();
await wait(()=>actions.length===2);
check(actions[1][0]==='bot-chat-tip'&&actions[1][1]===owner&&actions[1][2]==='bots','Opened Bot Chat in bots workspace');
const order=()=>[...document.querySelectorAll('button[aria-controls]')].map(b=>b.title).join(',');
check(order()==='Athena,Zeta','A-Z order by display name: '+order());
button('Zuletzt aktiv').click();
await wait(()=>order()==='Zeta,Athena');
check(storage.get('bot-order-v1')==='recent','Persisted order');
button('A–Z').click();
await wait(()=>order()==='Athena,Zeta');
const menuNew=[...document.querySelectorAll('[data-menuitem]')].find(b=>b.textContent==='Neue Unterhaltung');
menuNew.click();
await wait(()=>newChats.length===1);
check(newChats[0]===owner,'New conversation on the bot route');
check(!document.body.dataset.renderError,'Render error');
document.body.dataset.test='pass';
})().catch(e=>{document.body.dataset.test='fail';document.body.dataset.reason=e.message;});