@poolse/react 3.7.1 → 3.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,45 @@ All notable changes to `@poolse/react` are documented here. Format follows
4
4
  [Keep a Changelog](https://keepachangelog.com/en/1.1.0/); versions follow
5
5
  [semver](https://semver.org).
6
6
 
7
+ ## [3.9.0] - 2026-11-22
8
+
9
+ ### Added
10
+
11
+ - `useRecording(callId, conversationId, initial?)` — recording and consent
12
+ state from the call snapshot (late joiners see it at once) kept live by
13
+ events: `available`, `active`, `capturing`, `consentRequired`, `myConsent`,
14
+ `needsConsent`, `notice`, `lastRecording`, `start(mode?)`, `stop()`,
15
+ `consent(decision)`, `pending`, `error`.
16
+ - `useLiveTranscript(callId, { enabled?, maxSegments? })` — the live
17
+ transcript topic: `segments` / `finals` / `interim`, `transcript`, `live`,
18
+ `joined`, `start()`, `stop()`.
19
+ - `useTranscript(callId)` (`transcript`, `missing`, `renameSpeakers`, live
20
+ `transcript:speakers`), `useTranscripts(conversationId)`,
21
+ `useRecordings(conversationId)`.
22
+ - `useLiveCall().call.recording` / `.transcription` follow the events.
23
+ - `useCallRoom`: `canPublish`, `republish()`, `republishOnPermission` option.
24
+
25
+ ## [3.8.0] - 2026-11-21
26
+
27
+ ### Added
28
+
29
+ - `<PoolseProvider client={…}>` takes a client it never destroys (several
30
+ workspaces side by side; a hidden or unmounted provider keeps its client
31
+ connected and warm) and `background` (`client.setBackground`). `config`
32
+ is optional when `client` is given.
33
+ - The conversation store lives with the client, so a remounted provider is
34
+ warm; its rows feed `client.unread` and `client.cache`.
35
+ - `useMessages`: cached history at once (`fromCache`), readable offline;
36
+ sends through the outbox with `retry(id)` / `discard(id)`.
37
+ - `useUnreadTotals(client?)`, `useUnreadQueue()` / `orderUnread`,
38
+ `useOutbox()`, `useClientTimings()`, `filterConversations()`. Re-exports
39
+ `Poolse`, `createIndexedDbStorage`, `memoryStorage`, `MessageQueuedError`.
40
+
41
+ ### Changed
42
+
43
+ - A send that fails no longer disappears: queued offline, or kept as failed
44
+ (see `@poolse/sdk` `outbox`). `outbox: false` restores the old behaviour.
45
+
7
46
  ## [3.7.1] - 2026-11-21
8
47
 
9
48
  - No changes; released with the other `@poolse/*` packages at 3.7.1.
package/README.md CHANGED
@@ -60,31 +60,58 @@ The provider creates one `Poolse` instance per mount. Function options are
60
60
  read through a ref, so new closures on each render are fine. Remount with a
61
61
  new `key` to switch user.
62
62
 
63
+ ### Several workspaces
64
+
65
+ Create one client per workspace outside React and hand each to its own
66
+ provider. Providers side by side never share state, and a provider never
67
+ destroys a client it was given — unmounting or hiding a workspace keeps its
68
+ socket and its warm cache, so switching back is a view change:
69
+
70
+ ```tsx
71
+ <PoolseProvider client={acme} background={current !== acme}>
72
+ <Workspace />
73
+ </PoolseProvider>
74
+ ```
75
+
76
+ The conversation list store lives with the client (`chat.scoped`), so a
77
+ remounted provider shows it at once; `useMessages` shows the client's cached
78
+ messages at once (`fromCache: true`) while the page refetches. `background`
79
+ closes the socket while true (phones; leave it unset on desktop). Sign out
80
+ of one with `client.destroy({ clearStorage: true })`.
81
+
63
82
  ## Hooks
64
83
 
65
- | Hook | Returns |
66
- | -------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
67
- | `usePoolse()` | The `Poolse` instance. |
68
- | `useMe()` | `{ me, loading, error }` |
69
- | `useConversation(id \| null)` | `{ conversation, loading, error, refetch }` |
70
- | `useConversations()` | `{ conversations, loading, error, refetch, hasMore, loadingMore, loadMore, create, unreadCounts, mentionUnreadCounts, markConversationRead }` |
71
- | `useMessages(conversationId)` | `{ messages, loading, error, hasMore, loadMore, loadUntil(messageId), send, edit, delete, markReadUpTo, refetch }`, oldest first |
72
- | `useThread(conversationId, rootId)` | `{ replies, loading, error, hasMore, loadMore, sendReply, edit, delete }` |
73
- | `useReactions(messageId, { conversationId, initialReactions?, currentUserId? })` | `{ reactions, addReaction, removeReaction }` |
74
- | `useTyping(conversationId)` | `{ typing: Set<externalId>, signalTyping }` |
75
- | `usePresence(conversationId)` / `useConversationPresence` | `{ online: Set<externalId> }` — who has the conversation open |
76
- | `useUserPresence(id \| null)` | `Presence \| null` — `state`: `online`, `away`, `in_call`, `offline` |
77
- | `usePresenceMany(ids)` | `Record<id, Presence>` (known ids only) |
78
- | `useMembers(conversationId)` | `{ members, loading, error, refetch, addMembers(externalIds, { role? }), removeMember(externalId) }` |
79
- | `useAttachmentUpload()` | `{ queue, attachment, uploading, error, upload(input), uploadAll(inputs), cancel(localId), remove(localId), reset }` |
80
- | `useAttachmentUrl(id \| null)` | `{ url, loading, error }` (not renewed; URLs last one hour) |
81
- | `useUser(externalId)` | `{ profile, loading }` |
82
- | `useAppEvent(handler)` | Calls `handler({ type, data })` for each `app:event` sent to the user |
83
- | `useRealtimeStatus()` | `'idle' \| 'connecting' \| 'connected' \| 'reconnecting' \| 'closed'` |
84
- | `useReadReceipts()` | `{ visible, mode, shared, canChange, setShared }` |
85
- | `useLiveCall(conversationId \| null)` | `{ call, participantIds, refresh }` |
86
- | `useRoom(conversationId \| null, { livekit })` | `{ live, presentIds, joined, joining, join, leave, media, error }` |
87
- | `useCallRoom(conversationId \| null, { livekit, … })` | Call media: participants, mic, camera, devices |
84
+ | Hook | Returns |
85
+ | -------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
86
+ | `usePoolse()` | The `Poolse` instance. |
87
+ | `useMe()` | `{ me, loading, error }` |
88
+ | `useConversation(id \| null)` | `{ conversation, loading, error, refetch }` |
89
+ | `useConversations()` | `{ conversations, loading, error, refetch, hasMore, loadingMore, loadMore, create, unreadCounts, mentionUnreadCounts, markConversationRead }` |
90
+ | `useUnreadTotals(client?)` | `{ unread, mentions, conversations, source, loading, error, refresh }` for one client, live — pass a client to read one outside its provider (a workspace rail) |
91
+ | `useUnreadQueue({ mentionsFirst?, filter? })` | `{ queue, current, remaining, next(), skip(), markRead(id), reset() }` — unread conversations by latest activity; `next()` marks `current` read and moves on |
92
+ | `useOutbox({ conversationId?, client? })` | `{ entries, pending, failed, retry, remove, flush }` |
93
+ | `useClientTimings(client?)` | the client's `timings.get()`, re-rendering as timings land |
94
+ | `useMessages(conversationId)` | `{ messages, loading, error, hasMore, loadMore, loadUntil(messageId), send, retry(id), discard(id), edit, delete, markReadUpTo, fromCache, refetch }`, oldest first |
95
+ | `useThread(conversationId, rootId)` | `{ replies, loading, error, hasMore, loadMore, sendReply, edit, delete }` |
96
+ | `useReactions(messageId, { conversationId, initialReactions?, currentUserId? })` | `{ reactions, addReaction, removeReaction }` |
97
+ | `useTyping(conversationId)` | `{ typing: Set<externalId>, signalTyping }` |
98
+ | `usePresence(conversationId)` / `useConversationPresence` | `{ online: Set<externalId> }` — who has the conversation open |
99
+ | `useUserPresence(id \| null)` | `Presence \| null` — `state`: `online`, `away`, `in_call`, `offline` |
100
+ | `usePresenceMany(ids)` | `Record<id, Presence>` (known ids only) |
101
+ | `useMembers(conversationId)` | `{ members, loading, error, refetch, addMembers(externalIds, { role? }), removeMember(externalId) }` |
102
+ | `useAttachmentUpload()` | `{ queue, attachment, uploading, error, upload(input), uploadAll(inputs), cancel(localId), remove(localId), reset }` |
103
+ | `useAttachmentUrl(id \| null)` | `{ url, loading, error }` (not renewed; URLs last one hour) |
104
+ | `useUser(externalId)` | `{ profile, loading }` |
105
+ | `useAppEvent(handler)` | Calls `handler({ type, data })` for each `app:event` sent to the user |
106
+ | `useRealtimeStatus()` | `'idle' \| 'connecting' \| 'connected' \| 'reconnecting' \| 'closed'` |
107
+ | `useReadReceipts()` | `{ visible, mode, shared, canChange, setShared }` |
108
+ | `useLiveCall(conversationId \| null)` | `{ call, participantIds, refresh }` |
109
+ | `useRoom(conversationId \| null, { livekit })` | `{ live, presentIds, joined, joining, join, leave, media, error }` |
110
+ | `useCallRoom(conversationId \| null, { livekit, … })` | Call media: participants, mic, camera, devices, `canPublish`, `republish()` |
111
+ | `useRecording(callId, conversationId, initial?)` | `{ available, active, capturing, consentRequired, myConsent, needsConsent, notice, lastRecording, start(mode?), stop, consent(decision), pending, error }` |
112
+ | `useLiveTranscript(callId, { enabled? })` | `{ segments, finals, interim, transcript, live, joined, start, stop, error }` — the call's live transcript topic |
113
+ | `useTranscript(callId)` | `{ transcript, loading, missing, error, renameSpeakers(names), refresh }` |
114
+ | `useTranscripts(conversationId)` / `useRecordings(conversationId)` | `{ items, loading, error, refresh }`, newest first, re-read as they change |
88
115
 
89
116
  Helpers: `canEditOwnMessage`, `EDIT_WINDOW_MS`, `receiptsOf`,
90
117
  `computeGroupPosition`, `sameGroup`, `sameDay`, `formatDayLabel`, plus
@@ -95,8 +122,12 @@ Notes that trip people up:
95
122
  - `useTyping`, `usePresence`, `useUser` and `useMembers().removeMember` use
96
123
  **your** user ids (`external_id`). `useReactions`' `currentUserId` and the
97
124
  `reactions` map use **poolse** user ids (`me.id`).
98
- - `useMessages().send` removes the optimistic row and rejects if the request
99
- fails.
125
+ - `useMessages().send` goes through the client's outbox (3.8): offline, the
126
+ row stays as `local_status: 'queued'` and goes out on reconnect (the promise
127
+ rejects with `MessageQueuedError` — not a failure to show); refused (4xx), it
128
+ stays as `'failed'` with `local_error` until `retry(id)` / `discard(id)`.
129
+ With `outbox: false` in the config it removes the row and rejects, as
130
+ before. Thread replies (`useThread`) don't use the outbox yet.
100
131
  - `useAttachmentUpload().upload` takes `{ body, contentType, byteSize, filename? }`,
101
132
  not a bare `File`. Send `item.attachment.id`, not `item.localId`.
102
133
  - From 3.1, `useMessages` (the newest 50, merged in) and `useConversations`