Skip to content

refactor(desktop): remove 11 unused Tauri commands with no consumer - #2536

Open
zvzuola wants to merge 2 commits into
GCWing:1.0.0-explorefrom
zvzuola:remove_dead_command
Open

refactor(desktop): remove 11 unused Tauri commands with no consumer#2536
zvzuola wants to merge 2 commits into
GCWing:1.0.0-explorefrom
zvzuola:remove_dead_command

Conversation

@zvzuola

@zvzuola zvzuola commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Summary

移除 11 个已确认没有实际消费方的 Desktop Tauri Commands:

  • sync_config_to_global
  • initialize_snapshot
  • record_file_change
  • get_storage_paths
  • get_project_storage_paths
  • cleanup_storage
  • cleanup_storage_with_policy
  • get_storage_statistics
  • initialize_project_storage
  • reload_global_config
  • subscribe_config_updates

这些命令未被 Web UI 通过 api.invoke 调用,也未作为交互能力证据或其他 Agent Tool / Core 路径的实现入口。

本 PR 同步完成以下清理:

  • generate_handler! 中移除对应命令注册。
  • REMOTE_WORKSPACE_COMMAND_POLICIESLEGACY_UNAUDITED_BASELINE 中移除对应条目。
  • 删除全部命令均已废弃的 storage_commands.rs 模块。
  • 清理 commands.rsconfig_api.rssnapshot_service.rs 中的孤立命令实现。
  • 更新交互能力 catalog、生成的 Tauri Command Map 和 README 统计。
  • 将已审计 Tauri 命令数量从 651 降至 640。

另外保留了 18 个虽然没有前端直接调用、但仍作为真实能力实现证据的命令,例如由 Agent Tool 或 Core Function 提供实际能力的命令。

Type and Areas

Type:

Refactor / maintenance

Areas:

Desktop/Tauri, remote workspace policy, interactive capabilities catalog and generated documentation

Motivation / Impact

这些命令已经没有产品入口或运行时消费方,但仍扩大 Desktop IPC API 面,并增加命令注册、远程工作区策略和能力审计的维护负担。

删除这些孤立命令可以:

  • 缩小 Desktop Tauri Command 暴露面。
  • 降低远程工作区策略的遗留未审计数量。
  • 保持命令注册、策略清单和能力目录一致。
  • 避免生成的交互能力文档继续记录无效实现。

No direct user-facing change. 本 PR 不修改持久化数据格式,也不需要数据迁移。

Verification

  • node scripts/generate-interactive-capabilities.mjs --check

    • Passed.
    • Generated command inventory contains 640 audited Tauri commands.
  • node --test scripts/interactive-capabilities.test.mjs

    • Passed: 14/14 tests.
  • Registration/policy consistency audit:

    • generate_handler! command count: 640.
    • Remote workspace policy command count: 640.
    • LEGACY_UNAUDITED_BASELINE matches the actual LegacyUnaudited set: 278.
  • Repository-wide reference audit:

    • No dangling references to the 11 removed commands.
    • The generated command map and interactive-capability catalog are synchronized.
  • cargo check -p bitfun-desktop

    • Not completed because the existing sherpa-onnx-sys dependency download failed due to network access. This failure is unrelated to the changes in this PR.

Remote scenarios:

  • Remote workspace: registration and remote-workspace-policy consistency were verified; no end-to-end remote workspace session was exercised.
  • Remote control: not exercised; the removed commands have no RemoteCommand product route.
  • Peer Device Mode: not exercised; no active UI or capability path invokes these commands.
  • Detached Dispatch: not exercised; the removed Desktop commands are not part of the dispatch protocol or target runtime.

Reviewer Notes

The main review point is the distinction between truly orphaned commands and commands that merely lack a direct frontend invocation.

Only commands with no frontend consumer, capability evidence, Agent Tool path, or Core Function consumer were removed. Commands that still provide implementation evidence for active capabilities were intentionally retained.

This PR was AI-assisted. Verification was focused on command registration, remote-workspace policy consistency, generated capability artifacts, and dangling-reference detection.

Checklist

  • This PR is focused and does not include secrets, temporary prompts, generated scratch files, or unrelated artifacts.
  • Relevant verification is recorded above, or skipped checks are explained.
  • User-facing strings, docs, and locales are updated where applicable.

@limityan limityan left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

复审当前 head f5b18c395a569051318f76cfaaec69d9a328db09 后,这两个问题仍需修复:

  1. PR 与 1.0.0-explore 当前远端 tip 5d012cbddb3acfac009f21f11fa3f026c04edaec 存在冲突。三方合并确认冲突路径为 docs/interactive-capabilities/README.md,GitHub 也仍标记为 CONFLICTING / DIRTY。该文件是生成物,请 rebase 到最新目标分支后重新运行交互能力目录生成器,确保命令数和 UI 交互统计都来自合并后的源码状态。

  2. 删除 initialize_snapshotrecord_file_change 后,SnapshotInitRequestsrc/apps/desktop/src/api/snapshot_service.rs:57)、RecordFileChangeRequest:66)和 begin_snapshot_record_mutation:440)均已没有消费者。cargo check -p bitfun-desktop 成功,但明确报告 begin_snapshot_record_mutation 为 dead code。请一并删除这些失效 DTO、辅助函数以及随之失效的 import,完成本 PR 的孤立命令清理。

完成 rebase 和清理后,请基于新的 exact head 重新运行能力目录检查、Desktop check 和 PR CI。

@zvzuola
zvzuola force-pushed the remove_dead_command branch from f5b18c3 to f771bb2 Compare August 27, 2026 08:03

@limityan limityan left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

复审当前 head f771bb2a77613f040d347228f053a0e1c01fc1a8 后,上轮的 snapshot 死代码问题已经修复;当前仍有两个合并阻塞:

  1. PR 与 1.0.0-explore 当前远端 tip f2910919dd65dbd07b4ac4dcb32d88b7a1a4a56a 存在冲突。git merge-tree 确认唯一冲突路径为 docs/interactive-capabilities/README.md,GitHub 当前也标记为 CONFLICTING / DIRTY。请再次 rebase 并运行交互能力目录生成器。合并后的统计应保留本 PR 的 640 个 Tauri commands,同时采用最新目标分支的 365 个交互源码文件和 4423 个交互候选。

  2. 本 PR 从 merge-base 计算只有 11 个文件、9 行新增和 619 行删除,共 628 行,但当前包含 3 个 commits。仓库约束要求小于 3k 行的变更不得超过 2 个 commits;其中 71e72d1ac 仅清理 2 行 runtime contract,f771bb2a7 仅刷新生成统计,请在 rebase 时将提交压缩到不超过 2 个。

完成标准:PR 对最新目标分支无冲突,生成器检查与相关测试基于新 exact head 通过,commit 数量符合仓库约束,并重新获得最新集成 CI 结果。

Remove 11 orphaned Desktop commands together with their registrations, remote-workspace policies, implementation-only capability entries, dead snapshot DTOs/helpers, and runtime contract references. Regenerate the Tauri command map for the resulting 640-command surface.
Regenerate the interaction inventory after rebasing onto the latest target branch. The merged source now audits 640 Tauri commands and 4,393 interaction candidates across 364 UI source files.
@zvzuola
zvzuola force-pushed the remove_dead_command branch from f771bb2 to 9d8038b Compare August 27, 2026 12:36
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.

2 participants