Skip to content

Commit 22c6e49

Browse files
bloveclaude
andcommitted
fix(cockpit-chat-debug): give the devtools State tab real state to show
The dock has two tabs and only one of them demonstrated anything. Its graph was a plain MessagesState, and agent.state() projects messages out into the transcript, so the State inspector printed an empty object no matter what the run did — the page still promised it 'pretty-prints the agent's current state'. The process node already computed the metrics; it just buried them in a message. DebugState widens MessagesState with an analysis dict, so those numbers land in state where the inspector can render them. The fixture is now recorded from a real run rather than authored, and the State spec asserts the analysis keys instead of merely asserting the inspector renders some object — the shape the old comment said should widen this tab's coverage rather than fail it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1 parent bb86e46 commit 22c6e49

4 files changed

Lines changed: 408 additions & 33 deletions

File tree

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,25 @@ Before the first turn the Timeline tab shows its empty state: "No checkpoints ye
2222

2323
## How it is built
2424

25-
Three files carry the example: the graph that produces the checkpoints, the provider that points Angular at it, and the component that mounts the panel. Open the Code tab to read them in place.
25+
The example is three files: the graph that produces the checkpoints, the provider that points Angular at it, and the component that mounts the panel. Open the Code tab to read them in place.
2626

2727
### A graph with several nodes per turn
2828

29-
The backend is deliberately multi-step, because one node per turn produces one checkpoint and very little to look at. `generate` answers with the model, `process` appends a synthetic message derived from the answer, and `summarize` asks the model for a one-sentence summary of the conversation so far. The system prompt read by `generate` frames the assistant as an aviation helper; the graph binds no tools, so every answer comes from the model alone.
29+
The backend is deliberately multi-step, because one node per turn produces one checkpoint and very little to look at. `generate` answers with the model, `process` measures that answer and records the result, and `summarize` asks the model for a one-sentence summary of the conversation so far. The system prompt read by `generate` frames the assistant as an aviation helper; the graph binds no tools, so every answer comes from the model alone.
3030

3131
<ExampleCode file="graph.py" region="pipeline-nodes" title="graph.py — the three pipeline nodes" />
3232

3333
Each node returns a partial state update, and each of those updates becomes a checkpoint on the thread.
3434

35+
### State the inspector can show
36+
37+
`agent.state()` is the LangGraph values bag with `messages` projected out into the transcript, so a graph that carries nothing but its messages leaves the State tab printing an empty object. This graph widens `MessagesState` with the metrics `process` computes, which is what gives the second tab something to inspect.
38+
39+
<ExampleCode file="graph.py" region="debug-state" title="graph.py — the state the panel inspects" />
40+
3541
### Wiring the nodes into a linear pipeline
3642

37-
The nodes are registered on a `StateGraph` over `MessagesState` and chained: `generate` to `process` to `summarize` to `generate_title`, then to the end. `generate_title` is a background node that summarizes the first user message into a thread title; it returns an empty update, so it changes the message list not at all while still adding a step to the run.
43+
The nodes are registered on a `StateGraph` over `DebugState` and chained: `generate` to `process` to `summarize` to `generate_title`, then to the end. `generate_title` is a background node that summarizes the first user message into a thread title; it returns an empty update, so it changes the message list not at all while still adding a step to the run.
3844

3945
<ExampleCode file="graph.py" region="graph-wiring" title="graph.py — the compiled pipeline" />
4046

cockpit/chat/debug/angular/e2e/c-debug.spec.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,11 @@ test('c-debug: the State tab swaps in the live state inspector', async ({ page }
8888
// The tab owns the panel body — the timeline is torn down, not stacked.
8989
await expect(page.locator('chat-debug-checkpoint-card')).toHaveCount(0);
9090
// `agent.state()` is the LangGraph values bag with `messages` projected out
91-
// into the transcript, so on this MessagesState graph the inspector renders
92-
// an empty object today. Assert the shape the JsonPipe produces rather than
93-
// that exact literal: the claim is that the inspector is mounted and bound
94-
// to the agent, and a graph that carries state beyond its messages should
95-
// widen this tab's coverage, not fail it.
96-
await expect(stateTab.locator('chat-debug-state-inspector pre')).toHaveText(
97-
/^\{[\s\S]*\}$/,
98-
);
91+
// into the transcript. This graph's DebugState also carries `analysis`, the
92+
// metrics the `process` node computes, so the inspector has real run state
93+
// to print — that is what makes this tab worth opening.
94+
const inspector = stateTab.locator('chat-debug-state-inspector pre');
95+
await expect(inspector).toContainText('analysis');
96+
await expect(inspector).toContainText('characters');
97+
await expect(inspector).toContainText('words');
9998
});

0 commit comments

Comments
 (0)