fix(host): 启用时给每席会话写标题;记录侧栏不列会话的实测结论
This commit is contained in:
parent
41c8021fab
commit
1171eb0709
|
|
@ -67,6 +67,15 @@ HTTP 处理器端到端;systemPrompt 只注入十席;Web 纯视图模型(
|
|||
|
||||
仍未验证(不能宣称完成):dsh-go 手机 App 原生面板(第 4 步,需真实客户端/设备);运行中改模型即时生效;双真实项目联调;第 5 步打包发布。
|
||||
|
||||
## 实测发现:插件建的会话不进“左侧工作区会话列表”(待修)
|
||||
|
||||
用隔离测试 DSH 实测(1440 宽、整页重载、并已对每席 rename 标题):
|
||||
|
||||
- 会话确实创建并注册:`DSH_HOME/sessions/<默认工作区路径哈希>/<会话ID>/session.v4.jsonl.zstd`;`storages/workspace.json` 的 `sessionIds` 里十席齐全。
|
||||
- 但左侧“工作区 / 默认工作区”列表**不显示**这些会话(DOM 中带 `data-session-id` 的元素数 = 0),给会话写标题也无济于事。
|
||||
- 结论:DSH 侧栏的工作区会话列表并不直接读 `workspace.sessionIds`,插件用 `sessionController.create` 建的 root 会话进不了该列表——这是第一版必须补的接入点(需进一步核验侧栏会话列表的真实数据源/注册接口),或需要会话具备让列表收录的“活动/投影”。
|
||||
- 另:真实对话内容还需模型;隔离环境无可用模型路由(gemini 不存在,deepseek-v4.1-flash 仅属于当前会话进程)。
|
||||
|
||||
## 未改动
|
||||
|
||||
未安装到任何 DSH profile,未修改用户日常 DSH、node_modules 或全局默认模型。
|
||||
|
|
|
|||
|
|
@ -0,0 +1,11 @@
|
|||
import fs from 'node:fs'
|
||||
const url = process.argv[2]
|
||||
const first = await fetch(url, { redirect: 'manual' })
|
||||
const setCookie = first.headers.getSetCookie ? first.headers.getSetCookie() : [first.headers.get('set-cookie')].filter(Boolean)
|
||||
const cookie = setCookie.map(c => c.split(';')[0]).join('; ')
|
||||
const base = new URL(url)
|
||||
const state = JSON.parse(fs.readFileSync('C:/Users/qyh15/.dsh-test-b/sansheng/state.json', 'utf8'))
|
||||
const pid = Object.keys(state.projects)[0]
|
||||
const res = await fetch(base.origin + '/api/sansheng', { method: 'POST', headers: { 'content-type': 'application/json', cookie }, body: JSON.stringify({ endpoint: 'enable', payload: { projectId: pid } }) })
|
||||
const text = await res.text()
|
||||
console.log('status', res.status, text.slice(0, 500))
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
import { spawn } from 'node:child_process'
|
||||
import { mkdtemp, writeFile } from 'node:fs/promises'
|
||||
import { tmpdir } from 'node:os'
|
||||
import { join, dirname } from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
const url = process.argv[2]
|
||||
const EDGE = 'C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe'
|
||||
const dir = dirname(fileURLToPath(import.meta.url))
|
||||
const profile = await mkdtemp(join(tmpdir(), 'ss-sidebar-'))
|
||||
const sleep = ms => new Promise(r => setTimeout(r, ms))
|
||||
let browser, ws
|
||||
const result = {}
|
||||
try {
|
||||
browser = spawn(EDGE, ['--headless=new','--disable-gpu','--no-first-run','--no-default-browser-check','--remote-debugging-port=0','--user-data-dir='+profile,'about:blank'], { stdio:['ignore','ignore','pipe'] })
|
||||
const endpoint = await new Promise((res, rej) => { let log=''; const t=setTimeout(()=>rej(Error('timeout')),20000); browser.stderr.on('data', b=>{ log+=b; const m=log.match(/DevTools listening on (.+)/); if(m){clearTimeout(t);res(m[1].trim())} }); browser.on('error',rej) })
|
||||
ws = new WebSocket(endpoint); await new Promise((r,j)=>{ws.onopen=r;ws.onerror=j})
|
||||
let n=0; const pend=new Map()
|
||||
ws.onmessage = e => { const m=JSON.parse(e.data); if(m.id){const p=pend.get(m.id);pend.delete(m.id);m.error?p.reject(Error(JSON.stringify(m.error))):p.resolve(m.result)} }
|
||||
const cdp=(method,params={},sid)=>new Promise((res,rej)=>{const id=++n;pend.set(id,{resolve:res,reject:rej});ws.send(JSON.stringify({id,method,params,...(sid?{sessionId:sid}:{})}))})
|
||||
const { targetId } = await cdp('Target.createTarget',{url:'about:blank'})
|
||||
const { sessionId } = await cdp('Target.attachToTarget',{targetId,flatten:true})
|
||||
const call=(m,p={})=>cdp(m,p,sessionId)
|
||||
await call('Page.enable'); await call('Runtime.enable')
|
||||
const ev = async expr => { const r = await call('Runtime.evaluate',{expression:expr,returnByValue:true,awaitPromise:true}); if(r.exceptionDetails) throw Error(r.exceptionDetails.exception?.description||r.exceptionDetails.text); return r.result.value }
|
||||
await call('Emulation.setDeviceMetricsOverride',{width:1440,height:900,deviceScaleFactor:1,mobile:false})
|
||||
await call('Page.navigate',{url})
|
||||
for(let i=0;i<80;i++){ if(await ev("document.readyState==='complete'")) break; await sleep(200) }
|
||||
try { await ev("(() => { const b=[...document.querySelectorAll('button')].find(x=>(x.innerText||'').trim()==='继续'); if(b)b.click(); return !!b })()") } catch {}
|
||||
await sleep(500)
|
||||
try { await call('Input.dispatchKeyEvent',{type:'keyDown',key:'Escape',code:'Escape',windowsVirtualKeyCode:27}); await call('Input.dispatchKeyEvent',{type:'keyUp',key:'Escape',code:'Escape',windowsVirtualKeyCode:27}) } catch {}
|
||||
await sleep(3000)
|
||||
result.dom = await ev(`(() => {
|
||||
const ses = [...document.querySelectorAll('[data-session-id]')]
|
||||
const bodyText = (document.body.innerText||'').replace(/\\s+/g,' ').trim()
|
||||
return {
|
||||
bodySnippet: bodyText.slice(0, 1100),
|
||||
sessionAttrCount: ses.length,
|
||||
sessionIds: ses.map(e => e.getAttribute('data-session-id')).slice(0, 20),
|
||||
hasNewSessionWord: (bodyText.match(/新会话/g)||[]).length,
|
||||
}
|
||||
})()`)
|
||||
const shot = await call('Page.captureScreenshot',{format:'png',captureBeyondViewport:false})
|
||||
await writeFile(join(dir,'live-08-sidebar.png'), Buffer.from(shot.data,'base64'))
|
||||
} catch (e) { result.fatal = String(e?.stack ?? e) } finally { try{ws?.close()}catch{}; try{browser?.kill()}catch{} }
|
||||
console.log(JSON.stringify(result, null, 2))
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 40 KiB |
|
|
@ -1,7 +1,7 @@
|
|||
// 严格会话创建/恢复:先持久化计划 ID,再查是否已存在,只创建缺失项;
|
||||
// ID 不一致立即停止后续创建并保留记录;失败保留已完成绑定,重试只补未完成项。
|
||||
import { randomUUID } from 'node:crypto'
|
||||
import { SEAT_IDS } from '../shared/roles.js'
|
||||
import { SEAT_IDS, SEATS } from '../shared/roles.js'
|
||||
|
||||
export class ProvisionError extends Error {
|
||||
constructor(code, message) { super(message); this.name = 'ProvisionError'; this.code = code }
|
||||
|
|
@ -118,6 +118,17 @@ export function createProvisioner({ store, host, now = () => Date.now() }) {
|
|||
const result = await ensureSeat(projectId, seatId)
|
||||
if (result.fatal) { fatal = true; break }
|
||||
}
|
||||
|
||||
// 给每个已绑定会话写标题(如“丞相会话”),让左侧工作区列表能收录并显示为独立对话。
|
||||
if (typeof host.sessionController.rename === 'function') {
|
||||
for (const seatId of SEAT_IDS) {
|
||||
const seat = store.get(projectId)?.seats?.[seatId]
|
||||
if (!seat || !seat.sessionId || seat.status !== 'bound') continue
|
||||
try {
|
||||
await host.sessionController.rename({ sessionId: seat.sessionId, title: `${SEATS[seatId].label}会话` })
|
||||
} catch { /* 标题失败不影响绑定;下次启用会重试 */ }
|
||||
}
|
||||
}
|
||||
await store.mutate(s => {
|
||||
const p = s.projects[projectId]
|
||||
const allBound = SEAT_IDS.every(id => p.seats[id].status === 'bound')
|
||||
|
|
|
|||
Loading…
Reference in New Issue