@soffits/dsh-notify-inbox 0.1.1 → 0.1.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.3
4
+
5
+ - The buttons chunk keeps its names inside its own scope, so it loads next to another plugin's copy on the same page (DSH runs chunks as classic scripts in one global scope).
6
+ - Touch targets are at least 40 px on phones and touch screens.
7
+ - A notification you open under Unread stays on screen instead of vanishing as it turns read.
8
+
9
+ ## 0.1.2
10
+
11
+ - The buttons chunk registers as a chunk of the package (`{ id, chunk }`), so a page that got the plugin while it was open loads the buttons instead of failing with "loaded without registering"; a failed load is retried next time and never hides the list.
12
+ - A press that gets handled shows as handled without reloading the page.
13
+
3
14
  ## 0.1.1
4
15
 
5
16
  - Buttons come from the shared action bar (`client.actions.js`, the same one the card board uses), so both pages look and behave alike; buttons without a label get the shared words.
package/client.actions.js CHANGED
@@ -18,6 +18,7 @@
18
18
  * UI's own workspace service (so the person sends it themselves, signed in as
19
19
  * themselves), and link opens the URL.
20
20
  */
21
+ (() => {
21
22
  const OWNER = '@soffits/dsh-notify-inbox'
22
23
 
23
24
  const WORDS = {
@@ -254,6 +255,5 @@ function createActions({ React, ctx, locale = 'en', press }) {
254
255
  return { ActionBar, ActionButton, Icon, startChat, chatText, t }
255
256
  }
256
257
 
257
- if (typeof window !== 'undefined' && window.__ModuleLoader__) {
258
- window.__ModuleLoader__.load({ id: `${OWNER}/client.actions.js`, factory: () => ({ createActions, chatText }) })
259
- }
258
+ window.__ModuleLoader__.load({ id: OWNER, chunk: 'client.actions.js', factory: () => ({ createActions, chatText }) })
259
+ })()
package/client.js CHANGED
@@ -13,7 +13,7 @@ window.__ModuleLoader__.load({
13
13
  factory(require) {
14
14
  const React = require('react')
15
15
  const h = React.createElement
16
- const { useState, useEffect, useCallback, useSyncExternalStore } = React
16
+ const { useState, useEffect, useCallback, useRef, useSyncExternalStore } = React
17
17
 
18
18
  const NS = 'dsh-notify-inbox'
19
19
  const PANEL = 'dsh-notify-inbox'
@@ -137,6 +137,7 @@ window.__ModuleLoader__.load({
137
137
  .nib-more{margin:12px auto 0;display:flex}
138
138
  .nib-icon{position:relative;display:inline-flex}
139
139
  .nib-badge{position:absolute;top:-5px;right:-8px;min-width:14px;height:14px;padding:0 3px;box-sizing:border-box;border-radius:7px;background:var(--dsw-alias-state-error-primary);color:#fff;font-size:9px;font-weight:600;line-height:14px;text-align:center;pointer-events:none}
140
+ @media (width<=640px),(pointer:coarse){.nib-btn,.nib-tab,.nib-page .ua-btn{min-height:40px;min-width:40px}.nib-tab{padding-inline:14px}.nib-tabs{border-radius:12px}}
140
141
  @media (width<=640px){.nib-content{padding-inline:12px}.nib-head{padding-top:16px}.nib-body{margin-left:0}.nib-item{padding:10px 8px}}
141
142
  `
142
143
 
@@ -163,7 +164,7 @@ window.__ModuleLoader__.load({
163
164
  try {
164
165
  const summary = await call('summary')
165
166
  shared.pollSeconds = summary.pollSeconds || 30
166
- const key = `${summary.unread}|${summary.latest}|${summary.total}`
167
+ const key = `${summary.unread}|${summary.latest}|${summary.total}|${summary.handled}`
167
168
  if (key !== lastSummary) {
168
169
  lastSummary = key
169
170
  shared.unread = summary.unread
@@ -206,7 +207,7 @@ window.__ModuleLoader__.load({
206
207
  // ---- the buttons: the shared action bar (client.actions.js, also used by the card board) ----
207
208
 
208
209
  let actionsModule
209
- const loadActions = () => (actionsModule ??= require.async('./client.actions.js'))
210
+ const loadActions = () => (actionsModule ??= require.async('./client.actions.js').catch(error => { actionsModule = undefined; throw error }))
210
211
 
211
212
  /** The server's view of each button's last press: pending, done or unhandled. */
212
213
  function pressStates(item) {
@@ -368,10 +369,12 @@ window.__ModuleLoader__.load({
368
369
  const [more, setMore] = useState(false)
369
370
  const [error, setError] = useState(null)
370
371
  const [open, setOpen] = useState(() => shared.linked)
372
+ const openRef = useRef(open)
373
+ openRef.current = open
371
374
  const [ui, setUi] = useState(null)
372
375
  useEffect(() => {
373
376
  let live = true
374
- makeActions(t('time.locale')).then(made => { if (live) setUi(made) }, reason => { if (live) setError(reason.message) })
377
+ makeActions(t('time.locale')).then(made => { if (live) setUi(made) }, reason => { console.warn('notify-inbox: buttons unavailable', reason) })
375
378
  return () => { live = false }
376
379
  }, [])
377
380
 
@@ -381,7 +384,15 @@ window.__ModuleLoader__.load({
381
384
  if (filter === 'unread') params.set('unread', '1')
382
385
  if (append && items?.length) params.set('before', items[items.length - 1].id)
383
386
  const page = await call(`items?${params}`)
384
- setItems(previous => (append && previous ? [...previous, ...page.items] : page.items))
387
+ setItems(previous => {
388
+ if (append && previous) return [...previous, ...page.items]
389
+ // The open item stays where it was even when it no longer matches the filter (opening marks it read).
390
+ const kept = previous?.findIndex(row => row.id === openRef.current) ?? -1
391
+ if (kept < 0 || page.items.some(row => row.id === openRef.current)) return page.items
392
+ const next = [...page.items]
393
+ next.splice(Math.min(kept, next.length), 0, { ...previous[kept], read: true })
394
+ return next
395
+ })
385
396
  setMore(page.more)
386
397
  setError(null)
387
398
  } catch (reason) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soffits/dsh-notify-inbox",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "A notification inbox for DeepSeek Harness: each person sees their own notifications with read and unread, gets Web Push on their phone or browser, and can act on them.",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/routes.js CHANGED
@@ -89,7 +89,8 @@ export function createRoutes({ store, people, push, actions, identity, serviceWo
89
89
  const summary = handle(async (_request, who) => {
90
90
  const { items, bad } = await store.view(who.folders)
91
91
  const unread = items.filter(item => !item.read).length
92
- return json(200, { mode: who.mode, person: who.person, unread, total: items.length, latest: items[0]?.time ?? null, problems: { badLines: bad }, pollSeconds })
92
+ const handled = items.reduce((sum, item) => sum + item.handled.length, 0)
93
+ return json(200, { mode: who.mode, person: who.person, unread, total: items.length, handled, latest: items[0]?.time ?? null, problems: { badLines: bad }, pollSeconds })
93
94
  })
94
95
 
95
96
  const list = handle(async (request, who) => {