Handle older session-list contracts in Canopy
This commit is contained in:
1 parent
b24611adb7
commit
a8b2459dbc
4 files changed
+86
-16
No files matched your search
@@ -1,7 +1,7 @@
|
||||
// Generate an offline browser fixture. Run with the directory containing the pinned React UMD files.
|
||||
import {readFile,writeFile} from 'node:fs/promises'
|
||||
import {join} from 'node:path'
|
||||
const [deps,out] = process.argv.slice(2)
|
||||
const [deps,out,mode] = process.argv.slice(2)
|
||||
if (!deps || !out) throw Error('Usage: node scripts/browser-fixture.mjs DEPENDENCY_DIR OUTPUT.html')
|
||||
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')
|
||||
@@ -13,17 +13,23 @@ const h=(type,props,key)=>React.createElement(type,{...props,key});
|
||||
const owner={connectionId:'fixture',profile:'ops',targetProfile:'ops',mode:'remote'};
|
||||
const atom=v=>({get:()=>v});
|
||||
const actions=[], storage=new Map();
|
||||
const useLegacy=${JSON.stringify(mode === 'legacy')};
|
||||
const avatar='data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7';
|
||||
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]),
|
||||
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.get_asset')return {found:true,data:avatar};
|
||||
if(method!=='session.list')throw Error('Unexpected RPC');
|
||||
if(useLegacy)return {sessions:[]};
|
||||
if(p.scope==='live')return {scope:'live',sessions:[]};
|
||||
const sessions=Array.from({length:27},(_,i)=>({id:String(i+1),session_id:String(i+1),title:'Chat '+(i+1),source:'local',started_at:1760000000}));
|
||||
return {scope:'stored',next_cursor:null,sessions};
|
||||
return {scope:'stored',next_cursor:null,sessions:fixtureSessions};
|
||||
}};
|
||||
const data=new Map();
|
||||
const useQueryClient=()=>client;
|
||||
@@ -53,6 +59,7 @@ window.addEventListener('error',e=>{document.body.dataset.renderError=e.message;
|
||||
check(bot.getAttribute('aria-expanded')==='false','Initial collapsed');
|
||||
bot.click();
|
||||
const first=await wait(()=>button('Chat 1'));
|
||||
if(useLegacy)check(document.body.textContent.includes('begrenzt die Kompatibilitätsliste'),'Missing fallback limit warning');
|
||||
check(bot.getAttribute('aria-expanded')==='true'&&actions.length===0,'Toggle opened a chat');
|
||||
check(first.getAttribute('aria-current')==='true','Active marker');
|
||||
check(storage.get('expanded-v1')?.length===1,'Persistent expansion');
|
||||
|
||||
Reference in new issue
Block a user