Commit Graph
76 Commits
Author SHA1 Message Date
Menghuan1918 daf0329666 refactor(ui): 外壳与残余件接入统一组件层(B4)
- Switch.tsx 删除,唯一消费者 native/guide-order.tsx 改用 ui 的 ToggleSwitch
  (native checkbox → button role="switch",受控写回契约不变:下一次值仍由 prop 推导)。
- tests/switch.spec.tsx 改名 tests/toggle-switch.spec.tsx,断言改 aria-checked;
  native-guide 两处开关查询同步改选择器。
- sidebar/dock-fallback.tsx 与 split-pane.tsx 判断不接入:前者只有定位/让位逻辑
  与 BottomDockToggle 包壳,后者是纯布局与 pointer 拖拽手柄,统一层没有语义对应件。
- 收敛文档补 B4 实施记录,并把映射表中这两行改为「判断不接入」及理由。
2026-11-25 01:05:35 +08:00
Menghuan1918 39ccabcefb feat(sidebar): polish loading, floating windows and clue provenance 2026-11-24 16:43:27 +08:00
Menghuan1918 5ee81fb073 feat(clues): collect resources from files, Feishu and GitHub, adapted to DSH 0.2.2-rc.2
This lands the clue collection line on top of origin/dev (v0.32.1, DSH
0.2.2-rc.2). The 14 commits that carried it are squashed into this one
because every one of them overlapped upstream's own changes (version,
19 dictionaries, CHANGELOG), and each intermediate commit would have
failed to compile against rc.2's menu API. The pre-integration head is
kept at backup/clues-uiux-refresh-pre-rebase.

What the feature is:
- a Clues tab that reads local files, Feishu tasks/docs and GitHub
  issues/pulls through one source registry, with a scope row, shared
  search, filters, paging and stable [[dsh-clue:...]] references;
- one window host for detail, pack management, source configuration,
  new pack and sharing (preview and edit are separate paths: a read is
  never saved over);
- .cluepack export/import with per-row resolvability previews;
- a source runtime that owns dependency installs and connection
  authorization (gh, lark-cli device code) and only probes on an
  explicit read;
- the public betterSidebarClues service and the windows capability
  (features gains clues / windowHost).

Merged with upstream rather than over it:
- the settings section keeps upstream's start-page takeover group and
  this branch's clue sources group; navigation is now six groups;
- the dictionaries keep both sides' new keys (1211 each, verified equal
  across all 19), the external-plugin guide and CHANGELOG keep both
  histories, and service features list both capability sets.

Adapted to 0.2.2-rc.2:
- menu call sites use anchorPoint instead of getAnchorRect;
- the shared SelectMenu mounts the host menu only while open, because
  rc.2's Menu reads the DOM during render and broke server-rendered
  settings surfaces;
- the submenu flip workaround stays deleted (the host positions
  submenus now), pinned by an updated layout-css assertion.

Version 0.33.0 (three synced spots) with a new 未发布 / Unreleased
changelog section; package.json regains the ./clues export, lib/clues.js
and the uqr dependency that upstream never had.

Gates: typecheck, lint, 5410 unit tests, build, check:consumer-types and
the full mount lane (35 passed) against dsh 0.2.2-rc.2 in Chromium.
2026-11-24 16:43:26 +08:00
Hairy 1b36babe07 Merge pull request #945 from hairyf/fix/native-tab-chip-alignment
fix: 对齐原生 Tab 与官方图标尺寸、间距和居中
2026-11-21 12:54:45 +08:00
Menghuan1918 58cf84b733 fix(settings): re-show a start-page card with an explicit false (#1212) 2026-11-18 00:07:48 +08:00
Menghuan1918 0441249314 feat(sidechat): make the native page mode configurable (#1115)
Keep the contributor independent-page implementation, but make it opt-in: the default is still one shared page with the session last/newest reattach, and Settings -> Side card -> Side chat can switch to one native page per thread. The descriptor gains a dynamic multiple predicate, native sync re-registers on a flip, and occurrence bindings are read/written only for sidebar://sidechat/<uuid> contentIds so the shared page can never be captured by an old binding.
2026-11-16 00:47:59 +08:00
peng xiang ba6f3a3423 fix(sidechat): preserve independent native tabs and exact thread bindings 2026-11-16 00:39:39 +08:00
Menghuan1918 e688a29877 chore(dead-code): drop unreferenced exports and orphan module 2026-11-13 01:21:39 +08:00
Menghuan1918 58429f1573 fix(native): center More-menu icons with card labels
Wrap every More row glyph in a fixed 14px box and center both custom icon wrappers and SVGs, so Tasks/Side Chat no longer ride 2px above their labels.
2026-11-12 14:22:57 +08:00
Menghuan1918 91e3ee8970 fix(native): ellipsize start-page card descriptions
Long subtitles were clamped to two lines and grew the card; keep them on one line with a text-overflow ellipsis, and pin the rule with a CSS regression test.
2026-11-12 14:18:54 +08:00
Menghuan1918 973713b157 fix(native): unify start-page switches and repair toggle
Better Sidebar rows now use the same tabsEnabled feature switch in the reorder dialog and the start-page inventory; disabled rows stay in the inventory so they can be turned back on. The shared Switch now derives the next value from the controlled prop, fixing switches that could be turned off but not back on.
2026-11-12 00:05:55 +08:00
Menghuan1918 64a91dac53 fix(native): keep host shell menu and start-page plugin actions
Call webTerminals launcher methods on the service (the detached call lost its remote receiver), and restore the host browse/create plugin rows in an always-present More card alongside icon-plus-title overflow rows.
2026-11-12 00:05:55 +08:00
Menghuan1918 a4d11d7c09 feat(native): align, take over, and reorder start page refinements
Add centered/top alignment, a default-on start-page takeover switch, icon-plus-title More rows, and share the row-count input between settings and the reorder dialog.
2026-11-12 00:05:55 +08:00
Menghuan1918 a92252c5d3 feat(native): take over the right sidebar start page
Replace the host guide body with a plugin start page: responsive two-column cards, configurable rows, a More card for overflow, persisted order and visibility in Side Card settings, and the terminal card shell menu through the host webTerminals service.
2026-11-12 00:05:55 +08:00
kousaka 1f1f29743c fix(native): single-page tab chips take their title from the tab registry
(cherry picked from commit 5c65dd6bf49969983d83ddc612834c8dbe568b4c)
2026-11-08 00:10:06 +08:00
Menghuan1918 4224c78a98 fix(editor): 原生页签关闭与桌面退出保留未保存草稿(#1072 / #1071)
宿主原生页签条的关闭路径只有一个同步清理钩子(唯一的阻止方式是 throw,
会把异常抛给 replaceTab / 公共 close() 调用方),桌面 Cmd+Q 则完全在壳内
完成(before-quit → app.exitRequested),页面没有可取消事件;壳内也没有
will-prevent-unload 处理器。插件因此不伪造拦截,改为降低损失:

- 草稿变脏时按 1 s 节流把实时文档写入 localStorage(sessionId::path,
  单条 200k 字符 / 总计 600k / 最多 8 条 FIFO)
- 原生 registerCloseHandler('editor') 与 beforeunload 时立即 flush
- 重开同一文件提示恢复;保存、确认丢弃、确认刷新/换文件即删除备份

新增 src/client/editor-draft-backup.ts;docs/host-contracts.md §C 记录宿主
限制与将来的接法。测试:新增 editor-draft-backup.spec.tsx(8 例)+ guard
spec 2 例;去掉任一修复点后对应用例均转红。
2026-11-04 21:04:16 +08:00
Menghuan1918 01a6fa573b merge #1057: perf(sidebar): 页签内容的会话 scope 改为按内容稳定,消除无关重渲染导致的整文件重读 2026-10-26 15:03:28 +08:00
Menghuan1918 8c08758afd merge #956: fix(sidebar): worktree 会话的根选择与地址基准(#947 / #950 / #952) 2026-10-26 15:00:57 +08:00
Menghuan1918 22eb6ebddf merge #929: fix(tree): 改名/删除的调解覆盖后台会话的页签 + 标题只在派生自文件名时跟随(#915 后续) 2026-10-26 15:00:55 +08:00
unsc9 31dc3b4572 perf(sidebar): give every consumer one stable session scope
A tab body keys memos and effects off `scope` (the diff pane resolves its
media/html routes from it, the editor restores its preview scroll, the side
chat rebuilds its prose-rewrite cache), but the tab cell built
`{ sessionId, cwd }` fresh on every render. Every such dependency therefore
looked changed whenever the cell re-rendered — which the memo comparator
allows exactly when a COMPARED field moves: `expanded` on a directory toggle,
plus `revealed`, `localeRevision`, `tabsVersion`. The diff preview then
re-ran its whole-document rewrite and its content tab re-issued a whole-file
`fs.read`, flashing its loading row.

`useSessionScope` is now the one place a scope for a component tree is built;
the tab cell, the diff tab, the native tab adapter, and the shell's badge /
rightActions / `+` menu / lifecycle-callback seams all use it. Those last
ones are documented external plug-in surfaces, so a plug-in memoizing on
`scope` stops churning on every unrelated re-render too.

Stabilizing the object removes the only path the diff pane's `content` tab
had to re-read after the file changed on disk, so the header's refresh button
now drives it explicitly (the pane owns the gesture; the loader no longer
leaks its internal counter).

Seven comments asserted that the scope object's identity churns on every
render; that premise is gone, so the ones that still apply say what they
actually guard.
2026-10-25 20:41:54 +08:00
ymac 099128d1b6 merge origin/dev into fix/worktree-root-address-base
四处冲突,都不是「选一边」能了事的:

1) `src/active-worktree.ts` 的头注释:上游这半个月把模块重写了一遍(cwd 解析收敛:
   TTL 15s、在飞去重、三个缓存加 LRU 上界、`working-directory/change` 作为证据边界),
   本分支加的是「工作区内只有同仓库的 linked worktree 才采纳」(#952)。两边都保留:
   一句讲采纳判定,一句讲证据边界。

2/3) `isLinkedWorktree` 一带:上游保留布尔缓存 + 每次探测,本分支把它换成
   `gitIdentityOf`(一次 `rev-parse` 同时给出 git dir 与 common dir,并带自己的缓存),
   由它派生出 `isLinkedWorktree` 与 `isAdoptableTop`。合并后**只留身份缓存**
   (布尔缓存成为同一趟探测的第二份副本,且负结果两边都缓存),`cachePut` 给身份缓存
   补上 LRU 上界,模块头注释的「三个缓存」正好仍是三个。

4) `AGENTS.md`:上游把 §3 整体搬进 `docs/host-contracts.md`(原 §3.4 的 1–12 条按原编号),
   本分支往旧 §3.4 追加了第 13 条(会话地址基准)。取上游的 `AGENTS.md`,把第 13 条
   按新家的体例写进 `docs/host-contracts.md` §B(编号 13 接在第 12 条后),并把四处
   「第 1–12 条」更新为「第 1–13 条」。

顺带:`tests/active-worktree.spec.ts` 的 `rmSync` 导入在上游侧被同一个文件的重排吃掉,
补回。

门禁:typecheck 干净;全量 vitest 2691 passed / 17 skipped / 1 failed(唯一红是既有的
smoke 写 `$HOME` 被本机沙箱 EPERM 拒);`active-worktree` / `worktree-address` /
`native-surface` 70 passed。
2026-10-18 23:19:59 +08:00
Menghuan1918 93c43b0ac9 feat: add optional Context diagnostics navigation
Use an activation-scoped Cordis controller for session, agent, and job-owner entries. Reuse native Context tabs, cancel stale navigation, and close source overlays without canceling pending requests.

Verify optional capability lifecycle, truthful job ownership, three real dsh-context configurations, and the existing mount regression suite.
2026-10-17 02:20:53 +08:00
Menghuan1918 43742be658 perf(client): 每 tab 轮询收敛为按会话共享,keepMounted 加上界
v0.25 起原生 tab 一律 keepMounted:每个访问过的 body 都是永久的,于是
useSessionRoot 的 5s 轮询、目录 watch 的 socket、侧聊推送都按「挂载过的页签数」
永久复制。真机实测(4 个访问过的 tab、15s 空闲):活着的 5s 表 5 条、
session.cwd 请求 15 次;宿主那个解析器每次未命中要 spawn git 并回扫 4000 条事件。

- use-session-root:重写为模块级按会话引用计数的 store——一条 5s 表,只在 ≥1 个
  可见订阅者时存在;页面隐藏停表;恢复可见/聚焦/取消 park 立刻补刷一次;focus 与
  refresh-files 监听全 store 一份;parked body 保留上次答案。
- 消费点传真实可见性:native body 用 nativeTab.visible,壳用 bottomOpen。
- FileTree/use-dir-watch:已有的 visible 接进目录 watch——parked 或展开集为空时不建
  socket、不重列,恢复时重连并强制补刷一次(宿主按连接持有 ≤64 个 fs.watch 句柄)。
- use-sidechat-push/SideChatView:订阅按可见性门控,lastThreadBySession 加 LRU 并
  合并 localStorage 写入。
- state.bySession 加 LRU 32(当前会话永不淘汰,淘汰前先落盘),getSessionStates()
  不再每次整份复制(syncExpanded 原先每次 store notify 都 O(会话数) 复制),
  新增定向 getSessionState(id);FileTree 的 appsCacheRef 加上界。
2026-10-15 23:05:26 +08:00
ymac 97ab172cbb fix(sidebar): 地址路径按基的分隔符拼写(Windows 上同一文件只有一个身份)
CI 的 Windows lane 抓到:地址语法在**所有平台**都是 `/` 分隔,而
`resolveSidebarPath` 把相对路径原样拼到 Windows 基上,于是同一个文件得到
`C:\repo\src/a.ts` 这种混合拼写——文件树 / git 面板 / 一切 join 来源拼的是
`C:\repo\src\a.ts`,而编辑器的 tab id 与 dedupeKey 都是路径派生的,两种拼写
就是两个页签身份(CI 上 worktree-address.spec.ts 3/5 挂:正是三条路径相等断言)。

新增 `src/client/address-base.ts` 的 `resolveAddressPath(base, path)`:在地址边界
把结果折叠成 base 的分隔符风格(POSIX 原样保留 —— 那里 `\` 是合法文件名字符,
也是 `resolveSidebarPath` 从不在 POSIX 折叠的原因),`fileParamsOf` 与
`openSidebarFile` 都改走它。`resolveSidebarPath` 本身与其既有断言
(tests/paths.spec.ts 钉住的混合拼写)逐字未动。

用例:worktree-address.spec.ts 新增 1 条平台无关断言(`C:\repo` + `src/a.ts`
→ `C:\repo\src\a.ts`,POSIX 原样),并让既有 3 条断言在 Windows 上成立。
2026-10-14 23:44:38 +08:00
ymac 6f2054a56c fix(sidebar): 会话地址的基准统一到会话 header cwd(#947 / #950)
会话地址 `dsh-resource://file/session/<sid>/<path>` 的相对路径,宿主构造端
(ui-chat 的 openFile)与解析端(api-workspace-files)都取会话存储的 header cwd;
插件自 #802 起让 fs 路由与原生 tab 体跟随活动 worktree 根,于是地址里的相对拼写
被活动根再拼一次:worktree 嵌在 header cwd 之下时路径翻倍(ENOENT,聊天链接与
改动页都中招),两个检出都有同名文件时静默读到另一份(可保存写回)。

规则:构造端与消费端共用同一个基准,并在地址被读到的边界把它解析成绝对路径——
绝对路径在任何基准下都一样,下游再无可重定基的余地。

- 新增 src/client/address-base.ts 的 addressBaseOf(ctx, sessionId):会话列表里的
  header cwd(宿主地址契约的基准),取不到返回 undefined 让调用方回退。
- 消费边界:fileParamsOf(info, base?) 在切 `path:line` 规格之前把地址路径解析成
  绝对路径;native/index.ts 的 editor 类型注入
  paramsOf: (info) => fileParamsOf(info, addressBaseOf(ctx, fileSessionIdOf(info)))。
- 构造边界:native/surface.ts 的 fileAddress 与 sidebar-file.ts 的
  openClaimedNativeFile 都以 addressBaseOf 优先,调用方 cwd 只作回退——同一文件
  只有一个地址(与宿主聊天路径的地址一致,页签照旧合并)。
- 意图侧:openSidebarFile(ctx, sessionId, path, { line?, cwd? }) 的 cwd 是调用方
  手上的活根(EditorHost / 改动页 / markdown 面板传 useSessionRoot 的结果),
  相对路径按它解析,缺省才回退 header cwd——同一相对路径在各入口不再落到不同检出。
- 测试:新增 tests/worktree-address.spec.ts(基准三态 / 绝对路径不可重定基 /
  构造端基准 / 相对路径按活根解析),真 git worktree 夹具;file-open-claim 的
  `line` 位置参数随之改为 `{ line }`(唯一签名变更点)。
2026-10-14 23:18:08 +08:00
hairyf 82831e525d fix: align native tab icons with official title geometry 2026-10-13 22:26:34 +08:00
ymac 953bebcda3 fix(tree): 改名只在标题本来就来自文件名时才改写(#915 后续)
调解此前**无条件**把页签标题写成新的基名,于是**作者自设的标题**会被一次改名
悄悄替换掉:宿主的 agent-opens 推送就带着模型自己给的名字
(`use-host-feeds` → `openFile(scope, path, title)`),消费插件也可以自己标名字。

- `retargetPathTabs` 只在 `tab.title === baseName(tab.path)`(也就是打开时由
  文件名派生的那种)时才带上 title 补丁;目录改名本来就不动后代(后代基名
  没变),两处口径因此一致。
- `PathTab` / `NativePathTab` 补 `title` 字段,原生枚举(`pathTabs()`)随之
  交出每个记录当前的芯片标题。

测试:`tests/editor-unsaved-guard.spec.tsx` +1(同一个文件的两个页签:派生标题
跟着走、自设标题原样保留;底部工作台那一路一并断言),`tests/native-surface.spec.ts`
的路径枚举断言带上 `title`。判别性实测:把判定换回无条件改写 → 该用例红。
2026-10-12 08:49:28 +08:00
Atlas Zeng 963bef89f0 Merge pull request #912 from UNscientific-9/fix/native-tab-path-reconcile
fix(tabs): 改名/删除的页签调解覆盖右侧栏原生页签,并让改名不再重载文档
2026-10-12 01:40:02 +08:00
unsc9 e4a2d530ea refactor(tabs): 精简改名/删除页签调解的原生枚举与用例装配(行为不变)
上一个提交(e876aa9)过了一轮「代码精简」审查(复用 / 简化 / 效率 / 修在哪一层
四个角度,四个只读子代理并发),这里只落地行为完全不变的那批,净减 37 行。

- **原生页签枚举接回仓库既有的那条缝**:`SidebarSurface` 已有 `tabTypeOf?`
  (存在理由逐字相同:「service 自己看不见原生记录」),新增可选
  `pathTabs?()`,service 上加 `@internal nativePathTabs()` 转发。删掉
  `src/client/native/surface.ts` 里的模块级单例 `installed`、
  `installedNativeSurface()`,以及 dispose 里那条「只有仍是当前实例才清句柄」
  的顺序敏感守卫——那是同一个状态被存两份才需要的补丁。`NativePathTab` 从
  `native/tab-adapter.tsx` 上移到 `service.ts`(与 `NativeTabParams` 并列,
  `SidebarSurface` 的方法就引用它),`createNativeSurface` 因此回到直接
  `return { … }`,不再需要局部 `surface` 变量。
- `tab-adapter.tsx` 的 `ensure()`:`adopted`(三目求值 + `!== undefined` +
  `||`)改成具名布尔 `newNavigation`,`meta` 与 `path` 共用一次判断。真值表
  逐格等价(revision 缺省 → true;已定义且不同 → true;已定义且相同 → false)。
- `closePathTabs` 的 `tab.absolute !== target &&` 多余:`isWithinWorkspace`
  本身对目标自身就返回 true,一条判断同时覆盖「这个文件」与「这个目录下」。
- `EditorHost.tsx` 的布尔 `movedPath` 与 `tree-mutations.ts` 里返回**路径**的
  `movedPath` 撞名,改成 `pathChanged`。
- 用例装配:`mountNativeSession()` 一次装好 store / service / editor 描述符 /
  原生承载面 / 会话,`resetModuleRegistries()` 供 `beforeEach` 与 `afterEach`
  共用,`openNativeFile()` 参数化 seat 与 cwd(收掉两处手写 `records.ensure`)。
  六个用例各自少 5 行样板,用例数与断言不变(15 条)。

按「超出本次 diff / 会改变行为」跳过的三条,留档:改名标记改挂 `SidebarTab`
临时字段(要动持久化 schema 与 `updateTab` 公开 patch 类型)、标记在「宿主直接
关页签且编辑器不再挂载」这条极端路径上不回收(每次几百字节)、批量删除逐行重跑
全量枚举(低于可测量门槛)。

验证:`tsc --noEmit` 通过;eslint 对 6 个改动文件无输出;`vitest run --dir tests`
189 个文件 2240 条用例,184 个文件通过,8 条失败均与本次改动无关且为环境原因
(3 条 Windows 建符号链接 EPERM、1 条 `tar` 在 Windows 输出 CRLF 使结尾带 `\r`、
4 条中文语言标签)——覆盖本次改动模块的用例全绿(`editor-unsaved-guard` 15、
`native-surface` 50,另有 `service`、`editor-host`)。旁证:本地
`.tmp-audit/upstream-tree` 那份不含本改动的镜像副本,在 `tasks-model` 上红的是
同样 4 条。
2026-10-11 16:49:24 +08:00
ymac 6dd0486f5c fix(editor): 换文件 / 重命名时丢掉继承来的 landing line(#826 收尾之三)
`updateTab` 的补丁只有 title/path/meta,所以两条「插件自己改路径」的路都把上一个
文件的行号留在了记录里:合并模式在页头路径框输另一个文件、以及文件树里重命名
打开的文件(`retargetPathTabs`)。后果与 reload 那条同症状——新文件跳到旧行号,
markdown 还被拉进编辑态。宿主导航那条路径本来就有清理规则
(`params.line !== existing.tab.line`),插件自己写的路径没有。

规则统一为「**改 path 就是一次新的打开**」,瞬态行号随之清掉,落在两个记录层:
`patchTab`(store 分支)与原生记录的 `update()`(`updateTab` 的 native 分支);
只改 title / meta 的补丁不动它(同一文件,行号仍属于当前这次导航)。

测试:native-tab-line.spec.ts 加两例(换 path 清掉、只改 title 保留),
editor-line-nav-mode.spec.tsx 的第四条从「模拟 updateTab 的结果」改成驱动真实
`service.updateTab` 并断言记录里 `line` 消失、编辑器留在预览态。
2026-10-11 15:56:49 +08:00
unsc9 e876aa9667 fix(tabs): 改名/删除的页签调解覆盖右侧栏原生页签,并让改名不再重载文档
文件树改名/删除后的页签调解只走 `state.bottomSplits`(插件自己的底部工作台),
而当前架构下文件默认开在 **DSH 原生右侧栏**:有原生承载面时 `service.openTab`
直接走 native,从不写 store。那些页签因此从不参与调解——

- 改名后:页签仍绑旧路径,`EditorHost` 的保存按旧名字写盘;旧名字已被改掉,
  `fs.write` 的 `mkdir -p` + 写入把旧文件(连同被一并删掉的父目录)重建出来,
  界面还报「已保存」。仓库里于是同时留下新旧两份,新名字那份是旧内容。
- 删除后:连「有未保存改动,确定关吗」都不弹(`closePathTabs` 同样只遍历底部
  工作台),Ctrl+S 直接复活刚删掉的文件。

改动:

- `NativeTabRecords.pathTabs()` 按路径枚举原生记录(带 seat session),
  `NativeSurface.fileTabs()` 把它交给调解;`installedNativeSurface()` 是插件自身
  读原生承载面的句柄(模块级,与 `editor-dirty.ts` 同款「每次激活一份」)。
- `tree-mutations.ts`:两个页签空间一起遍历;改名按**子树**匹配(与删除同口径,
  此前只有删除覆盖子树,目录改名时子树里的页签连底部工作台也不改道);原生页签
  的关闭带上自己的 seat session。
- 改名**不重载文档**:`path` 变化原本会让编辑器重载,而重载会换掉文档并丢掉只存在
  于编辑器实例里的草稿——可改名并没有改字节。现在 `retargetPathTabs` 用
  `markRetargetedPath` / `consumeRetargetedPath` 把这次移动交给编辑器认领:文档与
  草稿留着,下一次保存落到新名字;没有这个标记的 `path` 变化(真实切换文件)照旧
  加载。
- `tab-adapter.tsx` 的 `ensure()`:`path` 与 `meta` 一样,只被「尚未采纳的导航修订」
  覆盖。原生承载面每次渲染都重投同一次导航,无条件按地址改 `path` 会把插件侧的
  改址当渲染垃圾丢掉——调解刚改完,下一次渲染就改回旧名字。
- 设计文档补实施偏差:`docs/plans/2026-09-04-file-tree-rename-delete-design.md`。

用例:`tests/editor-unsaved-guard.spec.tsx` 新增 `tree rename/delete
reconciliation`(原生页签改名改址、目录改名两个空间都改道、改名不重读文件且草稿
仍在、删除时脏页签先问、目录删除连子树关);`tests/native-surface.spec.ts` 新增
`path enumeration and the navigation gate`(枚举只含带路径的记录、插件侧改址扛得住
同修订重投、新修订仍按地址改回)。

复查后收紧(三支独立评审小队 + 自查收敛到同一处):

- `retargetedPaths` 的键由「tab id」改成「编辑器看到的那一侧会话 + tab id」
  (`pathTabKey`,写方与读方共用同一处定义):原生 tab id 每会话各自计数(`tab1`
  每个会话都有),只按 id 记键时两个会话的编辑器共用一个槽——其中一个(哪怕它自己
  的路径没动)在清理时会抹掉另一个尚未认领的移动,被抹掉的那个照旧重载、照旧丢草稿。
  同一键仍允许一个移动被认领多次(两个席位显示同一会话的文件时)。
- 生命周期补齐:`clear` 现在按细键生效,编辑器卸载时回收,删除关闭页签时也回收
  (原先只增不减:每次「改名没被已挂载编辑器认领」都会留一条)。
- `View` 记下 seat session:`pathTabs()` 不必再从视图键里拆 session,`retain()` 也
  不再重复同一份拆分(键只是内部编码,不该被别处解析)。
- 子树尾段改用 `paths.ts` 的 `relativeTo`(分隔符与大小写口径与全仓其它相对路径
  统一;原先手写的 slice 在旧路径带尾分隔符或大小写不同拼写时会算错);顺手删掉
  一条与既有用例重复的回归用例(`native-surface.spec.ts` 既有的「同记录二次
  ensure 且无 revision 时 path 跟着走」已经钉住同一事实)。
- **两种路径拼写**:聊天文件链接打开的页签,`path` 来自地址,而 `fileAddressFor`
  在工作区内一律写相对拼写(`src/a.ts`);文件树改名给的却是绝对路径。最初按原样
  比较,这类页签(正是默认打开方式)会整条判成「无关」,仍绑在刚被改名掉的旧名字
  上。现在比较统一在「按会话 cwd 解析后的绝对拼写」上进行,写回记录时用调用方给的
  新名;`movedPath` 的相等判断改用 `relativeTo` 的 `.`(字符串相等在 `E:/a` 与
  `E:\a` 混拼时会把 `新名/.` 写进记录)。
2026-10-10 22:19:07 +08:00
Menghuan1918 45285014d9 merge fix/826-file-link-line-jump into dev(#826 第二半:行号不再被解析完就扔掉。两种写法合流到同一个字段——#L131 由宿主解析成 navigation.params.line、path:131 由插件在 path-line.ts 切出,都落到 SidebarTab.line,再经 FileViewerProps.line 交给 viewer;TextEditor 到达时定位一次并高亮,越界钳到最后一行,区间只取起始行。line 是瞬态(sanitizePersistedTab 白名单不含它,刷新不把读者拽回旧行);markdown/html 收到行号先强制切到编辑态再定位,避开预览自己的挂载滚动恢复。公开面是纯增量:FileViewerProps.line?: number)
# Conflicts:
#	docs/external-plugin-guide.md
2026-10-08 22:20:45 +08:00
Menghuan1918 e4a4c3fa4c merge origin/dev into feat/774-terminal-tab(#774 收尾前置)
dev 前进 12 个提交(titleBar 让位机制整体移除、#132 新建文件与排序三档、
#817 后台激活改标记未读、#412 Windows「在应用中打开」候选链等)。两处冲突,
都是「双方各自新增的内容」,无实质取舍:

- CHANGELOG.md:Unreleased 保留双方条目。#774 一组在最上(本分支的新条目),
  其后是 dev 的「移除 titleBar 让位机制」「#132 新建文件 / 排序」一组,再往下
  是既有的 #109 / #203 一组(与文件里原有的空行分组一致)。
- tests/e2e/mount.e2e.ts:只在下一条用例的标题行冲突——保留本分支新增的底部
  终端用例(#774),标题取 dev 侧的新名(`a shell-stamped render URL mounts
  normally; …`;dev 已把 WCO / preset 两条场景删掉)。
- 21 份词典、AGENTS.md、docs/external-plugin-guide.md、README 自动合并:dev 删的
  12 个 titleBar 词典 key 保持删除,本分支新增的 3 个 terminal 词条保持新增。
2026-10-06 00:07:23 +08:00
Menghuan1918 95db9e4d42 feat(tabs): TabDescriptor.bottomOnly —— 只投底部、永不占原生承载面
#774 的第一条硬约束是「插件的底部终端绝不能变成宿主右列里的第二个
终端入口」(挂载 lane 钉住宿主 terminal guide 条目恰好 1 条)。已有的
两个字段都做不到:`hidden` 会连底部 + 菜单一起摘掉
(buildNewTabOptions 过滤 !hidden),而注册成普通描述符就会自动拿到
原生 tab 类型 + guide 条目。

新增一个显式的 `bottomOnly?: boolean`,效果两处,缺一不可:

- `openTab` 的原生分支条件加 `descriptor.bottomOnly !== true`:落点强制
  bottom(连 `target: 'side'` 也改道)。原生栏里的 tab 不在底部工作台的
  分栏树里,把只投底部的页面送进原生栏是归属矛盾。
- 原生承载面(src/client/native/index.ts 的 sync())跳过它:既不注册
  tab 类型,也不占 guide 条目。

字段带完整文档注释(含与 hidden 的区别、内置用例 terminal-bottom)。
接入文档同步在下一个 docs commit。
2026-10-05 23:42:40 +08:00
Menghuan1918 de1e76e2f5 feat(sidebar): 后台激活的页面不再顶掉读者,改为标记未读红点
维护者在 #817 上批准了「后台自动激活不接管右侧栏」的行为,并要求同批补上
「后台新开了页面」的提示:事件不能丢,但也不能把读者正在看的页面顶走。

行为:
- 被门控跳过的那次激活仍然创建任务管理页,只是不再抢焦点
  (`OpenTabSeed.reveal: false` → 宿主 `revealIfOpened: false`,即
  「放置但不聚焦」;页面类型本来就没有自己的聚焦路径,已经存在的页面
  再开一次也只是一次聚焦,正是门控要拒绝的那件事)。
- 该页在原生右栏芯片与插件底部工作台对应页签上显示一个静态小红点
  (`aria-label` = 新词条 `tabUnread`,颜色取既有 `--dsw-alias-danger`)。
- 读者切到该页即清除标记:底部工作台走 service.activateTab;原生栏的
  点击插件看不见(`ISidebarRight` 只有 `active()` 读取器,没有选中事件流),
  所以由宿主自己的芯片按 `tab.visible` 清除——非可见芯片不清除,
  否则宿主为每个展开页签都画标题,红点刚亮就会被抹掉。
- 标记存进会话状态的 `unread: TabType[]`(随布局持久化,跨挂载/跨会话/
  刷新都在),两个承载面读同一份,不会各自为政。

文案:20 份词典同批更新两条设置项描述(门控行为变了)+ 新增 `tabUnread`
词条(ja 真日文)。

测试:`tests/sidebar-auto-activation.spec.tsx` 的门控两条改为断言
「页面仍创建 + revealIfOpened:false + 标记出现」,并加红点生命周期与
「已在任务页/正常激活不标红」三条;新增 `tests/native-tab-unread.spec.tsx`
钉住原生芯片这一承载面(画点、按 visible 清除、非可见不清除、别的类型
不串味、不破坏可访问名)。判别性用 6 处镜像还原逐条证伪(见报告)。
2026-10-05 23:03:40 +08:00
ymac 415d517fb0 fix(editor): make a file reference land on its line (#826 second half)
`fileParamsOf` already split the `path:line` spec off the address (#828)
but kept only `spec.path` — so both spellings opened the file and left the
reader on line 1: `path:131` dropped the parsed line, and the host's own
`#L131` fragment was already delivered as `navigation.params.line` and
dropped just the same.

Carry the line the rest of the way: address → `SidebarTab.line` →
`FileViewerProps.line` → one reveal in the text editor. Both spellings
land on the same row.

Three decisions:

- `line` is transient: `sanitizePersistedTab` copies a whitelist and this
  field is deliberately left out of it, so a reload does not yank the
  reader back to a line a link named days ago. Same treatment as
  `revealed`.
- markdown/html flip out of preview when a line is present: preview has no
  source lines to put a cursor on, and its own mount-time scroll restore
  would fight the jump (both write the same `scrollTop`). The reference
  asked for source, so the flip does not record the key and the re-run
  after the mode change does the jump — which also dissolves the conflict
  instead of arbitrating it.
- A range keeps only its first line and the column is dropped: the editor
  has exactly one cursor.

The record must also be able to DROP the line, not only set it — an
in-place switch from `a.ts:131` to a bare `a.ts` would otherwise leave 131
behind and the editor would bounce the reader back on every notification.
Comparing against the current value instead of "was one passed" also keeps
the synthetic record's identity when neither side has one, which matters
because the host keeps visited bodies mounted.
2026-10-05 22:17:44 +08:00
Menghuan1918 acea3c9a65 fix(sidechat): bind the native side chat tab to its thread across re-navigation
The native right sidebar keeps at most ONE page tab per kind, so a side chat
tab is never a copy: every open re-delivers the same tab with fresh navigation
params and an incremented `navigation.revision` (verified in the pinned host's
client bundle: `TabDomain.navigate` replaces the whole target and bumps the
revision, and `openContent` settles an already-held page tab through it). Two
opposite mistakes followed from that: `records.ensure` only read the seed
`meta` when it MINTED a record (so the header thread menu closed and nothing
changed — #762), while adopting it on every pass would clobber the thread id
the view writes back through `updateTab` (the orphan `Side: New thread` half of
#684).

Adopt a navigation's `params.meta` exactly once per revision, and reattach an
unbound auto-creating tab to the thread its session was last in instead of
minting another empty one.

Rewritten against the current dev tree rather than merged from the PR:

- #776 (7cf9626) made a record key `(seat session, native tab id)`; the
  revision ledger is keyed the same way and is dropped together with the
  record — in `drop` AND in `retain(sessions)`, which also forgets records.
- dev's existing branch never wrote `meta` and folds a url seed into
  `nextPath`, so the PR's url/meta merge has no counterpart here and is
  deliberately not ported: "revision unchanged" simply leaves `meta` alone,
  which is what keeps #684's other half fixed.
- `updateTab` takes the seat session as its third argument (same commit), so
  the reattach names it like the rest of the view does.
- The "newest real thread, placeholders last" heuristic already exists on dev
  (477f627, the archive fallback); it is extracted into `newestThreadId` and
  reused instead of being copied a second time.
- The remembered thread uses the client store's key space
  (`dsh-sidebar:v1:sidechat-thread`), not the PR's `dsh-better-sidebar:*`.
- `openNewThread` starts the thread first and parks it for `createTab`, and an
  auto-creating tab no longer offers a manual create button while it binds.

Tests (the PR reported none): the revision gate, its no-revision guard (both
fail on the unported adapter), the call-site wiring through `NativeTabBody`,
plus the two dev-side records cases around them.

Refs #839
2026-10-05 02:19:58 +08:00
Menghuan1918andwaser0434 900b1592e1 fix(sidechat): bind the native side chat tab to its thread across re-navigation
The native right sidebar keeps at most ONE page tab per kind, so a side chat
tab is never a copy: every open re-delivers the same tab with fresh navigation
params and an incremented `navigation.revision` (verified in the pinned host's
client bundle: `TabDomain.navigate` replaces the whole target and bumps the
revision, and `openContent` settles an already-held page tab through it). Two
opposite mistakes followed from that: `records.ensure` only read the seed
`meta` when it MINTED a record (so the header thread menu closed and nothing
changed — #762), while adopting it on every pass would clobber the thread id
the view writes back through `updateTab` (the orphan `Side: New thread` half of
#684).

Adopt a navigation's `params.meta` exactly once per revision, and reattach an
unbound auto-creating tab to the thread its session was last in instead of
minting another empty one.

Rewritten against the current dev tree rather than merged from the PR:

- #776 (7cf9626) made a record key `(seat session, native tab id)`; the
  revision ledger is keyed the same way and is dropped together with the
  record — in `drop` AND in `retain(sessions)`, which also forgets records.
- dev's existing branch never wrote `meta` and folds a url seed into
  `nextPath`, so the PR's url/meta merge has no counterpart here and is
  deliberately not ported: "revision unchanged" simply leaves `meta` alone,
  which is what keeps #684's other half fixed.
- `updateTab` takes the seat session as its third argument (same commit), so
  the reattach names it like the rest of the view does.
- The "newest real thread, placeholders last" heuristic already exists on dev
  (477f627, the archive fallback); it is extracted into `newestThreadId` and
  reused instead of being copied a second time.
- The remembered thread uses the client store's key space
  (`dsh-sidebar:v1:sidechat-thread`), not the PR's `dsh-better-sidebar:*`.
- `openNewThread` starts the thread first and parks it for `createTab`, and an
  auto-creating tab no longer offers a manual create button while it binds.

Tests (the PR reported none): the revision gate, its no-revision guard (both
fail on the unported adapter), the call-site wiring through `NativeTabBody`,
plus the two dev-side records cases around them.

Refs #839

Co-authored-by: waser0434 <178004182+Waser750@users.noreply.github.com>
2026-10-05 02:19:58 +08:00
Menghuan1918 9c8d5c62ed merge #574 into dev(工作区提及重放到 reference-in-chat 新载体,复用 mentionFor)
冲突是载体搬迁,不是语义作废:

- `@` 回调的载体在 dev 已是 src/client/reference-in-chat.ts(#479 eed2fee 抽出的
  两侧共享入口)。PR 新增的 `insertWorkspaceReference` 与 `directoryMention`
  落在 conversation-draft.ts(它要用同模块的 appendToDraft /
  insertFileReference / mentionFor),由该入口转发;Sidebar.tsx 只保留转发,
  native/tab-adapter.tsx 与之同步,两个调用点不再传 cwd(工作区 root 由
  `ctx.get('workspaces')` 的会话成员匹配得到,不再回退会话 cwd)。
- PR 的 `directoryMention` 改为委托 dev 的共用构造器 `mentionFor(path, 'folder')`
  (#479 把「尾斜杠进引号」的规则收进它),不再自建一套引号规则;
  `insertWorkspaceReference` 的文件分支同样换成 `mentionFor(path, 'file')`。
- tests/paths.spec.ts:`resolveSidebarPath` 的导入走已搬迁的 src/client/paths.ts
  (produced-files.ts 已不存在),并存的 preview URL 用例与 workspaceRelativePath
  用例两块都保留。
- tests/reference-in-chat.spec.ts(#479 验收 spec):fake ctx 补上它现在要读的
  workspaces 面、调用点去掉 cwd,三处草稿断言跟随本 PR 的目录尾随分隔空格;
  引号与宿主 token 可读性的断言逐字未动。

Refs #574
2026-10-05 01:55:36 +08:00
Atlas Zeng b2599b390b Merge pull request #802 from zhanghunuaa/feat/follow-active-worktree
feat(sidebar): 文件树跟随会话实际所在的 git worktree(含跨仓库 linked worktree)
2026-10-05 01:39:22 +08:00
Menghuan1918 c5d8b13aa7 merge #802 into dev(文件树跟随活动 worktree,按 dev 原位解冲突)
三处冲突都是 main/dev 侧后插入行与变量改名造成的上下文漂移,被改的目标代码在
dev 上逐字仍在,按 dev 原位解(不是回退到 PR 的旧上下文):

- src/index.ts 导入区:保留 dev 新增的 FS_TREES_MAX_PATHS 导入与注释,同时加
  activeWorktreeRootOf 导入——两边都要;
- src/index.ts /sidebar/file 路由:保留 dev 的路径解析注释(dev 里本来就重复了
  一份,本次不顺手清理,避免把无关改动混进合并),cwd 改走 activeWorktreeRootOf;
- src/client/Sidebar.tsx:删掉 summaryCwd(改由 useSessionRoot 提供根),保留
  dev 插入的「空白会话」注释;
- src/client/native/tab-adapter.tsx:保留 dev 的 seat/scope 双会话命名与注释,
  useSessionCwd(ctx, scopeSessionId) → useSessionRoot(ctx, scopeSessionId)。

落地方另修三处(PR 自带 spec 在本机 macOS 上红,逐条有实测证据):

1. src/active-worktree.ts 的 normalizeActivePath 把分隔符一律折成反斜杠,POSIX
   路径随即不再 isAbsolute 而被 addActivePath 丢弃——该特性在 Linux/macOS 上
   静默空转(只在 Windows 上有效)。改为折成平台分隔符 sep;Windows 上 sep 就是
   反斜杠,行为不变。
2. active-worktree.ts 的根缓存改到 git 探测之前查询,并缓存「不在仓库里」这一
   结果:探测是一次真实 spawn(实测 ~6.5ms/次),此前每个 watch 帧、每个路由
   调用都要付一遍。dev 的 tests/zip.spec.ts「第 5 个并发构建被拒」正因此从 5/5
   绿变成 5/5 红(A/B:只回退 cwdOf 包装即恢复绿),本改动后该用例恢复 5/5 绿。
3. tests/active-worktree.spec.ts 的期望值改用 realpathSync.native:根来自
   `git rev-parse --show-toplevel`,本就是规范化路径,macOS 的 /var →
   /private/var 会让 resolve() 断言恒红(与 tests/git-worktree.spec.ts 同款写法)。

Refs #802
2026-10-05 01:35:58 +08:00
Menghuan1918 582f814d5e merge #828 into dev(fileParamsOf 剥掉 path:line 行号后缀,解上下文冲突)
贡献者 PR #828(fix/826-file-link-line-suffix,2c5b762)修 issue #826:
宿主 markdown 语法只认 `#L131`,`path:131` 会被 parseFileLink 整串当文件名,
editor tab 于是去读一个叫 `CMakeLists.txt:131` 的文件并报「文件不存在」。
改法是在插件唯一把文件地址转成合成记录的那一步(native/index.ts 的
fileParamsOf)切掉尾部行号规格,tab 标题同源修正;新增纯函数
src/client/path-line.ts 与 tests/path-line.spec.ts。

解冲突:只有 tests/native-surface.spec.ts 的第 9 行 import 块冲突。
dev 侧多了 `import { createNativeSurface } from '../src/client/native/surface.ts'`
(PR #696 移植),PR 侧把同一行改成 `import { fileParamsOf, registerNativeSurface }`。
两边都要,合为两行;docs/external-plugin-guide.md 由 git 三方合并自动解掉
(PR 新增的「地址里的行号(#826)」行与 dev 新增的「文件打开的认领判定」行并存)。
未改贡献者任何实现意图,未 rebase / squash 其提交。

Refs #828
2026-10-05 01:30:34 +08:00
ymac 2c5b7621dd fix(editor): 正文里 [path](path:131) 的链接去掉行号后缀再打开 (#826)
DSH 的 markdown 链接语法只认 GitHub 的 `#L131` 片段:目的地没有 `#` 时
`parseFileLink` 把整串当文件名返回。于是模型按编译器诊断的通用写法输出的
`[a/b.c](a/b.c:131)` 变成一次对 `b.c:131` 的文件打开,编辑器读不到、右侧栏
红字报「文件不存在」。

宿主源码不可改,纠正放在插件唯一把文件地址变成合成记录的那一步
(native/index.ts 的 fileParamsOf):尾部行号规格(`:行` / `:起-止` /
`:行:列`)在这里切掉,tab 标题按切完的文件名给(宿主用同一个字符串推导标题,
否则芯片上会写 `b.c:131`)。切完之后读、写、"打开方式"、去重、viewer 匹配
拿到的都是真实路径,所以没有需要重试或记住的状态。

切分规则与宿主的 `#L` 语法对齐:1 起、无前导零、锚在串尾(`data:2024.csv`
和盘符 `C:` 因此原样通过),并拒绝空前缀、只剩一个字符的前缀(`C:131`)和
倒序区间(`a.c:20-12`)。

取舍:从聊天链接打开一个真名以 `:数字` 结尾的文件会丢掉后缀。文件树 / 搜索 /
插件自有流程的路径不经过这一步(只有 `openResource` 的地址会),而 `:` 在
Windows 上本就不是合法文件名字符。

测试:新增 tests/path-line.spec.ts(9 例,含全部「必须原样通过」的反例);
tests/native-surface.spec.ts 补 fileParamsOf 四例 + editor 类型对带行号地址的
标题。typecheck / lint 全绿;全量 1503 passed,tests/locales.spec.ts 的 ja
词典缺 key 在干净 origin/main 上同样失败(既有问题,不在本 PR 范围)。
2026-10-01 22:05:56 +08:00
HuanLinOTO ea76981c0e Merge PR #697: fix(native): 跨会话打开改为排队到上屏重放(Fixes #694)
# Conflicts:
#	src/client/native/surface.ts
2026-10-01 17:13:47 +08:00
HuanLinOTO 86ec5ccc75 Merge PR #736: fix(native): focus through the controller on surface.activate; carry meta on close
# Conflicts:
#	docs/external-plugin-guide.md
#	src/client/native/surface.ts
#	src/client/service.ts
2026-10-01 17:12:53 +08:00
HuanLinOTO 92ab1f83b8 Merge PR #776: fix(native): 按会话记账 + 宿主 keepMounted,原生 tab 状态不再跨切换丢失(#636 #661)
# Conflicts:
#	src/client/native/index.ts
#	src/client/native/tab-adapter.tsx
2026-10-01 17:12:10 +08:00
HuanLinOTO 4e02951fb5 Merge PR #662: fix(native): 文件 tab 图标不再依赖插件侧记录(Fixes #660)
# Conflicts:
#	src/client/native/index.ts
2026-10-01 17:11:37 +08:00
HuanLinOTO 84d93ba6ce Merge PR #718: fix(native): keep a link's url seed on the tab it opens
# Conflicts:
#	src/client/native/tab-adapter.tsx
2026-10-01 17:11:15 +08:00
ymac d1c8208d56 Merge origin/main (v0.24.1, DSH 0.2.0-rc.1) into fix/native-tab-state-retention
Two conflicts, both in the native tab adapter's per-session work — main's
`5c95002` moved the expansion set into the plugin store's session state while
this branch moved the RECORD identity to `sessionId::tabId`:

- `src/client/native/tab-adapter.tsx`: keep main's store-backed expansion as
  the authority (`attachStore` / `syncExpanded` / `getSessionStates().expanded`)
  and this branch's seat-scoped identity (`views` keyed `sessionId::tabId`,
  `get/has/update/drop/versionOf/retain` take the seat session). `toggleExpanded`
  keeps main's active-`reduce` / background-`reduceFor` split, but locates the
  record by its seat and writes the SCOPE session's set — the set every view of
  that session mirrors.
- `tests/native-surface.spec.ts`: main's five expansion cases adapted to the
  session-scoped API (seat session on `ensure`, two-arg `get`/`drop`, seat on
  `toggleExpanded`); the branch's cases now bind a store before toggling, since
  expansion no longer lives in the record itself.

The `files` takeover guard and its registration invariants come from
main; this merge drops the branch's duplicate.
2026-10-01 16:37:35 +08:00
张虎 ef9c750df0 fix(sidebar): 原生右侧栏文件树也跟随会话实际 worktree(共享 useSessionRoot) 2026-09-29 14:56:06 +08:00