sideby 0.42.2 → 0.44.0

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 (66) hide show
  1. package/ai-tasks.json +10 -0
  2. package/dist/build.json +1 -1
  3. package/dist/src/cli/commands.js +54 -13
  4. package/dist/src/cli/json-schemas.js +65 -1
  5. package/dist/src/cli/main.js +11 -4
  6. package/dist/src/core/ask.d.ts +8 -14
  7. package/dist/src/core/ask.js +66 -30
  8. package/dist/src/core/egress.d.ts +5 -0
  9. package/dist/src/core/egress.js +32 -2
  10. package/dist/src/core/file-memo.d.ts +2 -0
  11. package/dist/src/core/file-memo.js +20 -0
  12. package/dist/src/core/handoff-run.js +41 -8
  13. package/dist/src/core/handoff-select.d.ts +5 -0
  14. package/dist/src/core/handoff-select.js +1 -1
  15. package/dist/src/core/handoff.d.ts +78 -1
  16. package/dist/src/core/handoff.js +100 -9
  17. package/dist/src/core/history-index.d.ts +4 -0
  18. package/dist/src/core/history-index.js +1 -1
  19. package/dist/src/core/live-sessions.d.ts +5 -0
  20. package/dist/src/core/live-sessions.js +12 -1
  21. package/dist/src/core/memo-store.js +32 -8
  22. package/dist/src/core/network.d.ts +37 -0
  23. package/dist/src/core/network.js +65 -1
  24. package/dist/src/core/pick-commands.d.ts +7 -1
  25. package/dist/src/core/pick-commands.js +15 -3
  26. package/dist/src/core/pick-records.d.ts +26 -0
  27. package/dist/src/core/pick-records.js +81 -0
  28. package/dist/src/families/agy/history.d.ts +2 -0
  29. package/dist/src/families/agy/history.js +118 -0
  30. package/dist/src/families/agy/index.js +5 -0
  31. package/dist/src/families/agy/quota.d.ts +5 -1
  32. package/dist/src/families/agy/quota.js +111 -10
  33. package/dist/src/families/history.js +2 -1
  34. package/dist/src/families/quota-watch.d.ts +12 -0
  35. package/dist/src/families/quota-watch.js +24 -0
  36. package/dist/src/network/hook.js +4 -4
  37. package/dist/src/network/page-script.d.ts +40 -0
  38. package/dist/src/network/page-script.js +270 -0
  39. package/dist/src/network/page.d.ts +11 -0
  40. package/dist/src/network/page.js +189 -0
  41. package/dist/src/network/panel.d.ts +5 -0
  42. package/dist/src/network/panel.js +7 -0
  43. package/dist/src/panel/changes.d.ts +57 -0
  44. package/dist/src/panel/changes.js +178 -0
  45. package/dist/src/panel/handler.d.ts +59 -1
  46. package/dist/src/panel/handler.js +374 -99
  47. package/dist/src/panel/i18n.d.ts +49 -0
  48. package/dist/src/panel/i18n.js +100 -2
  49. package/dist/src/panel/page-logic.d.ts +37 -3
  50. package/dist/src/panel/page-logic.js +106 -12
  51. package/dist/src/panel/page-script.js +194 -27
  52. package/dist/src/panel/page-styles.js +18 -8
  53. package/dist/src/panel/page.js +3 -1
  54. package/dist/src/runtime.d.ts +55 -5
  55. package/dist/src/runtime.js +105 -12
  56. package/dist/src/types.d.ts +3 -2
  57. package/package.json +1 -1
  58. package/schemas/network-diagnose.json +196 -0
  59. package/schemas/next.json +67 -2
  60. package/skills/sideby/SKILL.md +3 -2
  61. package/skills/sideby/references/accounts.md +1 -1
  62. package/skills/sideby/references/ai-tasks.md +1 -1
  63. package/skills/sideby/references/handoff.md +6 -2
  64. package/skills/sideby/references/network.md +6 -1
  65. package/skills/sideby/references/quota.md +1 -1
  66. package/skills/sideby/references/sessions.md +1 -1
@@ -6,7 +6,7 @@ import { groupsToAccept } from '../core/inbound.js';
6
6
  import { limitResetOffer, quotaAge, quotaIsStale, windowAge } from '../core/quota-levels.js';
7
7
  import { remoteControlTodo } from '../core/remote-control.js';
8
8
  import { catalogMatchLevel, catalogNorm, searchCatalog } from '../core/search-catalog.js';
9
- import { accountTitle, advisorPick, advisorSummary, aiTaskAccounts, aliasArgsOf, aliasIssue, aliasPrefix, askBridge, askBridged, askCopy, askPermissionNote, attentionReasons, attentionWhy, autostartNote, bindingWindow, cacheHitRate, canLeaveLocal, categoryOrder, codeSwapOutcome, dateFormatter, dotsKeepKeyboard, enableOutcome, expiredLogins, fileSize, findingSentence, fixPrompt, foldSkips, foldToolCalls, formatDuration, handoffChangeOf, handoffHintAccount, handoffTaskFacts, hiddenIn, highlightParts, histFilters, historyEmpty, historyRowSig, historyWhen, historyWhenNext, 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, startedFromView, steadyOrder, stripSecrets, suggestAlias, suggestName, switchFailure, tailInView, taskFindings, toastMerge, uaDayRuns, uaGroupByProject, uaGroupPending, uaOnChoices, uaParseClock, uaPickTime, uaSameSlot, uaShouldRead, uaSlotNight, uaStatusParts, uaStepClock, uaToggleDay, uaWaitingCount, uaWhen, updatedAge, vendorAlias, widthFollower, widthTier, windowState, withPinned, } from './page-logic.js';
9
+ import { accountTitle, advisorPick, advisorSummary, aiTaskAccounts, aliasArgsOf, aliasIssue, aliasPrefix, askBridge, askBridged, askCopy, askPermissionNote, attentionReasons, attentionWhy, autostartNote, bindingWindow, cacheHitRate, canLeaveLocal, categoryOrder, codeSwapOutcome, dateFormatter, dotsKeepKeyboard, enableOutcome, expiredLogins, fileSize, findingSentence, fixPrompt, foldSkips, foldToolCalls, formatDuration, handoffChangeOf, handoffHintAccount, handoffTaskFacts, hiddenIn, highlightParts, histFilters, historyEmpty, historyRowSig, historyWhen, historyWhenNext, hotkeyFromKey, hotkeyPressKind, inDisplayOrder, loginClusters, loginKey, longWindow, maskEmail, matchesQuery, mdBlocks, mdInline, menuPlacement, mergeDaily, mergeUsage, messageChip, messageNews, messageToCheck, networkDiagnoseTaskFacts, networkTaskFacts, newAccountDir, nextReset, openBridge, openBridged, orderedAliases, panelFixes, panelHint, panelLang, panelMigration, panelPrefs, passedWindow, pickNowChoice, pinnedIn, portalRefresh, quotaAskable, quotaHighLevel, quotaPressure, radioStep, reloadForBuild, remoteControlSummary, reorder, resetWhen, rowBadge, runCodeSwap, saveHandoffChange, sendBlock, sendFileProblem, sendResultView, sessionAge, sessionLabelParts, sessionRowShape, shortCwd, shortSessionLabel, sortAccounts, sortMenu, sortSessions, startedFromView, steadyOrder, stripSecrets, suggestAlias, suggestName, switchFailure, tailInView, taskFindings, toastMerge, uaDayRuns, uaGroupByProject, uaGroupPending, uaOnChoices, uaParseClock, uaPickTime, uaSameSlot, uaShouldRead, uaSlotNight, uaStatusParts, uaStepClock, uaToggleDay, uaWaitingCount, uaWhen, updatedAge, vendorAlias, widthFollower, widthTier, windowState, withPinned, } from './page-logic.js';
10
10
  // The component library's dropdown menu, copied by the brand repo's add script (--html into ui/); do not edit it.
11
11
  import { CHECK, menuItem, menuScript } from './ui/dropdown-menu/dropdown-menu.html.js';
12
12
  import { cn, esc } from './ui/lib/cn.js';
@@ -59,6 +59,7 @@ const LOGIC = [
59
59
  handoffChangeOf,
60
60
  handoffHintAccount,
61
61
  handoffTaskFacts,
62
+ networkDiagnoseTaskFacts,
62
63
  networkTaskFacts,
63
64
  inDisplayOrder,
64
65
  loginClusters,
@@ -77,6 +78,7 @@ const LOGIC = [
77
78
  longWindow,
78
79
  newAccountDir,
79
80
  nextReset,
81
+ pickNowChoice,
80
82
  canLeaveLocal,
81
83
  codeSwapOutcome,
82
84
  dateFormatter,
@@ -189,6 +191,10 @@ const MAIN = String.raw `
189
191
  // View state that is not saved: the search text, the attention filter, the Health check filter.
190
192
  const ui = { query: '', attention: false, allFindings: false, healthRef: null, checkingRef: null, desktopRef: null, browserRef: null, appBusy: null, appRemove: null, copied: null, resetRef: null, appNew: null, highlight: null, fade: true, loginRefs: new Map(), order: { families: [], units: {} }, drag: null, arrange: null }
191
193
  const $ = (id) => document.getElementById(id)
194
+ // The change feed (spec §3.45, ADR-0084): seq, the server's count of Quota file changes this page has seen; ctl, the
195
+ // held request; watching, whether the server watches any file; retryAt, when to ask again after a failure or while
196
+ // nothing is watched; off, an older server without the feed.
197
+ const chg = { seq: null, ctl: null, watching: false, retryAt: 0, off: false }
192
198
 
193
199
  // ---------- preferences ----------
194
200
  // Kept in localStorage, which can be missing or throw (private windows, blocked storage): every access is guarded
@@ -1325,14 +1331,16 @@ const MAIN = String.raw `
1325
1331
  function renderUpdated() {
1326
1332
  const busy = S.loading && !S.silent
1327
1333
  const every = Math.round((S.fastUntil > Date.now() ? FAST_MS : AUTO_MS) / 1000)
1328
- const text = S.loading && !S.state ? t('top.loading') : busy ? t('top.refreshing') : S.loadedAt ? t('top.updated', { ago: agoShort(Date.now() - S.loadedAt), s: every }) : ''
1334
+ // While Quota files are watched (spec §3.45), new numbers come as they land, not on the next round.
1335
+ const live = chg.watching && every === AUTO_MS / 1000
1336
+ const text = S.loading && !S.state ? t('top.loading') : busy ? t('top.refreshing') : S.loadedAt ? t(live ? 'top.updatedLive' : 'top.updated', { ago: agoShort(Date.now() - S.loadedAt), s: every }) : ''
1329
1337
  const el = $('updated')
1330
1338
  if (el.textContent !== text) el.textContent = text
1331
1339
  // A dot says whether the numbers are live: green while they refresh on their own, amber when they stopped.
1332
1340
  const stale = conn.lost || Boolean(S.loadError)
1333
1341
  el.classList.toggle('is-live', Boolean(S.loadedAt) && !stale)
1334
1342
  el.classList.toggle('is-stale', Boolean(S.loadedAt) && stale)
1335
- el.title = !S.loadedAt ? '' : (stale ? t('top.stale') + ' ' : '') + t('top.updatedTitle', { at: clock(new Date(S.loadedAt).toISOString()), s: Math.round((S.fastUntil > Date.now() ? FAST_MS : AUTO_MS) / 1000) })
1343
+ el.title = !S.loadedAt ? '' : (stale ? t('top.stale') + ' ' : '') + t(live ? 'top.updatedTitleLive' : 'top.updatedTitle', { at: clock(new Date(S.loadedAt).toISOString()), s: every })
1336
1344
  }
1337
1345
  function renderTop() {
1338
1346
  renderUpdated()
@@ -1369,8 +1377,8 @@ const MAIN = String.raw `
1369
1377
  }
1370
1378
  function stat(label, value, sub, extra, opts) {
1371
1379
  const kids = [h('div', { class: 'stat-text' }, h('div', { class: 'stat-label' }, label), h('div', { class: 'stat-value' }, value), h('div', { class: 'stat-sub' }, sub)), extra]
1372
- if (opts && opts.onclick) return h('button', { class: 'stat stat-btn' + (opts.cls ? ' ' + opts.cls : ''), type: 'button', 'aria-pressed': String(Boolean(opts.pressed)), 'aria-label': t('stat.btnLabel', { label, value, sub, action: opts.title || '' }), title: opts.title, onclick: opts.onclick }, kids)
1373
- return h('div', { class: 'stat' + (opts && opts.cls ? ' ' + opts.cls : '') }, kids)
1380
+ if (opts && opts.onclick) return h('button', { class: 'stat stat-btn' + (opts.cls ? ' ' + opts.cls : ''), type: 'button', 'aria-pressed': opts.pressed === undefined ? null : String(Boolean(opts.pressed)), 'aria-label': t('stat.btnLabel', { label, value, sub, action: opts.title || '' }), title: opts.title, onclick: opts.onclick }, kids)
1381
+ return h('div', { class: 'stat' + (opts && opts.cls ? ' ' + opts.cls : ''), title: (opts && opts.title) || null }, kids)
1374
1382
  }
1375
1383
  function spark(daily, cls) {
1376
1384
  if (!Array.isArray(daily) || !daily.length) return null
@@ -1416,6 +1424,7 @@ const MAIN = String.raw `
1416
1424
  const daily = mergeDaily(usages.map((a) => a.usage.daily)).slice(-BOOT.usageDays)
1417
1425
  const nr = nextReset(list, now)
1418
1426
  patch(box, [
1427
+ pickNowStat(list, now),
1419
1428
  stat(t('stat.accounts'), String(list.length), dots([tn('stat.families', famCount), apiCount ? tn('stat.api', apiCount) : null])),
1420
1429
  need
1421
1430
  ? stat(t('stat.attention'), String(need), needSub, h('span', { class: 'stat-act' }, t(ui.attention ? 'stat.attentionOff' : 'stat.attentionOn')), { cls: 'stat-warn', pressed: ui.attention, title: [needTitle, t(ui.attention ? 'stat.attentionOff' : 'stat.attentionOn')].join('\n'), onclick: () => { ui.attention = !ui.attention; renderSummary(); renderAccounts() } })
@@ -1427,6 +1436,52 @@ const MAIN = String.raw `
1427
1436
  ])
1428
1437
  }
1429
1438
 
1439
+ // "Best to use now" (spec §3.45): the account sideby next would pick in one tool, the quota it has left, and one click
1440
+ // that starts it. One value line and one line under it in every state, so the card keeps its size as answers change.
1441
+ function pickNowStat(list, now) {
1442
+ const pn = S.state.pickNow || {}
1443
+ const shownFams = new Set(list.map((a) => a.family))
1444
+ const choice = pickNowChoice(pn, familyOrder().filter((f) => shownFams.has(f)), prefs.family || '')
1445
+ const card = (label, value, sub, extra, opts) => stat(label, value, sub, extra, Object.assign({ cls: 'stat-pick' }, opts, { cls: 'stat-pick' + (opts && opts.cls ? ' ' + opts.cls : '') }))
1446
+ if (!choice) {
1447
+ const reading = list.some((a) => a.kind === 'subscription' && (a.pending || a.usagePending))
1448
+ return card(t('stat.pickNow'), '—', t(reading ? 'stat.pickReading' : prefs.family ? 'stat.pickNoSourceOne' : 'stat.pickNoSource'))
1449
+ }
1450
+ const fam = choice.family
1451
+ const e = pn[fam]
1452
+ const subs = list.filter((a) => a.family === fam && a.kind === 'subscription')
1453
+ const label = [...shownFams].filter((f) => pn[f]).length > 1 ? t('stat.pickNowIn', { title: family(fam).title }) : t('stat.pickNow')
1454
+ const shownName = (ref) => { const a = S.state.accounts.find((x) => x.ref === ref); return (a && a.aliases && a.aliases[0]) || ref }
1455
+ // Why a tool has no pick, in a few words: "All used up · claude:main is back in 1h 35m".
1456
+ const noPick = (x) => x.why === 'used-up' ? t('stat.pickUsedUp') + ' · ' + (x.earliestReset ? t('stat.pickBack', { ref: shownName(x.earliestReset.ref), when: t('time.in', { d: formatDuration(Math.max(0, Date.parse(x.earliestReset.at) - now), lang) }) }) : t('stat.pickWait')) : t(x.why === 'no-quota' ? 'stat.pickNoQuota' : 'stat.pickSignIn')
1457
+ const others = choice.others.length ? t('stat.pickOthers', { list: '' }) + '\n' + choice.others.map((f) => family(f).title + colon() + (pn[f].pick ? shownName(pn[f].pick) : noPick(pn[f]))).join('\n') : null
1458
+ if (!e.pick) {
1459
+ if (e.why === 'used-up') {
1460
+ const back = e.earliestReset ? t('stat.pickBack', { ref: shownName(e.earliestReset.ref), when: t('time.in', { d: formatDuration(Math.max(0, Date.parse(e.earliestReset.at) - now), lang) }) }) : t('stat.pickWait')
1461
+ return card(label, t('stat.pickUsedUp'), back, null, { cls: 'stat-warn', title: [e.earliestReset ? clock(e.earliestReset.at) : null, others].filter(Boolean).join('\n') || null })
1462
+ }
1463
+ return card(label, '—', t(e.why === 'no-quota' ? 'stat.pickNoQuota' : 'stat.pickSignIn'), null, { title: [e.why === 'no-quota' ? t('stat.pickNoQuotaTip') : null, others].filter(Boolean).join('\n') || null })
1464
+ }
1465
+ const a = S.state.accounts.find((x) => x.ref === e.pick)
1466
+ const left = pickLeft(a, now)
1467
+ const sub = e.reason === 'unknown' ? t('stat.pickNoData') : e.reason === 'tight' ? t('stat.pickTight') + ' · ' + left : left
1468
+ const keys = { expiring: 'acct.nextWhyExpiring', room: 'acct.nextWhyRoom', tight: 'acct.nextWhyTight', unknown: 'acct.nextWhyUnknown' }
1469
+ const why = subs.length > 1 ? t(keys[e.reason] || 'acct.nextWhy', { title: family(fam).title }) : t('stat.pickOnly', { title: family(fam).title })
1470
+ const act = BOOT.readOnly ? t('stat.pickCopyTip', { family: fam }) : t('stat.pickStartTip')
1471
+ // A short command on the card: the account's full name heads the hover text.
1472
+ const title = [shownName(e.pick) !== e.pick ? e.pick : null, why, e.running ? tn('acct.nextRunning', e.running) : null, others, act].filter(Boolean).join('\n')
1473
+ return card(label, shownName(e.pick), sub, h('span', { class: 'stat-act' }, icon(BOOT.readOnly ? 'copy' : 'terminal'), t(BOOT.readOnly ? 'stat.pickCopy' : 'stat.pickStart')),
1474
+ { cls: 'stat-acct' + (e.reason === 'tight' ? ' stat-warn' : ''), title, onclick: () => (BOOT.readOnly ? copyText('sideby next ' + fam) : startPick(null, fam)) })
1475
+ }
1476
+ // The quota an account has left in each counted window, shortest first: "5-hour 72% left · Weekly 40% left".
1477
+ function pickLeft(a, now) {
1478
+ const q = a && a.quota
1479
+ if (!q || q.status !== 'ok') return t('stat.pickNoData')
1480
+ const wins = (q.windows || []).filter((w) => !w.name).slice().sort((x, y) => (Number(x.windowMinutes) || 0) - (Number(y.windowMinutes) || 0))
1481
+ if (!wins.length) return t('stat.pickNoData')
1482
+ return wins.map((w) => passedWindow(w, q.observedAt, now) ? t('stat.pickReset', { w: winShort(w.label) }) : t('stat.pickLeft', { w: winShort(w.label), n: String(Math.max(0, 100 - Math.round(Number(w.usedPercent) || 0))) })).join(' · ')
1483
+ }
1484
+
1430
1485
  // ---------- toolbar ----------
1431
1486
  const tb = {}
1432
1487
  function seg(label, options, value, onPick) {
@@ -1917,6 +1972,13 @@ const MAIN = String.raw `
1917
1972
  }
1918
1973
  function usageBlock(a) {
1919
1974
  const u = a.usage
1975
+ // Its usage is still being parsed while the rest is in: two lines, as the numbers take, so the row keeps its height.
1976
+ if (!u && a.usagePending) {
1977
+ return h('div', { class: 'usage', 'aria-busy': 'true' },
1978
+ h('div', { class: 'u-text' },
1979
+ h('span', { class: 'u-num faint' }, '—'),
1980
+ h('div', { class: 'u-sub' }, t('acct.reading', { host: famTitle(a) }))))
1981
+ }
1920
1982
  if (!u) return h('div', { class: 'usage' })
1921
1983
  if (u.status !== 'ok') {
1922
1984
  const key = u.reason === 'no-session' ? 'usage.none' : u.reason === 'no-source' ? 'usage.noSource' : 'usage.unreadable'
@@ -2401,11 +2463,12 @@ const MAIN = String.raw `
2401
2463
  // The Account 'sideby next <family>' would pick; the server ranks it with the CLI's rule (spec §3.13).
2402
2464
  // "Suggested": a click says what it means and offers the command, instead of copying without a word.
2403
2465
  function nextTag(a) {
2404
- const b = h('button', { class: 'tag tag-ok tag-btn', type: 'button', 'aria-haspopup': 'dialog', 'aria-expanded': 'false', title: t('acct.nextWhy', { title: famTitle(a) }) }, t('acct.next'))
2466
+ const b = h('button', { class: 'tag tag-ok tag-btn', type: 'button', 'aria-haspopup': 'dialog', 'aria-expanded': 'false', title: t(nextWhyKey(a), { title: famTitle(a) }) }, t('acct.next'))
2405
2467
  b.addEventListener('click', (e) => {
2406
2468
  e.stopPropagation()
2407
2469
  openPopover(b, 'next', t('acct.next'), () => [
2408
- h('p', { class: 'next-why' }, t('acct.nextWhy', { title: famTitle(a) })),
2470
+ h('p', { class: 'next-why' }, t(nextWhyKey(a), { title: famTitle(a) })),
2471
+ nextRunning(a) ? h('p', { class: 'next-why' }, tn('acct.nextRunning', nextRunning(a))) : null,
2409
2472
  h('button', { class: 'btn btn-sm', type: 'button', onclick: () => { closeMenu(true); copyText('sideby next ' + a.family) } }, icon('copy'), t('acct.nextCopy')),
2410
2473
  h('code', { class: 'next-cmd' }, 'sideby next ' + a.family),
2411
2474
  ])
@@ -2413,6 +2476,14 @@ const MAIN = String.raw `
2413
2476
  return b
2414
2477
  }
2415
2478
  function isNext(a) { return Boolean(S.state && S.state.handoff && S.state.handoff[a.family] === a.ref) }
2479
+ // Sessions already running on the Next pick's login (ADR-0083); 0 when none or not known.
2480
+ function nextRunning(a) { return (S.state && S.state.handoffRunning && S.state.handoffRunning[a.family]) || 0 }
2481
+ // Why the pick goes first, as the Panel state says (ADR-0083); the general line when it says nothing.
2482
+ function nextWhyKey(a) {
2483
+ const why = S.state && S.state.handoffReason && S.state.handoffReason[a.family]
2484
+ const keys = { expiring: 'acct.nextWhyExpiring', room: 'acct.nextWhyRoom', tight: 'acct.nextWhyTight', unknown: 'acct.nextWhyUnknown' }
2485
+ return keys[why] || 'acct.nextWhy'
2486
+ }
2416
2487
  function row(a, now, cols) {
2417
2488
  if (ui.arrange) return arrangeRow(a, [a])
2418
2489
  const open = isOpen(a)
@@ -4924,7 +4995,7 @@ const MAIN = String.raw `
4924
4995
  s.projectName && !noProject ? h('span', { class: 'hist-pname', title: s.cwd || s.project }, s.projectName) : null,
4925
4996
  s.cwdGone ? h('span', { class: 'chip chip-sm hist-gone', tabindex: '0', 'data-tip': t('hist.goneTip') }, t('hist.gone')) : null,
4926
4997
  s.branch ? h('span', { class: 'mono hist-branch' }, s.branch) : null,
4927
- tn('hist.msgs', s.messages),
4998
+ s.messages ? tn('hist.msgs', s.messages) : null,
4928
4999
  s.children ? h('span', { class: 'chip chip-sm', tabindex: '0', 'data-tip': t('hist.kidsTip') }, tn('hist.kids', s.children)) : null,
4929
5000
  s.script ? h('span', { class: 'chip chip-sm' }, t('hist.script')) : null,
4930
5001
  h('span', { class: 'hist-age', 'data-hage': s.updatedAt, title: fullWhen(s.updatedAt) }, whenText(s.updatedAt)),
@@ -5169,7 +5240,7 @@ const MAIN = String.raw `
5169
5240
  s.cwdGone ? t('hist.gone') : null,
5170
5241
  s.branch ? h('span', { class: 'mono' }, s.branch) : null,
5171
5242
  s.model ? h('span', { class: 'mono' }, s.model) : null,
5172
- tn('hist.msgs', s.messages),
5243
+ s.messages ? tn('hist.msgs', s.messages) : null,
5173
5244
  h('span', { title: fullWhen(s.updatedAt) }, whenText(s.updatedAt)),
5174
5245
  ])),
5175
5246
  h('div', { class: 'hv-msgs', tabindex: '0', 'aria-label': t('hv.messages') },
@@ -8137,7 +8208,7 @@ const MAIN = String.raw `
8137
8208
  function openNet() {
8138
8209
  const n = netState()
8139
8210
  if (!n) return
8140
- net = { guard: n.guard, allow: [...n.allow], checking: false }
8211
+ net = { guard: n.guard, allow: [...n.allow], checking: false, diagnosing: false, diagnosis: null }
8141
8212
  showDialog('net')
8142
8213
  renderNet()
8143
8214
  // Opening it answers "where am I now" at once, unless a result is fresh.
@@ -8153,6 +8224,22 @@ const MAIN = String.raw `
8153
8224
  if (dlg.kind === 'net') renderNet()
8154
8225
  renderBanners()
8155
8226
  }
8227
+ async function netDiagnose() {
8228
+ const mine = net
8229
+ if (!mine) return
8230
+ mine.diagnosing = true
8231
+ if (dlg.kind === 'net') renderNet()
8232
+ try {
8233
+ const diagnosis = await api('/api/network/diagnose', {})
8234
+ if (net !== mine) return
8235
+ mine.diagnosis = diagnosis
8236
+ } catch (e) {
8237
+ if (net !== mine) return
8238
+ toast(t('net.checkFailed', { msg: e.message }), { kind: 'fail' })
8239
+ }
8240
+ mine.diagnosing = false
8241
+ if (dlg.kind === 'net') renderNet()
8242
+ }
8156
8243
  // Every change in the dialog applies at once, like a system setting, and its toast carries the undo. Changes are
8157
8244
  // saved one after another in the order clicked; a failed one puts the dialog back to what the config holds.
8158
8245
  let netSaving = Promise.resolve()
@@ -8201,6 +8288,16 @@ const MAIN = String.raw `
8201
8288
  x.ipChanged ? h('div', { class: 'muted small' }, t('net.ipChanged')) : null)
8202
8289
  })
8203
8290
  const skipped = n.accounts.filter((a) => a.skip === 'third-party' || a.skip === 'at-launch' || a.skip === 'api')
8291
+ const diagnosis = net.diagnosis
8292
+ const diagnosisRows = diagnosis ? diagnosis.targets.map((x) => {
8293
+ const listener = x.listener
8294
+ return h('li', { class: 'rc-row', 'data-key': 'net-diagnosis-' + x.url },
8295
+ h('div', null, h('code', null, new URL(x.url).hostname), ' ', h('b', null, t('net.diagnoseRoute', { proxy: x.proxy }))),
8296
+ h('div', { class: 'muted small' }, listener ? t(listener.reachable ? 'net.diagnoseListenerUp' : 'net.diagnoseListenerDown', { host: listener.host, port: listener.port, error: listener.error || 'failed' }) : t(x.guardSupport === 'direct' ? 'net.diagnoseDirect' : 'net.diagnoseNoLocalProbe')),
8297
+ h('div', { class: 'muted small' }, [x.guard.status, x.guard.loc || null, x.guard.checkedAt ? t('net.checked', { when: ago(x.guard.checkedAt) }) : t('net.notChecked'), x.guard.error || null].filter(Boolean).join(' · ')),
8298
+ x.guardSupport === 'unsupported' ? h('div', { class: 'small warn' }, t('net.diagnoseUnsupported')) : null,
8299
+ x.guardSupport === 'invalid' ? h('div', { class: 'small warn' }, t('net.diagnoseInvalid')) : null)
8300
+ }) : []
8204
8301
  const body = [
8205
8302
  h('p', { class: 'small' }, t('net.explain')),
8206
8303
  h('div', { class: 'row-actions' },
@@ -8212,6 +8309,14 @@ const MAIN = String.raw `
8212
8309
  h('div', { class: 'set-row' }, h('span', { class: 'set-label' }, t('net.now')),
8213
8310
  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'))),
8214
8311
  rows.length ? h('ul', { class: 'rc-list', 'data-patch': '' }, rows) : h('p', { class: 'small muted' }, t('net.noTargets')),
8312
+ h('div', { class: 'set-row' }, h('span', { class: 'set-label' }, t('net.diagnose')),
8313
+ h('div', { class: 'row-actions' },
8314
+ h('button', { class: 'btn btn-sm', type: 'button', 'data-key': 'net-diagnose', disabled: net.diagnosing, 'aria-busy': net.diagnosing ? 'true' : null, onclick: netDiagnose }, net.diagnosing ? spinner() : icon('refresh'), t(diagnosis ? 'net.diagnoseRefresh' : 'net.diagnose')),
8315
+ diagnosis ? h('button', { class: 'btn btn-sm', type: 'button', 'data-key': 'net-diagnose-ask', onclick: askNetworkDiagnose }, icon('bot'), t('ask.title.network-diagnose')) : null)),
8316
+ h('p', { class: 'small muted' }, t('net.diagnoseOffline')),
8317
+ diagnosis ? h('p', { class: 'small muted' }, t('net.diagnoseChecked', { when: ago(diagnosis.checkedAt) })) : null,
8318
+ diagnosisRows.length ? h('ul', { class: 'rc-list', 'data-patch': '' }, diagnosisRows) : null,
8319
+ diagnosis ? h('p', { class: 'small muted' }, t('net.diagnoseTcpLimit')) : null,
8215
8320
  skipped.length ? h('p', { class: 'small muted' }, t('net.skipped', { refs: skipped.map((a) => a.ref).join(', ') })) : null,
8216
8321
  h('p', { class: 'small muted' }, t('net.notCovered')),
8217
8322
  BOOT.readOnly ? h('p', { class: 'small' }, t('rc.readOnlyBoth')) : null,
@@ -8228,6 +8333,10 @@ const MAIN = String.raw `
8228
8333
  if (!n) return
8229
8334
  openAsk({ task: 'network', context: { network: networkTaskFacts(n), version: BOOT.version } })
8230
8335
  }
8336
+ function askNetworkDiagnose() {
8337
+ if (!net || !net.diagnosis) return
8338
+ openAsk({ task: 'network-diagnose', context: { networkDiagnose: networkDiagnoseTaskFacts(net.diagnosis), version: BOOT.version } })
8339
+ }
8231
8340
  // Where the problem shows: a banner on every page while the guard is on and the exit is wrong or unknown.
8232
8341
  function netBanner() {
8233
8342
  const x = netProblem()
@@ -8423,13 +8532,14 @@ const MAIN = String.raw `
8423
8532
  }
8424
8533
  function askBody() {
8425
8534
  const body = { task: ak.task, lang }
8535
+ const fixed = ak.task === 'network-diagnose'
8426
8536
  const text = ak.els && ak.els.text ? ak.els.text.value.trim() : ak.text
8427
- if (text) body.text = text
8537
+ if (!fixed && text) body.text = text
8428
8538
  if (ak.context) body.context = ak.context
8429
8539
  if (ak.account && ak.accountChanged) body.account = ak.account
8430
8540
  if (ak.terminal && ak.terminalChanged) body.terminal = ak.terminal
8431
8541
  const ids = ak.files.filter((f) => f.status === 'ready').map((f) => f.id)
8432
- if (ids.length) body.attachments = ids
8542
+ if (!fixed && ids.length) body.attachments = ids
8433
8543
  return body
8434
8544
  }
8435
8545
  function openAsk(opts) {
@@ -8437,7 +8547,7 @@ const MAIN = String.raw `
8437
8547
  closeMenu()
8438
8548
  // In a Portal that offers AI Tasks itself (createPanelHandler's ask bridge), the task goes to its dialog.
8439
8549
  if (askBridge(BOOT, opts, window)) return
8440
- ak = { task: opts.task || 'free', text: opts.text || '', context: opts.context || null, account: null, accountChanged: false, terminal: null, terminalChanged: false, pick: null, reason: null, terms: null, loading: true, busy: false, result: null, error: null, removed: false, files: [], els: {} }
8550
+ ak = { task: opts.task || 'free', text: opts.text || '', context: opts.context || null, account: null, accountChanged: false, terminal: null, terminalChanged: false, pick: null, reason: null, terms: null, loading: true, busy: false, result: null, error: null, removed: false, files: [], els: {}, prompt: null, promptChanged: false }
8441
8551
  showDialog('ask')
8442
8552
  hookDrops()
8443
8553
  const mine = ak
@@ -8459,6 +8569,7 @@ const MAIN = String.raw `
8459
8569
  if (ak !== mine) return
8460
8570
  ak.pick = pick.account
8461
8571
  ak.reason = pick.reason || null
8572
+ if (ak.task === 'network-diagnose') ak.prompt = pick.prompt
8462
8573
  if (!ak.accountChanged) ak.account = pick.account
8463
8574
  ak.terms = terms
8464
8575
  if (terms && !ak.terminalChanged) ak.terminal = terms.guess.id
@@ -8489,6 +8600,12 @@ const MAIN = String.raw `
8489
8600
  h('div', { class: 'ask-chips' }, copy.chips.map((k) => h('button', { class: 'chip chip-btn', type: 'button', onclick: () => { e.text.value = t(k); ak.text = e.text.value; warnNow(); e.text.focus() } }, t(k)))))
8490
8601
  return [h('div', { class: 'field' }, label, e.warn), askAttachField(), chips]
8491
8602
  }
8603
+ function askFixedPrompt() {
8604
+ return h('div', { class: 'field' },
8605
+ h('span', null, t('ask.actualPrompt')),
8606
+ ak.promptChanged ? h('p', { class: 'note note-warn', role: 'status' }, t('ask.promptChanged')) : null,
8607
+ h('pre', { class: 'ask-prompt', id: 'ak-prompt' }, ak.prompt || ''))
8608
+ }
8492
8609
 
8493
8610
  // Attachments (spec §3.28 "附件"): pasted, dropped or picked files upload at once, one request each, so a wrong
8494
8611
  // type or a file that is too big is named right away. The page shows image thumbnails from the file itself as a
@@ -8499,7 +8616,7 @@ const MAIN = String.raw `
8499
8616
  // Which open dialog takes pasted or dropped files now: the AI Task's or "Send to it"'s, until it shows its result.
8500
8617
  function fileDropTarget() {
8501
8618
  if (BOOT.readOnly) return null
8502
- if (dlg.kind === 'ask' && ak && !ak.result) return askAddFiles
8619
+ if (dlg.kind === 'ask' && ak && ak.task !== 'network-diagnose' && !ak.result) return askAddFiles
8503
8620
  if (dlg.kind === 'send' && sd && !sd.result) return sendAddFiles
8504
8621
  return null
8505
8622
  }
@@ -8574,7 +8691,7 @@ const MAIN = String.raw `
8574
8691
  ])
8575
8692
  }
8576
8693
  function askAddFiles(list) {
8577
- if (!ak || !list.length) return
8694
+ if (!ak || ak.task === 'network-diagnose' || !list.length) return
8578
8695
  ak.attachFull = false
8579
8696
  for (const file of list) {
8580
8697
  if (ak.files.filter((f) => f.status !== 'error').length >= ATTACH_MAX) { ak.attachFull = true; break }
@@ -8717,7 +8834,7 @@ const MAIN = String.raw `
8717
8834
  body.push(askResult())
8718
8835
  if (ak.result.removedSecrets) body.push(h('p', { class: 'small muted' }, t('ask.keyRemoved')))
8719
8836
  } else {
8720
- body.push(askTextField(), askConfirm(), askYourself())
8837
+ body.push(ak.task === 'network-diagnose' ? askFixedPrompt() : askTextField(), askConfirm(), askYourself())
8721
8838
  const canOpen = !BOOT.readOnly && !ak.loading && !ak.error && ak.account
8722
8839
  if (canOpen) {
8723
8840
  const term = termName(ak.terminal || 'terminal')
@@ -8748,10 +8865,23 @@ const MAIN = String.raw `
8748
8865
  renderAsk()
8749
8866
  try {
8750
8867
  await askUploadsDone()
8751
- if (ak !== mine) return
8868
+ if (ak !== mine || dlg.kind !== 'ask') return
8752
8869
  renderAsk()
8753
- const r = await api('/api/ask', askBody())
8754
- if (ak !== mine) return
8870
+ const body = askBody()
8871
+ if (ak.task === 'network-diagnose') {
8872
+ const check = await api('/api/ask/prompt', body)
8873
+ if (ak !== mine || dlg.kind !== 'ask') return
8874
+ if (check.prompt !== ak.prompt) {
8875
+ ak.prompt = check.prompt
8876
+ ak.promptChanged = true
8877
+ ak.busy = false
8878
+ renderAsk()
8879
+ return
8880
+ }
8881
+ ak.promptChanged = false
8882
+ }
8883
+ const r = await api('/api/ask', body)
8884
+ if (ak !== mine || dlg.kind !== 'ask') return
8755
8885
  ak.busy = false
8756
8886
  if (r.opened) {
8757
8887
  toast(t('ask.opened', { terminal: termName(r.terminal), ref: r.account }))
@@ -8770,7 +8900,7 @@ const MAIN = String.raw `
8770
8900
  renderAsk()
8771
8901
  copyText(r.command, t('ask.copiedCmd'))
8772
8902
  } catch (e) {
8773
- if (ak !== mine) return
8903
+ if (ak !== mine || dlg.kind !== 'ask') return
8774
8904
  ak.busy = false
8775
8905
  toast(e.message, { kind: 'fail' })
8776
8906
  renderAsk()
@@ -9102,13 +9232,16 @@ const MAIN = String.raw `
9102
9232
  const input = fam && document.getElementById('pk-name-' + fam)
9103
9233
  if (input) input.focus()
9104
9234
  }
9105
- async function startPick(name) {
9235
+ // By the Pick Command's name, or by tool (the "Best to use now" card, spec §3.45).
9236
+ async function startPick(name, fam) {
9106
9237
  if (BOOT.readOnly) { copyText(name, name); return }
9107
9238
  try {
9108
- const r = await api('/api/pick/start', { name })
9109
- const why = r.reason === 'most-room' ? t('pk.why.room', { n: String(r.pressure), w: r.window ? winTitle(r.window) + ' ' : '' }) : r.reason === 'tight' ? t('pk.why.tight', { n: String(r.pressure), w: r.window ? winTitle(r.window) + ' ' : '', limit: String(r.limit), longLimit: String(r.longLimit) }) : t(r.reason === 'others-full' ? 'pk.why.othersFull' : 'pk.why.noData')
9110
- if (r.opened) { toast(t('pk.started', { terminal: TERM_NAMES[r.terminal] || r.terminal, ref: r.picked, why })); return }
9111
- await copyText(name, name)
9239
+ const r = await api('/api/pick/start', name ? { name } : { family: fam })
9240
+ const why = r.reason === 'most-room' ? t(r.expiring ? 'pk.why.expiring' : r.running ? 'pk.why.roomRunning' : 'pk.why.room', { n: String(r.pressure), w: r.window ? winTitle(r.window) + ' ' : '', running: String(r.running || 0) }) : r.reason === 'tight' ? t('pk.why.tight', { n: String(r.pressure), w: r.window ? winTitle(r.window) + ' ' : '', limit: String(r.limit), longLimit: String(r.longLimit) }) : t(r.reason === 'others-full' ? 'pk.why.othersFull' : 'pk.why.noData')
9241
+ // The start counts for the next pick (ADR-0083): the card and the Next mark move on at once.
9242
+ if (r.opened) { toast(t('pk.started', { terminal: TERM_NAMES[r.terminal] || r.terminal, ref: r.picked, why })); load({ silent: true }); return }
9243
+ const cmd = name || 'sideby run ' + r.picked
9244
+ await copyText(cmd, cmd)
9112
9245
  toast(r.automation ? t('login.automation', { terminal: TERM_NAMES[r.terminal] || r.terminal }) : t('login.failed'), { kind: 'info' })
9113
9246
  } catch (e) { toast(e.message, { kind: 'fail' }) }
9114
9247
  }
@@ -9511,11 +9644,12 @@ const MAIN = String.raw `
9511
9644
  sessionsTick()
9512
9645
  messagesTick()
9513
9646
  if (document.visibilityState !== 'visible' || !S.state) return
9647
+ watchChanges()
9514
9648
  if (S.pending && !S.loading && !uiBusy()) { S.pending = false; renderAll() }
9515
9649
  const now = Date.now()
9516
9650
  // An Account still being read is asked for again soon, so it fills in without waiting for the next round.
9517
9651
  // For half a minute: the server says "took too long" after a minute, which the normal round then shows.
9518
- const pending = S.state.accounts.some((a) => a.pending)
9652
+ const pending = S.state.accounts.some((a) => a.pending || a.usagePending || a.refreshing)
9519
9653
  if (!pending) S.pendingSince = 0
9520
9654
  else if (!S.pendingSince) S.pendingSince = now
9521
9655
  // A Host being asked for its Quota behind the kept answer (spec §3.26): its row takes the new numbers as soon as
@@ -9526,6 +9660,35 @@ const MAIN = String.raw `
9526
9660
  const every = pending && now - S.pendingSince < 30_000 ? PENDING_MS : asking && now - S.askingSince < 30_000 ? ASKING_MS : now < S.fastUntil ? FAST_MS : AUTO_MS
9527
9661
  if (!S.loading && !conn.lost && !S.fixing && !S.checking && !dlg.busy && now - S.lastTry >= every) load({ silent: true })
9528
9662
  }
9663
+ // One request held open while the page is visible: the server answers it when a Quota file changes, and the page
9664
+ // reads its state at once. Not through api(): a request this page stops when hidden is not a lost connection.
9665
+ async function watchChanges() {
9666
+ if (chg.ctl || chg.off || conn.lost || document.visibilityState !== 'visible' || Date.now() < chg.retryAt) return
9667
+ const ctl = new AbortController()
9668
+ chg.ctl = ctl
9669
+ let res = null
9670
+ let data = null
9671
+ try {
9672
+ res = await fetch(BOOT.basePath + '/api/changes' + (chg.seq === null ? '' : '?since=' + chg.seq), { cache: 'no-store', signal: ctl.signal })
9673
+ if (res.ok) data = await res.json()
9674
+ } catch {}
9675
+ chg.ctl = null
9676
+ if (res && res.status === 404) { chg.off = true; chg.watching = false; renderUpdated(); return }
9677
+ if (!data || typeof data.seq !== 'number') {
9678
+ if (!ctl.signal.aborted) chg.retryAt = Date.now() + 5000
9679
+ return
9680
+ }
9681
+ chg.seq = data.seq
9682
+ if (chg.watching !== Boolean(data.watching)) { chg.watching = Boolean(data.watching); renderUpdated() }
9683
+ if (!data.watching) chg.retryAt = Date.now() + 60000
9684
+ if (data.changed) quotaChanged()
9685
+ watchChanges()
9686
+ }
9687
+ // A Quota file changed: read now, or, while a check, a fix or a dialog's work runs, at the first tick after it.
9688
+ function quotaChanged() {
9689
+ if (!conn.lost && !S.fixing && !S.checking && !dlg.busy) load({ silent: true })
9690
+ else S.lastTry = 0
9691
+ }
9529
9692
  // Coming back to the page refreshes at once.
9530
9693
  function wake() {
9531
9694
  // Back from the vendor's page a Limit Reset is used on: that account's quota is asked once (ADR-0072).
@@ -9983,7 +10146,11 @@ const MAIN = String.raw `
9983
10146
  // The sessions too, so the Sessions page opens with its rows already there.
9984
10147
  loadSessions()
9985
10148
  setInterval(tick, 1000)
9986
- document.addEventListener('visibilitychange', () => { if (document.visibilityState !== 'visible') resetLeft(); wake() })
10149
+ document.addEventListener('visibilitychange', () => {
10150
+ // A hidden page holds no request: browsers give a site only a few connections.
10151
+ if (document.visibilityState !== 'visible') { resetLeft(); if (chg.ctl) chg.ctl.abort() }
10152
+ wake()
10153
+ })
9987
10154
  window.addEventListener('blur', resetLeft)
9988
10155
  window.addEventListener('focus', wake)
9989
10156
  // A Portal that changed something the Panel shows says so (ADR-0006): read the state now instead of at the next
@@ -141,7 +141,7 @@ code, .mono { font-family: var(--mono); font-size: 12px; }
141
141
  .theme-bad { color: var(--fail); }
142
142
  .theme-fade, .theme-fade * { transition: background-color var(--duration-base) var(--ease-out), color var(--duration-base) var(--ease-out), border-color var(--duration-base) var(--ease-out), fill var(--duration-base) var(--ease-out) !important; }
143
143
  @media (prefers-reduced-motion: reduce) { .theme-fade, .theme-fade * { transition: none !important; } }
144
- /* Summary: four quiet numbers in one surface. */
144
+ /* Summary: the account to use now on a line of its own, then four quiet numbers, in one surface. */
145
145
  .summary[hidden], #checkup[hidden] { display: none; }
146
146
  .summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-xl); box-shadow: var(--shadow); margin-bottom: 20px; overflow: hidden; }
147
147
  .stat { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; min-width: 0; padding: 16px 20px; border-left: 1px solid var(--border); text-align: left; }
@@ -155,6 +155,13 @@ code, .mono { font-family: var(--mono); font-size: 12px; }
155
155
  .stat-btn[aria-pressed=true] { background: var(--selected); color: var(--brand); }
156
156
  .stat-warn .stat-value { color: var(--warn); }
157
157
  .stat-ok .stat-value { color: var(--ok); }
158
+ .stat-pick { grid-column: 1 / -1; align-items: center; min-height: 56px; padding: 12px 20px; border-bottom: 1px solid var(--border); }
159
+ .stat-pick + .stat { border-left: 0; }
160
+ .stat-pick .stat-text { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 16px; }
161
+ .stat-pick .stat-value { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
162
+ .stat-acct .stat-value { font-family: var(--mono); font-size: 18px; letter-spacing: 0; }
163
+ .stat-pick .stat-act { align-self: center; display: inline-flex; align-items: center; gap: 6px; font-weight: 500; }
164
+ .sk-pick { height: 24px; width: 45%; }
158
165
  .label-tip { display: inline-flex; align-items: center; gap: 8px; }
159
166
 
160
167
  /* Toolbar */
@@ -783,6 +790,7 @@ textarea.ask-text { min-height: 64px; resize: vertical; border-radius: var(--rad
783
790
  input[type=password]:focus, textarea.ask-text:focus { border-color: var(--focus); }
784
791
  textarea.ask-text:focus-visible, input[type=password]:focus-visible { outline: var(--focus-outline); outline-offset: 2px; box-shadow: var(--focus-ring); }
785
792
  textarea::placeholder { color: var(--faint); }
793
+ .ask-prompt { margin: 0; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-2); color: var(--text); white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; font-family: var(--mono); font-size: 12px; line-height: 1.55; }
786
794
  .ask-chips { display: flex; flex-wrap: wrap; gap: 8px; }
787
795
  .ask-chips .chip { font: inherit; font-size: 12px; text-align: left; white-space: normal; }
788
796
  .ask-attach-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
@@ -1033,7 +1041,8 @@ ${UI_CSS}
1033
1041
  .sk-title { height: 12px; width: 22%; }
1034
1042
  .sk-bar { height: 8px; flex: 1; max-width: 160px; margin-left: auto; }
1035
1043
  .sk-line { height: 12px; margin: 8px 0; }
1036
- .sk-stat { height: 40px; margin: 16px 20px; }
1044
+ /* As tall as a card's label, number and line under it, so the summary keeps its height when the numbers land. */
1045
+ .sk-stat { height: 47px; margin: 8px 0; }
1037
1046
  .w50 { width: 50%; } .w70 { width: 70%; }
1038
1047
  @keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
1039
1048
  .view-in > * { animation: view-in var(--duration-base) var(--ease-out) both; }
@@ -1084,8 +1093,8 @@ ${UI_CSS}
1084
1093
  .toolbar > .btn-primary { width: var(--ctl-h); padding: 0; justify-content: center; }
1085
1094
  .toolbar > .btn-primary > span { display: none; }
1086
1095
  .summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
1087
- .stat:nth-child(3) { border-left: 0; }
1088
- .stat:nth-child(n+3) { border-top: 1px solid var(--border); }
1096
+ .stat:nth-child(4) { border-left: 0; }
1097
+ .stat:nth-child(n+4) { border-top: 1px solid var(--border); }
1089
1098
  }
1090
1099
  :root[data-width=phone] { --gutter: 14px; }
1091
1100
  :where(:root[data-width=phone]) {
@@ -1118,10 +1127,11 @@ ${UI_CSS}
1118
1127
  #accounts { --col-gap: 14px; }
1119
1128
  /* One window per line, so the reset time is never cut off. */
1120
1129
  .row > .quota { grid-template-columns: 1fr; row-gap: 12px; max-width: none; }
1121
- /* On a phone the summary keeps what needs a look and the next reset. */
1122
- .stat:nth-child(1), .stat:nth-child(3) { display: none; }
1123
- .stat:nth-child(n) { border-top: 0; }
1124
- .stat:nth-child(4) { border-left: 1px solid var(--border); }
1130
+ /* On a phone the summary keeps the account to use now, what needs a look and the next reset. */
1131
+ .stat:nth-child(2), .stat:nth-child(4) { display: none; }
1132
+ .stat:nth-child(3) { border-left: 0; }
1133
+ .stat:nth-child(5) { border-left: 1px solid var(--border); border-top: 0; }
1134
+ .stat-pick { flex-direction: row; align-items: center; padding: 12px 12px; }
1125
1135
  .row-end .icon-btn { width: 36px; height: 36px; }
1126
1136
  .sess-row { grid-template-columns: auto minmax(0, 1fr); row-gap: 12px; }
1127
1137
  .sess-actions { grid-column: 2; }
@@ -35,6 +35,8 @@ function attr(value) {
35
35
  // layout; the page script then follows the width as it changes.
36
36
  const SKELETON_ROW = `<div class="sk-row"><span class="sk sk-badge"></span><span class="sk sk-title"></span><span class="sk sk-bar"></span><span class="sk sk-bar"></span></div>`;
37
37
  const SKELETON_STAT = `<div class="stat"><span class="sk sk-stat w70"></span></div>`;
38
+ /** The "Best to use now" card's place (spec §3.45), so the summary opens at its final size. */
39
+ const SKELETON_PICK = `<div class="stat stat-pick"><span class="sk sk-pick"></span></div>`;
38
40
  export function renderPage(opts) {
39
41
  const nonce = opts.nonce ? ` nonce="${attr(opts.nonce)}"` : '';
40
42
  const theme = opts.theme ?? resolveTheme(undefined);
@@ -108,7 +110,7 @@ export function renderPage(opts) {
108
110
  <main class="wrap">
109
111
  <div id="banners"></div>
110
112
  <nav id="pages" class="pages" role="tablist" hidden></nav>
111
- <section id="summary" class="summary" aria-busy="true">${SKELETON_STAT.repeat(4)}</section>
113
+ <section id="summary" class="summary" aria-busy="true">${SKELETON_PICK}${SKELETON_STAT.repeat(4)}</section>
112
114
  <section id="handoff-page" class="block page" aria-labelledby="h-handoff" hidden></section>
113
115
  <section id="tuning-page" class="block page" aria-labelledby="h-tuning" hidden></section>
114
116
  <section id="sessions-page" class="block page" aria-labelledby="h-sessions" hidden></section>