From 4a4a90c23793ccf4ef197c31aadea7b7c76283c7 Mon Sep 17 00:00:00 2001 From: yetone Date: Fri, 30 Oct 2026 09:28:10 +0800 Subject: [PATCH] gui: the sidebar's button stays in one place whether the sidebar shows or not (ztf4080 on X) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ztf4080: "左侧栏收起按钮在左上角,但是收起后展开按钮变了右下角". The button to hide the sidebar sat in the page header to the right of the sidebar (x=232 at 1280), and once hidden it was in the title bar after the magpie (Mac x=175; Windows 14; Linux 93/14/40 as the brand folds). Each click moved it. Now #sideToggle is first in the title bar in both layouts, as Finder's, Notes' and Mail's: layoutNav moves it with the brand, into .side-top when the sidebar shows and to the front of .top when it doesn't. .side-top has the header's height and left padding (Mac: after the traffic lights at 96px/zoom, as .top), so the button keeps its x, y and size. A sidebar too narrow for the name keeps the bird (fitTop sets .side-top.tight). Windows' 10px .side-top is gone: the button needs that row there too. Nothing else in the sidebar changed. Run (on mote, through mote-run; NODE_PATH playwright 1.62.0, chromium and webkit): - Repro before the fix: a probe at 1280/900/640, en/zh/de, Mac/Windows/ Linux chrome, gave the positions above. - side-toggle.test.cjs gains ": the button stays where it was" for Mac, Windows and Linux: every language (en, zh, zh-TW, ja, de) at 1280, 900, 640 and a 168px sidebar; hide then show, x/y/w/h within 0.5px, the header fits, .side-top doesn't overflow. - Broken by hand: the new test against origin/main's assets fails all 3 OS subtests in both engines (18 pass, 8 fail); reverting layoutNav's append/prepend fails them too. - side-toggle, side-width, header-centre: 49 pass, 1 fail (header-centre webkit, the ResizeObserver page error, #3479; the same on the base). - The 22 GUI files that touch the sidebar, brand or toggle (--test-concurrency=2): 335 pass, 11 fail: header-centre webkit (#3479) and mobile-web's desktop compare against HEAD~1, which moved on purpose. - mobile-web.test.cjs: until BASE_REF has the move, its desktop compare leaves the button, the magpie and the header out of both pictures, like its other "until BASE_REF has it" cases. Run in a git checkout on mote with BASE_REF=HEAD~1: 30 pass, 0 fail in chromium and webkit. - At the head rebased on 9e8c22dad: side-toggle.test.cjs 26 pass, 0 fail; go test -run TestCoreScriptBudget ./internal/gui ok (app.js 1,315,308 of 1,315,316, no raise; a comment in fitTop cut to fit after the rebase). - go test ./internal/gui: TestMainWindowCorners/macOS_26_SDK red, #3949 (macOS 27 box), not this change. Not run: the whole GUI suite (mote was busy with other sessions' full suites, load 45-110); the real app on Windows and Linux (the probe used their chrome classes in Playwright). --- internal/gui/assets/app.css | 14 +++++--- internal/gui/assets/app.js | 12 ++++--- internal/gui/assets/index.html | 12 ++++--- internal/gui/tests/mobile-web.test.cjs | 9 +++++ internal/gui/tests/side-toggle.test.cjs | 45 +++++++++++++++++++++++++ 5 files changed, 77 insertions(+), 15 deletions(-) diff --git a/internal/gui/assets/app.css b/internal/gui/assets/app.css index 695993d77..bcda245a2 100644 --- a/internal/gui/assets/app.css +++ b/internal/gui/assets/app.css @@ -364,13 +364,17 @@ body.side-nav { --side-w: 212px; padding-left: var(--side-w); } @media (pointer: coarse) { .side-edge { right: -12px; width: 24px; } } .side-edge:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 4px; } body.side-drag, body.side-drag * { cursor: col-resize !important; user-select: none; } -.side-top { flex: none; display: flex; align-items: center; height: 46px; padding: 0 18px; } +/* its top is the title bar's left end: the sidebar's button (app.js + layoutNav), then the magpie, at the header's own height and left padding, + so the button is in the one place whether the sidebar shows or not, as + Finder's and Notes' is (ztf4080 on X) */ +.side-top { flex: none; display: flex; align-items: center; gap: 8px; height: 46px; padding: 0 18px 0 14px; } .side-top .brand { font-size: 13.5px; } +/* a sidebar too narrow for the name keeps the bird (app.js fitTop) */ +.side-top.tight .brand > span:not(.logo) { display: none; } /* the traffic lights are the sidebar's top left, as in a Mac app's sidebar; - the magpie beside them, level with them (see .top above) */ -body.window.mac .side-top { height: calc(50px / var(--zoom, 1)); padding: calc(2px / var(--zoom, 1)) 0 0 calc(90px / var(--zoom, 1)); } -/* Windows' title bar above already shows the icon and the name */ -body.window:not(.mac):not(.linux):not(.web) .side-top { height: 10px; } + the button and the magpie beside them, level with them (see .top above) */ +body.window.mac .side-top { height: calc(50px / var(--zoom, 1)); padding: calc(2px / var(--zoom, 1)) 0 0 calc(96px / var(--zoom, 1)); } .side-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 0 10px 10px; } .side-foot { flex: none; max-height: 55%; overflow-y: auto; display: flex; flex-direction: column; gap: 1px; padding: 8px 10px 10px; border-top: .5px solid var(--line-2); } /* a short window's sidebar keeps no bar beside its pages: a thin one is laid diff --git a/internal/gui/assets/app.js b/internal/gui/assets/app.js index 8bc12eac1..073dabce9 100644 --- a/internal/gui/assets/app.js +++ b/internal/gui/assets/app.js @@ -23591,6 +23591,9 @@ matchMedia("(max-width: 760px), (pointer: coarse) and (max-width: 1024px)").addE // further still when they don't fit (the 560px window at 150%). function fitTop() { const top = $(".top"), nav = $("#nav"), brand = $(".brand"), actions = $(".actions"); + const st = $(".side-top"); + st.classList.remove("tight"); + st.classList.toggle("tight", st.scrollWidth > st.clientWidth); // a phone's browser: the tabs have a row of their own (app.css), at their size; // and beside the sidebar the header holds only where the reader is and the icons if (phoneWeb() || sideNav()) { top.classList.remove("tight", "cramped", "inrow", "crowded", "packed"); return; } @@ -23599,8 +23602,7 @@ function fitTop() { // the buttons sit against the padding; under a page zoom (the text size) // their edge can measure a hair past it, which isn't running off (#457) if (a.right > top.getBoundingClientRect().right - parseFloat(getComputedStyle(top).paddingRight) + 0.5) return false; - // the sidebar's button, when shown, comes after the brand - const lead = $("#sideToggle")?.offsetParent ? $("#sideToggle") : brand; + const lead = brand.offsetParent ? brand : $("#sideToggle"); const left = lead.offsetParent ? lead.getBoundingClientRect().right : top.getBoundingClientRect().left + parseFloat(getComputedStyle(top).paddingLeft); if (!nav?.offsetParent) return left + 8 <= a.left; @@ -23659,17 +23661,17 @@ function layoutNav() { return; } layoutNav.done = true; - const side = $("#side"), nav = $("#nav"), brand = $(".brand"), prefs = $("#prefs"); + const side = $("#side"), nav = $("#nav"), brand = $(".brand"), prefs = $("#prefs"), btn = $("#sideToggle"); document.body.classList.toggle("side-nav", on); side.hidden = !on; $("#crumb").hidden = !on; if (on) { - side.querySelector(".side-top").append(brand); + side.querySelector(".side-top").append(btn, brand); side.querySelector(".side-scroll").append(nav); side.querySelector(".side-foot").prepend(prefs); nav.querySelector(":scope > .thumb")?.remove(); } else { - $(".top").prepend(brand); + $(".top").prepend(btn, brand); $("#crumb").after(nav); $(".actions").insertBefore(prefs, $("#winclose")); } diff --git a/internal/gui/assets/index.html b/internal/gui/assets/index.html index f9e7bb0f6..46c26c1b1 100644 --- a/internal/gui/assets/index.html +++ b/internal/gui/assets/index.html @@ -51,16 +51,18 @@
+ +
magpie

Agents

- -