Skip to content

feat(polls): implement MSC3381 polls#589

Open
Just-Insane wants to merge 8 commits intoSableClient:devfrom
Just-Insane:feat/polls
Open

feat(polls): implement MSC3381 polls#589
Just-Insane wants to merge 8 commits intoSableClient:devfrom
Just-Insane:feat/polls

Conversation

@Just-Insane
Copy link
Copy Markdown
Contributor

@Just-Insane Just-Insane commented Mar 29, 2026

Description

⚠️ Merge together with SableClient/docs#12

Implements Matrix polls (MSC3381) with a creator dialog and timeline renderer.

  • New PollCreatorDialog — question, 2–20 answers, disclosed/undisclosed type, voter visibility toggle (show/hide voter names), poll duration (presets: 1h / 12h / 24h / 48h / 1 week / custom date-time)
  • New PollEvent timeline renderer — vote buttons, live/final results bars, expandable voter lists per answer, expiry countdown in footer, auto-expire enforcement, end-poll action
  • usePoll hook — assembles poll state from org.matrix.msc3381.poll.start, .poll.response, and .poll.end events via paginated room timeline; respects show_voter_names and closes_at fields
  • Poll button in RoomInput, gated by features.polls in config.json (defaults false)

Spec: MSC3381
Related upstream issue: cinnyapp/cinny#563
Documentation: SableClient/docs#12

Fixes #

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings

AI disclosure:

  • Partially AI assisted (clarify which code was AI assisted and briefly explain what it does).
  • Fully AI generated (explain what all the generated code does in moderate detail).

usePoll paginates the room timeline to collect poll.response events keyed by sender, deduplicating so only the last vote per user counts, and tallies totals and percentages. PollEvent renders the resulting state as vote buttons with fill-bars; it re-fetches on RoomEvent.Timeline so it stays live. PollCreatorDialog builds the m.poll.start content with crypto.randomUUID() answer IDs and sends via mx.sendEvent. The poll button in RoomInput is conditionally rendered based on clientConfig.features?.polls. The show_voter_names flag is a client-side display hint stored in the poll start event; the closes_at field is a Unix ms timestamp enforced client-side (voting blocked after expiry, UI shows countdown).

- Replace async usePoll hook (race condition → black screen → reload)
  with synchronous RelationsContainer.getAllChildEventsForEvent()
- Rewrite PollEvent to use Attachment/AttachmentHeader/AttachmentBox
  layout matching Sable design; use folds ProgressBar + RadioButton
- Replace toolbar ChartBarHorizontal button with /poll slash command
- Add Command.Poll to useCommands enum and autocomplete
- Delete usePoll.ts (no longer used)
- Pass outlined prop based on message layout (bubble vs default)
@Just-Insane Just-Insane marked this pull request as ready for review March 30, 2026 13:46
@dozro
Copy link
Copy Markdown
Member

dozro commented Mar 30, 2026

is it using the ui you showed in matrix chat or the ui of cinnyapp/cinny#2763 ?

@Just-Insane
Copy link
Copy Markdown
Contributor Author

is it using the ui you showed in matrix chat or the ui of cinnyapp/cinny#2763 ?

The UI from Cinny

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants