You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs: apply inline code formatting conventions to all doc pages
Add parentheses to all backticked function and hook references in prose
text across 24 doc pages, per the inline code formatting rules in the
docs skill (e.g. `useChat` → `useChat()`, `streamResponse` →
`streamResponse()`). Type and interface names remain without parens.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The transport automatically computes `forkOf` (the assistant message being replaced) and `parent` (the message before it). The server receives these in the POST body and passes them to `newTurn`.
39
+
The transport automatically computes `forkOf` (the assistant message being replaced) and `parent` (the message before it). The server receives these in the POST body and passes them to `newTurn()`.
@@ -106,7 +106,7 @@ Calling `select` updates the view's active branch and re-renders with the select
106
106
107
107
## Server handling
108
108
109
-
The server receives `forkOf` and `parent` in the POST body. Pass them through to `newTurn`:
109
+
The server receives `forkOf` and `parent` in the POST body. Pass them through to `newTurn()`:
110
110
111
111
```typescript
112
112
const { turnId, clientId, forkOf, parent, messages, history } =awaitreq.json();
@@ -130,7 +130,7 @@ The transport stamps `x-ably-parent` and `x-ably-fork-of` headers on the publish
130
130
131
131
With a single view, navigating to a different branch in one part of the UI changes what every other part sees. Split-pane comparison UIs need independent views so each pane can show a different branch of the same conversation without interfering with the other.
132
132
133
-
`useCreateView` has the same API as `useView` but creates an independent view instead of using the transport's default. The view is closed automatically when the component unmounts or the transport changes:
133
+
`useCreateView()` has the same API as `useView()` but creates an independent view instead of using the transport's default. The view is closed automatically when the component unmounts or the transport changes:
Both views share the same underlying tree - new messages from the server appear in both. But branch selections, pagination windows, and write operations are scoped to each view.
151
151
152
-
See [React hooks reference](../reference/react-hooks.md#usecreateview) for the full `useCreateView` API.
152
+
See [React hooks reference](../reference/react-hooks.md#usecreateview) for the full `useCreateView()` API.
See [Interruption](interruption.md) for cancel-then-send patterns. See [Error codes](../reference/error-codes.md) for cancel-related error codes. See [React hooks reference](../reference/react-hooks.md) for the `useActiveTurns` API. For the internal cancel routing and filter resolution, see [Cancel routing](../internals/transport-components.md#cancel-routing-server-transport).
117
+
See [Interruption](interruption.md) for cancel-then-send patterns. See [Error codes](../reference/error-codes.md) for cancel-related error codes. See [React hooks reference](../reference/react-hooks.md) for the `useActiveTurns()` API. For the internal cancel routing and filter resolution, see [Cancel routing](../internals/transport-components.md#cancel-routing-server-transport).
History messages carry the same `x-ably-parent` and `x-ably-fork-of` headers as live messages. When loaded, they're inserted into the conversation tree with their full branch structure intact. A client loading history sees the same tree of branches and can navigate siblings just like a client that was present for the original conversation.
68
68
69
-
Because the tree may contain multiple branches, the view's `flattenNodes()` returns only the messages along the currently selected path - not every message ever published. To see alternative branches, use `useView` or the view's `getSiblings()` / `select()` methods.
69
+
Because the tree may contain multiple branches, the view's `flattenNodes()` returns only the messages along the currently selected path - not every message ever published. To see alternative branches, use `useView()` or the view's `getSiblings()` / `select()` methods.
70
70
71
71
See [Conversation branching](branching.md) for the tree model.
// messages now includes messages from all clients on the channel
86
86
```
87
87
88
-
Without `useMessageSync`, `useChat` would only show messages from its own sends. The sync hook replaces `useChat`'s message state with the transport's authoritative list on every update.
88
+
Without `useMessageSync()`, `useChat()` would only show messages from its own sends. The sync hook replaces `useChat()`'s message state with the transport's authoritative list on every update.
**Multi-client ordering** - in a conversation with multiple clients sending concurrently, optimistic messages appear at the end of the local tree until reconciliation. After reconciliation, the serial determines the canonical order, which may differ from the optimistic insertion order. All clients converge on the same order once relays are reconciled.
80
80
81
-
**Cleanup** - the transport tracks optimistic msg-ids per turn. When a [turn](../concepts/turns.md) ends (via `x-ably-turn-end` on the channel), the tracking state for that turn is cleaned up. This prevents stale msg-ids from matching against unrelated messages in future turns.
81
+
**Cleanup** - the transport tracks optimistic message IDs per turn. When a [turn](../concepts/turns.md) ends (via `x-ably-turn-end` on the channel), the tracking state for that turn is cleaned up. This prevents stale message IDs from matching against unrelated messages in future turns.
82
82
83
83
For the internal implementation details, see [Client transport: optimistic reconciliation](../internals/client-transport.md#optimistic-reconciliation), [Conversation tree: upsert](../internals/conversation-tree.md#upsert-the-sole-mutation), and [Wire protocol: message identity](../internals/wire-protocol.md#message-identity-x-ably-msg-id).
Copy file name to clipboardExpand all lines: docs/features/streaming.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -36,7 +36,7 @@ Each stream has a lifecycle tracked by the `x-ably-status` header:
36
36
37
37
## Server
38
38
39
-
Pipe any `ReadableStream` of codec events through the turn's `streamResponse`:
39
+
Pipe any `ReadableStream` of codec events through the turn's `streamResponse()`:
40
40
41
41
```typescript
42
42
import { streamText } from'ai';
@@ -57,7 +57,7 @@ await turn.end(reason);
57
57
transport.close();
58
58
```
59
59
60
-
`streamResponse` reads events from the stream and routes them through the encoder. Text deltas become message appends; lifecycle events (finish, error) become discrete messages that close the stream.
60
+
`streamResponse()` reads events from the stream and routes them through the encoder. Text deltas become message appends; lifecycle events (finish, error) become discrete messages that close the stream.
61
61
62
62
## Client
63
63
@@ -78,7 +78,7 @@ This is the primary consumption path. In React, the `useView()` hook handles the
78
78
79
79
### The event stream
80
80
81
-
`send()` also returns a `ReadableStream<TEvent>` on the `ActiveTurn`. This exists as an integration seam for framework adapters - Vercel's `useChat` expects a `ReadableStream` as its transport contract. Most application code should use the view instead, since the accumulator provides the same per-token granularity.
81
+
`send()` also returns a `ReadableStream<TEvent>` on the `ActiveTurn`. This exists as an integration seam for framework adapters - Vercel's `useChat()` expects a `ReadableStream` as its transport contract. Most application code should use the view instead, since the accumulator provides the same per-token granularity.
82
82
83
83
```typescript
84
84
// Framework adapter usage - most apps won't consume this directly
@@ -112,4 +112,4 @@ The transport streams whatever events the codec produces. For the Vercel AI SDK
112
112
113
113
Multiple content streams can be active within a single turn (e.g., reasoning + text). Each gets its own message with its own stream ID.
114
114
115
-
See [Tool calling](tool-calling.md) for how tool input deltas and results are streamed. See [React hooks reference](../reference/react-hooks.md) for the full `useView` and `useClientTransport` API. See [Cancel](cancel.md) for how streams are aborted. For the internal mechanics of message encoding, decoding, and recovery, see the [Encoder](../internals/encoder.md), [Decoder](../internals/decoder.md), and [Wire protocol](../internals/wire-protocol.md) internals pages.
115
+
See [Tool calling](tool-calling.md) for how tool input deltas and results are streamed. See [React hooks reference](../reference/react-hooks.md) for the full `useView()` and `useClientTransport()` API. See [Cancel](cancel.md) for how streams are aborted. For the internal mechanics of message encoding, decoding, and recovery, see the [Encoder](../internals/encoder.md), [Decoder](../internals/decoder.md), and [Wire protocol](../internals/wire-protocol.md) internals pages.
Copy file name to clipboardExpand all lines: docs/frameworks/vercel-ai-sdk.md
+10-10Lines changed: 10 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Vercel AI SDK
2
2
3
-
The Vercel AI SDK provides model abstraction, streaming primitives, and React hooks (`useChat`) for building AI applications. AI Transport adds a durable real-time layer underneath - streaming over Ably channels instead of direct HTTP, with persistence, multi-client sync, and cancellation built in.
3
+
The Vercel AI SDK provides model abstraction, streaming primitives, and React hooks (`useChat()`) for building AI applications. AI Transport adds a durable real-time layer underneath - streaming over Ably channels instead of direct HTTP, with persistence, multi-client sync, and cancellation built in.
4
4
5
5
## What AI Transport adds
6
6
@@ -17,7 +17,7 @@ The Vercel AI SDK provides model abstraction, streaming primitives, and React ho
17
17
18
18
### useChat path (simpler)
19
19
20
-
Wrap the transport in a `ChatTransport` adapter and pass it to Vercel's `useChat`. Message state is managed by `useChat` - the transport delivers messages over Ably instead of HTTP.
20
+
Wrap the transport in a `ChatTransport` adapter and pass it to Vercel's `useChat()`. Message state is managed by `useChat()` - the transport delivers messages over Ably instead of HTTP.
`useChatTransport` wraps the core transport into the `ChatTransport` interface that `useChat` expects. `useMessageSync` pushes the transport's authoritative message list into `useChat`'s state - this is how messages from other clients appear.
40
+
`useChatTransport()` wraps the core transport into the `ChatTransport` interface that `useChat()` expects. `useMessageSync()` pushes the transport's authoritative message list into `useChat()`'s state - this is how messages from other clients appear.
41
41
42
42
### Generic hooks path (more control)
43
43
44
-
Use the generic React hooks directly. You manage message state through the transport's conversation tree instead of `useChat`.
44
+
Use the generic React hooks directly. You manage message state through the transport's conversation tree instead of `useChat()`.
45
45
46
46
```typescript
47
47
import {
@@ -63,23 +63,23 @@ This path gives you conversation branching UI (sibling navigation), write operat
63
63
| Use useChat when... | Use generic hooks when... |
64
64
|---|---|
65
65
| You want the simplest integration | You need conversation branching UI |
66
-
|`useChat`'s message state management is sufficient | You need custom message construction |
66
+
|`useChat()`'s message state management is sufficient | You need custom message construction |
67
67
| You don't need edit or branch navigation | You need `edit()` or `view.select()`|
68
-
| You're already using `useChat` and adding AI Transport | You're building a custom chat UI from scratch |
68
+
| You're already using `useChat()` and adding AI Transport | You're building a custom chat UI from scratch |
69
69
70
70
## Entry points
71
71
72
72
| Import | What you get |
73
73
|---|---|
74
-
|`@ably/ai-transport/vercel`|`UIMessageCodec`, `createServerTransport`, `createClientTransport`, `createChatTransport` - all pre-bound to Vercel types |
75
-
|`@ably/ai-transport/vercel/react`|`useChatTransport`, `useMessageSync` - hooks for the useChat path |
74
+
|`@ably/ai-transport/vercel`|`UIMessageCodec`, `createServerTransport()`, `createClientTransport()`, `createChatTransport()` - all pre-bound to Vercel types |
75
+
|`@ably/ai-transport/vercel/react`|`useChatTransport()`, `useMessageSync()` - hooks for the useChat path |
76
76
|`@ably/ai-transport/react`| Generic hooks - work with any codec including `UIMessageCodec`|
77
77
78
-
The Vercel entry points are convenience wrappers. `createServerTransport` from `/vercel` is the same as the core `createServerTransport` with `UIMessageCodec` pre-bound - you don't pass a `codec` option.
78
+
The Vercel entry points are convenience wrappers. `createServerTransport()` from `/vercel` is the same as the core `createServerTransport()` with `UIMessageCodec` pre-bound - you don't pass a `codec` option.
79
79
80
80
## Server side
81
81
82
-
The server code is the same for both client paths. Use `createServerTransport` from the Vercel entry point and pipe `streamText`'s output through a turn:
82
+
The server code is the same for both client paths. Use `createServerTransport()` from the Vercel entry point and pipe `streamText()`'s output through a turn:
0 commit comments