Repository navigation
gui: fit native Usage controls and keep period picks stable - #978
Snowyyyyyy1 wants to merge 1 commit into
Conversation
yetone
left a comment
There was a problem hiding this comment.
Thanks. I reviewed head f92b198 and ran it merged with current main (07326a3), in Chromium and WebKit, en and zh.
What holds up:
panel-usage-periodandusage-narrowpass 8/8. Copied onto main without the app change, they fail 8/8, so they guard what they claim to.- The rest of the usage, panel and session tests that touch the thumbs, the period strip,
#usageCost, the chart labels or the calendar pass. So doclick-scroll,gui-ja,gui-deandi18n-keys(61 files). - Keeping the tray's period buttons across a redraw looks right.
paint()covers every branch ofrenderPanelUse.
One thing has to change before this can merge:
It undoes #929, and two of that issue's tests now fail.
sess-agent-strip.test.cjsfails 4/4 with "the strip fits the window at 834px, so nothing is being fixed". It passes 4/4 on main.usage-sessions-agents-fit.test.cjsfails 4/4 with "the strip itself scrolls". On main it passes 3/4; the fourth, WebKit en, is a timeout that also happens on main and is unrelated.
#929 (liuweifeng) decided that a Usage › Sessions agent strip too wide for the window scrolls inside itself, and that the picked agent stays in view (c6e318e). The new @container (max-width: 1100px) rule for body.window:not(.web) .sess-tools > .segs / .sess-chart-head > .segs turns that strip into several wrapped rows instead.
The macOS overlay-scrollbar point is fair, but please don't reverse a decision made for an issue in a side change. Either:
- keep the strips scrolling and wrap only the head, the KPIs and the dates; or
- open an issue proposing wrap-instead-of-scroll, and update both #929 tests in the same change once that's agreed.
Before pushing again, please run the whole usage-*, sess* and panel-* set, not a hand-picked subset. Both tests that fail are in that set.
Minor:
f92b198 to
dc0dab4
Compare
…tone#978) Keep yetone#929 agent filters in their own scrolling strip and preserve the narrow window header, KPI and date fixes. Retain period transition position and connected panel controls across redraws. Verified: JS syntax; 472 GUI tests across Chromium and WebKit; go vet; macOS, Linux nogui and Windows builds. New browser tests fail 8/8 on current main assets and pass on this change. Full nogui Go suite has the existing TestBunThroughBridge SOCKS 0/2 failure, reproduced on current main and 20/20 targeted race runs.
Preserve the GUI shell and provider discovery documentation while keeping the yetone#929 agent strip scrolling and the Usage interaction fixes. Combined validation: 49/49 focused browser checks across Chromium and WebKit and go test -tags nogui -count=1 ./internal/gui.
yetone
left a comment
There was a problem hiding this comment.
Thanks. The layout and thumb changes look right, and I found no problems in the code. I checked dc0dab4 merged onto current main:
- Native window at 950, 760 and 560px, in Chromium and WebKit, in en, zh, ja and de. Every case has no sideways scroll and nothing past the right edge. Refresh and the sum stay on one head row, the chart dates don't collide, and no KPI sub-line is clipped.
- 51 of 52 GUI files pass (usage-, sess, panel-*, click-scroll, gui-ja, gui-de, i18n-keys), and so does
go test ./internal/gui. - Both new tests fail against main's assets, so they guard the change.
One thing blocks the merge: the new usage-narrow.test.cjs fails intermittently in Chromium. It failed in all 7 runs: 1 to 4 of its 4 Chromium cases each time (WebKit always passes). Every failure is "the scrolling strip highlights its choice" (internal/gui/tests/usage-narrow.test.cjs:248).
Repro: run BROWSER=chromium node --test internal/gui/tests/usage-narrow.test.cjs a few times. With the thumb printed in the message, a failure reads:
{"id":"sessAgent","on":"Qoder CN","dLeft":-1058.2,"dW":-42} last=true
The thumb is still on "All", the chip at the other end.
The page itself is fine. Sampling the thumb after a real click on the last chip, it sits on the pick within 50ms, in this PR and on main alike. The test reads it too early: settle() (two animation frames, line 173) after .opt.on moves (line 244) is not always enough for the thumb's move to land in Chromium.
Fix: wait for the thumb itself rather than a fixed two frames. For example, a waitForFunction that the #sessAgent thumb's left, top and height are within 1px of .opt.on, then assert. Please run it several times in Chromium before pushing. Per our rules, a new test that fails some runs counts as failing.
usage-narrow's picked-agent check measured the thumb two frames after the click, but the thumb glides for .28s, so Chromium could read it still on the chip it left. Wait (bounded) for the thumb's left/top/height to reach .opt.on, then assert as before.
|
Thanks. 24a17dc waits for the |
|
Sorry for the slow review on this one. It no longer merges onto main: I ran your two new tests against current main's assets (origin/main 5b14ebf plus
Could you rebase onto main and:
Then please re-run the tests in both engines, at 560/760/950, in every language. I'll review it again at the new head. |
Rebased onto main as one commit. Main's yetone#1599 head row (.usage-head.tight, the sum at the right) and b0e2569's thumb are kept as they are; this carries only what main still needs: - the tray's period buttons stay connected across an answer, so a redraw between pressing and releasing one still delivers its click; - a narrow native window wraps KPI sub-lines rather than cutting them short, and takes three figures to a row between 961 and 1100px; - fitChartLabels hides a chart date that would collide with its neighbour in the native window too, not only on phones. It lives in plugins/usage/page.js since 3c7ec4b, so page.js now refits the dates once fonts load, rather than app.js calling into the plugin. Sessions' agent strip keeps scrolling inside itself (yetone#929). usage-narrow's head-row checks assert yetone#1599's layout (at most two rows, the first starting at the left, no overlap, the sum whole at the right). panel-usage-period and usage-narrow: 16/16 in Chromium and WebKit, en, zh, ja, de, at 950/760/560; usage-narrow 6 runs in a row in Chromium, 4/4 each. Against origin/main's assets they fail 10: the click across an answer, KPI sub-lines cut at 560 and dates colliding at 560 -- the three fixes above. usage-*, sess*, panel-*, click-scroll, gui-ja, gui-de and i18n-keys (98 files): 1205/1234; the 29 that fail (usage-agents-hide, usage-checkin, usage-curve-zoom-back, usage-fold) fail the same on origin/main.
24a17dc to
6dfd48c
Compare
Rebased onto current main as one commit (
6dfd48c7). Main's #1599 head row (.usage-head.tight, the sum at the right) and b0e2569's period thumb are kept as they are. This PR no longer changes either. It carries only the three fixes main still needs:fitChartLabelsnow hides a date that would collide with its neighbour in the native window too, not only on phones. Since 3c7ec4b it lives inplugins/usage/page.js, so the plugin refits the dates itself once fonts load.app.jsdoesn't call into it.The Sessions agent strip keeps scrolling inside itself and keeps the picked agent in view (#929). These layout rules apply to the native window, not
magpie web.usage-narrow's head-row checks now assert #1599's layout instead of the left-packed head this PR used to propose. The checks are at most two rows, the first row starting at the left, no overlap, and the sum whole at the right. The picked-agent check waits for the strip's thumb to reach.opt.onbefore asserting.The GUI shell reference and browser test notes describe these paths.
Validation
All at
6dfd48c7's tree on main1eba266a(the main commits since touch onlysite/and the READMEs). Browser tests use Playwright 1.62.1 with isolated API fixtures.panel-usage-periodandusage-narrow: 16/16 in Chromium and WebKit, en/zh/ja/de, at 950/760/560px.usage-narrowin Chromium, 6 runs in a row: 4/4 each.sess-agent-stripandusage-sessions-agents-fit: 8/8 in Chromium and WebKit.usage-*,sess*,panel-*,click-scroll,gui-ja,gui-de,i18n-keys(98 files): 1205/1234. The 29 failures are inusage-agents-hide,usage-checkin,usage-curve-zoom-backandusage-fold. The same 29 fail on a clean origin/main checkout here (57/86 on both sides for those four files), so they aren't from this change.go test -count=1 ./internal/guiunder a temporary HOME: everything passes exceptTestProxyCheckSaysAProxyPassedBy(HTTP 503 from the sandboxed network) andTestMainWindowCorners(macOS title bar). Both fail the same way on clean origin/main on this machine.Not run: the real native app at these widths.
🎬 界面预览
CI 用这个 PR 的代码构建并真实运行 magpie(沙盒环境,配置了真实的 DeepSeek key),按改动自动操作、截图和录屏 ·
6dfd48c· 运行记录改动(按代码):这次改动让窄的原生窗口(body.window:not(.web))里用量页的 KPI 小字换行、六项统计在容器 961–1100px 时改排三列,并让图表横轴日期在原生窗口里也会因与相邻标签碰撞而隐藏(含字体就绪后再量一次),同时把托盘面板「用量」的周期按钮改为跨重绘复用,避免回答重绘吞掉点击或让高亮回跳。
Warning
描述与代码不符:描述说用量页头部「现在」把刷新和总额作为一组换行(.usage-head、#usageReload 与 #usageCost 的关系),但 diff 里没有任何 .usage-head 相关的 CSS 或标记改动,这条只出现在文档和新增测试的断言里。
Note
沙盒里看不到:两处布局规则只作用于原生窗口(body.window:not(.web)):预览环境运行的是 magpie web、宽 1280px 且没有调整窗口大小的动作,因此 KPI 小字换行、六项统计改排三列、以及窄窗口下相邻图表日期被隐藏,都无法在这里拍到;Sessions 的 Agent 标签条按描述保持原样(水平滚动、不换行),diff 也未改动它。面板周期按钮的「回答重绘 / 按下与松开之间到达的响应不吞点击、高亮不回跳」是时序行为,静态截图也拍不到。
托盘面板的用量周期按钮
面板「用量」里的周期按钮
面板「用量」的周期按钮与总量
用量页的头部与图表日期
用量页顶部:周期、刷新与总额
用量概览的柱状图与横轴日期标签
会话页的六项统计与 Agent 标签条
会话页顶部的六项统计
会话页的 Agent 标签条