fix: include ungrouped conversations in bind/send lists + left-align new-project folder row with wider path

This commit is contained in:
Aisland
2026-08-19 22:05:56 +08:00
parent e9f839d3d0
commit 9975e889f8
4 changed files with 124 additions and 11 deletions
+20 -9
View File
@@ -325,22 +325,33 @@ async function fetchSessionGroups(): Promise<{ groups: { title: string; sessions
} catch {}
const titleOf = (sid: string) => byId[sid]?.title ?? byId[sid]?.displayTitle ?? sid
const mk = (sid: string) => ({ id: sid, title: titleOf(sid), isCurrent: sid === current })
// 工作区分组:服务端读宿主 workspace.json(含 archived 排除),按用户面板结构分组
// 工作区分组:服务端读宿主 workspace.json(含 archived 排除),按用户面板结构分组;
// 不属于任何工作区的会话收进「未分组」组(绑定弹窗/发送到会话都要能看到它们)
try {
const r = await fetch('/api/worktable/workspaces')
const d = await r.json()
const order: string[] = Array.isArray(d?.global?.workspaceIds) ? d.global.workspaceIds : []
const archived: string[] = Array.isArray(d?.global?.archivedSessionIds) ? d.global.archivedSessionIds : []
const table = d?.tables?.workspaces ?? {}
const accounted = new Set<string>()
const groups = order
.map((wid: string) => ({
title: (table[wid]?.title ?? wid) as string,
sessions: ((table[wid]?.sessionIds ?? []) as string[])
.filter((sid) => !archived.includes(sid) && !subKids.has(sid))
.map(mk),
}))
.map((wid: string) => {
const sessIds = ((table[wid]?.sessionIds ?? []) as string[])
sessIds.forEach((sid) => accounted.add(sid))
return {
title: (table[wid]?.title ?? wid) as string,
sessions: sessIds
.filter((sid) => !archived.includes(sid) && !subKids.has(sid))
.map(mk),
}
})
.filter((g) => g.sessions.length > 0)
if (groups.length > 0) return { groups, current }
const allIds: string[] = Array.isArray(snap?.ids) ? snap.ids : []
const ungrouped = allIds.filter((sid) => !accounted.has(sid) && !archived.includes(sid) && !subKids.has(sid))
const withUngrouped = ungrouped.length > 0
? [{ title: '未分组', sessions: ungrouped.map(mk) }, ...groups]
: groups
if (withUngrouped.length > 0) return { groups: withUngrouped, current }
} catch {}
// 回退:平铺(排除子代理)
const ids: string[] = Array.isArray(snap?.ids) ? snap.ids : []
@@ -1534,7 +1545,7 @@ function buildCustomLayoutPrompt(req: string): string {
{addOpen && <div className="dsh-wt_popBackdrop" onClick={() => setAddOpen(false)} />}
{addOpen && (
<div className="dsh-wt_menu dsh-wt_add dsh-wt_pop" style={{ position: 'fixed', left: popLeft, top: popTop, width: 320, zIndex: 80 }}>
<div className="dsh-wt_menu dsh-wt_add dsh-wt_pop" style={{ position: 'fixed', left: popLeft, top: popTop, width: 360, zIndex: 80 }}>
<span className="dsh-wt_menuLabel">{t('add.chooseLayout')}</span>
<div className="dsh-wt_presets">
{PRESET_DEFS.map((def) => (
+2 -2
View File
@@ -226,10 +226,10 @@ export const css = [
'.dsh-wt_customPathInput{flex:1;min-width:0;box-sizing:border-box;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;line-height:18px;outline:none}',
'.dsh-wt_customPathInput:focus{border-color:var(--dsw-alias-state-accent-primary,#4f8ef7)}',
// 新建项目强制文件夹:两行(父目录/名称)
'.dsh-wt_addFolderRow{display:flex;align-items:center;gap:8px;margin-top:6px}',
'.dsh-wt_addFolderRow{display:flex;align-items:center;gap:8px;margin-top:6px;padding:0 2px}',
'.dsh-wt_addFolderPath{flex:1;min-width:0;padding:4px 8px;border:1px solid var(--dsw-alias-border-l1,#262b36);border-radius:6px;background:var(--dsw-alias-fill-l1,rgba(255,255,255,.03));font-size:11.5px;line-height:17px;color:var(--dsw-alias-label-primary,#e6e8eb);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}',
'.dsh-wt_addFolderPathNone{color:var(--dsw-alias-label-tertiary,#6b7280);border-style:dashed}',
'.dsh-wt_addFolderRow .dsh-wt_customLabel{width:86px;text-align:right}',
'.dsh-wt_addFolderRow .dsh-wt_customLabel{flex:none;width:auto;text-align:left}',
// 绑定弹窗内的项目文件夹区
'.dsh-wt_bindFolderBox{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_bindFolderRow{display:flex;align-items:center;justify-content:space-between}',