Skip to content

feat(rooms): a member may let a portal send messages and reactions in a room without asking while it is open - #457

Merged
stormer78 merged 1 commit into
mainfrom
feat/room-session-write-grant
Nov 26, 2026
Merged

stormer78 merged 1 commit into
mainfrom
feat/room-session-write-grant

Conversation

@stormer78

Copy link
Copy Markdown
Contributor

Requested by the user: a portal chat should not need a confirm window for every message while the member is in the room.

What

A message's or reaction's confirm offers an unticked box: "Send messages and reactions in without asking while this room is open in ". Ticking it creates a session grant (src/room-session-grant.ts), the second bounded exception to "every page write is confirmed", after #455's reaction grant.

Lifetime: what "while this room is open" means

  • Bound to one page document: tab.id plus the browser's documentId (pageSessionOf), read from the sender of both the rooms.* call and the ROOM_WATCH_PAGE_PORT. A reload or navigation is a new document and asks again.
  • Open = holding a watch: the grant lives only while that document holds a watch port on that room (roomOpened, counted per document and room). The portal's room page keeps one open while it shows the room and stop()s it on leaving. The last port closing ends the grant: leaving the room, closing the tab, reloading, navigating away, or the extension's background worker being stopped.
  • Also ends on: tabs.onRemoved; the share ending (reviewSessionGrants on any share-storage change); 30 minutes with no write under it; 8 hours from the confirm however used; the wallet locking (RUNTIME_LOCK_WALLET); Stop in the console.
  • Offered only while the room is open in the asking document, so nothing ever lacks an end.

Scope

  • Covered: putMessage (replies too), react and unreact for the same origin, community, VTA, room and member.
  • Never covered: notes, files, any other write.
  • Gates still apply: gates 1–3, recordMembersNotListed and value validation.
  • Rate limit: more than 10 writes in a rolling minute, or a message over 4,000 characters, is confirmed as usual and the grant stays. MAX_BODY is 1 MiB and already refuses outright, so a chat-sized bound is used instead.

Visibility

  • Storage: held in the background's memory only, never stored.
  • Action icon: while any grant is live, the tooltip names the rooms and the badge reads LIVE (green). It ranks below a waiting approval and above the room-offers count.
  • Console: the Communities tab shows "Sends without asking while open · Stop" beside the share, via RUNTIME_ROOM_SESSION_GRANTS (extension pages only).
  • Page: it can't ask for, see or extend a grant; the page contract is unchanged. sessionGrant crosses the consent window only with an approval, from a prompt that offered it.

Deviations

  • Grant ends with the background worker: a grant ends if Chrome stops the extension's background worker. The page's 20 s ping keeps it alive in a visible tab; in a tab hidden for more than 5 minutes the worker can stop, which drops the port, so the member is asked again. Storing the grant to survive that would detach it from the open-room signal, so the grant ends by design.
  • Reload ends it (the default in the brief): a reload is a new documentId.

Rules

CLAUDE.md: gate 4, the "no remember" sentence and the reaction-grant section now name this exception precisely. "What breaks it" adds: widening the grant to notes, files or other writes; letting it outlive the document (storing it, keying it by tab alone); lifting its idle limit, cap or rate limit; removing the badge or tooltip; renewing it without a confirm.

Tests

tests/room-page-session-grant.test.mts, 11 tests:

  • The box is offered only while the room is open.
  • Only the box grants; a denial grants nothing, including at the consent window.
  • Covered writes skip the window; notes are still confirmed.
  • Another room, member, origin, VTA, tab or reloaded document asks again.
  • Each of these ends it: the port closing, two ports closing (the last one ends it), tab close, lock, Stop, share revoked, 30 min idle, 8 h cap.
  • The rate limit and long message fall back to the confirm while keeping the grant.
  • The badge is notified on start and end.

Lint, build and check-task-versions pass; all workspace tests pass (extension 1623, core 1348).

… a room without asking while it is open

Every page write is confirmed in the wallet's own window, so a portal chat
asked for a confirm on every message. A message's or a reaction's confirm now
offers an unticked box: "Send messages and reactions in <room> without asking
while this room is open".

- Bound to one page document: the tab and the browser's `documentId`
  (`pageSessionOf`), taken from the call's and the watch port's sender. A
  reload or navigation is a new document and asks again.
- "While this room is open" is the document holding a `rooms.watch` port on
  that room (`roomOpened`): the last port closing (leaving the room, the tab
  closing, a reload, the worker sleeping) ends it. Offered only while one is.
- Covers `putMessage` (replies too), `react` and `unreact` for that origin,
  community, VTA, room and member; never notes, files or other writes. Gates
  1-3, `recordMembersNotListed` and the value checks still apply.
- Also ends on `tabs.onRemoved`, the share ending (`reviewSessionGrants` on any
  share change), 30 minutes idle, 8 hours from the confirm however used, the
  wallet locking, or Stop in the Communities tab.
- More than 10 writes in a rolling minute, or a message over 4,000 characters,
  is confirmed as usual; the grant stays.
- Held in the background's memory only, never stored. While any is live the
  action's tooltip names the rooms and the badge reads LIVE.
- The page cannot ask for, see or extend it; the page contract is unchanged.
- CLAUDE.md names this second bounded exception, and widening it joins "What
  breaks it".

Signed-off-by: Glenn Gore <glenn.g@affinidi.com>
@stormer78
stormer78 merged commit 6b3d4da into main Nov 26, 2026
4 checks passed
@stormer78
stormer78 deleted the feat/room-session-write-grant branch November 26, 2026 07:29
stormer78 added a commit to OpenVTC/verifiable-trust-infrastructure that referenced this pull request Nov 26, 2026
…e wallet's session grant (#2836)

OpenVTC/vta-browser-plugin#457 adds a second bounded exception to "every page
write is confirmed": messages and reactions while the one page holds the room
open through its watch. The portal needs no code change (the page contract is
unchanged); the portal-rooms rule now names the grant and says to keep the
watch held for exactly as long as the room is shown, since its closing ends the
grant.

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