diff --git a/internal/gui/assets/app.css b/internal/gui/assets/app.css index c93f1c9cc..5ae47f41f 100644 --- a/internal/gui/assets/app.css +++ b/internal/gui/assets/app.css @@ -3311,6 +3311,7 @@ body.window .ag-sk-icon { width: 22px; height: 22px; border-radius: 6px; } /* the sign-in link, one line, selected whole with a click */ .signing .signlink { display: flex; align-items: center; gap: 4px; margin: 5px 0 1px; min-width: 0; } .signing .signlink code { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: var(--code-style, normal) var(--code-weight, 400) 11px/1.3 var(--code-font, var(--code)); font-stretch: var(--code-stretch, 100%); color: var(--fg-2); padding: 4px 7px; border: 1px solid var(--line); border-radius: 6px; background: var(--card); user-select: all; -webkit-user-select: all; cursor: text; } +.signing .signlink > button.link { flex: none; white-space: nowrap; } .signing .callback-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 6px; } .signing .callback-form input { flex: 1; min-width: 120px; width: 100%; height: 28px; padding: 0 8px; border: 1px solid var(--line); border-radius: 7px; background: var(--card); color: var(--fg); font-size: 12px; } /* the field's button: as tall as the field, with the same corners */ diff --git a/internal/gui/assets/app.js b/internal/gui/assets/app.js index 0e3c9f411..e16b9f16c 100644 --- a/internal/gui/assets/app.js +++ b/internal/gui/assets/app.js @@ -13126,10 +13126,8 @@ function renderSigning(sub) { u.title = t("Open it in another browser or profile: copy it there"); const cp = copyBtn(signing.url, t("Sign-in link")); cp.title = t("Copy link"); - link.append(u, cp); - tt.append(link); const acts = el("span", "acts"); - const open = el("button", "link", signing.linkOnly && !signing.opened ? t("Open") : t("Open again")); + const open = el("button", "link", signing.linkOnly && !signing.opened ? t("Open in browser") : t("Open again")); // one that fails says why, where "magpie opened the sign-in page" was (#2043) // a poll may have put a fresh copy of the same sign-in in its place const flow = signing; @@ -13139,7 +13137,10 @@ function renderSigning(sub) { }, (e) => { if (same()) { signing = { ...signing, openError: e.message }; renderProviders(); } }); - acts.append(open); + // Copy link, then Open to its right: a sign-in kept to its link is + // copied into a private window or another profile, or opened here + link.append(u, cp, open); + tt.append(link); const ghe = copilotHostSwitch(sub); if (ghe) acts.append(ghe); acts.append(signInProxyLink(sub)); diff --git a/internal/gui/assets/i18n.js b/internal/gui/assets/i18n.js index 3fea31ac9..2e37dfa70 100644 --- a/internal/gui/assets/i18n.js +++ b/internal/gui/assets/i18n.js @@ -2312,6 +2312,7 @@ const I18N = { "Installing {cli}…": "正在安装 {cli}…", "{name} is used through its own CLI, which isn't on this computer yet. magpie is installing it with the official installer; the sign-in page opens as soon as it's done.": "{name} 需通过自身 CLI 使用,本机尚未安装。正在用官方安装脚本安装,完成后立即打开登录页。", "magpie opened the sign-in page. The account shows up here as soon as you're done.": "已打开登录页,完成后账号会出现在这里。", + "Open in browser": "在浏览器中打开", "Open again": "重新打开", "Sign-in pages": "登录页", "Open sign-in pages in the browser": "在浏览器中打开登录页", @@ -7440,6 +7441,7 @@ const I18N = { "Installing {cli}…": "正在安裝 {cli}…", "{name} is used through its own CLI, which isn't on this computer yet. magpie is installing it with the official installer; the sign-in page opens as soon as it's done.": "{name} 需透過自身 CLI 使用,本機尚未安裝。正在用官方安裝指令碼安裝,完成後立即開啟登入頁。", "magpie opened the sign-in page. The account shows up here as soon as you're done.": "已開啟登入頁,完成後帳號會出現在這裡。", + "Open in browser": "在瀏覽器中開啟", "Open again": "重新開啟", "Sign-in pages": "登入頁", "Open sign-in pages in the browser": "在瀏覽器中開啟登入頁", @@ -12544,6 +12546,7 @@ const I18N = { "Installing {cli}…": "{cli} をインストール中…", "{name} is used through its own CLI, which isn't on this computer yet. magpie is installing it with the official installer; the sign-in page opens as soon as it's done.": "{name} は専用の CLI を通じて使いますが、このコンピュータにはまだありません。magpie が公式インストーラでインストールしています。完了するとすぐにサインインページが開きます。", "magpie opened the sign-in page. The account shows up here as soon as you're done.": "magpie がサインインページを開きました。完了するとすぐにアカウントがここに表示されます。", + "Open in browser": "ブラウザで開く", "Open again": "もう一度開く", "Sign-in pages": "サインインページ", "Open sign-in pages in the browser": "サインインページをブラウザで開く", @@ -17679,6 +17682,7 @@ const I18N = { "Installing {cli}…": "{cli} wird installiert…", "{name} is used through its own CLI, which isn't on this computer yet. magpie is installing it with the official installer; the sign-in page opens as soon as it's done.": "{name} wird über seine eigene CLI verwendet, die auf diesem Computer noch fehlt. magpie installiert sie mit dem offiziellen Installer; die Anmeldeseite öffnet sich, sobald das erledigt ist.", "magpie opened the sign-in page. The account shows up here as soon as you're done.": "magpie hat die Anmeldeseite geöffnet. Das Konto erscheint hier, sobald Sie fertig sind.", + "Open in browser": "Im Browser öffnen", "Open again": "Erneut öffnen", "Sign-in pages": "Anmeldeseiten", "Open sign-in pages in the browser": "Anmeldeseiten im Browser öffnen", diff --git a/internal/gui/tests/signin-close.test.cjs b/internal/gui/tests/signin-close.test.cjs index ba7f2e4b1..a73b9434a 100644 --- a/internal/gui/tests/signin-close.test.cjs +++ b/internal/gui/tests/signin-close.test.cjs @@ -115,10 +115,10 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", }); }); assert(fit.every((f) => f.inside), JSON.stringify(fit)); - // one button puts it away: Open again stands alone, no Close (beside - // it only the proxy the sign-in goes through, #1663) - const acts = box.locator(".acts"); - assert.deepEqual(await acts.locator("button:not(.via)").allTextContents(), [w.again]); + // Open again sits to the right of Copy, no Close (the proxy the + // sign-in goes through, #1663, is below) + assert.deepEqual(await box.locator(".signlink button.link").allTextContents(), [w.again]); + assert.deepEqual(await box.locator(".acts button:not(.via)").allTextContents(), []); assert.equal(await box.getByRole("button", { name: w.close, exact: true }).count(), 0, "no Close beside Cancel"); const cancel = box.locator(":scope > button", { hasText: w.cancel }); assert.equal(await cancel.count(), 1); @@ -166,8 +166,8 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", const missing = await page.evaluate(() => ["Stop waiting for this sign-in"].filter((k) => !I18N.zh[k])); assert.deepEqual(missing, []); - // a Windows window tints its title bar to the page (6927bedfc), which changes nothing - assert.deepEqual(ctl.other.filter((o) => o.startsWith("POST") && !o.includes("/api/open") && !o.includes("/api/window/titlebar")), [], "nothing else was changed"); + // a Windows window tints its title bar to the page (6927bedfc), which changes nothing; so does the "in use" ping a click sends (10c4dc109) + assert.deepEqual(ctl.other.filter((o) => o.startsWith("POST") && !o.includes("/api/open") && !o.includes("/api/window/titlebar") && !o.includes("/api/update/using")), [], "nothing else was changed"); assert.deepEqual(errors, []); }); } diff --git a/internal/gui/tests/signin-link-only.test.cjs b/internal/gui/tests/signin-link-only.test.cjs index 17496d68a..d1f2ff742 100644 --- a/internal/gui/tests/signin-link-only.test.cjs +++ b/internal/gui/tests/signin-link-only.test.cjs @@ -20,11 +20,11 @@ const assets = path.resolve(__dirname, "../assets"); const LINK = "https://accounts.example/o/oauth2/auth?client_id=x&redirect_uri=http%3A%2F%2F127.0.0.1%3A51234%2Fcallback&state=" + "s".repeat(80); const W = { - en: { settings: "Settings", head: "Sign-in pages", name: "Open sign-in pages in the browser", anyway: "Sign in anyway", said: "magpie didn't open the sign-in page", open: "Open", again: "Open again", copy: "Copy link" }, - zh: { settings: "设置", head: "登录页", name: "在浏览器中打开登录页", anyway: "仍然登录", said: "magpie 按设置没有打开登录页", open: "打开", again: "重新打开", copy: "复制链接" }, - "zh-TW": { settings: "設定", head: "登入頁", name: "在瀏覽器中開啟登入頁", anyway: "仍然登入", said: "magpie 依設定沒有開啟登入頁", open: "開啟", again: "重新開啟", copy: "複製連結" }, - ja: { settings: "設定", head: "サインインページ", name: "サインインページをブラウザで開く", anyway: "それでもサインイン", said: "設定に従い、magpie はサインインページを開いていません", open: "開く", again: "もう一度開く", copy: "リンクをコピー" }, - de: { settings: "Einstellungen", head: "Anmeldeseiten", name: "Anmeldeseiten im Browser öffnen", anyway: "Trotzdem anmelden", said: "magpie hat die Anmeldeseite wie in den Einstellungen festgelegt nicht geöffnet", open: "Öffnen", again: "Erneut öffnen", copy: "Link kopieren" }, + en: { settings: "Settings", head: "Sign-in pages", name: "Open sign-in pages in the browser", anyway: "Sign in anyway", said: "magpie didn't open the sign-in page", open: "Open in browser", again: "Open again", copy: "Copy link" }, + zh: { settings: "设置", head: "登录页", name: "在浏览器中打开登录页", anyway: "仍然登录", said: "magpie 按设置没有打开登录页", open: "在浏览器中打开", again: "重新打开", copy: "复制链接" }, + "zh-TW": { settings: "設定", head: "登入頁", name: "在瀏覽器中開啟登入頁", anyway: "仍然登入", said: "magpie 依設定沒有開啟登入頁", open: "在瀏覽器中開啟", again: "重新開啟", copy: "複製連結" }, + ja: { settings: "設定", head: "サインインページ", name: "サインインページをブラウザで開く", anyway: "それでもサインイン", said: "設定に従い、magpie はサインインページを開いていません", open: "ブラウザで開く", again: "もう一度開く", copy: "リンクをコピー" }, + de: { settings: "Einstellungen", head: "Anmeldeseiten", name: "Anmeldeseiten im Browser öffnen", anyway: "Trotzdem anmelden", said: "magpie hat die Anmeldeseite wie in den Einstellungen festgelegt nicht geöffnet", open: "Im Browser öffnen", again: "Erneut öffnen", copy: "Link kopieren" }, }; function settingsPayload(lang, over) { @@ -134,8 +134,11 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", if (linkOnly) { assert.deepEqual(opened, [], "no page opened"); assert(said.startsWith(w.said), said); - assert.equal(await box.locator(".acts button", { hasText: new RegExp("^" + w.open + "$") }).count(), 1, "Open"); - assert.equal(await box.locator(".acts button", { hasText: w.again }).count(), 0, "not Open again"); + assert.equal(await box.locator(".signlink button", { hasText: new RegExp("^" + w.open + "$") }).count(), 1, "Open in browser, beside the link"); + // Copy first, Open in browser to its right + const at = await box.locator(".signlink").evaluate((r) => [...r.children].map((c) => c.tagName + "." + c.className)); + assert.deepEqual(at, ["CODE.", "BUTTON.copy", "BUTTON.link"], "link, Copy, Open in browser"); + assert.equal(await box.locator("button", { hasText: w.again }).count(), 0, "not Open again"); // "as set in Settings" leads to the setting const go = box.locator(".tt > .s button"); assert.equal((await go.textContent()).trim(), w.settings + " ›"); @@ -145,7 +148,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", assert.deepEqual(opened, [LINK], "the page opened once"); assert(!said.startsWith(w.said), said); assert.equal(await box.locator(".tt > .s button").count(), 0, "nothing to lead to"); - assert.equal(await box.locator(".acts button", { hasText: w.again }).count(), 1, "Open again"); + assert.equal(await box.locator(".signlink button", { hasText: w.again }).count(), 1, "Open again, beside Copy"); } assert.deepEqual(errors, []); await context.close();