From e21ea07e47a5828e248c9fc3aab2545e02ca63a3 Mon Sep 17 00:00:00 2001 From: yetone Date: Mon, 12 Oct 2026 14:56:22 +0800 Subject: [PATCH] gui: a client in the Usage page's Agents list can be hidden from it, and shown again from the line under it (ikunbots on X) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ikunbots asked to hide curl, Go-http-client, python-httpx and other clients from the Agents list beside the agents they actually use. What changed: - Each Agents row has a "…" button that shows on hover (always on touch) and opens the app's row menu (openRowMenu) with "Hide from this list". Right-clicking the row opens the same menu. No native select. - The hidden ids are saved by client id in settings.UsageAgentsHidden, trimmed and deduped. They go through POST /api/usage/arrange (agentsHidden), which changes only that field, and the Settings save carries the field over. - Hiding is display only. The ledger keeps the calls, and the totals, the chart and every share still count them. - When anything is hidden, a quiet "3 hidden" / "已隐藏 3 个" line sits under the list. It opens the hidden rows, dimmed, each with "Unhide" / "取消隐藏". No click scrolls the page: the scroll guard holds the clicked line in place. - Where a pointer hovers, the "…" takes no room. Its margins give back its width and gap, so a row at rest is laid out as on main (mobile-web's desktop comparison is the same). It shows over the end of the share bar. On phones (body.web) it has its own grid column. - Translated into zh, zh-TW, ja and de. docs/subsystems/gui-shell.md describes it. What was run, in a worktree off origin/main: - gofmt -l: clean. - go build ./... and go vet ./...: pass. - GOOS=linux go vet -tags nogui ./... and GOOS=windows go vet ./...: pass. - HOME= go test -tags nogui ./...: 49 packages ok. Includes the new TestUsageArrangeAgentsHidden, which covers saving, surviving a settings save, narrowing and emptying. - New usage-agents-hide.test.cjs: 32/32 in Chromium and WebKit. It covers en, zh, zh-TW, ja and de at 1200, 560 and 390 (web). It hides by "…" and by right-click, checks the POST body, unchanged totals and an unmoved page, then unhides, reloads and checks the hidden rows persist. - All 48 usage, panel-arrange and click-scroll GUI files: 503/503. old-webkit and mobile-web: pass. - Full GUI suite (6489 tests, concurrency 5): the reds outside this change fail the same when run alone on origin/main 3deb85685, in WebKit only. They are filed in #1672 and #1609, and in #1745 (new: group-member-info, searcher-pick). - Broken by hand: - Without the hidden filter in renderUsage, the new GUI test fails 16/16 in Chromium (the shown rows still list curl). - Without the arrange handler, TestUsageArrangeAgentsHidden fails at line 82. - Without the Settings-save carry-over, it fails at line 84. --- docs/subsystems/gui-shell.md | 1 + internal/gui/api.go | 14 +- internal/gui/assets/app.css | 30 +++ internal/gui/assets/app.js | 78 ++++++- internal/gui/assets/i18n.js | 16 ++ internal/gui/assets/index.html | 1 + internal/gui/settings_keep_test.go | 1 + internal/gui/tests/usage-agents-hide.test.cjs | 209 ++++++++++++++++++ internal/gui/usage_arrange_test.go | 38 ++++ internal/settings/settings.go | 6 + 10 files changed, 386 insertions(+), 8 deletions(-) create mode 100644 internal/gui/tests/usage-agents-hide.test.cjs diff --git a/docs/subsystems/gui-shell.md b/docs/subsystems/gui-shell.md index 0e44fd043..6bfcc19c8 100644 --- a/docs/subsystems/gui-shell.md +++ b/docs/subsystems/gui-shell.md @@ -154,6 +154,7 @@ retry after a failed read. See `TestRecentCallBodiesOnDemand` and - A click never moves the page. Code scrolls a view only with the reader's event in hand (`scrollOnPurpose`); `click-scroll.test.cjs` guards this. A click is taken where the reader left the view: a scroll not theirs made just before it, whose scroll event the browser sends only at the next frame, after the click, is put back first (`backToReader` in the click guard, #1554). - There are no native `