@gruu6y/page-clean-login 0.2.10 → 0.2.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/ui/app.js CHANGED
@@ -60,7 +60,9 @@ import {
60
60
  } from "./account-state.js";
61
61
  import {
62
62
  EXPIRING_SOON_MS,
63
+ accountBrowserPath,
63
64
  accountView,
65
+ browserStateSummary,
64
66
  countAccountsByProxy,
65
67
  filterAccounts,
66
68
  formatCheckSummary,
@@ -69,6 +71,7 @@ import {
69
71
  hostingStateLabel,
70
72
  hostingTone,
71
73
  isHostingPaused,
74
+ normalizeAccountBrowser,
72
75
  normalizeHosting,
73
76
  sortAccounts,
74
77
  } from "./account-view.js";
@@ -692,6 +695,32 @@ const messages = {
692
695
  accountDetailMethod: "Sign-in method",
693
696
  accountDetailExpiresAt: "Token expires",
694
697
  signInEgressWarning: "Warning: {detail}",
698
+ accountBrowserOpen: "Open browser",
699
+ accountBrowserClose: "Close browser",
700
+ accountBrowserOpening: "Opening…",
701
+ accountBrowserClosing: "Closing…",
702
+ accountBrowserOpenTitle: "Open this account's fingerprint browser with its current exit.",
703
+ accountBrowserCloseTitle: "Close this account's open fingerprint browser.",
704
+ accountBrowserNoFingerprintTitle: "This account has no pinned fingerprint yet. Sign in through Clean Login once first.",
705
+ accountBrowserStatusOpen: "Browser open · {exit}",
706
+ accountBrowserClosed: "Fingerprint browser: closed",
707
+ accountBrowserExitChanged: "Exit changed; close and reopen the browser to apply.",
708
+ toastBrowserOpened: "Fingerprint browser opened.",
709
+ toastBrowserClosed: "Fingerprint browser closed.",
710
+ browserErrorIdentityMissing: "This account has no pinned fingerprint yet. Sign in through Clean Login once first.",
711
+ browserErrorExecutableMissing: "The isolated browser is not prepared yet. Prepare the login browser first.",
712
+ browserErrorAlreadyOpen: "This account's fingerprint browser is already open.",
713
+ errorAccountBrowserOpen: "Close this account's fingerprint browser before continuing.",
714
+ browserErrorSignInRunning: "A sign-in flow is currently running for this account. Finish or cancel it first.",
715
+ browserErrorRenewalRunning: "Hosted renewal is currently running for this account. Wait for it to finish.",
716
+ browserErrorProvidersInvalid: "magpie's providers.json is invalid, so this account's exit could not be resolved.",
717
+ browserErrorProvidersUnreadable: "Could not read magpie's providers.json to resolve this account's exit.",
718
+ browserErrorInvalidExitUrl: "This account's configured exit URL is invalid. Fix the exit in account details first.",
719
+ browserErrorExitMissing: "This account's configured exit is no longer in the proxy list. Choose another exit in account details.",
720
+ browserErrorExitUnknown: "Could not determine which exit this account should use. Check its exit setting in account details.",
721
+ browserErrorLaunchFailed: "The fingerprint browser failed to start. The browser directory may be busy or damaged.",
722
+ browserErrorLaunchTimeout: "The fingerprint browser took too long to start.",
723
+ browserErrorInvalidUrl: "The requested page address is not allowed.",
695
724
  },
696
725
  "zh-Hans": {
697
726
  title: "干净登录",
@@ -1278,6 +1307,32 @@ const messages = {
1278
1307
  accountDetailMethod: "登录方式",
1279
1308
  accountDetailExpiresAt: "凭证过期时间",
1280
1309
  signInEgressWarning: "提示:{detail}",
1310
+ accountBrowserOpen: "打开浏览器",
1311
+ accountBrowserClose: "关闭浏览器",
1312
+ accountBrowserOpening: "打开中…",
1313
+ accountBrowserClosing: "关闭中…",
1314
+ accountBrowserOpenTitle: "用这个账号的固定指纹和当前出口打开隔离浏览器。",
1315
+ accountBrowserCloseTitle: "关闭这个账号已打开的指纹浏览器。",
1316
+ accountBrowserNoFingerprintTitle: "这个账号还没有固定指纹,请先通过干净登录登录一次。",
1317
+ accountBrowserStatusOpen: "浏览器已打开 · {exit}",
1318
+ accountBrowserClosed: "指纹浏览器:未打开",
1319
+ accountBrowserExitChanged: "出口已变更,关闭并重新打开浏览器后生效。",
1320
+ toastBrowserOpened: "已打开指纹浏览器。",
1321
+ toastBrowserClosed: "已关闭指纹浏览器。",
1322
+ browserErrorIdentityMissing: "这个账号还没有固定指纹,请先通过干净登录登录一次。",
1323
+ browserErrorExecutableMissing: "隔离浏览器尚未准备好,请先准备登录浏览器。",
1324
+ browserErrorAlreadyOpen: "这个账号的指纹浏览器已经打开了。",
1325
+ errorAccountBrowserOpen: "请先关闭这个账号的指纹浏览器后再操作。",
1326
+ browserErrorSignInRunning: "这个账号正在进行登录流程,请先完成或取消登录。",
1327
+ browserErrorRenewalRunning: "这个账号正在执行托管续期,请等待续期完成。",
1328
+ browserErrorProvidersInvalid: "magpie 的 providers.json 格式无效,无法解析这个账号的出口。",
1329
+ browserErrorProvidersUnreadable: "无法读取 magpie 的 providers.json,暂时不能解析这个账号的出口。",
1330
+ browserErrorInvalidExitUrl: "这个账号配置的出口地址无效,请先在账号详情里修正出口。",
1331
+ browserErrorExitMissing: "这个账号绑定的出口已不在代理列表里,请先在账号详情里重新选择出口。",
1332
+ browserErrorExitUnknown: "无法确定这个账号应使用的出口,请在账号详情里检查出口设置。",
1333
+ browserErrorLaunchFailed: "指纹浏览器启动失败,可能是安装目录被占用或文件缺失。",
1334
+ browserErrorLaunchTimeout: "指纹浏览器启动超时。",
1335
+ browserErrorInvalidUrl: "不允许打开这个页面地址。",
1281
1336
  },
1282
1337
  "zh-Hant": {
1283
1338
  title: "乾淨登入",
@@ -1864,6 +1919,32 @@ const messages = {
1864
1919
  accountDetailMethod: "登入方式",
1865
1920
  accountDetailExpiresAt: "憑證過期時間",
1866
1921
  signInEgressWarning: "提示:{detail}",
1922
+ accountBrowserOpen: "開啟瀏覽器",
1923
+ accountBrowserClose: "關閉瀏覽器",
1924
+ accountBrowserOpening: "開啟中…",
1925
+ accountBrowserClosing: "關閉中…",
1926
+ accountBrowserOpenTitle: "用這個帳號的固定指紋和目前出口開啟隔離瀏覽器。",
1927
+ accountBrowserCloseTitle: "關閉這個帳號已開啟的指紋瀏覽器。",
1928
+ accountBrowserNoFingerprintTitle: "這個帳號還沒有固定指紋,請先透過乾淨登入登入一次。",
1929
+ accountBrowserStatusOpen: "瀏覽器已開啟 · {exit}",
1930
+ accountBrowserClosed: "指紋瀏覽器:未開啟",
1931
+ accountBrowserExitChanged: "出口已變更,關閉並重新開啟瀏覽器後生效。",
1932
+ toastBrowserOpened: "已開啟指紋瀏覽器。",
1933
+ toastBrowserClosed: "已關閉指紋瀏覽器。",
1934
+ browserErrorIdentityMissing: "這個帳號還沒有固定指紋,請先透過乾淨登入登入一次。",
1935
+ browserErrorExecutableMissing: "隔離瀏覽器尚未準備好,請先準備登入瀏覽器。",
1936
+ browserErrorAlreadyOpen: "這個帳號的指紋瀏覽器已經開啟了。",
1937
+ errorAccountBrowserOpen: "請先關閉這個帳號的指紋瀏覽器後再操作。",
1938
+ browserErrorSignInRunning: "這個帳號正在進行登入流程,請先完成或取消登入。",
1939
+ browserErrorRenewalRunning: "這個帳號正在執行託管續期,請等待續期完成。",
1940
+ browserErrorProvidersInvalid: "magpie 的 providers.json 格式無效,無法解析這個帳號的出口。",
1941
+ browserErrorProvidersUnreadable: "無法讀取 magpie 的 providers.json,暫時不能解析這個帳號的出口。",
1942
+ browserErrorInvalidExitUrl: "這個帳號設定的出口網址無效,請先在帳號詳情裡修正出口。",
1943
+ browserErrorExitMissing: "這個帳號綁定的出口已不在代理清單裡,請先在帳號詳情裡重新選擇出口。",
1944
+ browserErrorExitUnknown: "無法確定這個帳號應使用的出口,請在帳號詳情裡檢查出口設定。",
1945
+ browserErrorLaunchFailed: "指紋瀏覽器啟動失敗,可能是安裝目錄被佔用或檔案缺失。",
1946
+ browserErrorLaunchTimeout: "指紋瀏覽器啟動逾時。",
1947
+ browserErrorInvalidUrl: "不允許開啟這個頁面位址。",
1867
1948
  },
1868
1949
  ja: {
1869
1950
  title: "クリーンログイン",
@@ -2450,6 +2531,32 @@ const messages = {
2450
2531
  accountDetailMethod: "ログイン方式",
2451
2532
  accountDetailExpiresAt: "有効期限",
2452
2533
  signInEgressWarning: "注意:{detail}",
2534
+ accountBrowserOpen: "ブラウザーを開く",
2535
+ accountBrowserClose: "ブラウザーを閉じる",
2536
+ accountBrowserOpening: "起動中…",
2537
+ accountBrowserClosing: "終了中…",
2538
+ accountBrowserOpenTitle: "このアカウントの固定フィンガープリントと現在の出口で分離ブラウザーを開きます。",
2539
+ accountBrowserCloseTitle: "このアカウントで開いているフィンガープリントブラウザーを閉じます。",
2540
+ accountBrowserNoFingerprintTitle: "このアカウントには固定フィンガープリントがまだありません。先にクリーンログインで一度ログインしてください。",
2541
+ accountBrowserStatusOpen: "ブラウザー起動中 · {exit}",
2542
+ accountBrowserClosed: "フィンガープリントブラウザー:閉じています",
2543
+ accountBrowserExitChanged: "出口が変更されました。反映するにはブラウザーを閉じて開き直してください。",
2544
+ toastBrowserOpened: "フィンガープリントブラウザーを開きました。",
2545
+ toastBrowserClosed: "フィンガープリントブラウザーを閉じました。",
2546
+ browserErrorIdentityMissing: "このアカウントには固定フィンガープリントがまだありません。先にクリーンログインで一度ログインしてください。",
2547
+ browserErrorExecutableMissing: "分離ブラウザーがまだ準備されていません。先にログイン用ブラウザーを準備してください。",
2548
+ browserErrorAlreadyOpen: "このアカウントのフィンガープリントブラウザーはすでに開いています。",
2549
+ errorAccountBrowserOpen: "続行する前に、このアカウントのフィンガープリントブラウザーを閉じてください。",
2550
+ browserErrorSignInRunning: "このアカウントのログイン処理が進行中です。先に完了するか中止してください。",
2551
+ browserErrorRenewalRunning: "このアカウントの自動更新が実行中です。完了するまでお待ちください。",
2552
+ browserErrorProvidersInvalid: "magpie の providers.json が不正なため、このアカウントの出口を解決できませんでした。",
2553
+ browserErrorProvidersUnreadable: "magpie の providers.json を読み取れず、このアカウントの出口を解決できませんでした。",
2554
+ browserErrorInvalidExitUrl: "このアカウントに設定されている出口 URL が無効です。先にアカウント詳細で出口を修正してください。",
2555
+ browserErrorExitMissing: "このアカウントに設定された出口はプロキシ一覧に見つかりません。アカウント詳細で別の出口を選んでください。",
2556
+ browserErrorExitUnknown: "このアカウントが使用する出口を特定できませんでした。アカウント詳細で出口設定を確認してください。",
2557
+ browserErrorLaunchFailed: "フィンガープリントブラウザーを起動できませんでした。インストール先が使用中か、ファイルが不足している可能性があります。",
2558
+ browserErrorLaunchTimeout: "フィンガープリントブラウザーの起動がタイムアウトしました。",
2559
+ browserErrorInvalidUrl: "指定されたページアドレスは許可されていません。",
2453
2560
  },
2454
2561
  };
2455
2562
 
@@ -2631,6 +2738,11 @@ let detailExitController = null;
2631
2738
  // is static markup, so without this a value left by the previous dialog would
2632
2739
  // look like a fresh user choice when the next account opens.
2633
2740
  let detailExitRenderedFor = null;
2741
+ // Per-account pending browser action ("opening" | "closing") keyed by
2742
+ // `${provider}\u0000${key}` so concurrent opens/closes on different accounts
2743
+ // stay independent while preventing double clicks on the same account.
2744
+ const accountBrowserBusy = new Map();
2745
+ const detailBrowserGuard = createRequestGuard();
2634
2746
  // The hosting dialog polls only while it is open, and only for the one account
2635
2747
  // it was opened for. Nothing polls on the user's behalf in the background.
2636
2748
  let accountHostingContext = null;
@@ -2643,6 +2755,7 @@ const NOTE_MAX_LENGTH = 200;
2643
2755
 
2644
2756
  const errorKeys = {
2645
2757
  signed_in: "errorAccountSignedIn",
2758
+ browser_open: "errorAccountBrowserOpen",
2646
2759
  auth_unreadable: "errorAccountAuthUnreadable",
2647
2760
  retired_missing: "errorAccountRetiredMissing",
2648
2761
  identity_mismatch: "errorAccountMismatch",
@@ -2697,6 +2810,7 @@ function apiErrorText(error) {
2697
2810
  const accountErrorKeys = {
2698
2811
  not_found: "errorAccountNotFound",
2699
2812
  signed_in: "errorAccountSignedIn",
2813
+ browser_open: "errorAccountBrowserOpen",
2700
2814
  auth_unreadable: "errorAccountAuthUnreadable",
2701
2815
  invalid_account: "errorAccountInvalid",
2702
2816
  retired_missing: "errorAccountRetiredMissing",
@@ -2707,6 +2821,30 @@ function accountErrorText(error) {
2707
2821
  return text[accountErrorKeys[error?.code]] || serverErrorText(error);
2708
2822
  }
2709
2823
 
2824
+ const accountBrowserErrorKeys = {
2825
+ not_found: "errorAccountNotFound",
2826
+ identity_missing: "browserErrorIdentityMissing",
2827
+ executable_missing: "browserErrorExecutableMissing",
2828
+ browser_missing: "browserErrorExecutableMissing",
2829
+ runtime_missing: "browserErrorExecutableMissing",
2830
+ browser_already_open: "browserErrorAlreadyOpen",
2831
+ browser_open: "errorAccountBrowserOpen",
2832
+ signin_running: "browserErrorSignInRunning",
2833
+ renewal_running: "browserErrorRenewalRunning",
2834
+ providers_invalid: "browserErrorProvidersInvalid",
2835
+ providers_unreadable: "browserErrorProvidersUnreadable",
2836
+ invalid_exit_url: "browserErrorInvalidExitUrl",
2837
+ exit_missing: "browserErrorExitMissing",
2838
+ exit_unknown: "browserErrorExitUnknown",
2839
+ launch_failed: "browserErrorLaunchFailed",
2840
+ launch_timeout: "browserErrorLaunchTimeout",
2841
+ invalid_url: "browserErrorInvalidUrl",
2842
+ };
2843
+
2844
+ function accountBrowserErrorText(error) {
2845
+ return text[accountBrowserErrorKeys[error?.code]] || serverErrorText(error);
2846
+ }
2847
+
2710
2848
  // The asset routes report their own codes. `not_found` means an asset row, not
2711
2849
  // an account, so it gets its own wording instead of the shared proxy text.
2712
2850
  const assetErrorKeys = {
@@ -2912,6 +3050,7 @@ function applyText() {
2912
3050
  byId("account-detail-note-hint").textContent = text.accountDetailNoteHint;
2913
3051
  byId("account-detail-history-title").textContent = text.accountDetailHistoryTitle;
2914
3052
  byId("account-detail-dismiss").textContent = text.accountDetailDismiss;
3053
+ byId("account-detail-browser").textContent = text.accountBrowserOpen;
2915
3054
  byId("account-detail-check").textContent = text.accountCheckStart;
2916
3055
  byId("account-detail-note-save").textContent = text.accountDetailNoteSave;
2917
3056
  byId("account-detail-exit-label").textContent = text.accountDetailExitLabel;
@@ -4506,6 +4645,13 @@ async function loadAccountIdentities() {
4506
4645
  } catch (error) {
4507
4646
  accountIdentitiesError = serverErrorText(error);
4508
4647
  } finally {
4648
+ if (accountDetailContext) {
4649
+ const updated = findAccountRecord(accountDetailContext.provider, accountDetailContext.key);
4650
+ if (updated) {
4651
+ accountDetailContext.account = updated;
4652
+ renderDetailBrowser();
4653
+ }
4654
+ }
4509
4655
  renderAccounts();
4510
4656
  // The counts order the main list, so the cards are laid out again once the
4511
4657
  // identities arrive. The split does not depend on them: no card moves
@@ -6688,6 +6834,19 @@ function accountRow(account) {
6688
6834
  expiryNode.textContent = expiry.label;
6689
6835
  statusCell.append(expiryNode);
6690
6836
  }
6837
+ const browserSummary = browserStateSummary(view.browser, accountBrowserLabels());
6838
+ if (browserSummary.open) {
6839
+ const browserLine = document.createElement("small");
6840
+ browserLine.className = `account-browser-line is-${browserSummary.tone}`;
6841
+ browserLine.textContent = browserSummary.statusText;
6842
+ statusCell.append(browserLine);
6843
+ if (browserSummary.noticeText) {
6844
+ const browserNotice = document.createElement("small");
6845
+ browserNotice.className = "account-browser-notice";
6846
+ browserNotice.textContent = browserSummary.noticeText;
6847
+ statusCell.append(browserNotice);
6848
+ }
6849
+ }
6691
6850
 
6692
6851
  const actions = accountCell("proxy-actions account-cell-actions", text.accountColActions);
6693
6852
  const busy = Boolean(accountCheckContext?.active);
@@ -6711,6 +6870,27 @@ function accountRow(account) {
6711
6870
  rotate.title = text.accountRotateTitle;
6712
6871
  actions.append(rotate);
6713
6872
  }
6873
+ const browserPending = accountBrowserPendingState(view.provider, view.key);
6874
+ const browserOpen = view.browser.open;
6875
+ const hasFingerprint = Boolean(view.fingerprint.id);
6876
+ const browserLabel =
6877
+ browserPending === "opening" ? text.accountBrowserOpening
6878
+ : browserPending === "closing" ? text.accountBrowserClosing
6879
+ : browserOpen ? text.accountBrowserClose
6880
+ : text.accountBrowserOpen;
6881
+ const browserButton = miniButton(browserLabel, () => {
6882
+ void toggleAccountBrowser(account);
6883
+ });
6884
+ browserButton.dataset.accountBrowserAction = browserOpen ? "close" : "open";
6885
+ if (browserOpen) browserButton.classList.add("is-active");
6886
+ browserButton.disabled = Boolean(browserPending) || (!browserOpen && !hasFingerprint);
6887
+ browserButton.title =
6888
+ browserPending === "opening" ? text.accountBrowserOpening
6889
+ : browserPending === "closing" ? text.accountBrowserClosing
6890
+ : !browserOpen && !hasFingerprint ? text.accountBrowserNoFingerprintTitle
6891
+ : browserOpen ? text.accountBrowserCloseTitle
6892
+ : text.accountBrowserOpenTitle;
6893
+ actions.append(browserButton);
6714
6894
  const checkButton = miniButton(text.accountCheck, () => openAccountCheck(account));
6715
6895
  checkButton.disabled = busy;
6716
6896
  if (busy) checkButton.title = text.accountCheckBusy;
@@ -7347,6 +7527,219 @@ async function loadAccountExit(context) {
7347
7527
  }
7348
7528
  }
7349
7529
 
7530
+ // --- account browser controls ---------------------------------------------
7531
+
7532
+ function accountBrowserKey(provider, key) {
7533
+ return `${String(provider ?? "")}\u0000${String(key ?? "")}`;
7534
+ }
7535
+
7536
+ function accountBrowserPendingState(provider, key) {
7537
+ return accountBrowserBusy.get(accountBrowserKey(provider, key)) || "";
7538
+ }
7539
+
7540
+ function accountBrowserLabels() {
7541
+ return {
7542
+ direct: text.accountExitDirect,
7543
+ custom: text.accountExitCustom,
7544
+ inherit: text.accountDetailExitInherit,
7545
+ openWithExit: text.accountBrowserStatusOpen,
7546
+ closed: text.accountBrowserClosed,
7547
+ exitChanged: text.accountBrowserExitChanged,
7548
+ };
7549
+ }
7550
+
7551
+ function findAccountRecord(provider, key) {
7552
+ return accountIdentities.find(
7553
+ (item) => item?.provider === provider && item?.key === key,
7554
+ ) || null;
7555
+ }
7556
+
7557
+ function isAccountDetailFor(provider, key) {
7558
+ return Boolean(
7559
+ accountDetailContext &&
7560
+ accountDetailContext.provider === provider &&
7561
+ accountDetailContext.key === key,
7562
+ );
7563
+ }
7564
+
7565
+ function updateAccountBrowserRecord(provider, key, browser) {
7566
+ const normalized = normalizeAccountBrowser(browser);
7567
+ const index = accountIdentities.findIndex(
7568
+ (item) => item?.provider === provider && item?.key === key,
7569
+ );
7570
+ if (index >= 0) {
7571
+ accountIdentities[index] = { ...accountIdentities[index], browser: normalized };
7572
+ }
7573
+ if (isAccountDetailFor(provider, key)) {
7574
+ accountDetailContext.account = {
7575
+ ...(accountDetailContext.account || {}),
7576
+ browser: normalized,
7577
+ };
7578
+ }
7579
+ }
7580
+
7581
+ async function refreshAccountBrowserState(provider, key) {
7582
+ const busyKey = accountBrowserKey(provider, key);
7583
+ if (accountBrowserBusy.has(busyKey)) return;
7584
+ try {
7585
+ const data = await api(accountBrowserPath(provider, key));
7586
+ if (accountBrowserBusy.has(busyKey)) return;
7587
+ if (data?.browser) {
7588
+ updateAccountBrowserRecord(provider, key, data.browser);
7589
+ if (isAccountDetailFor(provider, key)) renderDetailBrowser();
7590
+ renderAccounts();
7591
+ }
7592
+ } catch {
7593
+ // Keep the current display if the background status check fails.
7594
+ }
7595
+ }
7596
+
7597
+ async function toggleAccountBrowser(account, { fromDetail = false } = {}) {
7598
+ const latest = findAccountRecord(account?.provider, account?.key) || account;
7599
+ const view = accountDisplay(latest);
7600
+ const provider = view.provider;
7601
+ const key = view.key;
7602
+ if (!provider || !key) return;
7603
+ const busyKey = accountBrowserKey(provider, key);
7604
+ if (accountBrowserBusy.has(busyKey)) return;
7605
+ const closing = view.browser.open;
7606
+ if (!closing && !view.fingerprint.id) {
7607
+ const message = text.browserErrorIdentityMissing;
7608
+ if (fromDetail && isAccountDetailFor(provider, key)) setDetailError(message);
7609
+ else accountIdentitiesError = message;
7610
+ toast(message);
7611
+ renderAccounts();
7612
+ return;
7613
+ }
7614
+ accountBrowserBusy.set(busyKey, closing ? "closing" : "opening");
7615
+ if (isAccountDetailFor(provider, key)) {
7616
+ detailBrowserGuard.cancel();
7617
+ setDetailError("");
7618
+ renderDetailBrowser();
7619
+ }
7620
+ if (!fromDetail) {
7621
+ accountIdentitiesError = "";
7622
+ accountsNotice = "";
7623
+ }
7624
+ renderAccounts();
7625
+ let syncOpenAfter = false;
7626
+ try {
7627
+ if (closing) {
7628
+ const data = await api(accountBrowserPath(provider, key), { method: "DELETE" });
7629
+ updateAccountBrowserRecord(
7630
+ provider,
7631
+ key,
7632
+ data?.browser ?? { open: false, openedAt: null, exit: null, exitChanged: false },
7633
+ );
7634
+ toast(text.toastBrowserClosed);
7635
+ } else {
7636
+ const data = await api(accountBrowserPath(provider, key), { method: "POST", body: {} });
7637
+ updateAccountBrowserRecord(
7638
+ provider,
7639
+ key,
7640
+ data?.browser ?? { open: true, openedAt: null, exit: null, exitChanged: false },
7641
+ );
7642
+ toast(text.toastBrowserOpened);
7643
+ }
7644
+ } catch (error) {
7645
+ const message = accountBrowserErrorText(error);
7646
+ if (fromDetail && isAccountDetailFor(provider, key)) setDetailError(message);
7647
+ else accountIdentitiesError = message;
7648
+ toast(message);
7649
+ if (error?.code === "browser_already_open") syncOpenAfter = true;
7650
+ } finally {
7651
+ accountBrowserBusy.delete(busyKey);
7652
+ if (isAccountDetailFor(provider, key)) renderDetailBrowser();
7653
+ renderAccounts();
7654
+ }
7655
+ if (syncOpenAfter) {
7656
+ void refreshAccountBrowserState(provider, key);
7657
+ }
7658
+ }
7659
+
7660
+ function renderDetailBrowser() {
7661
+ const button = byId("account-detail-browser");
7662
+ const status = byId("account-detail-browser-status");
7663
+ const notice = byId("account-detail-browser-notice");
7664
+ const context = accountDetailContext;
7665
+ if (!context) {
7666
+ button.textContent = text.accountBrowserOpen;
7667
+ button.disabled = false;
7668
+ button.title = "";
7669
+ status.textContent = "";
7670
+ status.hidden = true;
7671
+ status.className = "setup-note account-browser-status";
7672
+ notice.textContent = "";
7673
+ notice.hidden = true;
7674
+ return;
7675
+ }
7676
+ const latest = findAccountRecord(context.provider, context.key) || context.account;
7677
+ const view = accountDisplay(latest);
7678
+ const pending = accountBrowserPendingState(view.provider, view.key);
7679
+ const open = view.browser.open;
7680
+ const hasFingerprint = Boolean(view.fingerprint.id);
7681
+ const summary = browserStateSummary(view.browser, accountBrowserLabels());
7682
+
7683
+ button.textContent =
7684
+ pending === "opening" ? text.accountBrowserOpening
7685
+ : pending === "closing" ? text.accountBrowserClosing
7686
+ : open ? text.accountBrowserClose
7687
+ : text.accountBrowserOpen;
7688
+ button.disabled = Boolean(pending) || (!open && !hasFingerprint);
7689
+ button.title =
7690
+ pending === "opening" ? text.accountBrowserOpening
7691
+ : pending === "closing" ? text.accountBrowserClosing
7692
+ : !open && !hasFingerprint ? text.accountBrowserNoFingerprintTitle
7693
+ : open ? text.accountBrowserCloseTitle
7694
+ : text.accountBrowserOpenTitle;
7695
+
7696
+ if (summary.open) {
7697
+ status.textContent = summary.statusText;
7698
+ status.className = `setup-note account-browser-status is-${summary.tone}`;
7699
+ status.hidden = false;
7700
+ } else if (!hasFingerprint) {
7701
+ status.textContent = text.accountBrowserNoFingerprintTitle;
7702
+ status.className = "setup-note account-browser-status";
7703
+ status.hidden = false;
7704
+ } else {
7705
+ status.textContent = text.accountBrowserClosed;
7706
+ status.className = "setup-note account-browser-status";
7707
+ status.hidden = false;
7708
+ }
7709
+
7710
+ if (summary.open && summary.noticeText) {
7711
+ notice.textContent = summary.noticeText;
7712
+ notice.hidden = false;
7713
+ } else {
7714
+ notice.textContent = "";
7715
+ notice.hidden = true;
7716
+ }
7717
+ }
7718
+
7719
+ async function loadAccountBrowser(context) {
7720
+ const token = detailBrowserGuard.begin();
7721
+ let data;
7722
+ try {
7723
+ data = await api(accountBrowserPath(context.provider, context.key));
7724
+ } catch {
7725
+ return;
7726
+ }
7727
+ if (!detailBrowserGuard.isCurrent(token) || accountDetailContext !== context) return;
7728
+ if (accountBrowserBusy.has(accountBrowserKey(context.provider, context.key))) return;
7729
+ if (data?.browser) {
7730
+ updateAccountBrowserRecord(context.provider, context.key, data.browser);
7731
+ renderDetailBrowser();
7732
+ renderAccounts();
7733
+ }
7734
+ }
7735
+
7736
+ function toggleBrowserFromDetail() {
7737
+ const context = accountDetailContext;
7738
+ if (!context) return;
7739
+ const account = findAccountRecord(context.provider, context.key) || context.account;
7740
+ void toggleAccountBrowser(account, { fromDetail: true });
7741
+ }
7742
+
7350
7743
  function openAccountDetail(account) {
7351
7744
  const dialog = byId("account-detail-dialog");
7352
7745
  const view = accountDisplay(account);
@@ -7354,12 +7747,14 @@ function openAccountDetail(account) {
7354
7747
  byId("account-detail-title").textContent = view.name;
7355
7748
  byId("account-detail-copy").textContent = `${view.providerLabel} · ${view.key}`;
7356
7749
  renderDetailFacts(view);
7750
+ renderDetailBrowser();
7357
7751
  byId("account-detail-note").value = view.note;
7358
7752
  setDetailError("");
7359
7753
  setDetailStatus(view.signedIn ? text.accountDetailSigninHint : text.accountDetailRetiredHint);
7360
7754
  renderDetailHistory(view.checks);
7361
7755
  if (!dialog.open) dialog.showModal();
7362
7756
  void loadAccountExit(accountDetailContext);
7757
+ void loadAccountBrowser(accountDetailContext);
7363
7758
  }
7364
7759
 
7365
7760
  function closeAccountDetail() {
@@ -7369,6 +7764,7 @@ function closeAccountDetail() {
7369
7764
 
7370
7765
  function cleanupAccountDetail() {
7371
7766
  detailExitProxyGuard.cancel();
7767
+ detailBrowserGuard.cancel();
7372
7768
  if (detailExitController) {
7373
7769
  detailExitController.abort();
7374
7770
  detailExitController = null;
@@ -7382,6 +7778,7 @@ function cleanupAccountDetail() {
7382
7778
  const status = byId("account-detail-exit-status");
7383
7779
  status.textContent = "";
7384
7780
  status.hidden = true;
7781
+ renderDetailBrowser();
7385
7782
  setDetailError("");
7386
7783
  }
7387
7784
 
@@ -7406,6 +7803,7 @@ const HOSTING_REASON_KEYS = {
7406
7803
  no_browser_method: "accountHostingReasonNoBrowserMethod",
7407
7804
  method_not_found: "accountHostingReasonMethodNotFound",
7408
7805
  unavailable: "accountHostingReasonUnavailable",
7806
+ browser_open: "errorAccountBrowserOpen",
7409
7807
  };
7410
7808
 
7411
7809
  // A known reason gets the page's own wording; an unknown one still shows the
@@ -7716,12 +8114,14 @@ async function saveAccountNote() {
7716
8114
  // Only the row the service returned is applied; never a locally invented
7717
8115
  // account object. The PATCH response is the source of truth for the note.
7718
8116
  if (data?.account) {
8117
+ detailBrowserGuard.cancel();
7719
8118
  const index = accountIdentities.findIndex(
7720
8119
  (item) => item?.provider === context.provider && item?.key === context.key,
7721
8120
  );
7722
8121
  if (index >= 0) accountIdentities[index] = data.account;
7723
8122
  context.account = data.account;
7724
8123
  renderDetailFacts(accountDisplay(data.account));
8124
+ renderDetailBrowser();
7725
8125
  renderDetailHistory(accountView(data.account).checks);
7726
8126
  }
7727
8127
  setDetailStatus(text.accountDetailSaved);
@@ -7763,6 +8163,7 @@ async function saveAccountExit() {
7763
8163
  if (accountDetailContext !== context) return;
7764
8164
  accountDetailExit = data?.exit ?? accountDetailExit;
7765
8165
  if (data?.account) {
8166
+ detailBrowserGuard.cancel();
7766
8167
  const index = accountIdentities.findIndex(
7767
8168
  (item) => item?.provider === context.provider && item?.key === context.key,
7768
8169
  );
@@ -7774,6 +8175,7 @@ async function saveAccountExit() {
7774
8175
  // Redraw after the shared identity list carries the new exit: the sign-in
7775
8176
  // dialog and this picker must agree on which nodes are already assigned.
7776
8177
  renderDetailExit();
8178
+ renderDetailBrowser();
7777
8179
  if (data?.account) renderAccounts();
7778
8180
  const status = byId("account-detail-exit-status");
7779
8181
  status.textContent = text.accountDetailExitSaved;
@@ -8385,6 +8787,7 @@ document.addEventListener("keydown", (nativeEvent) => {
8385
8787
  });
8386
8788
  byId("account-detail-close").addEventListener("click", closeAccountDetail);
8387
8789
  byId("account-detail-dismiss").addEventListener("click", closeAccountDetail);
8790
+ byId("account-detail-browser").addEventListener("click", toggleBrowserFromDetail);
8388
8791
  byId("account-detail-check").addEventListener("click", openCheckFromDetail);
8389
8792
  byId("account-detail-note-save").addEventListener("click", saveAccountNote);
8390
8793
  byId("account-detail-exit-save").addEventListener("click", saveAccountExit);
package/ui/index.html CHANGED
@@ -660,6 +660,10 @@
660
660
  <p class="field-hint" id="account-detail-exit-hint"></p>
661
661
  <p class="setup-note" id="account-detail-exit-status" role="status" hidden></p>
662
662
  </div>
663
+ <div class="account-browser-box" id="account-detail-browser-box">
664
+ <p class="setup-note account-browser-status" id="account-detail-browser-status" role="status"></p>
665
+ <p class="setup-note account-browser-notice" id="account-detail-browser-notice" role="status" hidden></p>
666
+ </div>
663
667
  <div class="field account-note-field">
664
668
  <label for="account-detail-note" id="account-detail-note-label">Note</label>
665
669
  <textarea id="account-detail-note" rows="3" maxlength="200"
@@ -673,6 +677,7 @@
673
677
  </div>
674
678
  <div class="dialog-footer">
675
679
  <button class="button" id="account-detail-dismiss" type="button">Close</button>
680
+ <button class="button" id="account-detail-browser" type="button">Open browser</button>
676
681
  <button class="button" id="account-detail-check" type="button">Check</button>
677
682
  <button class="button" id="account-detail-exit-save" type="button">Save exit</button>
678
683
  <button class="button primary" id="account-detail-note-save" type="button">Save note</button>
package/ui/style.css CHANGED
@@ -1278,6 +1278,8 @@ main { flex: 1; }
1278
1278
  .mini-button:disabled { opacity: 0.45; cursor: not-allowed; }
1279
1279
  .mini-button.primary { color: var(--red); font-weight: 620; }
1280
1280
  .mini-button.primary:hover { background: color-mix(in srgb, var(--red) 11%, transparent); color: var(--red); }
1281
+ .mini-button.is-active { color: var(--green); font-weight: 600; }
1282
+ .mini-button.is-active:hover { background: color-mix(in srgb, var(--green) 11%, transparent); color: var(--green); }
1281
1283
 
1282
1284
  /* --- dialogs ------------------------------------------------------------ */
1283
1285
 
@@ -2031,6 +2033,37 @@ main { flex: 1; }
2031
2033
  .account-expiry-badge.is-soon { color: var(--amber); }
2032
2034
  .account-expiry-badge.is-expired { color: var(--red); }
2033
2035
 
2036
+ .account-browser-line {
2037
+ display: block;
2038
+ margin-top: 3px;
2039
+ font: 500 10px/1.5 var(--mono);
2040
+ letter-spacing: 0.04em;
2041
+ white-space: normal;
2042
+ overflow-wrap: anywhere;
2043
+ color: var(--faint);
2044
+ }
2045
+ .account-browser-line.is-good { color: var(--green); }
2046
+ .account-browser-line.is-warn { color: var(--amber); }
2047
+
2048
+ .account-browser-notice {
2049
+ display: block;
2050
+ margin-top: 2px;
2051
+ font: 500 10.5px/1.45 var(--mono);
2052
+ color: var(--amber);
2053
+ white-space: normal;
2054
+ overflow-wrap: anywhere;
2055
+ }
2056
+
2057
+ .account-browser-box {
2058
+ margin-top: 12px;
2059
+ padding: 8px 10px;
2060
+ border: 1px solid var(--line);
2061
+ border-radius: var(--radius);
2062
+ background: var(--paper-2);
2063
+ }
2064
+ .account-browser-status.is-good { color: var(--green); }
2065
+ .account-browser-status.is-warn { color: var(--amber); }
2066
+
2034
2067
  @media (max-width: 780px) {
2035
2068
  .providers-category-field { width: 100%; }
2036
2069
  .filter-search-input { width: 100%; }