Skip to content

fix(inject): 适配新版 Codex 输入框额度耗尽横幅并修复切换闪烁 - #2229

Merged
BigPizzaV3 merged 8 commits into
BigPizzaV3:mainfrom
Rat0323:fix/composer-usage-alert
Sep 22, 2026
Merged

BigPizzaV3 merged 8 commits into
BigPizzaV3:mainfrom
Rat0323:fix/composer-usage-alert

Conversation

@Rat0323

@Rat0323 Rat0323 commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

变更背景

Codex 26.915 把官方低额度提示从左下角挪到了输入框上方,而且不能关闭。切换会话时,注入脚本的全量扫描有 200ms 防抖,横幅会先画出来再被藏掉。

旧版卡片仍在左下角:aside.app-shell-left-panel 里带 progress 和「关闭使用量提醒」按钮。两边都要能关,但不能把沙箱、安全、上传失败这类 composer 提示一起藏掉。

修复内容

  1. 旧版左下角:CSS 只预隐藏带进度条、且关闭按钮文案是 Dismiss usage alert / 关闭使用量提醒 / 關閉用量提示 / 關閉使用量警示 的 status。排除条件写在卡片上,不再写在整块侧边栏上。
  2. 新版输入框上方:不再使用「[data-codex-composer-root] aside 只要有标题就先 display: none」。26.915 的横幅和沙箱、安全提示共用 aside > h3,那条规则会误伤。
  3. 防闪:MutationObserver 回调里同步跑额度识别,不等 200ms 的全量 scan。识别依据是标题,覆盖 26.915 的简体文案,包括 你的 Codex 和工作使用额度已用完你的 Codex 和工作用量均已用完您即将达到使用限额此模型的使用额度已用完所选模型已超出使用限额,以及对应的英文耗尽、即将用尽和模型额度标题。
  4. 只给真正的额度提示写 data-codex-plus-usage-alert-hidden="true"。其它提示不再被标成 false 后靠宽 CSS 放出来。

测试

  • apps/codex-plus-manager: npm test 235 passed。

- 适配新版将额度耗尽提示移至 [data-codex-composer-root] aside 的 DOM 结构
- 增加 composerUsageAlertBanners,支持常见中英、繁体额度文案精准匹配
- 优化 officialUsageAlertContainer 提取单一子元素父容器,避免留白
- 在 installStyle 中增加局部 :has 预隐藏规则,解决切换会话瞬间闪烁
- 更新与补充 renderer-inject.test.ts 单元测试,确保回归测试通过
- 精确限制 CSS 防闪烁选择器至 billing/upgrade 特征,避免误伤 composer 其他普通通知
- 增强正则对多行排版、空白符规范化与常见限额提示的覆盖能力,并补充升级操作兜底
- 加固 officialUsageAlertContainer 容器判定,防止意外隐藏根级或表单容器
- 将 refreshOfficialUsageAlertVisibility 改为增量更新,减少高频 scan 下的 DOM 扰动
- 扩展 renderer-inject.test.ts,增加防误伤负向断言与多语言用例
旧版左下角只预隐藏带进度条和关闭按钮的额度卡。新版输入框横幅不再用「有标题就隐藏」的 CSS,改为在 MutationObserver 回调里按 26.915 的中英文标题同步判定,不等 200ms 全量扫描。非额度提示不再被标成隐藏。
@BigPizzaV3
BigPizzaV3 merged commit 53169da into BigPizzaV3:main Sep 22, 2026
3 checks passed
@Rat0323
Rat0323 deleted the fix/composer-usage-alert branch September 22, 2026 18:34
Sign up for free to 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