Skip to content

fix(desktop): hide custom provider SDK costs by default - #2878

Open
A1aZ wants to merge 10 commits into
makecindy:mainfrom
A1aZ:fix/issue-2855-custom-provider-billing
Open

fix(desktop): hide custom provider SDK costs by default#2878
A1aZ wants to merge 10 commits into
makecindy:mainfrom
A1aZ:fix/issue-2855-custom-provider-billing

Conversation

@A1aZ

@A1aZ A1aZ commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

这次改了什么

摘要

自定义 Provider 的 SDK costUSD 来源与计价口径无法由 Cindy 验证,不能默认当作可对账的真实支出。本 PR 将它改为:

  • 默认不展示 SDK 金额,仅展示输入、输出及总 Token;
  • 用户主动开启「显示 SDK 估算」后,SDK 金额只按 value-estimate 展示,仍不进入消息 / 会话 / 今日支出的 actual-cost 账本;
  • 用户自定义价格和 Provider 参考价继续作为独立估算保留,不会被该开关一并清空;
  • Cindy AI Gateway 等已有可信结算路径继续按真实费用处理。

「设置 → Providers」中的开关默认关闭,并明确提示该数字不是供应商账单、可能与最终扣费不一致。设置采用默认值 + override;用户修改后可看到「已自定义」并恢复默认,恢复时删除 override。

变更类型

  • feat 新功能
  • fix 缺陷修复
  • refactor / perf 重构或性能优化
  • docs / test / chore 文档、测试或工程维护
  • 其他:

范围

  • 关联 Issue / 需求:Closes 自定义模型服务的费用估算与实际计费不一致,建议仅统计 Token #2855;产品确认讨论 维护者确认:自定义 Provider SDK 费用默认隐藏(PR #2878) #2884
  • 本 PR 包含:Desktop 设置 store、受信任 IPC、preload、renderer hook/UI;Claude / Codex / Pi 路由;消息、会话、今日支出、Scheduler 的估值投影。历史数据只做展示投影,不改写账本。Device link / Mobile 读取被控 Desktop 的只读偏好并使用同一投影。Scheduler 对升级前缺少 turnCostIsCustomProvider 的记录,用会话 / 任务 Provider 做 fail-closed 回填。侧栏费用改为 main 侧批量投影,避免逐会话全历史扫描。新增 append-only、幂等守卫的 0093_ancient_gorilla_man migration。Desktop 和 Mobile 的英文、简中、繁中、日文、韩文。
  • 明确不包含:替供应商维护真实账单规则、承诺 SDK 估值可对账、修改供应商最终扣费。
  • 用户可见变化:默认关闭时,消息、侧栏、状态栏、Mobile 与 Scheduler 均优先展示 Token 或保留的其他可信 / 独立估价;开启后 SDK 金额按估算展示。
  • 是否存在 breaking change:无。变化只在默认展示与费用分类;用户仍可显式查看 SDK 估算。

UI 变化

  • 「设置 → Providers」新增「显示 SDK 估算」开关、风险说明、「已自定义」状态和「恢复默认」入口。

  • 默认关闭时,消息、侧栏、状态栏、Mobile 与 Scheduler 均优先展示 Token 或保留的其他可信 / 独立估价。

  • 已完成 Light / Dark × 默认关闭 / 手动开启四种脱敏运行时截图并做视觉复核
    Light · 默认关闭 provider-billing-light-default
    Dark · 默认关闭 provider-billing-dark-default
    Light · 手动开启 provider-billing-light-enabled
    Dark · 手动开启 provider-billing-dark-enabled

  • 引用的设计规范: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;提示文案直接说明来源、不可控性和开启后果。

怎么验证的

自动验证

vitest run
  src/shared/__tests__/customProviderBilling.test.ts
  src/main/__tests__/patchMessageAgentMeta.test.ts
  src/renderer/__tests__/makerTransportRouting.test.ts
  src/renderer/features/cc-agent/sidebar/__tests__/sidebarSessionUsageStore.test.tsx
  src/main/right-sidebar-window/__tests__/preload-contract.test.ts
  src/renderer/lib/__tests__/customProviderCostPresentation.test.ts
结果:6 files / 57 tests passed

vitest run packages/device-link/src/__tests__/allowlist.test.ts
结果:1 file / 42 tests passed

git diff --check
结果:通过

先前已通过的 Desktop / Mobile typecheck、migration validate、i18n 对齐与 DCO 仍适用本 PR 主干改动。本次新增提交覆盖 Scheduler 旧记录归类、侧栏批量投影、device-link 只读 batch channel 与老被控端逐会话回退。

手工验证

  • Desktop 设置页完成 Light / Dark、默认关闭 / 手动开启四态验证;开关状态、风险文案、「已自定义」和恢复默认均符合预期。
  • 账本语义通过注入 SDK 估值、Token、用户价格、Provider 参考价与混合历史费用的自动化场景验证;未使用或提交任何供应商凭证。
  • 不把供应商后台金额对比列为 Cindy 可保证的验证项:本修复的目标正是将不可验证的 SDK 数字与真实支出账本隔离。

未执行的验证

  • 未对照供应商后台账单核验 SDK 数字;该数字本身不可由 Cindy 对账。

风险

风险分类

  • 无已知风险
  • SQLite / migration
  • system prompt
  • 协议兼容
  • 权限 / 安全 / 用户数据
  • 存量插件兼容(批准状态 / 指纹 / manifest 校验 / 安装布局 / 包格式)
  • 原生层 / fingerprint / OTA
  • 跨平台差异
  • 其他:

影响与回滚

  • 影响范围:SQLite 只追加 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 无改动。存量插件影响:无。
  • 回滚 / 降级方式:回滚本 PR 即可;新增列可保留且不会影响旧代码,设置默认值为关闭。老被控端没有 batch channel 时,控制端回退到既有逐会话只读查询。

提交前检查

  • 已 review 完整 diff
  • 每个 commit 都带 DCO 签名(git commit -s,见 DCO
  • UI 改动已在「UI 变化」注明引用的设计规范章节(不涉及 UI 则跳过)
  • 未提交凭证、令牌或授权文件
  • 已补充必要文档
  • 已确认测试结果或说明未执行原因

@A1aZ
A1aZ requested a review from a team as a code owner August 17, 2026 07:48
@greptile-apps

greptile-apps Bot commented Aug 17, 2026

Copy link
Copy Markdown

Greptile Summary

本 PR 将自定义 Provider 的 SDK 成本从实际支出账本中分离,并默认隐藏该估值,同时在 Desktop、Mobile、Scheduler 与 device-link 链路中统一展示投影。

  • 新增“显示 SDK 估算”偏好、可信 IPC、设置界面及多语言文案。
  • 为消息、会话、今日支出、侧栏和 Scheduler 增加实际费用与 SDK 估值的独立分类。
  • 扩展远端只读费用投影,并为旧版被控端保留兼容降级路径。
  • 新增 Scheduler 估值列的幂等脚本型迁移。

Confidence Score: 5/5

当前证据中没有仍需阻止合并的故障,本 PR 看起来可以安全合并。

未发现仍然存在的阻断性故障。

Important Files Changed

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 会话视图"]
Loading

Reviews (10): Last reviewed commit: "fix(billing): close remaining remote sid..." | Re-trigger Greptile

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread apps/desktop/src/main/maker-ipc/register.ts Outdated
Comment thread apps/desktop/src/renderer/components/settings/CustomProviderBillingSection.tsx Outdated
@MagicLizi

Copy link
Copy Markdown
Contributor

这个 PR 触及产品默认行为变化(自定义 Provider 的 SDK 费用由默认展示改为默认隐藏,并新增设置开关),自动流程已暂停合并,需要维护者确认。

维护者确认方式:直接在 PR 上 Approve;需要修改就 Request Changes,作者改完后再 Approve 即放行。在维护者确认前,这个 PR 会保持在待确认队列中,不会自动合并。

讨论 issue:#2884

@MagicLizi MagicLizi added awaiting-discussion 等待维护者讨论(review-pr) touches:core 改动碰到架构核心路径(review-pr 自动维护,仅展示) touches:product-ui 改动碰到产品 / UI 面(review-pr 自动维护,仅展示) labels Aug 17, 2026
@MagicLizi

Copy link
Copy Markdown
Contributor

@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。

@MagicLizi

Copy link
Copy Markdown
Contributor

命中 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 设计规范

@A1aZ
A1aZ force-pushed the fix/issue-2855-custom-provider-billing branch from f4470f0 to cb1c617 Compare August 18, 2026 13:06

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread packages/device-link/src/allowlist.ts

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread apps/mobile/src/session/sessionBillingProjection.ts
Comment thread apps/desktop/src/renderer/components/status/TodaySpendChip.tsx
@A1aZ
A1aZ force-pushed the fix/issue-2855-custom-provider-billing branch from a7d2802 to 7af9436 Compare August 18, 2026 14:05

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread apps/desktop/src/main/scheduler-host/storage.ts Outdated
Comment thread apps/desktop/src/renderer/features/cc-agent/sidebar/SessionInfoMeta.tsx Outdated
@MagicLizi MagicLizi added touches:large-diff 改动量较大(review-pr 自动维护,仅展示) touches:redline 改动碰到红线路径(updater / DB schema 等,review-pr 自动维护,仅展示) labels Aug 18, 2026
@MagicLizi

Copy link
Copy Markdown
Contributor

@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。

@MagicLizi

Copy link
Copy Markdown
Contributor

@A1aZ 👋 这个 PR 目前与 main 有合并冲突,auto-review 因此暂时跳过、没法继续审查 / 合并。

请在本地 merge 最新的 origin/main 解决冲突后推送;冲突解除后,下一轮 auto-review 会自动重新处理这个 PR。

A1aZ added 4 commits August 21, 2026 15:55
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>
@A1aZ
A1aZ force-pushed the fix/issue-2855-custom-provider-billing branch from 7af9436 to b5676ee Compare August 21, 2026 07:56

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread apps/desktop/src/main/localDb/ipc/messages.ts Outdated
Comment thread apps/desktop/src/renderer/features/cc-agent/CCAgentSessionView.tsx Outdated
A1aZ added 2 commits August 21, 2026 16:23
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>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread apps/desktop/src/main/localDb/ipc/messages.ts
Signed-off-by: Alan Z <3347202+A1aZ@users.noreply.github.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread apps/mobile/src/session/sessionBillingProjection.ts
Signed-off-by: Alan Z <3347202+A1aZ@users.noreply.github.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread apps/desktop/src/main/bootstrap-electron.ts
Comment thread apps/desktop/src/renderer/components/chat/MessageActionBar.tsx Outdated
Comment thread apps/desktop/src/renderer/components/status/TodaySpendChip.tsx Outdated
@MagicLizi

Copy link
Copy Markdown
Contributor

@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>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread apps/mobile/app/sessions/[sessionId].tsx
Comment thread apps/desktop/src/renderer/features/cc-agent/sidebar/SessionInfoMeta.tsx Outdated
@MagicLizi

Copy link
Copy Markdown
Contributor

@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>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment on lines 489 to 493
return invokeRemote(deviceId, 'local-db:messages:estimatedSessionValue', [
sessionId,
presentation,
showSdkEstimate,
]) as ReturnType<typeof estimatedSessionValueFor>;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 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 👍 / 👎.

Comment on lines +2363 to +2370
return {
entries: [],
presentation: resolveMobileSdkCostPresentation(
currentSession?.providerId,
composerDeviceProviders.providers,
false,
),
showSdkEstimate: false,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 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 👍 / 👎.

Comment on lines +368 to +372
const costPresentation = useSessionCustomProviderCostPresentation(
session.providerId,
remoteDeviceId,
);
const showSdkEstimate = useShowCustomProviderSdkEstimate(remoteDeviceId);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 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 👍 / 👎.

@MagicLizi

Copy link
Copy Markdown
Contributor

@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。

@MagicLizi

Copy link
Copy Markdown
Contributor

@A1aZ 👋 这个 PR 目前与 main 有合并冲突,auto-review 因此暂时跳过、没法继续审查 / 合并。

请在本地 merge 最新的 origin/main 解决冲突后推送;冲突解除后,下一轮 auto-review 会自动重新处理这个 PR。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting-discussion 等待维护者讨论(review-pr) touches:core 改动碰到架构核心路径(review-pr 自动维护,仅展示) touches:large-diff 改动量较大(review-pr 自动维护,仅展示) touches:product-ui 改动碰到产品 / UI 面(review-pr 自动维护,仅展示) touches:redline 改动碰到红线路径(updater / DB schema 等,review-pr 自动维护,仅展示)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

自定义模型服务的费用估算与实际计费不一致,建议仅统计 Token

2 participants