feat(dashboard): range hit-rate card + chart panel + 5min granularity, proxy diag logs#439
Merged
icebear0828 merged 2 commits intodevfrom May 4, 2026
Merged
Conversation
…, proxy diag logs - UsageStats 新增「时段命中率」卡片(按当前时间窗口聚合 cached/input) - UsageChart 新增「Hit Rate Over Time」面板:折线 + 数据点 dot,input=0 自动跳过 - 后端 + 前端支持 `five_min` granularity(5 分钟一桶,配合默认 5min snapshot) - 新增 Last 1h / Last 6h 时间窗,granularity 切换时自动收敛兼容窗口 - shared/utils/usage-stats.ts 抽取 formatHitRate / sumWindow / formatUsageNumber, 补单测覆盖边界(input=0、<0.01% 截断、windowed 求和) - proxy-handler 入口/Usage 日志补诊断字段:rid / conv / key / prev=<src>:tail8 / tools=N / hit=X.X%,便于排查 prompt-cache 命中率为何偏低
…e routing - 上游请求新增 `x-codex-installation-id` header + body 内 `client_metadata` 对齐真实 codex CLI(core/src/client.rs:874)。优先复用 `~/.codex/installation_id`, 否则在 `data/installation_id` 持久化生成的 UUID。HTTP / WS / compact 三条路径都带。 - proxy-handler 入口日志加 `resume=on|off:<reason>` 字段,区分 implicit resume 实际激活 vs 因 instr_diff / acct_mismatch / missing_tool_calls 等被否决的情况。 `evaluateImplicitResume()` 替代 `shouldActivateImplicitResume()` 作为内部判定, 保留旧 API 作为薄包装。 - 实测:installation_id 单独不能修复缓存命中率抖动(见后续 WS 池修复 PR)。
7 tasks
icebear0828
added a commit
that referenced
this pull request
May 5, 2026
The soak check measures `now - dev_HEAD_timestamp >= 24h`, which means every new merge into dev resets the clock. Under any non-trivial merge cadence, dev never satisfies the soak gate and master stagnates: PRs #437/#438/#439/#440/#442 all stacked on dev for a week with no promotion. Add a `force_skip_soak` boolean input to workflow_dispatch (default false). Schedule cron remains untouched and continues to enforce the 24h rule. Only manual triggers can bypass, and only when the operator explicitly sets the input to true — intended for sync-back / merge commits whose content has actually been on dev long enough but whose HEAD timestamp is misleadingly fresh. Test plan: yaml syntax verified via js-yaml. Functional verification will be the next manual workflow_dispatch run with the input set. Co-authored-by: icebear0828 <icebear0828@users.noreply.github.com>
icebear0828
added a commit
that referenced
this pull request
May 5, 2026
…, proxy diag logs (#439) * feat(dashboard): range hit-rate card + chart panel + 5min granularity, proxy diag logs - UsageStats 新增「时段命中率」卡片(按当前时间窗口聚合 cached/input) - UsageChart 新增「Hit Rate Over Time」面板:折线 + 数据点 dot,input=0 自动跳过 - 后端 + 前端支持 `five_min` granularity(5 分钟一桶,配合默认 5min snapshot) - 新增 Last 1h / Last 6h 时间窗,granularity 切换时自动收敛兼容窗口 - shared/utils/usage-stats.ts 抽取 formatHitRate / sumWindow / formatUsageNumber, 补单测覆盖边界(input=0、<0.01% 截断、windowed 求和) - proxy-handler 入口/Usage 日志补诊断字段:rid / conv / key / prev=<src>:tail8 / tools=N / hit=X.X%,便于排查 prompt-cache 命中率为何偏低 * fix(proxy): send x-codex-installation-id + log resume reason for cache routing - 上游请求新增 `x-codex-installation-id` header + body 内 `client_metadata` 对齐真实 codex CLI(core/src/client.rs:874)。优先复用 `~/.codex/installation_id`, 否则在 `data/installation_id` 持久化生成的 UUID。HTTP / WS / compact 三条路径都带。 - proxy-handler 入口日志加 `resume=on|off:<reason>` 字段,区分 implicit resume 实际激活 vs 因 instr_diff / acct_mismatch / missing_tool_calls 等被否决的情况。 `evaluateImplicitResume()` 替代 `shouldActivateImplicitResume()` 作为内部判定, 保留旧 API 作为薄包装。 - 实测:installation_id 单独不能修复缓存命中率抖动(见后续 WS 池修复 PR)。 --------- Co-authored-by: icebear0828 <icebear0828@users.noreply.github.com>
icebear0828
added a commit
that referenced
this pull request
May 5, 2026
The soak check measures `now - dev_HEAD_timestamp >= 24h`, which means every new merge into dev resets the clock. Under any non-trivial merge cadence, dev never satisfies the soak gate and master stagnates: PRs #437/#438/#439/#440/#442 all stacked on dev for a week with no promotion. Add a `force_skip_soak` boolean input to workflow_dispatch (default false). Schedule cron remains untouched and continues to enforce the 24h rule. Only manual triggers can bypass, and only when the operator explicitly sets the input to true — intended for sync-back / merge commits whose content has actually been on dev long enough but whose HEAD timestamp is misleadingly fresh. Test plan: yaml syntax verified via js-yaml. Functional verification will be the next manual workflow_dispatch run with the input set. Co-authored-by: icebear0828 <icebear0828@users.noreply.github.com>
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.
Summary
cached_tokens / input_tokens,与原本的全局累计「Cache Hit Rate」并列显示,方便对比近窗口与历史命中率。cached / input;input=0的 bucket 跳过(不渲染 0% 假命中),单数据点也能可见。five_mingranularity(与默认 5min snapshot 对齐),前端新增「5 min」选项与「Last 1h / 6h」时间窗,切粒度时自动收敛到兼容窗口。rid/conv/key/prev=<src>:<tail8>/tools=N,Usage 行加rid与hit=X.X%,用于排查 prompt-cache 命中率偏低(同一会话是否落到同一 cache key、是否走到 implicit resume 等)。formatHitRate/sumWindow/formatUsageNumber抽到shared/utils/usage-stats.ts,配 vitest 单测覆盖边界(input=0 → "—"、<0.01% 截断、windowed 求和、空数组)。Test Plan
npm test— 1663 passed (+1 skipped)npx tsc --noEmit— cleannpm run build— vite + tsc OKrid/conv/key/prev/hit字段Notes
cacheHitRate全局卡片,老调用方零变更。web/src/components/UsageChart.tsx内formatNumber重新导出指向formatUsageNumber,对外签名兼容。tests/unit/auth/usage-stats.test.ts—— 未涉及 store 行为变化,只在 routes 层加了five_min用例。