diff --git a/README.md b/README.md index 888535ad..5764d348 100644 --- a/README.md +++ b/README.md @@ -22,12 +22,16 @@ | | | |---|---| -| **🗂️ File Management**
Lazy-loading tree, git status colors, live directory watch, global search, drag-and-drop upload, multi-select batch actions, dual-source "Open with" menu.
File tree with git colors
Context menu: Open with + Zip and download | **🌿 Changes**
Git lens + this-session AI-changes lens in one: hierarchical tree, stage / commit / history, unified diff rendering (intra-line highlights + syntax coloring).
Changes: hierarchical tree | +| **🗂️ File Management**
Lazy-loading tree, git status colors, live directory watch, global search, drag-and-drop upload, multi-select batch actions, dual-source "Open with" menu.
File tree with git colors
Context menu: Open with + Zip and download | **🌿 Changes**
Git lens + this-session AI-changes lens in one: hierarchical tree, stage / commit / history, unified diff rendering (intra-line highlights + syntax coloring); a **read-only commit graph** (Git Graph) shows branch and merge topology.
Changes: hierarchical tree | | **📝 Editable Editor & Previews**
An editable CodeMirror (the stock preview is read-only), Markdown + Mermaid + floating outline, sandboxed HTML preview, `.jsonl` record cards, paged preview for huge files, streaming transfers with no size caps.
Markdown + Mermaid preview | **🧩 Tasks**
Live subagent topology (workflow graph / tree modes) + background task list: exit codes, live output, force-kill.
Tasks: subagent topology | | **💬 Side Chat (beta)**
Codex-style side threads: inherit the full parent context and run independently, realtime push, visible & revocable queue, per-thread model selection, one-click promotion to a top-level session.
Side Chat | **🖥️ Bottom Workbench**
A self-drawn bottom panel that coexists with the native right sidebar: drag-to-split panes, multiple terminal tabs, per-session persisted layout.
Dual workbench | **Also**: 📂 the `sidebar_open` tool lets the model open the sidebar itself · ⚡ ~325KB core at startup, heavy chunks load on demand · 🌏 i18n follows DSH · 📱 narrow screens switch to a full-width drawer +### 🌿 Git Graph (read-only commit graph) + +Switch to **Git Graph** at the top of the Git panel for commit nodes, forks and merge edges across local branches, remote-tracking branches and HEAD. The branch selector only filters history — it **never checks out or fetches**; each commit is one line (lane edges + ref pills + subject), hover shows the author and short hash, and selecting one opens its full message and diff in the bottom pane. History loads in pages; reference changes during pagination prompt a refresh; reads are bounded (200 commits per page, offset 10,000, 1,000 branches) and report an explicit error past a limit. This first version shows no tags and offers no history-changing actions. + ## 🚀 Installation ```sh diff --git a/README_ZH.md b/README_ZH.md index 5ef63303..a599c4ff 100644 --- a/README_ZH.md +++ b/README_ZH.md @@ -22,12 +22,16 @@ | | | |---|---| -| **🗂️ 文件管理**
懒加载目录树、Git 变更着色、实时 watch 刷新、全局搜索、拖拽上传、多选批量操作、「打开方式」双源菜单。
文件树(Git 着色)
右键菜单:打开方式 + 打包下载 | **🌿 文件变动**
Git 视角 + 本轮 AI 改动视角合一:层级树、暂存 / 提交 / 历史、统一 diff 渲染(行内高亮 + 语法着色)。
文件变动:层级树 | +| **🗂️ 文件管理**
懒加载目录树、Git 变更着色、实时 watch 刷新、全局搜索、拖拽上传、多选批量操作、「打开方式」双源菜单。
文件树(Git 着色)
右键菜单:打开方式 + 打包下载 | **🌿 文件变动**
Git 视角 + 本轮 AI 改动视角合一:层级树、暂存 / 提交 / 历史、统一 diff 渲染(行内高亮 + 语法着色);**只读提交图**(Git Graph)看分支与合并拓扑。
文件变动:层级树 | | **📝 可编辑编辑器与预览**
可编辑的 CodeMirror(官方预览是只读)、Markdown + Mermaid + 浮动目录、HTML 沙箱预览、`.jsonl` 记录卡片、超大文件分页预览、传输无大小上限。
Markdown + Mermaid 预览 | **🧩 任务管理**
子代理拓扑实时预览(工作流图 / 树双模式)+ 后台任务清单:退出码、实时输出、强制终止。
任务页:子代理拓扑 | | **💬 侧边对话(beta)**
Codex 风格侧边线程:继承主会话完整上下文独立运行、实时推送、排队可见可撤回、每个线程独立选模型、一键提升为顶层会话。
侧边对话 | **🖥️ 底部工作台**
自绘底部面板与原生右侧栏同时展开:拖拽分栏、多终端页签、按会话持久化布局。
双工作台 | **还有**:📂 `sidebar_open` 工具让模型主动打开侧边栏 · ⚡ 启动只拉 ~325KB 核心、重依赖按需加载 · 🌏 多语言跟随 DSH · 📱 窄屏自动切换全宽抽屉 +### 🌿 Git Graph(只读提交图) + +在 Git 面板顶部切到 **Git Graph**:本地分支、远程跟踪分支与 HEAD 的提交节点、分叉与合并连线。分支下拉框只筛选历史,**不会 checkout 或 fetch**;提交行是单行(泳道连线 + 引用徽章 + 标题),hover 看作者与短 hash,选中后在底部面板看完整提交信息与 diff。历史按页加载,分页期间 refs 变化会提示刷新;读取有上限(每页 200 条、偏移 10,000、分支 1,000),超限明确报错。首版不显示 tag,也不提供任何改写历史的操作。 + ## 🚀 安装 ```sh diff --git a/docs/plans/2026-10-16-git-graph.md b/docs/plans/2026-10-16-git-graph.md new file mode 100644 index 00000000..55213408 --- /dev/null +++ b/docs/plans/2026-10-16-git-graph.md @@ -0,0 +1,113 @@ +# 只读提交图(Git Graph) + +> 分支 `feat/git-graph`(基于 `dev`,DSH 0.2.0-rc.2 线)。 +> 触发:外部贡献者希望在不切换分支、不改动工作区的前提下看清本地分支与合并拓扑。 + +## 问题与背景 + +Git 视角的历史列表只有线性提交,看不到分支从哪里分叉、合并汇入哪条线。让用户为了看一眼 +拓扑而 checkout 分支,代价与风险都不对等;把 `git log --graph` 的终端字符画搬进界面,又 +拿不到结构化的父提交身份,做不了行选择、无障碍标签与泳道配色。 + +## 决策 + +在既有 `git` 页签里加**第三个镜头** Git Graph(保留既有页签 id 与 `git` / `session` 两个 +持久化镜头值,新增 `graph`)。把外层页签名从「文件变动」改成「Git」是**另一批贡献**,两批 +分开 review。 + +图谱**只读**:分支下拉框只筛选可达历史,绝不 checkout / fetch / push / revert / +cherry-pick。「全部分支」指本地分支 + 远程跟踪分支 + HEAD(含 detached HEAD),不隐含任何 +网络查询,也不含 stash 历史。 + +新增专用且**有界**的 `git.graph` 路由,返回提交身份、父提交、装饰、元数据与续页游标: + +- 遍历是「子先于父」的拓扑序;游标身份包含仓库、筛选条件与一份 refs 快照指纹; +- refs 在分页期间变化 → 显式 `graph-stale`(HTTP 409),客户端重取第一页,绝不把两份 + 历史拼在一起;主动刷新即开启新快照; +- 偏移分页会对前缀重走,不是常数时间的 keyset 分页(首版取舍,见下); +- 首版上限:每页 200 条、游标偏移 10,000、分支清单 1,000、每个 git 子进程 10 s 且输出 + 8 MiB;**超限显式报错,不静默截断**; +- 装饰首版只含分支名与 HEAD,不含 tag。 + +错误码单独建了 `graph-stale` / `graph-limit`:共用的 Git 错误映射会把它们压成通用的 +`git-error`,客户端就失去了「游标过期、请刷新」这个唯一可区分的信号。 + +加载由**可见性、筛选变化、刷新与「加载更多」**驱动,不新增轮询定时器。 + +## 落地内容 + +### 1. 布局(`src/client/changes/graph-layout.ts`) + +`layoutGraph` 把「子先于父」的前缀排成泳道:首父尽量继承父提交的车道与颜色(颜色索引单调 +分配,调用方按主题色板取模);页边界之外的父保留悬空边、**不渲染成根**;每个空闲车道可复用 +但活着的车道永不平移,所以跨分页追加时每一行(含宽度与悬空边)逐字不变。 + +### 2. 连线几何与配色(`edgePath`) + +一个弯只拐一次,拐在哪儿决定颜色是否统一: + +- **开启新线的边**(合并提交的第二父)从节点水平出线、圆角拐进自己的新车道; +- **并入既有线的边**(分叉收尾)沿**自己**的车道下行,再在行边界横切进目标车道——反过来 + 画会把这条分支的颜色涂到它并入的主线上; +- 横切段的中心放在行边界上方半个描边宽(`STROKE_INSET`):行是后绘制的兄弟元素,溢出行外 + 的半条描边会被下一行的背景吃掉(8× 像素扫描实测 0.75 px,正常 1.5 px),内缩后下边缘 + 正好落在边界上,与下一行的竖线无缝相接; +- 布局给每条出边记 `join` 标记(并入 / 开启),颜色与几何都由它决定。 + +配色五槽全部用**状态色令牌**(business / success / warn / error + 次级灰):它们是给细线 +与小字设计的,两套主题下都能读;`brand-primary` 是面级深蓝,在深色主题下实测 +`rgb(15,17,21)`,主线几乎不可见,因此**刻意不作为泳道色**。提交徽章的颜色就是它所在车道 +的颜色,与连线、圆点走同一个五色映射。 + +### 3. 展示(`GitGraphLens`、`CommitDetails`、`graph.module.css`) + +- **没有颜色图例**:颜色表达的是「不同的线」而不是「唯一的分支」(泳道可以比创建它的分支活 + 得更久),做图例会暗示一种不存在的一一对应;行上的引用徽章就是唯一的分支钥匙。 +- 提交行是**一行 28px**:泳道连线 + 引用徽章 + 标题。徽章带图标(本地分支 / 远程跟踪分支), + `HEAD` 不单独成徽章,而是折叠进当前分支的徽章做前置 ✓(detached 时才单独渲染)。 +- 信息按**三档密度**分开:行(徽章 + 标题)< hover 卡片(350 ms 驻留;作者 · 相对时间 · + 短 hash · 绝对日期)< 详情(完整 hash、父提交、Markdown 正文)。hover 卡片取代了原生 + `title` tooltip。 +- 列表滚到底自动加载下一页(`IntersectionObserver` + 在飞守卫),手动按钮作为兜底。 + +### 4. 底部面板与内容视图(`ChangesTab`、`DiffPane`) + +三个视角共用**同一个可拖拽区域**,标签集合固定为 `提交详情 / 内容 / 差异`,不随上方视角或 +选中项变化;没有内容的标签显示空态(未选择提交 / 读取没有差异 / 此视图暂无内容)而不是消失 +——此前按选中项推导标签集合,同一个面板看起来像三个不同的面板。选择、高度、激活标签都持久化。 + +「内容」对两类来源都回答「文件里有什么」:操作快照(read 的带行号源码;md/html/pdf 用插件 +自己的渲染器)与 git 工作区文件(`fs.read` 读文件本身,二进制 / 超大走既有下载面板)。读取 +**懒加载**——只为看 diff 打开文件时不去读整个文档。md 默认渲染;html 默认源码、点了才渲染 +iframe(沿用「选中不自动加载 iframe」的沙箱契约;`sandbox-views` 的既有断言原样通过)。 + +## 取舍 + +- **复用既有历史控件**:否决——它的分支下拉框会执行 checkout,上下文菜单里还有写操作。 +- **解析 `git log --graph` 的终端字符画**:否决——拿不到结构化的父提交身份,布局、无障碍 + 标签与行选择都无从谈起。 +- **一次性加载全部历史**:否决——首屏与载荷都会失去上界。 +- **用 `lastHash^` 续页**:否决——它会漏掉经过合并的其它路径。 +- **服务端游标缓存**:首版不做——显式的「快照过期」错误让生命周期与资源归属都更简单。 + +## 后续项(本次未纳入) + +颜色图例(已明确不做,见上);tag 标签;keyset 分页;修改历史的操作(首版明确不提供)。 + +## 验收 + +- `tests/graph-layout.spec.ts`:空图与孤立根、线性历史的稳定颜色、合并只与共同祖先汇合、 + octopus 与重复父提交、断开 tip 不接顺路车道、任意分页边界逐行稳定、冻结输入与调用间无 + 共享状态、随机 DAG 的连通性走查,以及三条几何契约(含「同一行同一车道不得出现两种颜色」 + 的全组合断言)。 +- `tests/git-graph.spec.ts`:真实仓库的合并父提交、分支装饰、完整 message、稳定分页,refs + 移动 / 换筛选条件导致的过期,以及选中容器仓库与 linked worktree 的 HEAD。 +- `tests/git-graph-ui.spec.tsx`(19 项):请求时机(只在可见时、无定时器)、错误与重试、 + 分页游标与竞态中止、行结构、HEAD 折叠、hover 卡片、自动加载。 +- `tests/changes-tab.spec.tsx`:固定三标签在各视角一致、内容视图懒加载、读操作的差异空态、 + 箭头键在标签间移动。 +- `tests/smoke.spec.ts`:路由级——按选中的仓库与工作树路由、陈旧游标映射成 409。 +- `tests/e2e/git-graph.e2e.ts`:真实宿主挂载——建带合并的仓库、渲染历史、点合并提交看详情、 + 按分支筛选,并断言仓库 HEAD / refs / status 在读图前后逐字不变。 +- 图形渲染另用设备像素比 8 的截图 + 像素扫描核验:所有描边同为 1.5 px,同一行内同一车道不 + 出现两种颜色。 \ No newline at end of file