| 1 | { |
| 2 | "schema": 1, |
| 3 | "name": "remind", |
| 4 | "title": "Reminders", |
| 5 | "glyph": "⏰", |
| 6 | "blurb": "Set a reminder", |
| 7 | "collection": "items", |
| 8 | "state": { |
| 9 | "items": { |
| 10 | "key": "id", |
| 11 | "fields": { |
| 12 | "id": "string", |
| 13 | "text": "string", |
| 14 | "when": "time", |
| 15 | "ts": "time", |
| 16 | "sid": "string", |
| 17 | "fired": "bool", |
| 18 | "firedAt": "time" |
| 19 | } |
| 20 | } |
| 21 | }, |
| 22 | "events": { |
| 23 | "remind.add": { |
| 24 | "require": ["$event.id", "$event.text", "$event.when"], |
| 25 | "fold": [ |
| 26 | { "add": { "to": "items", "item": { "id": "$event.id", "text": "$event.text", "when": "$event.when", "ts": "$event.ts", "sid": "$event.sid", "fired": false, "firedAt": 0 } } }, |
| 27 | { "sort": { "in": "items", "by": "when", "dir": "asc" } } |
| 28 | ] |
| 29 | }, |
| 30 | "remind.fire": { |
| 31 | "fold": [ |
| 32 | { "update": { "in": "items", "id": "$event.id", "set": { "fired": true, "firedAt": "$event.ts" } } } |
| 33 | ] |
| 34 | }, |
| 35 | "remind.done": { |
| 36 | "fold": [ |
| 37 | { "remove": { "from": "items", "id": "$event.id" } } |
| 38 | ] |
| 39 | } |
| 40 | }, |
| 41 | "partition": { "flag": "fired", "at": "firedAt", "graceMs": 6000 }, |
| 42 | "actions": { |
| 43 | "add": { |
| 44 | "require": ["$input"], |
| 45 | "steps": [ |
| 46 | { "parse": { "kind": "reminder", "text": "$input", "onFail": { "hint": "When should I remind you? Try “call mum in 10 minutes”, “standup at 9:00”, or “renew passport | 2026-08-01”." } } }, |
| 47 | { "schedule": { "at": "$parsed.when", "event": { "type": "remind.fire", "id": "$newId", "notice": { "title": "⏰ Reminder", "body": "$parsed.text" } } } }, |
| 48 | { "emit": { "type": "remind.add", "id": "$newId", "text": "$parsed.text", "when": "$parsed.when", "sid": "$sid" } } |
| 49 | ] |
| 50 | }, |
| 51 | "dismiss": { |
| 52 | "steps": [ |
| 53 | { "if": { "all": [{ "not": { "truthy": "$item.fired" } }, { "truthy": "$item.sid" }] }, "unschedule": "$item.sid" }, |
| 54 | { "emit": { "type": "remind.done", "id": "$item.id" } } |
| 55 | ] |
| 56 | } |
| 57 | }, |
| 58 | "ticker": { |
| 59 | "seconds": 1, |
| 60 | "perItem": [ |
| 61 | { |
| 62 | "once": true, |
| 63 | "if": { "all": [{ "not": { "truthy": "$item.fired" } }, { "not": { "truthy": "$item.sid" } }, { "gte": ["$now", "$item.when"] }] }, |
| 64 | "emit": { "type": "remind.fire", "id": "$item.id", "notice": { "title": "⏰ Reminder", "body": "$item.text" } } |
| 65 | } |
| 66 | ] |
| 67 | }, |
| 68 | "chat": { |
| 69 | "remind.fire": { "text": "You asked me to remind you: “{event.notice.body}”", "groupText": "Reminder: “{event.notice.body}”" }, |
| 70 | "remind.add": { "text": "set a reminder: “{event.text}” — {event.when|abstime}", "action": true } |
| 71 | }, |
| 72 | "views": { |
| 73 | "main": { |
| 74 | "kind": "list", |
| 75 | "composer": { "placeholder": "Call the plumber in 2h", "button": "Add", "action": "add", "hint": "e.g. “… in 30m”, “… at 9:00”, or “… | 2026-08-01 14:00”" }, |
| 76 | "search": { "fields": ["text"] }, |
| 77 | "sections": [ |
| 78 | { "id": "upcoming", "source": "active", "order": { "by": "when", "dir": "asc" } }, |
| 79 | { "id": "settling", "source": "grace", "order": { "by": "firedAt", "dir": "asc" } }, |
| 80 | { "id": "previous", "source": "archived", "title": "Previous reminders ({count})", "collapsible": true, "collapsed": true, "order": { "by": "firedAt", "dir": "desc" } } |
| 81 | ], |
| 82 | "empty": [ |
| 83 | { "if": { "not": { "empty": "$buckets.archived" } }, "text": "No upcoming reminders." }, |
| 84 | { "text": "No reminders yet. Add one above, or type /remind in any chat." } |
| 85 | ], |
| 86 | "row": { |
| 87 | "title": { "text": "{item.text}", "strike": { "truthy": "$item.fired" }, "muted": { "truthy": "$item.fired" } }, |
| 88 | "subtitle": [ |
| 89 | { "if": { "all": [{ "truthy": "$item.fired" }, { "truthy": "$item.firedAt" }] }, "text": "Reminded · {item.firedAt|reltime}" }, |
| 90 | { "if": { "truthy": "$item.fired" }, "text": "Reminded" }, |
| 91 | { "text": "{item.when|reltime}", "accent": { "gte": ["$now", "$item.when"] } } |
| 92 | ], |
| 93 | "note": [ |
| 94 | { "if": { "all": [{ "not": { "truthy": "$item.fired" } }, { "gt": [{ "sub": ["$item.when", "$now"] }, 86400000] }] }, "text": "{item.when|abstime}" } |
| 95 | ], |
| 96 | "trailing": [ |
| 97 | { "kind": "button", "glyph": "×", "label": "Cancel reminder", "role": "destructive", "action": "dismiss" } |
| 98 | ], |
| 99 | "tap": { "detail": true } |
| 100 | }, |
| 101 | "refreshSeconds": 1 |
| 102 | }, |
| 103 | "detail": { |
| 104 | "title": "{item.text}", |
| 105 | "sections": [ |
| 106 | { |
| 107 | "kind": "definitions", |
| 108 | "rows": [ |
| 109 | { "term": "When", "value": "{item.when|abstime}" }, |
| 110 | { "term": "Status", "value": "Reminded", "if": { "truthy": "$item.fired" } }, |
| 111 | { "term": "Status", "value": "Upcoming", "if": { "not": { "truthy": "$item.fired" } } }, |
| 112 | { "term": "Added", "value": "{item.ts|abstime}", "if": { "truthy": "$item.ts" } } |
| 113 | ] |
| 114 | }, |
| 115 | { |
| 116 | "kind": "buttons", |
| 117 | "items": [ |
| 118 | { "label": "Dismiss reminder", "action": "dismiss", "role": "destructive", "dismiss": true } |
| 119 | ] |
| 120 | } |
| 121 | ] |
| 122 | } |
| 123 | } |
| 124 | } |
| 125 | |