Skip to content

Commit 42aa904

Browse files
authored
docs(chat): fix snippet accuracy vs 0.0.49 API (#644)
1 parent 7975dd3 commit 42aa904

4 files changed

Lines changed: 61 additions & 34 deletions

File tree

apps/website/content/docs/chat/a2ui/catalog.mdx

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -335,12 +335,15 @@ A tabbed container that shows one child panel at a time based on the selected ta
335335
```json
336336
{
337337
"id": "info-tabs",
338-
"component": "Tabs",
339-
"tabs": [
340-
{"label": "Overview", "childKeys": ["overview-content"]},
341-
{"label": "Details", "childKeys": ["detail-list"]}
342-
],
343-
"selected": {"path": "/activeTab"}
338+
"component": {
339+
"Tabs": {
340+
"tabs": [
341+
{"label": "Overview", "childKeys": ["overview-content"]},
342+
{"label": "Details", "childKeys": ["detail-list"]}
343+
],
344+
"selected": {"path": "/activeTab"}
345+
}
346+
}
344347
}
345348
```
346349

@@ -365,11 +368,14 @@ A dialog overlay that renders child content when open. Supports an optional titl
365368
```json
366369
{
367370
"id": "confirm-dialog",
368-
"component": "Modal",
369-
"title": "Confirm Action",
370-
"open": {"path": "/showConfirm"},
371-
"childKeys": ["confirm-message", "confirm-buttons"],
372-
"dismissible": true
371+
"component": {
372+
"Modal": {
373+
"title": {"literalString": "Confirm Action"},
374+
"open": {"path": "/showConfirm"},
375+
"childKeys": ["confirm-message", "confirm-buttons"],
376+
"dismissible": true
377+
}
378+
}
373379
}
374380
```
375381

@@ -393,10 +399,13 @@ Renders an HTML5 `<video>` element.
393399
```json
394400
{
395401
"id": "intro-video",
396-
"component": "Video",
397-
"url": "https://example.com/intro.mp4",
398-
"poster": "https://example.com/poster.jpg",
399-
"controls": true
402+
"component": {
403+
"Video": {
404+
"url": {"literalString": "https://example.com/intro.mp4"},
405+
"poster": {"literalString": "https://example.com/poster.jpg"},
406+
"controls": true
407+
}
408+
}
400409
}
401410
```
402411

@@ -417,9 +426,12 @@ Renders an HTML5 `<audio>` element.
417426
```json
418427
{
419428
"id": "podcast",
420-
"component": "AudioPlayer",
421-
"url": "https://example.com/episode.mp3",
422-
"controls": true
429+
"component": {
430+
"AudioPlayer": {
431+
"url": {"literalString": "https://example.com/episode.mp3"},
432+
"controls": true
433+
}
434+
}
423435
}
424436
```
425437

apps/website/content/docs/chat/components/chat-trace.mdx

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,15 @@ When `state` transitions from any value to `'running'`, the trace automatically
9191
### Full component example
9292

9393
```typescript
94-
import { Component, ChangeDetectionStrategy, signal } from '@angular/core';
94+
import { Component, ChangeDetectionStrategy, computed, signal } from '@angular/core';
9595
import { injectAgent, provideAgent } from '@threadplane/langgraph';
9696
import { ChatTraceComponent, ChatMessageListComponent } from '@threadplane/chat';
97+
import type { ToolCallStatus, TraceState } from '@threadplane/chat';
98+
99+
function toTraceState(status: ToolCallStatus): TraceState {
100+
// 'pending' | 'running' | 'error' carry over; only 'complete' is renamed.
101+
return status === 'complete' ? 'done' : status;
102+
}
97103

98104
@Component({
99105
selector: 'app-traced-chat',
@@ -106,10 +112,10 @@ import { ChatTraceComponent, ChatMessageListComponent } from '@threadplane/chat'
106112
<chat-message-list [agent]="chatAgent">
107113
<ng-template chatMessageTemplate="ai" let-message>
108114
<!-- Show tool traces before the AI message -->
109-
@for (step of chatAgent.steps(); track step.id) {
110-
<chat-trace [state]="step.state">
111-
<span traceLabel>{{ step.name }}</span>
112-
<pre>{{ step.output | json }}</pre>
115+
@for (trace of traces(); track trace.id) {
116+
<chat-trace [state]="trace.state">
117+
<span traceLabel>{{ trace.name }}</span>
118+
<pre>{{ trace.args | json }}</pre>
113119
</chat-trace>
114120
}
115121
<div>{{ message.content }}</div>
@@ -120,6 +126,16 @@ import { ChatTraceComponent, ChatMessageListComponent } from '@threadplane/chat'
120126
})
121127
export class TracedChatComponent {
122128
protected readonly chatAgent = injectAgent();
129+
130+
// The agent's toolCalls() signal is the real source for trace rows.
131+
protected readonly traces = computed(() =>
132+
this.chatAgent.toolCalls().map((call) => ({
133+
id: call.id,
134+
name: call.name,
135+
args: call.args,
136+
state: toTraceState(call.status),
137+
})),
138+
);
123139
}
124140
```
125141

apps/website/content/docs/chat/getting-started/installation.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ export const appConfig: ApplicationConfig = {
115115
provideZonelessChangeDetection(),
116116
provideAgent({
117117
apiUrl: environment.langgraphApiUrl, // e.g. 'http://localhost:2024'
118+
assistantId: 'chat', // The graph/agent ID exposed by your backend
118119
}),
119120
provideChat({
120121
license: environment.threadplaneLicense,

apps/website/content/docs/chat/getting-started/quickstart.mdx

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,17 @@ npm install @threadplane/chat marked
2828

2929
```ts
3030
// app.config.ts
31-
import { ApplicationConfig } from '@angular/core';
31+
import { ApplicationConfig, signal } from '@angular/core';
3232
import { provideAgent } from '@threadplane/langgraph';
3333
import { provideChat } from '@threadplane/chat';
3434

3535
export const appConfig: ApplicationConfig = {
3636
providers: [
37-
provideAgent({ apiUrl: 'http://localhost:2024' }),
37+
provideAgent({
38+
assistantId: 'chat',
39+
apiUrl: 'http://localhost:2024',
40+
threadId: signal(null),
41+
}),
3842
provideChat({ assistantName: 'Assistant' }),
3943
],
4044
};
@@ -45,29 +49,23 @@ export const appConfig: ApplicationConfig = {
4549

4650
```ts
4751
// chat-page.component.ts
48-
import { Component, ChangeDetectionStrategy, signal } from '@angular/core';
49-
import { injectAgent, provideAgent } from '@threadplane/langgraph';
52+
import { Component, ChangeDetectionStrategy } from '@angular/core';
53+
import { injectAgent } from '@threadplane/langgraph';
5054
import { ChatComponent } from '@threadplane/chat';
5155

5256
@Component({
5357
selector: 'app-chat-page',
5458
standalone: true,
5559
imports: [ChatComponent],
5660
changeDetection: ChangeDetectionStrategy.OnPush,
57-
providers: [
58-
provideAgent({
59-
assistantId: 'chat',
60-
threadId: signal(null),
61-
}),
62-
],
6361
template: `<div style="height: 100vh"><chat [agent]="chatAgent" /></div>`,
6462
})
6563
export class ChatPageComponent {
6664
protected readonly chatAgent = injectAgent();
6765
}
6866
```
6967

70-
The second `provideAgent()` isn't a duplicate. Angular's hierarchical DI merges it with the root provider from Step 2: `apiUrl` comes from the root, `assistantId` and `threadId` come from this component-level call. Splitting config this way lets one app host several `<chat>` surfaces that share a backend URL but target different graphs. See the [Multiple agents](/docs/chat/getting-started/installation) note in Installation for the full pattern.
68+
`injectAgent()` returns the singleton wired up in Step 2 — no extra provider needed here. To host several `<chat>` surfaces that share a backend URL but target different graphs, re-provide `provideAgent({...})` in a component's `providers: []` array; Angular's hierarchical DI scopes that override to the subtree. See the [Multiple agents](/docs/chat/getting-started/installation) note in Installation for the full pattern.
7169

7270
</Step>
7371
</Steps>

0 commit comments

Comments
 (0)