Repository navigation
Conversation
…asts Carry sessionId on PROVIDER_UPSTREAM_ERROR events across Claude Code, Codex proxy, and Codex bridge paths, isolate main-process throttling by session and retryable-5xx bucket so background or 529 errors never starve foreground 4xx alerts, and restrict renderer provider error toasts to visible foreground sessions while suppressing retryable 5xx responses that CLI retries automatically. Assisted-by: Cindy (https://cindy.app) Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
zqchris
approved these changes
Dec 5, 2026
zqchris
left a comment
Contributor
There was a problem hiding this comment.
Auto-approved by Chris’s trusted-author rule for makecindy/cindy. This is an automated approval.
Confidence Score: 4/5
[Medium impact] The PR changes provider-error notifications in the desktop app. 本次修改整体可合并,但工具面板撑满时,隐藏主会话仍弹提示的问题值得补齐。 Findings
Fix with agent prompt### Issue 1
apps/desktop/src/renderer/features/cc-agent/CCAgentSessionView.tsx:1177-1180
用户将右侧栏或其他工具面板撑满后,主会话虽然已经看不见,却仍被登记为前台会话。`viewVisible` 默认是 `true`;撑满操作只通过 CSS 隐藏聊天区或将其宽度设为零,没有改变这个值,也没有卸载组件。因此,该会话随后出现的 401、429 等错误仍会弹出全局提示,打扰正在查看其他面板的用户。
建议让登记条件同时跟随聊天区的实际可见状态,并补充撑满、还原的回归测试。
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
|
DavidShenXD
approved these changes
Dec 5, 2026
Assisted-by: Cindy (https://cindy.app) Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
这次改了什么
摘要
修复自定义(含组织下发 BYOK)供应商遇到上游 5xx 或后台任务出错时,向用户当前正在看的窗口误弹全局 toast 的问题:
UPSTREAM_ERROR与 529RATE_LIMITED)时,CLI/proxy 会自动退避重试;若最终耗尽重试,失败会正常落到对应会话内的ErrorBanner,不再每次单次抖动都弹全局 warning toast。ProviderUpstreamErrorEvent中补齐sessionId(覆盖 Claude Code 代理、Codex HTTP 代理及 Codex Chat / Anthropic 桥接路径),保持resolveUserSessionId对observeHealth/observeVerifiedResponse的原有语义不变。(sessionId, providerId, code, 5xx/non5xx)有界分桶隔离(上限 256 条,过期清理 + 最旧淘汰),避免后台会话或被 renderer 静默的529占掉节流槽而饿死前台会话随后的401/429提示。CCAgentSessionView挂载且viewVisible为真时通过引用计数登记当前窗口的前台会话;handleProviderUpstreamError仅在「非可重试 5xx + 归属当前窗口前台可见会话 + 窗口对用户可见(document.visibilityState === 'visible' && !isWindowHidden())」时弹 toast,后台 Worker、定时任务、未打开会话、折叠 rail/侧栏或隐藏窗口一律静默。变更类型
feat新功能fix缺陷修复refactor/perf重构或性能优化docs/test/chore文档、测试或工程维护范围
apps/desktop/src/shared/providerErrors.ts:新增共享isRetryableUpstream5xx判定。apps/desktop/src/main/maker-host/provider-upstream-error-observer.ts、anthropicCompatProxyHostCore.ts、codex-proxy-host.ts、maker-ipc/channels.ts:事件透传sessionId,按会话与 5xx/non5xx 分桶有界节流。apps/desktop/src/renderer/lib/providerUpstreamErrorToast.ts、CCAgentSessionView.tsx、vite-env.d.ts:前景可见会话引用计数登记、窗口可见性与可重试 5xx 过滤。providerUpstreamErrorObserver.test.ts、providerUpstreamErrorToast.test.ts:补充回归单测。observeHealth对 401/402/429/529 的账号健康度捕获,不改ErrorBanner会话内最终失败展示,不改服务端网关超时策略。UI 变化
不涉及(未修改组件布局、样式或文案)。
怎么验证的
自动验证
新增/改写测试价值说明(
engineering-conventions.md§3.2):apps/desktop/src/main/maker-host/__tests__/providerUpstreamErrorObserver.test.ts(unit,单跑 ~8ms):经真实createProviderUpstreamErrorObserver与reportProviderUpstreamError入口 + 注入时钟验证;补齐「后台会话错误不压制前台会话」「resolveSessionId与resolveUserSessionId分离归属」「529不占429节流槽」三类缺口(最小失败输入:30s 内同 provider 先后触发bg-session/fg-session401 或同会话先 529 后 429)。apps/desktop/src/renderer/lib/providerUpstreamErrorToast.test.ts(unit / jsdom,单跑 ~3ms):经真实handleProviderUpstreamError、registerForegroundSession、installProviderUpstreamErrorToastListener与hiddenAnimationGate入口验证;补齐「可重试 5xx(500/502/503/504/529)静默」「非前台/无sessionId静默」「429 与非可重试 500 保留」「重叠挂载引用计数与幂等注销」「visibilityState与主进程隐藏闸门静默」五类缺口(最小失败输入:前台登记fg-session后投递bg-worker401 或fg-session504)。通知与读写开销核查:
CCAgentSessionView卸载或viewVisible=false时立即注销引用计数,隐藏窗口经isWindowHidden()静默。手工验证
不涉及(核心过滤、跨进程透传、节流隔离与隐藏闸门已由确定性单测覆盖)。
未执行的验证
风险
风险分类
影响与回滚
PROVIDER_UPSTREAM_ERROR事件新增可选sessionId字段(向后兼容)。提交前检查
git commit -s,见 DCO)和每次通知触发几次 list/扫描/IPC/写事务(读远程数据再写远程调用次数和回包字节),以及隐藏或
卸载后是否停止(见
docs/dev-rules/engineering-conventions.md§8;远程读取同时见docs/dev-rules/server-channel-review.md)apps/docs或说明自动同步会从哪些来源更新。Assisted-by: Cindy (https://cindy.app)
Note
Low Risk
Changes only error-toast gating and optional event metadata; no auth, persistence, or protocol breaking changes.
Overview
Stops mis-timed global toasts when custom/BYOK provider failures happen in background work or during transient retryable 5xx, while keeping real signals (401, 429, non-retryable errors) for the chat the user is actually viewing.
Main now tags
PROVIDER_UPSTREAM_ERRORwith optionalsessionId(Codex HTTP + bridge paths, Claude compat proxy viaresolveSessionIdseparate fromresolveUserSessionId). The 30s broadcast throttle keys on(sessionId, providerId, code)with5xx/non-5xxbuckets and a capped throttle map so a background session—or a renderer-silent 529—does not swallow a later 429 or auth toast for the foreground session.Renderer adds
isRetryableUpstream5xxfiltering (no toast for retryable 500–529; sessionErrorBannerstill owns final failure).registerForegroundSessioninCCAgentSessionView(ref-counted, visibility-aware) gates toasts to the current visible window and visible chat shell; hidden document / hidden-window animation gate stays silent.IPC/channel typings document the new field; observer and toast tests cover session isolation, 529 vs 429 bucketing, and foreground suppression.
Reviewed by Cursor Bugbot for commit 0f9c753. Bugbot is set up for automated code reviews on this repo. Configure here.