Skip to content

refactor(product-split): 三产品共用全量主页 + 领域 feature 拆分与 UI 下沉 - #489

Merged
feigeCode merged 115 commits into
devfrom
refactor/product-split
Oct 30, 2026
Merged

feigeCode merged 115 commits into
devfrom
refactor/product-split

Conversation

@feigeCode

Copy link
Copy Markdown
Owner

目标

把 navop 拆成三个可独立交付的产品(全量 / Shell / Data),同时保持「全量产品功能不缩水、独立产品该有的都有」:

  • 共用一套全量主页:三个 app 各自实现 domain_api::Product,调用 navop_app::run_with(product, version) 启动同一套 UI(主页、设置、标签页、凭据库、AI、Notes、Team、扩展、托盘、单实例、自动更新、Tab 恢复全部保留)。
  • 领域能力靠 Cargo feature + 注册表:main 引入 database / shell 两个领域 feature,独立产品 default-features = false 只开自己的领域;连接类型、筛选、新建连接、设置页、已知主机/会话日志、本地终端、SFTP/RDP/端口转发等入口全部由 domain_api 注册表或 ShellExtras / FileOpenHandler / ActiveResourceProvider 契约驱动。
  • 领域 UI 下沉:shell_domain / data_domain 承接了终端菜单、WSL、端口转发运行时、远程桌面窗口、录制文件打开、临时连接保存、侧栏配色、终端主题卡片、连接表单、设置页、领域初始化与关停等实现;main/src 里已没有 use 领域crate::…。

验证(本地真实输出)

命令 结果
cargo build -p navop -p navop-shell -p navop-data 通过,0 rustc 警告
cargo test -p main --lib 591 passed, 0 failed
cargo test -p main --test i18n_locale_keys_contract 1 passed
cargo test -p app_kit -p domain_api -p shell_domain -p data_domain 141 / 18 / 42 / 11 passed
main shell-only / data-only cargo check(--no-default-features + 单领域 feature) 0 error / 0 warning
cargo tree -p navop-shell -e normal 不含 db / db_view / redis_view / mongodb_view
cargo tree -p navop-data -e normal 不含 terminal_view / sftp_view / remote_desktop_view / known_hosts_view / port_forwarding_view
两个独立产品临时 HOME 启动 RUNNING_OK
产物大小 navop 916 MB / navop-data 875 MB / navop-shell 789 MB(debug)

同时新增了两条 manifest 契约测试(native_driver_feature_contract_tests):独立产品必须只开自己的领域 feature、database/shell feature 不许互相夹带对方依赖,随 cargo test -p main --lib 在 CI 里跑。

已知限制

  • public_mcp_runtime(全量产品的 MCP 实现)仍用 #[cfg(feature)] 装配 data/shell 工具集,尚未并入 mcp_host;这部分代码不随独立产品编译。
  • Mongo 原生驱动工厂、扩展连接终端启动、远程桌面协议映射仍在 main 的 cfg 分支里(约 57 处 cfg)。
  • ProductKind 仍留在 main/src/lib.rs(下一步移到 apps/*)。
  • CI 依赖树 guard job 需要 workflow scope,本 PR 暂未改动 .github/workflows/ci.yml;等价校验已落成上面的契约测试 + script/check-product-deps.sh。

后续

合并后继续:合并两套 MCP 实现、把 ProductKind 移到各 app、补 CI 依赖树 job 与安装器矩阵实跑。

feigeCode and others added 28 commits October 29, 2026 20:26
- main/Cargo.toml 删除 6 个已无引用的 optional 领域依赖:
  db、ssh、sftp_view、known_hosts_view、port_forwarding、port_forwarding_view
  (builtin-duckdb 改由 db_view 转发)
- 修 shell-only 构建下的 Redis 资源池 helper cfg、外观页误加的 cfg
- 新增 script/check-product-deps.sh(本地依赖树守卫)
- 新增两个 manifest 契约测试:独立产品只开自己领域 feature、
  database/shell feature 互不包含对方领域依赖
- 文档补 §27(main 已无领域 use、cfg 161→57、验证与剩余项)
- main 默认 feature 追加 database/shell 后,同步 script/test-release-packaging.mjs 断言
- update/install.rs 已下沉到 crates/app_kit,修正契约脚本读取路径
- crates/core/key_storage.rs 的 keyring_services 只在 test/macOS/Windows
  下引用钥匙串服务名常量,补上同样的 cfg,修 Linux 构建的 E0425
- app_kit 单实例 Windows 模块在迁移后丢了可见性:forward_attempt /
  create_pipe_instance / serve_forever 改 pub(super),补 ForwardAttempt import
Linux CI 用 -D warnings,keyring_services/keyring_service_for 在非
test/macOS/Windows 平台被 cfg 掉后 KeyringServices 的 installed/development
两个字段变成 never read,补 allow(dead_code)。
remote_desktop_window/mstsc_credentials_windows.rs 用 windows crate 的
Win32_Security_Credentials,迁移时漏了 Cargo 依赖,Windows CI 报
cannot find module or crate `windows`。按 main 原配置补到 shell_domain
的 windows target 依赖。
RDP probe 用 --locked 构建,lock 未记录 shell_domain → windows 0.62 这条边
会导致 cannot update the lock file because --locked was passed。
report_single_instance_failure 收 &str,app_kit 的 user_message() 返回
String,Windows CI 报 E0308 expected &str, found String。
把人工 cargo tree | grep 的验收固化成集成测试:navop-shell 的依赖树不能
出现 db_view/redis_view/mongodb_view,navop-data 不能出现
terminal_view/sftp_view/remote_desktop_view/known_hosts_view/
port_forwarding_view。feature 写漏时编译不会报错,只有依赖树能拦住。
@feigeCode
feigeCode merged commit 1b05537 into dev Oct 30, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant