sideby 0.25.0 → 0.26.1

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.
Files changed (37) hide show
  1. package/README.md +1 -0
  2. package/ai-tasks.json +17 -0
  3. package/dist/build.json +1 -1
  4. package/dist/src/cli/commands.d.ts +14 -0
  5. package/dist/src/cli/commands.js +113 -7
  6. package/dist/src/cli/json-schemas.js +46 -0
  7. package/dist/src/cli/main.js +38 -3
  8. package/dist/src/core/ask.js +5 -0
  9. package/dist/src/core/config.d.ts +16 -0
  10. package/dist/src/core/config.js +16 -0
  11. package/dist/src/core/egress.d.ts +103 -0
  12. package/dist/src/core/egress.js +333 -0
  13. package/dist/src/core/handoff-run.d.ts +4 -2
  14. package/dist/src/core/handoff-run.js +18 -11
  15. package/dist/src/core/launch.d.ts +5 -1
  16. package/dist/src/core/launch.js +5 -0
  17. package/dist/src/core/network.d.ts +131 -0
  18. package/dist/src/core/network.js +317 -0
  19. package/dist/src/network/hook.d.ts +15 -0
  20. package/dist/src/network/hook.js +69 -0
  21. package/dist/src/panel/handler.d.ts +3 -0
  22. package/dist/src/panel/handler.js +32 -0
  23. package/dist/src/panel/i18n.d.ts +53 -0
  24. package/dist/src/panel/i18n.js +106 -0
  25. package/dist/src/panel/page-logic.d.ts +23 -1
  26. package/dist/src/panel/page-logic.js +33 -0
  27. package/dist/src/panel/page-script.js +184 -11
  28. package/dist/src/panel/page-styles.js +11 -3
  29. package/dist/src/runtime.d.ts +18 -1
  30. package/dist/src/runtime.js +78 -7
  31. package/package.json +2 -2
  32. package/schemas/config.json +20 -0
  33. package/schemas/network-set.json +129 -0
  34. package/schemas/network.json +199 -0
  35. package/skills/sideby/SKILL.md +2 -1
  36. package/skills/sideby/references/ai-tasks.md +1 -1
  37. package/skills/sideby/references/network.md +37 -0
@@ -647,6 +647,12 @@ const en = {
647
647
  'th.removeSure': 'Remove for good?',
648
648
  'th.removed': 'Removed {name}',
649
649
  'ask.title.theme': 'Let AI pick your colors',
650
+ 'ask.title.network': 'Let AI help',
651
+ 'ask.task.network': 'AI asks which countries your requests may leave from, shows the change, and turns the check on only after you agree.',
652
+ 'ask.ph.network': 'Where are you, and which proxy nodes do you use? Or paste what was blocked.',
653
+ 'ask.ex.network.1': 'I am in the US; stop everything when the proxy drops',
654
+ 'ask.ex.network.2': 'Allow only my Japan and Singapore nodes',
655
+ 'ask.ex.network.3': 'A message was blocked; help me check the proxy',
650
656
  'ask.ph.theme': 'What feel do you want? A website or a color works too.',
651
657
  'ask.ex.theme.1': 'Quiet and gray, like Notion',
652
658
  'ask.ex.theme.2': 'Green, like my company site',
@@ -1271,6 +1277,53 @@ const en = {
1271
1277
  'set.g.ai': 'Let AI help',
1272
1278
  'set.quotaChecksHint': 'Each tool asks for its own quota, at most every {n} minutes per account. sideby does not read their sign-ins.',
1273
1279
  'set.ahHint': 'When an account is about to run out, the task moves on to another account by itself.',
1280
+ 'net.title': 'Network check',
1281
+ 'net.hint': 'Stops Claude and Codex when your requests would leave from a country you did not allow, for example when the proxy stopped.',
1282
+ 'net.explain': 'Before an account starts, and before each message and tool call in a session sideby started, sideby checks which country your requests leave from. When it is not one you allow, or cannot be told, it stops and says what to do. It guards against a proxy that stopped or a node in the wrong country; it does not make use from an unsupported region allowed.',
1283
+ 'net.switch': 'Check the network',
1284
+ 'net.allow': 'Countries your requests may leave from',
1285
+ 'net.current': 'now',
1286
+ 'net.pickFirst': 'Choose at least one country to turn it on. sideby never chooses for you, not even the current one.',
1287
+ 'net.now': 'Where your requests leave from',
1288
+ 'net.recheck': 'Check again',
1289
+ 'net.ok': 'allowed',
1290
+ 'net.blocked': 'not allowed',
1291
+ 'net.unknown': 'cannot tell',
1292
+ 'net.notChecked': 'not checked yet',
1293
+ 'net.seen': 'seen',
1294
+ 'net.checked': 'checked {when}',
1295
+ 'net.ipChanged': 'The exit address changed in the last day (same check; nothing is blocked for that).',
1296
+ 'net.noTargets': 'No Claude or Codex account is checked here.',
1297
+ 'net.skipped': '{refs}: API accounts are checked when they start (a third-party endpoint is not checked).',
1298
+ 'net.notCovered': 'Only sessions sideby starts are checked; running claude or codex directly is not. sideby asks the vendor’s own /cdn-cgi/trace with your proxy settings and no credential, and keeps only the country.',
1299
+ 'net.savedOn': 'Network check is on.',
1300
+ 'net.savedAllow': 'Allowed: {list}.',
1301
+ 'net.none': 'no country yet',
1302
+ 'net.undone': 'Changed back.',
1303
+ 'net.savedOff': 'Network check is off.',
1304
+ 'net.checkFailed': 'Could not check: {msg}',
1305
+ 'net.bannerTitle': 'Wrong network.',
1306
+ 'net.bannerBlocked': 'Requests now leave from {cty}, not from {allow}. sideby will stop new sessions and messages until the proxy is right.',
1307
+ 'net.bannerUnknown': 'sideby cannot tell where requests leave from ({why}); the proxy may be off. Sessions and messages are stopped until it can.',
1308
+ 'net.listSep': ', ',
1309
+ 'net.listLast': ' or ',
1310
+ 'net.keepOne': 'Network check is on, so keep at least one country, or turn it off first.',
1311
+ 'ai.ask.network': 'Stop Claude and Codex when my network is not in the US or Japan.',
1312
+ 'net.cty.US': 'United States',
1313
+ 'net.cty.JP': 'Japan',
1314
+ 'net.cty.SG': 'Singapore',
1315
+ 'net.cty.GB': 'United Kingdom',
1316
+ 'net.cty.DE': 'Germany',
1317
+ 'net.cty.FR': 'France',
1318
+ 'net.cty.NL': 'Netherlands',
1319
+ 'net.cty.CA': 'Canada',
1320
+ 'net.cty.AU': 'Australia',
1321
+ 'net.cty.KR': 'South Korea',
1322
+ 'net.cty.TW': 'Taiwan',
1323
+ 'net.cty.HK': 'Hong Kong',
1324
+ 'net.cty.CN': 'Mainland China',
1325
+ 'net.cty.MO': 'Macau',
1326
+ 'net.cty.IN': 'India',
1274
1327
  'set.aiHint': 'Your AI assistant can do anything on this page for you, through the sideby skill.',
1275
1328
  'set.more': 'All settings…',
1276
1329
  'set.saveFailed': 'Could not save the setting: {msg}',
@@ -2040,6 +2093,12 @@ const zh = {
2040
2093
  'th.removeSure': '确定删除?',
2041
2094
  'th.removed': '已删除「{name}」',
2042
2095
  'ask.title.theme': '让 AI 帮我配色',
2096
+ 'ask.title.network': '让 AI 帮我',
2097
+ 'ask.task.network': 'AI 会问你允许哪些地区,先给你看改动,你同意后才打开检查。',
2098
+ 'ask.ph.network': '你在哪里、用哪些代理节点?或者贴上被拦下的提示。',
2099
+ 'ask.ex.network.1': '我在美国,代理一断就全部拦住',
2100
+ 'ask.ex.network.2': '只允许日本和新加坡节点',
2101
+ 'ask.ex.network.3': '消息被拦了,帮我查查代理',
2043
2102
  'ask.ph.theme': '想要什么感觉?给个网址或颜色也行。',
2044
2103
  'ask.ex.theme.1': '素净的灰色,像 Notion',
2045
2104
  'ask.ex.theme.2': '绿色,和我们公司官网一样',
@@ -2664,6 +2723,53 @@ const zh = {
2664
2723
  'set.g.ai': '让 AI 帮我',
2665
2724
  'set.quotaChecksHint': '各工具自己查询每个账号的额度,最多每 {n} 分钟一次。sideby 不读它们的登录信息。',
2666
2725
  'set.ahHint': '账号额度快用完时,任务自己换到另一个账号接着做。',
2726
+ 'net.title': '网络检查',
2727
+ 'net.hint': '请求要从你没允许的国家或地区发出时(比如代理断了),拦下 Claude 和 Codex。',
2728
+ 'net.explain': '账号启动前,以及 sideby 启动的会话里每条消息、每次工具调用前,sideby 都会查一下请求从哪个国家或地区发出。不在你允许的范围里,或者查不出来,就拦下并告诉你怎么办。它防的是代理断了、节点切错了;不会让在不支持的地区使用变得合规。',
2729
+ 'net.switch': '检查网络',
2730
+ 'net.allow': '允许请求从这些地区发出',
2731
+ 'net.current': '当前',
2732
+ 'net.pickFirst': '至少选一个地区才能打开。sideby 不替你选,当前所在的地区也不会自动选上。',
2733
+ 'net.now': '现在的请求从哪里发出',
2734
+ 'net.recheck': '重新检查',
2735
+ 'net.ok': '允许',
2736
+ 'net.blocked': '不允许',
2737
+ 'net.unknown': '查不出',
2738
+ 'net.notChecked': '还没查过',
2739
+ 'net.seen': '查到',
2740
+ 'net.checked': '{when}查过',
2741
+ 'net.ipChanged': '出口 IP 最近一天变过(不会因此拦截)。',
2742
+ 'net.noTargets': '这里没有要检查的 Claude 或 Codex 账号。',
2743
+ 'net.skipped': '{refs}:API 账号在启动时检查(第三方接口不检查)。',
2744
+ 'net.notCovered': '只检查 sideby 启动的会话,直接运行 claude 或 codex 不检查。sideby 带着你的代理设置访问服务商自己的 /cdn-cgi/trace,不带任何凭证,只保留国家或地区。',
2745
+ 'net.savedOn': '网络检查已打开。',
2746
+ 'net.savedAllow': '允许的地区:{list}。',
2747
+ 'net.none': '还没有选',
2748
+ 'net.undone': '已改回。',
2749
+ 'net.savedOff': '网络检查已关闭。',
2750
+ 'net.checkFailed': '没能检查:{msg}',
2751
+ 'net.bannerTitle': '网络不对。',
2752
+ 'net.bannerBlocked': '现在请求从{cty}发出,不在{allow}里。代理恢复前,sideby 会拦下新会话和消息。',
2753
+ 'net.bannerUnknown': 'sideby 查不出请求从哪里发出({why}),代理可能没开。能查出来之前,会话和消息都会被拦下。',
2754
+ 'net.listSep': '、',
2755
+ 'net.listLast': '、',
2756
+ 'net.keepOne': '网络检查开着,至少留一个地区;不想检查就先关掉。',
2757
+ 'ai.ask.network': '网络不在美国或日本时,别让 Claude 和 Codex 用。',
2758
+ 'net.cty.US': '美国',
2759
+ 'net.cty.JP': '日本',
2760
+ 'net.cty.SG': '新加坡',
2761
+ 'net.cty.GB': '英国',
2762
+ 'net.cty.DE': '德国',
2763
+ 'net.cty.FR': '法国',
2764
+ 'net.cty.NL': '荷兰',
2765
+ 'net.cty.CA': '加拿大',
2766
+ 'net.cty.AU': '澳大利亚',
2767
+ 'net.cty.KR': '韩国',
2768
+ 'net.cty.TW': '台湾',
2769
+ 'net.cty.HK': '香港',
2770
+ 'net.cty.CN': '中国大陆',
2771
+ 'net.cty.MO': '澳门',
2772
+ 'net.cty.IN': '印度',
2667
2773
  'set.aiHint': '这个页面上能做的事,都可以让你的 AI 助手通过 sideby skill 帮你做。',
2668
2774
  'set.more': '所有设置…',
2669
2775
  'set.saveFailed': '设置没有保存:{msg}',
@@ -538,8 +538,28 @@ export declare function stripSecrets(text: string): {
538
538
  text: string;
539
539
  removed: boolean;
540
540
  };
541
+ /**
542
+ * Network Guard facts for the `network` AI Task (spec §3.35), one plain line each, from the Panel state's `network`:
543
+ * the switch, the allowed countries and the newest result per address. No address is ever in it, only countries.
544
+ */
545
+ export declare function networkTaskFacts(n: {
546
+ guard: boolean;
547
+ allow: readonly string[];
548
+ targets: readonly {
549
+ url: string;
550
+ status: string;
551
+ loc?: string;
552
+ checkedAt?: string;
553
+ error?: string;
554
+ accounts: readonly string[];
555
+ }[];
556
+ accounts: readonly {
557
+ ref: string;
558
+ skip?: string;
559
+ }[];
560
+ }): string[];
541
561
  /** The kinds of AI Task (spec §3.28); anything else is refused. */
542
- export declare const AI_TASK_KINDS: readonly ['free', 'fix', 'quota', 'account', 'host', 'plugin', 'terminal', 'theme', 'handoff', 'menubar', 'hotkey'];
562
+ export declare const AI_TASK_KINDS: readonly ['free', 'fix', 'quota', 'account', 'host', 'plugin', 'terminal', 'theme', 'handoff', 'menubar', 'hotkey', 'network'];
543
563
  export type AiTaskKind = (typeof AI_TASK_KINDS)[number];
544
564
  /**
545
565
  * The message keys of the AI dialog for `task` (spec §3.28 "每个入口的提示"): its title, the text box placeholder and
@@ -625,6 +645,8 @@ export declare function taskPrompt(input: {
625
645
  terminals?: readonly string[];
626
646
  /** Auto Handoff facts, one per line, as `handoffTaskFacts` gives them (`handoff` task). */
627
647
  handoff?: readonly string[];
648
+ /** Network Guard facts, one per line, as `networkTaskFacts` gives them (`network` task, spec §3.35). */
649
+ network?: readonly string[];
628
650
  };
629
651
  /** Files saved for the task (spec §3.28 "附件"): absolute paths and their kind. */
630
652
  attachments?: readonly {
@@ -961,6 +961,27 @@ export function stripSecrets(text) {
961
961
  });
962
962
  return { text: out, removed };
963
963
  }
964
+ /**
965
+ * Network Guard facts for the `network` AI Task (spec §3.35), one plain line each, from the Panel state's `network`:
966
+ * the switch, the allowed countries and the newest result per address. No address is ever in it, only countries.
967
+ */
968
+ export function networkTaskFacts(n) {
969
+ const out = [`guard: ${n.guard ? 'on' : 'off'}`, `allow: ${n.allow.join(', ') || 'none'}`];
970
+ for (const t of n.targets) {
971
+ let host = t.url;
972
+ try {
973
+ host = new URL(t.url).hostname;
974
+ }
975
+ catch {
976
+ // keep the URL
977
+ }
978
+ out.push(`${host}: ${t.status}${t.loc ? `, country ${t.loc}` : ''}${t.checkedAt ? `, checked ${t.checkedAt}` : ''}${t.error ? `, ${t.error}` : ''} (${t.accounts.join(', ')})`);
979
+ }
980
+ for (const a of n.accounts)
981
+ if (a.skip)
982
+ out.push(`${a.ref}: not checked here (${a.skip})`);
983
+ return out;
984
+ }
964
985
  /** The kinds of AI Task (spec §3.28); anything else is refused. */
965
986
  export const AI_TASK_KINDS = [
966
987
  'free',
@@ -974,6 +995,7 @@ export const AI_TASK_KINDS = [
974
995
  'handoff',
975
996
  'menubar',
976
997
  'hotkey',
998
+ 'network',
977
999
  ];
978
1000
  /**
979
1001
  * The message keys of the AI dialog for `task` (spec §3.28 "每个入口的提示"): its title, the text box placeholder and
@@ -1080,6 +1102,9 @@ export function taskPrompt(input, strip) {
1080
1102
  pHotkey: '先运行 `sideby menubar hotkey --json` 看现在用的组合。再查本机已经被占的组合:`defaults read com.apple.symbolichotkeys AppleSymbolicHotKeys` 里 enabled 为 1 的系统快捷键,以及 `/Applications` 里装了哪些常用全局快捷键的 App(Raycast、Alfred、ChatGPT、Claude 等),按它们的默认快捷键判断;不要打开它们的配置文件(里面可能有密钥),拿不准就问我。问我习惯用哪只手、平时常按哪些快捷键,然后推荐 2 到 3 个按起来顺手、又没被占的组合(两个键最顺手,比如 ⌥X;必须带 ⌥、⌘ 或 ⌃),说清每个会占掉什么(比如 ⌥X 不能再打出 ≈)。我选定后运行 `sideby menubar hotkey <组合>`,几秒内生效,不用重启;再请我按一下,确认能打开菜单。按了没反应,说明别的 App 先占了,换下一个。不要改系统或别的 App 的快捷键设置。',
1081
1103
  pMenubar: '先运行 `sideby menubar --json`。`state` 为 `off`:它被关掉了(常见于菜单里的「从状态栏隐藏…」),给我看 `sideby menubar on` 的预览,我同意后加 `--yes`。`state` 为 `on` 但 `loaded` 为 `false`:macOS 没在运行它,`sideby menubar on --yes` 只是重新启动,不改文件。`loaded` 为 `true`:它在运行但被挡住了,依次查:状态栏是否太满或被刘海挡住(按住 ⌘ 拖动图标);有没有 Ice、Bartender、Hidden Bar 这类菜单栏整理工具把它收起来了(查 `/Applications`,告诉我去它的设置里把 sideby(显示为 osascript)挪出来);macOS 26 及以上要在「系统设置 › 菜单栏」里允许 osascript(`sideby menubar --json` 里的快捷键 `hotkey.label` 可以在任何地方打开菜单,用来确认它在运行)。不要结束或重启任何不是 sideby 的进程。',
1082
1104
  cHandoff: '自动接力现在的设置(来自 `sideby handoff status --json`):',
1105
+ network: '帮我设置 sideby 的网络检查:请求要从我没允许的国家或地区发出时(比如代理断了、节点切错了),拦下 Claude 和 Codex。',
1106
+ cNetwork: '网络检查现在的情况(来自 `sideby network --json`):',
1107
+ pNetwork: '先运行 `sideby network check --json`,告诉我现在每个地址的请求从哪里发出。问我允许哪些国家或地区;不要替我决定,也不要因为现在在哪就把它加进去(网络不对时那正是错的地区)。我说了以后,先不加 `--yes` 跑 `sideby network allow <代码>... --json` 和 `sideby network on --json` 给我看预览,我同意后再加 `--yes`。告诉我:只检查 sideby 启动的会话;Codex 要在 `/hooks` 里信任一次 `network-hook`;临时跳过一次用 `sideby run <账号> --ignore-network`。被拦过的话,先帮我查代理(开没开、哪个节点),再跑 `sideby network check --json` 确认。它只防代理出意外,不会让在不支持的地区使用变得合规;不要帮我隐藏所在地(时区、指纹之类)。',
1083
1108
  pHandoff: '先运行 `sideby handoff status --json` 和 `sideby quota --json`,看清每个账号的额度来源和用量。只用 `sideby handoff enable …` 或 `sideby config set handoff.<键> <值>` 改设置;先不加 `--yes` 给我看预览,我同意后再加 `--yes`。没有额度数据的账号排在顺序后面,并告诉我怎么让它显示额度。',
1084
1109
  cAccount: '账号:',
1085
1110
  cFamily: '家族:',
@@ -1126,6 +1151,9 @@ export function taskPrompt(input, strip) {
1126
1151
  pHotkey: 'Run `sideby menubar hotkey --json` first to see the current shortcut. Then find the combinations already taken on this Mac: the system shortcuts with enabled 1 in `defaults read com.apple.symbolichotkeys AppleSymbolicHotKeys`, and the apps in /Applications that usually hold a global shortcut (Raycast, Alfred, ChatGPT, Claude and the like), judged by their default shortcuts; do not open their config files (they may hold keys), and ask me when unsure. Ask which hand I use and which shortcuts I press often, then recommend 2 or 3 combinations that are easy to press and free (two keys are easiest, such as ⌥X; each needs ⌥, ⌘ or ⌃), and say what each takes away (⌥X no longer types ≈). Once I pick one, run `sideby menubar hotkey <keys>`: it works within seconds, with no restart; then ask me to press it and check the menu opens. If nothing happens another app took it first, so try the next. Never change the shortcuts of macOS or another app.',
1127
1152
  pMenubar: 'Run `sideby menubar --json` first. `state` is `off`: it was turned off (often with "Hide from Menu Bar…" in its menu); show me the preview of `sideby menubar on`, and add `--yes` after I agree. `state` is `on` with `loaded: false`: macOS is not running it; `sideby menubar on --yes` only starts it again and changes no file. `loaded: true`: it runs but is hidden; check in turn whether the menu bar is too full or the notch covers it (hold ⌘ and drag icons), whether a menu bar organizer such as Ice, Bartender or Hidden Bar tucked it away (look in /Applications, and tell me where in its settings to move sideby, shown as osascript, out), and, on macOS 26 and later, whether osascript is allowed under System Settings › Menu Bar. The shortcut in `hotkey.label` opens the menu from anywhere, which shows it is running. Never end or restart a process that is not sideby\'s.',
1128
1153
  cHandoff: 'Auto Handoff now (from `sideby handoff status --json`):',
1154
+ network: "Help me set up sideby's network check: stop Claude and Codex when my requests would leave from a country I did not allow (for example when the proxy stopped or a node in the wrong country is picked).",
1155
+ cNetwork: 'Network check now (from `sideby network --json`):',
1156
+ pNetwork: "Run `sideby network check --json` first and tell me where each address's requests leave from now. Ask me which countries to allow; never decide for me, and never add the current country because it is current (on a wrong network that is the wrong one). Once I say, run `sideby network allow <codes>... --json` and `sideby network on --json` without `--yes` to show me the change, and add `--yes` after I agree. Tell me: only sessions sideby starts are checked; in Codex I trust `network-hook` once in `/hooks`; `sideby run <account> --ignore-network` skips it once. If something was blocked, help me check the proxy (is it on, which node) first, then run `sideby network check --json` to confirm. It guards against proxy accidents; it does not make use from an unsupported region allowed, and never help hide where I am (time zone, fingerprints).",
1129
1157
  pHandoff: 'Run `sideby handoff status --json` and `sideby quota --json` first to see where each account gets its quota and how much is used. Change settings only with `sideby handoff enable …` or `sideby config set handoff.<key> <value>`; show me the preview without `--yes` first, and add `--yes` only after I agree. Put accounts without quota data last in the order, and tell me how to make them show it.',
1130
1158
  cAccount: 'Account: ',
1131
1159
  cFamily: 'Family: ',
@@ -1195,6 +1223,11 @@ export function taskPrompt(input, strip) {
1195
1223
  if (lines.length)
1196
1224
  facts.push('- ' + L.cHandoff, ...lines.map((l) => ' - ' + l));
1197
1225
  }
1226
+ if (task === 'network') {
1227
+ const lines = (c.network || []).map(clean).filter(Boolean);
1228
+ if (lines.length)
1229
+ facts.push('- ' + L.cNetwork, ...lines.map((l) => ' - ' + l));
1230
+ }
1198
1231
  const version = clean(c.version);
1199
1232
  if (version)
1200
1233
  facts.push('- ' + L.cVersion + version);
@@ -3,7 +3,7 @@
3
3
  import { groupsToAccept } from '../core/inbound.js';
4
4
  import { quotaIsStale } from '../core/quota-levels.js';
5
5
  import { remoteControlTodo } from '../core/remote-control.js';
6
- import { aiTaskAccounts, aliasArgsOf, aliasIssue, askBridge, askBridged, askCopy, attentionReasons, attentionWhy, autostartNote, bindingWindow, cacheHitRate, canLeaveLocal, categoryOrder, codeSwapOutcome, dotsKeepKeyboard, enableOutcome, fileSize, fixPrompt, foldSkips, foldToolCalls, formatDuration, handoffChangeOf, handoffHintAccount, handoffTaskFacts, hiddenIn, highlightParts, histFilters, historyEmpty, historyWhen, hotkeyFromKey, hotkeyPressKind, inDisplayOrder, loginClusters, loginKey, maskEmail, matchesQuery, mdBlocks, mdInline, menuPlacement, mergeDaily, mergeUsage, messageChip, messageNews, newAccountDir, nextReset, panelFixes, panelHint, panelLang, panelMigration, panelPrefs, passedWindow, pinnedIn, quotaAskable, quotaHighLevel, quotaPressure, radioStep, remoteControlSummary, reorder, rowBadge, runCodeSwap, saveHandoffChange, sendBlock, sendFileProblem, sendResultView, sessionAge, sessionLabelParts, shortCwd, shortSessionLabel, sortAccounts, sortSessions, steadyOrder, stripSecrets, suggestAlias, suggestName, switchFailure, tailInView, taskFindings, updatedAge, widthFollower, widthTier, windowState, withPinned, } from './page-logic.js';
6
+ import { aiTaskAccounts, aliasArgsOf, aliasIssue, askBridge, askBridged, askCopy, attentionReasons, attentionWhy, autostartNote, bindingWindow, cacheHitRate, canLeaveLocal, categoryOrder, codeSwapOutcome, dotsKeepKeyboard, enableOutcome, fileSize, fixPrompt, foldSkips, foldToolCalls, formatDuration, handoffChangeOf, handoffHintAccount, handoffTaskFacts, hiddenIn, highlightParts, histFilters, historyEmpty, historyWhen, hotkeyFromKey, hotkeyPressKind, inDisplayOrder, loginClusters, loginKey, maskEmail, matchesQuery, mdBlocks, mdInline, menuPlacement, mergeDaily, mergeUsage, messageChip, messageNews, networkTaskFacts, newAccountDir, nextReset, panelFixes, panelHint, panelLang, panelMigration, panelPrefs, passedWindow, pinnedIn, quotaAskable, quotaHighLevel, quotaPressure, radioStep, remoteControlSummary, reorder, rowBadge, runCodeSwap, saveHandoffChange, sendBlock, sendFileProblem, sendResultView, sessionAge, sessionLabelParts, shortCwd, shortSessionLabel, sortAccounts, sortSessions, steadyOrder, stripSecrets, suggestAlias, suggestName, switchFailure, tailInView, taskFindings, updatedAge, widthFollower, widthTier, windowState, withPinned, } from './page-logic.js';
7
7
  const LOGIC = [
8
8
  quotaIsStale,
9
9
  aiTaskAccounts,
@@ -34,6 +34,7 @@ const LOGIC = [
34
34
  handoffChangeOf,
35
35
  handoffHintAccount,
36
36
  handoffTaskFacts,
37
+ networkTaskFacts,
37
38
  inDisplayOrder,
38
39
  loginClusters,
39
40
  loginKey,
@@ -236,16 +237,23 @@ const MAIN = String.raw `
236
237
  else el.removeAttribute('aria-label')
237
238
  }
238
239
  // replaceChildren() would render null as the text "null"; route children through add(), which skips it.
240
+ // The toast stack (raiseToasts) may live in the open dialog; redrawing the dialog leaves it where it is.
241
+ const keepsToasts = (n) => n.nodeType === 1 && n.id === 'toasts'
239
242
  function setKids(el, kids) {
240
- el.replaceChildren()
241
- add(el, kids)
243
+ for (const n of Array.from(el.childNodes)) if (!keepsToasts(n)) n.remove()
244
+ const stack = el.lastChild
245
+ if (!stack) return add(el, kids)
246
+ // New content goes before the stack, so a later patch finds it in place and moves nothing (moving loses focus).
247
+ const box = document.createDocumentFragment()
248
+ add(box, kids)
249
+ el.insertBefore(box, stack)
242
250
  }
243
251
  // Re-renders el without the jolt of a rebuild: the focused control keeps focus (matched by data-key), and an element
244
252
  // marked data-enter that was not there before grows in, so a row that appears does not snap the layout open.
245
253
  // A first render (el empty) animates nothing; the container itself has its own entrance.
246
254
  function swapKids(el, kids) {
247
255
  const before = new Set([...el.querySelectorAll('[data-enter]')].map((x) => x.getAttribute('data-enter')))
248
- const shown = el.childNodes.length > 0
256
+ const shown = Array.from(el.childNodes).some((n) => !keepsToasts(n))
249
257
  const active = document.activeElement
250
258
  const focusKey = active && el.contains(active) ? active.getAttribute('data-key') : null
251
259
  setKids(el, kids)
@@ -253,6 +261,20 @@ const MAIN = String.raw `
253
261
  for (const x of el.querySelectorAll('[data-enter]')) if (!before.has(x.getAttribute('data-enter'))) x.classList.add('enter')
254
262
  if (focusKey) { const again = el.querySelector('[data-key="' + CSS.escape(focusKey) + '"]'); if (again) again.focus() }
255
263
  }
264
+ // swapKids for a view that refreshes while open: unchanged elements stay (see patch), so a refresh that brings the
265
+ // same answer redraws nothing; new data-enter elements still grow in.
266
+ function patchEnter(el, kids) {
267
+ const before = new Set([...el.querySelectorAll('[data-enter]')].map((x) => x.getAttribute('data-enter')))
268
+ const shown = Array.from(el.childNodes).some((n) => !keepsToasts(n))
269
+ patch(el, kids)
270
+ if (shown && !REDUCED)
271
+ for (const x of el.querySelectorAll('[data-enter]'))
272
+ if (!before.has(x.getAttribute('data-enter'))) {
273
+ x.classList.add('enter')
274
+ // Gone once it has grown in, so the next refresh sees the same markup and keeps the element.
275
+ x.addEventListener('animationend', () => x.classList.remove('enter'), { once: true })
276
+ }
277
+ }
256
278
  function add(el, kid) {
257
279
  if (kid === null || kid === undefined || kid === false) return
258
280
  if (Array.isArray(kid)) { for (const k of kid) add(el, k); return }
@@ -287,7 +309,7 @@ const MAIN = String.raw `
287
309
  }
288
310
  function patchKids(box, kids) {
289
311
  const next = flat(kids)
290
- const old = Array.from(box.childNodes)
312
+ const old = Array.from(box.childNodes).filter((n) => !keepsToasts(n))
291
313
  const byKey = new Map()
292
314
  for (const o of old) if (o.nodeType === 1 && o.dataset.key) byKey.set(o.dataset.key, o)
293
315
  const used = new Set()
@@ -508,9 +530,13 @@ const MAIN = String.raw `
508
530
  // Hovering a toast pauses it, so an Undo stays reachable.
509
531
  const toasts = []
510
532
  // The toast stack is a manual popover so it sits in the top layer; raising it again after a modal dialog
511
- // opens keeps toasts above that dialog's backdrop. Without popover support it stays a fixed element.
533
+ // opens keeps toasts above that dialog's backdrop. A modal dialog makes everything outside it inert, a popover
534
+ // above it included, so while one is open the stack moves into it and an Undo stays clickable; it moves back
535
+ // when the dialog closes. Without popover support it stays a fixed element.
512
536
  function raiseToasts() {
513
537
  const el = $('toasts')
538
+ const home = dlg.el && dlg.el.open ? dlg.el : document.body
539
+ if (el.parentNode !== home) home.append(el)
514
540
  if (typeof el.showPopover !== 'function') return
515
541
  try { if (el.matches(':popover-open')) el.hidePopover(); el.showPopover() } catch {}
516
542
  }
@@ -2787,6 +2813,7 @@ const MAIN = String.raw `
2787
2813
  const after = dlg.onClose
2788
2814
  dlg.kind = null
2789
2815
  dlg.onClose = null
2816
+ raiseToasts()
2790
2817
  if (after) after()
2791
2818
  })
2792
2819
  document.body.append(dlg.el)
@@ -5703,6 +5730,7 @@ const MAIN = String.raw `
5703
5730
  if (S.state && rcSummary()) out.push('rc')
5704
5731
  if (S.state && ahState()) out.push('ah')
5705
5732
  if (S.state && (S.state.quotaChecks || []).length) out.push('checks')
5733
+ if (S.state && S.state.network) out.push('net')
5706
5734
  return out
5707
5735
  }
5708
5736
  function renderSettingsButton() {
@@ -5714,6 +5742,7 @@ const MAIN = String.raw `
5714
5742
  b.setAttribute('aria-label', t('set.button') + (warn ? colon() + t('set.rcOn') : ''))
5715
5743
  refreshSettings()
5716
5744
  if (dlg.kind === 'rc') renderRc()
5745
+ if (dlg.kind === 'net' && net) renderNet()
5717
5746
  }
5718
5747
  // The settings live in two places (spec §3.29, 2026-10-20). The header popover holds only what people change
5719
5748
  // often, one click each and no explanations: language, theme, Auto Handoff, asking an AI, and "All settings…".
@@ -5794,6 +5823,13 @@ const MAIN = String.raw `
5794
5823
  h('button', { class: 'seg-btn', type: 'button', 'aria-pressed': String(v === c.on), onclick: () => { if (v !== c.on) { leave(false); setCheck(c.family, v) } } }, text)))))
5795
5824
  }
5796
5825
  }
5826
+ // Network Guard (spec §3.35): its own dialog, with the state on the link.
5827
+ const netItems = []
5828
+ if (secs.includes('net')) {
5829
+ const n = S.state.network
5830
+ const bad = netProblem()
5831
+ netItems.push(link(t('net.title'), bad ? t('net.blocked') : n.guard ? t('ah.on') : t('ah.off'), bad ? 'chip-fail' : n.guard ? 'chip-ok' : '', openNet, true))
5832
+ }
5797
5833
  // Everything here can also be asked of an AI assistant through the sideby skill (spec §3.8).
5798
5834
  const ai = [aiLink(leave), link(t('ask.plugin'), '', '', () => openAsk({ task: 'plugin', context: { version: BOOT.version } }), true)]
5799
5835
  return [
@@ -5802,6 +5838,7 @@ const MAIN = String.raw `
5802
5838
  { id: 'accounts', title: t('set.g.accounts'), items: acct },
5803
5839
  { id: 'quota', title: t('set.g.quota'), items: checks, foot: t('set.quotaChecksHint', { n: every }) },
5804
5840
  { id: 'handoff', title: t('ah.button'), items: [ahLink(leave)].filter(Boolean), foot: t('set.ahHint') },
5841
+ { id: 'network', title: t('net.title'), items: netItems, foot: t('net.hint') },
5805
5842
  { id: 'ai', title: t('set.g.ai'), items: ai, foot: t('set.aiHint') },
5806
5843
  ].filter((g) => g.items.length)
5807
5844
  }
@@ -5830,15 +5867,21 @@ const MAIN = String.raw `
5830
5867
  const leave = (opens) => { if (!opens && dlg.kind === 'settings') dlg.el.close() }
5831
5868
  const groups = settingsGroups(leave)
5832
5869
  const cur = groups.find((g) => g.id === prefs.setSec) || groups[0]
5833
- const nav = h('div', { class: 'set-nav', role: 'tablist', 'aria-label': t('set.title') }, groups.map((g) =>
5870
+ const nav = h('div', { class: 'set-nav', role: 'tablist', 'aria-label': t('set.title'), 'data-patch': '' }, groups.map((g) =>
5834
5871
  h('button', { class: 'set-tab', type: 'button', role: 'tab', id: 'set-tab-' + g.id, 'aria-selected': String(g === cur), 'aria-controls': 'set-pane', onclick: () => { if (prefs.setSec === g.id || g === cur) return; prefs.setSec = g.id; savePrefs(); renderSettingsDialog(true) } }, g.title)))
5835
- const pane = h('div', { class: 'set-pane' + (switched ? ' view-in' : ''), id: 'set-pane', role: 'tabpanel', 'aria-labelledby': 'set-tab-' + cur.id },
5872
+ const pane = h('div', { class: 'set-pane' + (switched ? ' view-in' : ''), id: 'set-pane', role: 'tabpanel', 'aria-labelledby': 'set-tab-' + cur.id, 'data-patch': '' },
5836
5873
  h('h3', { class: 'set-pane-title' }, cur.title),
5837
5874
  cur.foot ? h('p', { class: 'set-foot' }, cur.foot) : null,
5838
- h('div', { class: 'set-group' }, cur.items))
5875
+ h('div', { class: 'set-group', 'data-patch': '' }, cur.items))
5876
+ // Gone once it has slid in, so the next refresh sees the same markup.
5877
+ if (switched) pane.addEventListener('animationend', () => pane.classList.remove('view-in'), { once: true })
5839
5878
  // It stays wide while it fades out; showDialog drops the width when another dialog takes the element.
5840
5879
  dlg.el.classList.add('dialog-wide')
5841
- setKids(dlg.el, dialogFrame(t('set.title'), null, h('div', { class: 'set-dialog' }, nav, pane)))
5880
+ // Patched in place: the refresh every few seconds redraws only what changed, and a list the user has open stays.
5881
+ const frame = dialogFrame(t('set.title'), null, h('div', { class: 'set-dialog', 'data-patch': '' }, nav, pane))
5882
+ frame[1].setAttribute('data-patch', '')
5883
+ if (switched) setKids(dlg.el, frame)
5884
+ else patch(dlg.el, frame)
5842
5885
  // A redraw replaced the list; a section picked from it keeps the focus on its tab.
5843
5886
  if (switched) { const tab = document.getElementById('set-tab-' + cur.id); if (tab) tab.focus() }
5844
5887
  }
@@ -6170,7 +6213,135 @@ const MAIN = String.raw `
6170
6213
  return Boolean(u && u.skillUpdate && u.skillUpdate.installed && u.skillUpdate.installed.length)
6171
6214
  }
6172
6215
  // Example phrases: a click puts one in the Let AI do it box (spec §3.28).
6173
- const AI_ASKS = ['ai.ask.quota', 'ai.ask.pick', 'ai.ask.new', 'ai.ask.api', 'ai.ask.pin', 'ai.ask.hide', 'ai.ask.relogin', 'ai.ask.fix', 'ai.ask.handoff', 'ai.ask.handoffRules', 'ai.ask.session', 'ai.ask.history', 'ai.ask.send', 'ai.ask.inbound', 'ai.ask.menubar', 'ai.ask.rc', 'ai.ask.theme', 'ai.ask.tool']
6216
+ const AI_ASKS = ['ai.ask.quota', 'ai.ask.pick', 'ai.ask.new', 'ai.ask.api', 'ai.ask.pin', 'ai.ask.hide', 'ai.ask.relogin', 'ai.ask.fix', 'ai.ask.handoff', 'ai.ask.handoffRules', 'ai.ask.session', 'ai.ask.history', 'ai.ask.send', 'ai.ask.inbound', 'ai.ask.menubar', 'ai.ask.rc', 'ai.ask.network', 'ai.ask.theme', 'ai.ask.tool']
6217
+ // Network Guard (spec §3.35): one dialog with the switch, the allowed countries and the newest result per address.
6218
+ // Countries are never ticked for the user, the current one included: a wrong network would allow itself.
6219
+ const NET_COMMON = ['US', 'JP', 'SG', 'GB', 'DE', 'FR', 'NL', 'CA', 'AU', 'KR', 'TW', 'HK']
6220
+ let net = null
6221
+ function netState() { return S.state && S.state.network }
6222
+ function netProblem() {
6223
+ const n = netState()
6224
+ return n && n.active ? n.targets.find((x) => x.status === 'blocked' || x.status === 'unknown') || null : null
6225
+ }
6226
+ function netCountry(code) {
6227
+ const name = t('net.cty.' + code)
6228
+ if (name === 'net.cty.' + code) return code
6229
+ return lang === 'zh' ? name + '(' + code + ')' : name + ' (' + code + ')'
6230
+ }
6231
+ // "A, B or C" in English, "A、B、C" in Chinese.
6232
+ function netList(items) {
6233
+ if (items.length < 2) return items.join('')
6234
+ return items.slice(0, -1).join(t('net.listSep')) + t('net.listLast') + items[items.length - 1]
6235
+ }
6236
+ function openNet() {
6237
+ const n = netState()
6238
+ if (!n) return
6239
+ net = { guard: n.guard, allow: [...n.allow], checking: false }
6240
+ showDialog('net')
6241
+ renderNet()
6242
+ // Opening it answers "where am I now" at once, unless a result is fresh.
6243
+ if (!n.targets.some((x) => x.checkedAt && Date.now() - Date.parse(x.checkedAt) < 60000)) netCheck()
6244
+ }
6245
+ async function netCheck() {
6246
+ if (!net) net = { guard: false, allow: [], checking: false }
6247
+ net.checking = true
6248
+ if (dlg.kind === 'net') renderNet()
6249
+ renderBanners()
6250
+ try { S.state.network = await api('/api/network/check', {}) } catch (e) { toast(t('net.checkFailed', { msg: e.message }), { kind: 'fail' }) }
6251
+ net.checking = false
6252
+ if (dlg.kind === 'net') renderNet()
6253
+ renderBanners()
6254
+ }
6255
+ // Every change in the dialog applies at once, like a system setting, and its toast carries the undo. Changes are
6256
+ // saved one after another in the order clicked; a failed one puts the dialog back to what the config holds.
6257
+ let netSaving = Promise.resolve()
6258
+ function netApply(next, opts) {
6259
+ opts = opts || {}
6260
+ const prev = { guard: net.guard, allow: [...net.allow] }
6261
+ net.guard = next.guard
6262
+ net.allow = [...next.allow]
6263
+ renderNet()
6264
+ netSaving = netSaving.then(async () => {
6265
+ try {
6266
+ await api('/api/network/settings', { guard: next.guard, allow: next.allow, confirm: true })
6267
+ await load({ silent: true })
6268
+ const text = opts.undone ? t('net.undone')
6269
+ : next.guard !== prev.guard ? t(next.guard ? 'net.savedOn' : 'net.savedOff')
6270
+ : t('net.savedAllow', { list: next.allow.length ? netList(next.allow.map(netCountry)) : t('net.none') })
6271
+ toast(text, opts.undone ? { key: 'net' } : { key: 'net', action: { label: t('toast.undo'), run: () => netApply(prev, { undone: true }) }, duration: 10000 })
6272
+ } catch (e) {
6273
+ toast(e.message, { kind: 'fail' })
6274
+ const n = netState()
6275
+ if (n && net) { net.guard = n.guard; net.allow = [...n.allow] }
6276
+ }
6277
+ if (dlg.kind === 'net') renderNet()
6278
+ })
6279
+ }
6280
+ function renderNet() {
6281
+ const n = netState()
6282
+ if (!n || !net) return
6283
+ const here = new Set(n.targets.map((x) => x.loc).filter(Boolean))
6284
+ const list = [...new Set([...NET_COMMON, ...net.allow, ...here])]
6285
+ const toggle = (c) => netApply({ guard: net.guard, allow: net.allow.includes(c) ? net.allow.filter((x) => x !== c) : [...net.allow, c] })
6286
+ // While it is on, the last country stays: taking it away would leave nothing allowed.
6287
+ const lastOne = (c) => net.guard && net.allow.length === 1 && net.allow[0] === c
6288
+ const sw = h('div', { class: 'set-row', 'data-patch': '' }, h('span', { class: 'set-label' }, t('net.switch')),
6289
+ h('div', { class: 'seg', role: 'group', 'aria-label': t('net.switch'), 'data-patch': '' }, [[true, t('ah.on')], [false, t('ah.off')]].map(([v, text]) =>
6290
+ h('button', { class: 'seg-btn', type: 'button', 'data-key': 'net-sw-' + v, disabled: BOOT.readOnly || (v && !net.allow.length), 'aria-pressed': String(net.guard === v), onclick: () => { if (net.guard !== v) netApply({ guard: v, allow: net.allow }) } }, text))))
6291
+ const countries = h('div', { class: 'net-countries', role: 'group', 'aria-label': t('net.allow'), 'data-patch': '' }, list.map((c) =>
6292
+ h('button', { class: 'net-cty', type: 'button', 'data-key': 'net-cty-' + c, disabled: BOOT.readOnly || lastOne(c), title: lastOne(c) ? t('net.keepOne') : null, 'aria-pressed': String(net.allow.includes(c)), onclick: () => toggle(c) },
6293
+ netCountry(c), here.has(c) ? h('span', { class: 'chip chip-sm' }, t('net.current')) : null)))
6294
+ const status = (x) => x.status === 'ok' ? ['chip-ok', t('net.ok')] : x.status === 'blocked' ? ['chip-fail', t('net.blocked')] : x.status === 'unknown' ? ['chip-fail', t('net.unknown')] : ['', t('net.notChecked')]
6295
+ const rows = n.targets.map((x) => {
6296
+ const [cls, label] = n.allow.length || x.status === 'not-checked' ? status(x) : ['', t('net.seen')]
6297
+ return h('li', { class: 'rc-row', 'data-key': 'net-row-' + x.url },
6298
+ h('div', null, h('code', null, new URL(x.url).hostname), ' ', x.loc ? h('b', null, netCountry(x.loc)) : null, ' ', h('span', { class: 'chip chip-sm ' + cls }, label)),
6299
+ h('div', { class: 'muted small' }, [x.checkedAt ? t('net.checked', { when: ago(x.checkedAt) }) : null, x.error || null, x.accounts.join(', ')].filter(Boolean).join(' · ')),
6300
+ x.ipChanged ? h('div', { class: 'muted small' }, t('net.ipChanged')) : null)
6301
+ })
6302
+ const skipped = n.accounts.filter((a) => a.skip === 'third-party' || a.skip === 'at-launch')
6303
+ const body = [
6304
+ h('p', { class: 'small' }, t('net.explain')),
6305
+ h('div', { class: 'row-actions' },
6306
+ h('button', { class: 'btn btn-sm', type: 'button', 'data-key': 'net-ask', onclick: askNetwork }, icon('bot'), t('ask.title.network'))),
6307
+ sw,
6308
+ h('div', { class: 'set-label' }, t('net.allow')),
6309
+ countries,
6310
+ !net.allow.length ? h('p', { class: 'small muted', 'data-enter': 'net-pick' }, t('net.pickFirst')) : null,
6311
+ h('div', { class: 'set-row' }, h('span', { class: 'set-label' }, t('net.now')),
6312
+ h('button', { class: 'btn btn-sm', type: 'button', 'data-key': 'net-check', disabled: net.checking, 'aria-busy': net.checking ? 'true' : null, onclick: netCheck }, net.checking ? spinner() : icon('refresh'), t('net.recheck'))),
6313
+ rows.length ? h('ul', { class: 'rc-list', 'data-patch': '' }, rows) : h('p', { class: 'small muted' }, t('net.noTargets')),
6314
+ skipped.length ? h('p', { class: 'small muted' }, t('net.skipped', { refs: skipped.map((a) => a.ref).join(', ') })) : null,
6315
+ h('p', { class: 'small muted' }, t('net.notCovered')),
6316
+ BOOT.readOnly ? h('p', { class: 'small' }, t('rc.readOnlyBoth')) : null,
6317
+ ]
6318
+ const foot = [h('button', { class: 'btn', type: 'button', 'data-key': 'net-close', onclick: () => dlg.el.close() }, t('btn.close'))]
6319
+ const frame = dialogFrame(t('net.title'), null, body, foot)
6320
+ // Patched in place, so the state refreshing every few seconds redraws only what changed (a row's "checked … ago").
6321
+ frame[1].setAttribute('data-patch', '')
6322
+ patchEnter(dlg.el, frame)
6323
+ }
6324
+ // Let AI do it (spec §3.28): the AI asks which countries, shows the change and writes it after the user agrees.
6325
+ function askNetwork() {
6326
+ const n = netState()
6327
+ if (!n) return
6328
+ openAsk({ task: 'network', context: { network: networkTaskFacts(n), version: BOOT.version } })
6329
+ }
6330
+ // Where the problem shows: a banner on every page while the guard is on and the exit is wrong or unknown.
6331
+ function netBanner() {
6332
+ const x = netProblem()
6333
+ if (!x) return null
6334
+ const n = netState()
6335
+ const text = x.status === 'blocked'
6336
+ ? t('net.bannerBlocked', { cty: netCountry(x.loc), allow: netList(n.allow.map(netCountry)) })
6337
+ : t('net.bannerUnknown', { why: x.error || '' })
6338
+ return h('div', { class: 'banner banner-warn', role: 'status', 'data-enter': 'net-banner' },
6339
+ h('div', null, h('b', null, t('net.bannerTitle') + (lang === 'zh' ? '' : ' ')), text),
6340
+ h('div', { class: 'banner-actions' },
6341
+ h('button', { class: 'btn btn-sm btn-primary', type: 'button', 'data-key': 'net-banner-check', disabled: Boolean(net && net.checking), 'aria-busy': net && net.checking ? 'true' : null, onclick: netCheck }, net && net.checking ? spinner() : null, t('net.recheck')),
6342
+ h('button', { class: 'btn btn-sm', type: 'button', onclick: openNet }, t('net.title')),
6343
+ h('button', { class: 'btn btn-sm', type: 'button', onclick: askNetwork }, icon('bot'), t('ask.title.network'))))
6344
+ }
6174
6345
  function openRc() {
6175
6346
  if (!S.state || !rcSummary()) return
6176
6347
  rc.target = null
@@ -7099,6 +7270,8 @@ const MAIN = String.raw `
7099
7270
  if (rcBanner) out.push(rcBanner)
7100
7271
  const inbBanner = inboundBanner()
7101
7272
  if (inbBanner) out.push(inbBanner)
7273
+ const nb = netBanner()
7274
+ if (nb) out.push(nb)
7102
7275
  const errs = S.state.pluginErrors
7103
7276
  if (errs.length) out.push(h('div', { class: 'banner banner-warn', role: 'status' }, h('div', null,
7104
7277
  h('b', null, tn('banner.plugins', errs.length) + ' '), t('banner.pluginsHint'),
@@ -559,16 +559,24 @@ a.btn:hover { text-decoration: none; }
559
559
  .error-note { justify-content: space-between; gap: 12px; }
560
560
  .error-note > span { min-width: 0; overflow-wrap: anywhere; }
561
561
  .error-note > .note-sub { flex-basis: 100%; color: var(--text); }
562
- .banner { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 11px 14px; border-radius: calc(var(--radius) - 2px); margin-bottom: 12px; border: 1px solid var(--border); background: var(--surface); }
562
+ .banner { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 11px 14px; border-radius: calc(var(--radius) - 2px); margin-bottom: 12px; border: 1px solid var(--border); background: var(--surface); }
563
563
  .banner > div { min-width: 0; }
564
+ /* The text takes the room; buttons that no longer fit beside it move below it instead of squeezing it. */
565
+ .banner > div:not(.banner-actions) { flex: 1 1 260px; }
564
566
  .banner-quiet { padding: 8px 14px; background: transparent; border-style: dashed; }
565
567
  .banner-fail { background: var(--fail-soft); border-color: transparent; color: var(--fail); }
566
568
  .banner-warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
567
569
  .banner ul { margin: 6px 0 0; padding-left: 18px; }
570
+ .net-countries { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 2px; }
571
+ .net-cty { display: inline-flex; align-items: center; gap: 4px; height: var(--ctl-h-sm); padding: 0 10px; border: 1px solid var(--border-strong); border-radius: 999px; background: var(--surface); color: var(--text); font: inherit; font-size: var(--control-size); cursor: pointer; transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease; }
572
+ .net-cty:hover { background: var(--hover); }
573
+ .net-cty[aria-pressed=true] { background: var(--active); border-color: var(--accent); font-weight: var(--strong-weight); }
574
+ .net-cty .chip { margin-left: 2px; }
575
+ @media (prefers-reduced-motion: reduce) { .net-cty { transition: none; } }
568
576
  .rc-list { list-style: none; margin: 10px 0; padding: 0; display: grid; gap: 8px; }
569
577
  .rc-row { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; display: grid; gap: 2px; }
570
578
  .rc-row code { word-break: break-all; }
571
- .banner-actions { display: flex; gap: 8px; flex: none; }
579
+ .banner-actions { display: flex; flex-wrap: wrap; gap: 8px; flex: 0 1 auto; }
572
580
  .hp-rules { list-style: none; margin: 0; padding: 0; counter-reset: hp-rule; display: flex; flex-direction: column; }
573
581
  .hp-rules > li { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--border); }
574
582
  .hp-rules > li:last-child { border-bottom: 0; }
@@ -983,7 +991,7 @@ select:is(:hover, :focus) { --chevron: var(--text); }
983
991
  .tagline { display: none; }
984
992
  .brand .logo { width: 34px; height: 34px; }
985
993
  .brand h1 { font-size: 19px; }
986
- .banner { flex-direction: column; }
994
+ .banner > div:not(.banner-actions) { flex-basis: 100%; }
987
995
  .stat { padding: 11px 13px; align-items: flex-start; flex-direction: column; gap: 6px; }
988
996
  .stat-value { font-size: 19px; }
989
997
  .stat-sub { white-space: normal; }