修复每日 Token 跨日统计、主题与布局兼容问题 - #77
Open
kts-kris wants to merge 4 commits into
Open
Conversation
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.
背景
该 PR 替代存在冲突的 #61。分支已重新基于最新
main整理,保留 #53 已合入的缓存、索引和刷新性能优化,再补回历史回填、价格面板滚动和默认价格更新。本次逐项复现并处理了 #35、#37,同时对已关闭的 #62 做了性能回归,重点解决“首次打开或重启后今日用量明显偏小”“长时间复用的旧任务漏算今日 Token”“历史回填与实时采集重复相加”等实际问题。
处理内容与用户价值
1. 今日统计不再只依赖当前页面
localThreadCatalog获取最近更新任务,通过workspaceFiles.read读取本机 session JSONL。Codex Token Usage,也能独立补齐本机最近 5 日统计;已安装时仍可复用实时数据,不要求用户额外安装依赖。用户价值: 重启 Codex、首次打开插件或切换到历史任务后,不再只看到脚本加载之后的局部用量。
2. 正确处理长任务跨日与累计值
token_count的真实时间计入当天。total_token_usage的差分计算每日增量;累计值重置时回退到last_token_usage。用户价值: 避免累计值直接相加造成虚高,也避免旧任务路径日期导致漏算。
3. 处理 #35:暗色、输入与趋势交互
html.electron-dark主题适配,明确价格输入框文字、背景、光标和 placeholder 对比度。用户价值: 深色主题下可读、输入不丢焦点,较多 Model 价格项也能滚动到页面底部。
4. 处理 #37:不再破坏宿主布局
body,使用position: fixed,不进入 Codex 标题栏 flex 文档流。用户价值: Windows/macOS 标题栏、侧边栏和设置区域不会被插件撑开或裁切,后出现的原生按钮也不会与入口重叠。
5. 回归 #62:大会话性能
保留 #53 的 day cache、版本签名、时间索引匹配,并新增 MutationObserver 工具扫描节流。
在 226 个 turn、314 条工具事件的复现场景中,本机结果:
8.4ms0.2msrefresh():约2.2mstrue相较 issue 中单次聚合
348.1ms、完整刷新370.6ms,未发现性能回退。6. 版本与价格
1.4.17。index.json版本、说明和 SHA-256。真实环境验证
当前 Codex Desktop 热加载验证:
threads=9、filesRead=9、sessions=9、complete=trueBODYfixedscrollHeight=1115、clientHeight=1051、可滚动scrollTop=64electron-dark下:面板rgb(32, 33, 36),输入文字rgb(242, 242, 242)自动化验证
新增仓库内回归测试,覆盖:
Closes #35
Closes #37
#62 已关闭,本 PR 仅做回归验证并确保不重新引入该性能问题。