@soffits/dsh-card-board 0.5.0 → 0.6.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 CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.6.0
4
+
5
+ - Suggested next steps: cards and rows can carry `step` actions, concrete next steps whoever writes the card knows ("Renew the books online"). A tap records the press like done and snooze (the event `ui.action.step`, with who pressed it), then the step is sent with the card or row to the assistant as the person, and the button links to the conversation. At most 3 per card or row, a label of up to 80 characters is required. Needs @soffits/dsh-ui-actions 0.2.0.
6
+ - A row's steps sit on their own line under it; its other buttons stay beside the title.
7
+
3
8
  ## 0.5.0
4
9
 
5
10
  - The action buttons come from the shared [`@soffits/dsh-ui-actions`](https://github.com/soffits/dsh-ui-actions) plugin (`ctx.uiActions`) instead of a copy of `client.actions.js` in this package, which is gone. Install that plugin to get buttons; the page works without it, just without buttons. A chat button opens a conversation with the card or row attached to the message box as a small card, and the sent message shows it with the board's icon and name. The board names itself to it once, so cards from other pages read the same.
package/README.md CHANGED
@@ -219,6 +219,7 @@ A card, a list row or a status row can carry up to six buttons:
219
219
  "actions": [
220
220
  { "kind": "done", "id": "library-books:done" },
221
221
  { "kind": "snooze", "id": "library-books:snooze" },
222
+ { "kind": "step", "id": "library-books:renew", "label": { "en": "Renew the books online", "fr": "Renouveler les livres en ligne" } },
222
223
  { "kind": "chat", "id": "landlord:ask", "label": "Draft a message", "payload": { "prompt": "Help me write a short follow-up to the landlord." } },
223
224
  { "kind": "event", "id": "front-door:lock", "label": "Lock" },
224
225
  { "kind": "link", "id": "panel", "label": "Home panel", "payload": { "url": "https://example.com/home" } }
@@ -226,10 +227,11 @@ A card, a list row or a status row can carry up to six buttons:
226
227
  ```
227
228
 
228
229
  - `chat` opens a new conversation (or the session named in `payload.session`) with a draft that quotes the card or row and carries its ids as JSON, after `payload.prompt` if you gave one. Nothing is sent until the person sends it, so the message comes from them like any other. Every card also has a chat button in its corner without declaring one ("Chat about this"); when the board names an `assistant` the buttons say who they ask ("Ask Robin"). A `label` and `payload.prompt` can be text in several languages.
230
+ - `step` is a suggested next step the assistant starts on one tap: the label says the step plainly ("Renew the books online") and the tap is the person's go-ahead for exactly that. The press is recorded on the server like `done`, then the page sends the step (`payload.prompt` when it needs more words than the label, never more than it authorises; otherwise the label) with the card or row into a new session (or `payload.session`) as the person, with no draft to confirm, and the button links to that session. At most 3 steps per card or row; add one only where the data has a clear next step. The label (up to 80 characters) is required.
229
231
  - `done`, `snooze` and `event` are pressed on the server. A snooze without `payload.until` asks: in 3 hours, tomorrow at 9:00, or a time.
230
232
  - `link` opens `payload.url`.
231
233
 
232
- `id` is yours: letters, digits and `. _ : -`, unique within the card or row. `label` is optional except for `event`. `payload` is any small object (up to 4 KB of JSON).
234
+ `id` is yours: letters, digits and `. _ : -`, unique within the card or row. `label` is optional except for `event` and `step`. `payload` is any small object (up to 4 KB of JSON).
233
235
 
234
236
  The plugin doesn't act on a press itself. It checks that the person may see the board and that the action is in the card as written, then records an event:
235
237
 
package/client.js CHANGED
@@ -487,6 +487,9 @@ window.__ModuleLoader__.load({
487
487
  progress.label && size >= 90 && h('span', null, progress.label)))
488
488
  }
489
489
 
490
+ /** A row's suggested steps go on their own line under it; its other buttons stay beside the title. */
491
+ const hasSteps = row => row.actions?.some(action => action.kind === 'step') === true
492
+
490
493
  function ListCard({ data, locale, t, rowActions }) {
491
494
  const [ref, width] = useWidth()
492
495
  const checkable = data.rows.some(row => 'checked' in row)
@@ -501,7 +504,8 @@ window.__ModuleLoader__.load({
501
504
  (row.date || row.chip) && h('span', { className: 'cb-listMeta' },
502
505
  row.date && h('span', { className: 'cb-listDate' }, formatDay(toTime(row.date), locale, 0)),
503
506
  row.chip && h(Chip, row.chip)),
504
- row.actions && rowActions && h('span', { className: 'cb-rowActions' }, rowActions(i, row.actions, listRowLine(row))))))
507
+ row.actions && rowActions && h('span', { className: 'cb-rowActions' }, rowActions(i, row.actions, listRowLine(row), 'buttons')),
508
+ hasSteps(row) && rowActions && h('div', { className: 'cb-rowSteps' }, rowActions(i, row.actions, listRowLine(row), 'steps')))))
505
509
  if (!data.progress) return rows
506
510
  // Beside the rows when there is room for both, else a small ring with its count above them.
507
511
  const wide = width >= 460
@@ -607,7 +611,8 @@ window.__ModuleLoader__.load({
607
611
  h('span', { className: 'cb-statusNum', style: row.tone === 'bad' || row.tone === 'warn' ? { color: toneColor(row.tone) } : undefined }, formatNumber(row.value, locale)),
608
612
  row.sub && h(Trunc, { as: 'small', className: 'cb-statusSub', lines: 2, text: row.sub })),
609
613
  sparks && (row.spark ? h(Spark, { values: row.spark, color: toneColor(row.tone === 'ok' ? 'accent' : row.tone) }) : h('span', { className: 'cb-spark' })),
610
- hasActions && h('span', { className: 'cb-rowActions' }, rowActions && row.actions ? rowActions(i, row.actions, statusRowLine(row, locale)) : null))))
614
+ hasActions && h('span', { className: 'cb-rowActions' }, rowActions && row.actions ? rowActions(i, row.actions, statusRowLine(row, locale), 'buttons') : null),
615
+ hasSteps(row) && rowActions && h('div', { className: 'cb-rowSteps' }, rowActions(i, row.actions, statusRowLine(row, locale), 'steps')))))
611
616
  }
612
617
 
613
618
  // ---- what a chat quotes ----------------------------------------------------
@@ -715,8 +720,9 @@ window.__ModuleLoader__.load({
715
720
  // A chat button without its own label says "Ask <assistant>" when the board names one.
716
721
  const askName = assistant ? t('action.chatNamed', { name: assistant }) : undefined
717
722
  const named = list => (assistant ? list?.map(action => (action.kind === 'chat' && action.label === undefined ? { ...action, label: askName } : action)) : list)
718
- const rowActions = actions && ((row, list, line) => h(actions.ActionBar, {
723
+ const rowActions = actions && ((row, list, line, part) => h(actions.ActionBar, {
719
724
  actions: named(list),
725
+ part,
720
726
  states: statesOf(entry.presses, row),
721
727
  compact: true,
722
728
  about: about(row, line),
@@ -978,7 +984,10 @@ h3.cb-truncOpen{overflow:visible}
978
984
  .cb-progressLine strong{font-size:10px!important}
979
985
 
980
986
  .cb-listMain{flex:1;min-width:0}
981
- .cb-list li{display:flex;align-items:center;gap:10px;padding:8px 2px;border-top:.5px solid var(--dsw-alias-border-l2)}
987
+ .cb-list li{display:flex;flex-wrap:wrap;align-items:center;gap:10px;padding:8px 2px;border-top:.5px solid var(--dsw-alias-border-l2)}
988
+ .cb-rowSteps{flex-basis:100%;min-width:0}
989
+ .cb-list li .cb-checkBox~.cb-rowSteps{padding-left:28px}
990
+ .cb-status li>.cb-rowSteps{grid-column:2/-1}
982
991
  .cb-list li:first-child{border-top:0}
983
992
  .cb-listText{flex:1;min-width:0}
984
993
  .cb-listSub{color:var(--dsw-alias-label-tertiary);font-size:12px;line-height:18px}
@@ -1010,6 +1019,7 @@ h3.cb-truncOpen{overflow:visible}
1010
1019
  .cb-list li .cb-listText{grid-column:2;grid-row:1}
1011
1020
  .cb-list li .cb-rowActions{grid-column:3;grid-row:1;margin-left:8px}
1012
1021
  .cb-list li .cb-listMeta{grid-column:2/-1;grid-row:2;margin-top:2px}
1022
+ .cb-list li .cb-rowSteps,.cb-list li .cb-checkBox~.cb-rowSteps{grid-column:2/-1;grid-row:3;margin-top:6px;padding-left:0}
1013
1023
  }
1014
1024
  @container (width<380px){
1015
1025
  .cb-status,.cb-statusSparks{grid-template-columns:8px minmax(0,1fr) auto}
@@ -37,6 +37,20 @@
37
37
  "tone": "warn"
38
38
  },
39
39
  "actions": [
40
+ {
41
+ "kind": "step",
42
+ "id": "library-books:renew",
43
+ "label": {
44
+ "en": "Renew the books online",
45
+ "fr": "Renouveler les livres en ligne",
46
+ "zh": "在网上续借这些书"
47
+ },
48
+ "payload": {
49
+ "prompt": {
50
+ "en": "Renew the library books that are due on the library's website, then tell me the new due date."
51
+ }
52
+ }
53
+ },
40
54
  {
41
55
  "kind": "done",
42
56
  "id": "library-books:done"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soffits/dsh-card-board",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "A data-driven card board for DeepSeek Harness: scripts write small JSON cards, the Web UI shows each person the boards they may see.",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/schema.js CHANGED
@@ -10,9 +10,11 @@
10
10
 
11
11
  export const CARD_TYPES = Object.freeze(['stat', 'line', 'bar', 'donut', 'list', 'timeline', 'status'])
12
12
  export const TONES = Object.freeze(['ok', 'warn', 'bad', 'muted', 'accent'])
13
- export const ACTION_KINDS = Object.freeze(['chat', 'done', 'snooze', 'event', 'link'])
13
+ export const ACTION_KINDS = Object.freeze(['chat', 'step', 'done', 'snooze', 'event', 'link'])
14
14
  /** Kinds the server records as events; chat and link happen in the browser only. */
15
- export const PRESS_KINDS = Object.freeze(['done', 'snooze', 'event'])
15
+ export const PRESS_KINDS = Object.freeze(['step', 'done', 'snooze', 'event'])
16
+ /** Suggested steps per card or row: a few clear next moves, not a menu. */
17
+ export const MAX_STEPS = 3
16
18
  export const ACTION_ID_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,99}$/
17
19
  const MAX_ACTIONS = 6
18
20
  const MAX_PAYLOAD_BYTES = 4096
@@ -145,6 +147,7 @@ function tone(c, value, path) {
145
147
  /** Problems with an `actions` list (on a card, a list row or a status row). */
146
148
  function actions(c, list, path) {
147
149
  if (!c.array(list, path, { max: MAX_ACTIONS })) return
150
+ if (list.filter(action => action?.kind === 'step').length > MAX_STEPS) c.fail(path, `has more than ${MAX_STEPS} steps`)
148
151
  const seen = new Set()
149
152
  list.forEach((action, i) => {
150
153
  const p = join(path, i)
@@ -153,8 +156,8 @@ function actions(c, list, path) {
153
156
  if (typeof action.id !== 'string' || !ACTION_ID_PATTERN.test(action.id)) c.fail(join(p, 'id'), 'must be letters, digits and . _ : - (up to 100), starting with a letter or digit')
154
157
  else if (seen.has(action.id)) c.fail(join(p, 'id'), 'repeats another action id here')
155
158
  else seen.add(action.id)
156
- if ('label' in action) c.label(action.label, join(p, 'label'), { max: 40 })
157
- else if (action.kind === 'event') c.fail(join(p, 'label'), 'is required for an event action')
159
+ if ('label' in action) c.label(action.label, join(p, 'label'), { max: action.kind === 'step' ? 80 : 40 })
160
+ else if (action.kind === 'event' || action.kind === 'step') c.fail(join(p, 'label'), `is required for ${action.kind === 'step' ? 'a step: it says the step plainly' : 'an event action'}`)
158
161
  const payload = action.payload
159
162
  if ('payload' in action) {
160
163
  const pp = join(p, 'payload')
@@ -166,7 +169,7 @@ function actions(c, list, path) {
166
169
  if (!isSafeLink(payload?.url)) c.fail(join(join(p, 'payload'), 'url'), 'is required: an http(s) URL or a path starting with /')
167
170
  }
168
171
  if (action.kind === 'snooze' && payload !== undefined && 'until' in payload) c.dateTime(payload.until, join(join(p, 'payload'), 'until'))
169
- if (action.kind === 'chat' && payload !== undefined) {
172
+ if ((action.kind === 'chat' || action.kind === 'step') && payload !== undefined) {
170
173
  const pp = join(p, 'payload')
171
174
  if ('prompt' in payload) c.label(payload.prompt, join(pp, 'prompt'), { max: 2000 })
172
175
  if ('session' in payload) c.text(payload.session, join(pp, 'session'), { max: 200 })