Skip to content

feat(rooms): a room page can reply, react and be told the room changed (rooms.react, rooms.unreact, rooms.watch) - #454

Merged
stormer78 merged 1 commit into
mainfrom
feat/rooms-page-reply-react-watch
Nov 25, 2026
Merged

stormer78 merged 1 commit into
mainfrom
feat/rooms-page-reply-react-watch

Conversation

@stormer78

Copy link
Copy Markdown
Contributor

The VTC member portal shows a room as a conversation and can send a message, but it can't reply, react, or learn the room moved without a refresh button. This adds what the portal needs from the wallet, behind the same gates as every room call: the community's portal by its DID document, and a room the member shared with it.

Replies and reactions

  • rooms.putMessage({ hostDid, roomId, body, replyTo?: { key, version? } }) writes inReplyTo.
  • rooms.react({ hostDid, roomId, key, version?, value }) writes a record of kind reaction: the value as body, naming the record. That is exactly the shape assembleRoomRecords counts.
  • rooms.unreact({ hostDid, roomId, key, value }) writes an empty version over each of the member's own live reactions with that value on that record (ownReactions → withdrawReactionAsMember, over the version read), which only their author may. Answers { withdrawn }.
  • Room profile check: before the member is asked, the background reads the room's profile as the member. Where it doesn't list what the write needs (inReplyTo; kind + inReplyTo), the call is refused with a new wallet code, recordMembersNotListed (added to page-error.ts and docs/page-bridge-errors.md). A reply is never sent without its inReplyTo. Core refuses the same way as a backstop (RecordWriteRefused.code).
  • Confirm window: each write is confirmed, with no "remember", per the existing rule. The window shows the record being answered or reacted to as the wallet read it (rooms/keys/read, glimpseOf), never the page's description.

Change signal

  • rooms.watch({ hostDid, roomId, sinceVersion? }, onEvent) → { read(version?), stop() }.
  • Port: one ROOM_WATCH_PAGE_PORT per watch, relayed by the content script like roomFile frames. The background checks the port's attested origin and the share, then holds the watch in one shared RoomWatcher, so two tabs share a room's watch.
  • Arming: armed through the member's VTA (rooms/keys/watch/0.1, offscreen watch op), and armed again only after a read the page reports.
  • Signal: the room's rooms/keys/changed, taken only from the offscreen document, is passed to the ports that armed it as { kind: "changed", latestVersion } and nothing else, after re-checking the share. Closing the port cancels the watch at the VTA (the last holder).
  • Keep-alive: the page pings every 20 s to keep the worker alive while it watches. A worker restart closes the port and the page watches again.
  • Not a broadcast: this deliberately does not use RUNTIME_BROADCAST_EVENT, which reaches every tab of every origin.

Older wallets have none of these methods; a page feature-detects them.

Tests

  • core tests/rooms.reply-react.mjs (12)
  • extension tests/room-page-reply-react-watch.test.mts (22): shapes, the profile check before any prompt, confirm contents, share/origin refusals, watch arm/fire/re-arm/cancel, a shared watch, a share withdrawn mid-watch, no VTA support → unavailable, offscreen react/unreact/watch, content-script port-name parity
  • full gates: npm run lint, npm test (123 / 1348 / 1600 / 6 / 9, all pass), npm run build

…d (rooms.react, rooms.unreact, rooms.watch)

The member portal can send a message but not answer one, react, or learn a
room moved without a refresh button. Three additions to the page's
`window.vtaWallet.rooms`, behind the same gates as every room call (the
community's portal by its DID document, a room the member shared with it):

- `putMessage({ replyTo })` writes `inReplyTo`; `react` writes a record of
  kind `reaction` naming the record (the shape `assembleRoomRecords` counts);
  `unreact` writes an empty version over each of the member's own live
  reactions with that value (`ownReactions`, `withdrawReactionAsMember`).
  Where the room's profile does not list what the write needs, the wallet
  refuses with the new code `recordMembersNotListed` before the member is
  asked — never writing a reply without `inReplyTo`. Each is confirmed in the
  wallet's window, which shows the record answered or reacted to as the
  wallet read it, never the page's word.
- `watch` opens a port per room: the background arms a watch through the
  member's VTA (`rooms/keys/watch/0.1`) in one shared `RoomWatcher`, passes
  the room's `rooms/keys/changed` on to the ports that armed it — that it
  moved and to which version, nothing more — re-arms after each read the page
  reports, and cancels when the port closes. The page pings the port while it
  watches. Older wallets have none of these; a page feature-detects them.

Signed-off-by: Glenn Gore <glenn.g@affinidi.com>
@stormer78
stormer78 merged commit fa2b4b2 into main Nov 25, 2026
4 checks passed
@stormer78
stormer78 deleted the feat/rooms-page-reply-react-watch branch November 25, 2026 23:52
stormer78 added a commit to OpenVTC/verifiable-trust-infrastructure that referenced this pull request Nov 26, 2026
…chat (#2828)

The portal's chat could only send a plain message, and a member had to press
refresh to see anyone else's. The wallet now replies, reacts and watches a room
(OpenVTC/vta-browser-plugin#454); the portal uses all three, feature-detected,
so an older wallet keeps today's chat.

- Reply: a message's actions (hover or focus; a tap on a phone) offer Reply;
  the composer names what is answered and sends it as `putMessage`'s
  `replyTo`.
- React: a small picker of reactions; a reaction chip the member added is
  theirs to take back (`unreact`). Counts, authors and "yours" are the
  wallet's reading; the page counts nothing. The wallet confirms each one.
- A room whose profile does not list what a reply or reaction needs answers
  `recordMembersNotListed` and writes nothing: the page says so, stops
  offering both, and offers the words as a plain message.
- Live: `room-live.ts` watches the room through the wallet, reads it again
  when told it moved and tells the watch what it read; while the wallet
  cannot watch it reads on a 20-second timer while the tab is visible, and
  watches again with backoff after a close. "Live" is derived from the latest
  event and drops the moment any other arrives (R6.2); a wallet without
  `watch` keeps the refresh button.

Signed-off-by: Glenn Gore <glenn.g@affinidi.com>
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.

1 participant