Skip to content

Live updates and full lists for things shared out of other drives - #1949

Closed
joepio wants to merge 4 commits into
developfrom
claude/shared-resource-live
Closed

joepio wants to merge 4 commits into
developfrom
claude/shared-resource-live

Conversation

@joepio

@joepio joepio commented Oct 1, 2026 •

Copy link
Copy Markdown
Member

Requested by Joep · project thread

Split out of #1866 per review. Changes sync and server behaviour, so it needs its own review.

Before: a guest in a chat shared from someone else's drive (shared as a resource, not the whole drive) saw only their own messages and the ones present when they joined, even after a reload. The host's later messages never arrived live, so the guest got no notifications either. Found by testing #1866 with two browsers.

After: the guest sees the whole chat, gets new messages live, is notified while the app is open, and host and guest see each other's presence (who's here, who's typing) in the shared chat.

How:

  • Server (commit_monitor.rs): a commit is also sent to subscribers of the resource's parent. The guest can't subscribe to the host's drive, and a new message is a new subject, so neither the resource subscription nor a drive subscription reached them. Read rights are checked per subscriber against the resource at send time, since the subscription was admitted on the parent and access can be taken back. That runs under ctx.wait, so delivery stays in order with the commits that follow. A connection already reached through the resource itself or its drive is skipped, so nothing arrives twice.
  • Store.subscribeLive(subject): holds a per-resource SUB, counted and re-sent on reconnect (WSClient.subscribeResource / unsubscribeResource). MessageNotifier holds one for everything in Shared with me while the app runs.
  • Collection: a non-empty local answer was always trusted, but only a synced drive has its whole membership in the local DB. For a drive this client hasn't synced, the server is asked once per page per session. Its members are written locally as they load, and live updates keep them current after that. Members only the local DB knows (writes not yet acknowledged) are kept. Synced drives make no extra request, which keeps the invariant the count probe was reverted for (fix: everything found running two sync nodes against each other #1286).
  • Presence scoped to shared resources: presence was one channel per drive, which the guest can't read. The server refused them ("presence update from non-subscriber"). Store.presenceScope(subject) finds the nearest loaded resource at or above it with its own read list, which is what an invite or share writes to. Host and guest compute it from the same data, and the server already accepts presence on any readable subject. useResourcePresence and useTypingPresence announce in both the drive's channel and that one, and read both. useDrivePresenceManager skips the drive channel when the drive is unauthorized; FollowContext uses it too. All managers share one presenceSessionId per tab, so a session in both channels shows once.

Checklist

  • Changelog entries (CHANGELOG.md, browser/CHANGELOG.md)
  • Tests:
    • server/tests/it/ws_parent_fanout.rs covers delivery, a sibling the guest can't read, one frame for a connection on both child and parent, and no delivery after read is revoked. The last two fail without the send-time check; all 22 ws_ integration tests pass.
    • collection-partial-local.test.ts checks the server is asked for an unsynced drive, only once per query, and not at all for a synced one.
    • collection-sort-order.test.ts checks that a pending local row survives.
    • store.subscribe-live.test.ts covers the counting.
    • store.presence-scope.test.ts covers the share root, a message in it, and the rest of the drive staying on the drive channel. The lib, react and data-browser suites pass.

A guest in a chat shared from someone else's drive saw only their own
messages and the ones present when they joined, got none of the host's
later messages live, and so got no notifications for them.

- Server: a commit is also sent to WebSocket subscribers of the
  resource's parent. The guest can't subscribe to the host's drive, and
  a new message is a new subject, so neither the resource nor the drive
  subscription reached them. Read rights are checked per subscriber
  against the resource at send time (the subscription was admitted on
  the parent, and access can be taken back since), under ctx.wait so it
  stays in order with later commits. A connection already reached
  through the resource itself or its drive is skipped, so nothing
  arrives twice.
- Store.subscribeLive holds a per-resource SUB, counted and re-sent on
  reconnect. MessageNotifier holds one for everything in Shared with me
  while the app runs.
- Collection: a non-empty local answer was always trusted, but only a
  synced drive has its whole membership locally. For a drive this
  client hasn't synced the server is asked once per page per session;
  its members are written locally as they load and live updates keep
  them current. Members only the local DB knows (writes not yet
  acknowledged) are kept. Synced drives make no extra request.

ws_parent_fanout covers delivery, a sibling the guest can't read, one
frame for a connection on both child and parent, and no delivery after
read is revoked; the last two fail on the version without the send-time
check.
"shows a fetched external class for a partial name" timed out at 5 s in
CI (run 36813877203) though it takes a few milliseconds: as the first
render in the file it paid styled-components building its stylesheet,
jsdom parsing it and the picker's modules running for the first time.
The same fix as cb085dc for the table grid.
joepio added a commit that referenced this pull request Oct 1, 2026
…turn (#1866)

The Notifications page shows one row per conversation, a window coming back into focus reads what arrived on the page you are on, and the app offers system notifications once after missed messages. planning/notifications.md plans the next phases. The WebSocket parent fan-out and the Collection change for unsynced drives live in #1949.
joepio added 2 commits October 1, 2026 14:09
…/shared-resource-live

# Conflicts:
#	browser/CHANGELOG.md
Presence was one channel per drive. A guest given one chat out of a
drive they can't read was refused that channel ("presence update from
non-subscriber" on the server), so host and guest never saw each other
in the chat, nor who was typing.

- Store.presenceScope(subject): the nearest loaded resource at or
  above it with its own read list, below the drive. That's what an
  invite or a share writes to, and host and guest compute it from the
  same data. The server already accepts presence on any subject the
  agent can read.
- useResourcePresence and useTypingPresence announce in the drive
  channel and in that scope's channel, and read both.
- useDrivePresenceManager leaves the drive channel out when the drive
  is unauthorized; FollowContext uses it too.
- One presenceSessionId per tab across all managers, so a session in
  both channels is one entry, and filtering out our own is one check.

joepio commented Oct 5, 2026

Copy link
Copy Markdown
Member Author

Landed on develop in the combined batch #2060 (95707c0), tested together in one full run. Closing as included.


Generated by Claude Code

@joepio joepio closed this Oct 5, 2026
joepio added a commit that referenced this pull request Oct 5, 2026
Two people can message each other in a conversation only they can read.
The server that hosts it stores ciphertext; it still checks every write,
because the rights and signatures it needs stay readable.

- atomic_lib::conversation: an agent's X25519 encryption key, derived from
  its vault proof so every device has the same one; a keyring with one key
  per epoch, wrapped to each member; sealing and opening messages, bound to
  the conversation; report-by-reveal of a single message key. WASM exports
  for the browser.
- Ontology `conversations`: Conversation, SealedMessage, encryptionKey,
  conversationKeys, sealed, conversations.
- GET /conversations lists the conversations on the server the requester
  is in, so the other person finds one they did not start.
- A conversation is its own drive with read + append for its members and
  no writer, so nobody can change what someone else said.
- App: Messages section in the sidebar, "Message" on every avatar, a New
  message dialog, and the conversation page, which opens each message
  before ChatView shows it. Store.subscribeLive (as in #1949) keeps the
  conversation live. The app publishes the agent's key at start.
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