Skip to content

refactor(desktop): remove unused Usage preload bridge - #2038

Closed
me2seeks wants to merge 1 commit into
apache:mainfrom
me2seeks:chore/1982-remove-usage-preload
Closed

refactor(desktop): remove unused Usage preload bridge#2038
me2seeks wants to merge 1 commit into
apache:mainfrom
me2seeks:chore/1982-remove-usage-preload

Conversation

@me2seeks

Copy link
Copy Markdown
Contributor
English

Summary

  • remove the unused window.maka.usage preload namespace and its renderer type contract
  • keep settings.usageStats, which still powers the current Usage page
  • keep all six Main-process detailed Usage/Pricing handlers for the planned Runtime Host Desktop adapter

Why

The deleted namespace has no renderer, Storybook, or E2E consumer. Its pricing mutations also predate the Host revision/CAS contract, so keeping it would freeze the wrong renderer interface before #2010 has a real Pricing consumer.

The IPC surface test now names these six handlers as the only approved Main-only channels. It still requires exact Main/preload parity everywhere else and separately proves that every retained handler remains registered.

Validation

  • npm run build:test
  • node --test apps/desktop/dist/main/__tests__/ipc-surface-contract.test.js apps/desktop/dist/main/__tests__/usage-ipc-main.test.js
  • npm --workspace @maka/desktop run test:checks
  • npm run lint
  • npm run format:check
  • git diff --check origin/main...HEAD

Part of #1982. Pricing Settings is tracked in #2015 and remains coordinated with #2010.

简体中文

概要

  • 删除未使用的 window.maka.usage preload namespace 及其 renderer 类型契约
  • 保留当前 Usage 页面仍在使用的 settings.usageStats
  • 保留全部六个 Main 侧详细 Usage/Pricing handlers,供计划中的 Runtime Host Desktop adapter 接线

原因

被删除的 namespace 在 renderer、Storybook 和 E2E 中都没有消费者。它的 pricing mutation 也早于 Host 的 revision/CAS 契约;在 #2010 出现真实 Pricing consumer 之前继续保留,会提前冻结错误的 renderer interface。

IPC surface test 现在把这六个 handler 明确列为唯一允许的 Main-only channels。除此之外仍保持 Main/preload 严格一一对应,并单独证明六个保留 handler 一项都不能缺失。

验证

  • npm run build:test
  • node --test apps/desktop/dist/main/__tests__/ipc-surface-contract.test.js apps/desktop/dist/main/__tests__/usage-ipc-main.test.js
  • npm --workspace @maka/desktop run test:checks
  • npm run lint
  • npm run format:check
  • git diff --check origin/main...HEAD

属于 #1982 的一部分。Pricing Settings 由 #2015 跟踪,并继续与 #2010 协调。

@Astro-HanAstro-Han left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approve — verified in a local worktree; every claim in the description reproduces.

Verified

  • No renderer / Storybook / E2E consumer of window.maka.usage anywhere in the repo; the six removed types have no remaining references in bridge-contract.d.ts / preload.ts.
  • settings.usageStats still powers the Usage page and remains protected by the exact-parity branch of the contract test.
  • All six usage:* handlers stay registered in usage-ipc-main.ts; the retained-set assertion pins them.
  • Reproduced validation: build:test, both node --test runs (3/3 pass), test:checks, lint, git diff --check, plus full desktop typecheck (preload/main/renderer/storybook).
  • The full desktop suite has 8 failures, but the identical set fails on a main baseline — pre-existing environment issue, unrelated to this PR.

Non-blocking comments

  1. Branch is 2 commits behind main (base 1705111c8 vs 61a0ca1f5); the diff applies cleanly, but please rebase before merge.
  2. usage:pricing:changed is still sent to the renderer with no listener (pre-existing — it never had one). When #2015/#2010 wires the Runtime Host Desktop adapter, either add the subscription or drop the send.
  3. The retained-set assertion requires exact equality, so a future 7th Main-only channel will fail CI until the allowlist is extended in the same PR. A one-line comment on RETAINED_MAIN_ONLY_CHANNELS pointing at #2015 would make that coordination explicit for the next author.

@me2seeks
me2seeksforce-pushed the chore/1982-remove-usage-preload branch from f1c18b7 to 0cc726eCompareAugust 4, 2026 02:02
@me2seeks

Copy link
Copy Markdown
ContributorAuthor

Thanks for the detailed review. I rebased onto current main and added the ownership note above RETAINED_MAIN_ONLY_CHANNELS. The focused local checks and the new CI run are green on 0cc726e1.

For usage:pricing:changed, #2015 intentionally uses explicit refreshes rather than a live renderer subscription in V1. The #2010/#2015 Host adapter cutover will therefore remove that orphan send together with the legacy Pricing handlers instead of adding a listener.

@Astro-Han

Copy link
Copy Markdown
Contributor

This overlaps with #2065, which has merged (af316fe). #2065 removed the same maka.usage preload namespace (summary/buckets/logs/pricing:list/put/reset) and added the same main-only channel whitelist with the same bidirectional assertions in ipc-surface-contract.test.ts, touching the same three files. After a rebase onto current main, this branch collapses to almost nothing. Suggest closing it as superseded; the Usage/Pricing authority surface stays main-side per #1982 until the #2010 adapter lands. Thanks for the contribution.

@me2seeks

Copy link
Copy Markdown
ContributorAuthor

Thanks for catching the overlap. I confirmed that #2065 covers the same preload and IPC contract surface, so I’m closing this as superseded. I’ll keep the remaining Pricing work coordinated through #2015 and #2010.

@me2seeksme2seeks closed this Aug 4, 2026
Sign up for freeto 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

@me2seeks@Astro-Han