Show each bot's Bot Chat in Canopy and harden the session tree (0.2.0)
- Bot Chat as the first row under each bot, read from the roster projection (profiles.list include_sessions) and opened in the bots workspace like the built-in Bots pane; never created by Canopy - Sort conversations by last activity, cap the stored-cursor scan at 100 pages, typed CanopyError for user-facing messages - jsxs for static children (no React key warnings), useRef for the lock - package.json with npm test, .gitignore, tests and browser fixture Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
a8b2459dbc
commit
e0a147e2e8
6 files changed
+225
-66
No files matched your search
@@ -6,10 +6,11 @@ if (!deps || !out) throw Error('Usage: node scripts/browser-fixture.mjs DEPENDEN
|
||||
const react = await readFile(join(deps,'react/umd/react.production.min.js'),'utf8')
|
||||
const dom = await readFile(join(deps,'react-dom/umd/react-dom.production.min.js'),'utf8')
|
||||
const src = (await readFile(new URL('../plugin.js',import.meta.url),'utf8'))
|
||||
.replace(/^import .+\n/gm,'').replace(/^export (?=(?:async )?function)/gm,'').replace(/^export default /m,'const plugin = ')
|
||||
.replace(/^import .+\n/gm,'').replace(/^export (?=(?:async )?function|class)/gm,'').replace(/^export default /m,'const plugin = ')
|
||||
const fixture = `
|
||||
const {useEffect,useId,useState}=React;
|
||||
const {useEffect,useId,useRef,useState}=React;
|
||||
const h=(type,props,key)=>React.createElement(type,{...props,key});
|
||||
const jsxs=h;
|
||||
const owner={connectionId:'fixture',profile:'ops',targetProfile:'ops',mode:'remote'};
|
||||
const atom=v=>({get:()=>v});
|
||||
const actions=[], storage=new Map();
|
||||
@@ -18,13 +19,15 @@ 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]),
|
||||
profileRoutes:async()=>[owner],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');
|
||||
return {sessions:fixtureSessions,total:600,limit:500,offset:0};
|
||||
},
|
||||
requestProfile:async(_route,method,p)=>{
|
||||
if(method==='profiles.list')return {profiles:[{name:'ops',display_name:'Athena',has_avatar:true}]};
|
||||
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}}]};
|
||||
if(method==='profiles.get_asset')return {found:true,data:avatar};
|
||||
if(method!=='session.list')throw Error('Unexpected RPC');
|
||||
if(useLegacy)return {sessions:[]};
|
||||
@@ -69,6 +72,12 @@ 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);
|
||||
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');
|
||||
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;});
|
||||
|
||||
Reference in new issue
Block a user