Commit Graph
8 Commits
Author SHA1 Message Date
vlln a64f5cd8e9 feat(git-graph): 图谱视图与统一的底部面板(详情 / 内容 / 差异)
**图谱视图**(`GitGraphLens`):分支下拉框只筛选历史,不做任何写操作;提交行
是一行 28px——泳道连线 + 引用徽章 + 标题。徽章带图标(本地分支 = 分支图标、
远程跟踪分支 = 地球),`HEAD` 不单独成徽章,而是折叠进当前分支的徽章里做前置
✓;徽章的颜色就是它所在车道的颜色,和连线、圆点走同一个五色映射。行上不再
有短 hash 与作者时间:hover 350 ms 弹一张中等密度的卡片(标题、徽章、作者·
相对时间、短 hash + 绝对日期),点击后看到的「详情」才是完整信息(完整 hash、
父提交、Markdown 正文)。列表到底自动加载下一页(IntersectionObserver +
在飞守卫),并保留手动按钮作为兜底。

**底部面板**:三个视角共用同一个可拖拽区域,标签集合**固定**为
`提交详情 / 内容 / 差异`,不随上方视角或选中项变化;没有内容的标签显示空态
(未选择提交 / 读取没有差异 / 此视图暂无内容)而不是消失——此前按选中项推导
标签集合,同一个面板看起来像三个不同的面板。选择、高度、激活标签都持久化。

**内容视图**:操作记录(read 的带行号源码;md/html/pdf 用插件自己的渲染器)
与 git 工作区文件(`fs.read` 读文件本身,二进制/超大走既有下载面板)并列。
读取是懒加载的:只为看 diff 打开文件时不会去读整个文档。md 默认渲染,html
默认源码、点了才渲染 iframe(沿用「选中不自动加载 iframe」的沙箱契约)。

**配色**:五个色槽全部用状态色令牌(business/success/warn/error + 次级灰)。
原来槽位 0 用 `brand-primary`,实测在深色主题下是 rgb(15,17,21),主线几乎
不可见——状态色是给细线和小字设计的,两种主题下都能读。

顺带:Git 视角把当前仓库 / 工作树报给父组件(`onTargetChange`),图谱与预览
才能跟着同一个目标走。

测试:`tests/git-graph-ui.spec.tsx`(19 项:请求时机、错误与重试、分页游标、
竞态与中止、行结构、HEAD 折叠、hover 卡片、自动加载)、`tests/changes-tab.spec.tsx`
(固定三标签在各视角一致、内容视图懒加载、箭头键在标签间移动)、
`tests/markdown-surface.spec.tsx`(内容视图里的 markdown 链接认领)。
2026-10-15 20:44:33 -07:00
Menghuan1918 99db903255 docs(readme): README 拆成英文默认版 + 中文 README_ZH.md,锚点守卫改用固定 fixture
- README.md 改为英文默认版,README_ZH.md 承接原中文 README,删除 README_EN.md;package.json 的 files 清单同步
- CHANGELOG.md / CHANGELOG_EN.md 顶部「最新版摘要」链接改指 README_ZH.md
- 特性区重排为表格布局并换用仓库内截图(docs/screenshots/*.png),README 里的目录(TOC)整块去掉
- 两条锚点守卫用例原本拿仓库 README 当真实文档(emoji 标题 + TOC 锚点 0/16 的回归),README 去掉目录后改用 tests/fixtures/github-toc-anchors.md 承载同一形状(emoji 标题 / U+FE0F 变体选择符 / & 转双横线):markdown-slug 只换文档来源,markdown-surface 的 CRLF 与「逐锚点点击真的滚动」两条同样改读 fixture,判别力不变
- tests/install-powershell.spec.ts 的 README 清单同步(README_EN.md → README_ZH.md)

维护者收尾:合并 origin/main(454afaf)后把「微信群二维码换新资源」移植到 README.md / README_ZH.md(旧资源 5d727d52 已换成 e9c77c37)
2026-10-15 21:52:59 +08:00
ymac 68d6c33025 fix(markdown): 预览里的 #L131 链接也带上行号(#826 收尾之二)
插件自绘的 markdown 预览(编辑器预览 / 侧边对话转录 / 变更阅读窗 / 任务窗口)
里点 `./other.md#L42`,文件打开了却不跳行——而且停在预览态,源码被当成段落
渲染成一坨。聊天正文里同一个链接能跳:那一侧的 `navigation.params.line` 由宿主
解析后落进记录,而插件这一侧的 delegate `openFile(path, { line })` 收到的行号
只被当成「这是行号不是标题锚点」的判据,随后 `openSidebarFile` 就把它丢了
(种子没有 line 字段,原生分支的 `surface.openResource` 也没传——末跳本身是
支持的)。

补齐三跳:`use-markdown-surface` 把 `options.line` 传下去(拿不到时按宿主语法
自己解析片段,新增 `lineOfHostFragment`,区间取起始行),`openSidebarFile` 与
`OpenTabSeed` 各带一个可选 `line`,`openTab` 的原生分支转发给
`surface.openResource`、底部工作台的 mint 落进 tab。落地后的行为与聊天正文那条
一致:跳到那一行,markdown/html 离开预览(预览里没有源码行号),并且——承上一条
提交——读者随时能点回预览。

测试:markdown-surface.spec.tsx 走真实宿主 MarkdownText 点链接,钉住 `#L42` 与
`#L20-L25` 进记录、标题锚点仍然只走 parked 片段;markdown-navigation.spec.ts 钉
新解析器;file-open-claim.spec.ts 钉种子透传与「不传就不带这个键」。
2026-10-11 12:02:55 +08:00
Menghuan1918 ee5be9b601 fix(markdown): read a CRLF document exactly like its LF twin (#363)
The markdown pipeline's line-based scanners split on `\n` and then reason
about each line, so a Windows checkout (`core.autocrlf=true` — the
`ci-windows` lane) broke three of them at once:

- `splitHtmlBlocks`'s blank-line test (`/^[ \t]*$/`) read a CRLF blank line
  (`'\r'`) as content, so an HTML run never ended: on this repo's own README
  the splitter produced 4 segments instead of 36, and the markdown after a
  `<div>` run was rendered as raw text.
- `CLOSE_FENCE_RE` (`[ \t]*$`) never matched a CRLF closing fence, so
  `splitMermaidBlocks` swallowed the rest of the file and the splitter's own
  open-fence state never closed.
- `closesFence` (`/^[ \t]*$/`) left every CRLF fence open, so
  `maskCodeRegions` masked from the first fence to the end of the file and
  the link rewriter stopped claiming every `.md` link after it (first
  divergence on README.md: `./CHANGELOG.md%23v0230`, claimed under LF, left
  as an inert `#v0230` destination under CRLF).

The editor preview rendered the document twice as well: its draft snapshot
publishes CodeMirror's live document — always LF, whatever the file used —
one commit after mount, and that CRLF→LF re-render makes the host rebuild the
markdown elements whose text changed, discarding the heading ids the surface
pass had just written (the MutationObserver only heals them a microtask
later). Line endings are not an edit: the snapshot now keeps `draft` null
while the live document is the loaded content under any line-ending spelling.

Tests: `scanDocumentAnchors` and the README TOC slice split on `/\r?\n/`;
tests/markdown-crlf.spec.ts pins the CRLF≡LF invariant across the splitter,
the mask, both rewriters and the mermaid splitter, and two surface cases
mount a CRLF document through the real renderer — one of them a CRLF copy of
the README, so every lane exercises the spelling only `ci-windows` checks
out. Reverting the `\r` fixes turns nine of them red.
2026-10-06 00:54:24 +08:00
Menghuan1918 fab329d469 fix(markdown): match GitHub's heading slug and mask ~~~ fences (#363)
Two defects the independent verification rejected, plus the test gaps they
left behind.

1. `githubHeadingSlug` was not GitHub's slugger. It trimmed and collapsed
   whitespace runs (GitHub does neither: every space becomes its own dash) and
   kept `\p{M}`, which left the variation selector of `🖼️` inside the id. The
   consequence was the issue's main scenario: the repo's OWN READMEs resolved
   **0 of 15** table-of-contents anchors, and the click was claimed yet did
   nothing (`scrollTop` stayed 0). The slug is now `toLowerCase()`, drop
   pictographs / `\uFE00-\uFE0F` / regional indicators / `\p{C}`, drop
   everything that is not a letter, digit, combining mark, space, `-` or `_`,
   then each space → `-`. Emoji are removed here because GitHub removes them
   while RENDERING the heading (to `<img>`) before its slugger runs; that is
   the one deliberate difference from `github-slugger`, and it is what turns
   `🚀 安装` into GitHub's real `-安装`.

2. Both source rewriters inlined a fence mask that only recognised ```, so a
   link or image demonstrated inside a `~~~` fence was rewritten
   (`[y](./b.md#u)` → `[y](./b.md%23u)`; the image half predates this feature:
   `rewriteLocalImageUrls('~~~\n![i](./p.png)\n~~~')` already produced a
   `/sidebar/file` URL on 58d7f71). One shared mask now lives in
   `src/client/markdown-code.ts` (CommonMark: 3+ backticks OR 3+ tildes, a
   closing fence no shorter than its opener, an unclosed fence running to the
   end of the text) and both passes use it.

Evidence (all on the merged tree, HEAD after `git merge origin/dev`):
- Real `TextEditor` + real host `MarkdownText`, every TOC anchor clicked:
  README.md `0/15 → 15/15`, README_EN.md `0/15 → 15/15` (shipped as a case in
  tests/markdown-surface.spec.tsx; the id-level counts are 0/16 → 16/16).
- Parity against the actual `github-slugger@2.0.0` regex (vendored in
  tests/helpers/github-slug-reference.ts), plus explicit emoji/VS16 cases.
- Mutation: restoring the old trim+collapse+`\p{M}` slug reddens 9 cases
  (both README cases included); dropping the tilde fence reddens the new
  fence case in BOTH the link and the image spec; forcing `scrollHostFor` to
  return the container reddens the two new ancestor-scroller cases.
- `scrollHostFor`'s ancestor branch was unreachable from the shipped suite
  (the mutation above used to leave 33/33 green): tests/markdown-surface.spec.tsx
  now injects the computed style (`overflowY: auto` + `scrollHeight`/
  `clientHeight`) and asserts the write lands on the ancestor, that neither
  `window.scrollTo` nor `scrollIntoView` is called, and that the container's
  own `scrollTop` is never written.

Also: the untrue "exactly like GitHub does" comment, four-form fence cases per
pass (``` / ```` / ~~~ / an inline span inside ~~~), a CHANGELOG entry, and the
recorded narrow edges (a destination with an escaped parenthesis or a
single-quoted title is not claimed — plain text, unchanged; `#L24` does not
jump to a line).

Gates: typecheck / lint clean, `vitest run --maxWorkers=3` 182 files, 2120
passed | 13 skipped; `pnpm build` complete; mount lane
(`DSH_CMD='npx -y --package @deepseek-ai/dsh@0.2.0-rc.1 dsh' pnpm test:mount`)
9 passed (2.0m), exit 0. The bare `pnpm test:mount` now dies in preflight
because the installed CLI is 0.2.0-rc.2 while the baseline pins 0.2.0-rc.1;
the lane count is 9 rather than the verifier's 11 because merging origin/dev
removed the two WCO/preset cases with the titleBar mechanism.
2026-10-06 00:19:11 +08:00
Menghuan1918 ab0d40dee8 test(markdown): give each case its own session; encode a query inside a carried fragment (#363) 2026-10-05 23:51:31 +08:00
Menghuan1918 2ac881d10b test(markdown): cover the changes reading pane, line destinations, hidden anchors (#363) 2026-10-05 23:47:28 +08:00
Menghuan1918 cfe84c99b3 feat(markdown): claim local .md links and navigate headings across files (#363)
Markdown surfaces the plugin draws (editor preview, side-chat transcript,
changes reading pane, task note) now open local markdown links in the sidebar
and follow same-page / cross-file heading anchors.

The host renderer decides what a local destination even is: without a
`MarkdownDelegateProvider.openFile` a local link renders as plain text (there is
no `a[href]` to intercept), and `parseFileLink` accepts a fragment only in the
line grammar (`#L24`), so a heading fragment makes the whole destination
unparseable. So the claim is scoped by the provider (one per surface) and a
SOURCE pass carries a heading fragment past the parser as `%23` — the same shape
markdown-images.ts already uses for relative image destinations. Destinations
the plugin does not claim (non-markdown, remote, queried) keep rendering exactly
as they do today.

- `markdown-navigation.ts`: pure link judge + GitHub heading slugs (Chinese kept,
  duplicates `-1`, authored ids reserved first), collapsed-anchor hiding, the
  source rewrite, the jump that scrolls the surface's OWN scroller (never
  `window`/`scrollIntoView`), and the session+path keyed pending fragment table.
- `use-markdown-surface.ts`: one hook per surface — the container callback ref
  (DOM pass + mutation re-runs + pending fragment) and the delegate's `openFile`.
2026-10-05 23:43:14 +08:00