dsh-notify-tray 0.1.11 → 0.1.13

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/lib/client.js CHANGED
@@ -1,13 +1,7 @@
1
1
  // dsh-notify-tray, browser half (hand-written in DSH's client module format,
2
2
  // so no build step is needed).
3
3
  //
4
- // Polls the host's `notify-tray/state` route (its light `lite=1` form), shows
5
- // a native Notification for each new notice (completed / failed / approval /
6
- // choice / input; one per session, closed again once a question is answered)
7
- // and opens the session when a notification — or a tray menu row — is
8
- // clicked. In the
9
- // desktop app these notifications are OS-native and attributed to
10
- // "DeepSeek Harness".
4
+ // The window reports its visible session and opens explicit native notification clicks.
11
5
  window.__ModuleLoader__.load({
12
6
  id: 'dsh-notify-tray',
13
7
  factory: (require) => {
@@ -16,9 +10,7 @@ window.__ModuleLoader__.load({
16
10
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' })
17
11
 
18
12
  var ROUTE = 'notify-tray/state'
19
- var RAISE_ROUTE = 'notify-tray/raise'
20
13
  var POLL_MS = 2000
21
- var SEEN_KEY = 'dsh-notify-tray:seen'
22
14
 
23
15
  function mainSessionId(sessions) {
24
16
  try {
@@ -31,23 +23,12 @@ window.__ModuleLoader__.load({
31
23
  return undefined
32
24
  }
33
25
 
34
- // Cross-tab dedupe: one notification per host event, whichever page sees it first.
35
- function claim(boot, seq) {
36
- try {
37
- var raw = localStorage.getItem(SEEN_KEY)
38
- var seen = raw ? JSON.parse(raw) : {}
39
- if (seen.boot === boot && seen.seq >= seq) return false
40
- localStorage.setItem(SEEN_KEY, JSON.stringify({ boot: boot, seq: seq }))
41
- } catch (e) {}
42
- return true
43
- }
44
-
45
- // Settings mount independently once the layout and host namespace are ready.
26
+ // Settings entries mount when their slots and the host namespace are ready.
46
27
  var inject = ['uiWorkspace', 'sessions', 'slots', 'locale', 'configForms']
47
28
 
48
29
  // ------------------------------------------------------------------------
49
- // Settings page: a sidebar entry opens a main panel containing a SettingsForm
50
- // over the `notify-tray` settings namespace (the `.volatile()` fields of
30
+ // Settings and the main sidebar share a form over the `notify-tray`
31
+ // settings namespace (the `.volatile()` fields of
51
32
  // lib/index.js Config, served by @deepseek-ai/dsh-settings), grouped into
52
33
  // sections with toggles, segmented choices and number fields, saved automatically.
53
34
  // Plain React.createElement, so no build step is needed.
@@ -216,16 +197,9 @@ window.__ModuleLoader__.load({
216
197
  planResetAtHint: '例如「今晚 20:00」「每周一」。',
217
198
 
218
199
  advanced: '高级设置',
219
- advancedHint: '通知通道、花费算法、自定义单价、刷新间隔等,一般不用改。',
200
+ advancedHint: '花费算法、自定义单价、刷新间隔等,一般不用改。',
220
201
  advancedChanged: '已改 {n} 项',
221
202
  groupNotify: '通知',
222
- channel: '通知从哪里弹',
223
- channelAuto: '自动',
224
- channelClient: '只用窗口',
225
- channelSystem: '只用系统',
226
- channelBoth: '都弹',
227
- channelOff: '不弹',
228
- channelHint: '自动:开着 DSH 窗口就由窗口弹,否则由系统弹。',
229
203
  suppressWhenFocused: '正看着这个会话时不弹',
230
204
  suppressWhenFocusedHint: '关掉后,哪怕你正看着它跑完也会弹一条。',
231
205
  groupTray: '状态栏',
@@ -393,16 +367,9 @@ window.__ModuleLoader__.load({
393
367
  planResetAtHint: 'e.g. "20:00 tonight", "Mondays".',
394
368
 
395
369
  advanced: 'Advanced',
396
- advancedHint: 'Notification channel, spend method, custom prices, refresh intervals — rarely needed.',
370
+ advancedHint: 'Spend method, custom prices, refresh intervals — rarely needed.',
397
371
  advancedChanged: '{n} changed',
398
372
  groupNotify: 'Notifications',
399
- channel: 'Notification channel',
400
- channelAuto: 'Auto',
401
- channelClient: 'Window only',
402
- channelSystem: 'System only',
403
- channelBoth: 'Both',
404
- channelOff: 'Off',
405
- channelHint: 'Auto: the DSH window notifies while it is open; the OS does otherwise.',
406
373
  suppressWhenFocused: 'Stay quiet while I am looking at that session',
407
374
  suppressWhenFocusedHint: 'Off: notify even when you watch it finish.',
408
375
  groupTray: 'Status bar',
@@ -485,7 +452,7 @@ window.__ModuleLoader__.load({
485
452
  /** The five "notify me when" switches, shown as one row of checkboxes. */
486
453
  const NOTIFY_FIELDS = ['notifyCompleted', 'notifyChoice', 'notifyInput', 'notifyApproval', 'notifyFailed']
487
454
  /** Fields behind the "Advanced" fold (counted for its "n changed" tag). */
488
- const ADVANCED_FIELDS = ['channel', 'suppressWhenFocused', 'showSpendInTitle', 'errorHoldMinutes', 'spendSource', 'currency', 'balancePollMinutes', 'priceSource', 'customInput', 'customCacheRead', 'customOutput', 'customPriceCurrency', 'exchangeRate', 'planAutoQuota', 'quotaPollMinutes', 'planQuotaUrl']
455
+ const ADVANCED_FIELDS = ['suppressWhenFocused', 'showSpendInTitle', 'errorHoldMinutes', 'spendSource', 'currency', 'balancePollMinutes', 'priceSource', 'customInput', 'customCacheRead', 'customOutput', 'customPriceCurrency', 'exchangeRate', 'planAutoQuota', 'quotaPollMinutes', 'planQuotaUrl']
489
456
  const TRAY_FIELDS = ['showSpendInTitle', 'errorHoldMinutes']
490
457
  /** Plan fields a preset fills in; switching provider clears them. */
491
458
  const PRESET_FIELDS = ['planId', 'planName', 'planPrice', 'planCurrency', 'planPeriod', 'planQuota']
@@ -521,6 +488,9 @@ window.__ModuleLoader__.load({
521
488
  projection() {
522
489
  const fields = {}
523
490
  for (const f of FIELDS) fields[f] = this.form.field(f)
491
+ if (fields.channel.text === 'off') {
492
+ for (const key of NOTIFY_FIELDS) fields[key] = { ...fields[key], text: 'off' }
493
+ }
524
494
  return { ...this.form.shell(), fields, notice: this.notice }
525
495
  }
526
496
 
@@ -533,6 +503,11 @@ window.__ModuleLoader__.load({
533
503
  change(field, text, reset = false) {
534
504
  if (this.disposed || !this.form.shell().writable) return
535
505
  this.notice = null
506
+ // Convert the legacy master mute to independent switches in the same save.
507
+ if (NOTIFY_FIELDS.includes(field) && this.form.field('channel').text === 'off') {
508
+ this.change('channel', 'system')
509
+ for (const key of NOTIFY_FIELDS) if (key !== field) this.change(key, 'off')
510
+ }
536
511
  if (this.inFlight) this.pending.set(field, { text, reset })
537
512
  if (reset) this.actions.resetField(field)
538
513
  else this.actions.edit(field, text)
@@ -666,6 +641,7 @@ window.__ModuleLoader__.load({
666
641
  if (this.disposed) return
667
642
  if (!this.openBundle()) return this.patch({ phase: 'manual' })
668
643
  this.patch({ phase: 'available' })
644
+ return true
669
645
  } catch (error) {
670
646
  this.patch({ phase: 'manual', error: String(error.message || error) })
671
647
  }
@@ -708,10 +684,15 @@ window.__ModuleLoader__.load({
708
684
  React.useEffect(() => {
709
685
  const fn = () => bump(n => n + 1)
710
686
  live.listeners.add(fn)
711
- loadCatalog()
712
- loadState()
713
- const timer = setInterval(loadState, LIVE_MS)
714
- return () => { live.listeners.delete(fn); clearInterval(timer) }
687
+ if (live.listeners.size === 1) {
688
+ loadCatalog()
689
+ loadState()
690
+ live.timer = setInterval(loadState, LIVE_MS)
691
+ }
692
+ return () => {
693
+ live.listeners.delete(fn)
694
+ if (!live.listeners.size) clearInterval(live.timer)
695
+ }
715
696
  }, [])
716
697
  return live
717
698
  }
@@ -769,14 +750,14 @@ window.__ModuleLoader__.load({
769
750
  h(ui.Switch, { checked: field.text === 'on', disabled, label: t(name), onChange: next => edit(name, next ? 'on' : 'off') })))
770
751
  }
771
752
 
772
- function ChoiceRow({ t, name, field, options, disabled, edit, resetField, hint }) {
753
+ function ChoiceRow({ t, name, idPrefix, field, options, disabled, edit, resetField, hint }) {
773
754
  return h('div', { style: { ...S.row, flexWrap: 'wrap' } },
774
755
  h('div', { style: S.rowText },
775
756
  h('div', { style: S.label }, t(name), h(Overridden, { t, field, disabled, onReset: () => resetField(name) })),
776
757
  hint ? h('p', { style: S.hint }, t(hint)) : null),
777
758
  h('div', { style: S.control },
778
759
  h(ui.SegmentedControl, {
779
- id: `notify-tray-${name}`,
760
+ id: `${idPrefix}-${name}`,
780
761
  label: t(name),
781
762
  value: field.text,
782
763
  disabled,
@@ -798,9 +779,9 @@ window.__ModuleLoader__.load({
798
779
  ui.Checkbox ? null : h('span', null, t(name))))))
799
780
  }
800
781
 
801
- function ValueField({ t, name, field, disabled, edit, resetField, numeric, placeholder, hint }) {
782
+ function ValueField({ t, name, idPrefix, field, disabled, edit, resetField, numeric, placeholder, hint }) {
802
783
  return h(ui.SettingsValueField, {
803
- id: `notify-tray-${name}`,
784
+ id: `${idPrefix}-${name}`,
804
785
  label: t(name),
805
786
  hint: hint === undefined ? t(`${name}Hint`) : hint,
806
787
  overriddenLabel: t('overridden'),
@@ -820,9 +801,9 @@ window.__ModuleLoader__.load({
820
801
  const TextField = props => h(ValueField, { ...props, numeric: false })
821
802
 
822
803
  /** A bare dropdown (its row carries the label). */
823
- function Select({ t, name, field, options, disabled, onChange }) {
804
+ function Select({ t, name, idPrefix, field, options, disabled, onChange }) {
824
805
  return h('select', {
825
- id: `notify-tray-${name}`,
806
+ id: `${idPrefix}-${name}`,
826
807
  style: S.select,
827
808
  value: field.text,
828
809
  disabled,
@@ -976,8 +957,8 @@ window.__ModuleLoader__.load({
976
957
  ? h('p', { style: S.hint }, links.map(([key, url], i) => h(React.Fragment || 'span', { key }, i ? ' · ' : '', h('a', { href: url, target: '_blank', rel: 'noreferrer', style: S.link }, `${t(`${key}Page`)} ↗`))))
977
958
  : h('p', { style: S.hint }, t('myPlanHint'))),
978
959
  h('div', { style: { ...S.control, display: 'flex', gap: 8, flexWrap: 'wrap' } },
979
- h(Select, { t, name: 'planProvider', field: f.planProvider, options: providerOptions, disabled, onChange: chooseProvider }),
980
- providerId !== 'none' && plans.length ? h(Select, { t, name: 'planId', field: f.planId, options: planOptions, disabled, onChange: choosePlan }) : null))]
960
+ h(Select, { ...common, name: 'planProvider', field: f.planProvider, options: providerOptions, onChange: chooseProvider }),
961
+ providerId !== 'none' && plans.length ? h(Select, { ...common, name: 'planId', field: f.planId, options: planOptions, onChange: choosePlan }) : null))]
981
962
  if (providerId === 'none') return children
982
963
 
983
964
  // ---- remaining quota: the key reference and a refresh, when the provider has an endpoint ----
@@ -1019,9 +1000,7 @@ window.__ModuleLoader__.load({
1019
1000
  const changed = fields.filter(name => f[name].overridden).length
1020
1001
  return h('section', { style: S.advanced },
1021
1002
  h(Disclosure, { id: 'advanced', big: true, title: t('advanced'), hint: t('advancedHint'), badge: changed ? t('advancedChanged').replace('{n}', String(changed)) : undefined },
1022
- h(Group, { title: t('groupNotify') },
1023
- h(ChoiceRow, { name: 'channel', field: f.channel, hint: 'channelHint', ...common, options: [['auto', 'channelAuto'], ['client', 'channelClient'], ['system', 'channelSystem'], ['both', 'channelBoth'], ['off', 'channelOff']] }),
1024
- toggle('suppressWhenFocused')),
1003
+ h(Group, { title: t('groupNotify') }, toggle('suppressWhenFocused')),
1025
1004
  features.tray ? h(Group, { title: t('groupTray') },
1026
1005
  features.menuBarTitle ? toggle('showSpendInTitle') : null,
1027
1006
  h('div', { style: S.fieldGap }, h(NumberField, { name: 'errorHoldMinutes', field: f.errorHoldMinutes, ...common }))) : null,
@@ -1056,9 +1035,11 @@ window.__ModuleLoader__.load({
1056
1035
  }
1057
1036
 
1058
1037
  const PAGE_CSS = `
1059
- .dnt-page { --dnt-accent: #5085b2; --dnt-border: color-mix(in srgb, currentColor 11%, transparent); flex: 1; min-height: 0; overflow-y: auto; }
1060
- html[data-platform='darwin'] .dnt-page { margin-top: var(--dsh-frame-top-clearance, 0px); }
1038
+ .dnt-page { --dnt-accent: #5085b2; --dnt-border: color-mix(in srgb, currentColor 11%, transparent); }
1039
+ .dnt-panel { flex: 1; min-height: 0; overflow-y: auto; }
1040
+ html[data-platform='darwin'] .dnt-panel { margin-top: var(--dsh-frame-top-clearance, 0px); }
1061
1041
  .dnt-content { max-width: 1040px; margin: auto; padding: 30px 26px 48px; }
1042
+ .dnt-settings .dnt-content { padding: 0; }
1062
1043
  .dnt-hero { display: flex; align-items: center; gap: 18px; padding: 22px; margin-bottom: 24px; border-radius: 20px; background: linear-gradient(115deg, color-mix(in srgb, var(--dnt-accent) 12%, transparent), color-mix(in srgb, var(--dnt-accent) 2%, transparent)); border: 1px solid var(--dnt-border); }
1063
1044
  .dnt-mascot { box-sizing: border-box; width: 80px; height: 80px; padding: 8px; flex: none; border-radius: 22px; border: 1px solid var(--dnt-border); background: var(--dsw-alias-bg-layer-1, #fff); box-shadow: 0 3px 10px #00000006; }
1064
1045
  .dnt-mascot-window { width: 100%; height: 100%; overflow: hidden; border-radius: 15px; background: #050505; }
@@ -1111,7 +1092,7 @@ window.__ModuleLoader__.load({
1111
1092
  const state = props.useNotifyTray(snapshot => snapshot)
1112
1093
  const busy = state.saving || state.dirty
1113
1094
  const status = !state.available ? 'unavailable' : !state.writable ? 'readOnly' : state.notice?.kind === 'saveFailed' ? 'saveFailed' : state.invalid ? 'fixSettings' : state.saving ? 'saving' : state.dirty ? 'pendingSave' : 'autoSave'
1114
- return h('div', { className: 'dnt-page' },
1095
+ return h('div', { className: props.close ? 'dnt-page dnt-settings' : 'dnt-page dnt-panel' },
1115
1096
  h('style', null, PAGE_CSS),
1116
1097
  h('div', { className: 'dnt-content' },
1117
1098
  h('header', { className: 'dnt-hero' },
@@ -1142,6 +1123,9 @@ window.__ModuleLoader__.load({
1142
1123
  const t = props.t
1143
1124
  const state = props.useNotifyUpdate(snapshot => snapshot)
1144
1125
  React.useEffect(() => { props.checkUpdate() }, [])
1126
+ const openUpdate = async () => {
1127
+ if (await props.openPluginUpdate()) props.close?.()
1128
+ }
1145
1129
  const busy = state.phase === 'checking' || state.phase === 'opening'
1146
1130
  return h(Section, { title: t('updateTitle'), icon: 'update' },
1147
1131
  h('div', { className: 'dnt-update-row' },
@@ -1153,7 +1137,7 @@ window.__ModuleLoader__.load({
1153
1137
  state.error ? h('p', { className: 'dnt-note', style: S.error, role: 'alert' }, state.error === 'updateSaveFirst' ? t(state.error) : state.error) : null),
1154
1138
  h('div', { className: 'dnt-update-actions' },
1155
1139
  h('button', { type: 'button', style: S.button, disabled: busy, onClick: props.checkUpdate }, t('checkUpdate')),
1156
- state.phase === 'available' ? h('button', { type: 'button', style: { ...S.button, background: 'var(--dnt-accent)', color: '#fff', borderColor: 'transparent' }, onClick: props.openPluginUpdate }, t('openPluginUpdate')) : null)),
1140
+ state.phase === 'available' ? h('button', { type: 'button', style: { ...S.button, background: 'var(--dnt-accent)', color: '#fff', borderColor: 'transparent' }, onClick: openUpdate }, t('openPluginUpdate')) : null)),
1157
1141
  ['unavailable', 'manual', 'local'].includes(state.phase) ? null : h('p', { className: 'dnt-note', style: { marginTop: 12 } }, t('updateHint')))
1158
1142
  }
1159
1143
 
@@ -1170,7 +1154,8 @@ window.__ModuleLoader__.load({
1170
1154
  const features = (platform && FEATURES[platform]) || ALL_FEATURES
1171
1155
  const t = platformT(props.t, platform)
1172
1156
  const disabled = !state.writable
1173
- const common = { t, disabled, edit: props.edit, resetField: props.resetField, flush: props.flush }
1157
+ const idPrefix = props.close ? 'notify-tray-settings' : 'notify-tray'
1158
+ const common = { t, disabled, idPrefix, edit: props.edit, resetField: props.resetField, flush: props.flush }
1174
1159
  const f = state.fields
1175
1160
  const toggle = name => h(ToggleRow, { key: name, name, field: f[name], ...common })
1176
1161
  const titleStyle = f.titleStyle.text || 'text'
@@ -1207,39 +1192,28 @@ window.__ModuleLoader__.load({
1207
1192
  })
1208
1193
  ctx.effect(() => () => updater.dispose(), 'notify-tray: updates')
1209
1194
  ctx.effect(() => () => card.dispose(), 'notify-tray: settings form')
1210
- // DSH owns sidebar navigation and README rendering on the plugin page.
1211
- // Register no plugin-detail config/actions: settings have one entrance.
1212
- ctx.inject(['layout'], pageCtx => {
1213
- pageCtx.effect(() => pageCtx.configForms.whileServed([NS], () => {
1214
- const stopMain = pageCtx.slots.inject('main', () => pageCtx.slots.register({
1215
- name: 'main',
1216
- key: PANEL_ID,
1217
- locale: LOCALE_NS,
1218
- inject: () => {
1219
- const face = card.inject()
1220
- return { ...face, hooks: { ...face.hooks, notifyUpdate: updater.store }, checkUpdate: () => updater.check(), openPluginUpdate: () => updater.open() }
1221
- },
1222
- }, Page))
1223
- const stopSidebar = pageCtx.slots.inject('sidebar.panellist', () => pageCtx.slots.register({
1224
- name: 'sidebar.panellist',
1225
- id: PANEL_ID,
1226
- order: 11,
1227
- label: () => t('title'),
1228
- }, WhaleIcon))
1229
- return () => { stopSidebar(); stopMain() }
1230
- }), 'notify-tray: sidebar settings')
1231
- })
1195
+ const injectPage = () => {
1196
+ const face = card.inject()
1197
+ return { ...face, hooks: { ...face.hooks, notifyUpdate: updater.store }, checkUpdate: () => updater.check(), openPluginUpdate: () => updater.open() }
1198
+ }
1199
+ const label = () => t('title')
1200
+ ctx.effect(() => ctx.configForms.whileServed([NS], () => {
1201
+ const register = (options, component) => ctx.slots.inject(options.name, () => ctx.slots.register(options, component))
1202
+ const stops = [
1203
+ register({ name: 'settings.section', id: PANEL_ID, order: 8, label, locale: LOCALE_NS, inject: injectPage }, Page),
1204
+ register({ name: 'settings.section.icon', id: PANEL_ID }, WhaleIcon),
1205
+ register({ name: 'main', key: PANEL_ID, locale: LOCALE_NS, inject: injectPage }, Page),
1206
+ register({ name: 'sidebar.panellist', id: PANEL_ID, order: 11, label }, WhaleIcon),
1207
+ ]
1208
+ return () => { for (const stop of stops.reverse()) stop() }
1209
+ }), 'notify-tray: settings entries')
1232
1210
  }
1233
1211
 
1234
1212
 
1235
1213
  function apply(ctx) {
1236
- var cursor = -1
1237
- var boot
1214
+ var viewId = Math.random().toString(36).slice(2)
1238
1215
  var stopped = false
1239
1216
  var timer
1240
- /** Focus at the previous poll: a window that just came forward claims the session a system toast announced. */
1241
- var wasFocused = false
1242
-
1243
1217
  function open(sessionId) {
1244
1218
  try { window.focus() } catch (e) {}
1245
1219
  try { ctx.uiWorkspace.openSession(sessionId) } catch (e) {
@@ -1247,62 +1221,21 @@ window.__ModuleLoader__.load({
1247
1221
  }
1248
1222
  }
1249
1223
 
1250
- /** Notifications this window put up, by key (session): the next one for a key replaces it. */
1251
- var shown = {}
1252
-
1253
- function withdraw(notice) {
1254
- var n = shown[notice.key]
1255
- if (!n) return
1256
- delete shown[notice.key]
1257
- try { n.close() } catch (e) {}
1258
- }
1259
-
1260
- function show(event, state) {
1261
- if (event.kind === 'withdraw') return withdraw(event)
1262
- if (typeof Notification === 'undefined') return
1263
- if (state.suppressWhenFocused && document.hasFocus() && mainSessionId(ctx.sessions) === event.sessionId) return
1264
- // Without permission the host is not told we listen, so it notifies itself.
1265
- if (Notification.permission !== 'granted') return
1266
- if (!claim(boot, event.seq)) return
1267
- var display = event.display || { title: (state.titles[event.type] || 'DeepSeek Harness') + ' · ' + event.title, body: event.body }
1268
- var key = event.key || event.sessionId
1269
- // Same tag: the OS swaps the session's previous notification for this one.
1270
- var n = new Notification(display.title, { body: display.body, tag: 'dsh-notify-tray:' + key, renotify: true })
1271
- shown[key] = n
1272
- n.onclose = function () { if (shown[key] === n) delete shown[key] }
1273
- n.onclick = function () {
1274
- n.close()
1275
- // The renderer cannot move the OS foreground; the host brings the window forward where it can (Windows).
1276
- fetch(RAISE_ROUTE, { method: 'POST', cache: 'no-store' }).catch(function () {})
1277
- open(event.sessionId)
1278
- }
1279
- }
1280
-
1281
1224
  function poll() {
1282
- var granted = typeof Notification !== 'undefined' && Notification.permission === 'granted'
1283
- var focused = typeof document !== 'undefined' && typeof document.hasFocus === 'function' && document.hasFocus()
1284
- var claimToast = focused && !wasFocused
1285
- wasFocused = focused
1286
- fetch(ROUTE + '?lite=1&after=' + cursor + (granted ? '&notify=1' : '') + (claimToast ? '&claim=1' : ''), { headers: { accept: 'application/json' }, cache: 'no-store' })
1225
+ var focused = typeof document !== 'undefined' && document.hasFocus && document.hasFocus()
1226
+ var session = focused && mainSessionId(ctx.sessions)
1227
+ var query = '?lite=1&window=' + viewId + (focused ? '&foreground=1' : '') + (session ? '&view=' + encodeURIComponent(session) : '')
1228
+ fetch(ROUTE + query, { headers: { accept: 'application/json' }, cache: 'no-store' })
1287
1229
  .then(function (res) { return res.ok ? res.json() : undefined })
1288
1230
  .then(function (state) {
1289
1231
  if (!state || stopped) return
1290
1232
  // Tray clicks first: the host hands each one out once, even on our first poll.
1291
1233
  for (var j = 0; j < state.focus.length; j += 1) open(state.focus[j])
1292
- // First poll, or the host restarted (new boot id): adopt its cursor without replaying history.
1293
- if (state.boot !== boot) { boot = state.boot; cursor = state.seq; return }
1294
- for (var i = 0; i < state.events.length; i += 1) show(state.events[i], state)
1295
- cursor = Math.max(cursor, state.seq)
1296
1234
  })
1297
1235
  .catch(function () {})
1298
1236
  .then(function () { if (!stopped) timer = setTimeout(poll, POLL_MS) })
1299
1237
  }
1300
1238
 
1301
- // Browsers only show the permission prompt from a user gesture.
1302
- if (typeof Notification !== 'undefined' && Notification.permission === 'default' && typeof document.addEventListener === 'function') {
1303
- document.addEventListener('click', function () { Notification.requestPermission() }, { once: true })
1304
- }
1305
-
1306
1239
  poll()
1307
1240
  ctx.effect(function () {
1308
1241
  return function () { stopped = true; clearTimeout(timer) }