gui: one-value sign-in sheets load when asked for, the setup-token's budget raise undone
8ebf9cbea(a Claude account from a setup-token, v0.1.2167) raised the app.js budget 1,315,316 -> 1,317,705 and the core-script budget 1,537,034 -> 1,539,423. A raise bounds nothing (#2710), so this takes it back. app.js's budget is 1,315,316 again. The core's had since been lowered to 1,538,975 by1bbaded62(purposes.js, 448 bytes less); it is lowered by the 2,389 the setup-token added, to 1,536,586. The two sign-in sheets that ask one value before a sign-in starts move out of app.js into signsheets.js: Claude's setup-token sheet and Copilot's GHE.com host sheet. app.js imports the file only when one is asked for (signAsk), the way it imports cfgblocked.js. A failed import says why in the status line. app.js is now 1,314,384 bytes (budget 1,315,316), the core scripts 1,535,654 (budget 1,536,586). old-webkit's "loaded by index.html" check exempts signsheets.js as it does cfgblocked.js; its Safari 15 syntax checks still read the file. Run on xiaomi-gpu (win-run), at the pushed head (this and the next commit, signin-close's test fix) on origin/main1bbaded62: - go test -run TestCoreScriptBudget ./internal/gui: ok. - node --test claude-setup-token, copilot-ghe, old-webkit, i18n-keys, signin-close, Chromium and WebKit: 19/19 each. Both sheets open through the lazy import, their text translated, the setup-token's refusal and success, the GHE.com host's check. - gofmt -l internal/gui: empty. Broken by hand: signAsk without its import, claude-setup-token and copilot-ghe (Chromium) 0/7. Not run: the whole GUI suite and the full Go suite on mote, which is running other sessions' suites at load 82; the full Go suite runs on Linux after the push.
This commit is contained in:
@@ -12775,101 +12775,20 @@ function copilotHostSwitch(sub) {
|
||||
b.title = site ? t("Signing in on {host}", { host: site }) : t("An account of an enterprise on GitHub Enterprise Cloud with data residency signs in at its <name>.ghe.com");
|
||||
b.onclick = () => {
|
||||
if (site) return startSignIn("copilot", true); // which ends this one
|
||||
stopSignIn();
|
||||
signing = { agent: "copilot", state: "ghe" };
|
||||
renderProviders();
|
||||
signAsk({ agent: "copilot", state: "ghe" });
|
||||
};
|
||||
return b;
|
||||
}
|
||||
|
||||
// renderCopilotGHE: the enterprise's host asked before its sign-in starts.
|
||||
function renderCopilotGHE(sub) {
|
||||
const box = el("div", "signing copilot-ghe");
|
||||
const tt = el("span", "tt");
|
||||
box.append(tt);
|
||||
const flow = signing;
|
||||
const label = t("Your enterprise on GHE.com");
|
||||
tt.append(el("span", "n", label),
|
||||
el("span", "s", t("The address you sign in to GitHub at, like acme.ghe.com. An account on github.com doesn't need it.")));
|
||||
const form = el("form", "callback-form");
|
||||
const inp = input(flow.host || "", "acme.ghe.com");
|
||||
inp.setAttribute("aria-label", label);
|
||||
const go = el("button", "text primary", t("Sign in"));
|
||||
go.type = "submit";
|
||||
go.disabled = !GHE_HOST.test(inp.value.trim());
|
||||
const why = el("span", "s why", "");
|
||||
inp.oninput = () => { flow.host = inp.value; go.disabled = !GHE_HOST.test(inp.value.trim()); why.textContent = ""; };
|
||||
const submit = (e) => {
|
||||
e.preventDefault();
|
||||
if (signing !== flow) return;
|
||||
const host = inp.value.trim().replace(/^https?:\/\//i, "").replace(/\/$/, "").toLowerCase();
|
||||
if (!GHE_HOST.test(host)) { why.textContent = t("Type your enterprise's <name>.ghe.com"); return; }
|
||||
startSignIn("copilot", true, host);
|
||||
};
|
||||
form.onsubmit = submit;
|
||||
go.onclick = submit;
|
||||
form.append(inp, go);
|
||||
tt.append(form, why);
|
||||
const close = el("button", "text", t("Cancel"));
|
||||
close.onclick = cancelSignIn;
|
||||
const back = el("button", "text", "github.com");
|
||||
back.title = t("Sign in on github.com instead");
|
||||
back.onclick = () => startSignIn("copilot", true);
|
||||
box.append(close, back);
|
||||
setTimeout(() => { if (inp.isConnected) inp.focus({ preventScroll: true }); });
|
||||
return box;
|
||||
}
|
||||
|
||||
// a Claude account from a setup-token (claude_setup_token.go)
|
||||
function startClaudeToken() {
|
||||
// signAsk: a sign-in that asks one value first (Copilot's GHE.com host, a
|
||||
// Claude setup-token); its sheet is in signsheets.js, loaded when asked for
|
||||
async function signAsk(flow) {
|
||||
try { await import("./signsheets.js"); } catch (err) { return status(err.message, "err"); }
|
||||
stopSignIn();
|
||||
signing = { agent: "claude", state: "token", token: "" };
|
||||
signing = flow;
|
||||
renderProviders();
|
||||
}
|
||||
|
||||
function renderClaudeToken(sub) {
|
||||
const box = el("div", "signing claude-token");
|
||||
const tt = el("span", "tt");
|
||||
box.append(tt);
|
||||
const flow = signing;
|
||||
const label = t("Add a Claude account by setup-token");
|
||||
tt.append(el("span", "n", label),
|
||||
el("span", "s", t("Paste the token {cmd} printed. magpie gives it to Claude Code for this account's requests only; Claude Code itself stays signed in as it is.", { cmd: "claude setup-token" })),
|
||||
el("span", "s", t("A setup-token can't tell its email or allowance: the account is named by the token, and its allowance shows once a reply tells it.")));
|
||||
const form = el("form", "callback-form");
|
||||
const inp = input(flow.token || "", "sk-ant-oat01-…", "password");
|
||||
inp.setAttribute("aria-label", label);
|
||||
const go = el("button", "text primary", t("Add"));
|
||||
go.type = "submit";
|
||||
go.disabled = !inp.value.trim() || !!flow.busy;
|
||||
const why = el("span", "s why", flow.error || "");
|
||||
inp.oninput = () => { flow.token = inp.value; go.disabled = !inp.value.trim(); why.textContent = ""; };
|
||||
const submit = async (e) => {
|
||||
e.preventDefault();
|
||||
if (signing !== flow || flow.busy || !inp.value.trim()) return;
|
||||
flow.busy = true;
|
||||
go.disabled = true;
|
||||
try {
|
||||
const r = await api("signin/claude-token", { token: inp.value });
|
||||
if (signing !== flow) return;
|
||||
await signedIn({ agent: "claude", user: r.user, token: true });
|
||||
} catch (err) {
|
||||
if (signing !== flow) return;
|
||||
flow.busy = false;
|
||||
flow.error = err.message;
|
||||
renderProviders();
|
||||
}
|
||||
};
|
||||
form.onsubmit = submit;
|
||||
go.onclick = submit;
|
||||
form.append(inp, go);
|
||||
tt.append(form, why);
|
||||
const close = el("button", "text", t("Cancel"));
|
||||
close.onclick = cancelSignIn;
|
||||
box.append(close);
|
||||
setTimeout(() => { if (inp.isConnected) inp.focus({ preventScroll: true }); });
|
||||
return box;
|
||||
}
|
||||
const startClaudeToken = () => signAsk({ agent: "claude", state: "token", token: "" });
|
||||
|
||||
// dropSigningIn: the editor of provider id closing (Cancel, Save, Remove)
|
||||
// leaves no sign-in of its account waiting behind it, to come back with the
|
||||
@@ -12945,8 +12864,8 @@ function renderSigning(sub) {
|
||||
}
|
||||
return box;
|
||||
}
|
||||
if (signing.state === "ghe") return renderCopilotGHE(sub);
|
||||
if (signing.state === "token") return renderClaudeToken(sub);
|
||||
if (signing.state === "ghe") return window.copilotGHESheet();
|
||||
if (signing.state === "token") return window.claudeTokenSheet();
|
||||
if (signing.state === "import" || signing.state === "importing" || signing.state === "imported") return renderLoginImport(sub);
|
||||
if (signing.state === "method" || signing.state === "prompt" || signing.state === "key") return renderPluginAsk(sub);
|
||||
if (signing.state === "failed") {
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
// Sign-ins that ask one value before they start. app.js imports this only
|
||||
// when one is asked for (signAsk), so it weighs nothing on the core.
|
||||
|
||||
// Copilot's enterprise on GHE.com: its host, asked before its sign-in starts
|
||||
window.copilotGHESheet = function () {
|
||||
const box = el("div", "signing copilot-ghe");
|
||||
const tt = el("span", "tt");
|
||||
box.append(tt);
|
||||
const flow = signing;
|
||||
const label = t("Your enterprise on GHE.com");
|
||||
tt.append(el("span", "n", label),
|
||||
el("span", "s", t("The address you sign in to GitHub at, like acme.ghe.com. An account on github.com doesn't need it.")));
|
||||
const form = el("form", "callback-form");
|
||||
const inp = input(flow.host || "", "acme.ghe.com");
|
||||
inp.setAttribute("aria-label", label);
|
||||
const go = el("button", "text primary", t("Sign in"));
|
||||
go.type = "submit";
|
||||
go.disabled = !GHE_HOST.test(inp.value.trim());
|
||||
const why = el("span", "s why", "");
|
||||
inp.oninput = () => { flow.host = inp.value; go.disabled = !GHE_HOST.test(inp.value.trim()); why.textContent = ""; };
|
||||
const submit = (e) => {
|
||||
e.preventDefault();
|
||||
if (signing !== flow) return;
|
||||
const host = inp.value.trim().replace(/^https?:\/\//i, "").replace(/\/$/, "").toLowerCase();
|
||||
if (!GHE_HOST.test(host)) { why.textContent = t("Type your enterprise's <name>.ghe.com"); return; }
|
||||
startSignIn("copilot", true, host);
|
||||
};
|
||||
form.onsubmit = submit;
|
||||
go.onclick = submit;
|
||||
form.append(inp, go);
|
||||
tt.append(form, why);
|
||||
const close = el("button", "text", t("Cancel"));
|
||||
close.onclick = cancelSignIn;
|
||||
const back = el("button", "text", "github.com");
|
||||
back.title = t("Sign in on github.com instead");
|
||||
back.onclick = () => startSignIn("copilot", true);
|
||||
box.append(close, back);
|
||||
setTimeout(() => { if (inp.isConnected) inp.focus({ preventScroll: true }); });
|
||||
return box;
|
||||
};
|
||||
|
||||
// a Claude account from the token `claude setup-token` prints (sfss5362 on
|
||||
// X; claude_setup_token.go)
|
||||
window.claudeTokenSheet = function () {
|
||||
const box = el("div", "signing claude-token");
|
||||
const tt = el("span", "tt");
|
||||
box.append(tt);
|
||||
const flow = signing;
|
||||
const label = t("Add a Claude account by setup-token");
|
||||
tt.append(el("span", "n", label),
|
||||
el("span", "s", t("Paste the token {cmd} printed. magpie gives it to Claude Code for this account's requests only; Claude Code itself stays signed in as it is.", { cmd: "claude setup-token" })),
|
||||
el("span", "s", t("A setup-token can't tell its email or allowance: the account is named by the token, and its allowance shows once a reply tells it.")));
|
||||
const form = el("form", "callback-form");
|
||||
const inp = input(flow.token || "", "sk-ant-oat01-…", "password");
|
||||
inp.setAttribute("aria-label", label);
|
||||
const go = el("button", "text primary", t("Add"));
|
||||
go.type = "submit";
|
||||
go.disabled = !inp.value.trim() || !!flow.busy;
|
||||
const why = el("span", "s why", flow.error || "");
|
||||
inp.oninput = () => { flow.token = inp.value; go.disabled = !inp.value.trim(); why.textContent = ""; };
|
||||
const submit = async (e) => {
|
||||
e.preventDefault();
|
||||
if (signing !== flow || flow.busy || !inp.value.trim()) return;
|
||||
flow.busy = true;
|
||||
go.disabled = true;
|
||||
try {
|
||||
const r = await api("signin/claude-token", { token: inp.value });
|
||||
if (signing !== flow) return;
|
||||
await signedIn({ agent: "claude", user: r.user, token: true });
|
||||
} catch (err) {
|
||||
if (signing !== flow) return;
|
||||
flow.busy = false;
|
||||
flow.error = err.message;
|
||||
renderProviders();
|
||||
}
|
||||
};
|
||||
form.onsubmit = submit;
|
||||
go.onclick = submit;
|
||||
form.append(inp, go);
|
||||
tt.append(form, why);
|
||||
const close = el("button", "text", t("Cancel"));
|
||||
close.onclick = cancelSignIn;
|
||||
box.append(close);
|
||||
setTimeout(() => { if (inp.isConnected) inp.focus({ preventScroll: true }); });
|
||||
return box;
|
||||
};
|
||||
File diff suppressed because one or more lines are too long
@@ -142,8 +142,9 @@ test("compat.js is the first of the page's own scripts", async () => {
|
||||
const srcs = all.filter((s) => s !== "boot.js" && s !== "theme.js" && s !== "omarchy.js");
|
||||
assert.equal(srcs[0], "compat.js", "loaded first: " + srcs.join(", "));
|
||||
// webfonts.js is imported by app.js in a browser tab only, cfgblocked.js
|
||||
// when magpie can't write its folder; the checks above still read them
|
||||
for (const f of await scripts()) if (f !== "webfonts.js" && f !== "cfgblocked.js") assert(all.includes(f), f + " is not loaded by index.html");
|
||||
// when magpie can't write its folder, signsheets.js when a sign-in asks a
|
||||
// value first; the checks above still read them
|
||||
for (const f of await scripts()) if (!["webfonts.js", "cfgblocked.js", "signsheets.js"].includes(f)) assert(all.includes(f), f + " is not loaded by index.html");
|
||||
});
|
||||
|
||||
test("the styles hold up in Safari 15.0", async () => {
|
||||
|
||||
Reference in New Issue
Block a user