@soffits/dsh-notify-inbox 0.3.0 → 0.4.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/CHANGELOG.md +6 -0
- package/README.md +1 -1
- package/client.js +4 -3
- package/locale/en.json +1 -0
- package/locale/fr.json +1 -0
- package/locale/zh.json +1 -0
- package/package.json +1 -1
- package/src/actions.js +3 -2
- package/src/routes.js +2 -1
- package/src/store.js +3 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.4.0
|
|
4
|
+
|
|
5
|
+
- Suggested next steps: a notification's `step` actions show as their own buttons (from @soffits/dsh-ui-actions 0.2.0). A tap is recorded here like done and snooze, as the event `ui.action.step` with who pressed it, then the step is sent to the assistant; the row says "Started".
|
|
6
|
+
- Button labels may be maps from language tag to text.
|
|
7
|
+
- Each press remembers which button it was, so several steps on one notification keep their own state.
|
|
8
|
+
|
|
3
9
|
## 0.3.0
|
|
4
10
|
|
|
5
11
|
- The buttons come from [@soffits/dsh-ui-actions](https://github.com/soffits/dsh-ui-actions), installed as its own plugin, instead of a copy of the card board's chunk. "Ask" now opens a conversation with the notification attached as a card the person can remove and write beside; the sent message shows the same card, and the agent gets the notification as compact text with its id. Without the package the page works and shows no buttons.
|
package/README.md
CHANGED
|
@@ -66,7 +66,7 @@ The buttons come from [@soffits/dsh-ui-actions](https://github.com/soffits/dsh-u
|
|
|
66
66
|
|
|
67
67
|
Every notification gets **Ask**: it opens a new session with the notification attached to the message box as a card (removable), and the person writes their own words beside it. The sent message shows the same card; the agent gets the notification as a short quote with its id. Since the person sends it from the Web UI, the sign-in plugin records them as the sender.
|
|
68
68
|
|
|
69
|
-
Declared `actions` add more: `done`, `snooze` (a small picker: in an hour, this evening, tomorrow morning; or a fixed `payload.until`), `event` (anything else) and `link` (`payload.url`). A press on `done`, `snooze` or `event` is checked on the server (the record must be the caller's and declare that button), appended to `<dataDir>/<person>/actions.jsonl`, and published on the event channel `ui.action.<kind>` when [dsh-cron-jobs](https://github.com/soffits/dsh-cron-jobs) is installed, so a job listening there can act on it:
|
|
69
|
+
Declared `actions` add more: `step` (a suggested next step whoever filed the notification knows, like "Pay it from the joint account": one tap records the press, then sends the step with the notification to the assistant as the person, at most three; `label` required, text or `{ "en": …, "zh": … }`), `done`, `snooze` (a small picker: in an hour, this evening, tomorrow morning; or a fixed `payload.until`), `event` (anything else) and `link` (`payload.url`). A press on `step`, `done`, `snooze` or `event` is checked on the server (the record must be the caller's and declare that button), appended to `<dataDir>/<person>/actions.jsonl`, and published on the event channel `ui.action.<kind>` when [dsh-cron-jobs](https://github.com/soffits/dsh-cron-jobs) is installed, so a job listening there can act on it:
|
|
70
70
|
|
|
71
71
|
```json
|
|
72
72
|
{"action": "snooze", "id": "snooze", "payload": {"until": "2026-11-18T09:00:00-05:00"}, "person": "ana",
|
package/client.js
CHANGED
|
@@ -134,6 +134,7 @@ window.__ModuleLoader__.load({
|
|
|
134
134
|
function pressStatus(item, t) {
|
|
135
135
|
const press = item.presses[item.presses.length - 1]
|
|
136
136
|
if (press === undefined) return null
|
|
137
|
+
if (press.action === 'step') return t('press.started')
|
|
137
138
|
const handled = item.handled.find(row => row.press === press.press)
|
|
138
139
|
if (handled !== undefined) {
|
|
139
140
|
if (handled.result === 'snoozed' && handled.until) return t('press.snoozed', { time: absolute(handled.until, t) })
|
|
@@ -151,7 +152,7 @@ window.__ModuleLoader__.load({
|
|
|
151
152
|
function pressStates(item) {
|
|
152
153
|
const states = {}
|
|
153
154
|
for (const press of item.presses) {
|
|
154
|
-
const action = item.actions.find(row => row.kind === press.action) ?? { id: press.action }
|
|
155
|
+
const action = item.actions.find(row => row.id === press.id) ?? item.actions.find(row => row.kind === press.action) ?? { id: press.action }
|
|
155
156
|
const handled = item.handled.some(row => row.press === press.press)
|
|
156
157
|
states[action.id] = handled ? 'done' : Date.now() - Date.parse(press.at) < PENDING_MS ? 'pending' : 'unhandled'
|
|
157
158
|
}
|
|
@@ -173,9 +174,9 @@ window.__ModuleLoader__.load({
|
|
|
173
174
|
changed()
|
|
174
175
|
}
|
|
175
176
|
const status = pressStatus(item, t)
|
|
176
|
-
return h('div', { className: 'nib-actions' }, h(ui.ActionBar, { actions: item.actions, states: pressStates(item), about, defaultChat: true, onPress }
|
|
177
|
+
return h('div', { className: 'nib-actions' }, h(ui.ActionBar, { actions: item.actions, states: pressStates(item), about, defaultChat: true, onPress },
|
|
177
178
|
markUnread,
|
|
178
|
-
status && h('span', { className: 'nib-status' }, status))
|
|
179
|
+
status && h('span', { className: 'nib-status' }, status)))
|
|
179
180
|
}
|
|
180
181
|
|
|
181
182
|
// ---- one notification ----
|
package/locale/en.json
CHANGED
package/locale/fr.json
CHANGED
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
"press.unhandled": "Personne ne l’a encore pris en charge",
|
|
24
24
|
"press.done": "Marqué comme fait",
|
|
25
25
|
"press.snoozed": "Rappel {time}",
|
|
26
|
+
"press.started": "Lancé",
|
|
26
27
|
"push.title": "Notifications sur cet appareil",
|
|
27
28
|
"push.on": "Activées",
|
|
28
29
|
"push.off": "Désactivées",
|
package/locale/zh.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soffits/dsh-notify-inbox",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
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/actions.js
CHANGED
|
@@ -12,7 +12,8 @@ import { appendFile, mkdir, readFile } from 'node:fs/promises'
|
|
|
12
12
|
import { randomBytes } from 'node:crypto'
|
|
13
13
|
import { join } from 'node:path'
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
/** Kinds whose press is recorded here: a step's press is the person's go-ahead for what its label says. */
|
|
16
|
+
export const EMITTING = ['step', 'done', 'snooze', 'event']
|
|
16
17
|
const ACTIONS_LOG = 'actions.jsonl'
|
|
17
18
|
|
|
18
19
|
/** The event a press becomes (same shape as the practice's actions spec). */
|
|
@@ -77,7 +78,7 @@ export function createActions({ dataDir, events, warn }) {
|
|
|
77
78
|
const event = JSON.parse(line)
|
|
78
79
|
const id = event?.source?.record
|
|
79
80
|
if (typeof id !== 'string') continue
|
|
80
|
-
out.set(id, [...(out.get(id) ?? []), { press: event.press, action: event.action, at: event.at, until: event.payload?.until }])
|
|
81
|
+
out.set(id, [...(out.get(id) ?? []), { press: event.press, action: event.action, id: event.id, at: event.at, until: event.payload?.until }])
|
|
81
82
|
} catch {
|
|
82
83
|
// A torn line is skipped.
|
|
83
84
|
}
|
package/src/routes.js
CHANGED
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
import { readFile } from 'node:fs/promises'
|
|
20
20
|
import { extname } from 'node:path'
|
|
21
21
|
import { viewerOf } from './access.js'
|
|
22
|
+
import { EMITTING } from './actions.js'
|
|
22
23
|
import { PERSON_PATTERN, RECORD_ID_PATTERN } from './store.js'
|
|
23
24
|
|
|
24
25
|
export const PREFIX = '/api/notify-inbox'
|
|
@@ -144,7 +145,7 @@ export function createRoutes({ store, people, push, actions, identity, serviceWo
|
|
|
144
145
|
if (record === undefined) return json(404, { error: 'No such notification.' })
|
|
145
146
|
const declared = record.actions.find(row => row.id === value.action)
|
|
146
147
|
if (declared === undefined) return json(400, { error: 'This notification has no such button.' })
|
|
147
|
-
if (!
|
|
148
|
+
if (!EMITTING.includes(declared.kind)) return json(400, { error: 'This button acts in the page.' })
|
|
148
149
|
const result = await actions.press(record.person, record, declared, { until: value.until })
|
|
149
150
|
await store.setRead(record.person, [record.id], true)
|
|
150
151
|
return json(200, { press: result.event.press, published: result.published, matched: result.matched ?? 0 })
|
package/src/store.js
CHANGED
|
@@ -21,6 +21,8 @@ const READ = 'read.json'
|
|
|
21
21
|
|
|
22
22
|
const text = value => (typeof value === 'string' ? value : '')
|
|
23
23
|
const list = value => (Array.isArray(value) ? value : [])
|
|
24
|
+
/** Text a person reads: a string, or a map from language tag to text (the page picks the language). */
|
|
25
|
+
const words = value => (typeof value === 'string' ? value : value !== null && typeof value === 'object' && !Array.isArray(value) && Object.values(value).every(v => typeof v === 'string') ? value : '')
|
|
24
26
|
|
|
25
27
|
/** A record as the page gets it, or undefined when the line is not one. */
|
|
26
28
|
export function normalize(raw, person) {
|
|
@@ -48,7 +50,7 @@ export function normalize(raw, person) {
|
|
|
48
50
|
actions: list(raw.actions).filter(action => typeof action?.kind === 'string' && typeof action?.id === 'string').map(action => ({
|
|
49
51
|
kind: action.kind,
|
|
50
52
|
id: action.id,
|
|
51
|
-
label:
|
|
53
|
+
label: words(action.label) || undefined,
|
|
52
54
|
payload: typeof action.payload === 'object' && action.payload !== null && !Array.isArray(action.payload) ? action.payload : {},
|
|
53
55
|
})),
|
|
54
56
|
test: raw.test === true,
|