Skip to content

Commit 2beb1d5

Browse files
committed
docs(ai-chat): unblock check-broken-links + address PR #3226 review feedback
- Replace `### chat.history {#chat-history}` and `## chat.defer() {#chat-defer}` with sentence-case headings ("Chat history", "Chat defer"). Mintlify's MDX parser couldn't parse the `{#...}` explicit-anchor syntax — `{...}` is JSX expression syntax in MDX, and `#chat-history` is not a valid expression. The sentence-case slug matches the existing cross-references on `/ai-chat/backend#chat-history` and `/ai-chat/features#chat-defer`. - Fix the dead link to `/ai-chat/skills/overview` in patterns/skills.mdx by reframing as descriptive text instead. Review feedback (CodeRabbit on PR #3226): - backend.mdx persistence example: add a `<Warning>` callout reminding readers to scope every server action by the authenticated user (`where: { userId }`) before pasting into a real multi-user app. The example keeps auth out of the way to focus on the persistence shape; the warning makes the gap explicit. - features.mdx `chat.local` example: `userContext.get().userId` was read later but `userId` wasn't part of the type or init — added it to both. - features.mdx preload example: missing `import { useEffect } from "react";`. - frontend.mdx restoring-on-page-load example: relabel `app/page.tsx` to `app/chat/[chatId]/ChatPage.tsx`. The exported `ChatPage` is a client component that takes `chatId` as a normal prop — not an App Router page, which would receive `params`. Added a comment showing the trivial server- component wrapper that awaits `params` and forwards `chatId` into it. Internal "Phase 1/2/3" language stripped from skills.mdx and changelog.mdx — roadmap-internal terminology that doesn't mean anything to readers.
1 parent 0de87db commit 2beb1d5

5 files changed

Lines changed: 22 additions & 8 deletions

File tree

docs/ai-chat/backend.mdx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,10 @@ To build a chat app that survives page refreshes, you need to persist two things
619619

620620
#### Full persistence example
621621

622+
<Warning>
623+
The example below trusts raw `chatId` and returns rows without filtering by user. In a real multi-user app, **scope every query by the authenticated user** — read the user from your auth/session in each server action and add `where: { userId }` to all `db.chat.*` and `db.chatSession.*` queries. Without that, one client could read or delete another user's chat state, and `getAllSessions()` would leak other users' `publicAccessToken`s. The snippet keeps auth out of the way to focus on the persistence shape.
624+
</Warning>
625+
622626
<CodeGroup>
623627
```ts trigger/chat.ts
624628
import { chat } from "@trigger.dev/sdk/ai";
@@ -905,7 +909,7 @@ The action payload is validated against `actionSchema` on the backend — invali
905909
Actions always trigger `run()` — the LLM responds to the modified state. For silent state changes that don't need a response (e.g. injecting background context), use [`chat.inject()`](/ai-chat/background-injection) instead.
906910
</Note>
907911

908-
### chat.history {#chat-history}
912+
### Chat history
909913

910914
Imperative API for modifying the accumulated message history. Works from any hook (`onAction`, `onTurnStart`, `onBeforeTurnComplete`, `onTurnComplete`) or from `run()` and AI SDK tools.
911915

docs/ai-chat/changelog.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ See the [Sessions Upgrade Guide](/ai-chat/upgrade-guide) for the full step-by-st
4444

4545
<Update label="April 19, 2026" description="0.0.0-chat-prerelease-20260419173457" tags={["SDK", "CLI"]}>
4646

47-
## Agent Skills (Phase 1)
47+
## Agent Skills
4848

4949
Ship reusable capabilities as folders — a `SKILL.md` plus optional scripts, references, and assets. The agent sees short descriptions in its system prompt, loads full instructions on demand via `loadSkill`, and invokes bundled scripts via `bash` — no manual wiring.
5050

docs/ai-chat/features.mdx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import { db } from "@/lib/db";
2525

2626
// Declare at module level — each local needs a unique id
2727
const userContext = chat.local<{
28+
userId: string;
2829
name: string;
2930
plan: "free" | "pro";
3031
messageCount: number;
@@ -39,6 +40,7 @@ export const myChat = chat.agent({
3940
where: { id: clientData.userId },
4041
});
4142
userContext.init({
43+
userId: clientData.userId,
4244
name: user.name,
4345
plan: user.plan,
4446
messageCount: user.messageCount,
@@ -158,7 +160,7 @@ onTurnComplete: async ({ chatId }) => {
158160

159161
---
160162

161-
## chat.defer() {#chat-defer}
163+
## Chat defer
162164

163165
Use `chat.defer()` to run background work in parallel with streaming. The deferred promise runs alongside the LLM response and is awaited (with a 5s timeout) before `onTurnComplete` fires.
164166

@@ -426,6 +428,7 @@ Preload eagerly triggers a run for a chat before the first message is sent. This
426428
Call `transport.preload(chatId)` to start a run early:
427429

428430
```tsx
431+
import { useEffect } from "react";
429432
import { useTriggerChatTransport } from "@trigger.dev/sdk/chat/react";
430433
import { useChat } from "@ai-sdk/react";
431434

docs/ai-chat/frontend.mdx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ On page load, fetch both the messages and the session state from your database,
125125

126126
Because the underlying Session row outlives individual runs, a chat you were in yesterday resumes against the same chat — even if the original run has long since exited. The transport hydrates from the persisted state and uses `lastEventId` to resubscribe; if the client tries to send a new message and no run is alive, the server triggers a fresh continuation run on the same session before the message is appended.
127127

128-
```tsx app/page.tsx
128+
```tsx app/chat/[chatId]/ChatPage.tsx
129129
"use client";
130130

131131
import { useEffect, useState } from "react";
@@ -139,6 +139,13 @@ import {
139139
deleteSession,
140140
} from "@/app/actions";
141141

142+
// Rendered from `app/chat/[chatId]/page.tsx`, which awaits `params`
143+
// and forwards `chatId` into this client component:
144+
//
145+
// export default async function Page({ params }: { params: Promise<{ chatId: string }> }) {
146+
// const { chatId } = await params;
147+
// return <ChatPage chatId={chatId} />;
148+
// }
142149
export default function ChatPage({ chatId }: { chatId: string }) {
143150
const [initialMessages, setInitialMessages] = useState([]);
144151
const [initialSession, setInitialSession] = useState(undefined);

docs/ai-chat/patterns/skills.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Compared to regular AI SDK tools:
1717

1818
PDFs are the canonical example: you don't want to ask the LLM to parse PDF bytes inline. You want it to `bash scripts/extract.py report.pdf` using a bundled `pdfplumber` wrapper. A skill ships the script, the instructions, and any reference notes together.
1919

20-
Skills are also [dashboard-editable](/ai-chat/skills/overview) in Phase 2 — a platform team can tighten a skill's description or "when to use" text without a redeploy. Phase 1 (today) is SDK-only.
20+
Dashboard-editable `SKILL.md` is on the roadmap so a platform team can tighten a skill's description or "when to use" text without a redeploy. Today, skills are SDK-only — defined in your task code and shipped with each deploy.
2121

2222
## Trust model
2323

@@ -197,11 +197,11 @@ If you're running `trigger dev`, the same layout appears in the local dev output
197197
- `bash` runs with `cwd` set to the skill's root. Inside the script, relative paths resolve against the skill directory.
198198
- Cross-skill access isn't provided — each skill is isolated by design. If two skills need to share data, either duplicate the shared file or consolidate the skills.
199199

200-
## Limitations in Phase 1
200+
## Current limitations
201201

202-
- `skill.resolve()` (backend-managed overrides) is not available yet. It throws a "not available in Phase 1, use `.local()`" error. Phase 2 ships dashboard-editable `SKILL.md` text.
202+
- `skill.resolve()` (backend-managed overrides) is not available yetuse `.local()` for now. Dashboard-editable `SKILL.md` is on the roadmap.
203203
- No per-skill metrics in the dashboard yet.
204-
- No Anthropic `/v1/skills` integration — use the portable path today; the Anthropic optimization comes in Phase 4.
204+
- No Anthropic `/v1/skills` integration — use the portable path today; we're tracking the Anthropic optimization separately.
205205

206206
## Full example
207207

0 commit comments

Comments
 (0)