Skip to content

feat(web): display composer countdown indicators in HostUsageDock - #1113

Merged
iruriQ merged 1 commit into
mainfrom
feat/web-composer-indicators
Nov 24, 2026
Merged

iruriQ merged 1 commit into
mainfrom
feat/web-composer-indicators

Conversation

@BytePioneer-AI

Copy link
Copy Markdown
Owner

Summary

Display Thread usage composerIndicators (e.g. Claude Code's prompt cache countdown) in Standalone Web's composer dock (HostUsageDock), matching the existing Host contract already projected into codexhostUsage.

Changes

  • apps/web-ui/packages/client/ui-codexhost/src/client/usage.ts: Reuse ThreadUsageSnapshot["composerIndicators"] from @codexhost/shared-contracts on HostThreadUsage.
  • apps/web-ui/packages/client/ui-codexhost/src/client/locales.ts: Add English and Chinese remaining-minute strings (usage.indicator.remaining).
  • apps/web-ui/packages/client/ui-codexhost/src/client/HostUsageDock.tsx & HostUsageDock.module.css:
    • Render active countdown indicators independently between account quota and usage summary in HostUsageDock, suppressed on official Codex Threads (harnessIdentity?.id === "codex").
    • Match Desktop semantics: visible only when 0 < remaining <= 50m, formatted as clock icon + {minutes}m, refreshed on window-entry/minute boundaries and visibilitychange, hidden and timer-cleaned on expiry.
    • Localize label/tooltip via localizeHarnessText and show details with Tooltip (side="top", portal, openOnClick) for desktop hover/keyboard focus and touch tap without side-effect actions.
    • Yield before public quota/usage controls on narrow viewports via ResizeObserver, taking the clipped indicator out of flex flow so no blank gap remains and restoring it automatically when space returns.
  • docs/architecture/harness-plugin-runtime.md: Document Standalone Web display placement and behavior for composerIndicators.

Demo Screenshots (sanitized fixture)

Desktop Default Desktop Hover Tooltip
Desktop Default Desktop Hover Tooltip
Mobile 390px (Yields Cleanly Without Gap) Mobile 460px (Restored + Tap-to-Pin Tooltip)
Mobile 390px Squeezed Mobile 460px Restored and Tapped

Validation

  • prettier --check on all 5 edited files: passed
  • tsc -p apps/web-ui/tsconfig.json --noEmit: passed
  • Rebuilt @deepseek-ai/dsh-client-ui-codexhost browser bundle (tsdown): passed
  • Verified live rendering in Chromium against an isolated web-server + mock CH host fixture:
    • Desktop default & hover tooltip (提示词缓存 · 剩余 33 分钟)
    • Click/tap pinned tooltip (openOnClick)
    • Mobile 390px overflow yield (exact 12px uniform dock gap, no clipped icon) and 460px automatic restoration
    • Official Codex Thread suppression (hasIndicator: false)

@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create an environment for this repo.

@coderabbitai

coderabbitai Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • 新功能
    • 使用量面板现在可显示 Composer 指示器的本地化倒计时;剩余时间不超过 50 分钟时显示,并在指示器过期后自动隐藏。
    • 指示器会根据界面空间调整显示,避免被裁切时遮挡其他内容。
  • 文档
    • 补充了不同界面中 Composer 倒计时的显示位置说明。

HostUsageDock 新增 composer 指示器倒计时展示。组件按剩余时间筛选指示器,并在页面可见时刷新。HostThreadUsage 类型及英文、中文文案也作了扩展。

Changes: Composer 指示器倒计时

层 / 文件 摘要
Usage 类型和倒计时文案
apps/web-ui/packages/client/ui-codexhost/src/client/usage.ts, apps/web-ui/packages/client/ui-codexhost/src/client/locales.ts
HostThreadUsage 新增可选的 composerIndicators 属性。英文和中文 locale 新增剩余分钟数文案。
倒计时组件与 HostUsageDock 集成
apps/web-ui/packages/client/ui-codexhost/src/client/HostUsageDock.tsx, apps/web-ui/packages/client/ui-codexhost/src/client/HostUsageDock.module.css, docs/architecture/harness-plugin-runtime.md
HostUsageDock 在 harness ID 不是 codex 时传入 usage 中的 composer 指示器。组件显示未过期且剩余时间不超过 50 分钟的指示器,并按时间变化或页面重新可见刷新。组件测量裁切状态,并在裁切时禁用 tooltip。样式和架构文档同步新增对应展示说明。

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant HostThreadUsage
  participant HostUsageDock
  participant ComposerIndicators
  participant localizeHarnessText
  participant Document
  HostThreadUsage->>HostUsageDock: 提供 composerIndicators
  HostUsageDock->>ComposerIndicators: 传入所选指示器和翻译函数
  ComposerIndicators->>localizeHarnessText: 获取剩余时间文案
  Document->>ComposerIndicators: 页面变为可见时触发刷新
Loading

Possibly related PRs

Suggested reviewers: chacelyee2101, mouzhi

Merge Risk: Minimal · up to 34205

This change adds composer countdown indicators to the web dock and hides them on official Codex threads. No concrete merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed 标题“feat(web): display composer countdown indicators in HostUsageDock”准确描述了主要变更:在 HostUsageDock 中显示 composerIndicators 倒计时。变更文件包括 HostUsageDock.tsx、HostUsageDock.module.css、usage.ts、locales.ts 和文档,均与标题…
Description check Passed 描述与变更内容高度相关。描述说明了在 HostUsageDock 中显示 composerIndicators、本地化文案、Tooltip 行为、ResizeObserver 窄屏让位、以及文档更新,并列出了验证步骤。这与原始摘要中的文件变更和目标一致。
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

标题“feat(web): display composer countdown indicators in HostUsageDock”准确描述了主要变更:在 HostUsageDock 中显示 composerIndicators 倒计时。变更文件包括 HostUsageDock.tsx、HostUsageDock.module.css、usage.ts、locales.ts 和文档,均与标题一致。标题未涵盖抑制 codex 线程显示、窄屏让位等细节,但这属于可接受范围。

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
Fix failing CI checks

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 8fac402 and 34205e9.

Files selected for processing: 5

  • apps/web-ui/packages/client/ui-codexhost/src/client/HostUsageDock.module.css
  • apps/web-ui/packages/client/ui-codexhost/src/client/HostUsageDock.tsx
  • apps/web-ui/packages/client/ui-codexhost/src/client/locales.ts
  • apps/web-ui/packages/client/ui-codexhost/src/client/usage.ts
  • docs/architecture/harness-plugin-runtime.md

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 4 remain after this review.

Recent review details

Context from checks skipped due to timeout: 8

  • GitHub Check: CodeRabbit
  • GitHub Check: Check Linux ARM64
  • GitHub Check: Check ubuntu-22.04
  • GitHub Check: Check macos-26
  • GitHub Check: Check windows-latest
  • GitHub Check: Static checks
  • GitHub Check: Web Host tests
  • GitHub Check: Vitest
Additional context used

Code guidelines: 1

AGENTS.md — auto-discovered
Path-based instructions: 1

Source excerpt: Do not write browser, e2e, or component tests for Web pages (`apps/web-ui`); the user checks page changes directly.

CodeRabbit inference engine (AGENTS.md)

Files:

  • apps/web-ui/packages/client/ui-codexhost/src/client/HostUsageDock.module.css
  • apps/web-ui/packages/client/ui-codexhost/src/client/HostUsageDock.tsx
  • apps/web-ui/packages/client/ui-codexhost/src/client/locales.ts
  • apps/web-ui/packages/client/ui-codexhost/src/client/usage.ts
Additional comments: 2

apps/web-ui/packages/client/ui-codexhost/src/client/usage.ts: 1

6-6: Data Integrity & Integration

当前评论所指的机制不成立。parseHostUsage 位于 packages/harness-adapter/src/usage.ts,它显式保留 composerIndicators。apps/web-ui 中的 usage.ts 只新增了类型声明,不包含转换逻辑。

apps/web-ui/packages/client/ui-codexhost/src/client/HostUsageDock.tsx: 1

502-503: Functional Correctness

当前代码不存在该问题。.dock 按内容宽度收缩,不会铺满父容器,因此隐藏指示器后 dock.scrollWidth 会随之减小,needed 可以回落到可用宽度以内,clipped 能恢复为 false。

@iruriQ
iruriQ merged commit 62b9a6b into main Nov 24, 2026
6 of 8 checks passed
@iruriQ

iruriQ commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator

已在隔离 Web 实测通过全部 5 项场景(1280px 外部 Harness 倒计时胶囊与悬停 Tooltip、390px 窄屏让位不留白与拉宽恢复点按 Tooltip、>50m/过期过滤、官方 Codex 抑制,全程 0 报错),已合入 main。

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