feat(voyager): About tab (docstring + Mermaid) and 2/3-width sidebar#95
Merged
Conversation
为 ER-diagram 双击打开的侧边栏新增最左的 About tab,渲染 schema 模型类 __doc__ 为 GitHub-Flavored Markdown,docstring 中的 ```mermaid 围栏块 (stateDiagram-v2 / flowchart / sequenceDiagram)就地渲染为可视化图表; 语法错误块降级为"错误提示 + 默认折叠源码"。同时把侧边栏拖拽上限从 固定 800px 改为 floor(viewport × 2/3),视窗缩放时主动 clamp 到新上限。 - 后端:新增 POST /docstring 端点 + VoyagerContext.get_docstring 方法, 与 /source /vscode-link 对称,不改 SchemaNode、不改现有端点契约 - 前端:新建 about-display.js(marked + DOMPurify + mermaid.run 管线, per-block try/catch + <details> 折叠降级,链接强制 noopener); schema-code-display.js 加 About tab(最左,默认激活仍是 Fields); vue-main.js mermaid.initialize + 拖拽 clamp + resize 监听 - 依赖:marked@15 / dompurify@3 / mermaid@11 走 CDN(cdn.jsdelivr.net), 匹配现有 Vue/d3/jQuery 模式;三个 URL 加入 sw.js CDN_ASSETS 预缓存 - 测试:tests/test_voyager_docstring.py 5 条 pytest 用例 - demo:Employee docstring 覆盖 FR-003 全元素矩阵 + FR-004 三种 mermaid 类型 Spec-kit 产物在 specs/006-voyager-about-tab/,全中文撰写(项目约定)。 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
allmonday
added a commit
that referenced
this pull request
Jul 1, 2026
…-width sidebar Version bump for PR #95 (Voyager About tab + sidebar width clamp). Updates CHANGELOG, pyproject.toml, uv.lock. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
__doc__为 GitHub-Flavored Markdown;docstring 中的 ```mermaid 围栏块(stateDiagram-v2/flowchart/sequenceDiagram)就地渲染为可视化图表,语法错误块降级为"错误提示 + 默认折叠源码"。DOMPurify清洗,所有<a>强制target="_blank" rel="noopener noreferrer";About tab 与 Related Entities 子图一样只读——不识别实体引用、不导航。设计要点
POST /docstring(与/source//vscode-link对称),不改 SchemaNode、不改/source契约——避免 er-diagram 初始 payload 膨胀与 service worker 缓存键失效。marked/dompurify/mermaid走 CDN(cdn.jsdelivr.net),匹配现有 Vue/d3/jQuery 模式;三个 URL 加入 sw.js 的CDN_ASSETS预缓存以保证离线可用。parse:渲染管线用async/await统一处理 sync (v10-) 与 Promise (v10+/v11) 两种返回形态,避免成功路径上提前退出导致 pending 数组为空的 bug(converge 阶段发现并修复)。Changes
src/nexusx/voyager/voyager_context.pyget_docstring(schema_name)方法src/nexusx/voyager/create_voyager.pyPOST /docstring路由,状态码与/source一致src/nexusx/voyager/web/component/about-display.js<details>折叠降级,链接强制 noopener,stale-fetch 守卫src/nexusx/voyager/web/component/schema-code-display.jsshowAboutprop;tab 栏最左加 About;content 区挂载<about-display>src/nexusx/voyager/web/vue-main.jsmermaid.initialize({ startOnLoad: false, theme: "default" });startDragDrawerclamp 改为Math.max(300, Math.min(floor(innerWidth × 2/3), ...));onMounted注册window.resize监听器src/nexusx/voyager/web/index.html<script>;<schema-code-display>加:show-about="store.state.mode === 'er-diagram'"src/nexusx/voyager/web/sw.jsCDN_ASSETS预缓存列表追加三个 CDN URLtests/test_voyager_docstring.pydemo/enterprise_voyager/models.pyEmployee加 docstring,覆盖 FR-003 全部 Markdown 元素 + FR-004 三种 Mermaid 类型,便于人工验证CHANGELOG.mdspecs/006-voyager-about-tab/Test plan
后端自动化(已通过)
uv run pytest tests/test_voyager_docstring.py -v→ 5/5 PASSEDuv run pytest --no-cov -q→ 1128 passed, 6 skipped,无回归node --check三个修改/新增 JS 文件全过show-about接线、Employee docstring 含 3 种 mermaid 类型、空 docstring 返回{"docstring":""}、非法 schema_name → 400浏览器手动验证(按
specs/006-voyager-about-tab/quickstart.md§3 路径 A-G)启动:
uv run uvicorn demo.enterprise_voyager.voyager_demo:app --port 8010,开http://localhost:8010/voyager,强刷一次(Ctrl+Shift+R)让 service worker 拉新缓存。Employee→ 切到 About tab → 看到标题/段落/列表/表格/代码块/引用块/水平线/链接的合理排版(无##/**/`标记泄露)-->的尖括号),重启服务 → 看到错误提示 + 可展开"查看源码"折叠区,其它内容正常Organization(无 docstring)→ 看到"该实体暂无 docstring。";DevTools Network 阻断/docstring→ 看到红色错误文案;Slow 3G 节流 → 看到<q-linear-progress>加载条Department→ 侧边栏停留在 About tab、内容刷新为 Department[SQLModel 关系文档]链接 → 在新 tab 打开;主画布选中状态仍是 Employee;侧边栏仍停留 About tabMermaid 渲染专项(路径 B 的细化,converge T022 修复后)
🤖 Generated with Claude Code