fix: wait for native workspace projection before opening a conversation
Core regression / Python core, intervention UI and release configuration (push) Successful in 4m20s
Core regression / JavaScript syntax (push) Successful in 10s
Core regression / Python core, intervention UI and release configuration (pull_request) Successful in 3m42s
Core regression / JavaScript syntax (pull_request) Successful in 7s

This commit is contained in:
阿白叔 committed 2026-11-16 11:00:46 +08:00
1 parent d0c07f4f74
commit 6cd6520bae
3 files changed
+13 -3

No files matched your search

+8
View File
@@ -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;