繁體中文

新功能

終端機介面不再卡死,底層檔案掃描更省力

之前在終端機裡看用量時,因為一個程式迴圈寫錯(不小心跳過了更新步驟),導致畫面永遠凍結在剛打開的那一秒,再也不會自動更新。現在這個迴圈修好了,畫面會乖乖定時刷新。同時,我們也優化了底層的檔案掃描:以前每次更新畫面,系統都會笨笨地把同一個歷史紀錄檔案重複讀 4 次來算不同時間區間的數字;現在它學聰明了,一次讀完最長的區間然後直接往下分派,大幅省下白費力氣的硬碟讀取。另外,舊版的環境變數和過時的內部代號也一併統一了。就像是顧門口的警衛以前一直忘記看手錶導致從來不換班,而且查房時還同一層樓爬上爬下巡了四遍,現在終於準時交接,而且知道從頂樓一次巡下來最省事。

English

FEATURE

Terminal UI stops freezing, and underlying file scans are much more efficient

Previously, when viewing your usage in the terminal, a buggy programming loop (which accidentally skipped the update step) caused the screen to freeze permanently at the exact second you opened it, never automatically refreshing again. This loop is now fixed, and the screen faithfully updates on time. Simultaneously, we've optimized the underlying file scans: before, every time the screen refreshed, the system foolishly read the exact same history file 4 times to calculate numbers for different time ranges; it's now smart enough to read the longest range once and pass the data down, drastically cutting down on wasted hard drive reads. Additionally, legacy environment variables and stale internal names have been unified. It's like a security guard who used to forget to check his watch and never changed shifts, while also climbing up and down the same floor four times during a patrol — now he hands over exactly on time and knows it's easiest to just patrol from the top floor down once.

原始 CHANGELOG

Original changelog終端機介面不再卡死,底層檔案掃描更省力
**TUI polling never updated after first fetch**: a `continue` in `poll_usage` caused every timeout to jump back to the loop head, leaving the UI frozen at the initial state. Changed to `pass` so the polling path is actually reached.
**Inconsistent env var name**: `USAG_FORCE_GROUP` (v0.1.x legacy prefix) renamed to `USAGE_FORCE_GROUP` to match all other env vars in the project.
**Redundant filesystem scans per refresh**: `_refresh_in_background` was calling `history_loader.load_entries` four times per cycle (24h × 2, 168h × 1, 720h × 1). Now loads the 720h superset once and passes it down, eliminating the duplicate I/O.
`pricing.py` User-Agent updated from the stale `usage/0.2` to `usage/0.9`.
`--setup` no longer prints a "no migration needed" message on clean installs.