Commit Graph
4 Commits
Author SHA1 Message Date
yetone c124f87e2e gui tests: Settings rows are held once the last settings read is drawn (#4469)
images-library-way opened Settings › Models and waited for the Image
generation row, then screenshotted it. A page opened on Settings reads
/api/settings twice (go('settings')'s own read and load()'s), and each
answer draws the tab again, so when the second answer came late the row
it had waited on was replaced while Playwright held it: "element was
detached from the DOM" / a screenshot of a redrawn element (zh-TW 1100
in Chromium). The app's double draw is by design; the test was wrong to
hold the first one. It now waits with reader.cjs's watchSettingsReads and
settingsDrawn, as the other Settings files do, before taking the row.
proxy-test opens Settings › Network the same way and presses its Test
button after the first draw: it gets the same wait at both gotos.

What was run (WSL magpie-desktop, Playwright 1.62.0):
- By hand: the second /api/settings answer held 1.5s and a marker set on
  the row first waited on. origin/main's images-library-way: zh-TW 1100
  and 420 red, "the row held for the screenshot is the one drawn last";
  this file 6 of 6 green, Chromium.
- images-library-way.test.cjs and proxy-test.test.cjs, Chromium and
  WebKit, every language each file covers: images-library-way 62 of 62, proxy-test 22 of 22 green at load ~210 (nav-timeout green on this tree).

Not tried: the whole GUI suite; mote (#4125) or Windows.
2026-10-31 02:09:18 +08:00
yetone ce8b67de37 gui tests: a page's first load gets a minute, not a click's 5s (#4470)
claude-switch-only set page.setDefaultTimeout(5000) and then called
page.goto with no timeout of its own, so Playwright held the first load
of app.js, i18n.js and the plugins to the 5s bar meant for clicks. On a
busy box (a whole-suite run at load 130-160) that load took longer and
goto timed out. The same pattern is in 988 GUI test files (1174 pages):
every one of them now also sets setDefaultNavigationTimeout(60000) on
the same page, right after its default, so goto, reload and waitForURL
wait on the load itself with room, while clicks and waits keep their
short bar. group-from-model-add's own 20s navigation bar is raised to the
same minute. claude-switch-only also gives its first provider row (drawn
from the page's first reads) a minute before clicking it.

nav-timeout.test.cjs (no browser) reads every GUI test file and names
each page given a default under a minute without a navigation timeout of
at least a minute, so a new file can't bring the pattern back.

What was run (WSL magpie-desktop, Playwright 1.62.0, load 70-260 from
other sessions):
- node --check on every file in internal/gui/tests: all parse.
- nav-timeout.test.cjs against origin/main's test files: red (names the
  1174 pages); against this tree: its only reds were my own probe copies
  of the old files, since removed.
- By hand: claude-switch-only with app.js served 7s late (a busy box's
  first load), --test-name-pattern "1100 en": origin/main's file 4 of 4
  red with "page.goto: Timeout 5000ms exceeded"; this file 4 of 4 green.
- claude-switch-only.test.cjs, both engines, en/zh/ja/de, 1100 and 420:
  32 of 32. group-from-model-add, usage-access-key-card and i18n-keys:
  green. agent-plugin-agents: Chromium green; WebKit's de 420 subtest red
  on a 5s waitForFunction at line 115 (a wait after load, not the
  navigation), at load ~230.

Not tried: the whole GUI suite (about 1000 files; the change is one
mechanical line per page), Windows or mote (mote's browsers, #4125).
2026-10-31 02:09:18 +08:00
yetone cf5a6f9cfd gui: the proxy test says a TUN may share one exit when the proxy took the request, not "no proxy" (#2369, Emt-lin)
The proxy test compared the exit IP through the proxy with the direct one,
and called the same address "they leave as if there were no proxy". Under
a TUN or system VPN every request leaves from one exit, so a working proxy
read as not in effect.

The leg through the proxy now records what it can see: the connection that
carried it (httptrace GotConn's RemoteAddr) and the proxy netproxy chose for
the URL. It is Proxied when that connection is the proxy's (same port, the
default by scheme; the host as an IP or resolved). With the same exit IP:
- Proxied: "The proxy took the requests, but they leave from {where} as
  direct ones do: a TUN or system VPN may send every request out one exit,
  so the address can't tell the two paths apart" (not a failure);
- not Proxied (bypassed by NO_PROXY or the system bypass list): "...didn't
  connect to it ...: the proxy is passed by" (a failure).
The verdict is made only in app.js's proxyCheckText; no CLI, TUI or plugin
path makes it.

Run:
- go test -race -count=3 -run TestProxyCheck ./internal/gui/: ok.
  New: TestProxyCheckSaysTheProxyTookItUnderOneExit (the proxy answers with
  the direct leg's IP), TestProxyCheckSaysAProxyPassedBy (NO_PROXY),
  TestProxyCheckConnectedToByName; TellsTheProxyFromDirect also checks
  Proxied.
- Broken by hand: no Proxied assignment turns TellsTheProxyFromDirect and
  SaysTheProxyTookItUnderOneExit red; Proxied always true turns
  SaysAProxyPassedBy red; origin/main's app.js turns proxy-test's
  "one-exit" case red.
- GUI: proxy-test.test.cjs 22/22 in Chromium and WebKit (1100 and 420, en,
  zh, zh-TW, ja, de); gui-de, gui-ja, gui-zh-tw, i18n-keys 12/12.
- Real use: a local CONNECT proxy named by localhost, to the real
  Cloudflare trace: through Proxied true, direct Proxied false, one
  CONNECT, the same exit both ways (the reporter's case). A real TUN was
  not tried.
- gofmt -l clean; go vet ./... (darwin), GOOS=linux and GOOS=windows
  go vet -tags nogui ./..., and GOOS=windows go vet ./...: ok.
- Not fixed here: at 420px the proxy row's mode control overlaps a long
  check line; origin/main's "down" message does the same.

Suite run here: HOME=<sandbox> go test -tags nogui -timeout 45m ./...: 62 ok,
internal/gateway FAIL only on TestOTelFastRequestTranscriptDiscovery/true
("request must still have a cached discovery miss"), open as #1811 (red
under load; load average ~170 here); it and its sibling pass -count=3
alone.

Full suite: SUITE_LINE
2026-10-15 23:08:05 +08:00
yetone 536b15a8e9 gui: Settings › Proxy has a Test that says whether requests leave through it (#2076)
c4ex: the proxy setting gave no way to see whether it takes effect, and
suggested asking a Cloudflare address.

What changed:
- POST /api/proxy/check (proxycheck.go) asks Cloudflare's trace page
  (www.cloudflare.com/cdn-cgi/trace) twice at once, 10s each: once as a
  vendor request without a proxy of its own goes (http.DefaultClient,
  netproxy's Settings / *_PROXY / system proxy), once direct
  (netproxy.With "direct"). Each answer is the ip= and loc= Cloudflare saw,
  and the ms. With no proxy in force (source off/none) only the direct one
  is made. The proxy is reported redacted (Describe); a failure's text has
  user:password taken out.
- The Proxy row gets a Test button; the result goes on a line under the
  row's text: works (two addresses), the same address both ways (shown as
  a failure: the proxy isn't taking the requests), the proxy failing (with
  the direct address), no proxy in force, the check failing. Testing… while
  it runs; the result outlives a redraw and goes when the proxy changes.
  Strings in zh, zh-TW, ja, de.

Decision (delegated): compare against a direct request rather than only
show the proxied address, since an address alone can't say whether the
proxy was used; Cloudflare's trace page as the reporter suggested (plain
text, no account, served worldwide).

Run:
- go test ./internal/gui -run TestProxyCheck: 5 tests (proxy vs direct;
  no proxy asks only direct; a refusing proxy, password not in the error;
  a page with no ip= fails; ALL_PROXY global proxy is gone around for the
  direct leg). All loopback/.invalid, nothing leaves the machine. Broke
  the direct leg's With("direct"): the global-proxy test goes red ("the
  proxy asked 2 times").
- go test ./internal/gui -count=1: all pass except TestMainWindowCorners,
  the load red filed as #1936 (same on origin/main).
- New proxy-test.test.cjs (5 languages x 1100/420, 6 cases each): chromium
  11/11, webkit 11/11; with the same-address branch broken 0/11.
- proxy-test, settings-proxy-auth, proxy-own-wording, i18n-keys and six
  settings-* tests: chromium 63/63; webkit 62/63, the red being
  settings-proxy-auth zh once under the 2-wide run; it passed alone 5/5
  and three more 2-wide runs with proxy-test 3x0 fails (noted on #2142).
- gofmt -l clean; go vet darwin, linux -tags nogui, windows clean.

Tried: checkProxy against the real www.cloudflare.com trace page, direct
leg only, from a temporary test (not committed): ip and loc read, 1.2s.
Not tried: a real proxy (Settings, *_PROXY or system) through to it.
2026-10-14 16:14:54 +08:00