sideby 0.21.0 → 0.23.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/README.md +1 -0
- package/ai-tasks.json +14 -0
- package/dist/build.json +1 -1
- package/dist/src/cli/commands.d.ts +7 -0
- package/dist/src/cli/commands.js +441 -31
- package/dist/src/cli/format.js +3 -2
- package/dist/src/cli/json-schemas.js +157 -47
- package/dist/src/cli/main.js +38 -7
- package/dist/src/core/accounts.d.ts +6 -1
- package/dist/src/core/accounts.js +16 -3
- package/dist/src/core/ask.d.ts +2 -1
- package/dist/src/core/ask.js +12 -4
- package/dist/src/core/claude-settings-file.d.ts +57 -0
- package/dist/src/core/claude-settings-file.js +104 -2
- package/dist/src/core/config.d.ts +34 -16
- package/dist/src/core/config.js +58 -5
- package/dist/src/core/create.js +4 -1
- package/dist/src/core/desktop-app.js +5 -1
- package/dist/src/core/handoff-overview.d.ts +4 -1
- package/dist/src/core/handoff-overview.js +3 -2
- package/dist/src/core/handoff-rules.d.ts +34 -0
- package/dist/src/core/handoff-rules.js +115 -0
- package/dist/src/core/handoff-select.js +45 -28
- package/dist/src/core/handoff-status.d.ts +37 -7
- package/dist/src/core/handoff-status.js +95 -19
- package/dist/src/core/handoff.d.ts +4 -1
- package/dist/src/core/handoff.js +8 -5
- package/dist/src/core/inbound.d.ts +11 -3
- package/dist/src/core/inbound.js +26 -74
- package/dist/src/core/launch.js +6 -4
- package/dist/src/core/quota-levels.d.ts +13 -2
- package/dist/src/core/quota-levels.js +21 -3
- package/dist/src/core/remote-control.d.ts +10 -12
- package/dist/src/core/remote-control.js +29 -86
- package/dist/src/core/themes.d.ts +107 -0
- package/dist/src/core/themes.js +463 -0
- package/dist/src/core/tuning-apply.js +12 -20
- package/dist/src/families/agy/index.d.ts +8 -0
- package/dist/src/families/agy/index.js +53 -0
- package/dist/src/families/agy/quota.d.ts +9 -0
- package/dist/src/families/agy/quota.js +110 -0
- package/dist/src/families/index.js +7 -0
- package/dist/src/families/logos.d.ts +10 -0
- package/dist/src/families/logos.js +12 -1
- package/dist/src/menubar/script.js +26 -3
- package/dist/src/menubar/snapshot.d.ts +33 -6
- package/dist/src/menubar/snapshot.js +138 -43
- package/dist/src/menubar/strings.d.ts +18 -2
- package/dist/src/menubar/strings.js +18 -2
- package/dist/src/panel/handler.d.ts +4 -1
- package/dist/src/panel/handler.js +206 -46
- package/dist/src/panel/i18n.d.ts +106 -7
- package/dist/src/panel/i18n.js +260 -62
- package/dist/src/panel/page-logic.d.ts +67 -20
- package/dist/src/panel/page-logic.js +74 -7
- package/dist/src/panel/page-script.js +522 -124
- package/dist/src/panel/page-styles.d.ts +2 -0
- package/dist/src/panel/page-styles.js +157 -34
- package/dist/src/panel/page.js +3 -3
- package/dist/src/panel/theme.d.ts +6 -1
- package/dist/src/panel/theme.js +4 -0
- package/dist/src/panel/themes.d.ts +14 -0
- package/dist/src/panel/themes.js +162 -0
- package/dist/src/plugins/check.js +27 -13
- package/dist/src/plugins/loader.d.ts +11 -0
- package/dist/src/plugins/loader.js +47 -1
- package/dist/src/runtime.d.ts +9 -2
- package/dist/src/runtime.js +12 -5
- package/dist/src/types.d.ts +35 -5
- package/package.json +2 -2
- package/schemas/config.json +45 -2
- package/schemas/families.json +13 -5
- package/schemas/handoff-disable.json +22 -0
- package/schemas/handoff-enable.json +22 -0
- package/schemas/handoff-rules.json +302 -0
- package/schemas/handoff-status.json +26 -0
- package/schemas/hide.json +157 -0
- package/schemas/list.json +15 -0
- package/schemas/menubar-snapshot.json +309 -2
- package/schemas/order.json +26 -1
- package/schemas/pin.json +17 -0
- package/schemas/theme-check.json +140 -0
- package/schemas/theme-export.json +86 -0
- package/schemas/theme-import.json +92 -0
- package/schemas/theme-preview.json +86 -0
- package/schemas/theme-remove.json +87 -0
- package/schemas/theme-use.json +88 -0
- package/schemas/theme.json +137 -0
- package/schemas/unhide.json +157 -0
- package/schemas/unpin.json +17 -0
- package/skills/sideby/SKILL.md +5 -2
- package/skills/sideby/references/accounts.md +1 -0
- package/skills/sideby/references/ai-tasks.md +1 -1
- package/skills/sideby/references/handoff.md +7 -3
- package/skills/sideby/references/panel.md +9 -0
- package/skills/sideby/references/quota.md +3 -1
- package/skills/sideby/references/themes.md +47 -0
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
// The Panel page's inline script. Plain browser JavaScript in a string (no template literals inside, so String.raw
|
|
2
2
|
// keeps it verbatim); the pure helpers from page-logic.ts are prepended so the tested code is the code that runs.
|
|
3
|
+
import { groupsToAccept } from '../core/inbound.js';
|
|
3
4
|
import { quotaIsStale } from '../core/quota-levels.js';
|
|
4
|
-
import {
|
|
5
|
+
import { remoteControlTodo } from '../core/remote-control.js';
|
|
6
|
+
import { aiTaskAccounts, aliasArgsOf, aliasIssue, askBridge, askBridged, askCopy, attentionReasons, attentionWhy, autostartNote, bindingWindow, cacheHitRate, canLeaveLocal, categoryOrder, codeSwapOutcome, enableOutcome, fileSize, fixPrompt, foldSkips, foldToolCalls, formatDuration, handoffChangeOf, handoffHintAccount, handoffTaskFacts, hiddenIn, highlightParts, histFilters, historyEmpty, historyWhen, hotkeyFromKey, hotkeyPressKind, inDisplayOrder, loginClusters, loginKey, maskEmail, matchesQuery, mdBlocks, mdInline, menuPlacement, mergeDaily, mergeUsage, messageChip, messageNews, newAccountDir, nextReset, panelFixes, panelHint, panelLang, panelMigration, panelPrefs, passedWindow, pinnedIn, quotaAskable, quotaHighLevel, quotaPressure, remoteControlSummary, reorder, rowBadge, runCodeSwap, saveHandoffChange, sendBlock, sendFileProblem, sendResultView, sessionAge, sessionLabelParts, shortCwd, shortSessionLabel, sortAccounts, sortSessions, steadyOrder, stripSecrets, suggestAlias, suggestName, switchFailure, tailInView, taskFindings, updatedAge, widthFollower, widthTier, windowState, withPinned, } from './page-logic.js';
|
|
5
7
|
const LOGIC = [
|
|
6
8
|
quotaIsStale,
|
|
7
9
|
aiTaskAccounts,
|
|
@@ -15,6 +17,7 @@ const LOGIC = [
|
|
|
15
17
|
aliasIssue,
|
|
16
18
|
attentionReasons,
|
|
17
19
|
attentionWhy,
|
|
20
|
+
quotaHighLevel,
|
|
18
21
|
autostartNote,
|
|
19
22
|
hotkeyFromKey,
|
|
20
23
|
hotkeyPressKind,
|
|
@@ -56,6 +59,9 @@ const LOGIC = [
|
|
|
56
59
|
quotaPressure,
|
|
57
60
|
remoteControlSummary,
|
|
58
61
|
remoteControlTodo,
|
|
62
|
+
groupsToAccept,
|
|
63
|
+
saveHandoffChange,
|
|
64
|
+
enableOutcome,
|
|
59
65
|
reorder,
|
|
60
66
|
rowBadge,
|
|
61
67
|
sendBlock,
|
|
@@ -76,9 +82,11 @@ const LOGIC = [
|
|
|
76
82
|
tailInView,
|
|
77
83
|
updatedAge,
|
|
78
84
|
pinnedIn,
|
|
85
|
+
hiddenIn,
|
|
79
86
|
widthFollower,
|
|
80
87
|
widthTier,
|
|
81
88
|
windowState,
|
|
89
|
+
bindingWindow,
|
|
82
90
|
withPinned,
|
|
83
91
|
]
|
|
84
92
|
.map((fn) => fn.toString())
|
|
@@ -348,6 +356,11 @@ const MAIN = String.raw `
|
|
|
348
356
|
}
|
|
349
357
|
|
|
350
358
|
const ICONS = {
|
|
359
|
+
// Lucide "users-round", "messages-square", "gauge" and "route" for the page tabs (ISC license)
|
|
360
|
+
tabAccounts: 'M18 21a8 8 0 0 0-16 0M5 8a5 5 0 1 0 10 0 5 5 0 1 0-10 0M22 20c0-3.37-2-6.5-4-8a5 5 0 0 0-.45-8.3',
|
|
361
|
+
tabSessions: 'M16 10a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 14.286V4a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2zM20 9a2 2 0 0 1 2 2v10.286a.71.71 0 0 1-1.212.502l-2.202-2.202A2 2 0 0 0 17.172 19H10a2 2 0 0 1-2-2v-1',
|
|
362
|
+
tabTuning: 'm12 14 4-4M3.34 19a10 10 0 1 1 17.32 0',
|
|
363
|
+
tabHandoff: 'M3 19a3 3 0 1 0 6 0 3 3 0 1 0-6 0M9 19h8.5a3.5 3.5 0 0 0 0-7h-11a3.5 3.5 0 0 1 0-7H15M15 5a3 3 0 1 0 6 0 3 3 0 1 0-6 0',
|
|
351
364
|
refresh: 'M20 11a8 8 0 1 0-2.3 5.7M20 4v7h-7',
|
|
352
365
|
search: 'M11 18a7 7 0 1 0 0-14 7 7 0 0 0 0 14zM20 20l-4.2-4.2',
|
|
353
366
|
chevron: 'M9 6l6 6-6 6',
|
|
@@ -380,6 +393,9 @@ const MAIN = String.raw `
|
|
|
380
393
|
grid: 'M4 4h7v7H4zM13 4h7v7h-7zM4 13h7v7H4zM13 13h7v7h-7z',
|
|
381
394
|
list: 'M9 6h11M9 12h11M9 18h11M4 6h.01M4 12h.01M4 18h.01',
|
|
382
395
|
sliders: 'M4 7h10M18 7h2M4 17h4M12 17h8M16 5v4M10 15v4',
|
|
396
|
+
// Lucide "users" and "message-square" (ISC license)
|
|
397
|
+
users: 'M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2M9 11a4 4 0 1 0 0-8 4 4 0 0 0 0 8zM22 21v-2a4 4 0 0 0-3-3.87M16 3.13a4 4 0 0 1 0 7.75',
|
|
398
|
+
messages: 'M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z',
|
|
383
399
|
clock: 'M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18zM12 7v5l3 2',
|
|
384
400
|
mail: 'M3 6h18v12H3zM3 7l9 6 9-6',
|
|
385
401
|
globe: 'M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18zM3 12h18M12 3c2.5 2.5 3.8 5.5 3.8 9s-1.3 6.5-3.8 9c-2.5-2.5-3.8-5.5-3.8-9S9.5 5.5 12 3z',
|
|
@@ -592,6 +608,7 @@ const MAIN = String.raw `
|
|
|
592
608
|
function famTitle(a) { return a.familyTitle || family(a.family).title }
|
|
593
609
|
// The email as the page shows it: masked everywhere while "Hide emails" is on (copying still gives the real one).
|
|
594
610
|
function emailText(email) { return prefs.hideEmail ? maskEmail(email) : email }
|
|
611
|
+
let logoWashes = 0
|
|
595
612
|
// A Family's mark: the logo its FamilyDef sets (checked by the loader), or its initials on a color derived from the id.
|
|
596
613
|
// size: '' (cards), 'sm' (rows, groups, dialogs) or 'xs' (inside a chip; no initials fallback there).
|
|
597
614
|
function badge(id, size) {
|
|
@@ -601,10 +618,36 @@ const MAIN = String.raw `
|
|
|
601
618
|
const svg = document.createElementNS(SVG_NS, 'svg')
|
|
602
619
|
svg.setAttribute('viewBox', '0 0 24 24')
|
|
603
620
|
svg.setAttribute('focusable', 'false')
|
|
604
|
-
const
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
621
|
+
const shape = (fill) => {
|
|
622
|
+
const path = document.createElementNS(SVG_NS, 'path')
|
|
623
|
+
path.setAttribute('d', logo.path)
|
|
624
|
+
if (logo.fillRule) path.setAttribute('fill-rule', logo.fillRule)
|
|
625
|
+
if (fill) path.setAttribute('fill', fill)
|
|
626
|
+
return path
|
|
627
|
+
}
|
|
628
|
+
svg.append(shape(null))
|
|
629
|
+
// A multicoloured mark: each wash is the shape again, filled with a gradient that fades out (ids unique per page).
|
|
630
|
+
if (Array.isArray(logo.gradients) && logo.gradients.length) {
|
|
631
|
+
const defs = document.createElementNS(SVG_NS, 'defs')
|
|
632
|
+
svg.prepend(defs)
|
|
633
|
+
for (const g of logo.gradients) {
|
|
634
|
+
const id = 'logo-wash-' + (++logoWashes)
|
|
635
|
+
const lg = document.createElementNS(SVG_NS, 'linearGradient')
|
|
636
|
+
lg.setAttribute('id', id)
|
|
637
|
+
lg.setAttribute('gradientUnits', 'userSpaceOnUse')
|
|
638
|
+
lg.setAttribute('x1', String(g.from[0])); lg.setAttribute('y1', String(g.from[1]))
|
|
639
|
+
lg.setAttribute('x2', String(g.to[0])); lg.setAttribute('y2', String(g.to[1]))
|
|
640
|
+
for (const [offset, opacity] of [['0', '1'], ['1', '0']]) {
|
|
641
|
+
const stop = document.createElementNS(SVG_NS, 'stop')
|
|
642
|
+
stop.setAttribute('offset', offset)
|
|
643
|
+
stop.setAttribute('stop-color', g.color)
|
|
644
|
+
stop.setAttribute('stop-opacity', opacity)
|
|
645
|
+
lg.append(stop)
|
|
646
|
+
}
|
|
647
|
+
defs.append(lg)
|
|
648
|
+
svg.append(shape('url(#' + id + ')'))
|
|
649
|
+
}
|
|
650
|
+
}
|
|
608
651
|
return h('span', { class: cls + ' badge-logo', css: logo.color ? { color: logo.color } : null, title: logo.title || family(id).title, 'aria-hidden': 'true' }, svg)
|
|
609
652
|
}
|
|
610
653
|
if (size === 'xs') return null
|
|
@@ -918,7 +961,8 @@ const MAIN = String.raw `
|
|
|
918
961
|
a.identity && a.identity.email ? { icon: 'mail', label: t('menu.copyEmail'), hint: emailText(a.identity.email), run: () => copyText(a.identity.email) } : null,
|
|
919
962
|
]
|
|
920
963
|
}
|
|
921
|
-
|
|
964
|
+
// A Main-only Family (ADR-0047) has no other Account to create.
|
|
965
|
+
function likeItem(a) { return BOOT.readOnly || family(a.family).mainOnly ? null : { icon: 'userPlus', label: t('menu.like'), run: () => openCreate({ family: a.family, api: a.kind === 'api' }) } }
|
|
922
966
|
// Grouped by what the user wants to do: open, copy, manage. A Same Login row (ADR-0026) passes its other
|
|
923
967
|
// directories: the menu is the one of the directory the row is named after, and each other directory is one item
|
|
924
968
|
// that opens its own actions in the same menu, so the shared actions appear once.
|
|
@@ -937,7 +981,7 @@ const MAIN = String.raw `
|
|
|
937
981
|
up.from = item
|
|
938
982
|
return { up, item }
|
|
939
983
|
})
|
|
940
|
-
const items = [pinItem(a),
|
|
984
|
+
const items = [pinItem(a), ...hideItems(a),
|
|
941
985
|
opens.length ? '-' : null, opens.length ? { header: t('menu.groupOpen') } : null, ...opens,
|
|
942
986
|
'-', { header: t('menu.groupCopy') }, run, ...(fold ? [fold] : more),
|
|
943
987
|
'-', { header: t('menu.groupManage') }, signInItem, key, ...dirTools(a), likeItem(a),
|
|
@@ -1106,7 +1150,8 @@ const MAIN = String.raw `
|
|
|
1106
1150
|
function renderSummary() {
|
|
1107
1151
|
const box = $('summary')
|
|
1108
1152
|
if (!S.state) { if (S.loadError) box.hidden = true; return }
|
|
1109
|
-
|
|
1153
|
+
// Hidden Accounts (spec §3.25) stay out of the counts and the attention card; the list's last line counts them.
|
|
1154
|
+
const list = visibleAccounts()
|
|
1110
1155
|
// Another page keeps it hidden: a refresh while there must not push that page down (renderPageChrome shows it).
|
|
1111
1156
|
box.hidden = !list.length || curPage !== 'accounts'
|
|
1112
1157
|
box.removeAttribute('aria-busy')
|
|
@@ -1122,9 +1167,10 @@ const MAIN = String.raw `
|
|
|
1122
1167
|
for (const r of rs) counts[r] = (counts[r] || 0) + 1
|
|
1123
1168
|
}
|
|
1124
1169
|
const order = ['error', 'health-fail', 'signed-out', 'not-installed', 'quota-high', 'health-warn']
|
|
1125
|
-
// Who needs a look, by name: counting reasons beside a count of accounts made numbers that did not add up.
|
|
1170
|
+
// Who needs a look, by name: counting reasons beside a count of accounts made numbers that did not add up. One name
|
|
1171
|
+
// and a count, as two names did not fit the card.
|
|
1126
1172
|
const needing = list.filter((a) => reasonsOf(a, now).length)
|
|
1127
|
-
const needSub = need ? t(needing.length >
|
|
1173
|
+
const needSub = need ? t(needing.length > 1 ? 'stat.needWhoMore' : 'stat.needWho', { names: needing[0].ref, n: needing.length - 1 }) : t('stat.allClear')
|
|
1128
1174
|
const needTitle = need ? order.filter((r) => counts[r]).map((r) => tn('need.' + r, counts[r])).join(' · ') : null
|
|
1129
1175
|
const usages = list.filter((a) => a.usage && a.usage.status === 'ok')
|
|
1130
1176
|
const total = usages.reduce((s, a) => s + (Number(a.usage.totalTokens) || 0), 0)
|
|
@@ -1206,9 +1252,10 @@ const MAIN = String.raw `
|
|
|
1206
1252
|
}
|
|
1207
1253
|
function renderFamilyFilter() {
|
|
1208
1254
|
if (!tb.family) return
|
|
1209
|
-
const
|
|
1255
|
+
const list = S.state ? listedAccounts() : []
|
|
1256
|
+
const fams = S.state ? S.state.families.filter((f) => list.some((a) => a.family === f.id)) : []
|
|
1210
1257
|
tb.family.replaceChildren(h('option', { value: '' }, t('tb.allFamilies')),
|
|
1211
|
-
...fams.map((f) => h('option', { value: f.id }, f.title + ' (' +
|
|
1258
|
+
...fams.map((f) => h('option', { value: f.id }, f.title + ' (' + list.filter((a) => a.family === f.id).length + ')')))
|
|
1212
1259
|
if (prefs.family && S.state && !fams.some((f) => f.id === prefs.family)) prefs.family = ''
|
|
1213
1260
|
tb.family.value = prefs.family
|
|
1214
1261
|
tb.family.hidden = fams.length < 2 && !prefs.family
|
|
@@ -1245,18 +1292,20 @@ const MAIN = String.raw `
|
|
|
1245
1292
|
}
|
|
1246
1293
|
// A window's cell: percent and countdown on one line, the bar under them. The label shows where no column
|
|
1247
1294
|
// header does (cards, narrow screens).
|
|
1248
|
-
function meter(w, now, stale, observedAt) {
|
|
1295
|
+
function meter(w, now, stale, observedAt, withLength) {
|
|
1249
1296
|
const st = windowState(w, now, WARN, FAIL)
|
|
1250
1297
|
const passed = passedWindow(w, observedAt, now)
|
|
1251
1298
|
const left = prefs.quota === 'left'
|
|
1252
1299
|
const shown = left ? 100 - st.pct : st.pct
|
|
1253
1300
|
const asOf = stale ? t('quota.asOf', { ago: ago(observedAt) }) : ''
|
|
1254
1301
|
const reset = passed ? t('quota.resetShort') : t('quota.resetsIn', { d: formatDuration(Date.parse(w.resetsAt) - now, lang) })
|
|
1255
|
-
|
|
1302
|
+
// The wide list's column says only the model group, so the hover names which of its limits this is.
|
|
1303
|
+
const title = [withLength ? winTitle(w.label) : '', passed ? t('quota.resetNoData', { date: day(passed.since) }) : t('quota.resetsAt', { at: clock(w.resetsAt) }), asOf].filter(Boolean).join(' · ')
|
|
1256
1304
|
return h('div', { class: 'meter lvl-' + st.level + (stale || passed ? ' lvl-stale' : ''), title },
|
|
1257
1305
|
h('div', { class: 'm-top' },
|
|
1258
1306
|
// Cards show the short window name ("5 小时"); the list and its column titles keep the full one.
|
|
1259
|
-
|
|
1307
|
+
// withLength: the group has other limits too, so name which one this is ("Gemini Models · 5-hour").
|
|
1308
|
+
h('span', { class: 'm-label' }, h('span', { class: 'm-full' }, winTitle(winKey(w)) + (withLength ? ' · ' + winTitle(w.label) : '')), h('span', { class: 'm-short' }, winShort(winKey(w)) + (withLength ? ' · ' + winShort(w.label) : ''))),
|
|
1260
1309
|
h('span', { class: 'm-pct' }, shown + '%', h('span', { class: 'm-unit' }, ' ' + t(left ? 'quota.unitLeft' : 'quota.unitUsed')),
|
|
1261
1310
|
null),
|
|
1262
1311
|
h('span', { class: 'm-reset' + (passed ? ' m-passed' : '') }, Number.isFinite(Date.parse(w.resetsAt)) || passed ? reset : '?')),
|
|
@@ -1289,29 +1338,41 @@ const MAIN = String.raw `
|
|
|
1289
1338
|
if (!quotaAskable(q.reason)) return null
|
|
1290
1339
|
return h('button', { class: 'link-btn small q-ask', type: 'button', onclick: (e) => { e.stopPropagation(); openAsk({ task: 'quota', context: { account: a.ref, family: a.family, quotaReason: q.reason + (q.detail ? ': ' + q.detail : ''), version: BOOT.version } }) } }, t('ask.quotaWhy'))
|
|
1291
1340
|
}
|
|
1341
|
+
// The newest session of this login on this computer: the Account's own and its Same Login's (spec §3.31).
|
|
1342
|
+
function lastUseOf(a) {
|
|
1343
|
+
const refs = [a.ref, ...(a.sameLogin || [])]
|
|
1344
|
+
const times = (S.state ? S.state.accounts : []).filter((x) => refs.includes(x.ref) && x.usage && x.usage.status === 'ok' && x.usage.lastActivityAt).map((x) => Date.parse(x.usage.lastActivityAt)).filter(Number.isFinite)
|
|
1345
|
+
return times.length ? new Date(Math.max(...times)).toISOString() : null
|
|
1346
|
+
}
|
|
1292
1347
|
function quotaBlock(a, now, cols) {
|
|
1293
1348
|
// Still reading (a slow plugin or Host): say so where its numbers will appear; the page asks again soon.
|
|
1294
1349
|
if (a.pending) return h('div', { class: 'quota' }, h('div', { class: 'q-note' }, spinner(), t('acct.reading', { host: famTitle(a) })))
|
|
1295
1350
|
const q = a.quota
|
|
1296
1351
|
if (!q) return h('div', { class: 'quota' }, h('div', { class: 'q-note' }, '—'))
|
|
1297
1352
|
if (q.status !== 'ok') return h('div', { class: 'quota' }, quotaNote(a, q))
|
|
1298
|
-
const stale = quotaIsStale(q, now)
|
|
1353
|
+
const stale = quotaIsStale(q, now, lastUseOf(a))
|
|
1354
|
+
// Over an hour old but unused here since: the numbers stand, and the hover text says what it cannot see.
|
|
1355
|
+
const quiet = !stale && now - Date.parse(q.observedAt) > 3600_000
|
|
1356
|
+
// Old numbers of a Host that cannot be asked (Claude Code) change only when a session runs in the account.
|
|
1357
|
+
const waits = stale && !q.fetchError && !family(a.family).quotaRefresh ? t('quota.staleSession') : null
|
|
1299
1358
|
const wins = q.windows || []
|
|
1300
1359
|
// A reading borrowed from another Account of the same login says where it came from (spec §3.21).
|
|
1301
1360
|
const from = q.from ? t('quota.sharedFrom', { name: refName(q.from), ago: ago(q.observedAt) }) : null
|
|
1302
1361
|
// Where the numbers came from when the Host was asked (spec §3.26), and why the latest ask failed.
|
|
1303
1362
|
const via = q.fetched ? t('quota.fetchedFrom', { host: famTitle(a), ago: ago(q.observedAt) }) : null
|
|
1304
1363
|
const failed = q.fetchError ? t('quota.lastCheckFailed', { why: q.fetchError }) : null
|
|
1305
|
-
const title = [from || via || (stale ? null : t('quota.dataFrom', { ago: ago(q.observedAt) })), failed].filter(Boolean).join('\n') || null
|
|
1364
|
+
const title = [from || via || (stale ? null : t('quota.dataFrom', { ago: ago(q.observedAt) })), quiet ? t('quota.quiet') : null, failed, waits].filter(Boolean).join('\n') || null
|
|
1306
1365
|
// --qr: this row's own number of windows, so a narrow list can split the width between them alone (--qn is the
|
|
1307
1366
|
// widest Family's, for the wide list's shared columns).
|
|
1308
1367
|
return h('div', { class: 'quota' + (stale ? ' is-stale' : ''), title, css: wins.length ? { '--qr': String(cols.length) } : null },
|
|
1309
1368
|
wins.length ? cols.map((c) => {
|
|
1310
|
-
|
|
1311
|
-
|
|
1369
|
+
// A model group with several limits (Antigravity's 5-hour and weekly) shows the one that binds first.
|
|
1370
|
+
const same = wins.filter((x) => winKey(x) === c)
|
|
1371
|
+
const w = bindingWindow(same, now, WARN, FAIL)
|
|
1372
|
+
return w ? meter(w, now, stale, q.observedAt, same.length > 1) : noMeter(winTitle(c), winShort(c))
|
|
1312
1373
|
}) : h('div', { class: 'q-note' }, t('quota.noWindows')),
|
|
1313
1374
|
// Old numbers keep their colours and say their age once, under the bars.
|
|
1314
|
-
stale && wins.length ? h('div', { class: 'q-asof', title: failed || t('quota.asOf', { ago: ago(q.observedAt) }) }, icon('clock'), q.fetchError ? t('quota.fetchFailed') + ' · ' : '', t('quota.staleShort', { ago: agoShort(now - Date.parse(q.observedAt)) })) : null)
|
|
1375
|
+
stale && wins.length ? h('div', { class: 'q-asof', title: failed || [t('quota.asOf', { ago: ago(q.observedAt) }), waits].filter(Boolean).join('\n') }, icon('clock'), q.fetchError ? t('quota.fetchFailed') + ' · ' : '', t('quota.staleShort', { ago: agoShort(now - Date.parse(q.observedAt)) })) : null)
|
|
1315
1376
|
}
|
|
1316
1377
|
function usageBlock(a) {
|
|
1317
1378
|
const u = a.usage
|
|
@@ -1367,7 +1428,7 @@ const MAIN = String.raw `
|
|
|
1367
1428
|
}
|
|
1368
1429
|
// A word, not only a colour (spec §3.8): what kind of look the account needs; the reason is on hover.
|
|
1369
1430
|
function attentionWord(subject, reason) {
|
|
1370
|
-
const lvl = reason === 'health-fail' ? 'fail' : 'warn'
|
|
1431
|
+
const lvl = reason === 'health-fail' ? 'fail' : reason === 'quota-high' ? quotaHighLevel(subject, Date.now(), FAIL) : 'warn'
|
|
1371
1432
|
const why = whyOf(subject, Date.now())
|
|
1372
1433
|
const word = reason === 'health-fail' ? t('att.fix') : reason === 'quota-high' ? t('att.quota') : t('att.check')
|
|
1373
1434
|
const dot = h('span', { class: 'dot dot-' + lvl, 'aria-hidden': 'true' })
|
|
@@ -1418,6 +1479,7 @@ const MAIN = String.raw `
|
|
|
1418
1479
|
h('span', { class: 'name', title: a.name }, a.name),
|
|
1419
1480
|
loginMark(o.linked || members),
|
|
1420
1481
|
aliasText(a),
|
|
1482
|
+
hiddenMark(isHidden(a) && !famHidden(a.family)),
|
|
1421
1483
|
statusBadge(a, members))
|
|
1422
1484
|
}
|
|
1423
1485
|
// An organization name as the vendor wrote it, without a trailing comma or full stop it sometimes carries.
|
|
@@ -1619,7 +1681,7 @@ const MAIN = String.raw `
|
|
|
1619
1681
|
}
|
|
1620
1682
|
// What a row or card shows depends on more than the account (health, view preferences, language); the
|
|
1621
1683
|
// fingerprint covers what its click handlers use.
|
|
1622
|
-
function rowSig(a) { return sig([a, healthOf(a.ref), isNext(a), ui.desktopRef === a.ref, ui.browserRef === a.ref, ui.copied === a.ref, browserFor(a), prefs.hideEmail, isOpen(a), loginLead(a), isPinned(a)]) }
|
|
1684
|
+
function rowSig(a) { return sig([a, healthOf(a.ref), isNext(a), ui.desktopRef === a.ref, ui.browserRef === a.ref, ui.copied === a.ref, browserFor(a), prefs.hideEmail, isOpen(a), loginLead(a), isPinned(a), isHidden(a), famHidden(a.family)]) }
|
|
1623
1685
|
// Whether the row sits in a login group (spec §3.21): its first row then shows the quota for all of them.
|
|
1624
1686
|
function inLogin(a) { return ui.loginRefs.has(a.ref) }
|
|
1625
1687
|
// The group's first row, which shows the quota for all of them.
|
|
@@ -1916,13 +1978,15 @@ const MAIN = String.raw `
|
|
|
1916
1978
|
// The group's attention tag says who and why: with one Account its name and reason, and a click shows its row;
|
|
1917
1979
|
// with more, the count, each one's reason on hover, and a click shows only them (as the summary card does).
|
|
1918
1980
|
function attentionTag(needing, now) {
|
|
1981
|
+
// Red when one of them needs a fix or has a red quota bar, so the tag matches what the rows show.
|
|
1982
|
+
const lvl = needing.some((a) => reasonsOf(a, now).includes('health-fail') || quotaHighLevel(a, now, FAIL) === 'fail') ? 'fail' : 'warn'
|
|
1919
1983
|
if (needing.length === 1) {
|
|
1920
1984
|
const a = needing[0]
|
|
1921
1985
|
const label = a.name + ' · ' + whyOf(a, now)
|
|
1922
|
-
return h('button', { class: 'tag tag-
|
|
1986
|
+
return h('button', { class: 'tag tag-' + lvl + ' tag-btn', type: 'button', title: t('group.attentionShow', { name: a.name }), onclick: () => flashRow(a.ref) }, label)
|
|
1923
1987
|
}
|
|
1924
1988
|
const list = needing.map((a) => a.name + colon() + whyOf(a, now)).join('\n')
|
|
1925
|
-
return h('button', { class: 'tag tag-
|
|
1989
|
+
return h('button', { class: 'tag tag-' + lvl + ' tag-btn', type: 'button', title: list, 'aria-pressed': String(ui.attention), onclick: () => { ui.attention = !ui.attention; renderSummary(); renderAccounts() } }, tn('group.attention', needing.length))
|
|
1926
1990
|
}
|
|
1927
1991
|
// ---------- Grok Bot windows (ADR-0019) ----------
|
|
1928
1992
|
// Windows of an app that signs in apart from every account, so they get a group of their own after the accounts.
|
|
@@ -2103,11 +2167,13 @@ const MAIN = String.raw `
|
|
|
2103
2167
|
h('button', { class: 'btn btn-sm', type: 'button', title: setup.summary, 'aria-label': t('quota.turnOnFamilyLabel', { host: info.title }), onclick: () => openSetup(fam) }, t('quota.turnOnFamily')))
|
|
2104
2168
|
: null,
|
|
2105
2169
|
off && setup && setup.plan.status === 'blocked' ? h('span', { class: 'muted small label-tip' }, t('quota.blocked'), tipRaw(t('quota.blocked'), setup.plan.message)) : null,
|
|
2170
|
+
hiddenMark(famHidden(fam)),
|
|
2171
|
+
ui.arrange && !BOOT.readOnly ? hideToggle(info.title, famHidden(fam), () => toggleHideFamily(fam)) : null,
|
|
2106
2172
|
ui.arrange ? null : pickHead(fam)))
|
|
2107
2173
|
const body = collapsedNow ? null : cards
|
|
2108
2174
|
? h('div', { class: 'grid', id: bodyId, 'data-key': 'cards', 'data-patch': '' }, loginClusters(list).map((x) => Array.isArray(x) ? loginCard(x, now, cols) : card(x, now, cols)))
|
|
2109
2175
|
: h('div', { class: 'rows', id: bodyId, role: 'list', 'data-key': ui.arrange ? 'rows-arrange' : 'rows', 'data-patch': '' }, loginClusters(list).map((x) => Array.isArray(x) ? loginRow(x, now, cols) : row(x, now, cols)))
|
|
2110
|
-
return h('section', { class: 'group' + (cards ? ' group-cards' : ' group-list') + (collapsedNow ? ' is-collapsed' : '') + (ui.arrange ? ' is-arranging' : ''), 'aria-label': info.title, 'data-key': 'g:' + fam, 'data-fam': fam, 'data-patch': '' },
|
|
2176
|
+
return h('section', { class: 'group' + (cards ? ' group-cards' : ' group-list') + (collapsedNow ? ' is-collapsed' : '') + (ui.arrange ? ' is-arranging' : '') + (famHidden(fam) ? ' is-hidden' : ''), 'aria-label': info.title, 'data-key': 'g:' + fam, 'data-fam': fam, 'data-patch': '' },
|
|
2111
2177
|
head, collapsedNow || cards || ui.arrange ? null : colHead(cols, list), body)
|
|
2112
2178
|
}
|
|
2113
2179
|
function emptyState() {
|
|
@@ -2177,7 +2243,8 @@ const MAIN = String.raw `
|
|
|
2177
2243
|
}
|
|
2178
2244
|
function ordered() { const d = displayOf(); return Boolean((d.families && d.families.length) || (d.accounts && Object.keys(d.accounts).length)) }
|
|
2179
2245
|
function copyDisplay(d) {
|
|
2180
|
-
return { families: d.families ? d.families.slice() : [], accounts: Object.assign({}, d.accounts || {}), pinned: Object.assign({}, d.pinned || {})
|
|
2246
|
+
return { families: d.families ? d.families.slice() : [], accounts: Object.assign({}, d.accounts || {}), pinned: Object.assign({}, d.pinned || {}),
|
|
2247
|
+
hiddenFamilies: d.hiddenFamilies ? d.hiddenFamilies.slice() : [], hidden: Object.assign({}, d.hidden || {}) }
|
|
2181
2248
|
}
|
|
2182
2249
|
// Shows next at once and writes it to the config. Writes go one at a time; a failed one puts back what the config
|
|
2183
2250
|
// last confirmed, never another write's unsaved state.
|
|
@@ -2186,7 +2253,7 @@ const MAIN = String.raw `
|
|
|
2186
2253
|
if (!displaySaves.pending) displaySaves.confirmed = before
|
|
2187
2254
|
displaySaves.pending++
|
|
2188
2255
|
S.state.display = next
|
|
2189
|
-
|
|
2256
|
+
renderDisplayed()
|
|
2190
2257
|
const run = displaySaves.chain.then(async () => {
|
|
2191
2258
|
try {
|
|
2192
2259
|
const r = await api('/api/display-order', { display: next })
|
|
@@ -2195,7 +2262,7 @@ const MAIN = String.raw `
|
|
|
2195
2262
|
return true
|
|
2196
2263
|
} catch (e) {
|
|
2197
2264
|
// A newer write already on its way settles the screen; only the latest one puts things back.
|
|
2198
|
-
if (S.state.display === next) { S.state.display = displaySaves.confirmed;
|
|
2265
|
+
if (S.state.display === next) { S.state.display = displaySaves.confirmed; renderDisplayed() }
|
|
2199
2266
|
toast(t(failKey || 'order.failed', { msg: e.message }), { kind: 'fail' })
|
|
2200
2267
|
return false
|
|
2201
2268
|
} finally { displaySaves.pending-- }
|
|
@@ -2217,6 +2284,74 @@ const MAIN = String.raw `
|
|
|
2217
2284
|
next.pinned[a.family] = list
|
|
2218
2285
|
saveDisplay(before, next, 'pin.failed')
|
|
2219
2286
|
}
|
|
2287
|
+
// What the Display Order changes on screen: the accounts, and the counts and tool filter that leave Hidden ones out.
|
|
2288
|
+
function renderDisplayed() { renderAccounts(); renderSummary(); renderFamilyFilter(); renderPageChrome() }
|
|
2289
|
+
|
|
2290
|
+
// ---------- Hidden Families and Accounts (spec §3.25) ----------
|
|
2291
|
+
// Display only: a hidden Account still starts, shows in History and can be picked by a Handoff.
|
|
2292
|
+
function isHidden(a) { return hiddenIn(a, displayOf()) }
|
|
2293
|
+
function famHidden(fam) { return (displayOf().hiddenFamilies || []).includes(fam) }
|
|
2294
|
+
function hiddenOf(fam) { return (displayOf().hidden || {})[fam] || [] }
|
|
2295
|
+
function visibleAccounts() { return S.state.accounts.filter((a) => !isHidden(a)) }
|
|
2296
|
+
// The accounts the list shows: the arrange mode and "Show hidden" bring the hidden ones back, marked.
|
|
2297
|
+
function listedAccounts() { return ui.arrange || ui.showHidden ? S.state.accounts : visibleAccounts() }
|
|
2298
|
+
function afterHide(hide, name, undo) {
|
|
2299
|
+
// Hiding from the list itself makes the row go away; the toast says where it went and offers it back.
|
|
2300
|
+
if (hide && !ui.arrange && !ui.showHidden) toast(t('hide.done', { name }), { action: { label: t('order.undo'), run: undo } })
|
|
2301
|
+
}
|
|
2302
|
+
// Hides or shows an Account, with the other directories of its Same Login.
|
|
2303
|
+
function toggleHide(a) {
|
|
2304
|
+
const before = displayOf()
|
|
2305
|
+
const next = copyDisplay(before)
|
|
2306
|
+
const names = [a.name].concat((a.sameLogin || []).map(refName))
|
|
2307
|
+
const exists = (n) => S.state.accounts.some((x) => x.family === a.family && x.name === n)
|
|
2308
|
+
const list = hiddenOf(a.family).filter((n) => !names.includes(n) && exists(n))
|
|
2309
|
+
const hide = !hiddenIn(a, { hidden: displayOf().hidden })
|
|
2310
|
+
if (hide) list.push(...names.filter(exists))
|
|
2311
|
+
next.hidden[a.family] = list
|
|
2312
|
+
saveDisplay(before, next, 'hide.failed').then((ok) => { if (ok) afterHide(hide, a.ref, () => toggleHide(a)) })
|
|
2313
|
+
}
|
|
2314
|
+
function toggleHideFamily(fam) {
|
|
2315
|
+
const before = displayOf()
|
|
2316
|
+
const next = copyDisplay(before)
|
|
2317
|
+
const hide = !famHidden(fam)
|
|
2318
|
+
next.hiddenFamilies = hide ? next.hiddenFamilies.concat(fam) : next.hiddenFamilies.filter((x) => x !== fam)
|
|
2319
|
+
saveDisplay(before, next, 'hide.failed').then((ok) => { if (ok) afterHide(hide, family(fam).title, () => toggleHideFamily(fam)) })
|
|
2320
|
+
}
|
|
2321
|
+
// The row menu's items: hide this account, or all of its tool; on a hidden row, show it again.
|
|
2322
|
+
function hideItems(a) {
|
|
2323
|
+
if (BOOT.readOnly) return []
|
|
2324
|
+
const title = family(a.family).title
|
|
2325
|
+
if (famHidden(a.family)) return [{ icon: 'eye', label: t('hide.showFamily', { title }), run: () => toggleHideFamily(a.family) }]
|
|
2326
|
+
if (isHidden(a)) return [{ icon: 'eye', label: t('hide.showAccount'), run: () => toggleHide(a) }]
|
|
2327
|
+
return [{ icon: 'eyeOff', label: t('hide.account'), run: () => toggleHide(a) }, { icon: 'eyeOff', label: t('hide.family', { title }), run: () => toggleHideFamily(a.family) }]
|
|
2328
|
+
}
|
|
2329
|
+
// A hidden row or group says so while "Show hidden" or the arrange mode brings it back.
|
|
2330
|
+
function hiddenMark(on) {
|
|
2331
|
+
return on ? h('span', { class: 'chip chip-sm hidden-chip' }, icon('eyeOff'), t('hide.mark')) : null
|
|
2332
|
+
}
|
|
2333
|
+
// The eye in the arrange mode: one click hides or shows the Family or the Account (with its Same Login).
|
|
2334
|
+
function hideToggle(label, hidden, run) {
|
|
2335
|
+
const text = t(hidden ? 'hide.showName' : 'hide.hideName', { name: label })
|
|
2336
|
+
return h('button', { class: 'icon-btn hide-btn' + (hidden ? ' is-on' : ''), type: 'button', 'aria-pressed': String(hidden), 'aria-label': text, title: text, onclick: (e) => { e.stopPropagation(); run() } }, icon(hidden ? 'eyeOff' : 'eye'))
|
|
2337
|
+
}
|
|
2338
|
+
// Under the list: how many are hidden, a red dot when one of them needs a look, and the switch to show them.
|
|
2339
|
+
function hiddenBar(n) {
|
|
2340
|
+
const now = Date.now()
|
|
2341
|
+
const needs = S.state.accounts.some((a) => isHidden(a) && reasonsOf(a, now).length)
|
|
2342
|
+
return h('div', { class: 'hidden-bar', 'data-key': 'hidden-bar', 'data-sig': sig([n, needs, Boolean(ui.showHidden), lang]) },
|
|
2343
|
+
needs ? h('span', { class: 'hidden-dot', role: 'img', title: t('hide.needs'), 'aria-label': t('hide.needs') }) : null,
|
|
2344
|
+
h('span', { class: 'muted small' }, tn('hide.count', n)),
|
|
2345
|
+
h('button', { class: 'link-btn small', type: 'button', 'aria-expanded': String(Boolean(ui.showHidden)), onclick: toggleShowHidden }, t(ui.showHidden ? 'hide.collapse' : 'hide.show')))
|
|
2346
|
+
}
|
|
2347
|
+
function toggleShowHidden() { ui.showHidden = !ui.showHidden; renderFamilyFilter(); renderAccounts() }
|
|
2348
|
+
// Everything is hidden: say so, instead of the first-run screen that would suggest the accounts are gone.
|
|
2349
|
+
function allHiddenState() {
|
|
2350
|
+
return h('div', { class: 'empty empty-sm', 'data-key': 'all-hidden' },
|
|
2351
|
+
h('h3', null, t('hide.allTitle')),
|
|
2352
|
+
h('p', { class: 'muted' }, t('hide.allBody')),
|
|
2353
|
+
h('button', { class: 'btn', type: 'button', onclick: toggleShowHidden }, icon('eye'), t('hide.show')))
|
|
2354
|
+
}
|
|
2220
2355
|
|
|
2221
2356
|
// The arrange mode: the only place to drag (spec §3.25). It starts from the order on screen, saves each move at
|
|
2222
2357
|
// once, and "Done" offers to put back the order it started from.
|
|
@@ -2266,13 +2401,19 @@ const MAIN = String.raw `
|
|
|
2266
2401
|
const label = ms.map((m) => m.name).join(', ')
|
|
2267
2402
|
const full = !pinned && pinnedUnits(fam) >= PIN_MAX
|
|
2268
2403
|
const pinLabel = full ? t('pin.full', { n: PIN_MAX }) : t(pinned ? 'pin.unpinName' : 'pin.pinName', { name: label, title: family(fam).title })
|
|
2269
|
-
|
|
2404
|
+
const hidden = isHidden(a)
|
|
2405
|
+
return h('div', { class: 'row row-arrange' + (pinned ? ' is-pinned' : '') + (hidden ? ' is-hidden' : ''), role: 'listitem', 'data-ref': a.ref, 'data-key': 'arr:' + loginKey(ms.map((m) => m.ref)), 'data-sig': sig([ms.map(rowSig), at, lo, hi, full, hidden, famHidden(fam)]) },
|
|
2270
2406
|
h('div', { class: 'ident' }, dragHandle('account', fam, a.name, label), badge(fam, 'sm'), h('div', { class: 'ident-text' }, h('div', { class: 'ident-name' },
|
|
2271
2407
|
pinMark(a),
|
|
2272
2408
|
h('span', { class: 'name', title: a.name }, a.name),
|
|
2273
2409
|
loginMark(ms),
|
|
2274
|
-
aliasText(a)
|
|
2410
|
+
aliasText(a),
|
|
2411
|
+
hiddenMark(hidden && !famHidden(fam))))),
|
|
2275
2412
|
h('div', { class: 'arrange-tools' },
|
|
2413
|
+
// In a hidden Family the row keeps its eye, greyed, so the columns stay in line; the group's eye shows it again.
|
|
2414
|
+
famHidden(fam)
|
|
2415
|
+
? h('button', { class: 'icon-btn hide-btn is-on', type: 'button', disabled: true, title: t('hide.inFamily', { title: family(fam).title }), 'aria-label': t('hide.inFamily', { title: family(fam).title }) }, icon('eyeOff'))
|
|
2416
|
+
: hideToggle(label, isHidden(a), () => toggleHide(a)),
|
|
2276
2417
|
h('button', { class: 'icon-btn', type: 'button', 'aria-label': t('order.up', { name: label }), title: t('order.up', { name: label }), disabled: at <= lo ? true : undefined, onclick: () => moveUnit('account', fam, at, at - 1, { focus: a.name, label, button: 'up' }) }, icon('arrowUp')),
|
|
2277
2418
|
h('button', { class: 'icon-btn', type: 'button', 'aria-label': t('order.down', { name: label }), title: t('order.down', { name: label }), disabled: at >= hi ? true : undefined, onclick: () => moveUnit('account', fam, at, at + 1, { focus: a.name, label, button: 'down' }) }, icon('arrowDown')),
|
|
2278
2419
|
// Words, not a lone pin icon at the end of the row: the arrange mode is where the order and the pins are set.
|
|
@@ -2406,8 +2547,10 @@ const MAIN = String.raw `
|
|
|
2406
2547
|
// Forgets the order of Families and accounts; pins stay.
|
|
2407
2548
|
async function resetOrder() {
|
|
2408
2549
|
const before = displayOf()
|
|
2409
|
-
const
|
|
2410
|
-
|
|
2550
|
+
const keep = {}
|
|
2551
|
+
for (const k of ['pinned', 'hidden']) if (before[k] && Object.keys(before[k]).length) keep[k] = before[k]
|
|
2552
|
+
if (before.hiddenFamilies && before.hiddenFamilies.length) keep.hiddenFamilies = before.hiddenFamilies
|
|
2553
|
+
if (await saveDisplay(before, keep)) toast(t('order.reset'))
|
|
2411
2554
|
}
|
|
2412
2555
|
// Words for screen readers only, such as the new place of something moved with the keyboard.
|
|
2413
2556
|
let live = null
|
|
@@ -2429,13 +2572,17 @@ const MAIN = String.raw `
|
|
|
2429
2572
|
const now = Date.now()
|
|
2430
2573
|
$('toolbar').hidden = !all.length
|
|
2431
2574
|
if (!all.length) { setKids(count, null); patch(box, [emptyState()].concat(appGroups())); return }
|
|
2432
|
-
const
|
|
2433
|
-
const
|
|
2575
|
+
const listed = listedAccounts()
|
|
2576
|
+
const hiddenN = all.length - visibleAccounts().length
|
|
2577
|
+
if (!listed.length) { setKids(count, null); patch(box, [allHiddenState()].concat(appGroups())); return }
|
|
2578
|
+
const shown = listed.filter((a) => (!prefs.family || a.family === prefs.family) && matchesQuery(a, ui.query, famTitle(a)) && (!ui.attention || reasonsOf(a, now).length))
|
|
2579
|
+
const filtered = shown.length !== listed.length
|
|
2434
2580
|
patch(count, filtered
|
|
2435
|
-
? [t('count.filtered', { n: shown.length, total:
|
|
2436
|
-
: tn('count.accounts',
|
|
2581
|
+
? [t('count.filtered', { n: shown.length, total: listed.length }), ' ', h('button', { class: 'link-btn', type: 'button', onclick: clearFilters }, t('filter.clear'))]
|
|
2582
|
+
: tn('count.accounts', listed.length))
|
|
2437
2583
|
const apps = appGroups()
|
|
2438
|
-
|
|
2584
|
+
const tail = hiddenN && !ui.arrange ? [hiddenBar(hiddenN)] : []
|
|
2585
|
+
if (!shown.length && !apps.length) { patch(box, [noMatch()].concat(tail)); return }
|
|
2439
2586
|
ui.loginRefs = new Map()
|
|
2440
2587
|
for (const x of loginClusters(shown)) if (Array.isArray(x)) for (const a of x) ui.loginRefs.set(a.ref, loginMembers(x)[0].ref)
|
|
2441
2588
|
// Families in the Display Order (spec §3.25) whatever the sort; each group gets the quota columns it uses.
|
|
@@ -2455,10 +2602,10 @@ const MAIN = String.raw `
|
|
|
2455
2602
|
const sorted = withPinned(sortAccounts(list, prefs.sort, now, accountOrder(fam)), pinnedOf(fam))
|
|
2456
2603
|
const cols = quotaColumns(sorted)
|
|
2457
2604
|
width = Math.max(width, cols.length)
|
|
2458
|
-
groups.push(group(fam, sorted,
|
|
2605
|
+
groups.push(group(fam, sorted, listed.filter((a) => a.family === fam).length, now, cols))
|
|
2459
2606
|
}
|
|
2460
2607
|
box.style.setProperty('--qn', String(width))
|
|
2461
|
-
patch(box, (ui.arrange ? [arrangeBar()] : []).concat(groups))
|
|
2608
|
+
patch(box, (ui.arrange ? [arrangeBar()] : []).concat(groups, tail))
|
|
2462
2609
|
if (ui.fade && !REDUCED) {
|
|
2463
2610
|
box.classList.add('view-in')
|
|
2464
2611
|
setTimeout(() => box.classList.remove('view-in'), 400)
|
|
@@ -2775,11 +2922,14 @@ const MAIN = String.raw `
|
|
|
2775
2922
|
const mine = useUi && useUi.gid === g.id
|
|
2776
2923
|
const busy = mine && (useUi.step === 'asking' || useUi.step === 'busy')
|
|
2777
2924
|
const asking = mine && (useUi.step === 'confirm' || busy)
|
|
2778
|
-
const rows = [h('
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
|
|
2925
|
+
const rows = [h('div', { class: 'tg-head' }, badge(entries[0] ? entries[0].family : 'claude', 'sm'),
|
|
2926
|
+
h('p', { class: 'small' }, g.members.length > 1 ? t('tune.groupShared', { list: g.members.join(', ') }) : h('b', { class: 'mono' }, g.members[0])))]
|
|
2927
|
+
// Now, the suggestion and what it saves read as one strip, like the Accounts summary.
|
|
2928
|
+
const saved = pick && pick.savedPercent !== null ? Math.round(pick.savedPercent) : null
|
|
2929
|
+
rows.push(h('div', { class: 'tg-stats' },
|
|
2930
|
+
h('div', { class: 'tg-stat' }, h('span', { class: 'stat-label' }, t('tune.now')), h('div', { class: 'tune-num' }, g.current === null ? defaultSize(claudeModels(entries)) : tuneSize(g.current))),
|
|
2931
|
+
pick ? h('div', { class: 'tg-stat' }, h('span', { class: 'stat-label' }, t('tune.best')), h('div', { class: 'tune-num tune-best' }, tokens(pick.threshold))) : null,
|
|
2932
|
+
saved !== null ? h('div', { class: 'tg-stat', title: t('tune.saved', { n: saved }) }, h('span', { class: 'stat-label' }, t('tune.savedLabel')), h('div', { class: 'tune-num' }, t('tune.savedValue', { n: saved }))) : null))
|
|
2783
2933
|
if (pick) rows.push(h('p', { class: 'muted small' }, t('tune.basis', { model: pick.model, ref: pick.ref })))
|
|
2784
2934
|
if (pick) {
|
|
2785
2935
|
const seen = entries.find((e) => e.ref === pick.ref)
|
|
@@ -2914,9 +3064,22 @@ const MAIN = String.raw `
|
|
|
2914
3064
|
if (canTune) tabs.push(['tuning', t('page.tuning')])
|
|
2915
3065
|
if (canHandoff) tabs.push(['handoff', t('page.handoff')])
|
|
2916
3066
|
nav.hidden = tabs.length < 2
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
3067
|
+
// Underline tabs: each page has its mark, the Accounts tab its count and Auto Handoff a dot while it is on.
|
|
3068
|
+
const tabIcon = { accounts: 'tabAccounts', sessions: 'tabSessions', tuning: 'tabTuning', handoff: 'tabHandoff' }
|
|
3069
|
+
// The tab counts what the list shows: Hidden Accounts (spec §3.25) are counted on the line under it.
|
|
3070
|
+
const nAccounts = S.state ? visibleAccounts().length : 0
|
|
3071
|
+
const handoffOn = Boolean(ahState() && ahState().settings.auto)
|
|
3072
|
+
// Redrawn only when something on it changes, so a refresh never replays the underline.
|
|
3073
|
+
const navShape = JSON.stringify([lang, curPage, tabs, nAccounts, handoffOn, sp.opening, pasteCount()])
|
|
3074
|
+
if (nav._drawn !== navShape) {
|
|
3075
|
+
nav._drawn = navShape
|
|
3076
|
+
swapKids(nav, [h('div', { class: 'tabs', role: 'presentation' }, tabs.map(([id, label]) =>
|
|
3077
|
+
h('button', { class: 'tab', type: 'button', role: 'tab', 'data-key': 'tab:' + id, 'aria-selected': curPage === id ? 'true' : 'false', 'aria-busy': id === 'sessions' && sp.opening ? 'true' : null, onclick: () => setPage(id) },
|
|
3078
|
+
id === 'sessions' && sp.opening ? spinner() : icon(tabIcon[id]), h('span', { class: 'tab-label', 'data-label': label }, label),
|
|
3079
|
+
id === 'accounts' && nAccounts ? h('span', { class: 'tab-count' }, String(nAccounts)) : null,
|
|
3080
|
+
id === 'handoff' && handoffOn ? h('span', { class: 'tab-dot', 'aria-label': t('ah.on') }) : null,
|
|
3081
|
+
id === 'sessions' && pasteCount() ? h('span', { class: 'seg-badge', 'data-tip': t('msgn.badge', { n: pasteCount() }), 'aria-label': t('msgn.badge', { n: pasteCount() }) }, String(pasteCount())) : null)))])
|
|
3082
|
+
}
|
|
2920
3083
|
const away = curPage !== 'accounts' && tabs.some(([id]) => id === curPage)
|
|
2921
3084
|
// With no account yet the empty state is the whole page: no summary, no health check.
|
|
2922
3085
|
const none = Boolean(S.state && !S.state.accounts.length)
|
|
@@ -3026,7 +3189,7 @@ const MAIN = String.raw `
|
|
|
3026
3189
|
return ib.loading
|
|
3027
3190
|
}
|
|
3028
3191
|
function inboundGroups() { return (ib.data && ib.data.groups) || [] }
|
|
3029
|
-
function inboundTodo() { return inboundGroups()
|
|
3192
|
+
function inboundTodo() { return groupsToAccept(inboundGroups()) }
|
|
3030
3193
|
function inboundWaiting() { return inboundGroups().filter((g) => g.waits).flatMap((g) => g.accounts).map(shortRef) }
|
|
3031
3194
|
function inboundShape() { return inboundGroups().length > 0 }
|
|
3032
3195
|
const refList = (refs) => refs.join(lang === 'zh' ? '、' : ', ')
|
|
@@ -3093,8 +3256,8 @@ const MAIN = String.raw `
|
|
|
3093
3256
|
return h('li', { class: 'rc-row' },
|
|
3094
3257
|
h('div', null, h('code', null, g.file), ' ', h('span', { class: 'chip chip-sm' + (tone ? ' chip-' + tone : '') }, t(key))),
|
|
3095
3258
|
h('div', { class: 'muted small' }, t('rc.usedBy', { refs: refList(g.accounts.map(shortRef)) })),
|
|
3096
|
-
g.reason ? h('div', { class: 'muted small' }, g.reason) : null,
|
|
3097
|
-
!BOOT.readOnly && todo.includes(g) ? h('div', { class: 'small rc-change' },
|
|
3259
|
+
g.reason ? h('div', { class: 'muted small' }, g.why ? t('settings.why.' + g.why) : g.reason) : null,
|
|
3260
|
+
!BOOT.readOnly && todo.includes(g) ? h('div', { class: 'small rc-change' }, keyChange('crossSessionInbound', g.state === 'hold' ? '"hold"' : null, '"accept"')) : null)
|
|
3098
3261
|
})))
|
|
3099
3262
|
if (BOOT.readOnly) body.push(h('p', { class: 'small' }, t('inb.readOnly')))
|
|
3100
3263
|
else if (todo.length) body.push(h('p', { class: 'small muted' }, t('inb.confirmNote')))
|
|
@@ -3112,8 +3275,9 @@ const MAIN = String.raw `
|
|
|
3112
3275
|
async function inboundAccept() {
|
|
3113
3276
|
inboundBusy(true)
|
|
3114
3277
|
try {
|
|
3115
|
-
const r = await api('/api/messages/inbound/accept', {})
|
|
3116
|
-
if (r.
|
|
3278
|
+
const r = await api('/api/messages/inbound/accept', { confirm: true, files: inboundTodo().map((g) => g.file) })
|
|
3279
|
+
if (r.changedSince) toast(t('as.changedSince'), { kind: 'fail' })
|
|
3280
|
+
else if (r.ok) {
|
|
3117
3281
|
if (dlg.kind === 'inbound' && dlg.el.open) dlg.el.close()
|
|
3118
3282
|
toast(t('inb.done'), { kind: 'ok', key: 'inb', action: { label: t('toast.undo'), run: inboundUndo }, duration: 12000 })
|
|
3119
3283
|
} else toast(t('inb.failed', { msg: r.message }), { kind: 'fail' })
|
|
@@ -3124,7 +3288,7 @@ const MAIN = String.raw `
|
|
|
3124
3288
|
async function inboundUndo() {
|
|
3125
3289
|
inboundBusy(true)
|
|
3126
3290
|
try {
|
|
3127
|
-
const r = await api('/api/messages/inbound/undo', {})
|
|
3291
|
+
const r = await api('/api/messages/inbound/undo', { confirm: true })
|
|
3128
3292
|
if (r.ok && dlg.kind === 'inbound' && dlg.el.open) dlg.el.close()
|
|
3129
3293
|
toast(r.ok ? t('inb.undone') : r.message, { kind: r.ok ? 'ok' : 'fail', key: 'inb' })
|
|
3130
3294
|
} catch (e) { toast(t('toast.undoFailed', { msg: e.message }), { kind: 'fail' }) }
|
|
@@ -4065,7 +4229,7 @@ const MAIN = String.raw `
|
|
|
4065
4229
|
open.addEventListener('click', () => openHistoryView(s, open))
|
|
4066
4230
|
const more = h('button', { class: 'icon-btn more', type: 'button', 'aria-haspopup': 'menu', 'aria-expanded': 'false', 'data-key': 'hist-more-' + k, 'aria-label': t('hist.more', { title }), 'data-tip': t('menu.title') }, icon('more'))
|
|
4067
4231
|
more.addEventListener('click', () => historyMenu(more, s))
|
|
4068
|
-
const view = h('button', { class: 'btn
|
|
4232
|
+
const view = h('button', { class: 'icon-btn hist-view', type: 'button', 'data-key': 'hist-view-' + k, 'aria-label': t('hist.openLabel', { title }), 'data-tip': t('hist.viewShort') }, icon('eye'))
|
|
4069
4233
|
view.addEventListener('click', () => openHistoryView(s, view))
|
|
4070
4234
|
const cont = h('button', { class: 'btn btn-sm hist-cont', type: 'button', 'data-key': 'hist-cont-' + k, 'aria-label': t('hist.continueFor', { title }), 'data-tip': t(s.cwdGone ? 'hist.continueGoneTip' : 'hist.continueTip') }, icon('terminal'), h('span', null, t('hist.continueShort')))
|
|
4071
4235
|
cont.addEventListener('click', () => copyContinue(cont, s))
|
|
@@ -4536,6 +4700,7 @@ const MAIN = String.raw `
|
|
|
4536
4700
|
// New account. The form is built once per opening so typing keeps focus; only its derived parts re-render.
|
|
4537
4701
|
let nf = null
|
|
4538
4702
|
function familyStatus(f) {
|
|
4703
|
+
if (f.mainOnly) return 'main-only'
|
|
4539
4704
|
const hasMain = S.state && S.state.accounts.some((a) => a.family === f.id && a.isMain)
|
|
4540
4705
|
if (hasMain) return 'ready'
|
|
4541
4706
|
return f.installed ? 'no-main' : 'missing'
|
|
@@ -4543,7 +4708,7 @@ const MAIN = String.raw `
|
|
|
4543
4708
|
function openCreate(prefill) {
|
|
4544
4709
|
if (BOOT.readOnly || !S.state) return
|
|
4545
4710
|
const fams = S.state.families.slice().sort((x, y) => {
|
|
4546
|
-
const rank = (f) => ({ ready: 0, 'no-main': 1, missing: 2 })[familyStatus(f)]
|
|
4711
|
+
const rank = (f) => ({ ready: 0, 'no-main': 1, missing: 2, 'main-only': 3 })[familyStatus(f)]
|
|
4547
4712
|
return rank(x) - rank(y)
|
|
4548
4713
|
})
|
|
4549
4714
|
const ready = fams.filter((f) => familyStatus(f) === 'ready')
|
|
@@ -4623,7 +4788,7 @@ const MAIN = String.raw `
|
|
|
4623
4788
|
renderPreview()
|
|
4624
4789
|
})
|
|
4625
4790
|
const n = S.state.accounts.filter((a) => a.family === f.id).length
|
|
4626
|
-
const sub = st === 'ready' ? tn('nf.accounts', n) : st === 'no-main' ? tx('nf.runOnce', { bin: h('code', null, f.bin) }) : t(f.brokenBin ? 'nf.broken' : 'nf.notInstalled')
|
|
4791
|
+
const sub = st === 'ready' ? tn('nf.accounts', n) : st === 'main-only' ? t('nf.mainOnly') : st === 'no-main' ? tx('nf.runOnce', { bin: h('code', null, f.bin) }) : t(f.brokenBin ? 'nf.broken' : 'nf.notInstalled')
|
|
4627
4792
|
return h('label', { class: 'fam-card' + (st === 'ready' ? '' : ' is-off') }, input, badge(f.id, 'sm'),
|
|
4628
4793
|
h('span', { class: 'fam-text' }, h('span', { class: 'fam-title' }, f.title), h('span', { class: 'fam-sub' }, sub)))
|
|
4629
4794
|
})
|
|
@@ -4855,7 +5020,7 @@ const MAIN = String.raw `
|
|
|
4855
5020
|
const cur = s.families[f]
|
|
4856
5021
|
orders[f] = { policy: cur && cur.policy === 'order' ? 'order' : 'pressure', order: cur ? cur.order.slice() : [] }
|
|
4857
5022
|
}
|
|
4858
|
-
return { auto: s.auto, sameFamily: s.sameFamily, prepareAt: s.prepareAt, threshold: s.threshold, wait: s.waitIfResetWithinMinutes, countdown: s.countdownSeconds, orders }
|
|
5023
|
+
return { auto: s.auto, sameFamily: s.sameFamily, prepareAt: s.prepareAt, threshold: s.threshold, wait: s.waitIfResetWithinMinutes, countdown: s.countdownSeconds, orders, crossOrganization: s.crossOrganization.slice() }
|
|
4859
5024
|
}
|
|
4860
5025
|
// "Let AI tune it" (spec §3.29): the AI gets the facts of sideby handoff status --json, as far as the page has them.
|
|
4861
5026
|
function askHandoff() {
|
|
@@ -4864,11 +5029,14 @@ const MAIN = String.raw `
|
|
|
4864
5029
|
const status = ah && ah.status ? ah.status : null
|
|
4865
5030
|
openAsk({ task: 'handoff', context: { handoff: handoffTaskFacts(st.settings, st.starters, S.state.accounts, Date.now(), status), version: BOOT.version } })
|
|
4866
5031
|
}
|
|
4867
|
-
|
|
5032
|
+
// focus: the field a rule's "Change…" is about, so the dialog opens at it.
|
|
5033
|
+
async function openHandoff(focus) {
|
|
4868
5034
|
if (!ahState()) return
|
|
4869
5035
|
ah = { form: handoffForm(), loading: true }
|
|
4870
5036
|
showDialog('handoff')
|
|
4871
5037
|
renderHandoff()
|
|
5038
|
+
const field = typeof focus === 'string' ? document.getElementById('ah-' + focus) : null
|
|
5039
|
+
if (field) field.focus()
|
|
4872
5040
|
await loadHandoffStatus()
|
|
4873
5041
|
}
|
|
4874
5042
|
async function loadHandoffStatus() {
|
|
@@ -4932,6 +5100,24 @@ const MAIN = String.raw `
|
|
|
4932
5100
|
} else kids.push(h('p', { class: 'muted small' }, t('ah.byQuotaHint')))
|
|
4933
5101
|
return h('div', { class: 'ah-fam' }, kids)
|
|
4934
5102
|
}
|
|
5103
|
+
// Accounts that may take over although signed in to another organization (config handoff.crossOrganization).
|
|
5104
|
+
function ahCrossOrganization() {
|
|
5105
|
+
const list = ah.form.crossOrganization
|
|
5106
|
+
const accounts = S.state.accounts.filter((a) => a.kind !== 'api')
|
|
5107
|
+
if (!accounts.length) return null
|
|
5108
|
+
return h('details', { class: 'ah-fam', open: list.length > 0 },
|
|
5109
|
+
h('summary', null, h('b', null, t('ah.crossOrg'))),
|
|
5110
|
+
h('p', { class: 'muted small' }, t('ah.crossOrgHint')),
|
|
5111
|
+
h('div', { class: 'ah-cross' }, accounts.map((a) => {
|
|
5112
|
+
const input = h('input', { type: 'checkbox', disabled: BOOT.readOnly })
|
|
5113
|
+
input.checked = list.includes(a.ref) || (a.aliases || []).some((n) => list.includes(n))
|
|
5114
|
+
input.addEventListener('change', () => ahEdit((f) => {
|
|
5115
|
+
f.crossOrganization = f.crossOrganization.filter((r) => r !== a.ref && !(a.aliases || []).includes(r))
|
|
5116
|
+
if (input.checked) f.crossOrganization.push(a.ref)
|
|
5117
|
+
}))
|
|
5118
|
+
return h('label', { class: 'check' }, input, h('span', { class: 'title-logo' }, badge(a.family, 'sm'), h('span', { class: 'mono' }, accountLabel(a.ref))))
|
|
5119
|
+
})))
|
|
5120
|
+
}
|
|
4935
5121
|
function ahReadiness() {
|
|
4936
5122
|
if (ah.loading) return h('p', { class: 'muted' }, spinner(), ' ', t('ah.checking'))
|
|
4937
5123
|
if (ah.error) return errorNote(ah.error, loadHandoffStatus)
|
|
@@ -4964,6 +5150,7 @@ const MAIN = String.raw `
|
|
|
4964
5150
|
ahNumber('countdown', t('ah.countdown'), 0, 60)))
|
|
4965
5151
|
if (f.prepareAt >= f.threshold) body.push(h('p', { class: 'note note-warn' }, t('ah.badLevels')))
|
|
4966
5152
|
for (const fam of st.starters) body.push(ahFamily(fam))
|
|
5153
|
+
body.push(ahCrossOrganization())
|
|
4967
5154
|
// The result of Review or Apply sits right under the form, where the button that made it is.
|
|
4968
5155
|
if (ah.applyError) body.push(errorNote(ah.applyError, null))
|
|
4969
5156
|
if (ah.saved) body.push(h('p', { class: 'note' }, t('ah.saved', { file: ah.saved })))
|
|
@@ -5003,6 +5190,8 @@ const MAIN = String.raw `
|
|
|
5003
5190
|
ah.preview = null
|
|
5004
5191
|
toast(r.settings.auto ? t('toast.ahOn') : t('toast.ahOff'))
|
|
5005
5192
|
await load({ silent: true })
|
|
5193
|
+
// The Handoff Rules behind the dialog show the new settings too.
|
|
5194
|
+
if (curPage === 'handoff') loadHandoffPage()
|
|
5006
5195
|
if (ahState()) ah.form = handoffForm()
|
|
5007
5196
|
ah.loading = true
|
|
5008
5197
|
ah.status = null
|
|
@@ -5138,7 +5327,7 @@ const MAIN = String.raw `
|
|
|
5138
5327
|
// ---------- the Auto Handoff page ----------
|
|
5139
5328
|
// Off: one sentence and one button. On: where each account's work would go next, the last hand-overs and what is
|
|
5140
5329
|
// still missing. Turning on is one plan shown first (hp.preview) and one confirmation; no commands to copy.
|
|
5141
|
-
const hp = { data: null, plan: null, loading: false, error: null, preview: null, previewing: false, applying: false, failed: null, changed: false,
|
|
5330
|
+
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 }
|
|
5142
5331
|
async function loadHandoffPage() {
|
|
5143
5332
|
// One read at a time: a second refresh while one runs would end its spinner early.
|
|
5144
5333
|
if (hp.loading) return
|
|
@@ -5154,8 +5343,8 @@ const MAIN = String.raw `
|
|
|
5154
5343
|
hp.loading = false
|
|
5155
5344
|
renderHandoffPage()
|
|
5156
5345
|
}
|
|
5157
|
-
//
|
|
5158
|
-
function hpBody() { return
|
|
5346
|
+
// The Handoff Rules on this page write each setting as it is switched, so turning on keeps whatever is set.
|
|
5347
|
+
function hpBody() { return {} }
|
|
5159
5348
|
async function hpPreview() {
|
|
5160
5349
|
hp.previewing = true
|
|
5161
5350
|
hp.failed = null
|
|
@@ -5171,11 +5360,10 @@ const MAIN = String.raw `
|
|
|
5171
5360
|
renderHandoffPage()
|
|
5172
5361
|
try {
|
|
5173
5362
|
const r = await api('/api/handoff/enable', Object.assign(hpBody(), { confirm: true, expect: hp.preview && hp.preview.key }))
|
|
5174
|
-
const
|
|
5175
|
-
|
|
5176
|
-
|
|
5177
|
-
if (
|
|
5178
|
-
else if (bad) hp.failed = { step: bad, plan: r.plan }
|
|
5363
|
+
const out = enableOutcome(r)
|
|
5364
|
+
hp.changed = out.kind === 'changed'
|
|
5365
|
+
if (out.kind === 'changed' || out.kind === 'blocked') hp.preview = out.plan
|
|
5366
|
+
else if (out.kind === 'failed') hp.failed = { step: out.step, plan: out.plan }
|
|
5179
5367
|
else { hp.preview = null; toast(t('toast.ahOn')) }
|
|
5180
5368
|
await load({ silent: true })
|
|
5181
5369
|
await loadHandoffPage()
|
|
@@ -5183,14 +5371,16 @@ const MAIN = String.raw `
|
|
|
5183
5371
|
hp.applying = false
|
|
5184
5372
|
renderHandoffPage()
|
|
5185
5373
|
}
|
|
5186
|
-
|
|
5374
|
+
// Every change on this page applies at once and its toast carries the undo (spec §3.17 "接力规则").
|
|
5375
|
+
async function hpChange(change, message, opts) {
|
|
5187
5376
|
hp.busyOff = true
|
|
5188
5377
|
renderHandoffPage()
|
|
5189
5378
|
try {
|
|
5190
|
-
await
|
|
5379
|
+
const { undo } = await saveHandoffChange(api, change, opts)
|
|
5191
5380
|
hp.preview = null
|
|
5192
5381
|
hp.askSame = false
|
|
5193
|
-
|
|
5382
|
+
hp.askApi = false
|
|
5383
|
+
toast(message, undo ? { action: { label: t('toast.undo'), run: () => hpChange(undo, t('hp.undone'), { noUndo: true }) }, duration: 12000 } : undefined)
|
|
5194
5384
|
await load({ silent: true })
|
|
5195
5385
|
await loadHandoffPage()
|
|
5196
5386
|
} catch (e) { hp.failed = { error: e } }
|
|
@@ -5230,39 +5420,117 @@ const MAIN = String.raw `
|
|
|
5230
5420
|
return h('p', { class: 'note note-fail', role: 'alert' }, t('hp.stepFailed', { step: hpStepTitle(f.step), why: f.step.message || '' }) + ' ' + t('hp.tryAgain'))
|
|
5231
5421
|
}
|
|
5232
5422
|
function hpDecision(d, starts) {
|
|
5233
|
-
|
|
5234
|
-
if (d.kind === 'pick') return starts.includes('quota') ? t('hp.goesTo', { to: accountLabel(d.ref), p: thr }) : t('hp.goesToLimit', { to: accountLabel(d.ref) })
|
|
5423
|
+
if (d.kind === 'pick') return starts.includes('quota') ? t('hp.goesTo', { to: accountLabel(d.ref) }) : t('hp.goesToLimit', { to: accountLabel(d.ref) })
|
|
5235
5424
|
if (d.kind === 'wait') return t('hp.waits', { at: clock(d.until) })
|
|
5236
5425
|
return d.earliestReset ? t('hp.noneBack', { ref: accountLabel(d.earliestReset.ref), at: clock(d.earliestReset.at) }) : t('hp.none')
|
|
5237
5426
|
}
|
|
5238
|
-
// The one case where reaching the threshold does not switch (spec §3.17 "选号" 1); none when waiting is off.
|
|
5239
|
-
function hpWaitRule(st) {
|
|
5240
|
-
const w = st.settings.waitIfResetWithinMinutes
|
|
5241
|
-
return w > 0 ? ' ' + t('hp.waitRule', { w }) : null
|
|
5242
|
-
}
|
|
5243
5427
|
function hpRows(d) {
|
|
5244
5428
|
if (!d.takeover.length) return h('p', { class: 'muted small' }, t('hp.noAccounts'))
|
|
5245
5429
|
return h('ul', { class: 'hp-rows' }, d.takeover.map((r) => {
|
|
5246
5430
|
const a = S.state.accounts.find((x) => x.ref === r.ref)
|
|
5247
5431
|
const p = a ? quotaPressure(a, Date.now()) : -1
|
|
5248
5432
|
return h('li', null,
|
|
5249
|
-
|
|
5250
|
-
h('span', { class: '
|
|
5251
|
-
h('span',
|
|
5433
|
+
// A hidden Account can still take over (spec §3.25): the mark says why it is here though the list leaves it out.
|
|
5434
|
+
h('span', { class: 'title-logo' }, badge(r.family, 'sm'), h('span', { class: 'mono' }, accountLabel(r.ref)), hiddenMark(Boolean(a && isHidden(a)))),
|
|
5435
|
+
h('span', { class: 'muted num' }, p >= 0 ? t('hp.used', { p: Math.round(p) }) : t('hp.noQuota')),
|
|
5436
|
+
h('span', { class: r.decision.kind === 'none' ? 'muted' : null }, hpDecision(r.decision, r.starts)))
|
|
5252
5437
|
}))
|
|
5253
5438
|
}
|
|
5254
5439
|
function hpRecent(d) {
|
|
5255
5440
|
if (!d.recent.length) return h('p', { class: 'muted small' }, t('hp.noneYet'))
|
|
5256
|
-
return h('ul', { class: 'hp-rows' }, d.recent.map((r) => h('li', null,
|
|
5441
|
+
return h('ul', { class: 'hp-rows hp-recent' }, d.recent.map((r) => h('li', null,
|
|
5257
5442
|
h('span', { class: 'mono' }, accountLabel(r.from) + ' → ' + accountLabel(r.to)),
|
|
5258
|
-
h('span', { class: 'muted' }, clock(r.at) + ' · ' + ago(r.at)),
|
|
5443
|
+
h('span', { class: 'muted num' }, clock(r.at) + ' · ' + ago(r.at)),
|
|
5259
5444
|
h('span', { class: 'muted' }, r.trigger ? t('hp.why.' + r.trigger) : ''))))
|
|
5260
5445
|
}
|
|
5261
|
-
|
|
5262
|
-
|
|
5263
|
-
|
|
5264
|
-
|
|
5265
|
-
|
|
5446
|
+
// ---- Handoff Rules (spec §3.17 "接力规则"): every rule in effect, each next to the switch that changes it ----
|
|
5447
|
+
function hpRuleText(r) {
|
|
5448
|
+
const p = r.params
|
|
5449
|
+
const thr = ahState().settings.threshold
|
|
5450
|
+
switch (r.id) {
|
|
5451
|
+
case 'when': return p.adaptive ? t('hp.rule.whenAdaptive', { prepare: p.prepareAt, p: p.threshold, max: p.max }) : t('hp.rule.when', { prepare: p.prepareAt, p: p.threshold })
|
|
5452
|
+
case 'windows': return t('hp.rule.windows')
|
|
5453
|
+
case 'takeover': return t('hp.rule.takeover', { limit: p.limit, p: thr })
|
|
5454
|
+
case 'wait': return p.minutes > 0 ? t('hp.rule.wait', { w: p.minutes }) : t('hp.rule.noWait')
|
|
5455
|
+
case 'sameFamily': return t(p.on ? 'hp.rule.sameOn' : 'hp.rule.sameOff')
|
|
5456
|
+
case 'otherFamilies': return p.on ? t('hp.rule.otherOn') : t('hp.rule.otherOff')
|
|
5457
|
+
case 'api': return t(p.on ? 'hp.rule.apiOn' : 'hp.rule.apiOff')
|
|
5458
|
+
case 'organization': return p.allowed.length ? t('hp.rule.orgExcept', { refs: p.allowed.map(accountLabel).join(', ') }) : t('hp.rule.org')
|
|
5459
|
+
case 'order': return t('hp.rule.order', { host: family(p.family).title, order: p.order.map(accountLabel).join(' → ') })
|
|
5460
|
+
case 'countdown': return p.seconds > 0 ? t('hp.rule.countdown', { s: p.seconds }) : t('hp.rule.noCountdown')
|
|
5461
|
+
}
|
|
5462
|
+
return r.text
|
|
5463
|
+
}
|
|
5464
|
+
// An on/off pair like Remote Control's; onPick(true|false) runs only when the side changes.
|
|
5465
|
+
function hpSwitch(key, label, on, onPick) {
|
|
5466
|
+
return h('div', { class: 'seg', role: 'group', 'aria-label': label }, [true, false].map((v) =>
|
|
5467
|
+
h('button', { class: 'seg-btn', type: 'button', 'data-key': key + ':' + v, disabled: BOOT.readOnly || hp.busyOff, 'aria-pressed': String(on === v), onclick: () => { if (on !== v) onPick(v) } }, t(v ? 'hp.on' : 'hp.off'))))
|
|
5468
|
+
}
|
|
5469
|
+
function hpEditBtn(key) {
|
|
5470
|
+
const field = { when: 'prepareAt', wait: 'wait', countdown: 'countdown' }[key]
|
|
5471
|
+
return h('button', { class: 'link-btn', type: 'button', 'data-key': 'edit:' + key, onclick: () => openHandoff(field) }, t('hp.edit'))
|
|
5472
|
+
}
|
|
5473
|
+
function hpConfirm(key, warn, cancel, confirmLabel, run) {
|
|
5474
|
+
return h('div', { class: 'ah-fam hp-confirm', 'data-enter': key },
|
|
5475
|
+
h('p', { class: 'note note-warn' }, warn),
|
|
5476
|
+
h('div', { class: 'row-actions' },
|
|
5477
|
+
h('button', { class: 'btn btn-sm', type: 'button', disabled: hp.busyOff, onclick: cancel }, t('btn.cancel')),
|
|
5478
|
+
h('button', { class: 'btn btn-sm btn-primary', type: 'button', 'data-key': 'confirm:' + key, disabled: BOOT.readOnly || hp.busyOff, onclick: run }, confirmLabel)))
|
|
5479
|
+
}
|
|
5480
|
+
// The AIs in the order they take over; ↑↓ write familyOrder at once.
|
|
5481
|
+
function hpAiOrder(order) {
|
|
5482
|
+
const move = (i, d) => { const l = order.slice(); const x = l[i]; l[i] = l[i + d]; l[i + d] = x; hpChange({ familyOrder: l }, t('hp.aiOrderSaved')) }
|
|
5483
|
+
return h('ol', { class: 'ah-order hp-ai-order' }, order.map((f, i) => h('li', null,
|
|
5484
|
+
h('span', { class: 'title-logo' }, badge(f, 'sm'), (i + 1) + '. ' + family(f).title),
|
|
5485
|
+
h('button', { class: 'btn btn-sm', type: 'button', 'data-key': 'up:' + f, disabled: BOOT.readOnly || hp.busyOff || i === 0, 'aria-label': t('ah.up'), onclick: () => move(i, -1) }, '↑'),
|
|
5486
|
+
h('button', { class: 'btn btn-sm', type: 'button', 'data-key': 'down:' + f, disabled: BOOT.readOnly || hp.busyOff || i === order.length - 1, 'aria-label': t('ah.down'), onclick: () => move(i, 1) }, '↓'))))
|
|
5487
|
+
}
|
|
5488
|
+
// ctl sits right of the rule's text; below takes the full width under it (a sub-switch, a confirmation, the AI order).
|
|
5489
|
+
function hpRuleControls(r) {
|
|
5490
|
+
const p = r.params
|
|
5491
|
+
switch (r.id) {
|
|
5492
|
+
case 'when': return { ctl: [hpEditBtn('when')], below: [h('div', { class: 'hp-rule-sub' }, h('span', { class: 'muted small' }, t('hp.adaptive')),
|
|
5493
|
+
hpSwitch('adaptive', t('hp.adaptive'), p.adaptive, (v) => hpChange({ adaptive: v }, t(v ? 'hp.adaptiveOn' : 'hp.adaptiveOff'))))] }
|
|
5494
|
+
case 'wait': case 'countdown': case 'order': case 'organization': return { ctl: [hpEditBtn(r.id)], below: [] }
|
|
5495
|
+
case 'sameFamily': return { ctl: [hpSwitch('same', t('hp.sameFamily'), p.on, (v) => {
|
|
5496
|
+
if (v) { hp.askSame = true; renderHandoffPage() } else hpChange({ sameFamily: false }, t('hp.sameOff'))
|
|
5497
|
+
})], below: [hp.askSame && !p.on ? hpConfirm('same', t('ah.sameFamilyWarn'), () => { hp.askSame = false; renderHandoffPage() }, t('hp.sameConfirm'), () => hpChange({ sameFamily: true }, t('hp.sameOn'))) : null] }
|
|
5498
|
+
case 'otherFamilies': return { ctl: [hpSwitch('other', t('hp.otherFamilies'), p.on, (v) => hpChange({ otherFamilies: v }, t(v ? 'hp.otherOn' : 'hp.otherOff')))],
|
|
5499
|
+
below: [p.on && p.order.length > 1 ? hpAiOrder(p.order) : null] }
|
|
5500
|
+
case 'api': return { ctl: [hpSwitch('api', t('hp.api'), p.on, (v) => {
|
|
5501
|
+
if (v) { hp.askApi = true; renderHandoffPage() } else hpChange({ api: false }, t('hp.apiOff'))
|
|
5502
|
+
})], below: [!p.accounts ? h('p', { class: 'muted small' }, t('hp.noApi')) : null,
|
|
5503
|
+
hp.askApi && !p.on ? hpConfirm('api', t('hp.apiWarn'), () => { hp.askApi = false; renderHandoffPage() }, t('hp.apiConfirm'), () => hpChange({ api: true }, t('hp.apiOn'))) : null] }
|
|
5504
|
+
}
|
|
5505
|
+
return { ctl: [], below: [] }
|
|
5506
|
+
}
|
|
5507
|
+
function hpRules(d) {
|
|
5508
|
+
if (!d || !d.rules) return null
|
|
5509
|
+
return [h('div', { class: 'page-sec-head' }, h('h3', { class: 'page-sec' }, t('hp.rules')),
|
|
5510
|
+
h('p', { class: 'muted small' }, t('hp.rulesNote'))),
|
|
5511
|
+
h('ol', { class: 'hp-rules' }, d.rules.map((r) => {
|
|
5512
|
+
const c = hpRuleControls(r)
|
|
5513
|
+
return h('li', { 'data-rule': r.id },
|
|
5514
|
+
h('div', { class: 'hp-rule-text' }, hpRuleText(r)),
|
|
5515
|
+
h('div', { class: 'hp-rule-ctl' }, c.ctl),
|
|
5516
|
+
...c.below.filter(Boolean).map((el) => h('div', { class: 'hp-rule-below' }, el)))
|
|
5517
|
+
}))]
|
|
5518
|
+
}
|
|
5519
|
+
// When no account could take over anywhere, say which switch opens the way instead of leaving a dead end.
|
|
5520
|
+
function hpNoneHint(d) {
|
|
5521
|
+
if (!d.takeover.length || d.takeover.some((r) => r.decision.kind !== 'none')) return null
|
|
5522
|
+
const st = ahState().settings
|
|
5523
|
+
return st.sameFamily && st.otherFamilies ? null : h('p', { class: 'note', 'data-enter': 'none-hint' }, t('hp.noneAll'))
|
|
5524
|
+
}
|
|
5525
|
+
// Up to ADR-0046 API accounts took over by themselves; this asks once, where Auto Handoff is on.
|
|
5526
|
+
function hpApiBanner() {
|
|
5527
|
+
const st = ahState()
|
|
5528
|
+
if (!st || !st.apiUndecided || BOOT.readOnly) return null
|
|
5529
|
+
return h('div', { class: 'banner banner-warn', role: 'status', 'data-enter': 'api-banner' },
|
|
5530
|
+
h('div', null, h('b', null, t('hp.apiAskTitle') + ' '), t('hp.apiAskBody')),
|
|
5531
|
+
h('div', { class: 'banner-actions' },
|
|
5532
|
+
h('button', { class: 'btn btn-sm btn-primary', type: 'button', disabled: hp.busyOff, onclick: () => hpChange({ api: false }, t('hp.apiKeptOff')) }, t('hp.apiKeepOff')),
|
|
5533
|
+
h('button', { class: 'btn btn-sm', type: 'button', disabled: hp.busyOff, onclick: () => hpChange({ api: true }, t('hp.apiOn')) }, t('hp.apiKeepOn'))))
|
|
5266
5534
|
}
|
|
5267
5535
|
function renderHandoffPage() {
|
|
5268
5536
|
const box = $('handoff-page')
|
|
@@ -5273,34 +5541,36 @@ const MAIN = String.raw `
|
|
|
5273
5541
|
h('h2', { id: 'h-handoff' }, t('hp.title')),
|
|
5274
5542
|
h('div', { class: 'row-actions' },
|
|
5275
5543
|
h('button', { class: 'btn btn-sm', type: 'button', onclick: askHandoff }, icon('bot'), t('ask.title.handoff')),
|
|
5276
|
-
h('button', { class: 'btn
|
|
5544
|
+
h('button', { class: 'link-btn small', type: 'button', onclick: () => openHandoff() }, t('hp.advanced')),
|
|
5277
5545
|
hp.loading ? spinner() : null))]
|
|
5278
5546
|
const on = st.settings.auto
|
|
5279
5547
|
if (hp.loading && !hp.data) kids.push(h('p', { class: 'muted' }, spinner(), ' ', t('hp.loading')))
|
|
5280
5548
|
if (hp.error) kids.push(errorNote(hp.error, loadHandoffPage))
|
|
5281
5549
|
if (BOOT.readOnly) kids.push(h('p', { class: 'note' }, t('banner.readOnly')))
|
|
5550
|
+
const d = hp.data
|
|
5551
|
+
// One status card on top: whether it is on, what that means, and the one action that changes it.
|
|
5552
|
+
const status = (text, action) => h('div', { class: 'hp-status' + (on ? ' is-on' : '') },
|
|
5553
|
+
h('span', { class: 'hp-status-ic' }, icon('swap')),
|
|
5554
|
+
h('div', { class: 'hp-status-text' }, h('b', null, on ? t('hp.statusOn') : t('hp.statusOff')), h('p', { class: 'muted' }, text)),
|
|
5555
|
+
action)
|
|
5282
5556
|
if (!on) {
|
|
5283
|
-
|
|
5284
|
-
kids.push(h('
|
|
5285
|
-
if (!
|
|
5286
|
-
else
|
|
5287
|
-
|
|
5288
|
-
|
|
5289
|
-
if (!hp.sameTouched) hp.sameFamily = st.settings.sameFamily
|
|
5290
|
-
kids.push(hpSameFamilyBox(hp.sameFamily, (v) => { hp.sameFamily = v; hp.sameTouched = true }))
|
|
5291
|
-
kids.push(h('div', { class: 'row-actions' }, h('button', { class: 'btn btn-primary', type: 'button', disabled: BOOT.readOnly || hp.previewing, 'aria-busy': hp.previewing ? 'true' : null, onclick: hpPreview }, hp.previewing ? spinner() : null, t('hp.turnOn'))))
|
|
5292
|
-
} else kids.push(hpPreviewCard())
|
|
5293
|
-
}
|
|
5557
|
+
const starters = S.state.accounts.some((a) => a.kind !== 'api' && st.starters.includes(a.family))
|
|
5558
|
+
kids.push(status(t('hp.intro'), starters && !hp.preview ? h('button', { class: 'btn btn-primary', type: 'button', 'data-key': 'turn-on', disabled: BOOT.readOnly || hp.previewing, 'aria-busy': hp.previewing ? 'true' : null, onclick: hpPreview }, hp.previewing ? spinner() : null, t('hp.turnOn')) : null))
|
|
5559
|
+
if (!starters) kids.push(h('p', { class: 'note' }, t('hp.noStarters')))
|
|
5560
|
+
else if (hp.preview) kids.push(hpPreviewCard())
|
|
5561
|
+
kids.push(hpRules(d))
|
|
5562
|
+
if (d && d.takeover.length) kids.push(h('h3', { class: 'page-sec' }, t('hp.takeoverIf')), hpRows(d), hpNoneHint(d))
|
|
5294
5563
|
} else {
|
|
5295
|
-
kids.push(
|
|
5296
|
-
|
|
5564
|
+
kids.push(status(t('hp.onNote'),
|
|
5565
|
+
h('button', { class: 'btn', type: 'button', 'data-key': 'turn-off', disabled: BOOT.readOnly || hp.busyOff, onclick: () => hpChange({ auto: false }, t('toast.ahOff')) }, t('hp.turnOff'))))
|
|
5297
5566
|
if (d) {
|
|
5298
|
-
kids.push(h('h3', { class: '
|
|
5299
|
-
kids.push(
|
|
5567
|
+
kids.push(h('h3', { class: 'page-sec' }, t('hp.takeover')), hpRows(d), hpNoneHint(d))
|
|
5568
|
+
kids.push(...(hpRules(d) || []))
|
|
5569
|
+
kids.push(h('h3', { class: 'page-sec' }, t('hp.recent')), hpRecent(d))
|
|
5300
5570
|
}
|
|
5301
5571
|
const plan = hp.plan
|
|
5302
5572
|
if (plan && (plan.blocked || plan.steps.length)) {
|
|
5303
|
-
kids.push(h('h3', { class: '
|
|
5573
|
+
kids.push(h('h3', { class: 'page-sec' }, t('hp.missing')))
|
|
5304
5574
|
if (!hp.preview) {
|
|
5305
5575
|
if (plan.blocked) kids.push(h('p', { class: 'note note-fail' }, t('hp.blocked', { why: plan.blocked })), codeCopy('npm i -g sideby'))
|
|
5306
5576
|
else {
|
|
@@ -5310,18 +5580,9 @@ const MAIN = String.raw `
|
|
|
5310
5580
|
} else kids.push(hpPreviewCard())
|
|
5311
5581
|
} else if (plan) kids.push(...hpManual(plan))
|
|
5312
5582
|
kids.push(h('p', { class: 'muted small' }, t('hp.onlySideby')))
|
|
5313
|
-
kids.push(hpSameFamilyBox(st.settings.sameFamily, (v) => {
|
|
5314
|
-
if (v) { hp.askSame = true; renderHandoffPage() } else { hp.askSame = false; hpChange({ sameFamily: false }, t('hp.sameOff')) }
|
|
5315
|
-
}))
|
|
5316
|
-
if (hp.askSame && !st.settings.sameFamily) kids.push(h('div', { class: 'ah-fam' },
|
|
5317
|
-
h('p', { class: 'note note-warn' }, t('ah.sameFamilyWarn')),
|
|
5318
|
-
h('div', { class: 'row-actions' },
|
|
5319
|
-
h('button', { class: 'btn', type: 'button', disabled: hp.busyOff, onclick: () => { hp.askSame = false; renderHandoffPage() } }, t('btn.cancel')),
|
|
5320
|
-
h('button', { class: 'btn btn-primary', type: 'button', disabled: BOOT.readOnly || hp.busyOff, onclick: () => { hp.askSame = false; hpChange({ sameFamily: true }, t('hp.sameOn')) } }, t('hp.sameConfirm')))))
|
|
5321
|
-
kids.push(h('div', { class: 'row-actions' }, h('button', { class: 'btn', type: 'button', disabled: BOOT.readOnly || hp.busyOff, onclick: () => hpChange({ auto: false }, t('toast.ahOff')) }, hp.busyOff ? spinner() : null, t('hp.turnOff'))))
|
|
5322
5583
|
}
|
|
5323
5584
|
kids.push(hpFailed())
|
|
5324
|
-
|
|
5585
|
+
swapKids(box, kids)
|
|
5325
5586
|
}
|
|
5326
5587
|
|
|
5327
5588
|
// ---------- Remote Control (spec §3.22) ----------
|
|
@@ -5330,13 +5591,18 @@ const MAIN = String.raw `
|
|
|
5330
5591
|
// target: the side the dialog's switch was moved to, waiting for its confirmation; null while nothing is chosen.
|
|
5331
5592
|
const rc = { confirm: false, busy: false, target: null }
|
|
5332
5593
|
const shortRef = (ref) => ref.replace(/^claude:/, '')
|
|
5594
|
+
// One settings key's change: the key and literal values in the code font, "not set" in words.
|
|
5595
|
+
function keyChange(key, from, to) {
|
|
5596
|
+
const val = (v) => (v === null ? t('rc.notSet') : h('code', null, v))
|
|
5597
|
+
return h('span', { class: 'key-change' }, h('code', null, key), ' ', val(from), ' → ', val(to))
|
|
5598
|
+
}
|
|
5333
5599
|
function remoteControlBanner() {
|
|
5334
5600
|
const groups = S.state.remoteControl || []
|
|
5335
5601
|
// API Accounts never sign in to claude.ai, so Remote Control cannot reach their sessions.
|
|
5336
5602
|
const api = new Set(S.state.accounts.filter((a) => a.kind === 'api').map((a) => a.ref))
|
|
5337
5603
|
const refs = groups.filter((g) => g.state === 'on').flatMap((g) => g.accounts).filter((r) => !api.has(r)).map(shortRef)
|
|
5338
5604
|
if (!refs.length || prefs.rcHide) return null
|
|
5339
|
-
const todo = groups
|
|
5605
|
+
const todo = remoteControlTodo(groups, 'off')
|
|
5340
5606
|
const text = h('div', null, h('b', null, t('rc.title') + ' '), tn('rc.body', refs.length, { refs: refs.join(', ') }))
|
|
5341
5607
|
if (BOOT.readOnly) return h('div', { class: 'banner banner-warn', role: 'status' }, h('div', null, text, ' ', t('rc.readOnly')))
|
|
5342
5608
|
if (!rc.confirm)
|
|
@@ -5345,8 +5611,14 @@ const MAIN = String.raw `
|
|
|
5345
5611
|
h('button', { class: 'btn btn-sm btn-primary', type: 'button', onclick: () => { rc.confirm = true; renderBanners() } }, t('rc.turnOff')),
|
|
5346
5612
|
h('button', { class: 'btn btn-sm', type: 'button', onclick: () => { prefs.rcHide = true; savePrefs(); renderBanners(); toast(t('rc.hidden')) } }, t('rc.keep'))))
|
|
5347
5613
|
const lines = todo.map((g) => h('li', null, h('code', null, g.file), ' ',
|
|
5348
|
-
|
|
5614
|
+
keyChange('remoteControlAtStartup', g.state === 'on' ? 'true' : null, 'false'), ' ',
|
|
5349
5615
|
h('span', { class: 'muted' }, t('rc.usedBy', { refs: g.accounts.map(shortRef).join(', ') }))))
|
|
5616
|
+
// Files sideby cannot change stay listed, as in the dialog, so "all" never hides one.
|
|
5617
|
+
for (const g of groups.filter((g) => g.state === 'blocked' || g.state === 'missing'))
|
|
5618
|
+
lines.push(h('li', null, h('code', null, g.file), ' ',
|
|
5619
|
+
h('span', { class: 'chip chip-sm' + (g.state === 'blocked' ? ' chip-fail' : '') }, t('rc.state.' + g.state)), ' ',
|
|
5620
|
+
h('span', { class: 'muted' }, t('rc.usedBy', { refs: g.accounts.map(shortRef).join(', ') })),
|
|
5621
|
+
g.reason ? h('div', { class: 'muted small' }, t('rc.skipped') + (g.why ? t('settings.why.' + g.why) : g.reason)) : null))
|
|
5350
5622
|
return h('div', { class: 'banner banner-warn', role: 'status' },
|
|
5351
5623
|
h('div', null, h('b', null, t('rc.confirmTitle')), h('ul', null, lines), h('div', { class: 'small' }, t('rc.confirmNote'))),
|
|
5352
5624
|
h('div', { class: 'banner-actions' },
|
|
@@ -5359,8 +5631,10 @@ const MAIN = String.raw `
|
|
|
5359
5631
|
if (dlg.kind === 'rc') renderRc()
|
|
5360
5632
|
const fail = to === 'on' ? 'rc.failedOn' : 'rc.failed'
|
|
5361
5633
|
try {
|
|
5362
|
-
const
|
|
5363
|
-
|
|
5634
|
+
const files = remoteControlTodo(S.state.remoteControl || [], to).map((g) => g.file)
|
|
5635
|
+
const r = await api('/api/remote-control/' + to, { confirm: true, files })
|
|
5636
|
+
if (r.changedSince) toast(t('as.changedSince'), { kind: 'fail' })
|
|
5637
|
+
else if (r.ok) {
|
|
5364
5638
|
// Show the new state now; the reload that follows confirms it.
|
|
5365
5639
|
const changed = new Set(remoteControlTodo(S.state.remoteControl || [], to).map((g) => g.file))
|
|
5366
5640
|
S.state.remoteControl = (S.state.remoteControl || []).map((g) => changed.has(g.file) ? { ...g, state: to, undo: true } : g)
|
|
@@ -5377,7 +5651,7 @@ const MAIN = String.raw `
|
|
|
5377
5651
|
}
|
|
5378
5652
|
async function remoteControlUndo() {
|
|
5379
5653
|
try {
|
|
5380
|
-
const r = await api('/api/remote-control/undo', {})
|
|
5654
|
+
const r = await api('/api/remote-control/undo', { confirm: true })
|
|
5381
5655
|
toast(r.ok ? t('rc.undone') : r.message, { kind: r.ok ? 'ok' : 'fail' })
|
|
5382
5656
|
} catch (e) { toast(t('toast.undoFailed', { msg: e.message }), { kind: 'fail' }) }
|
|
5383
5657
|
await load({ silent: true })
|
|
@@ -5477,7 +5751,7 @@ const MAIN = String.raw `
|
|
|
5477
5751
|
function settingsGroups(leave) {
|
|
5478
5752
|
const secs = settingsSections()
|
|
5479
5753
|
const link = (...args) => setLink(leave, ...args)
|
|
5480
|
-
const general = [...lookRows(), autostartRow('autostart')]
|
|
5754
|
+
const general = [...lookRows(), link(t('th.title'), themeLabel(), '', openThemes, true), autostartRow('autostart')]
|
|
5481
5755
|
if (!BOOT.readOnly) general.push(link(t('term.title'), '', '', openTerminals, true))
|
|
5482
5756
|
// The menu bar switch shows only where it works (macOS); while its state loads it waits, unseen.
|
|
5483
5757
|
const bar = []
|
|
@@ -5490,7 +5764,8 @@ const MAIN = String.raw `
|
|
|
5490
5764
|
const acct = []
|
|
5491
5765
|
// The arrange mode (spec §3.25) has a place here too, where people look for "how do I change this".
|
|
5492
5766
|
if (secs.includes('order')) {
|
|
5493
|
-
const
|
|
5767
|
+
const d = displayOf()
|
|
5768
|
+
const pins = [d.pinned, d.hidden].some((r) => Object.values(r || {}).some((x) => x.length)) || Boolean(d.hiddenFamilies && d.hiddenFamilies.length)
|
|
5494
5769
|
acct.push(link(t('set.order'), t(ordered() || pins ? 'set.orderMine' : 'set.orderDefault'), '', () => {
|
|
5495
5770
|
setPage('accounts')
|
|
5496
5771
|
startArrange()
|
|
@@ -5852,6 +6127,7 @@ const MAIN = String.raw `
|
|
|
5852
6127
|
function adoptPanel(next) {
|
|
5853
6128
|
if (!CFG || cfgSaving) return
|
|
5854
6129
|
next = next || {}
|
|
6130
|
+
if ((next.colorTheme || 'default') !== themeChosen) refreshThemeCss()
|
|
5855
6131
|
if (next.theme === cfgPanel.theme && next.language === cfgPanel.language) return
|
|
5856
6132
|
cfgPanel = Object.assign({}, next)
|
|
5857
6133
|
applyTheme()
|
|
@@ -5875,6 +6151,7 @@ const MAIN = String.raw `
|
|
|
5875
6151
|
else if (dlg.kind === 'ask' && ak) { if (ak.els.text) ak.text = ak.els.text.value; renderAsk() }
|
|
5876
6152
|
else if (dlg.kind === 'key' && ky && ky.step !== 'enter') renderKey()
|
|
5877
6153
|
else if (dlg.kind === 'terminal' && tm) renderTerminals()
|
|
6154
|
+
else if (dlg.kind === 'theme' && th) renderThemes()
|
|
5878
6155
|
else if (dlg.kind === 'autostart') renderAutostart()
|
|
5879
6156
|
else if (dlg.kind === 'mbset') renderMenubarSettings()
|
|
5880
6157
|
else if (dlg.kind === 'pick' && pk) renderPick()
|
|
@@ -5891,7 +6168,7 @@ const MAIN = String.raw `
|
|
|
5891
6168
|
return Boolean(u && u.skillUpdate && u.skillUpdate.installed && u.skillUpdate.installed.length)
|
|
5892
6169
|
}
|
|
5893
6170
|
// Example phrases: a click puts one in the Let AI do it box (spec §3.28).
|
|
5894
|
-
const AI_ASKS = ['ai.ask.quota', 'ai.ask.pick', 'ai.ask.new', 'ai.ask.api', 'ai.ask.pin', 'ai.ask.relogin', 'ai.ask.fix', 'ai.ask.handoff', 'ai.ask.session', 'ai.ask.history', 'ai.ask.send', 'ai.ask.inbound', 'ai.ask.menubar', 'ai.ask.rc', 'ai.ask.tool']
|
|
6171
|
+
const AI_ASKS = ['ai.ask.quota', 'ai.ask.pick', 'ai.ask.new', 'ai.ask.api', 'ai.ask.pin', 'ai.ask.hide', 'ai.ask.relogin', 'ai.ask.fix', 'ai.ask.handoff', 'ai.ask.handoffRules', 'ai.ask.session', 'ai.ask.history', 'ai.ask.send', 'ai.ask.inbound', 'ai.ask.menubar', 'ai.ask.rc', 'ai.ask.theme', 'ai.ask.tool']
|
|
5895
6172
|
function openRc() {
|
|
5896
6173
|
if (!S.state || !rcSummary()) return
|
|
5897
6174
|
rc.target = null
|
|
@@ -5910,12 +6187,12 @@ const MAIN = String.raw `
|
|
|
5910
6187
|
const sw = h('div', { class: 'set-row rc-switch' }, h('span', null, t('rc.switch')),
|
|
5911
6188
|
h('div', { class: 'seg', role: 'group', 'aria-label': t('rc.switch') }, ['on', 'off'].map((v) =>
|
|
5912
6189
|
h('button', { class: 'seg-btn', type: 'button', disabled: BOOT.readOnly || rc.busy, 'aria-pressed': String((to || sum) === v), onclick: () => pick(v) }, t('rc.state.' + v)))))
|
|
5913
|
-
const fromOf = (g) => g.state === 'on' ? 'true' : g.state === 'off' ? 'false' :
|
|
6190
|
+
const fromOf = (g) => g.state === 'on' ? 'true' : g.state === 'off' ? 'false' : null
|
|
5914
6191
|
const rows = groups.map((g) => h('li', { class: 'rc-row' },
|
|
5915
6192
|
h('div', null, h('code', null, g.file), ' ', h('span', { class: 'chip chip-sm ' + (g.state === 'on' ? 'chip-warn' : g.state === 'off' ? 'chip-ok' : g.state === 'blocked' ? 'chip-fail' : '') }, t('rc.state.' + g.state))),
|
|
5916
6193
|
h('div', { class: 'muted small' }, t('rc.usedBy', { refs: g.accounts.map(shortRef).join(', ') })),
|
|
5917
|
-
g.reason ? h('div', { class: 'muted small' }, g.reason) : null,
|
|
5918
|
-
changing.has(g.file) ? h('div', { class: 'small rc-change' },
|
|
6194
|
+
g.reason ? h('div', { class: 'muted small' }, g.why ? t('settings.why.' + g.why) : g.reason) : null,
|
|
6195
|
+
changing.has(g.file) ? h('div', { class: 'small rc-change' }, keyChange('remoteControlAtStartup', fromOf(g), to === 'on' ? 'true' : 'false')) : null))
|
|
5919
6196
|
const body = [h('p', { class: 'small' }, t('rc.explain')), sw, h('ul', { class: 'rc-list' }, rows)]
|
|
5920
6197
|
if (to === 'on') body.push(h('div', { class: 'note note-warn small' }, t('rc.onWarn')))
|
|
5921
6198
|
else if (to === 'off') body.push(h('p', { class: 'small muted' }, t('rc.confirmNote')))
|
|
@@ -6462,6 +6739,124 @@ const MAIN = String.raw `
|
|
|
6462
6739
|
setKids(dlg.el, dialogFrame(t('term.title'), null, body, [h('button', { class: 'btn', type: 'button', onclick: () => dlg.el.close() }, t('btn.close'))]))
|
|
6463
6740
|
}
|
|
6464
6741
|
|
|
6742
|
+
// ---------- Themes (spec §3.34, ADR-0050) ----------
|
|
6743
|
+
// The Theme dialog: Built-in Themes and Theme Files as cards, the user's own color, and "Let AI pick my colors".
|
|
6744
|
+
// A switch swaps the page's token rules in place (a constructed sheet after the page's own), so the colors ease over
|
|
6745
|
+
// instead of the page reloading.
|
|
6746
|
+
let th = null
|
|
6747
|
+
let themeFetching = false
|
|
6748
|
+
// The Theme config names ('default' when none) and the one the page shows (inside a Portal, 'default' is its colors).
|
|
6749
|
+
let themeChosen = (BOOT.panel && BOOT.panel.colorTheme) || 'default'
|
|
6750
|
+
let themeNow = themeChosen === 'default' ? 'sky' : themeChosen
|
|
6751
|
+
function themeName(x) { return x.source === 'portal' ? t('th.page') : x.id === 'custom' && x.source === 'file' ? t('th.custom') : lang === 'zh' && x.nameZh ? x.nameZh : x.name }
|
|
6752
|
+
function themeLabel() {
|
|
6753
|
+
const x = th && th.data && th.data.themes.find((y) => y.id === themeNow)
|
|
6754
|
+
if (x) return themeName(x)
|
|
6755
|
+
if (themeNow === 'default') return t('th.page')
|
|
6756
|
+
const b = { sky: ['Sky', '晴空'], leaf: ['New Leaf', '新叶'] }[themeNow]
|
|
6757
|
+
return b ? b[lang === 'zh' ? 1 : 0] : themeNow
|
|
6758
|
+
}
|
|
6759
|
+
function applyThemeCss(css) {
|
|
6760
|
+
if (!css || typeof CSSStyleSheet !== 'function' || !('adoptedStyleSheets' in document)) { location.reload(); return }
|
|
6761
|
+
const root = document.documentElement
|
|
6762
|
+
if (!REDUCED) { root.classList.add('theme-fade'); setTimeout(() => root.classList.remove('theme-fade'), 220) }
|
|
6763
|
+
const sheet = new CSSStyleSheet()
|
|
6764
|
+
sheet.replaceSync(css)
|
|
6765
|
+
document.adoptedStyleSheets = [sheet]
|
|
6766
|
+
}
|
|
6767
|
+
function refreshThemeCss() {
|
|
6768
|
+
if (themeFetching) return
|
|
6769
|
+
themeFetching = true
|
|
6770
|
+
api('/api/themes').then((d) => { themeFetching = false; themeData(d) }, () => { themeFetching = false })
|
|
6771
|
+
}
|
|
6772
|
+
function themeData(d) {
|
|
6773
|
+
themeNow = d.active
|
|
6774
|
+
themeChosen = d.chosen
|
|
6775
|
+
applyThemeCss(d.css)
|
|
6776
|
+
if (th) { th.data = d; if (dlg.kind === 'theme') renderThemes() }
|
|
6777
|
+
refreshSettings()
|
|
6778
|
+
}
|
|
6779
|
+
function openThemes() {
|
|
6780
|
+
closeMenu()
|
|
6781
|
+
th = { data: null, busy: false, error: null, accent: null, ai: '', armed: null, status: null }
|
|
6782
|
+
showDialog('theme')
|
|
6783
|
+
renderThemes()
|
|
6784
|
+
api('/api/themes').then((d) => { if (th) { th.data = d; themeNow = d.active; themeChosen = d.chosen; renderThemes() } }, (e) => { if (th) { th.error = e; renderThemes() } })
|
|
6785
|
+
}
|
|
6786
|
+
async function themeSend(body) {
|
|
6787
|
+
if (th) { th.busy = true; th.error = null; renderThemes() }
|
|
6788
|
+
let d = null
|
|
6789
|
+
try { d = await api('/api/theme', body) } catch (e) { if (th) th.error = e; else toast(e.message, { kind: 'fail' }) }
|
|
6790
|
+
if (th) th.busy = false
|
|
6791
|
+
if (d) themeData(d)
|
|
6792
|
+
else if (th && dlg.kind === 'theme') renderThemes()
|
|
6793
|
+
return d
|
|
6794
|
+
}
|
|
6795
|
+
async function useThemeBy(body) {
|
|
6796
|
+
const d = await themeSend(body)
|
|
6797
|
+
if (!d || !th) return
|
|
6798
|
+
const x = d.themes.find((y) => y.id === d.active)
|
|
6799
|
+
th.status = { text: t('th.switched', { name: x ? themeName(x) : d.active }), undo: true }
|
|
6800
|
+
renderThemes()
|
|
6801
|
+
}
|
|
6802
|
+
async function undoThemeSwitch() {
|
|
6803
|
+
const back = await themeSend({ undo: true })
|
|
6804
|
+
if (!back || !th) return
|
|
6805
|
+
const y = back.themes.find((z) => z.id === back.active)
|
|
6806
|
+
th.status = { text: t('th.undone', { name: y ? themeName(y) : back.active }), undo: false }
|
|
6807
|
+
renderThemes()
|
|
6808
|
+
}
|
|
6809
|
+
function renderThemes() {
|
|
6810
|
+
if (!th) return
|
|
6811
|
+
const d = th.data
|
|
6812
|
+
const body = [h('p', { class: 'muted small' }, t('th.intro'))]
|
|
6813
|
+
// What changed, with undo, sits in the footer beside Close, so the dialog never grows when it appears.
|
|
6814
|
+
const st = th.status
|
|
6815
|
+
const status = h('p', { class: 'theme-status small', role: 'status' }, st ? [st.text, st.undo ? h('button', { class: 'link-btn', type: 'button', disabled: th.busy, onclick: undoThemeSwitch }, t('th.undo')) : null] : null)
|
|
6816
|
+
if (!d && !th.error) body.push(h('p', { class: 'muted small' }, spinner(), ' ', t('th.loading')))
|
|
6817
|
+
if (d) {
|
|
6818
|
+
if (d.fallback) body.push(h('p', { class: 'note note-warn' }, d.fallback))
|
|
6819
|
+
else if (d.adjusted) body.push(h('p', { class: 'note' }, t('th.adjusted', { n: d.adjusted })))
|
|
6820
|
+
body.push(h('div', { class: 'theme-grid', role: 'radiogroup', 'aria-label': t('th.title') }, d.themes.filter((x) => x.source === 'builtin' || !x.problems.length).map((x) => {
|
|
6821
|
+
const on = x.id === d.active
|
|
6822
|
+
return h('button', { class: 'theme-card' + (on ? ' is-on' : ''), type: 'button', role: 'radio', 'aria-checked': String(on), disabled: th.busy || (BOOT.readOnly && !on), onclick: () => { if (!on && !BOOT.readOnly) useThemeBy({ use: x.id }) } },
|
|
6823
|
+
h('span', { class: 'theme-sw', 'aria-hidden': 'true' }, x.swatches.map((c) => h('span', { css: { background: c } }))),
|
|
6824
|
+
h('span', { class: 'theme-name' }, h('span', null, themeName(x)), on ? h('span', { class: 'chip chip-sm chip-ok' }, t('th.inUse')) : x.source === 'file' ? h('span', { class: 'faint small' }, t('th.mine')) : null))
|
|
6825
|
+
})))
|
|
6826
|
+
if (!BOOT.readOnly) {
|
|
6827
|
+
const cur = d.themes.find((y) => y.id === d.active)
|
|
6828
|
+
const pick = h('input', { id: 'th-accent', type: 'color', value: th.accent || (cur && cur.swatches[2]) || '#3f8fc4', disabled: th.busy, 'aria-label': t('th.accent') })
|
|
6829
|
+
pick.addEventListener('input', () => { th.accent = pick.value })
|
|
6830
|
+
body.push(h('div', { class: 'theme-row' },
|
|
6831
|
+
h('label', { class: 'theme-label', for: 'th-accent' }, t('th.accent')), pick,
|
|
6832
|
+
h('button', { class: 'btn btn-sm', type: 'button', disabled: th.busy, onclick: () => useThemeBy({ accent: pick.value }) }, t('th.accentUse'))),
|
|
6833
|
+
h('p', { class: 'field-hint' }, t('th.accentHint')))
|
|
6834
|
+
const ai = h('input', { id: 'th-ai', type: 'text', autocomplete: 'off', placeholder: t('th.aiPh'), 'aria-label': t('th.ai') })
|
|
6835
|
+
ai.value = th.ai
|
|
6836
|
+
ai.addEventListener('input', () => { th.ai = ai.value })
|
|
6837
|
+
const go = () => {
|
|
6838
|
+
openAsk({ task: 'theme', text: th.ai.trim(), context: { theme: cur ? cur.name + ' (' + cur.id + ')' : d.active, version: BOOT.version } })
|
|
6839
|
+
}
|
|
6840
|
+
ai.addEventListener('keydown', (e) => { if (e.key === 'Enter' && !e.isComposing) { e.preventDefault(); go() } })
|
|
6841
|
+
body.push(h('label', { class: 'field', for: 'th-ai' }, h('span', null, t('th.ai')), ai),
|
|
6842
|
+
h('div', { class: 'theme-row' }, h('button', { class: 'btn btn-sm', type: 'button', onclick: go }, icon('bot'), t('th.aiGo')), h('span', { class: 'field-hint' }, t('th.aiHint'))))
|
|
6843
|
+
const files = d.themes.filter((x) => x.source === 'file')
|
|
6844
|
+
if (files.length) body.push(h('div', { class: 'theme-files' }, h('p', { class: 'set-label' }, t('th.files')), files.map((x) => {
|
|
6845
|
+
const sure = th.armed === x.id
|
|
6846
|
+
return h('div', { class: 'theme-file' },
|
|
6847
|
+
h('span', { class: 'theme-file-name' }, themeName(x), x.problems.length ? h('span', { class: 'theme-bad small' }, x.problems[0]) : null),
|
|
6848
|
+
h('button', { class: 'btn btn-sm' + (sure ? ' btn-danger' : ''), type: 'button', disabled: th.busy, onclick: async () => {
|
|
6849
|
+
if (!sure) { th.armed = x.id; renderThemes(); return }
|
|
6850
|
+
th.armed = null
|
|
6851
|
+
if (await themeSend({ remove: x.id })) toast(t('th.removed', { name: themeName(x) }))
|
|
6852
|
+
} }, t(sure ? 'th.removeSure' : 'th.remove')))
|
|
6853
|
+
})))
|
|
6854
|
+
}
|
|
6855
|
+
}
|
|
6856
|
+
if (th.error) body.push(errorNote(th.error, null))
|
|
6857
|
+
setKids(dlg.el, dialogFrame(t('th.title'), null, body, [status, h('button', { class: 'btn', type: 'button', onclick: () => dlg.el.close() }, t('btn.close'))]))
|
|
6858
|
+
}
|
|
6859
|
+
|
|
6465
6860
|
// ---------- pick commands (spec §3.13, ADR-0035) ----------
|
|
6466
6861
|
// A short command per tool that starts, each time, the account with the most quota left. The dialog lists every
|
|
6467
6862
|
// tool that has one or could have one; adding shows what the name would hide in the shell before it writes.
|
|
@@ -6671,6 +7066,9 @@ const MAIN = String.raw `
|
|
|
6671
7066
|
const mb = curPage === 'accounts' ? menubarHint() : null
|
|
6672
7067
|
if (mb) out.push(mb)
|
|
6673
7068
|
}
|
|
7069
|
+
// On every page until answered: whether API accounts may still take over (ADR-0046).
|
|
7070
|
+
const apiBanner = hpApiBanner()
|
|
7071
|
+
if (apiBanner) out.push(apiBanner)
|
|
6674
7072
|
const rcBanner = remoteControlBanner()
|
|
6675
7073
|
if (rcBanner) out.push(rcBanner)
|
|
6676
7074
|
const inbBanner = inboundBanner()
|