feat(desktop): interactive to-do card rendering + kind:40009 check-off responses - #4928
Closed
mcdickenson wants to merge 1 commit into
Closed
feat(desktop): interactive to-do card rendering + kind:40009 check-off responses#4928mcdickenson wants to merge 1 commit into
mcdickenson wants to merge 1 commit into
Conversation
… check-offs
A ```buzz:todo-card fenced JSON sentinel inside an ordinary stream
message now renders as a native to-do card (config-nudge pattern for
the carrier, huddle-card pattern for state):
- todoCard.ts: sentinel extract/strip + type guards (never throws;
malformed payloads fall back to prose) and reduceTodoResponses, a
pure fold over kind:40009 events — latest response per (item, pubkey)
wins, so only a completer can un-check their own completion;
assignee's response takes precedence, non-assignee completions are
allowed and attributed.
- cardResponses.ts: sendCardResponse signs {done} with the clicking
user's key (tags h/e/item) and subscribeToCardResponses replays
per-card history scoped by #e — composes relayClientSession's public
surface instead of growing the size-ratcheted client.
- TodoCardAttachment.tsx: per-card subscription + fold, optimistic
pending state, per-item completer avatar/name, n-of-m progress.
- MessageRow renders the card in place of the prose fallback whenever
a channelId is available; every other surface (drafts, previews,
inbox) keeps showing the prose + fence.
- KIND_CARD_RESPONSE stays out of all timeline/unread kind sets:
responses are not rows and must never create unreads.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Matt Dickenson <mdickenson@squareup.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Renders interactive
buzz:todo-cardmessages in the desktop client. A```buzz:todo-cardfenced JSON sentinel inside an ordinary stream message (kind:9 / kind:40002) now renders as a native checklist card with per-item check-offs; every other surface (drafts, previews, inbox) and any client that doesn't understand the fence keeps showing the prose fallback.desktop/src/features/messages/lib/todoCard.ts— sentinel extract/strip + type guards (never throws; malformed/over-cap/wrong-version payloads fall back to prose), andreduceTodoResponses, a pure fold over kind:40009 events: latest response per (item, pubkey) wins; an assignee's response is authoritative for their item; non-assignee completions are allowed and attributed; un-check only retracts your own completion.desktop/src/shared/api/cardResponses.ts—sendCardResponsesigns{done}with the clicking user's key (tagsh/e/item);subscribeToCardResponsesreplays per-card history scoped by#e. ComposesrelayClientSession's public surface instead of growing the size-ratcheted client.desktop/src/features/messages/ui/TodoCardAttachment.tsx— per-card live subscription + fold, optimistic pending state while a publish is in flight, per-item completer avatar/name, n-of-m progress.desktop/src/features/messages/ui/MessageRow.tsx— renders the card in place of the prose fallback whenever achannelIdis available.desktop/src/shared/constants/kinds.ts— addsKIND_CARD_RESPONSE(40009) but keeps it out of all timeline/unread/mention kind sets: responses are not rows and must never create unreads.Why
Checklists posted as prose can't be checked off, attributed, or kept in sync across viewers. Embedding the card in a normal message (config-nudge sentinel pattern for the carrier, huddle-card fold pattern for state) keeps delivery, threading, unreads, and permissions exactly as they are — the relay stores nothing card-specific.
Test evidence (run on this branch at 34d51c5)
pnpm typecheck(tsc --noEmit): cleanpnpm test(node test runner): 4314 pass, 0 fail across 63 suitestodoCard.test.mjs: 28 tests, all passing (sentinel parsing/fallback edge cases + fold semantics)Stack
maindirectly.Spec:
docs/nips/NIP-TC.md(in #4929).🤖 Generated with Claude Code