fix(desktop): hide custom provider SDK costs by default - #2878
Conversation
|
| Filename | Overview |
|---|---|
| apps/desktop/src/shared/customProviderBilling.ts | 定义自定义 Provider 识别、SDK 估值分类及显示投影的共享语义。 |
| apps/desktop/src/main/usage/turnCostCalculator.ts | 在 turn 成本计算阶段区分可信实际费用与自定义 Provider SDK 估值。 |
| apps/desktop/src/main/localDb/ipc/messages.ts | 增加会话估值的单条与批量只读投影,并对可信 renderer/device-link 调用实施门禁。 |
| apps/desktop/src/main/scheduler-host/storage.ts | 持久化并汇总 Scheduler 的实际费用和 SDK 估值,兼容缺少新标记的历史记录。 |
| apps/desktop/drizzle/scripts/0093_ancient_gorilla_man.ts | 通过列存在性检查幂等添加 schedule_runs.sdk_estimated_value_amount。 |
| apps/desktop/src/main/device-link/dispatch.ts | 将新增只读费用查询接入既有 remote-control、撤销和 allowlist 门禁。 |
| apps/desktop/src/renderer/lib/makerTransport.ts | 为本地及远端侧栏增加批量估值查询和旧端逐会话降级。 |
| apps/mobile/src/session/sessionBillingProjection.ts | 在 Mobile 端按被控 Desktop 的偏好和权威投影展示费用或 Token。 |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart LR
SDK["自定义 Provider SDK costUSD"] --> Classify["费用分类"]
Trusted["可信 Gateway 结算"] --> Classify
Classify --> Actual["actual-cost 账本"]
Classify --> Estimate["value-estimate / sdk-estimate"]
Preference["显示 SDK 估算偏好"] --> Projection["展示投影"]
Actual --> Projection
Estimate --> Projection
Projection --> Desktop["Desktop 消息 / 侧栏 / 今日支出"]
Projection --> Scheduler["Scheduler 历史与汇总"]
Projection --> DeviceLink["Device Link 只读 RPC"]
DeviceLink --> Mobile["Mobile 会话视图"]
Reviews (10): Last reviewed commit: "fix(billing): close remaining remote sid..." | Re-trigger Greptile
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f4470f0ca1
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
这个 PR 触及产品默认行为变化(自定义 Provider 的 SDK 费用由默认展示改为默认隐藏,并新增设置开关),自动流程已暂停合并,需要维护者确认。 维护者确认方式:直接在 PR 上 Approve;需要修改就 Request Changes,作者改完后再 Approve 即放行。在维护者确认前,这个 PR 会保持在待确认队列中,不会自动合并。 讨论 issue:#2884 |
|
@A1aZ 👋 这个 PR 还有 2 条 review conversation 没 resolve(apps/desktop/src/main/maker-ipc/register.ts / apps/desktop/src/renderer/components/settings/CustomProviderBillingSection.tsx),auto-review 因此暂时跳过、没法继续审查 / 合并。 如果你已经按评论改完或回应了,请到对应 thread 上点 Resolve conversation;全部 resolve 后,下一轮 auto-review 会自动重新审查这个 PR。 |
|
命中 UI 路径(apps/desktop/src/renderer/components/settings/CustomProviderBillingSection.tsx / apps/desktop/src/renderer/components/settings/ProvidersSection.tsx / apps/desktop/src/renderer/hooks/useCustomProviderBillingSettings.ts 等)但 description 未附界面效果证据——建议补充改动后效果:截图/录屏,或改动后界面的 HTML 页面(```html 代码块、.html 附件或在线预览链接),便于确认界面符合 DESIGN.md 设计规范 |
f4470f0 to
cb1c617
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cb1c6176b6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a7d280209f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
a7d2802 to
7af9436
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7af9436d96
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@A1aZ 👋 这个 PR 还有 2 条 review conversation 没 resolve(apps/desktop/src/main/scheduler-host/storage.ts / apps/desktop/src/renderer/features/cc-agent/sidebar/SessionInfoMeta.tsx),auto-review 因此暂时跳过、没法继续审查 / 合并。 如果你已经按评论改完或回应了,请到对应 thread 上点 Resolve conversation;全部 resolve 后,下一轮 auto-review 会自动重新审查这个 PR。 |
|
@A1aZ 👋 这个 PR 目前与 请在本地 merge 最新的 |
Signed-off-by: Alan Z <3347202+A1aZ@users.noreply.github.com>
Signed-off-by: Alan Z <3347202+A1aZ@users.noreply.github.com>
Signed-off-by: Alan Z <3347202+A1aZ@users.noreply.github.com>
…ates Use the session/schedule provider as a fail-closed fallback when older custom-provider rows omit turnCostIsCustomProvider, so Scheduler run history no longer treats those SDK amounts as actual spend. Sidebar cost rows now share one main-process batch query and listener pair instead of scanning every session independently. Signed-off-by: Alan Z <3347202+A1aZ@users.noreply.github.com>
7af9436 to
b5676ee
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b5676ee2f8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Require a trusted renderer sender for estimated-session-value IPC while keeping device-link on its existing async-context path. Desktop remote sessions now read the controlled host billing preference, sidebar cost refreshes that arrive mid-query are kept, and the Pi subscription source contract matches the rebased hot path. Signed-off-by: Alan Z <3347202+A1aZ@users.noreply.github.com>
Attach Light/Dark default-off and opt-in screenshots so the PR body can reference checked-in evidence without GitHub comment image upload. Signed-off-by: Alan Z <3347202+A1aZ@users.noreply.github.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f7900a46ff
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Signed-off-by: Alan Z <3347202+A1aZ@users.noreply.github.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 844d50f7b3
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Signed-off-by: Alan Z <3347202+A1aZ@users.noreply.github.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9757f08c58
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@A1aZ 👋 这个 PR 还有 6 条 review conversation 没 resolve(apps/desktop/src/renderer/features/cc-agent/contexts/CustomProviderCostPresentationContext.tsx / apps/desktop/src/main/localDb/ipc/messages.ts / apps/mobile/src/session/sessionBillingProjection.ts / apps/desktop/src/main/bootstrap-electron.ts / apps/desktop/src/renderer/components/chat/MessageActionBar.tsx 等),auto-review 因此暂时跳过、没法继续审查 / 合并。 如果你已经按评论改完或回应了,请到对应 thread 上点 Resolve conversation;全部 resolve 后,下一轮 auto-review 会自动重新审查这个 PR。 |
Signed-off-by: Alan Z <3347202+A1aZ@users.noreply.github.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ad6b40446c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@A1aZ 👋 这个 PR 还有 3 条 review conversation 没 resolve(apps/mobile/app/sessions/[sessionId].tsx / apps/desktop/src/renderer/features/cc-agent/sidebar/sidebarSessionUsageStore.ts / apps/desktop/src/renderer/features/cc-agent/sidebar/SessionInfoMeta.tsx),auto-review 因此暂时跳过、没法继续审查 / 合并。 如果你已经按评论改完或回应了,请到对应 thread 上点 Resolve conversation;全部 resolve 后,下一轮 auto-review 会自动重新审查这个 PR。 |
Signed-off-by: Alan Z <3347202+A1aZ@users.noreply.github.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 08be042d44
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| return invokeRemote(deviceId, 'local-db:messages:estimatedSessionValue', [ | ||
| sessionId, | ||
| presentation, | ||
| showSdkEstimate, | ||
| ]) as ReturnType<typeof estimatedSessionValueFor>; |
There was a problem hiding this comment.
Reject legacy remote cost projections on Desktop
When Desktop controls a pre-change host, this remote invoke can succeed while returning no projectionVersion or excludedActualMoney, yet the result is accepted as authoritative. Both useSessionEstimatedValue and the sidebar summary then treat the missing exclusion as zero, so SDK costs persisted by the old host remain visible as actual spend even though the remote preference lookup fails closed to disabled. Fresh evidence relative to the earlier Mobile legacy-host thread is that the shared Desktop transport still never validates projectionVersion; reject or token-only downgrade legacy remote responses here.
AGENTS.md reference: AGENTS.md:L113-L115
Useful? React with 👍 / 👎.
| return { | ||
| entries: [], | ||
| presentation: resolveMobileSdkCostPresentation( | ||
| currentSession?.providerId, | ||
| composerDeviceProviders.providers, | ||
| false, | ||
| ), | ||
| showSdkEstimate: false, |
There was a problem hiding this comment.
Keep Mobile messages token-only until projection is authoritative
When the host response is legacy, or while a refreshed request is pending or failed, this fallback supplies empty entries but uses regular presentation for a session whose current provider is built-in. If that session previously used a custom provider, raw historical SDK amounts in message metadata therefore remain visible in action bars even though billingDisplaySession correctly removes the session total. Fresh evidence after the prior token-only fix is that the message path neither retains/checks projectionVersion nor strips money when the current provider is regular; use an explicit token-only message projection until an authoritative response arrives.
AGENTS.md reference: AGENTS.md:L120-L123
Useful? React with 👍 / 👎.
| const costPresentation = useSessionCustomProviderCostPresentation( | ||
| session.providerId, | ||
| remoteDeviceId, | ||
| ); | ||
| const showSdkEstimate = useShowCustomProviderSdkEstimate(remoteDeviceId); |
There was a problem hiding this comment.
Share sidebar billing-setting reads per device
Every mounted sidebar row calls two helpers that each instantiate useCustomProviderBillingSettings, so each row performs two independent GETs and installs two subscription sets; this happens even when the user has not enabled the cost task-info field. For device-link rows, opening a sidebar with N sessions consequently emits 2N reliable tunnel requests initially and again after preference pushes, undoing the new batch-store work and potentially congesting the shared relay. Cache this setting once per device and reuse the same value for presentation and projection.
Useful? React with 👍 / 👎.
|
@A1aZ 👋 这个 PR 还有 3 条 review conversation 没 resolve(apps/desktop/src/renderer/lib/makerTransport.ts / apps/mobile/app/sessions/[sessionId].tsx / apps/desktop/src/renderer/features/cc-agent/sidebar/SessionItem.tsx),auto-review 因此暂时跳过、没法继续审查 / 合并。 如果你已经按评论改完或回应了,请到对应 thread 上点 Resolve conversation;全部 resolve 后,下一轮 auto-review 会自动重新审查这个 PR。 |
|
@A1aZ 👋 这个 PR 目前与 请在本地 merge 最新的 |
这次改了什么
摘要
自定义 Provider 的 SDK
costUSD来源与计价口径无法由 Cindy 验证,不能默认当作可对账的真实支出。本 PR 将它改为:value-estimate展示,仍不进入消息 / 会话 / 今日支出的actual-cost账本;「设置 → Providers」中的开关默认关闭,并明确提示该数字不是供应商账单、可能与最终扣费不一致。设置采用默认值 + override;用户修改后可看到「已自定义」并恢复默认,恢复时删除 override。
变更类型
feat新功能fix缺陷修复refactor/perf重构或性能优化docs/test/chore文档、测试或工程维护范围
turnCostIsCustomProvider的记录,用会话 / 任务 Provider 做 fail-closed 回填。侧栏费用改为 main 侧批量投影,避免逐会话全历史扫描。新增 append-only、幂等守卫的0093_ancient_gorilla_manmigration。Desktop 和 Mobile 的英文、简中、繁中、日文、韩文。UI 变化
「设置 → Providers」新增「显示 SDK 估算」开关、风险说明、「已自定义」状态和「恢复默认」入口。
默认关闭时,消息、侧栏、状态栏、Mobile 与 Scheduler 均优先展示 Token 或保留的其他可信 / 独立估价。
已完成 Light / Dark × 默认关闭 / 手动开启四种脱敏运行时截图并做视觉复核



Light · 默认关闭
Dark · 默认关闭
Light · 手动开启
Dark · 手动开启
引用的设计规范:
docs/design-rules/DESIGN.md§2 Layer System、§3 Typography、§4 Cards & Forms、§10 Light/Dark dual-mode and theme tokens、§11 Voice & Content。控件复用现有设置卡片、Switch 和语义化主题 token;提示文案直接说明来源、不可控性和开启后果。怎么验证的
自动验证
先前已通过的 Desktop / Mobile typecheck、migration validate、i18n 对齐与 DCO 仍适用本 PR 主干改动。本次新增提交覆盖 Scheduler 旧记录归类、侧栏批量投影、device-link 只读 batch channel 与老被控端逐会话回退。
手工验证
未执行的验证
风险
风险分类
影响与回滚
schedule_runs.sdk_estimated_value_amount,migration 带列存在性守卫,不修改历史 migration。本地 GET / SET / RESET 继续先校验 trusted app renderer。Device link 仅提供门禁后的只读 GET 投影,以及只读estimatedSessionValueBatch;不能远程修改偏好。SSH / remote workspace 不读取或修改远端 workdir 文件;费用偏好仍属于被控 Desktop 本地。Mobile / device-link 新增字段与读取路径均为可选 / 向后兼容;旧端继续降级为 token-only 或逐会话查询。原生层 / fingerprint / OTA 无改动。存量插件影响:无。提交前检查
git commit -s,见 DCO)