sideby 0.41.2 → 0.41.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist/build.json +1 -1
  2. package/dist/src/cli/commands.js +163 -32
  3. package/dist/src/cli/json-schemas.js +41 -4
  4. package/dist/src/cli/main.js +17 -6
  5. package/dist/src/core/cli-commands.js +1 -1
  6. package/dist/src/core/config.d.ts +16 -0
  7. package/dist/src/core/config.js +262 -42
  8. package/dist/src/core/history-project.d.ts +14 -0
  9. package/dist/src/core/history-project.js +42 -12
  10. package/dist/src/core/history.d.ts +4 -6
  11. package/dist/src/core/history.js +5 -15
  12. package/dist/src/core/local-build.d.ts +12 -0
  13. package/dist/src/core/local-build.js +32 -0
  14. package/dist/src/core/search-catalog.js +27 -0
  15. package/dist/src/core/unattended-followup.d.ts +62 -0
  16. package/dist/src/core/unattended-followup.js +205 -0
  17. package/dist/src/core/unattended-pending.d.ts +11 -3
  18. package/dist/src/core/unattended-pending.js +34 -8
  19. package/dist/src/families/claude/history.js +9 -1
  20. package/dist/src/families/history.d.ts +22 -2
  21. package/dist/src/families/history.js +55 -0
  22. package/dist/src/handoff/messages.js +1 -1
  23. package/dist/src/panel/handler.d.ts +11 -4
  24. package/dist/src/panel/handler.js +50 -25
  25. package/dist/src/panel/i18n.d.ts +23 -1
  26. package/dist/src/panel/i18n.js +48 -4
  27. package/dist/src/panel/page-logic.d.ts +53 -0
  28. package/dist/src/panel/page-logic.js +96 -0
  29. package/dist/src/panel/page-script.js +140 -36
  30. package/dist/src/panel/page-styles.js +17 -0
  31. package/dist/src/unattended/hook.d.ts +10 -5
  32. package/dist/src/unattended/hook.js +17 -12
  33. package/package.json +1 -1
  34. package/schemas/unattended-pending.json +156 -56
  35. package/skills/sideby/SKILL.md +2 -1
  36. package/skills/sideby/references/diagnose.md +1 -0
  37. package/skills/sideby/references/handoff.md +1 -1
  38. package/skills/sideby/references/panel.md +1 -1
  39. package/skills/sideby/references/unattended.md +16 -5
@@ -6,7 +6,7 @@ import { groupsToAccept } from '../core/inbound.js';
6
6
  import { limitResetOffer, quotaAge, quotaIsStale, windowAge } from '../core/quota-levels.js';
7
7
  import { remoteControlTodo } from '../core/remote-control.js';
8
8
  import { catalogMatchLevel, catalogNorm, searchCatalog } from '../core/search-catalog.js';
9
- import { accountTitle, advisorPick, advisorSummary, aiTaskAccounts, aliasArgsOf, aliasIssue, aliasPrefix, askBridge, askBridged, askCopy, askPermissionNote, attentionReasons, attentionWhy, autostartNote, bindingWindow, cacheHitRate, canLeaveLocal, categoryOrder, codeSwapOutcome, dotsKeepKeyboard, enableOutcome, expiredLogins, fileSize, fixPrompt, foldSkips, foldToolCalls, formatDuration, handoffChangeOf, handoffHintAccount, handoffTaskFacts, hiddenIn, highlightParts, histFilters, historyEmpty, historyWhen, hotkeyFromKey, hotkeyPressKind, inDisplayOrder, loginClusters, loginKey, longWindow, maskEmail, matchesQuery, mdBlocks, mdInline, menuPlacement, mergeDaily, mergeUsage, messageChip, messageNews, messageToCheck, networkTaskFacts, newAccountDir, nextReset, openBridge, openBridged, orderedAliases, panelFixes, panelHint, panelLang, panelMigration, panelPrefs, passedWindow, pinnedIn, portalRefresh, quotaAskable, quotaHighLevel, quotaPressure, radioStep, reloadForBuild, remoteControlSummary, reorder, resetWhen, rowBadge, runCodeSwap, saveHandoffChange, sendBlock, sendFileProblem, sendResultView, sessionAge, sessionLabelParts, sessionRowShape, shortCwd, shortSessionLabel, sortAccounts, sortMenu, sortSessions, startedFromView, steadyOrder, stripSecrets, suggestAlias, suggestName, switchFailure, tailInView, taskFindings, uaDayRuns, uaGroupPending, uaOnChoices, uaParseClock, uaPickTime, uaSameSlot, uaShouldRead, uaSlotNight, uaStatusParts, uaStepClock, uaToggleDay, uaWaitingCount, uaWhen, updatedAge, vendorAlias, widthFollower, widthTier, windowState, withPinned, } from './page-logic.js';
9
+ import { accountTitle, advisorPick, advisorSummary, aiTaskAccounts, aliasArgsOf, aliasIssue, aliasPrefix, askBridge, askBridged, askCopy, askPermissionNote, attentionReasons, attentionWhy, autostartNote, bindingWindow, cacheHitRate, canLeaveLocal, categoryOrder, codeSwapOutcome, dateFormatter, dotsKeepKeyboard, enableOutcome, expiredLogins, fileSize, fixPrompt, foldSkips, foldToolCalls, formatDuration, handoffChangeOf, handoffHintAccount, handoffTaskFacts, hiddenIn, highlightParts, histFilters, historyEmpty, historyRowSig, historyWhen, historyWhenNext, hotkeyFromKey, hotkeyPressKind, inDisplayOrder, loginClusters, loginKey, longWindow, maskEmail, matchesQuery, mdBlocks, mdInline, menuPlacement, mergeDaily, mergeUsage, messageChip, messageNews, messageToCheck, networkTaskFacts, newAccountDir, nextReset, openBridge, openBridged, orderedAliases, panelFixes, panelHint, panelLang, panelMigration, panelPrefs, passedWindow, pinnedIn, portalRefresh, quotaAskable, quotaHighLevel, quotaPressure, radioStep, reloadForBuild, remoteControlSummary, reorder, resetWhen, rowBadge, runCodeSwap, saveHandoffChange, sendBlock, sendFileProblem, sendResultView, sessionAge, sessionLabelParts, sessionRowShape, shortCwd, shortSessionLabel, sortAccounts, sortMenu, sortSessions, startedFromView, steadyOrder, stripSecrets, suggestAlias, suggestName, switchFailure, tailInView, taskFindings, toastMerge, uaDayRuns, uaGroupByProject, uaGroupPending, uaOnChoices, uaParseClock, uaPickTime, uaSameSlot, uaShouldRead, uaSlotNight, uaStatusParts, uaStepClock, uaToggleDay, uaWaitingCount, uaWhen, updatedAge, vendorAlias, widthFollower, widthTier, windowState, withPinned, } from './page-logic.js';
10
10
  // The component library's dropdown menu, copied by the brand repo's add script (--html into ui/); do not edit it.
11
11
  import { CHECK, menuItem, menuScript } from './ui/dropdown-menu/dropdown-menu.html.js';
12
12
  import { cn, esc } from './ui/lib/cn.js';
@@ -53,7 +53,9 @@ const LOGIC = [
53
53
  foldToolCalls,
54
54
  highlightParts,
55
55
  historyEmpty,
56
+ historyRowSig,
56
57
  historyWhen,
58
+ historyWhenNext,
57
59
  handoffChangeOf,
58
60
  handoffHintAccount,
59
61
  handoffTaskFacts,
@@ -77,6 +79,7 @@ const LOGIC = [
77
79
  nextReset,
78
80
  canLeaveLocal,
79
81
  codeSwapOutcome,
82
+ dateFormatter,
80
83
  runCodeSwap,
81
84
  switchFailure,
82
85
  panelFixes,
@@ -115,6 +118,7 @@ const LOGIC = [
115
118
  suggestAlias,
116
119
  suggestName,
117
120
  tailInView,
121
+ toastMerge,
118
122
  updatedAge,
119
123
  pinnedIn,
120
124
  hiddenIn,
@@ -132,6 +136,7 @@ const LOGIC = [
132
136
  uaToggleDay,
133
137
  uaSameSlot,
134
138
  uaGroupPending,
139
+ uaGroupByProject,
135
140
  uaParseClock,
136
141
  uaStepClock,
137
142
  uaShouldRead,
@@ -262,6 +267,10 @@ const MAIN = String.raw `
262
267
  return out.filter((x) => x !== '')
263
268
  }
264
269
  const locale = () => (lang === 'zh' ? 'zh-CN' : 'en-US')
270
+ // A date in the page's language, as toLocaleDateString(locale(), options) would write it (page-logic.ts, dateFormatter),
271
+ // which also says "Invalid Date" where a formatter would throw.
272
+ const formatDate = dateFormatter()
273
+ function dateIn(d, options) { return Number.isFinite(d.getTime()) ? formatDate(d, locale(), options) : 'Invalid Date' }
265
274
 
266
275
  function h(tag, props, ...kids) {
267
276
  const el = document.createElement(tag)
@@ -459,13 +468,33 @@ const MAIN = String.raw `
459
468
  if (!o || used.has(o) || o.nodeType !== n.nodeType || o.nodeName !== n.nodeName) return n
460
469
  if (n.nodeType === 3) { if (o.data !== n.data) o.data = n.data; used.add(o); return o }
461
470
  if (n.nodeType !== 1) return n
462
- if (markup(o) === markup(n)) { used.add(o); return o }
463
- if (o.hasAttribute('data-patch') && n.hasAttribute('data-patch')) { syncAttrs(o, n); patchKids(o, Array.from(n.childNodes)); used.add(o); return o }
471
+ if (n._make) {
472
+ if (o._sig === n._sig) { used.add(o); return o }
473
+ n = made(n)
474
+ }
475
+ const both = o.hasAttribute('data-patch') && n.hasAttribute('data-patch')
476
+ // A container holding stand-ins never has the same markup: it goes child by child without being compared whole.
477
+ if (!(both && n.querySelector('[data-stand]')) && markup(o) === markup(n)) { used.add(o); return o }
478
+ if (both) { syncAttrs(o, n); patchKids(o, Array.from(n.childNodes)); used.add(o); return o }
464
479
  return n
465
480
  })
466
481
  for (const o of old) if (!used.has(o)) o.remove()
467
482
  result.forEach((n, i) => { if (box.childNodes[i] !== n) box.insertBefore(n, box.childNodes[i] || null) })
468
483
  }
484
+ // A stand-in for an element of a long list that make() builds (a div with this data-key): patch keeps the element
485
+ // drawn before when it was made with the same sig, so a row that did not change is neither built nor compared, and
486
+ // never leaves the page (focus, hover and a text selection in it stay); make() runs only for a new or changed one.
487
+ function standIn(key, sig, make) {
488
+ const el = h('div', { 'data-key': key, 'data-stand': '' })
489
+ el._sig = sig
490
+ el._make = make
491
+ return el
492
+ }
493
+ function made(stand) {
494
+ const el = stand._make()
495
+ el._sig = stand._sig
496
+ return el
497
+ }
469
498
  function pathOf(el, root) {
470
499
  const p = []
471
500
  while (el && el !== root) {
@@ -489,6 +518,8 @@ const MAIN = String.raw `
489
518
  const path = anchor !== box || (active && box.contains(active) && active !== box) ? pathOf(active, anchor) : null
490
519
  const chain = keys.map((el) => el.getAttribute('data-key'))
491
520
  patchKids(box, kids)
521
+ // Stand-ins that came in with a new container (a first draw, a new group) are built in place.
522
+ for (const x of box.querySelectorAll('[data-stand]')) x.replaceWith(made(x))
492
523
  if (path && !active.isConnected) {
493
524
  let el = box
494
525
  for (const k of chain) el = el && Array.from(el.querySelectorAll('[data-key]')).find((x) => x.getAttribute('data-key') === k)
@@ -686,10 +717,11 @@ const MAIN = String.raw `
686
717
  opts = opts || {}
687
718
  const kind = opts.kind || 'ok'
688
719
  const ms = opts.duration || Math.max(2000, Math.min(8000, 1800 + text.length * 40 + (opts.action ? 4000 : 0) + (kind === 'fail' ? 2000 : 0)))
689
- // A keyed toast (such as the theme) replaces the earlier one with that key.
690
- const keyed = opts.key ? toasts.find((x) => x.key === opts.key && x.text !== text) : null
691
- if (keyed) dismiss(keyed)
692
- let item = toasts.find((x) => x.text === text)
720
+ // A keyed toast (such as the theme) replaces the earlier one with that key; the same text merges into one toast,
721
+ // unless they carry different keys (two Undos stay two).
722
+ const where = toastMerge(toasts, text, opts.key)
723
+ if (where.replaces) dismiss(where.replaces)
724
+ let item = where.merges
693
725
  if (item) {
694
726
  clearTimeout(item.timer)
695
727
  item.el.classList.remove('bump')
@@ -752,15 +784,15 @@ const MAIN = String.raw `
752
784
  function clock(iso) {
753
785
  const d = new Date(iso)
754
786
  if (!Number.isFinite(d.getTime())) return '?'
755
- const time = d.toLocaleTimeString(locale(), { hour: '2-digit', minute: '2-digit' })
787
+ const time = dateIn(d, { hour: '2-digit', minute: '2-digit' })
756
788
  const now = new Date()
757
789
  if (d.toDateString() === now.toDateString()) return time
758
- if (Math.abs(d - now) < 6 * 864e5) return d.toLocaleDateString(locale(), { weekday: 'short' }) + ' ' + time
759
- return d.toLocaleDateString(locale(), { month: 'short', day: 'numeric' }) + ' ' + time
790
+ if (Math.abs(d - now) < 6 * 864e5) return dateIn(d, { weekday: 'short' }) + ' ' + time
791
+ return dateIn(d, { month: 'short', day: 'numeric' }) + ' ' + time
760
792
  }
761
793
  function day(iso) {
762
794
  const d = new Date(iso)
763
- return Number.isFinite(d.getTime()) ? d.toLocaleDateString(locale(), { month: 'short', day: 'numeric' }) : '?'
795
+ return Number.isFinite(d.getTime()) ? dateIn(d, { month: 'short', day: 'numeric' }) : '?'
764
796
  }
765
797
  function countdown(iso, now) {
766
798
  const at = Date.parse(iso)
@@ -1346,7 +1378,7 @@ const MAIN = String.raw `
1346
1378
  daily.map((d, i) => {
1347
1379
  const v = Number(d.totalTokens) || 0
1348
1380
  const date = new Date(d.date + 'T12:00:00')
1349
- const day = Number.isFinite(date.getTime()) ? date.toLocaleDateString(locale(), { weekday: 'short', month: 'numeric', day: 'numeric' }) : d.date
1381
+ const day = Number.isFinite(date.getTime()) ? dateIn(date, { weekday: 'short', month: 'numeric', day: 'numeric' }) : d.date
1350
1382
  // Every day keeps its slot; an empty day shows only a short stub on the baseline, so it reads as a gap in time.
1351
1383
  return h('i', { class: (i === daily.length - 1 ? 'today' : '') + (v ? '' : ' zero') || null, title: day + colon() + tokens(v) },
1352
1384
  h('b', { css: { height: v && max ? Math.max(10, Math.round((v / max) * 100)) + '%' : null } }))
@@ -4246,14 +4278,14 @@ const MAIN = String.raw `
4246
4278
  function histFold(by) { return prefs.histFold[by] || (prefs.histFold[by] = {}) }
4247
4279
  function fullWhen(iso) {
4248
4280
  const d = new Date(iso)
4249
- return Number.isFinite(d.getTime()) ? d.toLocaleString(locale(), { dateStyle: 'medium', timeStyle: 'short' }) : ''
4281
+ return Number.isFinite(d.getTime()) ? dateIn(d, { dateStyle: 'medium', timeStyle: 'short' }) : ''
4250
4282
  }
4251
4283
  function whenText(iso) {
4252
4284
  const w = historyWhen(iso, Date.now())
4253
4285
  if (!w) return ''
4254
4286
  if (w.key !== 'time.on') return t(w.key, { n: w.n })
4255
4287
  const d = new Date(iso)
4256
- const date = d.toLocaleDateString(locale(), d.getFullYear() === new Date().getFullYear() ? { month: 'short', day: 'numeric' } : { dateStyle: 'medium' })
4288
+ const date = dateIn(d, d.getFullYear() === new Date().getFullYear() ? { month: 'short', day: 'numeric' } : { dateStyle: 'medium' })
4257
4289
  return t(w.key, { date })
4258
4290
  }
4259
4291
  // A snippet that only repeats the title (ellipses and spacing aside) adds nothing under it.
@@ -4777,7 +4809,7 @@ const MAIN = String.raw `
4777
4809
  })
4778
4810
  return h('section', { class: 'hist-group' + (open ? '' : ' is-folded'), 'data-key': 'hg-' + by + '-' + g.key, 'aria-label': title, 'data-patch': '' },
4779
4811
  h('div', { class: 'hist-ghead', 'data-key': 'hgh' }, btn),
4780
- open && list.length ? h('div', { class: 'group-list hist-rows', role: 'list', id: bodyId, 'data-key': 'hgr', 'data-patch': '' }, list.map((s) => historyRow(s, words, by === 'project' || Boolean(hs.project)))) : null)
4812
+ open && list.length ? h('div', { class: 'group-list hist-rows', role: 'list', id: bodyId, 'data-key': 'hgr', 'data-patch': '' }, list.map((s) => listedHistoryRow(s, words, by === 'project' || Boolean(hs.project)))) : null)
4781
4813
  })
4782
4814
  }
4783
4815
  // Folding eases the group's rows away and drops them from the list at once; the list is then asked again quietly,
@@ -4900,6 +4932,12 @@ const MAIN = String.raw `
4900
4932
  })
4901
4933
  return withMenu(row, (a) => historyMenu(a, s, more))
4902
4934
  }
4935
+ // A row of the list itself (patchIf): a stand-in that keeps the row already drawn from the same session, words and
4936
+ // language, so folding a group or loading more builds only the rows that are new. The buttons of a kept row act on
4937
+ // the session it was drawn from, which the same sig means has not changed.
4938
+ function listedHistoryRow(s, words, noProject) {
4939
+ return standIn('hr-' + s.account + '-' + s.sessionId, historyRowSig(s, words, noProject, lang), () => historyRow(s, words, noProject))
4940
+ }
4903
4941
  // Each item carries its own leading dot; the dots of items that start a line fall outside the box and are clipped.
4904
4942
  function metaItems(parts) {
4905
4943
  return parts.filter((p) => p !== null && p !== undefined && p !== false && p !== '').map((p) => h('span', { class: 'hist-mi' }, p))
@@ -4945,7 +4983,7 @@ const MAIN = String.raw `
4945
4983
  empty.widen ? h('button', { class: 'btn btn-sm', type: 'button', onclick: () => { hs.since = 'all'; e.since.value = 'all'; historyChanged(true) } }, t('hist.widen')) : null,
4946
4984
  empty.tools ? h('button', { class: 'btn btn-sm', type: 'button', onclick: () => { hs.tools = true; e.tools.checked = true; startToolScan() } }, t('hist.tools')) : null) : null)
4947
4985
  if (d.groups && d.groups.length) return historyGroups(d, words)
4948
- return h('div', { class: 'group-list hist-rows', role: 'list', 'data-key': 'hrows', 'data-patch': '' }, d.sessions.map((s) => historyRow(s, words, Boolean(hs.project))))
4986
+ return h('div', { class: 'group-list hist-rows', role: 'list', 'data-key': 'hrows', 'data-patch': '' }, d.sessions.map((s) => listedHistoryRow(s, words, Boolean(hs.project))))
4949
4987
  })
4950
4988
  if (hs.swap && !hs.loading) {
4951
4989
  hs.swap = false
@@ -5007,9 +5045,15 @@ const MAIN = String.raw `
5007
5045
  function historyTick() {
5008
5046
  const e = hs.els
5009
5047
  if (!e || !e.root.isConnected) return
5048
+ // Each age is worked out again only once its words change (historyWhenNext), or when the clock was set back.
5049
+ const now = Date.now()
5010
5050
  for (const el of e.root.querySelectorAll('[data-hage]')) {
5011
- const text = whenText(el.getAttribute('data-hage'))
5051
+ const due = el._hage
5052
+ if (due && now < due.at && now >= due.from) continue
5053
+ const iso = el.getAttribute('data-hage')
5054
+ const text = whenText(iso)
5012
5055
  if (el.textContent !== text) el.textContent = text
5056
+ el._hage = { at: historyWhenNext(iso, now), from: now }
5013
5057
  }
5014
5058
  if (hs.pending) renderHistoryParts()
5015
5059
  const d = hs.data
@@ -6274,7 +6318,7 @@ const MAIN = String.raw `
6274
6318
  const UA_MS = 15000
6275
6319
  const UA_DAYS = ['mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun']
6276
6320
  const UA_PRESET = { name: 'Weeknights', days: ['mon', 'tue', 'wed', 'thu', 'fri'], start: '23:00', end: '08:00' }
6277
- const ua = { data: null, error: null, loading: null, at: 0, nextAt: 0, inflight: new Map(), opening: false, choosing: false, choice: null, time: '08:00', timeInit: '08:00', busy: false, local: null, saves: 0, rows: [], seq: 0, gone: {}, open: {}, firstUse: false, focus: null, wait: undefined, waitSaves: 0 }
6321
+ const ua = { data: null, error: null, loading: null, at: 0, nextAt: 0, inflight: new Map(), opening: false, choosing: false, choice: null, time: '08:00', timeInit: '08:00', busy: false, local: null, saves: 0, rows: [], seq: 0, gone: {}, open: {}, batch: 0, showReplied: {}, showDone: false, firstUse: false, focus: null, wait: undefined, waitSaves: 0 }
6278
6322
  let uaSaving = Promise.resolve()
6279
6323
  function uaStatusNow() { return (S.state && S.state.unattended) || null }
6280
6324
  // The latest status's count, less the ones being marked done right now (the page shows them gone already).
@@ -6322,7 +6366,7 @@ const MAIN = String.raw `
6322
6366
  const w = uaWhen(ms, now)
6323
6367
  if (w.day === 'today') return ''
6324
6368
  if (w.day === 'tomorrow') return t('ua.tomorrow')
6325
- return new Date(ms).toLocaleDateString(locale(), w.day === 'week' ? { weekday: 'short' } : { month: 'short', day: 'numeric' })
6369
+ return dateIn(new Date(ms), w.day === 'week' ? { weekday: 'short' } : { month: 'short', day: 'numeric' })
6326
6370
  }
6327
6371
  // kind: until ("until 08:00"), back ("back on at 08:00") or next ("next: Mon 23:00"; today is said too).
6328
6372
  function uaAt(kind, ms) {
@@ -6342,7 +6386,7 @@ const MAIN = String.raw `
6342
6386
  }
6343
6387
  function uaDayNames(style) {
6344
6388
  // 2024-01-01 was a Monday.
6345
- return UA_DAYS.map((d, i) => new Date(2024, 0, 1 + i).toLocaleDateString(locale(), { weekday: style }))
6389
+ return UA_DAYS.map((d, i) => dateIn(new Date(2024, 0, 1 + i), { weekday: style }))
6346
6390
  }
6347
6391
  // The status sentence, its parts joined by dots: "On · Slot “Weeknights” · until 08:00".
6348
6392
  function uaSentence(st) {
@@ -6656,14 +6700,14 @@ const MAIN = String.raw `
6656
6700
  const ms = Date.parse(iso)
6657
6701
  const now = Date.now()
6658
6702
  const w = uaWhen(ms, now)
6659
- return w.day === 'today' ? w.hhmm : new Date(ms).toLocaleDateString(locale(), { month: 'short', day: 'numeric' }) + ' ' + w.hhmm
6703
+ return w.day === 'today' ? w.hhmm : dateIn(new Date(ms), { month: 'short', day: 'numeric' }) + ' ' + w.hhmm
6660
6704
  }
6661
6705
  async function uaDone(ids, all) {
6662
6706
  const before = uaStatusNow()
6663
6707
  for (const id of ids) { ua.gone[id] = true; ua.inflight.set(id, before) }
6664
6708
  uaRedraw()
6665
6709
  try {
6666
- const r = await api('/api/unattended/pending', all ? { all: true } : { id: ids[0] })
6710
+ const r = await api('/api/unattended/pending', all ? { all: true } : ids.length > 1 ? { ids } : { id: ids[0] })
6667
6711
  const done = r.ids
6668
6712
  // A status read meanwhile already counts without them; only the one from before is lowered.
6669
6713
  if (before && uaStatusNow() === before) {
@@ -6671,21 +6715,28 @@ const MAIN = String.raw `
6671
6715
  if (Array.isArray(before.pendingIds)) before.pendingIds = before.pendingIds.filter((id) => !done.includes(id))
6672
6716
  }
6673
6717
  for (const id of ids) ua.inflight.delete(id)
6674
- toast(done.length > 1 ? tn('ua.doneMany', done.length) : t('ua.doneOne'), { key: 'ua-done', duration: 10000, action: BOOT.readOnly ? undefined : { label: t('toast.undo'), run: () => uaReopen(done) } })
6718
+ // Each mark has its own toast and Undo: a second mark does not take the first one's away.
6719
+ // Done elsewhere meanwhile (another tab, the CLI): nothing was marked here, so there is nothing to undo.
6720
+ if (!done.length) toast(t('ua.doneAlready'))
6721
+ else toast(done.length > 1 ? tn('ua.doneMany', done.length) : t('ua.doneOne'), { key: 'ua-done-' + (++ua.batch), duration: 10000, action: BOOT.readOnly ? undefined : { label: t('toast.undo'), run: () => uaReopen(done) } })
6675
6722
  } catch (e) {
6676
6723
  for (const id of ids) { delete ua.gone[id]; ua.inflight.delete(id) }
6677
6724
  toast(e.message, { kind: 'fail' })
6678
6725
  }
6679
6726
  uaRedraw()
6680
6727
  }
6681
- async function uaReopen(ids) {
6728
+ // Undo after "Done", and "Reopen" in the done list (said: what the toast says then).
6729
+ async function uaReopen(ids, said) {
6682
6730
  try {
6683
- for (const id of ids) await api('/api/unattended/pending', { id, done: false })
6731
+ await api('/api/unattended/pending', { ids, done: false })
6684
6732
  for (const id of ids) delete ua.gone[id]
6685
- toast(t('ua.undone'), { key: 'ua-done' })
6733
+ toast(said || t('ua.undone'))
6686
6734
  } catch (e) { toast(e.message, { kind: 'fail' }) }
6687
6735
  await load({ silent: true })
6688
6736
  await loadUa()
6737
+ // The done list hid them while they were reopened; it shows what the answer says now.
6738
+ for (const id of ids) delete ua.gone['re:' + id]
6739
+ uaRedraw()
6689
6740
  }
6690
6741
  // "Back to the session": a running one is on the Sessions page; an ended one resumes with the copied command.
6691
6742
  function uaBack(d) {
@@ -6718,9 +6769,27 @@ const MAIN = String.raw `
6718
6769
  // Until the folder is fixed nothing is read; "nothing waits" would not be true.
6719
6770
  if (st.problem) return [head, h('p', { class: 'note', 'data-key': 'ua-blocked' }, t('ua.pendingBlocked'))]
6720
6771
  const list = ua.data.pending.filter((d) => !ua.gone[d.id])
6721
- if (!list.length) return [head, h('p', { class: 'note ua-empty', 'data-key': 'ua-none', 'data-ua': 'none' }, icon('check'), t('ua.pendingEmpty'))]
6722
- const groups = uaGroupPending(list)
6723
- const box = h('div', { class: 'ua-groups', 'data-key': 'ua-groups', 'data-ua': 'groups', 'data-patch': '' }, groups.map((g) => {
6772
+ // Marked done in the last 30 days, folded at the end: one marked by mistake is reopened there.
6773
+ const doneList = (ua.data.done || []).filter((d) => !ua.gone['re:' + d.id])
6774
+ const doneFold = doneList.length
6775
+ ? h('div', { class: 'ua-fold ua-done-fold', 'data-key': 'ua-df', 'data-ua': 'df', 'data-find': 'ua-done', 'data-patch': '' },
6776
+ h('button', { class: 'group-toggle ua-fold-btn', type: 'button', 'data-key': 'ua-df-btn', 'aria-expanded': String(ua.showDone), 'aria-controls': 'ua-df-body', onclick: () => { ua.showDone = !ua.showDone; renderUaPage() } },
6777
+ icon('chevron', 'chev'), h('span', null, tn('ua.doneShow', doneList.length))),
6778
+ ua.showDone
6779
+ ? h('div', { class: 'ua-fold-body', id: 'ua-df-body', 'data-key': 'ua-df-body', 'data-patch': '' },
6780
+ h('p', { class: 'muted small ua-fold-note' }, t('ua.doneListNote')),
6781
+ h('ul', { class: 'ua-items ua-done-list', 'data-patch': '' }, doneList.map((x) => h('li', { class: 'ua-item', 'data-key': 'ua-d-' + x.id, 'data-ua': 'd-' + x.id, 'data-patch': '' },
6782
+ h('div', { class: 'ua-item-meta' },
6783
+ h('span', { class: 'chip chip-sm' }, x.project ? x.projectName : t('ua.projOther')),
6784
+ h('span', { class: 'muted small' }, t('ua.doneWhen', { when: uaWhenShort(x.doneAt) }))),
6785
+ h('p', { class: 'ua-text is-clamped' }, x.text),
6786
+ h('div', { class: 'ua-item-actions' },
6787
+ h('button', { class: 'btn btn-sm', type: 'button', 'data-key': 'ua-reopen-' + x.id, disabled: BOOT.readOnly, onclick: () => { ua.gone['re:' + x.id] = true; uaRedraw(); uaReopen([x.id], t('ua.reopenedOne')) } }, icon('refresh'), t('ua.reopen')))))))
6788
+ : null)
6789
+ : null
6790
+ if (!list.length) return [head, h('p', { class: 'note ua-empty', 'data-key': 'ua-none', 'data-ua': 'none' }, icon('check'), t('ua.pendingEmpty')), doneFold]
6791
+ // By Project (ADR-0078), then by the session that left them; what nobody touched first at every level.
6792
+ const session = (g) => {
6724
6793
  const d = g.first
6725
6794
  // Kept outside a session (a defer typed in a terminal): no account or tool to name.
6726
6795
  const known = d.account || (d.family && d.family !== 'unknown')
@@ -6737,22 +6806,53 @@ const MAIN = String.raw `
6737
6806
  h('ul', { class: 'ua-items', 'data-patch': '' }, g.items.map((x) => {
6738
6807
  const long = x.text.length > 280 || x.text.split('\n').length > 5
6739
6808
  const open = Boolean(ua.open[x.id])
6740
- return h('li', { class: 'ua-item', 'data-key': 'ua-i-' + x.id, 'data-ua': 'i-' + x.id, 'data-patch': '' },
6809
+ const replied = x.state === 'replied' && x.repliedAt
6810
+ return h('li', { class: 'ua-item' + (replied ? ' is-replied' : ''), 'data-key': 'ua-i-' + x.id, 'data-ua': 'i-' + x.id, 'data-patch': '' },
6741
6811
  h('div', { class: 'ua-item-meta' },
6742
6812
  h('span', { class: 'chip chip-sm' + (x.kind === 'question' ? ' chip-accent' : x.kind === 'permission' ? ' chip-warn' : '') }, t('ua.kind.' + x.kind)),
6743
6813
  h('time', { class: 'muted small', datetime: x.at }, uaWhenShort(x.at)),
6744
6814
  x.waited ? h('span', { class: 'muted small' }, t('ua.waited', { n: x.waited })) : null,
6745
- x.agentType ? h('span', { class: 'muted small' }, t('ua.agent', { type: x.agentType })) : null),
6815
+ x.agentType ? h('span', { class: 'muted small' }, t('ua.agent', { type: x.agentType })) : null,
6816
+ replied ? h('span', { class: 'chip chip-sm ua-replied', 'data-tip': t('ua.repliedTip', { when: uaWhenShort(x.repliedAt) }) }, t('ua.replied', { ago: ago(x.repliedAt) })) : null,
6817
+ x.replyCheck === 'no-record' ? h('span', { class: 'muted small' }, t('ua.noRecord')) : null),
6746
6818
  h('p', { class: 'ua-text' + (long && !open ? ' is-clamped' : '') }, x.text),
6747
6819
  h('div', { class: 'ua-item-actions' },
6748
6820
  long ? h('button', { class: 'link-btn small', type: 'button', 'data-key': 'ua-more-' + x.id, 'aria-expanded': String(open), onclick: () => { ua.open[x.id] = !open; renderUaPage() } }, t(open ? 'ua.less' : 'ua.more')) : null,
6749
6821
  h('button', { class: 'btn btn-sm', type: 'button', 'data-key': 'ua-done-' + x.id, disabled: off, onclick: () => uaDone([x.id]) }, icon('check'), t('ua.done'))))
6750
6822
  })))
6823
+ }
6824
+ // In each Project the untouched ones show; the ones written in afterwards fold under them (writing there does not
6825
+ // mean it was finished), each with its own Done, and a counted mark for all of them with a caution.
6826
+ const box = h('div', { class: 'ua-groups', 'data-key': 'ua-groups', 'data-ua': 'groups', 'data-patch': '' }, uaGroupByProject(list).map((p, i) => {
6827
+ const counts = [p.open ? tn('ua.projOpen', p.open) : null, p.replied ? tn('ua.projReplied', p.replied) : null].filter(Boolean).join(' · ')
6828
+ const openBlocks = p.sessions.filter((g) => g.first.state !== 'replied')
6829
+ const repliedBlocks = p.sessions.filter((g) => g.first.state === 'replied')
6830
+ const repliedIds = repliedBlocks.flatMap((g) => g.items).map((x) => x.id)
6831
+ const shown = Boolean(ua.showReplied[p.key])
6832
+ const name = p.project ? p.name : t('ua.projOther')
6833
+ return h('section', { class: 'ua-proj', 'data-key': 'ua-p-' + p.key, 'data-ua': 'p-' + p.key, 'data-patch': '', 'aria-label': name },
6834
+ h('div', { class: 'ua-proj-head', 'data-patch': '' },
6835
+ h('div', { class: 'ua-proj-who' },
6836
+ h('h4', { class: 'ua-proj-name', 'data-tip': p.project || null }, icon('folder'), h('span', null, name)),
6837
+ h('span', { class: 'muted small' }, counts))),
6838
+ openBlocks.length ? h('div', { class: 'ua-proj-sessions', 'data-key': 'ua-po-' + p.key, 'data-patch': '' }, openBlocks.map(session)) : null,
6839
+ repliedIds.length
6840
+ ? h('div', { class: 'ua-fold', 'data-key': 'ua-rf-' + p.key, 'data-ua': 'rf-' + p.key, 'data-patch': '' },
6841
+ h('button', { class: 'group-toggle ua-fold-btn', type: 'button', 'data-key': 'ua-rf-btn-' + p.key, 'aria-expanded': String(shown), 'aria-controls': 'ua-rf-' + i, onclick: () => { ua.showReplied[p.key] = !shown; renderUaPage() } },
6842
+ icon('chevron', 'chev'), h('span', null, tn('ua.repliedShow', repliedIds.length))),
6843
+ shown
6844
+ ? h('div', { class: 'ua-fold-body', id: 'ua-rf-' + i, 'data-key': 'ua-rb-' + p.key, 'data-patch': '' },
6845
+ h('div', { class: 'ua-fold-note', 'data-patch': '' },
6846
+ h('p', { class: 'muted small' }, t('ua.repliedCaution')),
6847
+ h('button', { class: 'btn btn-sm', type: 'button', 'data-key': 'ua-rdone-' + p.key, disabled: off, onclick: () => uaDone(repliedIds) }, icon('check'), tn('ua.repliedBatch', repliedIds.length))),
6848
+ h('div', { class: 'ua-proj-sessions', 'data-patch': '' }, repliedBlocks.map(session)))
6849
+ : null)
6850
+ : null)
6751
6851
  }))
6752
- const all = list.length > 1 ? h('button', { class: 'link-btn small', type: 'button', 'data-key': 'ua-all', disabled: off, onclick: () => uaDone(list.map((x) => x.id), true) }, t('ua.allDone')) : null
6753
- return [h('div', { class: 'page-sec-head ua-pending-head' },
6852
+ const all = list.length > 1 ? h('button', { class: 'link-btn small', type: 'button', 'data-key': 'ua-all', disabled: off, onclick: () => uaDone(list.map((x) => x.id), true) }, tn('ua.allDoneN', list.length)) : null
6853
+ return [h('div', { class: 'page-sec-head ua-pending-head', 'data-find': 'ua-pending' },
6754
6854
  h('div', { class: 'ua-sec-row' }, h('h3', { class: 'page-sec' }, t('ua.pending'), ' ', h('span', { class: 'tab-count' }, String(list.length))), all),
6755
- h('p', { class: 'muted small' }, t('ua.pendingNote'))), box]
6855
+ h('p', { class: 'muted small' }, t('ua.pendingNote'))), box, doneFold]
6756
6856
  }
6757
6857
 
6758
6858
  // ---------- Answer Wait (ADR-0077) ----------
@@ -6858,6 +6958,7 @@ const MAIN = String.raw `
6858
6958
  }
6859
6959
  // The Search Catalog's actions: to the page, then the chooser open, or the "Add a Slot" button shown.
6860
6960
  function uaGo(what) {
6961
+ if (what === 'done' && !ua.showDone) { ua.showDone = true; renderUaPage() }
6861
6962
  setPage('unattended')
6862
6963
  let tries = 0
6863
6964
  const look = () => {
@@ -6865,7 +6966,8 @@ const MAIN = String.raw `
6865
6966
  if (box.hidden || (!ua.data && !ua.error)) { if (++tries < 40) setTimeout(look, 100); return }
6866
6967
  const st = uaStatusNow()
6867
6968
  if (what === 'on' && st && uaStatusParts(st).state !== 'on' && !BOOT.readOnly && !st.problem) { if (!ua.choosing) uaOpenChooser(); return }
6868
- const el = box.querySelector(what === 'on' ? '[data-key="ua-main"]' : what === 'wait' ? '[data-find="ua-wait"]' : '[data-find="ua-add"]')
6969
+ const el = box.querySelector(what === 'on' ? '[data-key="ua-main"]' : what === 'wait' ? '[data-find="ua-wait"]' : what === 'pending' ? '.ua-pending-head' : what === 'done' ? '[data-find="ua-done"]' : '[data-find="ua-add"]') ||
6970
+ (what === 'done' ? box.querySelector('.ua-pending-head') : null)
6869
6971
  if (!el) return
6870
6972
  el.scrollIntoView({ behavior: REDUCED ? 'auto' : 'smooth', block: 'center' })
6871
6973
  palFlash(el)
@@ -7346,6 +7448,8 @@ const MAIN = String.raw `
7346
7448
  'unattended-on': { run: () => uaGo('on'), ok: () => Boolean(uaStatusNow()), nav: true },
7347
7449
  'unattended-add-slot': { run: () => uaGo('add'), ok: () => Boolean(uaStatusNow()), nav: true },
7348
7450
  'unattended-wait': { run: () => uaGo('wait'), ok: () => Boolean(uaStatusNow()), nav: true },
7451
+ 'unattended-pending': { run: () => uaGo('pending'), ok: () => Boolean(uaStatusNow()), nav: true },
7452
+ 'unattended-pending-done': { run: () => uaGo('done'), ok: () => Boolean(uaStatusNow()), nav: true },
7349
7453
  'limit-reset': { run: openResetPick, ok: () => resetCandidates().length > 0 },
7350
7454
  }
7351
7455
  function palHealth() {
@@ -7969,7 +8073,7 @@ const MAIN = String.raw `
7969
8073
  return Boolean(u && u.skillUpdate && u.skillUpdate.installed && u.skillUpdate.installed.length)
7970
8074
  }
7971
8075
  // Example phrases: a click puts one in the Let AI do it box (spec §3.28).
7972
- const AI_ASKS = ['ai.ask.quota', 'ai.ask.reset', 'ai.ask.pick', 'ai.ask.new', 'ai.ask.api', 'ai.ask.pin', 'ai.ask.hide', 'ai.ask.relogin', 'ai.ask.expired', 'ai.ask.fix', 'ai.ask.handoff', 'ai.ask.handoffRules', 'ai.ask.session', 'ai.ask.history', 'ai.ask.send', 'ai.ask.inbound', 'ai.ask.menubar', 'ai.ask.rc', 'ai.ask.advisor', 'ai.ask.trust', 'ai.ask.network', 'ai.ask.unattended', 'ai.ask.progress', 'ai.ask.theme', 'ai.ask.find', 'ai.ask.commands', 'ai.ask.tool']
8076
+ const AI_ASKS = ['ai.ask.quota', 'ai.ask.reset', 'ai.ask.pick', 'ai.ask.new', 'ai.ask.api', 'ai.ask.pin', 'ai.ask.hide', 'ai.ask.relogin', 'ai.ask.expired', 'ai.ask.fix', 'ai.ask.handoff', 'ai.ask.handoffRules', 'ai.ask.session', 'ai.ask.history', 'ai.ask.send', 'ai.ask.inbound', 'ai.ask.menubar', 'ai.ask.rc', 'ai.ask.advisor', 'ai.ask.trust', 'ai.ask.network', 'ai.ask.unattended', 'ai.ask.pending', 'ai.ask.progress', 'ai.ask.theme', 'ai.ask.find', 'ai.ask.commands', 'ai.ask.tool']
7973
8077
  // Network Guard (spec §3.35): one dialog with the switch, the allowed countries and the newest result per address.
7974
8078
  // Countries are never ticked for the user, the current one included: a wrong network would allow itself.
7975
8079
  const NET_COMMON = ['US', 'JP', 'SG', 'GB', 'DE', 'FR', 'NL', 'CA', 'AU', 'KR', 'TW', 'HK']
@@ -1451,6 +1451,23 @@ input.ua-time::placeholder { color: var(--faint); }
1451
1451
  .ua-sec-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
1452
1452
  .ua-sec-row .tab-count { margin-left: 4px; vertical-align: 1px; }
1453
1453
  .ua-groups { display: flex; flex-direction: column; }
1454
+ .ua-proj { margin-bottom: 20px; }
1455
+ .ua-proj-head { display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap; margin-bottom: 8px; }
1456
+ .ua-proj-who { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 12px; min-width: 0; }
1457
+ .ua-proj-name { display: inline-flex; align-items: center; gap: 8px; margin: 0; font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
1458
+ .ua-proj-name .ic { width: 15px; height: 15px; flex: none; color: var(--muted); }
1459
+ .ua-proj-sessions > .ua-group:last-child { margin-bottom: 0; }
1460
+ /* What was written in afterwards, and the done list: folded under a toggle (ADR-0078). */
1461
+ .ua-fold { margin-top: 8px; }
1462
+ .ua-fold-btn { margin-left: -4px; font-size: 13px; color: var(--muted); }
1463
+ .ua-fold-btn:hover { color: var(--text); }
1464
+ .ua-fold-btn .chev { width: 12px; height: 12px; }
1465
+ .ua-fold-body { margin-top: 8px; }
1466
+ .ua-fold-note { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 12px; margin: 0 0 8px; }
1467
+ .ua-fold-note p { margin: 0; }
1468
+ .ua-done-fold { margin-top: 0; }
1469
+ .ua-done-list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-xl); box-shadow: var(--shadow); }
1470
+ .ua-item-meta { flex-wrap: wrap; }
1454
1471
  .ua-group { margin-bottom: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-xl); box-shadow: var(--shadow); }
1455
1472
  .ua-group-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 12px 12px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border); border-radius: var(--radius-xl) var(--radius-xl) 0 0; }
1456
1473
  .ua-group-who { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 12px; min-width: 0; }
@@ -27,7 +27,10 @@ export declare function questionText(input: Record<string, unknown>): string;
27
27
  * answering (Answer Wait); the session shows the text too, so it opens with what happened for the person coming back.
28
28
  */
29
29
  export declare function questionReason(state: UnattendedState, now: Date, zh: boolean, kept: boolean, waited?: number): string;
30
- /** How much of the end of the model's last message is read to tell whether it ends on a question. */
30
+ /**
31
+ * How much of the end of the model's last message is read to tell whether it ends on a question. The `需要你拍板`
32
+ * marker is looked for in the whole message instead (`endingQuestion`).
33
+ */
31
34
  export declare const QUESTION_TAIL = 600;
32
35
  /**
33
36
  * Ways a model asks the user in plain text, in English and Chinese, checked against the end of its last message (the
@@ -37,10 +40,12 @@ export declare const QUESTION_TAIL = 600;
37
40
  export declare const QUESTION_PATTERNS: readonly RegExp[];
38
41
  /**
39
42
  * The part of the model's last message that asks the user something, or undefined when it does not end on a
40
- * question. Code blocks (``` and ~~~), inline code and quoted lines (`> …`) are left out first, then the last
41
- * {@link QUESTION_TAIL} characters are read: a line that starts with the `需要你拍板` marker (from it to the end); a last line that ends with `?`
42
- * or `?`, or a list of options at the end right after such a line; or one of {@link QUESTION_PATTERNS} in the last
43
- * paragraph (and the one before it when the last is a list), unless a negation comes just before it ("无需你来决定").
43
+ * question. Code blocks (``` and ~~~), inline code and quoted lines (`> …`) are left out first. A line anywhere in
44
+ * the rest that starts with the `需要你拍板` / `Needs your decision` marker asks (from the first such line to the end):
45
+ * a report often goes on for a long while after it. Otherwise only the last {@link QUESTION_TAIL} characters are
46
+ * read: a last line that ends with `?` or `?`, or a list of options at the end right after such a line; or one of
47
+ * {@link QUESTION_PATTERNS} in the last paragraph (and the one before it when the last is a list), unless a negation
48
+ * comes just before it ("无需你来决定").
44
49
  */
45
50
  export declare function endingQuestion(message: string): string | undefined;
46
51
  /**
@@ -125,7 +125,7 @@ export function questionReason(state, now, zh, kept, waited) {
125
125
  const head = waited
126
126
  ? `${waited} 分钟没人回答:sideby 无人值守已开启${when},会话不再等回答,${keep}。`
127
127
  : `未显示:sideby 无人值守已开启${when},现在没人能回答,${keep}。`;
128
- return `${head}不要再问。能撤回的选择按推荐的选项继续,在最终汇报里写出这个问题和你的选择。删除、对外发送或发布、部署、付费等难撤回的操作不要做:跳过它,运行 \`sideby unattended defer "<一句话>"\` 记下,再继续做其余的事。`;
128
+ return `${head}不要再问。能撤回的选择按推荐的选项继续,在最终汇报里写出这个问题和你的选择。删除、对外发送或发布、部署、付费等难撤回的操作不要做:跳过它,运行 \`sideby unattended defer "<一句话>"\` 记下,再继续做其余的事。用户自己的规则或项目文档已对这类操作常设授权的,照那份授权做。`;
129
129
  }
130
130
  const when = session ? 'for this session' : until ? `until ${until}` : 'with no end set';
131
131
  const keep = kept
@@ -134,10 +134,13 @@ export function questionReason(state, now, zh, kept, waited) {
134
134
  const head = waited
135
135
  ? `No answer after ${minutesText(waited)}: sideby's Unattended Mode is on ${when}, so the session goes on without one, and ${keep}.`
136
136
  : `Not shown: sideby's Unattended Mode is on ${when}, so nobody is here to answer, and ${keep}.`;
137
- return `${head} Do not ask again. Where the choice can be undone, go on with the recommended option, and list the question and your choice in your final report. Do not do anything hard to undo (deleting, sending or posting anything outside, publishing, deploying, paying): skip it, record it with \`sideby unattended defer "<one sentence>"\`, and go on with the rest.`;
137
+ return `${head} Do not ask again. Where the choice can be undone, go on with the recommended option, and list the question and your choice in your final report. Do not do anything hard to undo (deleting, sending or posting anything outside, publishing, deploying, paying): skip it, record it with \`sideby unattended defer "<one sentence>"\`, and go on with the rest. Where the user's own rules or project docs already give standing permission for that kind of action, follow that permission instead.`;
138
138
  }
139
139
  const minutesText = (n) => (n === 1 ? '1 minute' : `${n} minutes`);
140
- /** How much of the end of the model's last message is read to tell whether it ends on a question. */
140
+ /**
141
+ * How much of the end of the model's last message is read to tell whether it ends on a question. The `需要你拍板`
142
+ * marker is looked for in the whole message instead (`endingQuestion`).
143
+ */
141
144
  export const QUESTION_TAIL = 600;
142
145
  /**
143
146
  * Ways a model asks the user in plain text, in English and Chinese, checked against the end of its last message (the
@@ -180,10 +183,12 @@ function asks(pattern, text) {
180
183
  }
181
184
  /**
182
185
  * The part of the model's last message that asks the user something, or undefined when it does not end on a
183
- * question. Code blocks (``` and ~~~), inline code and quoted lines (`> …`) are left out first, then the last
184
- * {@link QUESTION_TAIL} characters are read: a line that starts with the `需要你拍板` marker (from it to the end); a last line that ends with `?`
185
- * or `?`, or a list of options at the end right after such a line; or one of {@link QUESTION_PATTERNS} in the last
186
- * paragraph (and the one before it when the last is a list), unless a negation comes just before it ("无需你来决定").
186
+ * question. Code blocks (``` and ~~~), inline code and quoted lines (`> …`) are left out first. A line anywhere in
187
+ * the rest that starts with the `需要你拍板` / `Needs your decision` marker asks (from the first such line to the end):
188
+ * a report often goes on for a long while after it. Otherwise only the last {@link QUESTION_TAIL} characters are
189
+ * read: a last line that ends with `?` or `?`, or a list of options at the end right after such a line; or one of
190
+ * {@link QUESTION_PATTERNS} in the last paragraph (and the one before it when the last is a list), unless a negation
191
+ * comes just before it ("无需你来决定").
187
192
  */
188
193
  export function endingQuestion(message) {
189
194
  // Judged on a copy where code and quotes are blanked out at the same length, so a span of it is the same span of
@@ -195,14 +200,14 @@ export function endingQuestion(message) {
195
200
  .replace(/`[^`\n]*`/g, (m) => 'x'.repeat(m.length))
196
201
  .replace(/^[ \t]*>.*$/gm, blank);
197
202
  const stop = plain.trimEnd().length;
203
+ const heading = DECIDE_HEADING.exec(plain.slice(0, stop));
204
+ if (heading)
205
+ return written.slice(heading.index, stop).trim();
198
206
  const from = Math.max(0, stop - QUESTION_TAIL);
199
207
  const tail = plain.slice(from, stop);
200
208
  if (!tail.trim())
201
209
  return undefined;
202
210
  const kept = (at) => written.slice(from + at, stop).trim();
203
- const heading = DECIDE_HEADING.exec(tail);
204
- if (heading)
205
- return kept(heading.index);
206
211
  // Each paragraph with where it starts in the tail.
207
212
  const paragraphs = [];
208
213
  let at = 0;
@@ -245,7 +250,7 @@ export function stopReason(state, now, zh, kept, waited) {
245
250
  const head = waited
246
251
  ? `${waited} 分钟没人回复你的问题:sideby 无人值守已开启${when},${keep}。这条不是用户的回复。`
247
252
  : `没人能回答:sideby 无人值守已开启${when},${keep}。`;
248
- return `${head}不要等回复,也不要再问。能撤回的选择按推荐的选项继续,一直做到完。删除、对外发送或发布、部署、付费等难撤回的操作不要做:跳过它,运行 \`sideby unattended defer "<一句话>"\` 记下,再做完其余的事。最后写一份最终汇报,列出你做的每个选择和记下的每件事,不提任何问题。`;
253
+ return `${head}不要等回复,也不要再问。能撤回的选择按推荐的选项继续,一直做到完。删除、对外发送或发布、部署、付费等难撤回的操作不要做:跳过它,运行 \`sideby unattended defer "<一句话>"\` 记下,再做完其余的事。用户自己的规则或项目文档已对这类操作常设授权的,照那份授权做。最后写一份最终汇报,列出你做的每个选择和记下的每件事,不提任何问题。`;
249
254
  }
250
255
  const when = session ? 'for this session' : until ? `until ${until}` : 'with no end set';
251
256
  const keep = kept
@@ -254,7 +259,7 @@ export function stopReason(state, now, zh, kept, waited) {
254
259
  const head = waited
255
260
  ? `Nobody replied to your question for ${minutesText(waited)}: sideby's Unattended Mode is on ${when}, and ${keep}. This note is not the user's reply.`
256
261
  : `Nobody is here to answer: sideby's Unattended Mode is on ${when}, and ${keep}.`;
257
- return `${head} Do not wait for an answer and do not ask again. Where the choice can be undone, go on with the recommended option and carry on to the end. Do not do anything hard to undo (deleting, sending or posting anything outside, publishing, deploying, paying): skip it, record it with \`sideby unattended defer "<one sentence>"\`, and finish the rest. Then end with a final report that lists each choice you made and each item you recorded, without asking anything.`;
262
+ return `${head} Do not wait for an answer and do not ask again. Where the choice can be undone, go on with the recommended option and carry on to the end. Do not do anything hard to undo (deleting, sending or posting anything outside, publishing, deploying, paying): skip it, record it with \`sideby unattended defer "<one sentence>"\`, and finish the rest. Where the user's own rules or project docs already give standing permission for that kind of action, follow that permission instead. Then end with a final report that lists each choice you made and each item you recorded, without asking anything.`;
258
263
  }
259
264
  /** What a declined MCP form is kept as: the server's name and what it asked, never a field's value. */
260
265
  export function elicitationText(v) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sideby",
3
- "version": "0.41.2",
3
+ "version": "0.41.3",
4
4
  "description": "Run work, personal and API-key accounts at the same time, without their configs drifting apart.",
5
5
  "license": "MIT",
6
6
  "author": "Adonis0123 (https://github.com/Adonis0123)",