gui: a moved provider's editor reads as the built-in's — its model list dated, its agent's own sign-in said, its move a button (要保证插件订阅 provider 跟内置的订阅 provider所有逻辑都要一模一样) — after a move the list said "magpie's list · Refresh asks the vendor" where the built-in said "vendor list · 9m ago"; it is now dated by when the plugin last listed it, in the editor and in magpie providers. "Command Code itself stays signed in as it is." is kept for Devin, ZCode, WorkBuddy, Kiro and Command Code, whose agents keep their own sign-in through the move; and Move to the plugin / Use the built-in again is drawn as a button, not a line of text. plugin-move.test.cjs fails without the kept line. go vet, go build -tags nogui (darwin, GOOS=linux), GOOS=windows go build, go test -tags nogui ./... pass; plugin-move, click-scroll, old-webkit, plugin-market, plugin-signin, nokey-editor pass.
This commit is contained in:
@@ -1459,7 +1459,7 @@ body.window .ag-sk-icon { width: 22px; height: 22px; border-radius: 6px; }
|
||||
.editor .move .hint { margin-top: 0; }
|
||||
.editor .move .move-why { font-size: 11.5px; line-height: 1.45; color: var(--red); overflow-wrap: anywhere; user-select: text; -webkit-user-select: text; }
|
||||
.editor .move .move-why[hidden] { display: none; }
|
||||
.editor .move > button { padding-left: 0; padding-right: 0; }
|
||||
.editor .move > button { max-width: 100%; white-space: normal; text-align: left; height: auto; min-height: 27px; }
|
||||
.editor .headers { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
|
||||
.editor .headers .pair { width: 100%; }
|
||||
.editor .headers .hadds { display: flex; flex-wrap: wrap; gap: 2px 12px; }
|
||||
|
||||
@@ -4933,9 +4933,8 @@ const subOf = (agent) => {
|
||||
const own = SUBS.find((x) => x.agent === agent);
|
||||
const pl = pluginSubs().find((x) => x.agent === agent);
|
||||
if (own && pl && movedSub(agent)) {
|
||||
// own too: the agent's own sign-in stays where it was, and its editor says so as the built-in's does
|
||||
const { name, icon, plans, risk, riskNote, hint, sites, importable } = own;
|
||||
return { ...pl, name, icon, plans, risk, riskNote, hint, sites, importable, own: own.own, moved: true };
|
||||
return { ...pl, name, icon, plans, risk, riskNote, hint, sites, importable, moved: true };
|
||||
}
|
||||
return own || pl;
|
||||
};
|
||||
@@ -5425,7 +5424,7 @@ function renderAccounts(a) {
|
||||
dot.title = l.paused ? t("Resume: the gateway uses this account first again") : t("Pause: the gateway uses the other accounts, {agent} stays signed in to this one", { agent: a.agentName });
|
||||
dot.onclick = () => accountAction("login/" + (l.paused ? "on" : "off"), { agent: a.agent, user: l.user });
|
||||
} else if (l.active) {
|
||||
dot.title = sub?.own || sub?.plugin ? t("The gateway uses this account first") : t("{agent} is signed in to this account", { agent: a.agentName });
|
||||
dot.title = sub?.own ? t("The gateway uses this account first") : t("{agent} is signed in to this account", { agent: a.agentName });
|
||||
dot.classList.add("fixed");
|
||||
} else {
|
||||
dot.title = on ? t("Stop using this account") : t("Use this account too");
|
||||
@@ -5445,8 +5444,8 @@ function renderAccounts(a) {
|
||||
forget.title = l.own ? forgetOwnTitle(a) : t("magpie forgets this account's sign-in; the account itself is untouched");
|
||||
forget.onclick = () => accountAction("login/forget", { agent: a.agent, user: l.user }, t("{user} removed", { user: l.user }));
|
||||
const use = el("button", "text", on ? t("Make first") : t("Use"));
|
||||
use.title = sub?.own || sub?.plugin ? t("The gateway uses this account first") : t("Sign {agent} in to this account", { agent: a.agentName });
|
||||
use.onclick = () => { use.classList.add("busy"); accountAction("login/switch", { agent: a.agent, user: l.user }, sub?.own || sub?.plugin ? t("The gateway now uses {user} first", { user: l.user }) : t("{agent} is now signed in as {user}", { agent: a.agentName, user: l.user })); };
|
||||
use.title = sub?.own ? t("The gateway uses this account first") : t("Sign {agent} in to this account", { agent: a.agentName });
|
||||
use.onclick = () => { use.classList.add("busy"); accountAction("login/switch", { agent: a.agent, user: l.user }, sub?.own ? t("The gateway now uses {user} first", { user: l.user }) : t("{agent} is now signed in as {user}", { agent: a.agentName, user: l.user })); };
|
||||
row.append(forget, use);
|
||||
}
|
||||
row.append(accountQuota(l.lapsed ? { [l.user]: { error: l.lapsed } } : quota, l.user));
|
||||
@@ -6116,7 +6115,7 @@ function renderMove(p) {
|
||||
const failed = m.state === "failed" && (m.why || m.error);
|
||||
say(failed ? t("It stays built-in: {error}", { error: moveWhy(m, p) }) : "");
|
||||
const idle = () => onPlugin ? t("Use the built-in again") : failed ? t("Try again") : t("Move to the plugin");
|
||||
const b = el("button", "text", idle());
|
||||
const b = el("button", "text action", idle()); // a button, not a line of text: it changes what runs the subscription
|
||||
b.onclick = async () => {
|
||||
b.classList.add("busy");
|
||||
b.disabled = true;
|
||||
|
||||
@@ -360,7 +360,7 @@ func providerInfo(p provider.Provider, agents []agentUse) providerJSON {
|
||||
out.DrawIDs = append(out.DrawIDs, m.ID)
|
||||
}
|
||||
out.Draws = len(out.DrawIDs)
|
||||
if t, ok := p.Fetched(); ok {
|
||||
if t, ok := p.Listed(); ok {
|
||||
out.Fetched = &t
|
||||
}
|
||||
for _, a := range agents {
|
||||
|
||||
@@ -29,7 +29,7 @@ function serve(lang, posts) {
|
||||
// enough models that the editor scrolls to reach Runs on
|
||||
models: Array.from({ length: 30 }, (_, i) => ({ id: "m" + i, name: "Model " + i, on: i === 0 })),
|
||||
agents: [], fallback: [], headers: {}, keyList: [], key: {},
|
||||
account: { agent: "zed", agentName: "Zed", user: "ada", logins: [{ user: "ada", active: true, on: true }, { user: "bob", on: true }] },
|
||||
account: { agent: "zed", agentName: "Zed", user: "ada", logins: [{ user: "ada", active: true, on: true, own: true }, { user: "bob", on: true }] },
|
||||
move,
|
||||
};
|
||||
return {
|
||||
@@ -73,12 +73,12 @@ const L = {
|
||||
move: "Move to the plugin", busy: "Installing the plugin and checking each account…", again: "Try again", back: "Use the built-in again",
|
||||
failed: "It stays built-in: magpie couldn't reach npm to install the plugin. Check the network or proxy, then try again.",
|
||||
onPlugin: "The community Zed plugin", builtin: "magpie's built-in · or the community Zed plugin", done: "Zed now runs on its plugin — 2 accounts, 1 model.",
|
||||
subs: "Subscriptions", card: "Move my Zed accounts (2)" },
|
||||
subs: "Subscriptions", card: "Move my Zed accounts (2)", own: "Zed itself stays signed in as it is." },
|
||||
zh: { runs: "运行方式", line: "Zed 可以改由社区插件运行,账号不变。", look: "看看",
|
||||
move: "迁移到插件", busy: "正在安装插件并逐个检查账号…", again: "重试", back: "改回内置",
|
||||
failed: "仍使用内置:无法连接 npm 安装插件,请检查网络或代理后重试。",
|
||||
onPlugin: "社区 Zed 插件", builtin: "magpie 内置 · 也可改用社区 Zed 插件", done: "Zed 现在由插件运行——2 个账号,1 个模型。",
|
||||
subs: "订阅", card: "迁移我的 Zed 账号(2)" },
|
||||
subs: "订阅", card: "迁移我的 Zed 账号(2)", own: "Zed 本身的登录保持不变。" },
|
||||
};
|
||||
|
||||
const launch = (engine) => engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" });
|
||||
@@ -112,6 +112,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
assert.equal(await ed.locator(".move").getAttribute("title"), null);
|
||||
assert.equal(await ed.locator(".move > div").first().getAttribute("title"), pkg, "the package isn't in the tooltip");
|
||||
assert.ok(!text.includes(pkg), "names the npm package in the sentence");
|
||||
assert.ok(text.includes(w.own), "doesn't say Zed stays signed in");
|
||||
|
||||
// the reader scrolled to the field: nothing the move does moves it
|
||||
const body = ed.locator(".ebody");
|
||||
@@ -137,6 +138,8 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
await back.waitFor();
|
||||
assert.equal(await page.locator("#modal .editor").count(), 1, "the editor closed");
|
||||
assert.ok((await ed.innerText()).includes(w.onPlugin), "doesn't say the plugin runs it");
|
||||
// as the built-in said: the agent's own sign-in is where it was
|
||||
assert.ok((await ed.innerText()).includes(w.own), "the moved Zed no longer says Zed stays signed in");
|
||||
assert.equal(await why.count() && await why.isVisible(), false, "the failure is still said");
|
||||
assert.equal(await body.evaluate((e) => e.scrollTop), top, "the move moved the editor");
|
||||
assert.ok((await page.locator("#status").innerText()).startsWith(w.done), "no toast saying what moved");
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
"slices"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/yetone/magpie/internal/settings"
|
||||
)
|
||||
@@ -87,6 +88,16 @@ var (
|
||||
|
||||
func providersPath() string { return filepath.Join(settings.Dir(), "plugin-providers.json") }
|
||||
|
||||
// ListedAt is when the plugins last listed their providers and models, as
|
||||
// a built-in's list is dated by when it was fetched.
|
||||
func ListedAt() (time.Time, bool) {
|
||||
st, err := os.Stat(providersPath())
|
||||
if err != nil {
|
||||
return time.Time{}, false
|
||||
}
|
||||
return st.ModTime(), true
|
||||
}
|
||||
|
||||
func forgetProviders() {
|
||||
provMu.Lock()
|
||||
provGood = false
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/yetone/magpie/internal/catalog"
|
||||
"github.com/yetone/magpie/internal/plugin"
|
||||
"github.com/yetone/magpie/internal/settings"
|
||||
)
|
||||
|
||||
@@ -94,6 +95,15 @@ func (p Provider) Fetched() (time.Time, bool) {
|
||||
return t, ok
|
||||
}
|
||||
|
||||
// Listed is when the models listed now were had from the vendor: fetched
|
||||
// for a built-in, listed by its plugin for a plugin's.
|
||||
func (p Provider) Listed() (time.Time, bool) {
|
||||
if p.IsPlugin() {
|
||||
return plugin.ListedAt()
|
||||
}
|
||||
return p.Fetched()
|
||||
}
|
||||
|
||||
// live is the list last fetched from the vendor. A plugin's provider has
|
||||
// none: its models are what the plugin lists now, and a built-in moved
|
||||
// onto it left its own last list under the same id.
|
||||
|
||||
+2
-2
@@ -94,7 +94,7 @@ func providers() error {
|
||||
r.key = amber.Render("○ no key")
|
||||
}
|
||||
n := len(p.Exposed())
|
||||
if t, ok := p.Fetched(); ok {
|
||||
if t, ok := p.Listed(); ok {
|
||||
r.models = fmt.Sprintf("%d of %d models", n, len(p.Available())) + muted.Render(" · fetched "+ago(t))
|
||||
} else {
|
||||
r.models = fmt.Sprintf("%d models", n)
|
||||
@@ -609,7 +609,7 @@ func showProvider(p provider.Provider) error {
|
||||
}
|
||||
ms := p.Exposed()
|
||||
src := "models.dev"
|
||||
if t, ok := p.Fetched(); ok {
|
||||
if t, ok := p.Listed(); ok {
|
||||
src = fetchedFrom(p) + " · fetched " + ago(t)
|
||||
}
|
||||
kv("models", fmt.Sprintf("%d exposed of %d %s", len(ms), len(p.Available()), muted.Render("from "+src)))
|
||||
|
||||
Reference in New Issue
Block a user