diff --git a/01_content/src/client/index.tsx b/01_content/src/client/index.tsx index 7ade564..3a41013 100644 --- a/01_content/src/client/index.tsx +++ b/01_content/src/client/index.tsx @@ -710,9 +710,11 @@ function WorktableSection(props: any) { const [wsFolderError, setWsFolderError] = useState(false) /** 图标选择器:kind + 目标 id + 弹窗锚点坐标(fixed 定位) */ const [iconPick, setIconPick] = useState<{ kind: 'layout' | 'shortcut' | 'project'; id: string; x: number; y: number } | null>(null) - /** 对话绑定弹窗:项目 id + 锚点坐标;bindGroups = 打开时抓取的会话分组 */ + /** 对话绑定弹窗:项目 id + 锚点坐标;bindGroups = 打开时抓取的会话分组; + * bindListOpen = 右侧对话列表弹层(点「绑定对话」行弹出) */ const [bindPick, setBindPick] = useState<{ id: string; x: number; y: number } | null>(null) const [bindGroups, setBindGroups] = useState<{ title: string; sessions: { id: string; title: string; isCurrent: boolean }[] }[]>([]) + const [bindListOpen, setBindListOpen] = useState(false) /** 自定义布局弹窗(预设网格末尾的 + 磁贴):描述 → 复制提示词到剪贴板 */ const [customOpen, setCustomOpen] = useState(false) @@ -1037,6 +1039,7 @@ function buildCustomLayoutPrompt(req: string): string { const x = clamp(Math.round(r.right + 8), 8, window.innerWidth - 300) const y = clamp(Math.round(r.top), 8, window.innerHeight - 420) setBindPick({ id, x, y }) + setBindListOpen(false) setBindGroups([]) fetchSessionGroups().then((res) => setBindGroups(res.groups)).catch(() => setBindGroups([])) }, []) @@ -1060,7 +1063,7 @@ function buildCustomLayoutPrompt(req: string): string { }) } - /** 绑定 / 解绑会话 */ + /** 绑定 / 解绑会话(弹窗保持打开,绑定结果即时显示在「绑定对话」框里) */ const setProjectBinding = (id: string, sessionId: string | null) => { persistProjects((prev) => { const next = { ...prev.bindings } @@ -1068,7 +1071,7 @@ function buildCustomLayoutPrompt(req: string): string { else delete next[id] return { ...prev, bindings: next } }) - setBindPick(null) + setBindListOpen(false) } /** 复制自定义布局提示词到剪贴板(失败则全选输入框手动复制) */ @@ -1957,11 +1960,11 @@ function buildCustomLayoutPrompt(req: string): string { )} - {bindPick &&
setBindPick(null)} />} + {bindPick &&
{ setBindPick(null); setBindListOpen(false) }} />} {bindPick && (
{t('bind.title')} - {/* 项目文件夹(工作目录):所有产出文件放这里,可随时更改 */} + {/* 项目文件夹框(格式基准):第一行 emoji+标题,第二行路径;可随时更改 */}
📁 {t('bind.folder')} @@ -1971,29 +1974,44 @@ function buildCustomLayoutPrompt(req: string): string { {projects.folders[bindPick.id] ?? t('bind.folderNone')}
- {(() => { - const sid = projects.bindings[bindPick.id] - if (!sid) { + {/* 绑定对话框(与项目文件夹同格式):第一行 💬+标题;第二行 分组 | 对话名(点击右侧弹列表);框内下方:说明 + 解绑 */} +
+
+ 💬 {t('bind.title')} +
+ {(() => { + const sid = projects.bindings[bindPick.id] + if (!sid) { + return ( + + ) + } + const info = bindInfoOf(bindGroups, sid) return ( -
- - {t('bind.unbound')} -
+ ) - } - const info = bindInfoOf(bindGroups, sid) - return ( -
- 📂 {info.folder} - | - {info.title} -
- ) - })()} -

{t('bind.hint')}

- {projects.bindings[bindPick.id] && ( - - )} + })()} +

{t('bind.hint')}

+ {projects.bindings[bindPick.id] && ( + + )} +
+
+ )} + {/* 对话列表弹层:点「绑定对话」行弹出(优先右侧,放不下翻到左侧);选中即绑定并收起 */} + {bindPick && bindListOpen && (() => { + // 主弹窗实际渲染宽 = 280 + 菜单内边距/边框(约 292),右侧列表按 300 偏移避免重叠 + const rightFits = bindPick.x + 300 + 260 <= window.innerWidth - 8 + const listLeft = rightFits ? bindPick.x + 300 : Math.max(8, bindPick.x - 268) + return ( +
{bindGroups.map((g, gi) => ( @@ -2008,7 +2026,7 @@ function buildCustomLayoutPrompt(req: string): string { key={s.id} type="button" className={'dsh-wt_selectItem' + (projects.bindings[bindPick.id] === s.id ? ' dsh-wt_selectItemOn' : '')} - onClick={() => setProjectBinding(bindPick.id, s.id)} + onClick={() => { setProjectBinding(bindPick.id, s.id); setBindListOpen(false) }} > {s.title} {s.isCurrent && {t('custom.sessionCurrent')}} @@ -2018,7 +2036,8 @@ function buildCustomLayoutPrompt(req: string): string { ))}
- )} + ) + })()} {customOpen &&
setCustomOpen(false)} />} {customOpen && ( diff --git a/01_content/src/client/locales.ts b/01_content/src/client/locales.ts index 646d838..ecdaa14 100644 --- a/01_content/src/client/locales.ts +++ b/01_content/src/client/locales.ts @@ -101,7 +101,8 @@ export const zh = { 'bind.folderChange': '更改', 'bind.folderNone': '未设置(建议设置:项目产出文件都会放进这里)', 'bind.tipBound': '已绑定对话:{name}', - 'bind.hint': '一个项目只能绑定一个对话。选择后,打开该项目时右侧对话窗会自动切换过去;已绑定的项目不会因新建/发送对话而自动改绑。', + 'bind.clickPick': '点击选择对话', + 'bind.hint': '打开项目时,右侧对话窗会自动切换到这个对话。', 'customLayout.add': '自定义', 'customLayout.addTitle': '自定义一个布局(生成提示词)', 'customLayout.title': '自定义布局', @@ -235,7 +236,8 @@ export const en = { 'bind.folderChange': 'Change', 'bind.folderNone': 'Not set (recommended: project outputs go here)', 'bind.tipBound': 'Bound to: {name}', - 'bind.hint': 'A project can bind exactly one conversation. When bound, opening the project switches the right chat pane to it; an existing binding is never auto-changed by creating/sending conversations.', + 'bind.clickPick': 'click to pick', + 'bind.hint': 'Opening the project switches the right chat pane to this conversation.', 'customLayout.add': 'Custom', 'customLayout.addTitle': 'Customize a layout (generate a prompt)', 'customLayout.title': 'Custom layout', diff --git a/01_content/src/client/styles.ts b/01_content/src/client/styles.ts index 444ec6e..474543a 100644 --- a/01_content/src/client/styles.ts +++ b/01_content/src/client/styles.ts @@ -264,20 +264,23 @@ export const css = xtermCss + '\n' + [ '.dsh-wt_customLayoutBtn:hover{background:var(--dsw-alias-fill-l1,rgba(255,255,255,.05))}', '.dsh-wt_customLayoutToast{margin:8px 0 0;font-size:11.5px;line-height:17px;color:var(--dsw-alias-state-success,#3fb950)}', '.dsh-wt_customLayoutToastFail{color:var(--dsw-alias-state-danger,#f85149)}', - // 对话绑定弹窗:状态行(未绑定 / 📂文件夹 | [对话框]) - '.dsh-wt_bindStatus{display:flex;align-items:center;gap:6px;margin-top:8px;padding:6px 8px;background:var(--dsw-alias-fill-l1,rgba(255,255,255,.03));border:1px solid var(--dsw-alias-border-l1,#262b36);border-radius:8px}', - '.dsh-wt_bindStatusNone{color:var(--dsw-alias-label-secondary,#9aa4b2)}', - '.dsh-wt_bindMini{position:relative;display:inline-block;width:18px;height:14px;flex:none}', + // 对话绑定弹窗:绑定对话框内的对话行(点击右侧弹列表) '.dsh-wt_bindNoneText{font-size:12px;line-height:18px}', '.dsh-wt_bindFolder{flex:none;font-size:12px;line-height:18px;color:var(--dsw-alias-label-secondary,#9aa4b2);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:40%}', '.dsh-wt_bindSep{flex:none;color:var(--dsw-alias-border-l2,#3a4150);font-size:11px}', - '.dsh-wt_bindConv{flex:1;min-width:0;padding:2px 8px;border:1px solid var(--dsw-alias-border-l2,#3a4150);border-radius:6px;background:var(--dsw-alias-fill-l2,rgba(255,255,255,.05));font-size:12px;line-height:18px;color:var(--dsw-alias-label-primary,#e6e8eb);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}', - '.dsh-wt_bindHint{margin:6px 0 6px;font-size:11px;line-height:16px;color:var(--dsw-alias-label-secondary,#9aa4b2)}', + '.dsh-wt_bindConvRow{display:flex;align-items:center;gap:6px;width:100%;box-sizing:border-box;margin-top:4px;padding:3px 4px;border:1px solid transparent;border-radius:6px;background:transparent;color:var(--dsw-alias-label-primary,#e6e8eb);font:inherit;font-size:12px;line-height:18px;cursor:pointer;text-align:left}', + '.dsh-wt_bindConvRow:hover{background:var(--dsw-alias-fill-l1,rgba(255,255,255,.05));border-color:var(--dsw-alias-border-l2,#3a4150)}', + '.dsh-wt_bindConvRowNone{color:var(--dsw-alias-label-secondary,#9aa4b2)}', + '.dsh-wt_bindConvName{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}', + '.dsh-wt_bindConvChevron{flex:none;color:var(--dsw-alias-label-tertiary,#6b7280);font-size:9px;line-height:1}', + '.dsh-wt_bindHint{margin:6px 0 2px;font-size:11px;line-height:16px;color:var(--dsw-alias-label-secondary,#9aa4b2)}', // 自定义窗完成页:自动绑定提示 '.dsh-wt_customDoneBind{margin:6px 0 0;font-size:11px;line-height:16px;color:var(--dsw-alias-state-accent-primary,#4f8ef7)}', - '.dsh-wt_bindUnbind{display:inline-flex;align-items:center;gap:4px;margin-bottom:6px;padding:3px 8px;border:1px solid var(--dsw-alias-border-l1,#262b36);border-radius:6px;background:transparent;color:var(--dsw-alias-label-secondary,#9aa4b2);font:inherit;font-size:11px;line-height:16px;cursor:pointer}', + '.dsh-wt_bindUnbind{display:inline-flex;align-items:center;gap:4px;margin:4px 0 0;padding:3px 8px;border:1px solid var(--dsw-alias-border-l1,#262b36);border-radius:6px;background:transparent;color:var(--dsw-alias-label-secondary,#9aa4b2);font:inherit;font-size:11px;line-height:16px;cursor:pointer}', '.dsh-wt_bindUnbind:hover{color:var(--dsw-alias-state-danger,#f85149);border-color:var(--dsw-alias-state-danger,#f85149)}', '.dsh-wt_bindList{max-height:280px;overflow:auto;position:static}', + '.dsh-wt_bindListPop{display:flex;flex-direction:column;padding:6px}', + '.dsh-wt_bindListPop .dsh-wt_bindList{max-height:320px}', '.dsh-wt_customRow{display:flex;align-items:center;gap:8px}', '.dsh-wt_customLabel{flex:none;font-size:11.5px;color:var(--dsw-alias-label-secondary,#9aa4b2)}', '.dsh-wt_customSelect{flex:1;min-width:0;padding:5px 8px;background:var(--dsw-alias-fill-l1,rgba(255,255,255,.03));border:1px solid var(--dsw-alias-border-l1,#262b36);border-radius:6px;color:var(--dsw-alias-label-primary,#e6e8eb);font:inherit;font-size:12px;outline:none}', diff --git a/02_process/worklogs/2026-08-16_worktable-v2.md b/02_process/worklogs/2026-08-16_worktable-v2.md index 66535cb..d059d24 100644 --- a/02_process/worklogs/2026-08-16_worktable-v2.md +++ b/02_process/worklogs/2026-08-16_worktable-v2.md @@ -1103,7 +1103,19 @@ tasks 非网页标签无 ↻ ✓;functional-diag 全 20 STEP ERROR_COUNT: 0。 - 备注:纯客户端改动,F5 即生效。 +## 补记(绑定弹窗精简:两框统一格式 + 右侧弹列表) - - - +- 用户反馈:绑定对话弹窗内容太多太丑,要求精简。定案:① 点开只显示「项目文件夹」+ + 「绑定对话」两个框,说明简化;② 底部对话列表去掉,改在点击「绑定对话」行时于右侧 + 弹出列表;③ 「绑定对话」按「项目文件夹」格式做完整框:第一行 💬 emoji + 「绑定对话」 + 标题,第二行现在显示的 分组 | 对话名,下方简单说明、再下方解绑,全部框在框里。 +- 实现:bindPick 弹窗重构——两个 .dsh-wt_bindFolderBox 同格式框;绑定对话行 + .dsh-wt_bindConvRow(未绑定态「未绑定对话 · 点击选择对话」,已绑定态 📂分组|名称+▾), + 点击开 bindListOpen 右侧 .dsh-wt_bindListPop(优先右侧 x+300,放不下翻左侧);选会话后 + 列表收起、主弹窗保持打开即时显示绑定结果(setProjectBinding 不再 setBindPick(null), + 改 setBindListOpen(false));说明 bind.hint 简化为一句话;解绑按钮入框。 + 样式:删 bindStatus/bindMini/bindConv,新增 bindConvRow/ConvName/ConvChevron/bindListPop。 +- 验证(probe-batch15.cjs):两框同格式(📁 项目文件夹 / 💬 绑定对话)✓;主弹窗无列表 ✓; + 点行右侧弹列表(listOnRight、23 项)✓;选后列表收起、主弹窗显示新绑定(名称/▾/解绑)✓; + 解绑回未绑定态 ✓;backdrop 关闭 ✓;functional-diag 全 20 STEP ERROR_COUNT: 0。 +- 备注:纯客户端改动,F5 即生效。 diff --git a/04_test/probe-batch15.cjs b/04_test/probe-batch15.cjs new file mode 100644 index 0000000..ea646e9 --- /dev/null +++ b/04_test/probe-batch15.cjs @@ -0,0 +1,109 @@ +// probe-batch15.cjs — 绑定弹窗精简:文件夹框 + 绑定对话框(💬行点击右侧弹列表)+ 框内说明/解绑 +const http = require('http'); +const { spawn } = require('child_process'); +const WebSocket = require('ws'); +const PORT = 9372; +const proc = spawn('C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe', [ + '--headless=new', '--disable-gpu', '--no-first-run', '--no-default-browser-check', + '--window-size=1440,900', '--force-device-scale-factor=1', + '--remote-debugging-port=' + PORT, + '--user-data-dir=C:\\Users\\SJL\\AppData\\Local\\Temp\\wt-chrome-batch15', + 'about:blank', +], { stdio: 'ignore' }); +const getJSON = (p) => new Promise((res, rej) => { + http.get({ host: '127.0.0.1', port: PORT, path: p }, (r) => { let d=''; r.on('data',c=>d+=c); r.on('end',()=>{try{res(JSON.parse(d))}catch(e){rej(e)}}) }).on('error', rej); +}); +const sleep = (ms) => new Promise((r) => setTimeout(r, ms)); +(async () => { + let list = null; + for (let i = 0; i < 40; i++) { try { list = await getJSON('/json/list'); if (list && list.length) break; } catch {} await sleep(500); } + const target = list.find((t) => t.type === 'page') || list[0]; + const ws = new WebSocket(target.webSocketDebuggerUrl); + let id = 0; const pending = new Map(); + const send = (method, params) => new Promise((res) => { const mid = ++id; pending.set(mid, res); ws.send(JSON.stringify({ id: mid, method, params })); }); + ws.on('message', (raw) => { const m = JSON.parse(String(raw)); if (m.id && pending.has(m.id)) { pending.get(m.id)(m); pending.delete(m.id); } }); + await new Promise((r) => ws.on('open', r)); + await send('Runtime.enable'); + await send('Page.enable'); + await send('Page.addScriptToEvaluateOnNewDocument', { + source: "try{ if(location.origin==='http://127.0.0.1:3080'){ localStorage.setItem('dsh.worktable.view.v1', JSON.stringify({query:'',searchOpen:false,orderBy:'manual',dock:'footer',floatTop:null,sortMigratedV2:true})); localStorage.setItem('dsh.worktable.projects.v1', JSON.stringify({order:['t-bind'],lastUsed:{},hidden:[],nameOverrides:{},iconOverrides:{},shortcuts:[],layouts:[{id:'t-bind',title:'\u7ed1\u5b9a\u6d4b\u8bd5',icon:'\ud83e\uddea',top:null,left:null,main:[{id:'p1',title:'\u5185\u5bb91',min:200,content:null,tabs:[],active:0}],leftWidth:{default:260,min:160,max:480},chatWidth:{default:360,min:240,max:600},topHeight:{default:200,min:120,max:480},chatSide:'right',chatFullHeight:false}],bindings:{},folders:{'t-bind':'C:\\Temp'},views:{},removed:[]})); } }catch(e){}", + }); + await send('Page.navigate', { url: 'http://127.0.0.1:3080/' }); + const evaluate = async (expr) => { + const r = await send('Runtime.evaluate', { expression: expr, returnByValue: true, awaitPromise: true }); + if (r.result && r.result.exceptionDetails) return { __error: (r.result.exceptionDetails.exception || {}).description || r.result.exceptionDetails.text }; + return r.result && r.result.result ? r.result.result.value : undefined; + }; + let ready = null; + for (let i = 0; i < 30; i++) { await sleep(1000); ready = await evaluate("!!window.__dshWorktable"); if (ready === true) break; } + await sleep(1500); + await evaluate("(function(){ var b=document.querySelector('button[title=\"Open sidebar\"],button[aria-label=\"Open sidebar\"]'); if(b){b.click(); return true} return false })()"); + await sleep(1000); + const out = await evaluate(`(async function(){ + var out = {}; + var sleep = function(ms){ return new Promise(function(r){ setTimeout(r, ms); }); }; + var vis = function(sel){ return [].slice.call(document.querySelectorAll(sel)).find(function(el){ return (getComputedStyle(el).visibility!=='hidden'&&el.getBoundingClientRect().height>0); }); }; + try { + // 打开绑定弹窗(布局卡右上 ●●) + var card = vis('.dsh-wt_projects .dsh-wt_layout'); + out.cardFound = !!card; + var bb = card && card.querySelector('.dsh-wt_bindBtn'); + if (bb) { bb.dispatchEvent(new MouseEvent('click', {bubbles:true, cancelable:true})); } + await sleep(400); + var pop = vis('.dsh-wt_bindPop'); + out.popOpen = !!pop; + if (!pop) { return out; } + // 结构:两个同格式框;主弹窗内不再有列表 + out.boxCount = pop.querySelectorAll('.dsh-wt_bindFolderBox').length; + out.mainHasList = !!pop.querySelector('.dsh-wt_bindList'); + var boxes = pop.querySelectorAll('.dsh-wt_bindFolderBox'); + out.box0Label = boxes[0] ? boxes[0].querySelector('.dsh-wt_bindFolderLabel').textContent : null; + out.box1Label = boxes[1] ? boxes[1].querySelector('.dsh-wt_bindFolderLabel').textContent : null; + out.box0Path = boxes[0] ? boxes[0].querySelector('.dsh-wt_bindFolderPath').textContent : null; + out.box0Change = !!(boxes[0] && boxes[0].querySelector('.dsh-wt_bindFolderChange')); + // 未绑定态:行显示 未绑定对话·点击选择;无解绑;无右侧列表 + var rowNone = boxes[1] && boxes[1].querySelector('.dsh-wt_bindConvRow'); + out.unboundRow = rowNone ? rowNone.textContent : null; + out.unbindAbsent = !pop.querySelector('.dsh-wt_bindUnbind'); + out.listClosed0 = !vis('.dsh-wt_bindListPop'); + // 点击行 → 右侧弹列表 + if (rowNone) { rowNone.dispatchEvent(new MouseEvent('click', {bubbles:true, cancelable:true})); } + await sleep(400); + var lpop = vis('.dsh-wt_bindListPop'); + out.listOpened = !!lpop; + if (lpop) { + var pr = pop.getBoundingClientRect(); var lr = lpop.getBoundingClientRect(); + out.debug = { prLeft: Math.round(pr.left), prRight: Math.round(pr.right), lrLeft: Math.round(lr.left), innerW: window.innerWidth }; + out.listOnRight = lr.left >= pr.right - 1; + out.itemCount = lpop.querySelectorAll('.dsh-wt_selectItem').length; + var item = lpop.querySelector('.dsh-wt_selectItem'); + if (item) { item.dispatchEvent(new MouseEvent('click', {bubbles:true, cancelable:true})); } + await sleep(400); + } + out.listClosedAfterPick = !vis('.dsh-wt_bindListPop'); + out.mainStillOpen = !!vis('.dsh-wt_bindPop'); + var convName = vis('.dsh-wt_bindPop .dsh-wt_bindConvName'); + out.boundName = convName ? convName.textContent : null; + out.boundFolderText = vis('.dsh-wt_bindPop .dsh-wt_bindFolder') ? vis('.dsh-wt_bindPop .dsh-wt_bindFolder').textContent : null; + out.chevron = !!vis('.dsh-wt_bindPop .dsh-wt_bindConvChevron'); + out.unbindPresent = !!vis('.dsh-wt_bindPop .dsh-wt_bindUnbind'); + var saved = JSON.parse(localStorage.getItem('dsh.worktable.projects.v1')); + out.savedBinding = saved.bindings['t-bind']; + // 解绑 → 恢复未绑定 + var ub = vis('.dsh-wt_bindPop .dsh-wt_bindUnbind'); + if (ub) { ub.dispatchEvent(new MouseEvent('click', {bubbles:true, cancelable:true})); } + await sleep(400); + out.unboundAfterUnbind = !!vis('.dsh-wt_bindPop .dsh-wt_bindConvRowNone'); + out.unbindGoneAfter = !vis('.dsh-wt_bindPop .dsh-wt_bindUnbind'); + // 关闭(backdrop) + var bd = vis('.dsh-wt_popBackdrop'); + if (bd) { bd.dispatchEvent(new MouseEvent('click', {bubbles:true, cancelable:true})); } + await sleep(300); + out.closed = !vis('.dsh-wt_bindPop'); + } catch (e) { out.err = String(e && e.stack || e); } + return out; + })()`); + console.log('RESULT ' + JSON.stringify(out)); + try { ws.close(); } catch {} + proc.kill(); +})().catch((e) => { console.error('PROBE FAIL', e); try { proc.kill(); } catch {} });