sideby 0.35.6 → 0.35.8

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 (63) hide show
  1. package/dist/build.json +1 -1
  2. package/dist/src/cli/commands.d.ts +9 -1
  3. package/dist/src/cli/commands.js +59 -16
  4. package/dist/src/cli/json-schemas.js +20 -0
  5. package/dist/src/cli/main.js +11 -5
  6. package/dist/src/core/cli-commands.js +1 -1
  7. package/dist/src/core/config.d.ts +7 -0
  8. package/dist/src/core/config.js +9 -0
  9. package/dist/src/core/doctor.d.ts +5 -1
  10. package/dist/src/core/doctor.js +16 -0
  11. package/dist/src/core/edit-settings.d.ts +27 -1
  12. package/dist/src/core/edit-settings.js +78 -4
  13. package/dist/src/core/handoff-select.d.ts +3 -1
  14. package/dist/src/core/handoff-select.js +11 -1
  15. package/dist/src/core/handoff.d.ts +13 -1
  16. package/dist/src/core/handoff.js +16 -5
  17. package/dist/src/core/history-index.d.ts +4 -0
  18. package/dist/src/core/history-index.js +46 -17
  19. package/dist/src/core/history-project.js +15 -2
  20. package/dist/src/core/history.d.ts +11 -1
  21. package/dist/src/core/history.js +70 -16
  22. package/dist/src/core/login-mark.d.ts +3 -0
  23. package/dist/src/core/login-mark.js +22 -0
  24. package/dist/src/core/pick-commands.d.ts +4 -2
  25. package/dist/src/core/pick-commands.js +7 -2
  26. package/dist/src/core/quota-fetch.d.ts +7 -1
  27. package/dist/src/core/quota-fetch.js +38 -1
  28. package/dist/src/core/quota-store.d.ts +5 -0
  29. package/dist/src/core/quota-store.js +3 -0
  30. package/dist/src/core/search-catalog.js +9 -0
  31. package/dist/src/families/claude/index.js +3 -0
  32. package/dist/src/families/claude/login-events.d.ts +24 -0
  33. package/dist/src/families/claude/login-events.js +163 -0
  34. package/dist/src/families/claude/quota-fetch.js +14 -0
  35. package/dist/src/families/grok/bot.d.ts +6 -3
  36. package/dist/src/families/grok/bot.js +15 -4
  37. package/dist/src/menubar/snapshot.d.ts +2 -0
  38. package/dist/src/menubar/snapshot.js +6 -2
  39. package/dist/src/menubar/strings.d.ts +4 -0
  40. package/dist/src/menubar/strings.js +4 -0
  41. package/dist/src/panel/handler.d.ts +14 -1
  42. package/dist/src/panel/handler.js +48 -14
  43. package/dist/src/panel/i18n.d.ts +23 -0
  44. package/dist/src/panel/i18n.js +46 -0
  45. package/dist/src/panel/page-logic.d.ts +44 -2
  46. package/dist/src/panel/page-logic.js +43 -3
  47. package/dist/src/panel/page-script.js +124 -7
  48. package/dist/src/panel/page-styles.js +8 -0
  49. package/dist/src/panel/page.d.ts +7 -0
  50. package/dist/src/panel/page.js +1 -0
  51. package/dist/src/runtime.d.ts +16 -1
  52. package/dist/src/runtime.js +51 -2
  53. package/dist/src/types.d.ts +37 -0
  54. package/package.json +3 -3
  55. package/schemas/config.json +11 -0
  56. package/schemas/edit.json +4 -0
  57. package/schemas/list.json +24 -0
  58. package/schemas/next.json +18 -0
  59. package/skills/sideby/SKILL.md +4 -2
  60. package/skills/sideby/references/accounts.md +9 -0
  61. package/skills/sideby/references/diagnose.md +6 -1
  62. package/skills/sideby/references/panel.md +1 -1
  63. package/skills/sideby/references/unattended.md +1 -1
@@ -161,6 +161,8 @@ const en = {
161
161
  'need.health-fail.other': '{n} with issues',
162
162
  'need.signed-out.one': '{n} signed out',
163
163
  'need.signed-out.other': '{n} signed out',
164
+ 'need.login-expired.one': '{n} sign-in expired',
165
+ 'need.login-expired.other': '{n} sign-ins expired',
164
166
  'need.not-installed.one': '{n} tool missing',
165
167
  'need.not-installed.other': '{n} tool missing',
166
168
  'need.quota-high.one': '{n} near limit',
@@ -170,6 +172,7 @@ const en = {
170
172
  'why.error': 'unreadable',
171
173
  'why.health-fail': 'Health check found issues',
172
174
  'why.signed-out': 'signed out',
175
+ 'why.login-expired': 'sign-in expired',
173
176
  'why.not-installed': 'tool not installed',
174
177
  'why.broken': 'tool install broken',
175
178
  'why.quota-high': '{label} at {pct}% (warns from {warn}%)',
@@ -274,6 +277,18 @@ const en = {
274
277
  'acct.api': 'API',
275
278
  'acct.model': 'Model',
276
279
  'acct.signedOut': 'Signed out',
280
+ 'acct.expired': 'Sign-in expired',
281
+ 'acct.expiredIn': 'Sign-in expired: {name}',
282
+ 'acct.expiredWaiting': 'Sign-in finished, waiting for confirmation',
283
+ 'acct.expiredHint': '{ref}: Claude Code said its sign-in expired{since}. Sign in again to use it; sideby will not pick it until then.',
284
+ 'acct.expiredWaitingHint': '{ref}: the sign-in finished. The mark goes away after its next session or quota check confirms it.',
285
+ 'acct.expiredSince': ' at {time}',
286
+ 'acct.signInAgain': 'Sign in again',
287
+ 'acct.signInName': 'Sign in {name}',
288
+ 'exp.banner.one': '{refs}: sign-in expired. Sign in again to use it; until then sideby will not pick it.',
289
+ 'exp.banner.other': '{refs}: sign-ins expired. Sign in again to use them; until then sideby will not pick them.',
290
+ 'exp.signIn': 'Sign in again',
291
+ 'exp.signInRef': 'Sign in {ref} again',
277
292
  'acct.signInHint': 'Copy the sign-in command',
278
293
  'acct.signedOutLabel': '{ref} is signed out: copy the sign-in command',
279
294
  'acct.next': 'Suggested',
@@ -458,6 +473,7 @@ const en = {
458
473
  'ai.ask.handoffRules': 'When does Auto Handoff switch accounts, and could it use my API accounts?',
459
474
  'ai.ask.rc': 'Turn off Remote Control for every Claude account.',
460
475
  'ai.ask.relogin': 'Two of my accounts are the same login; help me sign one in with another account.',
476
+ 'ai.ask.expired': 'Which of my accounts has an expired sign-in? Help me sign it in again.',
461
477
  'ai.orderHint': 'or ask your AI',
462
478
  'ai.emptyHint': 'Or let your AI assistant set it up for you.',
463
479
  'ai.how': 'How',
@@ -755,6 +771,8 @@ const en = {
755
771
  'edit.opened': 'Opened {ref}’s {file} with your default program.',
756
772
  'edit.shared': 'This file is shared: a change also applies to {names}.',
757
773
  'edit.failed': 'Could not open {file} for {ref}: {msg}',
774
+ 'edit.openedWith': 'Opened {ref}’s {file} in {app}.',
775
+ 'edit.noPath': 'the panel did not get the file’s path; reload the page and try again',
758
776
  'menu.like': 'New account like this',
759
777
  'menu.tune': 'Context tuning',
760
778
  'menu.model': 'Model and effort…',
@@ -1348,6 +1366,11 @@ const en = {
1348
1366
  'set.button': 'Settings',
1349
1367
  'set.lang': 'Language',
1350
1368
  'set.theme': 'Light or dark',
1369
+ 'set.editor': 'Open settings files in',
1370
+ 'set.editor.system': 'Default app',
1371
+ 'set.editor.hint': 'Used by “Open settings.json” in each account’s ⋯ menu and by sideby edit. Pick your editor if the default app shows a window but not the file.',
1372
+ 'set.editor.portal': 'On this page the file opens in the app chosen under “Open in” of the page around the panel; this choice is for sideby edit and the panel opened on its own.',
1373
+ 'set.editor.saved': 'Settings files now open in {app}.',
1351
1374
  'set.theme.system': 'System',
1352
1375
  'set.theme.light': 'Light',
1353
1376
  'set.theme.dark': 'Dark',
@@ -1788,6 +1811,8 @@ const zh = {
1788
1811
  'need.health-fail.other': '{n} 个有问题',
1789
1812
  'need.signed-out.one': '{n} 个未登录',
1790
1813
  'need.signed-out.other': '{n} 个未登录',
1814
+ 'need.login-expired.one': '{n} 个登录已过期',
1815
+ 'need.login-expired.other': '{n} 个登录已过期',
1791
1816
  'need.not-installed.one': '{n} 个缺少工具',
1792
1817
  'need.not-installed.other': '{n} 个缺少工具',
1793
1818
  'need.quota-high.one': '{n} 个接近上限',
@@ -1797,6 +1822,7 @@ const zh = {
1797
1822
  'why.error': '读取失败',
1798
1823
  'why.health-fail': '体检发现问题',
1799
1824
  'why.signed-out': '未登录',
1825
+ 'why.login-expired': '登录已过期',
1800
1826
  'why.not-installed': '缺少工具',
1801
1827
  'why.broken': '工具安装已损坏',
1802
1828
  'why.quota-high': '{label} 已用 {pct}%({warn}% 起提醒)',
@@ -1901,6 +1927,18 @@ const zh = {
1901
1927
  'acct.api': 'API',
1902
1928
  'acct.model': '模型',
1903
1929
  'acct.signedOut': '未登录',
1930
+ 'acct.expired': '登录已过期',
1931
+ 'acct.expiredIn': '登录已过期:{name}',
1932
+ 'acct.expiredWaiting': '已重新登录,等待确认',
1933
+ 'acct.expiredHint': '{ref}:Claude Code 说它的登录已过期{since}。重新登录后才能用;在那之前 sideby 不会选它。',
1934
+ 'acct.expiredWaitingHint': '{ref}:登录已完成。下一次会话或额度查询确认后,这个标记会消失。',
1935
+ 'acct.expiredSince': '({time})',
1936
+ 'acct.signInAgain': '重新登录',
1937
+ 'acct.signInName': '重新登录 {name}',
1938
+ 'exp.banner.one': '{refs} 的登录已过期。重新登录后才能用;在那之前 sideby 不会选它。',
1939
+ 'exp.banner.other': '{refs} 的登录已过期。重新登录后才能用;在那之前 sideby 不会选它们。',
1940
+ 'exp.signIn': '重新登录',
1941
+ 'exp.signInRef': '重新登录 {ref}',
1904
1942
  'acct.signInHint': '复制登录命令',
1905
1943
  'acct.signedOutLabel': '{ref} 未登录:复制登录命令',
1906
1944
  'acct.next': '建议使用',
@@ -2085,6 +2123,7 @@ const zh = {
2085
2123
  'ai.ask.handoffRules': '自动接力什么时候换号?会不会用到我的 API 账号?',
2086
2124
  'ai.ask.rc': '把所有 Claude 账号的远程控制关掉。',
2087
2125
  'ai.ask.relogin': '我有两个账号登录的是同一个号,帮我把其中一个换成别的账号。',
2126
+ 'ai.ask.expired': '哪个账号登录过期了?帮我重新登录。',
2088
2127
  'ai.orderHint': '也可以让 AI 帮你排',
2089
2128
  'ai.emptyHint': '也可以让你的 AI 编程助手帮你装好、加账号。',
2090
2129
  'ai.how': '怎么做',
@@ -2382,6 +2421,8 @@ const zh = {
2382
2421
  'edit.opened': '已用默认程序打开 {ref} 的 {file}。',
2383
2422
  'edit.shared': '这个文件是共用的,改动对 {names} 也生效。',
2384
2423
  'edit.failed': '没能打开 {ref} 的 {file}:{msg}',
2424
+ 'edit.openedWith': '已用 {app} 打开 {ref} 的 {file}。',
2425
+ 'edit.noPath': '面板没拿到文件路径;刷新页面后再试一次',
2385
2426
  'menu.like': '照此新建账号',
2386
2427
  'menu.tune': '上下文调优',
2387
2428
  'menu.model': '模型和 effort…',
@@ -2975,6 +3016,11 @@ const zh = {
2975
3016
  'set.button': '设置',
2976
3017
  'set.lang': '语言',
2977
3018
  'set.theme': '明暗',
3019
+ 'set.editor': '设置文件用什么打开',
3020
+ 'set.editor.system': '默认程序',
3021
+ 'set.editor.hint': '账号「⋯」菜单里的「打开 settings.json」和 sideby edit 都用它。默认程序只弹出窗口、没打开文件时,选你的编辑器。',
3022
+ 'set.editor.portal': '在这个页面里,文件用外层页面「打开方式」里选的应用打开;这里的选择给 sideby edit 和单独打开的面板用。',
3023
+ 'set.editor.saved': '设置文件改为用 {app} 打开。',
2978
3024
  'set.theme.system': '跟随系统',
2979
3025
  'set.theme.light': '浅色',
2980
3026
  'set.theme.dark': '深色',
@@ -33,6 +33,12 @@ export interface LogicAccount {
33
33
  };
34
34
  /** The other Accounts of its Same Login (spec §3.21). */
35
35
  sameLogin?: string[];
36
+ /** Its Expired Login (ADR-0071). */
37
+ loginProblem?: {
38
+ kind: string;
39
+ since?: string;
40
+ signedInAt?: string;
41
+ };
36
42
  usage?: LogicUsage;
37
43
  }
38
44
  /** The parts of an Account's usage the helpers read. */
@@ -116,7 +122,8 @@ export declare function passedWindow(w: {
116
122
  /** The fullest live Quota window in percent, or -1 when the Account has no Quota data. */
117
123
  export declare function quotaPressure(a: LogicAccount, now: number): number;
118
124
  /**
119
- * Why an Account needs a look, most serious first: `error`, `health-fail`, `signed-out`, `not-installed`,
125
+ * Why an Account needs a look, most serious first: `error`, `health-fail`, `signed-out`, `login-expired` (ADR-0071),
126
+ * `not-installed`,
120
127
  * `quota-high` (a live window at or over the warning level), `health-warn`. Empty when all is well. A Quota read from
121
128
  * another Account of the same login (`quota.from`, spec §3.21) is that Account's warning, so it counts once per group.
122
129
  */
@@ -134,13 +141,18 @@ longWarn?: number): string[];
134
141
  export declare function quotaHighLevel(a: LogicAccount, now: number, fail: number, longFail?: number): 'warn' | 'fail';
135
142
  /**
136
143
  * The one status badge an account row shows after its name (spec §3.27), most important first: `health-fail`
137
- * (needs fixing), `quota-high` (running low), the other attention labels (`signed-out`, `not-installed`,
144
+ * (needs fixing; an Expired Login, `login-expired`, before it), `quota-high` (running low), the other attention labels (`signed-out`, `not-installed`,
138
145
  * `health-warn`), then `next` (recommended) and last `api`. Null when none applies. `reasons` are attentionReasons'.
139
146
  */
140
147
  export declare function rowBadge(reasons: string[], opts: {
141
148
  next?: boolean;
142
149
  api?: boolean;
143
150
  }): string | null;
151
+ /**
152
+ * The Accounts whose sign-in expired (ADR-0071), API Accounts never, in the order given: what the Panel's summary
153
+ * banner names. Its content changes only when this list does, so a refresh with the same answer redraws nothing.
154
+ */
155
+ export declare function expiredLogins<T extends LogicAccount>(accounts: readonly T[]): T[];
144
156
  /**
145
157
  * The most serious reason an Account needs a look, as a message key and its values for the Panel to show where the
146
158
  * attention count is: `why.<reason>`; for `quota-high` the fullest live window at or over `warn`, with its label and
@@ -717,6 +729,36 @@ export declare function askBridge(boot: {
717
729
  origin: string;
718
730
  };
719
731
  }): boolean;
732
+ /**
733
+ * Whether "Open settings.json" hands the file to the Portal around the Panel (spec §3.30, ADR-0033 amendment):
734
+ * createPanelHandler was given `open: { bridge: 'postMessage' }` and the page sits in a frame. A Panel opened on its
735
+ * own is its own parent; its server opens the file.
736
+ */
737
+ export declare function openBridged(boot: {
738
+ open?: {
739
+ bridge?: string;
740
+ } | null;
741
+ }, win: {
742
+ parent: unknown;
743
+ }): boolean;
744
+ /**
745
+ * Hands a file to the Portal around the Panel when `openBridged` says so: posts
746
+ * `{ type: 'local-tools:open', version: 1, path }` (an absolute path, never the file's content) to the parent with the
747
+ * Panel's own origin as the target, and says it did. Otherwise, or for a path that is not absolute, posts nothing and
748
+ * returns false.
749
+ */
750
+ export declare function openBridge(boot: {
751
+ open?: {
752
+ bridge?: string;
753
+ } | null;
754
+ }, path: unknown, win: {
755
+ parent: {
756
+ postMessage(message: unknown, targetOrigin: string): void;
757
+ } | null;
758
+ location: {
759
+ origin: string;
760
+ };
761
+ }): boolean;
720
762
  /**
721
763
  * Whether a `message` event asks the Panel to read its state again (ADR-0006, 2026-11-02 amendment): the Portal around
722
764
  * it changed something the Panel shows (its own Unattended switch, say) and posted
@@ -181,7 +181,8 @@ export function quotaPressure(a, now) {
181
181
  return windows.length && max < 0 ? 0 : max;
182
182
  }
183
183
  /**
184
- * Why an Account needs a look, most serious first: `error`, `health-fail`, `signed-out`, `not-installed`,
184
+ * Why an Account needs a look, most serious first: `error`, `health-fail`, `signed-out`, `login-expired` (ADR-0071),
185
+ * `not-installed`,
185
186
  * `quota-high` (a live window at or over the warning level), `health-warn`. Empty when all is well. A Quota read from
186
187
  * another Account of the same login (`quota.from`, spec §3.21) is that Account's warning, so it counts once per group.
187
188
  */
@@ -195,6 +196,8 @@ longWarn = warn) {
195
196
  out.push('health-fail');
196
197
  if (a.login === 'logged-out' && a.kind !== 'api')
197
198
  out.push('signed-out');
199
+ else if (a.loginProblem?.kind === 'expired' && a.kind !== 'api')
200
+ out.push('login-expired');
198
201
  if (a.hostInstalled === false)
199
202
  out.push('not-installed');
200
203
  const q = a.quota;
@@ -236,11 +239,19 @@ export function quotaHighLevel(a, now, fail, longFail = fail) {
236
239
  }
237
240
  /**
238
241
  * The one status badge an account row shows after its name (spec §3.27), most important first: `health-fail`
239
- * (needs fixing), `quota-high` (running low), the other attention labels (`signed-out`, `not-installed`,
242
+ * (needs fixing; an Expired Login, `login-expired`, before it), `quota-high` (running low), the other attention labels (`signed-out`, `not-installed`,
240
243
  * `health-warn`), then `next` (recommended) and last `api`. Null when none applies. `reasons` are attentionReasons'.
241
244
  */
242
245
  export function rowBadge(reasons, opts) {
243
- for (const r of ['health-fail', 'quota-high', 'signed-out', 'not-installed', 'health-warn'])
246
+ // An Expired Login comes first: the account cannot start, so its quota or health says little (ADR-0071).
247
+ for (const r of [
248
+ 'login-expired',
249
+ 'health-fail',
250
+ 'quota-high',
251
+ 'signed-out',
252
+ 'not-installed',
253
+ 'health-warn',
254
+ ])
244
255
  if (reasons.includes(r))
245
256
  return r;
246
257
  if (opts.next)
@@ -249,6 +260,13 @@ export function rowBadge(reasons, opts) {
249
260
  return 'api';
250
261
  return null;
251
262
  }
263
+ /**
264
+ * The Accounts whose sign-in expired (ADR-0071), API Accounts never, in the order given: what the Panel's summary
265
+ * banner names. Its content changes only when this list does, so a refresh with the same answer redraws nothing.
266
+ */
267
+ export function expiredLogins(accounts) {
268
+ return accounts.filter((a) => a.kind !== 'api' && a.loginProblem?.kind === 'expired');
269
+ }
252
270
  /**
253
271
  * The most serious reason an Account needs a look, as a message key and its values for the Panel to show where the
254
272
  * attention count is: `why.<reason>`; for `quota-high` the fullest live window at or over `warn`, with its label and
@@ -1264,6 +1282,28 @@ export function askBridge(boot, opts, win) {
1264
1282
  }, win.location.origin);
1265
1283
  return true;
1266
1284
  }
1285
+ /**
1286
+ * Whether "Open settings.json" hands the file to the Portal around the Panel (spec §3.30, ADR-0033 amendment):
1287
+ * createPanelHandler was given `open: { bridge: 'postMessage' }` and the page sits in a frame. A Panel opened on its
1288
+ * own is its own parent; its server opens the file.
1289
+ */
1290
+ export function openBridged(boot, win) {
1291
+ return boot.open?.bridge === 'postMessage' && Boolean(win.parent) && win.parent !== win;
1292
+ }
1293
+ /**
1294
+ * Hands a file to the Portal around the Panel when `openBridged` says so: posts
1295
+ * `{ type: 'local-tools:open', version: 1, path }` (an absolute path, never the file's content) to the parent with the
1296
+ * Panel's own origin as the target, and says it did. Otherwise, or for a path that is not absolute, posts nothing and
1297
+ * returns false.
1298
+ */
1299
+ export function openBridge(boot, path, win) {
1300
+ if (!openBridged(boot, win) || !win.parent)
1301
+ return false;
1302
+ if (typeof path !== 'string' || !/^(\/|[A-Za-z]:[\\/])/.test(path))
1303
+ return false;
1304
+ win.parent.postMessage({ type: 'local-tools:open', version: 1, path }, win.location.origin);
1305
+ return true;
1306
+ }
1267
1307
  /**
1268
1308
  * Whether a `message` event asks the Panel to read its state again (ADR-0006, 2026-11-02 amendment): the Portal around
1269
1309
  * it changed something the Panel shows (its own Unattended switch, say) and posted
@@ -5,13 +5,15 @@ import { groupsToAccept } from '../core/inbound.js';
5
5
  import { quotaIsStale } from '../core/quota-levels.js';
6
6
  import { remoteControlTodo } from '../core/remote-control.js';
7
7
  import { catalogMatchLevel, catalogNorm, searchCatalog } from '../core/search-catalog.js';
8
- import { accountTitle, aiTaskAccounts, aliasArgsOf, aliasIssue, aliasPrefix, askBridge, askBridged, askCopy, askPermissionNote, 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, longWindow, maskEmail, matchesQuery, mdBlocks, mdInline, menuPlacement, mergeDaily, mergeUsage, messageChip, messageNews, messageToCheck, networkTaskFacts, newAccountDir, nextReset, orderedAliases, panelFixes, panelHint, panelLang, panelMigration, panelPrefs, passedWindow, pinnedIn, portalRefresh, quotaAskable, quotaHighLevel, quotaPressure, radioStep, reloadForBuild, remoteControlSummary, reorder, resetWhen, rowBadge, runCodeSwap, saveHandoffChange, sendBlock, sendFileProblem, sendResultView, sessionAge, sessionLabelParts, sessionRowShape, shortCwd, shortSessionLabel, sortAccounts, sortMenu, sortSessions, steadyOrder, stripSecrets, suggestAlias, suggestName, switchFailure, tailInView, taskFindings, uaDayRuns, uaGroupPending, uaOnChoices, uaParseClock, uaPickTime, uaSameSlot, uaShouldRead, uaSlotNight, uaStatusParts, uaStepClock, uaToggleDay, uaWaitingCount, uaWhen, updatedAge, vendorAlias, widthFollower, widthTier, windowState, withPinned, } from './page-logic.js';
8
+ import { accountTitle, aiTaskAccounts, aliasArgsOf, aliasIssue, aliasPrefix, askBridge, askBridged, askCopy, askPermissionNote, attentionReasons, attentionWhy, autostartNote, bindingWindow, cacheHitRate, canLeaveLocal, categoryOrder, codeSwapOutcome, dotsKeepKeyboard, enableOutcome, expiredLogins, fileSize, fixPrompt, foldSkips, foldToolCalls, formatDuration, handoffChangeOf, handoffHintAccount, handoffTaskFacts, hiddenIn, highlightParts, histFilters, historyEmpty, historyWhen, hotkeyFromKey, hotkeyPressKind, inDisplayOrder, loginClusters, loginKey, longWindow, maskEmail, matchesQuery, mdBlocks, mdInline, menuPlacement, mergeDaily, mergeUsage, messageChip, messageNews, messageToCheck, networkTaskFacts, newAccountDir, nextReset, openBridge, openBridged, orderedAliases, panelFixes, panelHint, panelLang, panelMigration, panelPrefs, passedWindow, pinnedIn, portalRefresh, quotaAskable, quotaHighLevel, quotaPressure, radioStep, reloadForBuild, remoteControlSummary, reorder, resetWhen, rowBadge, runCodeSwap, saveHandoffChange, sendBlock, sendFileProblem, sendResultView, sessionAge, sessionLabelParts, sessionRowShape, shortCwd, shortSessionLabel, sortAccounts, sortMenu, sortSessions, steadyOrder, stripSecrets, suggestAlias, suggestName, switchFailure, tailInView, taskFindings, uaDayRuns, uaGroupPending, uaOnChoices, uaParseClock, uaPickTime, uaSameSlot, uaShouldRead, uaSlotNight, uaStatusParts, uaStepClock, uaToggleDay, uaWaitingCount, uaWhen, updatedAge, vendorAlias, widthFollower, widthTier, windowState, withPinned, } from './page-logic.js';
9
9
  // The component library's dropdown menu, copied by the brand repo's add script (--html into ui/); do not edit it.
10
10
  import { CHECK, menuItem, menuScript } from './ui/dropdown-menu/dropdown-menu.html.js';
11
11
  import { cn, esc } from './ui/lib/cn.js';
12
12
  const LOGIC = [
13
13
  quotaIsStale,
14
14
  portalRefresh,
15
+ openBridge,
16
+ openBridged,
15
17
  catalogNorm,
16
18
  catalogMatchLevel,
17
19
  searchCatalog,
@@ -31,6 +33,7 @@ const LOGIC = [
31
33
  accountTitle,
32
34
  vendorAlias,
33
35
  attentionReasons,
36
+ expiredLogins,
34
37
  attentionWhy,
35
38
  quotaHighLevel,
36
39
  autostartNote,
@@ -1100,13 +1103,43 @@ const MAIN = String.raw `
1100
1103
  if (!file || !a.dir || BOOT.readOnly) return null
1101
1104
  return { icon: 'file', label: t('menu.editSettings', { file }), hint: a.dir + '/' + file, run: () => editSettings(a, file) }
1102
1105
  }
1106
+ // In a Portal that opens files itself (createPanelHandler's open bridge), the server only says where the real file
1107
+ // is and the Portal opens it with the app chosen there, and says so; otherwise the server opens it (config editor).
1103
1108
  async function editSettings(a, file) {
1104
1109
  try {
1105
- const r = await api('/api/account/edit-settings', { account: a.ref })
1106
- toast(t('edit.opened', { ref: a.ref, file }))
1110
+ const bridged = openBridged(BOOT, window)
1111
+ const r = await api('/api/account/edit-settings', bridged ? { account: a.ref, open: false } : { account: a.ref })
1112
+ if (bridged) { if (!openBridge(BOOT, r.realPath, window)) throw new Error(t('edit.noPath')) }
1113
+ else toast(t(r.editor && r.editor !== 'system' ? 'edit.openedWith' : 'edit.opened', { ref: a.ref, file, app: editorName(r.editor) }))
1107
1114
  if (r.sharedWith && r.sharedWith.length) toast(t('edit.shared', { names: r.sharedWith.map(refName).join(', ') }), { kind: 'info', duration: 8000 })
1108
1115
  } catch (e) { toast(t('edit.failed', { ref: a.ref, file, msg: e.message }), { kind: 'fail' }) }
1109
1116
  }
1117
+ // config editor (spec §3.30): the choices of the Settings row, in the order of EDITORS.
1118
+ const EDITOR_CHOICES = [['system', ''], ['cursor', 'Cursor'], ['vscode', 'VS Code'], ['windsurf', 'Windsurf'], ['zed', 'Zed']]
1119
+ function editorName(id) { const c = EDITOR_CHOICES.find((x) => x[0] === id); return c && c[1] ? c[1] : t('set.editor.system') }
1120
+ let editorSaving = null
1121
+ function editorNow() { return editorSaving || (S.state && S.state.editor) || 'system' }
1122
+ async function setEditor(v) {
1123
+ if (v === editorNow()) return
1124
+ editorSaving = v
1125
+ refreshSettings()
1126
+ try {
1127
+ const r = await api('/api/editor', { editor: v })
1128
+ if (S.state) S.state.editor = r.editor
1129
+ toast(t('set.editor.saved', { app: editorName(r.editor) }))
1130
+ } catch (e) { toast(t('set.saveFailed', { msg: e.message }), { kind: 'fail' }) }
1131
+ editorSaving = null
1132
+ refreshSettings()
1133
+ }
1134
+ // The Settings row. In a Portal that opens files itself, the Portal's own choice opens them here, so the row says so.
1135
+ function editorRow() {
1136
+ const label = t('set.editor')
1137
+ const cur = editorNow()
1138
+ return h('div', { class: 'set-row set-stack' },
1139
+ h('div', { class: 'set-text' }, h('span', { class: 'set-label' }, label), h('span', { class: 'set-hint' }, t(openBridged(BOOT, window) ? 'set.editor.portal' : 'set.editor.hint'))),
1140
+ h('div', { class: 'seg', role: 'group', 'aria-label': label }, EDITOR_CHOICES.map(([v, text]) =>
1141
+ h('button', { class: 'seg-btn', type: 'button', 'aria-pressed': String(v === cur), disabled: Boolean(editorSaving), onclick: () => setEditor(v) }, text || t('set.editor.system')))))
1142
+ }
1110
1143
  // What the login does, whichever directory: the browser, signing in, the email, a new account like it.
1111
1144
  function loginItems(a) {
1112
1145
  return [
@@ -1327,7 +1360,7 @@ const MAIN = String.raw `
1327
1360
  if (rs.length) need++
1328
1361
  for (const r of rs) counts[r] = (counts[r] || 0) + 1
1329
1362
  }
1330
- const order = ['error', 'health-fail', 'signed-out', 'not-installed', 'quota-high', 'health-warn']
1363
+ const order = ['error', 'health-fail', 'signed-out', 'login-expired', 'not-installed', 'quota-high', 'health-warn']
1331
1364
  // Who needs a look, by name: counting reasons beside a count of accounts made numbers that did not add up. One name
1332
1365
  // and a count, as two names did not fit the card.
1333
1366
  const needing = list.filter((a) => reasonsOf(a, now).length)
@@ -1616,8 +1649,17 @@ const MAIN = String.raw `
1616
1649
  function statusBadge(a, members) {
1617
1650
  const subject = attentionSubject(a)
1618
1651
  const next = members ? members.some(isNext) : isNext(a)
1619
- const k = rowBadge(reasonsOf(subject, Date.now()), { next, api: a.kind === 'api' })
1620
- if (k === 'health-fail' || k === 'quota-high' || k === 'health-warn') return attentionWord(subject, k)
1652
+ // A Same Login row speaks for every directory in it: an expired one is named (ADR-0071).
1653
+ const expired = expiredLogins(members || [a])
1654
+ const reasons = reasonsOf(subject, Date.now())
1655
+ if (expired.length && !reasons.includes('login-expired')) reasons.push('login-expired')
1656
+ const k = rowBadge(reasons, { next, api: a.kind === 'api' })
1657
+ if (k === 'login-expired') return expiredBadge(expired, Boolean(members && members.length > 1), a.ref)
1658
+ const now = k === 'health-fail' || k === 'quota-high' || k === 'health-warn' ? attentionWord(subject, k) : otherBadge(a, k)
1659
+ const leaving = expiredBadgeLeaving(a.ref)
1660
+ return leaving ? [leaving, now] : now
1661
+ }
1662
+ function otherBadge(a, k) {
1621
1663
  if (k === 'signed-out')
1622
1664
  return h('button', { class: 'tag tag-fail tag-btn', type: 'button', title: t('acct.signInHint'), 'aria-label': t('acct.signedOutLabel', { ref: a.ref }), onclick: (e) => { e.stopPropagation(); signIn(a) } }, h('span', { class: 'dot dot-fail', 'aria-hidden': 'true' }), t('acct.signedOut'))
1623
1665
  if (k === 'not-installed') return h('span', { class: 'tag tag-warn' }, t(family(a.family).brokenBin ? 'acct.broken' : 'acct.notInstalled'))
@@ -1625,6 +1667,45 @@ const MAIN = String.raw `
1625
1667
  if (k === 'api') return h('span', { class: 'tag tag-warn', title: t('tip.api.body') }, t('acct.api'))
1626
1668
  return null
1627
1669
  }
1670
+ // An Expired Login (ADR-0071): a word, and "Sign in again" beside it, which opens the sign-in in the terminal. In a
1671
+ // Same Login row the word names every expired directory, each with its own button. After a sign-in sideby started it
1672
+ // says it waits for confirmation. row is the ref of the row it sits in, so it can shrink away when it goes.
1673
+ function expiredBadge(list, named, row) {
1674
+ const waiting = list.every((m) => m.loginProblem && m.loginProblem.signedInAt)
1675
+ const why = list.map((m) => {
1676
+ const p = m.loginProblem || {}
1677
+ const since = p.since ? t('acct.expiredSince', { time: clock(p.since) }) : ''
1678
+ return p.signedInAt ? t('acct.expiredWaitingHint', { ref: m.ref }) : t('acct.expiredHint', { ref: m.ref, since })
1679
+ }).join('\n')
1680
+ const word = waiting ? t('acct.expiredWaiting') : named ? t('acct.expiredIn', { name: list.map((m) => m.name).join(', ') }) : t('acct.expired')
1681
+ const todo = BOOT.readOnly ? [] : list.filter((m) => !(m.loginProblem && m.loginProblem.signedInAt))
1682
+ const btn = (m) => h('button', { class: 'link-btn small', type: 'button', title: t('exp.signInRef', { ref: m.ref }), onclick: (e) => { e.stopPropagation(); signIn(m) } }, todo.length > 1 ? t('acct.signInName', { name: m.name }) : t('acct.signInAgain'))
1683
+ // It grows in once; the class goes after that, so a refresh with the same answer keeps this element.
1684
+ return h('span', { class: 'exp-badge', 'data-row': row, 'data-enter': 'exp-' + list.map((m) => m.ref).join(','), onanimationend: (e) => e.currentTarget.classList.remove('enter') },
1685
+ h('span', { class: 'tag tag-warn', title: why, 'aria-label': why }, h('span', { class: 'dot dot-warn', 'aria-hidden': 'true' }), word),
1686
+ todo.map(btn))
1687
+ }
1688
+ // The badge a row showed before its sign-in works again: kept for one more render while it fades and narrows to
1689
+ // nothing (180 ms, none under reduced motion), then the next render drops it.
1690
+ function expiredBadgeLeaving(row) {
1691
+ if (REDUCED) return null
1692
+ const old = document.querySelector('.exp-badge[data-row="' + CSS.escape(row) + '"]')
1693
+ if (!old || old.dataset.gone) return null
1694
+ if (old.dataset.leaving) return old
1695
+ old.dataset.leaving = '1'
1696
+ old.removeAttribute('data-enter')
1697
+ old.classList.remove('enter')
1698
+ old.style.pointerEvents = 'none'
1699
+ old.style.overflow = 'hidden'
1700
+ old.style.whiteSpace = 'nowrap'
1701
+ const w = old.offsetWidth
1702
+ setTimeout(() => {
1703
+ if (!old.isConnected) return
1704
+ old.animate([{ opacity: 1, maxWidth: w + 'px', marginLeft: '0px' }, { opacity: 0, maxWidth: '0px', marginLeft: '-8px' }], { duration: 180, easing: 'ease-in-out', fill: 'forwards' })
1705
+ setTimeout(() => { old.dataset.gone = '1'; renderAccounts() }, 190)
1706
+ }, 0)
1707
+ return old
1708
+ }
1628
1709
  // An Account's short commands, as quiet text after its title: those that only start it first, then those with Host
1629
1710
  // arguments; each says on hover what it adds. A card too narrow for all of them ends in an ellipsis.
1630
1711
  function aliasText(a, list) {
@@ -6611,6 +6692,7 @@ const MAIN = String.raw `
6611
6692
  const link = (...args) => setLink(leave, ...args)
6612
6693
  const general = [...lookRows(), fm('themes', link(t('th.title'), themeLabel(), '', openThemes, true)), fm('autostart', autostartRow('autostart'))]
6613
6694
  if (!BOOT.readOnly) general.push(fm('terminal', link(t('term.title'), '', '', openTerminals, true)))
6695
+ if (!BOOT.readOnly && S.state) general.push(fm('editor', editorRow()))
6614
6696
  // The menu bar switch shows only where it works (macOS); while its state loads it waits, unseen.
6615
6697
  const bar = []
6616
6698
  if (li.menubar.status && li.menubar.status.supported) {
@@ -7364,7 +7446,7 @@ const MAIN = String.raw `
7364
7446
  return Boolean(u && u.skillUpdate && u.skillUpdate.installed && u.skillUpdate.installed.length)
7365
7447
  }
7366
7448
  // Example phrases: a click puts one in the Let AI do it box (spec §3.28).
7367
- 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.unattended', 'ai.ask.theme', 'ai.ask.find', 'ai.ask.commands', 'ai.ask.tool']
7449
+ 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.expired', '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.unattended', 'ai.ask.theme', 'ai.ask.find', 'ai.ask.commands', 'ai.ask.tool']
7368
7450
  // Network Guard (spec §3.35): one dialog with the switch, the allowed countries and the newest result per address.
7369
7451
  // Countries are never ticked for the user, the current one included: a wrong network would allow itself.
7370
7452
  const NET_COMMON = ['US', 'JP', 'SG', 'GB', 'DE', 'FR', 'NL', 'CA', 'AU', 'KR', 'TW', 'HK']
@@ -8516,6 +8598,8 @@ const MAIN = String.raw `
8516
8598
  if (inbBanner) out.push(inbBanner)
8517
8599
  const nb = netBanner()
8518
8600
  if (nb) out.push(nb)
8601
+ const eb = expiredBanner()
8602
+ if (eb) out.push(eb)
8519
8603
  const errs = S.state.pluginErrors
8520
8604
  if (errs.length) out.push(h('div', { class: 'banner banner-warn', role: 'status' }, h('div', null,
8521
8605
  h('b', null, tn('banner.plugins', errs.length) + ' '), t('banner.pluginsHint'),
@@ -8523,6 +8607,39 @@ const MAIN = String.raw `
8523
8607
  }
8524
8608
  patch($('banners'), out)
8525
8609
  growInboundBanner()
8610
+ growExpiredBanner()
8611
+ }
8612
+ // One banner while any Account's sign-in has expired (ADR-0071), on the Accounts page. Its text and button change
8613
+ // only when the list of expired Accounts does, so a refresh with the same answer redraws nothing. It grows in when it
8614
+ // appears and shrinks away when the last one is signed in again.
8615
+ const exb = { el: undefined }
8616
+ function expiredBanner() {
8617
+ const list = S.state ? expiredLogins(visibleAccounts()).filter((a) => !(a.loginProblem && a.loginProblem.signedInAt)) : []
8618
+ if (curPage !== 'accounts' || !list.length) return expiredBannerKept()
8619
+ const refs = list.map((a) => a.ref)
8620
+ const attrs = { class: 'banner banner-warn', role: 'status', 'data-key': 'exp-banner' }
8621
+ const text = h('div', null, tn('exp.banner', refs.length, { refs: refList(refs) }))
8622
+ if (BOOT.readOnly) return h('div', attrs, text)
8623
+ return h('div', attrs, text,
8624
+ h('div', { class: 'banner-actions' },
8625
+ list.slice(0, 3).map((a, i) => h('button', { class: 'btn btn-sm' + (i === 0 ? ' btn-primary' : ''), type: 'button', onclick: () => signIn(a) }, list.length > 1 ? t('exp.signInRef', { ref: a.ref }) : t('exp.signIn')))))
8626
+ }
8627
+ function expiredBannerKept() {
8628
+ const old = $('banners').querySelector('[data-key="exp-banner"]')
8629
+ if (!old || old.dataset.gone || REDUCED) return null
8630
+ // Another render while it shrinks keeps it, so it is not cut short.
8631
+ if (old.dataset.leaving) return old
8632
+ old.dataset.leaving = '1'
8633
+ old.style.pointerEvents = 'none'
8634
+ old.animate(bannerFrames(old).reverse(), { duration: 180, easing: 'ease-in-out', fill: 'forwards' })
8635
+ setTimeout(() => { old.dataset.gone = '1'; renderBanners() }, 180)
8636
+ return old
8637
+ }
8638
+ function growExpiredBanner() {
8639
+ const el = $('banners').querySelector('[data-key="exp-banner"]:not([data-leaving])')
8640
+ if (el === exb.el) return
8641
+ if (el && exb.el !== undefined && !REDUCED) el.animate(bannerFrames(el), { duration: 180, easing: 'ease-out' })
8642
+ exb.el = el
8526
8643
  }
8527
8644
 
8528
8645
  // ---------- loading ----------
@@ -238,6 +238,8 @@ code, .mono { font-family: var(--mono); font-size: 12px; }
238
238
  /* A Same Login (spec §3.21, ADR-0026): one row; opened, a short line per directory. */
239
239
  .login-mark { display: inline-flex; flex: none; color: var(--muted); cursor: help; }
240
240
  .login-mark .ic { width: 13px; height: 13px; }
241
+ /* An Expired Login (ADR-0071): the word, then "Sign in again" beside it. */
242
+ .exp-badge { display: inline-flex; align-items: center; gap: 6px; flex: none; }
241
243
  .login-detail { flex-direction: column; gap: 8px; }
242
244
  .login-detail .rd-note { margin: 0; }
243
245
  .login-detail > .rd-browser { flex-direction: row; align-items: center; gap: 16px; }
@@ -891,6 +893,12 @@ ${UI_CSS}
891
893
  .pop-settings { width: 340px; }
892
894
  .set-group { display: flex; flex-direction: column; gap: 8px; }
893
895
  .set-check .set-label { white-space: normal; }
896
+ /* A row whose choices need the full width (the editor for settings files): the words on top, the choices below. */
897
+ .set-stack { flex-direction: column; align-items: flex-start; gap: 8px; }
898
+ /* Five choices do not fit a phone's width on one line: they wrap as whole buttons instead of breaking their labels. */
899
+ .set-stack .seg { flex-wrap: wrap; height: auto; max-width: 100%; }
900
+ .set-stack .seg-btn { height: calc(var(--ctl-h-sm) - 10px); white-space: nowrap; }
901
+ .set-stack .seg { max-width: 100%; overflow-x: auto; }
894
902
  .set-link .menu-label { flex: 1 1 auto; min-width: 0; white-space: normal; line-height: 1.3; }
895
903
  .set-link { height: auto; min-height: 32px; padding-top: 8px; padding-bottom: 8px; }
896
904
  .set-link .chip { flex: none; }
@@ -28,6 +28,13 @@ export interface PageOptions {
28
28
  ask?: {
29
29
  bridge: 'postMessage';
30
30
  };
31
+ /**
32
+ * createPanelHandler's `open`: with the bridge, inside a frame, "Open settings.json" posts the file's real path to
33
+ * the Portal, which opens it; opened on its own, the Panel's server opens it.
34
+ */
35
+ open?: {
36
+ bridge: 'postMessage';
37
+ };
31
38
  /** Config `panel` (spec §3.29): the theme and language saved for the Panel. */
32
39
  panel?: {
33
40
  theme?: string;
@@ -49,6 +49,7 @@ export function renderPage(opts) {
49
49
  readOnly: Boolean(opts.readOnly),
50
50
  updates: opts.updates !== false,
51
51
  ask: opts.ask ?? null,
52
+ open: opts.open ?? null,
52
53
  colorScheme: theme.colorScheme,
53
54
  lang,
54
55
  panel: opts.panel ?? {},
@@ -20,7 +20,7 @@ import { type TuneEntry, type TuneGroup } from './core/tuning.ts';
20
20
  import { type TuneApplyPlan, type TuneChange, type TuneUndoRecord } from './core/tuning-apply.ts';
21
21
  import { type UnattendedStatus } from './core/unattended.ts';
22
22
  import { type BuiltinPlugin, type LoadedPlugin, type PluginLoadError } from './plugins/loader.ts';
23
- import type { Account, AccountIdentity, Env, FamilyDef, LoginState, QuotaResult, QuotaSetupPlan, ReadContext, ShareMode, TuningResult, UnattendedEndedContext, UsageResult } from './types.ts';
23
+ import type { Account, AccountIdentity, Env, FamilyDef, LoginProblem, LoginState, QuotaResult, QuotaSetupPlan, ReadContext, ShareMode, TuningResult, UnattendedEndedContext, UsageResult } from './types.ts';
24
24
  export type { AccountIdentity, AccountRefError, DoctorHistory, Shell, ShellInitWrite };
25
25
  /** How `sideby resume` starts the Host (spec §3.15). */
26
26
  export interface ResumeLaunch {
@@ -137,6 +137,11 @@ export interface AccountStatus extends Account {
137
137
  hostInstalled: boolean;
138
138
  /** `not-needed` for API Accounts, which authenticate with their Secret File. */
139
139
  login: LoginState | 'not-needed';
140
+ /**
141
+ * Set when the Account is signed in but its Host has reported that the login expired (an Expired Login, ADR-0071).
142
+ * Only for Subscription Accounts of a Family that can tell.
143
+ */
144
+ loginProblem?: LoginProblem;
140
145
  model?: string;
141
146
  /** Who the Account is signed in as (email, organization), when its Family can tell. */
142
147
  identity?: AccountIdentity;
@@ -342,6 +347,16 @@ export interface Runtime {
342
347
  setDisplayOrder(display: DisplayConfig | undefined): Promise<DisplayConfig>;
343
348
  /** The other Accounts signed in as the same login as this one (spec §3.21), in discovery order; empty when none. */
344
349
  sameLogin(account: Account): Promise<string[]>;
350
+ /** The Account's Expired Login (ADR-0071), or undefined when it has none or its Family cannot tell. */
351
+ loginProblem(account: Account): Promise<LoginProblem | undefined>;
352
+ /**
353
+ * After a sign-in that sideby started finished with exit 0 (ADR-0071 Q9): remembers when, and asks the Account's
354
+ * Quota once when Quota checks are on, so a good answer clears an Expired Login. Returns what is left of it.
355
+ */
356
+ afterLogin(account: Account): Promise<{
357
+ loginProblem?: LoginProblem;
358
+ checked: boolean;
359
+ }>;
345
360
  usage(account: Account): Promise<UsageResult>;
346
361
  /** Estimated Compaction Threshold per model for one Account (spec §3.18); read-only. */
347
362
  tuning(account: Account): Promise<TuningResult>;