usage 0.29.26
新功能 2 項
Codex 狀態列看得到分支與已用 token
你在終端機裡連續做了幾輪工作,想知道自己在哪個 Git 分支、這個工作階段(session,一次開啟到結束的工作過程)已用了多少 token(AI 處理文字的計量單位)?Codex 的狀態列(終端機最底下那行摘要)現在多了 git-branch 和 used-tokens,設定檔裡的區段也由五個增為七個。它像車上的儀表板:分支和已用 token 會同列顯示,但表板零件只能選 Codex 內建項目;不能接像 Claude Code 那樣的指令掛鉤,所以文字、顏色與 · 分隔符號都由 Codex 決定,也不能加進度條或重設倒數。5h 則要等 Codex 真的拿到含五小時視窗的限流快照才會出現。
官方原文
**Codex's status line now shows the Git branch and the session's token count.** The segment set usage writes into ~/.codex/config.toml grew from five entries to seven, adding git-branch and used-tokens, so a session reads usage · main · 5h 39% left · weekly 50% left · Context 95% left · 12.3K used · gpt-5.6-sol high. Codex's status line accepts only its own built-in segments — there is no command hook like Claude Code's, which is why the wording, the colors and the · separator are Codex's own and why a progress bar or a reset countdown cannot be rendered on that side. The 5h segment is omitted until Codex holds a rate-limit snapshot that actually contains a five-hour window.
更新或移除狀態列,不會誤蓋你的原始設定
你以前用 usage 裝過 Codex 狀態列,後來想換新版或移除它,原本自己設的狀態列不該被舊版 usage 的清單冒充。現在 usage 認得自己歷來發過的區段組合,遇到舊組合會原地升級,不會把它另存成你的原始設定,也不會碰既有備份。移除時同樣接受所有舊組合;回復設定仍是先寫回找回的內容,再刪備份。啟動時還會檢查舊組合並自動更新,但只比對 usage 發過的組合,使用者自訂狀態列與已是新版的設定都不動。像寄物櫃管理員看得懂哪張標籤是店家舊款,換新標籤時不會把舊標籤誤收成你的私人物品。
官方原文
**Upgrading the segments no longer files usage's own older set as your original status line.** _setup_codex() backed up whatever it found before overwriting, which was correct for a status line you configured yourself but wrong for one an earlier version of usage installed: changing the segment set would have written the previous usage-installed list into ~/.codex/usage-backup.json, and a later removal would have "restored" that instead of your real configuration — silently overwriting the only copy of it. Segment sets that usage has shipped are now recognized as its own and upgraded in place, leaving any existing backup untouched.
**Removing the Codex status line works on installs still holding an older segment set.** The removal path required an exact match against the current segments, so anyone who had not re-run setup was told the status line was not usage's and nothing happened. Every set usage has shipped is now accepted; the restore sequence itself is unchanged, including writing the recovered configuration before deleting the backup.
**The new segments apply without pressing anything.** Startup self-healing upgrades a status line that still holds a set from an earlier version of usage. It only ever matches those sets — a status line you configured yourself, and one already on the current set, are both left alone.
修正 1 項
測試不會再改到開發者真正的 Codex 設定
開發者跑完整套測試時,原本不該拿自己的 ~/.codex/config.toml 當測試材料。先前啟動時的自我修復會讀這個真實設定檔,但測試沒有把路徑換掉;因此測試可能改寫開發者的 Codex 設定,連驗證自我修復日誌的結果也會隨那台電腦的狀態改變。現在自動套用的 fixture(每個測試先準備好的共用環境)會把 Codex 設定檔與兩個備份路徑全指向暫存資料夾,和原本已隔離的日誌資料夾一致。這像舞台彩排不再借用真實控制室的開關:演員怎麼測,都只影響臨時布景。
官方原文
**Tests can no longer reach the real ~/.codex/config.toml.** The self-healing path above reads that file, and no test overrode the path constant, so a full test run on a developer's machine rewrote their own Codex configuration and made an unrelated assertion about the self-heal log depend on the state of that machine. An autouse fixture now points the Codex configuration and both backup paths at a temporary directory, matching how the log directory is already isolated.