From 133b54d69dfac52380677036073b2d2c2112616e Mon Sep 17 00:00:00 2001 From: qyh15 Date: Tue, 27 Oct 2026 20:11:32 +0800 Subject: [PATCH] feat: pinned tabs, tab context menu and group appearance (0.5.0) Tab strip: pinned block, drag reorder with cross-boundary pin flip, middle-click close, double-click tab rename (never rewrites the session), context menu (close / others / right / pin / rename), responsive overflow; persistence v2 keeps pinned+title and still reads v1. Sidebar: per-group colour and icon (20 presets or 1-4 char glyph) plus pinning, stored in the manual overlay 'appearance' map with strict-write/tolerant-read validation; animated group folding with the flower-branch overlay suppressed while rows move. Tests: pure-logic suites for tabs, appearance partition and overlay parsing; verified by tools/verify-tabs.mjs and tools/verify-appearance.mjs (vitest cannot spawn in this sandbox). --- DEVELOPMENT.md | 22 +- README.md | 55 +- README_ZH.md | 47 +- lib/client.js | 1240 +++++++++++++++++++++++++---- lib/client.js.map | 2 +- lib/index.js | 110 ++- lib/types/client/locales.d.ts | 2 +- lib/types/client/rows.d.ts | 36 +- lib/types/client/tab-persist.d.ts | 4 + lib/types/client/tab-store.d.ts | 17 +- lib/types/client/tabs.d.ts | 151 +++- lib/types/client/tree.d.ts | 4 +- lib/types/core/matcher.d.ts | 16 +- lib/types/core/types.d.ts | 33 +- lib/types/host-tabs.d.ts | 26 +- package.json | 2 +- src/client/GroupsBrowser.tsx | 394 +++++++-- src/client/SessionTabs.tsx | 459 +++++++++-- src/client/index.ts | 7 +- src/client/locales.ts | 93 +++ src/client/rows.tsx | 196 ++++- src/client/styles.css | 266 ++++++- src/client/tab-persist.ts | 31 +- src/client/tab-store.ts | 25 + src/client/tabs.ts | 268 ++++++- src/client/tree.ts | 16 +- src/core/matcher.ts | 71 +- src/core/types.ts | 52 +- src/host-manual.ts | 69 +- src/host-tabs.ts | 60 +- src/index.ts | 13 +- tests/core.test.ts | 42 + tests/manual.test.ts | 63 ++ tests/tabs.test.ts | 216 +++++ tests/tree.test.ts | 47 +- 35 files changed, 3753 insertions(+), 402 deletions(-) create mode 100644 tests/tabs.test.ts diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 5d2035d..a66caa3 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -140,7 +140,19 @@ $installed = "C:\Users\qyh15\.dsh\profiles\desktop\node_modules\@dsh-xhl\workspa 挂路由 → 客户端照 `tab-persist.ts` 的 `fetch` 封装去调,注意 `Cache-Control: no-store`。 - **加标签条行为**:状态变换进 `tabs.ts`(纯),store 绑定在 `tab-store.ts`, 渲染在 `SessionTabs.tsx`,落盘走 `tab-persist.ts`;位置模型是「首次入列时定序」, - 改动前先读 `tabs.ts` 顶部的 position model 注释。 + 改动前先读 `tabs.ts` 顶部的 position model 注释。两条不变量:**固定标签恒在未固定 + 之前**(`moveTab` 在固定区边界夹紧、`togglePinTab` 插到固定区尾/未固定区头), + **标签名与会话标题互不影响**(`renameTab` 只动 `title`)。除 `order` 之外的标签状态 + (固定、自定义名)也必须由 `restoreTabsImpl` 原样复原,否则每次重启都丢配置。 +- **加一个分组展示元数据(颜色 / 图标 / 置顶等)**:字段进 `types.ts` + (`CategoryAppearance` + `GROUP_COLORS`/`GROUP_ICON_IDS` 白名单)→ 校验进 + `host-manual.ts` 的 `parseAppearance`(**严格写、宽容读**:不校验键对应的分类是否 + 还存在,否则删掉一条 YAML 分类就会让之后每次保存都 400)→ 派生进 `matcher.ts` + (要影响排序就必须放 `effectiveCategories`,只在渲染层排会让拖拽落点与看到的顺序 + 不一致)→ `tree.ts` 节点带 `appearance` → `rows.tsx` 渲染 → `styles.css` 配色/ + 动画 → `locales.ts` 双语文案。写路径统一走 + `GroupsBrowser.tsx` 的 `updateCategoryAppearance`;**改名要重映射 `appearance` 的键、 + 删除要清掉**(键空间是 display name,与 `categoryOrder` 一致)。 - **新增平台依赖**:先确认 DSH shell 的 module table 真有那一行,再往 `CLIENT_EXTERNALS` 里加,否则运行时 `require` 会拿不到模块。 @@ -149,7 +161,11 @@ $installed = "C:\Users\qyh15\.dsh\profiles\desktop\node_modules\@dsh-xhl\workspa - **沙箱内跑不了 vitest**:`spawn` 被 DSH 沙箱拦(EPERM),在普通 PowerShell 终端里跑。 - **`node_modules/.bin/*.CMD` 直调会挂**:pnpm 里嵌套的 pnpm 脚本在 DSH 沙箱下会 `Could not determine executable`,统一用 `node