fix: wait for official workspace synchronization before opening assistant sessions #28
No files matched your search
@@ -154,5 +154,6 @@ jobs:
|
||||
- name: Intervention panel and bounded model views (no model or network)
|
||||
run: |
|
||||
node tools/verify_dsh_incident_panel.mjs
|
||||
node tools/verify_dsh_dock_startup.mjs
|
||||
node tools/verify_dsh_model_results.mjs
|
||||
node tools/verify_dsh_diagnosis_cancel.mjs
|
||||
@@ -295,7 +295,7 @@ window.__ModuleLoader__.load({id:'@dx/dsh-task',factory:require=>{
|
||||
tab==='tickets'?h(TicketsPanel,{operations,perform,pending:pending||operations.busy}):h(UsagePanel,{runtime,control,pending})),
|
||||
tab!=='overview'&&h('p',{'data-testid':'dx-operations-notice',role:'status',style:{fontSize:12,color:secondary,lineHeight:1.8,whiteSpace:'pre-wrap'}},operations.activity?.message||notice||''));
|
||||
}
|
||||
return{inject:['slots','sidebarRightTabs','sidebarRight','uiSession','uiWorkspace'],apply(ctx){
|
||||
return{inject:['slots','sidebarRightTabs','sidebarRight','uiSession','uiWorkspace','workspaces'],apply(ctx){
|
||||
ctx.effect(()=>{
|
||||
let live=true,opened='';
|
||||
const check=()=>fetch('/dx/context').then(r=>r.json()).then(data=>{
|
||||
@@ -318,10 +318,11 @@ window.__ModuleLoader__.load({id:'@dx/dsh-task',factory:require=>{
|
||||
if(sessionId){
|
||||
if(openedSession===sessionId)return;
|
||||
try{ctx.sidebarRight.openTab('dx-task');if(ctx.sidebarRight.isExpanded()){openedSession=sessionId;return;}}catch{}
|
||||
}else if(!connecting&&!adopted){
|
||||
}else if(!connecting&&!adopted&&ctx.workspaces.list.getSnapshot().phase==='ready'){
|
||||
connecting=true;
|
||||
fetch('/dx/workspace').then(r=>{if(!r.ok&&r.ok!==undefined)throw Error();return r.json();}).then(value=>{
|
||||
if(live&&!current.getSnapshot()&&typeof value.workspace_id==='string'){
|
||||
if(live&&!current.getSnapshot()&&typeof value.workspace_id==='string'&&
|
||||
ctx.workspaces.list.getSnapshot().items.some(row=>row.workspaceId===value.workspace_id)){
|
||||
adopted=true;return ctx.uiWorkspace.openWorkspace(value.workspace_id);
|
||||
}
|
||||
}).catch(()=>{adopted=false;}).finally(()=>{connecting=false;if(live)queue();});
|
||||
|
||||
@@ -4,6 +4,7 @@ import {readFile} from 'node:fs/promises';
|
||||
import vm from 'node:vm';
|
||||
|
||||
let plugin,session,subscriber,expanded=false,openedWorkspace=0,openedTabs=0;
|
||||
let workspaceSnapshot={phase:'pending',items:[]};
|
||||
const effects=[];
|
||||
const sandbox={window:{__ModuleLoader__:{load:value=>{plugin=value;}}},
|
||||
setTimeout,clearTimeout,setInterval,clearInterval,
|
||||
@@ -12,6 +13,7 @@ const sandbox={window:{__ModuleLoader__:{load:value=>{plugin=value;}}},
|
||||
vm.runInNewContext(await readFile(new URL('../integration/dsh/task-plugin/client.js',import.meta.url),'utf8'),sandbox);
|
||||
const exported=plugin.factory(name=>name==='react'?{createElement:()=>null}:{});
|
||||
const ctx={slots:{inject:(_name,fn)=>fn(),register:()=>()=>{}},
|
||||
workspaces:{list:{getSnapshot:()=>workspaceSnapshot}},
|
||||
effect:(fn)=>{effects.push(fn());},sidebarRightTabs:{register:()=>{}},
|
||||
sidebarRight:{mounted:{getSnapshot:()=>session,subscribe:fn=>{subscriber=fn;return()=>{};}},
|
||||
openTab:()=>{if(!session)throw Error('Session seat absent');openedTabs++;expanded=true;},isExpanded:()=>expanded},
|
||||
@@ -22,6 +24,12 @@ const ctx={slots:{inject:(_name,fn)=>fn(),register:()=>()=>{}},
|
||||
try{
|
||||
exported.apply(ctx);
|
||||
await new Promise(r=>setTimeout(r,150));
|
||||
assert.equal(openedWorkspace,0,'native workspace adoption must wait for the official client workspace snapshot');
|
||||
workspaceSnapshot={phase:'ready',items:[]};
|
||||
await new Promise(r=>setTimeout(r,150));
|
||||
assert.equal(openedWorkspace,0,'a ready snapshot must actually contain the native workspace before opening');
|
||||
workspaceSnapshot={phase:'ready',items:[{workspaceId:'owned-workspace'}]};
|
||||
await new Promise(r=>setTimeout(r,150));
|
||||
assert.equal(openedWorkspace,1,'fresh page must adopt the owned native workspace once');
|
||||
assert.equal(expanded,true,'right dock must open after delayed Session adoption');
|
||||
const previous=openedTabs;
|
||||
|
||||
Reference in new issue
Block a user