sideby 0.43.0 → 0.45.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.
- package/dist/build.json +1 -1
- package/dist/src/cli/commands.d.ts +4 -0
- package/dist/src/cli/commands.js +9 -8
- package/dist/src/cli/json-schemas.js +58 -0
- package/dist/src/core/cli-commands.js +0 -10
- package/dist/src/core/egress.d.ts +1 -7
- package/dist/src/core/egress.js +7 -36
- package/dist/src/core/file-memo.d.ts +2 -0
- package/dist/src/core/file-memo.js +20 -0
- package/dist/src/core/handoff.d.ts +9 -0
- package/dist/src/core/handoff.js +10 -0
- package/dist/src/core/history.d.ts +1 -1
- package/dist/src/core/history.js +2 -2
- package/dist/src/core/memo-store.js +32 -8
- package/dist/src/core/network.d.ts +5 -35
- package/dist/src/core/network.js +18 -54
- package/dist/src/core/themes.js +0 -7
- package/dist/src/core/update.d.ts +1 -1
- package/dist/src/core/update.js +4 -12
- package/dist/src/families/claude/quota-fetch.js +2 -2
- package/dist/src/families/claude/tuning.d.ts +0 -1
- package/dist/src/families/claude/tuning.js +1 -1
- package/dist/src/families/quota-watch.d.ts +12 -0
- package/dist/src/families/quota-watch.js +24 -0
- package/dist/src/network/hook.js +1 -1
- package/dist/src/network/page.d.ts +1 -1
- package/dist/src/network/page.js +15 -181
- package/dist/src/panel/changes.d.ts +57 -0
- package/dist/src/panel/changes.js +178 -0
- package/dist/src/panel/handler.d.ts +38 -0
- package/dist/src/panel/handler.js +263 -93
- package/dist/src/panel/i18n.d.ts +23 -0
- package/dist/src/panel/i18n.js +46 -0
- package/dist/src/panel/page-logic.d.ts +22 -29
- package/dist/src/panel/page-logic.js +22 -33
- package/dist/src/panel/page-script.js +114 -45
- package/dist/src/panel/page-styles.js +26 -26
- package/dist/src/panel/page.js +3 -1
- package/dist/src/quota/claude-statusline.js +1 -1
- package/dist/src/runtime.d.ts +13 -1
- package/dist/src/runtime.js +14 -8
- package/dist/src/types.d.ts +2 -2
- package/dist/src/unattended/hook.js +0 -1
- package/dist/testing/index.js +1 -1
- package/package.json +2 -1
- package/schemas/network-diagnose.json +239 -0
- package/schemas/next.json +25 -0
- package/skills/sideby/SKILL.md +2 -2
- package/skills/sideby/references/handoff.md +2 -0
- package/skills/sideby/references/network.md +5 -3
- package/dist/src/network/page-script.d.ts +0 -40
- package/dist/src/network/page-script.js +0 -270
|
@@ -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, networkDiagnoseTaskFacts, 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';
|
|
@@ -78,6 +78,7 @@ const LOGIC = [
|
|
|
78
78
|
longWindow,
|
|
79
79
|
newAccountDir,
|
|
80
80
|
nextReset,
|
|
81
|
+
pickNowChoice,
|
|
81
82
|
canLeaveLocal,
|
|
82
83
|
codeSwapOutcome,
|
|
83
84
|
dateFormatter,
|
|
@@ -190,8 +191,11 @@ const MAIN = String.raw `
|
|
|
190
191
|
// View state that is not saved: the search text, the attention filter, the Health check filter.
|
|
191
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 }
|
|
192
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 }
|
|
193
198
|
|
|
194
|
-
// ---------- preferences ----------
|
|
195
199
|
// Kept in localStorage, which can be missing or throw (private windows, blocked storage): every access is guarded
|
|
196
200
|
// and the defaults apply.
|
|
197
201
|
const PREFS_KEY = 'sideby.panel.v2'
|
|
@@ -226,7 +230,6 @@ const MAIN = String.raw `
|
|
|
226
230
|
}
|
|
227
231
|
// The categories of the side list, in the order the user dragged them to.
|
|
228
232
|
p.histCatOrder = Array.isArray(raw.histCatOrder) ? raw.histCatOrder.filter((c) => typeof c === 'string' && c).slice(0, HIST_FOLD_MAX) : []
|
|
229
|
-
// The categories folded in the side list.
|
|
230
233
|
p.histCatFold = {}
|
|
231
234
|
if (raw.histCatFold && typeof raw.histCatFold === 'object')
|
|
232
235
|
for (const k of Object.keys(raw.histCatFold).filter((k) => raw.histCatFold[k] === true).slice(0, HIST_FOLD_MAX)) p.histCatFold[k] = true
|
|
@@ -246,7 +249,6 @@ const MAIN = String.raw `
|
|
|
246
249
|
function viewPrefs() { return panelPrefs(cfgPanel, { theme: prefs.theme, lang: prefs.lang }, CFG) }
|
|
247
250
|
let lang = panelLang(BOOT.lang, viewPrefs().language, navigator.language)
|
|
248
251
|
|
|
249
|
-
// ---------- text ----------
|
|
250
252
|
function t(key, vars) {
|
|
251
253
|
const table = MESSAGES[lang] || {}
|
|
252
254
|
let s = Object.hasOwn(table, key) ? table[key] : Object.hasOwn(MESSAGES.en, key) ? MESSAGES.en[key] : key
|
|
@@ -441,7 +443,6 @@ const MAIN = String.raw `
|
|
|
441
443
|
return out
|
|
442
444
|
}
|
|
443
445
|
|
|
444
|
-
// ---------- updating in place ----------
|
|
445
446
|
// A refresh rebuilds the markup, then keeps every existing element whose markup did not change, so focus, hover,
|
|
446
447
|
// text selection and scroll stay put and only changed rows are swapped. Children match by data-key, else by
|
|
447
448
|
// position; a data-patch container that changed is updated child by child instead of being replaced. Rows carry
|
|
@@ -616,7 +617,6 @@ const MAIN = String.raw `
|
|
|
616
617
|
return svg
|
|
617
618
|
}
|
|
618
619
|
|
|
619
|
-
// ---------- server calls ----------
|
|
620
620
|
// The token is per server process: after sideby ui restarts, the first write gets 403 "bad-token". The page then
|
|
621
621
|
// fetches the new token from api/session and sends that same request once more; the server refused it before
|
|
622
622
|
// running it, so the retry cannot apply anything twice. A request that got no answer is never replayed.
|
|
@@ -666,7 +666,6 @@ const MAIN = String.raw `
|
|
|
666
666
|
}
|
|
667
667
|
}
|
|
668
668
|
|
|
669
|
-
// ---------- connection ----------
|
|
670
669
|
// A request that cannot reach the server shows a small notice and polls api/health, waiting 1 s and then up to 5 s
|
|
671
670
|
// between tries. Once it answers, the page renews its token and reloads the state; writes are left for the user.
|
|
672
671
|
const conn = { lost: false, timer: 0, delay: 1000 }
|
|
@@ -700,7 +699,6 @@ const MAIN = String.raw `
|
|
|
700
699
|
$('conn').hidden = !conn.lost
|
|
701
700
|
}
|
|
702
701
|
|
|
703
|
-
// ---------- toasts ----------
|
|
704
702
|
// Bottom center, newest last, at most three. The same text again restarts its timer instead of stacking.
|
|
705
703
|
// Hovering a toast pauses it, so an Undo stays reachable.
|
|
706
704
|
const toasts = []
|
|
@@ -766,7 +764,6 @@ const MAIN = String.raw `
|
|
|
766
764
|
setTimeout(done, 1000)
|
|
767
765
|
}
|
|
768
766
|
|
|
769
|
-
// ---------- small parts ----------
|
|
770
767
|
function ago(iso) {
|
|
771
768
|
const ts = Date.parse(iso)
|
|
772
769
|
if (!Number.isFinite(ts)) return ''
|
|
@@ -931,7 +928,6 @@ const MAIN = String.raw `
|
|
|
931
928
|
document.addEventListener('pointerdown', hideDataTip, true)
|
|
932
929
|
window.addEventListener('scroll', hideDataTip, true)
|
|
933
930
|
|
|
934
|
-
// ---------- floating panels: menus and popovers ----------
|
|
935
931
|
// One shared base for everything that floats next to a button: it is placed under (or above) its anchor, kept
|
|
936
932
|
// inside the window, closed by a click outside, Escape or a resize, and only one is open at a time. One taller than
|
|
937
933
|
// the room it gets scrolls inside itself (menuPlacement), and that scroll never closes it; a scroll of the page
|
|
@@ -1291,7 +1287,6 @@ const MAIN = String.raw `
|
|
|
1291
1287
|
return b
|
|
1292
1288
|
}
|
|
1293
1289
|
|
|
1294
|
-
// ---------- Doctor history ----------
|
|
1295
1290
|
// Health comes from the Doctor history, which keeps the latest result per Account: an Account that was
|
|
1296
1291
|
// never checked shows "Not checked", never "Healthy".
|
|
1297
1292
|
function entries() {
|
|
@@ -1322,18 +1317,19 @@ const MAIN = String.raw `
|
|
|
1322
1317
|
}
|
|
1323
1318
|
function setupFor(fam) { return S.state && S.state.quotaSetups.find((s) => s.family === fam) }
|
|
1324
1319
|
|
|
1325
|
-
// ---------- header and summary ----------
|
|
1326
1320
|
function renderUpdated() {
|
|
1327
1321
|
const busy = S.loading && !S.silent
|
|
1328
1322
|
const every = Math.round((S.fastUntil > Date.now() ? FAST_MS : AUTO_MS) / 1000)
|
|
1329
|
-
|
|
1323
|
+
// While Quota files are watched (spec §3.45), new numbers come as they land, not on the next round.
|
|
1324
|
+
const live = chg.watching && every === AUTO_MS / 1000
|
|
1325
|
+
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 }) : ''
|
|
1330
1326
|
const el = $('updated')
|
|
1331
1327
|
if (el.textContent !== text) el.textContent = text
|
|
1332
1328
|
// A dot says whether the numbers are live: green while they refresh on their own, amber when they stopped.
|
|
1333
1329
|
const stale = conn.lost || Boolean(S.loadError)
|
|
1334
1330
|
el.classList.toggle('is-live', Boolean(S.loadedAt) && !stale)
|
|
1335
1331
|
el.classList.toggle('is-stale', Boolean(S.loadedAt) && stale)
|
|
1336
|
-
el.title = !S.loadedAt ? '' : (stale ? t('top.stale') + ' ' : '') + t('top.updatedTitle', { at: clock(new Date(S.loadedAt).toISOString()), s:
|
|
1332
|
+
el.title = !S.loadedAt ? '' : (stale ? t('top.stale') + ' ' : '') + t(live ? 'top.updatedTitleLive' : 'top.updatedTitle', { at: clock(new Date(S.loadedAt).toISOString()), s: every })
|
|
1337
1333
|
}
|
|
1338
1334
|
function renderTop() {
|
|
1339
1335
|
renderUpdated()
|
|
@@ -1370,8 +1366,8 @@ const MAIN = String.raw `
|
|
|
1370
1366
|
}
|
|
1371
1367
|
function stat(label, value, sub, extra, opts) {
|
|
1372
1368
|
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]
|
|
1373
|
-
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)
|
|
1374
|
-
return h('div', { class: 'stat' + (opts && opts.cls ? ' ' + opts.cls : '') }, kids)
|
|
1369
|
+
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)
|
|
1370
|
+
return h('div', { class: 'stat' + (opts && opts.cls ? ' ' + opts.cls : ''), title: (opts && opts.title) || null }, kids)
|
|
1375
1371
|
}
|
|
1376
1372
|
function spark(daily, cls) {
|
|
1377
1373
|
if (!Array.isArray(daily) || !daily.length) return null
|
|
@@ -1417,6 +1413,7 @@ const MAIN = String.raw `
|
|
|
1417
1413
|
const daily = mergeDaily(usages.map((a) => a.usage.daily)).slice(-BOOT.usageDays)
|
|
1418
1414
|
const nr = nextReset(list, now)
|
|
1419
1415
|
patch(box, [
|
|
1416
|
+
pickNowStat(list, now),
|
|
1420
1417
|
stat(t('stat.accounts'), String(list.length), dots([tn('stat.families', famCount), apiCount ? tn('stat.api', apiCount) : null])),
|
|
1421
1418
|
need
|
|
1422
1419
|
? 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() } })
|
|
@@ -1428,7 +1425,52 @@ const MAIN = String.raw `
|
|
|
1428
1425
|
])
|
|
1429
1426
|
}
|
|
1430
1427
|
|
|
1431
|
-
//
|
|
1428
|
+
// "Best to use now" (spec §3.45): the account sideby next would pick in one tool, the quota it has left, and one click
|
|
1429
|
+
// that starts it. One value line and one line under it in every state, so the card keeps its size as answers change.
|
|
1430
|
+
function pickNowStat(list, now) {
|
|
1431
|
+
const pn = S.state.pickNow || {}
|
|
1432
|
+
const shownFams = new Set(list.map((a) => a.family))
|
|
1433
|
+
const choice = pickNowChoice(pn, familyOrder().filter((f) => shownFams.has(f)), prefs.family || '')
|
|
1434
|
+
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 : '') }))
|
|
1435
|
+
if (!choice) {
|
|
1436
|
+
const reading = list.some((a) => a.kind === 'subscription' && (a.pending || a.usagePending))
|
|
1437
|
+
return card(t('stat.pickNow'), '—', t(reading ? 'stat.pickReading' : prefs.family ? 'stat.pickNoSourceOne' : 'stat.pickNoSource'))
|
|
1438
|
+
}
|
|
1439
|
+
const fam = choice.family
|
|
1440
|
+
const e = pn[fam]
|
|
1441
|
+
const subs = list.filter((a) => a.family === fam && a.kind === 'subscription')
|
|
1442
|
+
const label = [...shownFams].filter((f) => pn[f]).length > 1 ? t('stat.pickNowIn', { title: family(fam).title }) : t('stat.pickNow')
|
|
1443
|
+
const shownName = (ref) => { const a = S.state.accounts.find((x) => x.ref === ref); return (a && a.aliases && a.aliases[0]) || ref }
|
|
1444
|
+
// Why a tool has no pick, in a few words: "All used up · claude:main is back in 1h 35m".
|
|
1445
|
+
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')
|
|
1446
|
+
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
|
|
1447
|
+
if (!e.pick) {
|
|
1448
|
+
if (e.why === 'used-up') {
|
|
1449
|
+
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')
|
|
1450
|
+
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 })
|
|
1451
|
+
}
|
|
1452
|
+
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 })
|
|
1453
|
+
}
|
|
1454
|
+
const a = S.state.accounts.find((x) => x.ref === e.pick)
|
|
1455
|
+
const left = pickLeft(a, now)
|
|
1456
|
+
const sub = e.reason === 'unknown' ? t('stat.pickNoData') : e.reason === 'tight' ? t('stat.pickTight') + ' · ' + left : left
|
|
1457
|
+
const keys = { expiring: 'acct.nextWhyExpiring', room: 'acct.nextWhyRoom', tight: 'acct.nextWhyTight', unknown: 'acct.nextWhyUnknown' }
|
|
1458
|
+
const why = subs.length > 1 ? t(keys[e.reason] || 'acct.nextWhy', { title: family(fam).title }) : t('stat.pickOnly', { title: family(fam).title })
|
|
1459
|
+
const act = BOOT.readOnly ? t('stat.pickCopyTip', { family: fam }) : t('stat.pickStartTip')
|
|
1460
|
+
// A short command on the card: the account's full name heads the hover text.
|
|
1461
|
+
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')
|
|
1462
|
+
return card(label, shownName(e.pick), sub, h('span', { class: 'stat-act' }, icon(BOOT.readOnly ? 'copy' : 'terminal'), t(BOOT.readOnly ? 'stat.pickCopy' : 'stat.pickStart')),
|
|
1463
|
+
{ cls: 'stat-acct' + (e.reason === 'tight' ? ' stat-warn' : ''), title, onclick: () => (BOOT.readOnly ? copyText('sideby next ' + fam) : startPick(null, fam)) })
|
|
1464
|
+
}
|
|
1465
|
+
// The quota an account has left in each counted window, shortest first: "5-hour 72% left · Weekly 40% left".
|
|
1466
|
+
function pickLeft(a, now) {
|
|
1467
|
+
const q = a && a.quota
|
|
1468
|
+
if (!q || q.status !== 'ok') return t('stat.pickNoData')
|
|
1469
|
+
const wins = (q.windows || []).filter((w) => !w.name).slice().sort((x, y) => (Number(x.windowMinutes) || 0) - (Number(y.windowMinutes) || 0))
|
|
1470
|
+
if (!wins.length) return t('stat.pickNoData')
|
|
1471
|
+
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(' · ')
|
|
1472
|
+
}
|
|
1473
|
+
|
|
1432
1474
|
const tb = {}
|
|
1433
1475
|
function seg(label, options, value, onPick) {
|
|
1434
1476
|
const btns = options.map((o) => h('button', { class: 'seg-btn', type: 'button', 'aria-pressed': String(o[0] === value), title: o[2] || null, 'aria-label': o[2] || t('tb.segLabel', { group: label, option: o[1] }), onclick: () => {
|
|
@@ -1517,7 +1559,6 @@ const MAIN = String.raw `
|
|
|
1517
1559
|
}
|
|
1518
1560
|
})
|
|
1519
1561
|
|
|
1520
|
-
// ---------- accounts ----------
|
|
1521
1562
|
// One column per Quota window label. 5h and 7d always have one, so rows of every group line up under the same
|
|
1522
1563
|
// header; a label only some account reports (such as 60m) adds a column, at most three in all.
|
|
1523
1564
|
const KNOWN_WINDOWS = { '5h': 300, '7d': 10080 }
|
|
@@ -1918,6 +1959,13 @@ const MAIN = String.raw `
|
|
|
1918
1959
|
}
|
|
1919
1960
|
function usageBlock(a) {
|
|
1920
1961
|
const u = a.usage
|
|
1962
|
+
// Its usage is still being parsed while the rest is in: two lines, as the numbers take, so the row keeps its height.
|
|
1963
|
+
if (!u && a.usagePending) {
|
|
1964
|
+
return h('div', { class: 'usage', 'aria-busy': 'true' },
|
|
1965
|
+
h('div', { class: 'u-text' },
|
|
1966
|
+
h('span', { class: 'u-num faint' }, '—'),
|
|
1967
|
+
h('div', { class: 'u-sub' }, t('acct.reading', { host: famTitle(a) }))))
|
|
1968
|
+
}
|
|
1921
1969
|
if (!u) return h('div', { class: 'usage' })
|
|
1922
1970
|
if (u.status !== 'ok') {
|
|
1923
1971
|
const key = u.reason === 'no-session' ? 'usage.none' : u.reason === 'no-source' ? 'usage.noSource' : 'usage.unreadable'
|
|
@@ -3235,7 +3283,6 @@ const MAIN = String.raw `
|
|
|
3235
3283
|
setTimeout(() => el.classList.remove('flash'), 2600)
|
|
3236
3284
|
}
|
|
3237
3285
|
|
|
3238
|
-
// ---------- Health check ----------
|
|
3239
3286
|
async function runCheck() {
|
|
3240
3287
|
if (S.checking || S.fixing) return
|
|
3241
3288
|
S.checking = true
|
|
@@ -3392,7 +3439,6 @@ const MAIN = String.raw `
|
|
|
3392
3439
|
extra ? h('span', { class: 'note-sub' }, extra) : null)
|
|
3393
3440
|
}
|
|
3394
3441
|
|
|
3395
|
-
// ---------- dialogs ----------
|
|
3396
3442
|
const dlg = { el: null, kind: null, busy: false, onClose: null }
|
|
3397
3443
|
function ensureDialog() {
|
|
3398
3444
|
if (dlg.el) return dlg.el
|
|
@@ -4758,7 +4804,6 @@ const MAIN = String.raw `
|
|
|
4758
4804
|
renderHistorySide()
|
|
4759
4805
|
historyChanged(false)
|
|
4760
4806
|
}
|
|
4761
|
-
// ---------- grouping the list ----------
|
|
4762
4807
|
// A "Display" popover by the filters picks how the list is grouped; a group folds from its header and stays
|
|
4763
4808
|
// folded in this browser. The server pages through the groups in order and counts folded ones without their rows.
|
|
4764
4809
|
function groupName(by) {
|
|
@@ -5083,7 +5128,6 @@ const MAIN = String.raw `
|
|
|
5083
5128
|
Promise.resolve(loadHistory(false, d.sessions.length, true)).then(loadProjects)
|
|
5084
5129
|
}
|
|
5085
5130
|
|
|
5086
|
-
// ---------- reading one past session ----------
|
|
5087
5131
|
// Read only. The newest 200 messages first, older ones on request; a run of tool calls is one line. The dialog
|
|
5088
5132
|
// opens once the messages are in, at its final size, scrolled to the end.
|
|
5089
5133
|
const hv = { data: null, open: {}, loading: false }
|
|
@@ -5742,7 +5786,6 @@ const MAIN = String.raw `
|
|
|
5742
5786
|
load()
|
|
5743
5787
|
}
|
|
5744
5788
|
|
|
5745
|
-
// ---------- auto handoff ----------
|
|
5746
5789
|
// Settings come with /api/state; readiness (which runs a check of the sideby on PATH) only when the dialog opens.
|
|
5747
5790
|
let ah = null
|
|
5748
5791
|
const HINT_QUIET_MS = 24 * 3600000
|
|
@@ -6065,7 +6108,6 @@ const MAIN = String.raw `
|
|
|
6065
6108
|
setKids(dlg.el, dialogFrame(t('md.title') + ' · ' + a.ref, a.family, body, foot))
|
|
6066
6109
|
}
|
|
6067
6110
|
|
|
6068
|
-
// ---------- the Auto Handoff page ----------
|
|
6069
6111
|
// Off: one sentence and one button. On: where each account's work would go next, the last hand-overs and what is
|
|
6070
6112
|
// still missing. Turning on is one plan shown first (hp.preview) and one confirmation; no commands to copy.
|
|
6071
6113
|
const hp = { data: null, plan: null, loading: false, error: null, preview: null, previewing: false, applying: false, failed: null, changed: false, busyOff: false, askSame: false, askApi: false }
|
|
@@ -6264,7 +6306,8 @@ const MAIN = String.raw `
|
|
|
6264
6306
|
const st = ahState().settings
|
|
6265
6307
|
return st.sameFamily && st.otherFamilies ? null : h('p', { class: 'note', 'data-enter': 'none-hint' }, t('hp.noneAll'))
|
|
6266
6308
|
}
|
|
6267
|
-
//
|
|
6309
|
+
// A user who turned Auto Handoff on before API accounts needed their own switch has not chosen yet (ADR-0046);
|
|
6310
|
+
// this asks once, and either answer ends the question.
|
|
6268
6311
|
function hpApiBanner() {
|
|
6269
6312
|
const st = ahState()
|
|
6270
6313
|
if (!st || !st.apiUndecided || BOOT.readOnly) return null
|
|
@@ -6377,7 +6420,6 @@ const MAIN = String.raw `
|
|
|
6377
6420
|
renderPageChrome()
|
|
6378
6421
|
}
|
|
6379
6422
|
|
|
6380
|
-
// ---------- words ----------
|
|
6381
6423
|
// A moment relative to now: "08:00" today, else "tomorrow 08:00", "Mon 08:00" or "Nov 3 08:00".
|
|
6382
6424
|
function uaDayWord(ms, now) {
|
|
6383
6425
|
const w = uaWhen(ms, now)
|
|
@@ -6416,7 +6458,6 @@ const MAIN = String.raw `
|
|
|
6416
6458
|
return [t('ua.off'), p.next ? uaAt('next', p.next.at) : null]
|
|
6417
6459
|
}
|
|
6418
6460
|
|
|
6419
|
-
// ---------- the header badge ----------
|
|
6420
6461
|
// "Unattended · until 08:00" while it is on, to the page in one click. It fades in and out; a refresh with the same
|
|
6421
6462
|
// words leaves it alone.
|
|
6422
6463
|
function renderUaBadge() {
|
|
@@ -6448,7 +6489,6 @@ const MAIN = String.raw `
|
|
|
6448
6489
|
}
|
|
6449
6490
|
}
|
|
6450
6491
|
|
|
6451
|
-
// ---------- motion ----------
|
|
6452
6492
|
// Like patch, and a [data-ua] part that was not there grows in while one that went away shrinks out where it was.
|
|
6453
6493
|
// A first draw animates nothing; reduced motion only switches.
|
|
6454
6494
|
function uaPatch(box, kids) {
|
|
@@ -6497,7 +6537,6 @@ const MAIN = String.raw `
|
|
|
6497
6537
|
a.finished.then(end, end)
|
|
6498
6538
|
}
|
|
6499
6539
|
|
|
6500
|
-
// ---------- turning it on and off ----------
|
|
6501
6540
|
function uaOpenChooser() {
|
|
6502
6541
|
const st = uaStatusNow()
|
|
6503
6542
|
if (!st) return
|
|
@@ -6573,7 +6612,6 @@ const MAIN = String.raw `
|
|
|
6573
6612
|
uaRedraw()
|
|
6574
6613
|
}
|
|
6575
6614
|
|
|
6576
|
-
// ---------- the Schedule ----------
|
|
6577
6615
|
// Each row keeps an id while the page shows it, so a removed Slot is the row that leaves and an edited one stays the
|
|
6578
6616
|
// same element (focus stays in its time field). A Schedule changed elsewhere matches rows by what they cover.
|
|
6579
6617
|
function uaSchedule() {
|
|
@@ -6712,7 +6750,6 @@ const MAIN = String.raw `
|
|
|
6712
6750
|
return out
|
|
6713
6751
|
}
|
|
6714
6752
|
|
|
6715
|
-
// ---------- Pending Decisions ----------
|
|
6716
6753
|
function uaWhenShort(iso) {
|
|
6717
6754
|
const ms = Date.parse(iso)
|
|
6718
6755
|
const now = Date.now()
|
|
@@ -6940,7 +6977,6 @@ const MAIN = String.raw `
|
|
|
6940
6977
|
})))]
|
|
6941
6978
|
}
|
|
6942
6979
|
|
|
6943
|
-
// ---------- the page ----------
|
|
6944
6980
|
function uaCoverage(st) {
|
|
6945
6981
|
const have = new Set(S.state.accounts.map((a) => a.family))
|
|
6946
6982
|
const lines = [h('li', null, t('ua.coverLine'))]
|
|
@@ -7287,9 +7323,8 @@ const MAIN = String.raw `
|
|
|
7287
7323
|
return out
|
|
7288
7324
|
}
|
|
7289
7325
|
function famTitleOf(fam) { const f = S.state && S.state.families.find((x) => x.id === fam); return f ? f.title : fam }
|
|
7290
|
-
//
|
|
7291
|
-
//
|
|
7292
|
-
// A dot on it says Remote Control starts by itself, so that state stays visible after its banner is gone.
|
|
7326
|
+
// One header button opens the settings; settingsSections() lists the sections that have something to show
|
|
7327
|
+
// right now, and the button hides when none do. A dot on it says Remote Control starts by itself, so that state stays visible after its banner is gone.
|
|
7293
7328
|
function settingsSections() {
|
|
7294
7329
|
const out = []
|
|
7295
7330
|
if (!LANG_FIXED) out.push('lang')
|
|
@@ -7353,7 +7388,7 @@ const MAIN = String.raw `
|
|
|
7353
7388
|
return setLink(leave, t('ai.title'), t(skillInstalled() ? 'ai.installed' : 'ai.notInstalled'), skillInstalled() ? 'chip-ok' : '', () => openAsk(), true)
|
|
7354
7389
|
}
|
|
7355
7390
|
// The dialog's sections, in order: General, Menu bar, Accounts, Quota checks, Auto Handoff, Progress updates,
|
|
7356
|
-
// Network check, Let AI help. Each is
|
|
7391
|
+
// Folder trust, Shared memory, Network check, Let AI help. Each is
|
|
7357
7392
|
// { id, title, items, foot }: foot is the one line that explains the whole section.
|
|
7358
7393
|
function settingsGroups(leave) {
|
|
7359
7394
|
const secs = settingsSections()
|
|
@@ -9171,13 +9206,16 @@ const MAIN = String.raw `
|
|
|
9171
9206
|
const input = fam && document.getElementById('pk-name-' + fam)
|
|
9172
9207
|
if (input) input.focus()
|
|
9173
9208
|
}
|
|
9174
|
-
|
|
9209
|
+
// By the Pick Command's name, or by tool (the "Best to use now" card, spec §3.45).
|
|
9210
|
+
async function startPick(name, fam) {
|
|
9175
9211
|
if (BOOT.readOnly) { copyText(name, name); return }
|
|
9176
9212
|
try {
|
|
9177
|
-
const r = await api('/api/pick/start', { name })
|
|
9213
|
+
const r = await api('/api/pick/start', name ? { name } : { family: fam })
|
|
9178
9214
|
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')
|
|
9179
|
-
|
|
9180
|
-
|
|
9215
|
+
// The start counts for the next pick (ADR-0083): the card and the Next mark move on at once.
|
|
9216
|
+
if (r.opened) { toast(t('pk.started', { terminal: TERM_NAMES[r.terminal] || r.terminal, ref: r.picked, why })); load({ silent: true }); return }
|
|
9217
|
+
const cmd = name || 'sideby run ' + r.picked
|
|
9218
|
+
await copyText(cmd, cmd)
|
|
9181
9219
|
toast(r.automation ? t('login.automation', { terminal: TERM_NAMES[r.terminal] || r.terminal }) : t('login.failed'), { kind: 'info' })
|
|
9182
9220
|
} catch (e) { toast(e.message, { kind: 'fail' }) }
|
|
9183
9221
|
}
|
|
@@ -9423,7 +9461,6 @@ const MAIN = String.raw `
|
|
|
9423
9461
|
return h('button', { class: 'link-btn small', type: 'button', 'aria-label': full, 'data-tip': full, onclick: () => openPick(fam) }, offer.name ? t('pk.offerShort', { name: offer.name }) : t('pk.offerNoNameShort'))
|
|
9424
9462
|
}
|
|
9425
9463
|
|
|
9426
|
-
// ---------- banners ----------
|
|
9427
9464
|
// Offered once on macOS (spec §3.31), when quota shows and the menu bar item is off; "No thanks" is for good.
|
|
9428
9465
|
function menubarHint() {
|
|
9429
9466
|
if (BOOT.readOnly || prefs.mbHintDone) return null
|
|
@@ -9512,7 +9549,6 @@ const MAIN = String.raw `
|
|
|
9512
9549
|
exb.el = el
|
|
9513
9550
|
}
|
|
9514
9551
|
|
|
9515
|
-
// ---------- loading ----------
|
|
9516
9552
|
function renderAll() { renderTop(); renderBanners(); renderSummary(); renderFamilyFilter(); renderAccounts(); renderCheckup(); renderPageChrome() }
|
|
9517
9553
|
// A load that starts while another runs is queued, never dropped, so a change made meanwhile (a new
|
|
9518
9554
|
// account, a fix) always ends up on screen; and only the newest response is ever rendered. A silent load is a
|
|
@@ -9580,11 +9616,12 @@ const MAIN = String.raw `
|
|
|
9580
9616
|
sessionsTick()
|
|
9581
9617
|
messagesTick()
|
|
9582
9618
|
if (document.visibilityState !== 'visible' || !S.state) return
|
|
9619
|
+
watchChanges()
|
|
9583
9620
|
if (S.pending && !S.loading && !uiBusy()) { S.pending = false; renderAll() }
|
|
9584
9621
|
const now = Date.now()
|
|
9585
9622
|
// An Account still being read is asked for again soon, so it fills in without waiting for the next round.
|
|
9586
9623
|
// For half a minute: the server says "took too long" after a minute, which the normal round then shows.
|
|
9587
|
-
const pending = S.state.accounts.some((a) => a.pending)
|
|
9624
|
+
const pending = S.state.accounts.some((a) => a.pending || a.usagePending || a.refreshing)
|
|
9588
9625
|
if (!pending) S.pendingSince = 0
|
|
9589
9626
|
else if (!S.pendingSince) S.pendingSince = now
|
|
9590
9627
|
// A Host being asked for its Quota behind the kept answer (spec §3.26): its row takes the new numbers as soon as
|
|
@@ -9595,6 +9632,35 @@ const MAIN = String.raw `
|
|
|
9595
9632
|
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
|
|
9596
9633
|
if (!S.loading && !conn.lost && !S.fixing && !S.checking && !dlg.busy && now - S.lastTry >= every) load({ silent: true })
|
|
9597
9634
|
}
|
|
9635
|
+
// One request held open while the page is visible: the server answers it when a Quota file changes, and the page
|
|
9636
|
+
// reads its state at once. Not through api(): a request this page stops when hidden is not a lost connection.
|
|
9637
|
+
async function watchChanges() {
|
|
9638
|
+
if (chg.ctl || chg.off || conn.lost || document.visibilityState !== 'visible' || Date.now() < chg.retryAt) return
|
|
9639
|
+
const ctl = new AbortController()
|
|
9640
|
+
chg.ctl = ctl
|
|
9641
|
+
let res = null
|
|
9642
|
+
let data = null
|
|
9643
|
+
try {
|
|
9644
|
+
res = await fetch(BOOT.basePath + '/api/changes' + (chg.seq === null ? '' : '?since=' + chg.seq), { cache: 'no-store', signal: ctl.signal })
|
|
9645
|
+
if (res.ok) data = await res.json()
|
|
9646
|
+
} catch {}
|
|
9647
|
+
chg.ctl = null
|
|
9648
|
+
if (res && res.status === 404) { chg.off = true; chg.watching = false; renderUpdated(); return }
|
|
9649
|
+
if (!data || typeof data.seq !== 'number') {
|
|
9650
|
+
if (!ctl.signal.aborted) chg.retryAt = Date.now() + 5000
|
|
9651
|
+
return
|
|
9652
|
+
}
|
|
9653
|
+
chg.seq = data.seq
|
|
9654
|
+
if (chg.watching !== Boolean(data.watching)) { chg.watching = Boolean(data.watching); renderUpdated() }
|
|
9655
|
+
if (!data.watching) chg.retryAt = Date.now() + 60000
|
|
9656
|
+
if (data.changed) quotaChanged()
|
|
9657
|
+
watchChanges()
|
|
9658
|
+
}
|
|
9659
|
+
// A Quota file changed: read now, or, while a check, a fix or a dialog's work runs, at the first tick after it.
|
|
9660
|
+
function quotaChanged() {
|
|
9661
|
+
if (!conn.lost && !S.fixing && !S.checking && !dlg.busy) load({ silent: true })
|
|
9662
|
+
else S.lastTry = 0
|
|
9663
|
+
}
|
|
9598
9664
|
// Coming back to the page refreshes at once.
|
|
9599
9665
|
function wake() {
|
|
9600
9666
|
// Back from the vendor's page a Limit Reset is used on: that account's quota is asked once (ADR-0072).
|
|
@@ -9996,7 +10062,6 @@ const MAIN = String.raw `
|
|
|
9996
10062
|
setKids(dlg.el, dialogFrame(t('upd.title'), null, body, foot))
|
|
9997
10063
|
}
|
|
9998
10064
|
|
|
9999
|
-
// ---------- start ----------
|
|
10000
10065
|
$('ver').textContent = BOOT.version ? 'sideby v' + BOOT.version : 'sideby'
|
|
10001
10066
|
$('ver').disabled = !BOOT.updates
|
|
10002
10067
|
$('ver').addEventListener('click', () => openVerPop($('ver')))
|
|
@@ -10052,7 +10117,11 @@ const MAIN = String.raw `
|
|
|
10052
10117
|
// The sessions too, so the Sessions page opens with its rows already there.
|
|
10053
10118
|
loadSessions()
|
|
10054
10119
|
setInterval(tick, 1000)
|
|
10055
|
-
document.addEventListener('visibilitychange', () => {
|
|
10120
|
+
document.addEventListener('visibilitychange', () => {
|
|
10121
|
+
// A hidden page holds no request: browsers give a site only a few connections.
|
|
10122
|
+
if (document.visibilityState !== 'visible') { resetLeft(); if (chg.ctl) chg.ctl.abort() }
|
|
10123
|
+
wake()
|
|
10124
|
+
})
|
|
10056
10125
|
window.addEventListener('blur', resetLeft)
|
|
10057
10126
|
window.addEventListener('focus', wake)
|
|
10058
10127
|
// A Portal that changed something the Panel shows says so (ADR-0006): read the state now instead of at the next
|