refactor(wiki): Catalog 与 Publish 子视图合并为单页一体化发布工作台 - #576
Merged
Conversation
PR #556 引入的 ModeToggle 把发布相关 UI 折叠到第二个视图后,发布入口的发现性显著下降——用户在默认 Catalog 视图下找不到「把编排好的 Wiki 发布到 negentropy-wiki 站点」的操作入口。本次彻底去除「模式」概念,改为单页一体化:顶部粘性发布工具栏(Publication 选择器 + 状态徽章 + 操作按钮组 + Pipeline 状态条)+ 左栏 Catalog 树 + 右栏节点详情 + 底部可折叠的条目预览。后端 API、ISR webhook 链路、数据模型零改动。 - 新增 WikiPublishToolbar 承载 publish/unpublish/sync/delete 全部 handlers + Pipeline 透传;切换发布对象时 useEffect([pubId]) 复位 Pipeline 状态避免上次回执遗留 - 新增 WikiEntriesPreview 作为底部折叠区,forwardRef + useImperativeHandle 暴露 refresh(),从 Catalog 同步成功后由 LibraryShell 触发刷新 - 重构 LibraryShell 移除 viewMode/handleModeChange/ModeToggle,主区固定为 NodeDetailPanel - 删除 ModeToggle/WikiPublicationDetail/WikiPublicationList 三个已被替代的组件 - 简化 page.tsx 去掉 ?mode 参数与 Suspense+useSearchParams 间接层,旧 URL ?mode=publish 仍可正常打开(参数被忽略) - KnowledgeNav 移除 dead prop modeToggle 与对应渲染分支,同步移除 KnowledgeNav.test.tsx 中相关 case - 新增 WikiPublishToolbar.test.tsx 7 例覆盖 disabled 态/状态切换/publishWiki/unpublishWiki/deleteWikiPublication/同步并发布/仅同步双路径 - docs/wiki/user-guide/publishing.md 新增 §8.2.1 实操指南,覆盖前置条件/第一次发布 5 步/日常增量发布/取消发布与回滚/配置说明/FAQ,交叉引用 docs/wiki/ops.md §8 与 §12.3 - CHANGELOG 在 [Unreleased]/Changed 顶部新增条目,详尽记录改动半径与契约 本地静态验证:typecheck/typecheck:test/lint 全绿,vitest 730 例全通过,Next.js build 成功且 /knowledge/wiki 路由保持 Static 预渲染。浏览器实机回归留作 PR 阶段人工验收清单。 🤖 Generated with [Claude Code](https://github.com/claude), [CodeX](https://openai.com), [Gemini](https://github.com/apps/gemini-code-assist) Co-Authored-By: Aurelius Huang<threefish.ai@gmail.com>
- catalog/page.tsx 移除 ?mode=edit 死查询串(wiki/page.tsx 已不再读取该参数) - WikiPublishToolbar 状态徽章区补回 publication.description 截断显示,闭环信息回显 - publishing.md §8.2.1 死链占位符替换为指向 CHANGELOG.md 的相对链接 🤖 Generated with [Claude Code](https://github.com/claude), [CodeX](https://openai.com), [Gemini](https://github.com/apps/gemini-code-assist) Co-Authored-By: Aurelius Huang<threefish.ai@gmail.com>
This was referenced May 19, 2026
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.
背景与动机
PR #556 (commit
dc90de62) 把原来独立的/knowledge/catalog与/knowledge/wiki合并到单一路由后,引入ModeToggle(Catalog / Publish)做视图切换:默认进入 Catalog 编辑视图,发布相关 UI 全部被折叠到第二个视图后面。结果:用户在默认视图下找不到「把编排好的 Wiki 发布到 negentropy-wiki 站点」的操作入口。本次彻底去除「模式」概念,改为单页一体化:在一个页面上同时完成 Catalog 维护和 Wiki 发布,消除发布入口的发现性问题。
设计
重构前 vs 重构后
重构前:
重构后:
核心改动
apps/negentropy-ui/app/knowledge/wiki/_components/WikiPublishToolbar.tsxapps/negentropy-ui/app/knowledge/wiki/_components/WikiEntriesPreview.tsxforwardRef + useImperativeHandle暴露refresh()给工具栏apps/negentropy-ui/app/knowledge/wiki/_components/LibraryShell.tsxapps/negentropy-ui/app/knowledge/wiki/_components/ModeToggle.tsxapps/negentropy-ui/app/knowledge/wiki/_components/WikiPublicationDetail.tsxapps/negentropy-ui/app/knowledge/wiki/_components/WikiPublicationList.tsxapps/negentropy-ui/app/knowledge/wiki/page.tsx?modeURL 参数读取与Suspense+useSearchParams间接层;旧 URL?mode=publish仍可正常打开(参数被忽略)apps/negentropy-ui/components/ui/KnowledgeNav.tsxmodeToggle及对应渲染分支apps/negentropy-ui/tests/unit/ui/KnowledgeNav.test.tsxapps/negentropy-ui/tests/unit/knowledge/WikiPublishToolbar.test.tsxdocs/wiki/user-guide/publishing.mdCHANGELOG.md不变项
POST /api/knowledge/wiki/publications/{id}/publish及全部 schema 零改动NE_KNOWLEDGE_WIKI_REVALIDATE__URL→ SSG/api/revalidate)零改动features/knowledgeAPI client 签名零改动/knowledge/wiki路由保持 Static 预渲染(移除useSearchParams后是意外优化)/knowledge/wiki?mode=publish向后兼容(参数被忽略,不报错)测试用例
新增
WikiPublishToolbar.test.tsx7 例锁定行为契约:draft状态显示「仅发布」,published状态显示「取消发布」publishWiki(pubId)并触发onPublicationsChangedunpublishWikideleteWikiPublication并触发onPublicationDeleted本地静态验证
pnpm typecheck零错误pnpm typecheck:test零错误pnpm lint --max-warnings=0零告警pnpm test93 个测试文件 / 730 例全部通过(含新增 7 例)pnpm build成功,/knowledge/wiki保持○ Static预渲染浏览器实机回归清单(待 PR 阶段人工验收)
基础渲染
/knowledge/wiki顶部出现「Wiki 发布」工具栏,无 ModeToggle 元素发布流程
http://localhost:3092)刷新看到新版本内容回退 / 异常
/knowledge/wiki?mode=publish仍能正常打开(参数被忽略,不报错)正交回归
/knowledge/catalog旧路由仍能 redirect 到/knowledge/wiki(PR refactor(knowledge+wiki): 合并 Catalog 与 Wiki 为统一管理入口 + negentropy-wiki 站点视觉四阶段升级 #556 的兼容逻辑)/knowledge/base、/knowledge/graph等同级页面不受影响设计依据
forwardRef + useImperativeHandle用于父子命令式通信(Catalog 同步成功 → 触发条目预览刷新)useSearchParams后页面恢复 Static 预渲染能力🤖 Generated with Claude Code