Skip to content

[Bug] MEMMY-741 账号模式,computer history设置页,提示:暂时无法确认自定义 API Key 的 Token 用量和限额,将稍后自动重试。 - #904

Open
Memtensor-AI wants to merge 1 commit into
MemTensor:agent/bug-reviewfrom
Memtensor-AI:bugfix/yunxiao-b58a3abffa45ea7f-r2
Open

Memtensor-AI wants to merge 1 commit into
MemTensor:agent/bug-reviewfrom
Memtensor-AI:bugfix/yunxiao-b58a3abffa45ea7f-r2

Conversation

@Memtensor-AI

Copy link
Copy Markdown
Collaborator

Coding Agent 修复报告

云效工单:MEMMY-741 · 账号模式,computer history设置页,提示:暂时无法确认自定义 API Key 的 Token 用量和限额,将稍后自动重试。

memmy-agent · 第 2 轮 · 修复提交 88742189

修复已完成规定检查:22/30 项规定检查通过;8 项测试所在的包未受本次修改影响,未执行。

待人工 Review 与验收;未合并、未部署。

问题与根因

App/frontend/desktop/src/pages/memory/computer-history-sub-page.tsx の narrationErrorMessage 計算ロジック(旧 lines 353-359)が、history_summary_budget_unavailable と history_summary_budget_paused の2つのエラーコードに対して modelSource を確認せず、常に BYOK 専用メッセージ(「暂时无法确认自定义 API Key 的 Token 用量和限额,将稍后自动重试。」)を返していた。account モード(modelSource が "byok" でない場合)でも同じメッセージが表示されていた。

本轮修改

  1. App/frontend/desktop/src/pages/memory/computer-history-sub-page.tsx(narrationErrorMessage 计算):const modelSource = snapshot?.observation.modelSource; を追加し、history_summary_budget_unavailable と history_summary_budget_paused の条件分岐に modelSource === "byok" チェックを加えた。BYOK モードでのみ BYOK 専用メッセージを返し、account モードでは null を返すよう修正。

  2. 同ファイル(レンダー条件):JSX の2箇所(外側コンテナ条件・内側 alert 条件)で narrationError を narrationErrorMessage に変更。narrationErrorMessage が null の場合に空の role="alert" div がレンダーされることを防ぐ。

  3. App/frontend/desktop/src/pages/tests/computer-history-sub-page.interaction.test.tsx:account モード(modelSource なし)で history_summary_budget_unavailable および history_summary_budget_paused が来たときに、BYOK 専用の alert が表示されないことを検証する it.each テストブロックを追加。

变更文件

2 个文件,+17 / −4 行。

文件 新增 删除
App/frontend/desktop/src/pages/memory/computer-history-sub-page.tsx 5 4
App/frontend/desktop/src/pages/tests/computer-history-sub-page.interaction.test.tsx 12 0

验证结果

检查 类型 结果 用例数 执行 / 退出码
prepare-1 检查 ✅ 通过 未记录 已执行 / 0
prepare-2 检查 ✅ 通过 未记录 已执行 / 0
prepare-3 检查 ✅ 通过 未记录 已执行 / 0
prepare-4 检查 ✅ 通过 未记录 已执行 / 0
prepare-5 构建 ✅ 通过 未记录 已执行 / 0
prepare-6 构建 ✅ 通过 未记录 已执行 / 0
prepare-7 构建 ✅ 通过 未记录 已执行 / 0
prepare-8 检查 ✅ 通过 未记录 已执行 / 0
prepare-9 构建 ✅ 通过 未记录 已执行 / 0
verify-1 检查 ✅ 通过 未记录 已执行 / 0
verify-2 代码规范 ✅ 通过 未记录 已执行 / 0
verify-3 类型检查 ✅ 通过 未记录 已执行 / 0
verify-4 类型检查 ✅ 通过 未记录 已执行 / 0
verify-5 测试 ✅ 通过 182 已执行 / 0
verify-6 测试 ✅ 通过 129 已执行 / 0
verify-7 测试 ✅ 通过 8 已执行 / 0
verify-8 测试 ✅ 通过 24 已执行 / 0
verify-9 测试 ⏭ 未受影响,未执行 不适用 未执行
verify-10 测试 ⏭ 未受影响,未执行 不适用 未执行
verify-11 测试 ⏭ 未受影响,未执行 不适用 未执行
verify-12 测试 ⏭ 未受影响,未执行 不适用 未执行
verify-13 测试 ⏭ 未受影响,未执行 不适用 未执行
verify-14 测试 ⏭ 未受影响,未执行 不适用 未执行
verify-15 测试 ✅ 通过 3157 已执行 / 0
verify-16 测试 ⏭ 未受影响,未执行 不适用 未执行
verify-17 测试 ✅ 通过 7274 已执行 / 0
verify-18 测试 ⏭ 未受影响,未执行 不适用 未执行
verify-19 测试 ✅ 通过 5 已执行 / 0
verify-20 测试 ✅ 通过 3 已执行 / 0
verify-21 测试 ✅ 通过 3 已执行 / 0

verify-9:只覆盖 Memory,本次修改影响的包是 App/frontend/desktop,因此未执行;合并前如需全量回归请人工触发。
verify-10:只覆盖 Migrations,本次修改影响的包是 App/frontend/desktop,因此未执行;合并前如需全量回归请人工触发。
verify-11:只覆盖 AgentSourceCore,本次修改影响的包是 App/frontend/desktop,因此未执行;合并前如需全量回归请人工触发。
verify-12:只覆盖 Knowledge,本次修改影响的包是 App/frontend/desktop,因此未执行;合并前如需全量回归请人工触发。
verify-13:只覆盖 App/backend/local-api-contracts,本次修改影响的包是 App/frontend/desktop,因此未执行;合并前如需全量回归请人工触发。
verify-14:只覆盖 App/backend,本次修改影响的包是 App/frontend/desktop,因此未执行;合并前如需全量回归请人工触发。
verify-16:只覆盖 App/shell/desktop,本次修改影响的包是 App/frontend/desktop,因此未执行;合并前如需全量回归请人工触发。
verify-18:只覆盖 App/memmy-agent,本次修改影响的包是 App/frontend/desktop,因此未执行;合并前如需全量回归请人工触发。

未验证项

  • 修复 Agent 未声明额外未验证项。

验收步骤(给测试同学)

  1. account モード(BYOK 未設定)で「computer history 設定ページ」を開く。
  2. バックエンドが narrationError: "history_summary_budget_unavailable" または "history_summary_budget_paused" を返す状態を再現する。
  3. 画面上部にピンクのエラーバナーが表示されないこと(または「自定义 API Key」に関する文言が含まれないこと)を確認する。
  4. BYOK モード(カスタム API Key 設定済み)で同じ状態を再現し、「暂时无法确认自定义 API Key 的 Token 用量和限额,将稍后自动重试。」が表示されることを確認する。
  5. BYOK・account 両モードで history_summary_accounting_unavailable エラーは引き続き「摘要用量记录暂未同步,将稍后自动重试。」が表示されること(このエラーは両モード共通)を確認する。

⚠️ 假设与边界

  • 假设:後端は account モードでも history_summary_budget_unavailable / history_summary_budget_paused を送信することがあるが、frontend 側でフィルタリングするのが正しい対応(後端の修正は将来別途検討)。
  • 假设:observation.modelSource が undefined(フィールド未設定)の場合は account モードと同等に扱い、BYOK 専用メッセージを表示しない。
  • 未覆蓋场景:後端が account モードで history_summary_budget_unavailable を送る場合、現在はこのエラーが静かに無視される(ユーザーに何も表示されない)。将来的に account モード向けの別メッセージが必要な場合は追加実装が必要。
  • 影响範囲:computer history 設定ページのみ。history_summary_accounting_unavailable や不明エラーコードの表示ロジックは変更なし。

修复计划与定位过程

  • 根因假设:narrationErrorMessage 계산 시 history_summary_budget_unavailable 및 history_summary_budget_paused 에러 코드에서 modelSource 를 확인하지 않아 account 모드에서도 BYOK 전용 에러 메시지가 표시됨
  • 计划修改的文件:
    • App/frontend/desktop/src/pages/memory/computer-history-sub-page.tsx
    • App/frontend/desktop/src/pages/tests/computer-history-sub-page.interaction.test.tsx
  • 重规划次数:0

交付信息

项目 内容
云效工单 MEMMY-741
修复提交 88742189
比较基线 99b51b37
分支 bugfix/yunxiao-b58a3abffa45ea7f-r2 → agent/bug-review
修复轮次 第 2 轮

待人工确认(不影响本次修复)

  • 后端是否有计划在账号模式停止下发这两个错误码(若有则只需前端临时 workaround)

需求整理与定位证据

需求整理(EARS)

  • When the user is in account mode and narrationError is history_summary_budget_unavailable, the system shall NOT display the BYOK-specific error message
  • When modelSource is byok and narrationError is history_summary_budget_unavailable, the system shall display the BYOK-specific error message

验收条件

  • 账号模式下(modelSource !== byok),narrationError 为 history_summary_budget_unavailable 或 history_summary_budget_paused 时,不展示「自定义 API Key」相关文案
  • BYOK 模式下(modelSource === byok)仍正常展示对应 BYOK 文案
  • 修复后交互测试全部通过

定位证据

  • App/frontend/desktop/src/pages/memory/computer-history-sub-page.tsx:350-365(memmy-agent · ref=agent/bug-review · 99b51b3);理由:narrationErrorMessage 计算逻辑:对 history_summary_budget_unavailable 和 history_summary_budget_paused 未检查 modelSource,导致账号模式也展示 BYOK 专属文案
  • App/frontend/desktop/src/pages/memory/computer-history-sub-page.tsx:507-516(memmy-agent · ref=agent/bug-review · 99b51b3);理由:narration 错误渲染位置,在 !narrationQuotaExhausted 时直接展示 narrationErrorMessage
  • App/frontend/desktop/src/pages/tests/computer-history-sub-page.interaction.test.tsx:829-844(memmy-agent · ref=agent/bug-review · 99b51b3);理由:测试用例仅在 modelSource: byok 下验证 BYOK 状态文案,说明预期行为是按 modelSource 过滤
  • App/frontend/desktop/src/i18n/messages.ts:1591-1591(memmy-agent · ref=agent/bug-review · 99b51b3);理由:narrationBudgetUnavailable 文案来源

修复结果供人工 Review 与验收;Coding Agent 不自动合并。

@Memtensor-AI

Copy link
Copy Markdown
Collaborator Author

🤖 Open Code Review

Target: PR #904
Task: f3543f2e09c365d8
Base: agent/bug-review
Head: bugfix/yunxiao-b58a3abffa45ea7f-r2
Head SHA: 887421897e02e3c6681b35e5237dc388b117d7a7

🔍 OpenCodeReview found 1 issue(s) in this PR.


1. App/frontend/desktop/src/pages/memory/computer-history-sub-page.tsx (L357)

This change deepens an already nested ternary chain to four levels and repeats the modelSource === "byok" check (the same comparison also appears at line 362), which hurts readability. Prefer a small mapping/helper so the per-code message and its model-source condition live in one place, e.g.:

const byokOnlyMessage = (message: string) => (modelSource === "byok" ? message : null);

and then narrationError === "history_summary_budget_unavailable" ? byokOnlyMessage(t(...)) : ..., or extract a narrationMessage(narrationError, isByok) function above the component.

💡 Suggested Change

Before:

      ? (modelSource === "byok" ? t("computerHistory.narrationBudgetUnavailable") : null)

After:

      ? (modelSource === "byok" ? t("computerHistory.narrationBudgetUnavailable") : null)

Generated by cloud-assistant via Open Code Review.

@Memtensor-AI

Copy link
Copy Markdown
Collaborator Author

✅ Automated Test Results: PASSED

Required tests passed (92/92 executed, 0 skipped). Duration: 29s

Branch: bugfix/yunxiao-b58a3abffa45ea7f-r2

Tested source: 887421897e02e3c6681b35e5237dc388b117d7a7
Tested base: 99b51b3759b12d1e5c93be5d5d7148200e443d3e
Tested commit: 887421897e02e3c6681b35e5237dc388b117d7a7
These results apply only to this immutable source/base snapshot.

This branch has not been deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants