gui: Discover is quieter: one unofficial mark, one button style, a reason in your language
Kiko03O1 on X asked for a better-looking Plugins › Discover page
("ui 设计能不能好看点"). Five things on it said one thing twice or said
it raw:
- A GitHub card had an "Unofficial" chip. A GitHub card is only ever
drawn in the 非官方插件 · GitHub section, so the chip repeated the
section's head on every card. It is gone from the card; the plugin's
page keeps its full warning.
- Sign in on a card and on an Installed row is tinted like Install,
not filled. It stays filled only in the plugin's sheet, so each level
of action has one look.
- The GitHub line said Go's English in the middle of a zh page ("no
answer in 8s"). internal/plugin's GitHub read now wraps its timeout in
ErrNoAnswer; /api/plugins/github passes `why`: "slow" for that or any
timeout, "limited" for GitHub's rate limit (ghtoken.Limited), and the page says "GitHub 响应超时" (zh, zh-TW, ja, de); the raw
error is the line's hover. The line is smaller and muted, and Retry
takes the accent colour.
- The second filter row's All had a count. It always equalled
Installed + Not installed and the first row's picked count, so
"全部 · N" showed twice side by side. It has no count now.
- Found on the way, same page: the filter box's placeholder was cut off
in en at 1280/1100/980 and in de at every width but 420. It fits at
every width now; the filter bar wraps where it did.
Looked at and left alone: the 8px inset on the borderless Signed in,
and the monospace version numbers.
plugins.js nets -25 bytes (the Unofficial chip's code went), so the
core script budget is unchanged: TestCoreScriptBudget passes at the
pushed head with no raise.
What was run, at this change on origin/main 4b9694c34, and again after
the last rebase onto 0df6a3aba: TestCoreScriptBudget, TestTaggedWhyKind,
gofmt, and the four changed GUI files with i18n-keys in both engines
(80 of 80):
- Red without the change: with the old assets, the four changed GUI
files (plugin-github, plugin-github-wait, plugin-github-filter,
plugin-market) went 37 red in Chromium; plugin-market expected the
tinted colour and got the filled one. TestTaggedWhyKind doesn't
compile without the change.
- Changed and nearby GUI files (those four, i18n-keys,
plugin-check-github-limit, plugin-kinds-discover, plugin-page), both
engines: 124 of 124 pass.
- gofmt clean. go vet clean on darwin, linux (-tags nogui) and windows;
all three build. go test internal/gui and internal/plugin: plugin ok;
gui ok on its own, one red in the package run,
TestMainWindowCorners/macOS_15_SDK killed at its 40s deadline at load
~85 (#2645), which passes alone.
- The whole GUI suite (858 files, both engines, concurrency 3) was
started at 628e18987 and ended early when the disk filled (ENOSPC):
~350 files ran, 3108 passed. Its five reds from before the disk
filled are off the Plugins page, pass alone, and are filed:
agent-models (#3468), cli-update (#3473), context-picks (#3483),
deprecated-subscriptions (#3484). The rest failed launching a browser
with ENOSPC.
- Rerun after space was freed, at d7ad3f2a3 plus this change: every
library-* file, every plugin-* file, login-import, menu-input-scroll,
mobile-web, name-suffix-saved and i18n-keys (94 files, both engines):
1414 of 1426 pass. The 12 reds are all red on an origin/main
118486258 worktree too, and filed: library-mcp-health-wsl ja (#3350),
menu-input-scroll (#3402, 0 of 4 on main), plugin-card-update webkit
(#3079, 0-1 of 3 on main over three runs, same Update-button wait),
plugin-github chromium de 440 scrolled 1px (#3218, 18 of 18 alone).
- The two files after name-suffix-saved outside plugin-* that open the
Plugins page, settings-tabs-stick and title-bar-tools, both engines:
42 of 42 pass.
- Not run: the other ~440 GUI files after name-suffix-saved, and
go test ./... .
Screenshots, before and after, zh dark and en light, were checked by
eye at 1280.
This commit is contained in:
@@ -3561,12 +3561,12 @@ const I18N = {
|
||||
"Getting Bun…": "正在下载 Bun…",
|
||||
"Plugins run on Bun {v}, downloaded once": "插件运行在 Bun {v} 上,只需下载一次",
|
||||
"Coming soon": "即将上线",
|
||||
"Unofficial": "非官方",
|
||||
"Tagged {topic} on GitHub by its author. Nobody at magpie has read it: read its code before you install it": "作者在 GitHub 上给它打了 {topic} 标签,magpie 没有审阅过:安装前请先看看它的代码",
|
||||
"{n} stars on GitHub": "GitHub 上 {n} 个 Star",
|
||||
"Unofficial, on GitHub": "非官方插件 · GitHub",
|
||||
"Looking on GitHub": "正在 GitHub 上查找",
|
||||
"Couldn't ask GitHub: {error}": "无法连接 GitHub:{error}",
|
||||
"GitHub didn't answer in time": "GitHub 响应超时",
|
||||
"GitHub is turning requests away for now": "GitHub 暂时限制了请求",
|
||||
"{n} more on GitHub couldn't be read: {error}": "GitHub 上还有 {n} 个插件没能读取:{error}",
|
||||
"GitHub found {n} repositories, but none of them could be read: {error}": "GitHub 找到了 {n} 个仓库,但一个都没能读取:{error}",
|
||||
"Couldn't ask GitHub, so these are from before: {error}": "无法连接 GitHub,下面是之前获取的列表:{error}",
|
||||
@@ -7458,12 +7458,12 @@ const I18N = {
|
||||
"Getting Bun…": "正在下載 Bun…",
|
||||
"Plugins run on Bun {v}, downloaded once": "外掛執行在 Bun {v} 上,只需下載一次",
|
||||
"Coming soon": "即將上線",
|
||||
"Unofficial": "非官方",
|
||||
"Tagged {topic} on GitHub by its author. Nobody at magpie has read it: read its code before you install it": "作者在 GitHub 上給它打了 {topic} 標籤,magpie 沒有審閱過:安裝前請先看看它的程式碼",
|
||||
"{n} stars on GitHub": "GitHub 上 {n} 個 Star",
|
||||
"Unofficial, on GitHub": "非官方外掛 · GitHub",
|
||||
"Looking on GitHub": "正在 GitHub 上尋找",
|
||||
"Couldn't ask GitHub: {error}": "無法連線 GitHub:{error}",
|
||||
"GitHub didn't answer in time": "GitHub 回應逾時",
|
||||
"GitHub is turning requests away for now": "GitHub 暫時限制了請求",
|
||||
"{n} more on GitHub couldn't be read: {error}": "GitHub 上還有 {n} 個外掛未能讀取:{error}",
|
||||
"GitHub found {n} repositories, but none of them could be read: {error}": "GitHub 找到了 {n} 個儲存庫,但一個都未能讀取:{error}",
|
||||
"Couldn't ask GitHub, so these are from before: {error}": "無法連線 GitHub,以下是先前取得的列表:{error}",
|
||||
@@ -11377,12 +11377,12 @@ const I18N = {
|
||||
"Getting Bun…": "Bun を取得中…",
|
||||
"Plugins run on Bun {v}, downloaded once": "プラグインは Bun {v} で動作します(ダウンロードは一度だけ)",
|
||||
"Coming soon": "近日公開",
|
||||
"Unofficial": "非公式",
|
||||
"Tagged {topic} on GitHub by its author. Nobody at magpie has read it: read its code before you install it": "作者が GitHub で {topic} タグを付けたものです。magpie はレビューしていません。インストール前にコードを確認してください",
|
||||
"{n} stars on GitHub": "GitHub のスター {n}",
|
||||
"Unofficial, on GitHub": "非公式 · GitHub",
|
||||
"Looking on GitHub": "GitHub を検索中",
|
||||
"Couldn't ask GitHub: {error}": "GitHub に接続できませんでした:{error}",
|
||||
"GitHub didn't answer in time": "GitHub の応答がタイムアウトしました",
|
||||
"GitHub is turning requests away for now": "GitHub が一時的にリクエストを制限しています",
|
||||
"{n} more on GitHub couldn't be read: {error}": "GitHub 上のほか {n} 件を読み込めませんでした:{error}",
|
||||
"GitHub found {n} repositories, but none of them could be read: {error}": "GitHub で {n} 件のリポジトリが見つかりましたが、どれも読み込めませんでした:{error}",
|
||||
"Couldn't ask GitHub, so these are from before: {error}": "GitHub に接続できないため、以前の一覧を表示しています:{error}",
|
||||
@@ -15309,12 +15309,12 @@ const I18N = {
|
||||
"Getting Bun…": "Bun wird geladen…",
|
||||
"Plugins run on Bun {v}, downloaded once": "Erweiterungen laufen auf Bun {v}, einmalig heruntergeladen",
|
||||
"Coming soon": "Demnächst",
|
||||
"Unofficial": "Inoffiziell",
|
||||
"Tagged {topic} on GitHub by its author. Nobody at magpie has read it: read its code before you install it": "Vom Autor auf GitHub mit {topic} getaggt. Niemand bei magpie hat es geprüft: Lies den Code, bevor du es installierst",
|
||||
"{n} stars on GitHub": "{n} Sterne auf GitHub",
|
||||
"Unofficial, on GitHub": "Inoffiziell, auf GitHub",
|
||||
"Looking on GitHub": "Suche auf GitHub",
|
||||
"Couldn't ask GitHub: {error}": "GitHub nicht erreichbar: {error}",
|
||||
"GitHub didn't answer in time": "GitHub hat nicht rechtzeitig geantwortet",
|
||||
"GitHub is turning requests away for now": "GitHub weist Anfragen vorübergehend ab",
|
||||
"{n} more on GitHub couldn't be read: {error}": "{n} weitere auf GitHub konnten nicht gelesen werden: {error}",
|
||||
"GitHub found {n} repositories, but none of them could be read: {error}": "GitHub hat {n} Repositories gefunden, aber keines konnte gelesen werden: {error}",
|
||||
"Couldn't ask GitHub, so these are from before: {error}": "GitHub nicht erreichbar, dies ist die Liste von zuvor: {error}",
|
||||
|
||||
@@ -48,11 +48,16 @@
|
||||
they don't */
|
||||
.pm-ghbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
|
||||
.pm-ghbar .segs { flex: none; max-width: 100%; }
|
||||
.pm-ghfind { width: min(240px, 100%); }
|
||||
/* it takes a share of the room the strips leave, up to what its
|
||||
placeholder needs, so "Filter by name, author or description" isn't cut */
|
||||
.pm-ghfind { flex: 4 0 auto; width: min(240px, 100%); max-width: min(320px, 100%); }
|
||||
.pm-ghnone { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 22px 12px; border-radius: 12px; border: 1px dashed var(--line); font-size: 12px; color: var(--muted); text-align: center; }
|
||||
/* what GitHub couldn't give, over the cards it could: a quiet line, its
|
||||
reason wrapping anywhere (a URL in it is one long word) */
|
||||
.pm-ghwarn { display: flex; align-items: baseline; flex-wrap: wrap; gap: 2px 10px; font-size: 12px; color: var(--muted); }
|
||||
.pm-ghwarn { display: flex; align-items: baseline; flex-wrap: wrap; gap: 2px 6px; padding: 0 2px; font-size: 11.5px; color: var(--muted); }
|
||||
/* its Try again reads as the button it is, beside the quiet line */
|
||||
.pm-ghwarn .text { padding: 1px 6px; margin: -1px 0; font-size: 11.5px; color: var(--accent); }
|
||||
.pm-ghwarn .text:hover:not(:disabled) { color: var(--accent); background: var(--accent-soft); }
|
||||
.pm-ghwarn > span, .pm-ghnone > span { overflow-wrap: anywhere; }
|
||||
|
||||
.pm-logo { flex: none; width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--pill); color: var(--fg-2); }
|
||||
@@ -132,8 +137,12 @@ button.pm-chip:disabled { cursor: default; opacity: .6; }
|
||||
/* an update out: Install's size, green for its own (#1587) */
|
||||
.pm-act.pm-up { background: var(--green-soft); color: var(--green); }
|
||||
.pm-act.pm-up:hover:not(:disabled) { background: var(--green); color: var(--card); }
|
||||
.pm-act.go { background: var(--accent); color: var(--accent-fg); }
|
||||
.pm-act.go:hover:not(:disabled) { filter: brightness(1.08); background: var(--accent); color: var(--accent-fg); }
|
||||
/* Sign in, in a list of cards or rows, is Install's tinted capsule: one
|
||||
style for a row's action, so no card shouts over its neighbours (HIG's
|
||||
one filled button is a sheet's own); a plugin's page fills it */
|
||||
.pm-act.go { background: var(--accent-soft); color: var(--accent); }
|
||||
.pm-act.go:hover:not(:disabled), .pm-dact .pm-act.go { background: var(--accent); color: var(--accent-fg); }
|
||||
.pm-dact .pm-act.go:hover:not(:disabled) { filter: brightness(1.08); }
|
||||
.pm-act.done { background: none; color: var(--green); padding: 0 8px; min-width: 0; }
|
||||
.pm-act.done:hover:not(:disabled) { background: var(--green-soft); color: var(--green); }
|
||||
.pm-act.busy { color: var(--muted); font-weight: 500; }
|
||||
@@ -278,6 +287,7 @@ button.pm-chip:disabled { cursor: default; opacity: .6; }
|
||||
@media (max-width: 560px) {
|
||||
.pm-head { flex-wrap: wrap; }
|
||||
.pm-find { width: 100%; order: 3; }
|
||||
.pm-ghfind { max-width: 100%; }
|
||||
.pm-art { display: none; }
|
||||
}
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
let listings = null; // /api/plugins/listings: the plugins suggested
|
||||
let tagged = null; // /api/plugins/github: repositories their authors tagged magpie-plugin, as listings
|
||||
let taggedErr = ""; // why the list isn't GitHub's whole answer: it couldn't be asked, or...
|
||||
let taggedKind = ""; // its kind: "slow", "limited" or ""
|
||||
let taggedMissing = 0; // ...this many repositories it named couldn't be read
|
||||
let topic = "magpie-plugin";
|
||||
const npm = {}; // /api/plugins/npm: package → what npm says of it
|
||||
@@ -182,10 +183,12 @@
|
||||
const got = (r.repos || []).map(ghListing);
|
||||
if (!(r.error && !got.length && tagged?.length)) tagged = got;
|
||||
taggedErr = r.error || "";
|
||||
taggedKind = r.why || "";
|
||||
taggedMissing = r.missing || 0;
|
||||
if (r.topic) topic = r.topic;
|
||||
} catch (e) {
|
||||
taggedErr = e.message || String(e);
|
||||
taggedKind = "";
|
||||
taggedMissing = 0;
|
||||
tagged = tagged || [];
|
||||
}
|
||||
@@ -526,7 +529,7 @@
|
||||
const sum = el("p", "pm-sum", summary(l));
|
||||
const meta = el("div", "pm-meta");
|
||||
meta.append(kindChip(kindOf(l)));
|
||||
if (l.github) meta.append(unofficial(), stars(l.github.stars));
|
||||
if (l.github) meta.append(stars(l.github.stars));
|
||||
if (l.npm?.weekly) {
|
||||
const d = el("span", "pm-dl");
|
||||
d.append(glyph(DOWN, 11, 1.5), el("span", "", t("{n}/week", { n: count(l.npm.weekly) })));
|
||||
@@ -552,13 +555,6 @@
|
||||
return c;
|
||||
}
|
||||
|
||||
// a repository's author put it here, nobody reviewed it: said on its card
|
||||
function unofficial() {
|
||||
const u = el("span", "pm-chip warn");
|
||||
u.append(el("span", "dot"), el("span", "", t("Unofficial")));
|
||||
u.title = t("Tagged {topic} on GitHub by its author. Nobody at magpie has read it: read its code before you install it", { topic });
|
||||
return u;
|
||||
}
|
||||
function stars(n) {
|
||||
const d = el("span", "pm-dl");
|
||||
d.append(glyph(STAR, 11, 1.4), el("span", "", count(n)));
|
||||
@@ -653,10 +649,16 @@
|
||||
replaceKeeping(ghSec, [ghHead, skeleton(3)]);
|
||||
return ghSec;
|
||||
}
|
||||
// why the list isn't GitHub's whole answer; kept: cards are shown
|
||||
const ghWhy = (kept) => taggedMissing
|
||||
? t(kept ? "{n} more on GitHub couldn't be read: {error}" : "GitHub found {n} repositories, but none of them could be read: {error}", { n: taggedMissing, error: taggedErr })
|
||||
: t(kept ? "Couldn't ask GitHub, so these are from before: {error}" : "Couldn't ask GitHub: {error}", { error: taggedErr });
|
||||
// why the list isn't GitHub's whole answer; kept: cards are shown. A
|
||||
// known kind in the reader's words, the raw error as its hover
|
||||
const ghWhy = (kept) => {
|
||||
const error = { slow: t("GitHub didn't answer in time"), limited: t("GitHub is turning requests away for now") }[taggedKind] || taggedErr;
|
||||
const s = el("span", "", taggedMissing
|
||||
? t(kept ? "{n} more on GitHub couldn't be read: {error}" : "GitHub found {n} repositories, but none of them could be read: {error}", { n: taggedMissing, error })
|
||||
: t(kept ? "Couldn't ask GitHub, so these are from before: {error}" : "Couldn't ask GitHub: {error}", { error }));
|
||||
if (error !== taggedErr) s.title = taggedErr;
|
||||
return s;
|
||||
};
|
||||
// and one GitHub couldn't be asked of says so, with another go
|
||||
function ghFailed() {
|
||||
ghHead.replaceChildren(...ghTitle());
|
||||
@@ -671,7 +673,7 @@
|
||||
drawBody();
|
||||
loadTagged(true).then(drawBody);
|
||||
};
|
||||
box.append(el("span", "", ghWhy(false)), again);
|
||||
box.append(ghWhy(false), again);
|
||||
replaceKeeping(ghSec, [ghHead, box]);
|
||||
return ghSec;
|
||||
}
|
||||
@@ -686,7 +688,7 @@
|
||||
again.disabled = true;
|
||||
loadTagged(true).then(drawBody);
|
||||
};
|
||||
note.append(el("span", "", ghWhy(true)), again);
|
||||
note.append(ghWhy(true), again);
|
||||
return note;
|
||||
}
|
||||
function ghSection(list) {
|
||||
@@ -739,7 +741,7 @@
|
||||
// what's installed, on both sides of it: a reader looks for what to
|
||||
// add as much as for what they have
|
||||
if (both) {
|
||||
const pick = segs([["", t("All") + " · " + n(ghKind, "")], ["have", t("Installed") + " · " + n(ghKind, "have")], ["none", t("Not installed") + " · " + n(ghKind, "none")]], ghHave, (h) => { ghHave = h; drawGh(); });
|
||||
const pick = segs([["", t("All")], ["have", t("Installed") + " · " + n(ghKind, "have")], ["none", t("Not installed") + " · " + n(ghKind, "none")]], ghHave, (h) => { ghHave = h; drawGh(); });
|
||||
pick.classList.add("pm-ghhave");
|
||||
pick.setAttribute("role", "group");
|
||||
pick.setAttribute("aria-label", t("Installed or not"));
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"io"
|
||||
"net"
|
||||
"net/http"
|
||||
"regexp"
|
||||
"strings"
|
||||
@@ -12,6 +13,7 @@ import (
|
||||
|
||||
"github.com/yetone/magpie/internal/agent"
|
||||
"github.com/yetone/magpie/internal/gateway"
|
||||
"github.com/yetone/magpie/internal/ghtoken"
|
||||
"github.com/yetone/magpie/internal/middleware"
|
||||
"github.com/yetone/magpie/internal/plugin"
|
||||
"github.com/yetone/magpie/internal/provider"
|
||||
@@ -522,6 +524,11 @@ func pluginRoutes(mux *http.ServeMux, w Windows) {
|
||||
if errors.As(err, &m) {
|
||||
out["error"], out["missing"] = m.Why.Error(), m.Missing
|
||||
}
|
||||
// and what kind of why, for the page to say in the reader's
|
||||
// language (the raw error stays its hover)
|
||||
if w := taggedWhyKind(err); w != "" {
|
||||
out["why"] = w
|
||||
}
|
||||
}
|
||||
writeJSON(rw, out)
|
||||
})
|
||||
@@ -793,3 +800,19 @@ func pluginAgentOf(spec string, errs map[string]string) *pluginAgentJSON {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// taggedWhyKind is what kind of failure keeps GitHub's list from being
|
||||
// whole: "slow" when GitHub didn't answer in time, "limited" when it
|
||||
// turned magpie away for its rate limit, "" for anything else (the page
|
||||
// shows that error as it is).
|
||||
func taggedWhyKind(err error) string {
|
||||
var lim ghtoken.Limited
|
||||
var ne net.Error
|
||||
switch {
|
||||
case errors.As(err, &lim):
|
||||
return "limited"
|
||||
case errors.Is(err, plugin.ErrNoAnswer), errors.Is(err, context.DeadlineExceeded), errors.As(err, &ne) && ne.Timeout():
|
||||
return "slow"
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
package gui
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
"net/url"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/yetone/magpie/internal/ghtoken"
|
||||
"github.com/yetone/magpie/internal/plugin"
|
||||
)
|
||||
|
||||
// The Plugins page says why GitHub's list isn't whole in the reader's
|
||||
// language when magpie knows the kind of why, rather than Go's English in
|
||||
// the middle of the page (the Kiko03O1 reply on X: "no answer in 8s"
|
||||
// under 非官方插件 · GitHub). Each kind as the errors arrive: wrapped in
|
||||
// TaggedMissing, in a url.Error, or as they are.
|
||||
func TestTaggedWhyKind(t *testing.T) {
|
||||
timeout := &url.Error{Op: "Get", URL: "https://raw.githubusercontent.com/a/b/main/package.json", Err: &net.OpError{Op: "dial", Net: "tcp", Err: timeoutErr{}}}
|
||||
refused := &url.Error{Op: "Get", URL: "http://127.0.0.1:1/raw", Err: &net.OpError{Op: "dial", Net: "tcp", Err: errors.New("connect: connection refused")}}
|
||||
for _, c := range []struct {
|
||||
name string
|
||||
err error
|
||||
want string
|
||||
}{
|
||||
{"the page stopped waiting", &plugin.TaggedMissing{Missing: 7, Why: fmt.Errorf("%w in %s", plugin.ErrNoAnswer, 8*time.Second)}, "slow"},
|
||||
{"a read past its deadline", &plugin.TaggedMissing{Missing: 2, Why: &url.Error{Op: "Get", URL: "https://raw.githubusercontent.com/x", Err: context.DeadlineExceeded}}, "slow"},
|
||||
{"a dial that timed out", &plugin.TaggedMissing{Missing: 1, Why: timeout}, "slow"},
|
||||
{"the search past its deadline", fmt.Errorf("search: %w", context.DeadlineExceeded), "slow"},
|
||||
{"GitHub's rate limit", ghtoken.Limited{Until: time.Now().Add(time.Hour)}, "limited"},
|
||||
{"GitHub's rate limit, missing", &plugin.TaggedMissing{Missing: 3, Why: ghtoken.Limited{Token: true}}, "limited"},
|
||||
{"refused: said as it is", &plugin.TaggedMissing{Missing: 12, Why: refused}, ""},
|
||||
{"anything else", errors.New("GitHub's search: 502 Bad Gateway"), ""},
|
||||
} {
|
||||
if got := taggedWhyKind(c.err); got != c.want {
|
||||
t.Errorf("%s: %q, want %q (%v)", c.name, got, c.want, c.err)
|
||||
}
|
||||
}
|
||||
// the error as it came is still what the line's hover says
|
||||
if e := fmt.Errorf("%w in %s", plugin.ErrNoAnswer, 8*time.Second); e.Error() != "no answer in 8s" {
|
||||
t.Errorf("hover: %q", e)
|
||||
}
|
||||
}
|
||||
|
||||
type timeoutErr struct{}
|
||||
|
||||
func (timeoutErr) Error() string { return "i/o timeout" }
|
||||
func (timeoutErr) Timeout() bool { return true }
|
||||
func (timeoutErr) Temporary() bool { return true }
|
||||
@@ -111,7 +111,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
// two of them, a provider and a middleware, are already here, as
|
||||
// the page's own cards say
|
||||
const have = sec.locator(".pm-ghhave .opt");
|
||||
const wantHave = async (rs) => [await tr("All") + " · " + rs.length, await tr("Installed") + " · " + rs.filter(here).length, await tr("Not installed") + " · " + rs.filter((r) => !here(r)).length];
|
||||
const wantHave = async (rs) => [await tr("All"), await tr("Installed") + " · " + rs.filter(here).length, await tr("Not installed") + " · " + rs.filter((r) => !here(r)).length];
|
||||
assert.deepEqual(await have.allTextContents(), await wantHave(GH.repos));
|
||||
assert.equal(await sec.locator(".pm-ghhave .opt.on").textContent(), (await wantHave(GH.repos))[0]);
|
||||
assert.deepEqual((await sec.locator(".pm-card.have .pm-name b").allInnerTexts()).sort(), names(GH.repos.filter(here)));
|
||||
|
||||
@@ -65,10 +65,10 @@ function server(lang, gh, urls = []) {
|
||||
}
|
||||
|
||||
const L = {
|
||||
en: { section: "Unofficial, on GitHub", look: "Looking on GitHub", failed: /Couldn't ask GitHub/, again: "Try again", none: /GitHub found 12 repositories, but none of them could be read/, more: /12 more on GitHub couldn't be read/ },
|
||||
zh: { section: "非官方插件 · GitHub", look: "正在 GitHub 上查找", failed: /无法连接 GitHub/, again: "重试", none: /GitHub 找到了 12 个仓库,但一个都没能读取/, more: /GitHub 上还有 12 个插件没能读取/ },
|
||||
ja: { section: "非公式 · GitHub", look: "GitHub を検索中", failed: /GitHub に接続できませんでした/, again: "再試行", none: /GitHub で 12 件のリポジトリが見つかりましたが/, more: /GitHub 上のほか 12 件を読み込めませんでした/ },
|
||||
de: { section: "Inoffiziell, auf GitHub", look: "Suche auf GitHub", failed: /GitHub nicht erreichbar/, again: "Erneut versuchen", none: /GitHub hat 12 Repositories gefunden/, more: /12 weitere auf GitHub konnten nicht gelesen werden/ },
|
||||
en: { section: "Unofficial, on GitHub", look: "Looking on GitHub", failed: /Couldn't ask GitHub/, again: "Try again", none: /GitHub found 12 repositories, but none of them could be read/, more: /12 more on GitHub couldn't be read/, slow: /7 more on GitHub couldn't be read: GitHub didn't answer in time/ },
|
||||
zh: { section: "非官方插件 · GitHub", look: "正在 GitHub 上查找", failed: /无法连接 GitHub/, again: "重试", none: /GitHub 找到了 12 个仓库,但一个都没能读取/, more: /GitHub 上还有 12 个插件没能读取/, slow: /GitHub 上还有 7 个插件没能读取:GitHub 响应超时/ },
|
||||
ja: { section: "非公式 · GitHub", look: "GitHub を検索中", failed: /GitHub に接続できませんでした/, again: "再試行", none: /GitHub で 12 件のリポジトリが見つかりましたが/, more: /GitHub 上のほか 12 件を読み込めませんでした/, slow: /GitHub の応答がタイムアウトしました/ },
|
||||
de: { section: "Inoffiziell, auf GitHub", look: "Suche auf GitHub", failed: /GitHub nicht erreichbar/, again: "Erneut versuchen", none: /GitHub hat 12 Repositories gefunden/, more: /12 weitere auf GitHub konnten nicht gelesen werden/, slow: /GitHub hat nicht rechtzeitig geantwortet/ },
|
||||
};
|
||||
|
||||
const shot = async (loc, name) => {
|
||||
@@ -216,6 +216,22 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
assert.deepEqual(urls2, ["/api/plugins/github", "/api/plugins/github?again=1"]);
|
||||
assert.deepEqual(m.errors, []);
|
||||
|
||||
// GitHub too slow, as magpie tells it (why: "slow"): the line
|
||||
// says so in the reader's language, not Go's "no answer in 8s"
|
||||
// in the middle of the page, and the error as it came is its
|
||||
// hover (the Kiko03O1 reply on X: ui 设计能不能好看点); Try
|
||||
// again reads as a button, in the accent
|
||||
const s = await open([{ json: { repos: REPOS, topic: "magpie-plugin", error: "no answer in 8s", why: "slow", missing: 7 } }]);
|
||||
t.after(() => s.ctx.close());
|
||||
const sLine = s.sec.locator(".pm-ghwarn");
|
||||
await sLine.waitFor();
|
||||
assert.match(await sLine.innerText(), w.slow);
|
||||
assert.doesNotMatch(await sLine.innerText(), /no answer/);
|
||||
assert.equal(await sLine.locator("span").first().getAttribute("title"), "no answer in 8s");
|
||||
const tone = (v) => s.page.evaluate((v) => { const d = document.createElement("div"); d.style.color = `var(${v})`; document.body.append(d); const c = getComputedStyle(d).color; d.remove(); return c; }, v);
|
||||
assert.equal(await sLine.getByRole("button", { name: w.again }).evaluate((b) => getComputedStyle(b).color), await tone("--accent"));
|
||||
assert.deepEqual(s.errors, []);
|
||||
|
||||
// a failed ask after a list was had: the list stands, and the
|
||||
// line says it is from before
|
||||
const k = await open([{ json: { repos: REPOS, topic: "magpie-plugin" } }, { json: { repos: [], topic: "magpie-plugin", error: "GitHub's search: 403 rate limit" } }]);
|
||||
|
||||
@@ -126,8 +126,10 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
assert.equal(await cards.nth(2).locator(".pm-logo img").count(), 0);
|
||||
// a provider and a middleware part by hue (yetone: 中间件和供应商稍微有点区分吧)
|
||||
assert.equal(await c.locator(".pm-chip.kind.pv").count(), 1);
|
||||
assert.equal((await c.locator(".pm-chip.warn").innerText()).trim(), w.chip);
|
||||
assert.match(await c.locator(".pm-chip.warn").getAttribute("title"), /magpie-plugin/);
|
||||
// unofficial is said by the section's head, once, not by a chip on
|
||||
// every card in it (the Kiko03O1 reply on X: ui 设计能不能好看点)
|
||||
assert.equal(await sec.locator(".pm-chip.warn").count(), 0);
|
||||
assert.equal(await sec.locator(".pm-meta", { hasText: w.chip }).count(), 0);
|
||||
assert.equal((await c.locator(".pm-dl").innerText()).trim(), "1.3k");
|
||||
assert.equal((await c.locator(".pm-ver").innerText()).trim(), "v2.2.1");
|
||||
// installed by its page's URL: Installed all the same
|
||||
@@ -203,7 +205,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
await page.waitForFunction(() => document.querySelectorAll("#view-plugins .pm-sec .pm-card").length === 1);
|
||||
assert.deepEqual(await found.locator(".pm-name b").allInnerTexts(), ["opencode-quota"]);
|
||||
await view.locator(".pm-find input").fill("nothing-like-it");
|
||||
await page.waitForFunction(() => !document.querySelector("#view-plugins .pm-sec .pm-card .pm-chip.warn"));
|
||||
await page.waitForFunction(() => !document.querySelector("#view-plugins .pm-ghsec .pm-card"));
|
||||
|
||||
assert.equal(asked.filter(([k]) => k === "fetched").length, 0, "nothing fetched from outside: " + JSON.stringify(asked.filter(([k]) => k === "fetched")));
|
||||
assert.deepEqual(errors, []);
|
||||
|
||||
@@ -189,6 +189,15 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
await dlg.locator(".pm-act", { hasText: w.install }).click();
|
||||
await dlg.locator(".pm-act.go", { hasText: w.signIn }).waitFor();
|
||||
assert.deepEqual(asked.find(([k]) => k === "add")[1], { spec: "opencode-copilot-auth" });
|
||||
// the page's one action is filled; on the card behind it, Sign in is
|
||||
// Install's tinted capsule, so no card in the grid shouts over the
|
||||
// rest (the Kiko03O1 reply on X: ui 设计能不能好看点)
|
||||
const fill = (loc) => loc.evaluate((b) => getComputedStyle(b).backgroundColor);
|
||||
const tone = (v) => page.evaluate((v) => { const d = document.createElement("div"); d.style.background = `var(${v})`; document.body.append(d); const c = getComputedStyle(d).backgroundColor; d.remove(); return c; }, v);
|
||||
assert.equal(await fill(dlg.locator(".pm-act.go")), await tone("--accent"));
|
||||
const cardGo = copilot.locator(".pm-act.go", { hasText: w.signIn });
|
||||
await cardGo.waitFor();
|
||||
assert.equal(await fill(cardGo), await tone("--accent-soft"));
|
||||
await dlg.locator(".pm-act.go").click();
|
||||
await page.locator("#view-providers").waitFor({ state: "visible" });
|
||||
await page.waitForFunction(() => document.querySelector("#modal").hidden);
|
||||
|
||||
@@ -101,6 +101,10 @@ func taggedOnDisk() []Tagged {
|
||||
return l
|
||||
}
|
||||
|
||||
// ErrNoAnswer is GitHub not answering a read before the page stopped
|
||||
// waiting for it.
|
||||
var ErrNoAnswer = errors.New("no answer")
|
||||
|
||||
// TaggedMissing is the error TaggedRepos gives when GitHub's search
|
||||
// answered but repositories it named couldn't be read: Missing of them
|
||||
// aren't in the list, for Why.
|
||||
@@ -357,7 +361,7 @@ func askTagged(ctx context.Context, last []Tagged) (l []Tagged, whole bool, miss
|
||||
w := why
|
||||
mu.Unlock()
|
||||
if w == nil {
|
||||
w = fmt.Errorf("no answer in %s", taggedWait)
|
||||
w = fmt.Errorf("%w in %s", ErrNoAnswer, taggedWait)
|
||||
}
|
||||
missing = &TaggedMissing{Missing: gone, Why: w}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user