Commit 5634f18
feat: overhaul AI devtools hook dashboard (#632)
* feat: overhaul ai devtools
* refactor(ai-client): consolidate devtools coupling, add E2E suite
- Extract bridge construction into buildDevtoolsBridgeOptions helpers on
ChatClient, GenerationClient, VideoGenerationClient
- Add ChatDevtoolsAwareEventEmitter that auto-attaches run context and
emits snapshots so clients call this.events.X(...) like normal events
- Ship NoOp bridges by default; tree-shake real bridges into the
@tanstack/ai-client/devtools subpath entry
- Update React, Vue, Solid, Svelte, Preact hooks to pass the real
bridge factory
- Expand E2E suite: registration, chat, structured output, tools,
generation hooks, responsive layout
- Add devtools-name-types tests per framework integration
* ci: apply automated fixes
* fix: resolve eslint errors
- Sort imports alphabetically across ai-client, ai-react, ai-solid,
ai-vue, and ai-devtools-core
- Drop leading underscore from NoOpGenerationDevtoolsBridge type
parameter (used in constructor signature)
- Disable no-restricted-syntax on intentional `as unknown as` casts in
no-op bridge factories and generation result assignment, with reasons
- Remove unnecessary type assertion in devtools.ts (auto-fixed)
* fix(ai-devtools): address PR feedback
- log + preserve raw localStorage payload on fixture parse failure instead
of silently calling removeItem
- log + report full error name/message from tool-fixture execute, and
narrow the try block to executeFunc only so unrelated bugs in
addToolResultForFixture don't masquerade as tool failures
- cap seenEventIds at 10k via FIFO ring buffer to prevent unbounded
memory growth over the lifetime of long-running sessions; also reset
the order array in clearHookRegistry
- restore ai-code-mode/vite.config.ts to main (rename detection swapped
it with ai-client's during the merge); ai-client now correctly
declares devtools.ts as a separate entry
* docs: require pnpm test:pr locally before opening or updating a PR
Add a mandatory pre-PR quality gate to CLAUDE.md and a new AGENTS.md
(cross-agent file) documenting that `pnpm test:pr` — the exact target set
the CI `PR` workflow runs — must be run and pass locally before pushing.
Falling back on CI as the first signal wastes review cycles when a quick
local run would have caught the failure.
* fix(ai-devtools): address PR review feedback (critical + important + types + comments)
Critical
- ToolFixtureForm: remove dead `'{}' ? : '{}'` ternary leftover from refactor
- ChatDevtoolsBridge.executeFixture: warn when execute=true but no client tool
is registered instead of silently substituting the saved output
- stringifyFixtureValue / parseFixtureResultContent: log + report the original
error instead of swallowing JSON.stringify / JSON.parse failures
- devtools-middleware: replace `chunk: any` with a mirrored discriminated
union (DevtoolsKnownChunk) + isKnownChunk type guard, drop the `as` cast
on chunk.error, fall back with the raw chunk payload instead of "Unknown
error" when RUN_ERROR.message is missing
- normalizeRunStatusFromSnapshot: return `null` for unknown statuses and let
the caller skip + warn instead of silently coercing them to `'updated'`
Important
- Remove unreachable `'unmounted'` HookLifecycle variant + dead filters
- Drop unused `runs` prop on GenerationPanel
- removeHookRecord: also clean up TimelineEvents attached to the hook
- IterationTimeline `totalUsage`: compare on `totalTokens` (not
prompt+completion) so providers that include reasoning tokens in
totalTokens don't get their max overwritten by a smaller later reading
- jsonSafeValue / stringifyToolArguments: log + return an explicit
placeholder instead of returning the original on failure
- No-op bridges: add compile-time parity checks (Exclude<keyof, keyof>)
so adding a public method to the real bridge fails the build until the
no-op is updated, instead of becoming a runtime TypeError
- devtools-middleware: wrap every emit with `safeEmit` so a subscriber
throw can't bubble into the host chat engine
- markEventSeen: warn when a dedupe key falls back entirely to literal
sentinels; tools:registered: warn when hookName is missing
- hook-registry tests: cover snapshot run backfill (success/error/idle/
unknown statuses) and lifecycle inference from snapshot state
Type design
- AIDevtoolsGenerationRunStatus union ('idle' | 'generating' | 'success'
| 'error' | 'cancelled') replacing the previous `status: string` and
threaded through GenerationDevtoolsCoreState / SnapshotBase / RunPatch
- Drop redundant `unknown | null` on input / videoStatus fields
- Remove `extends Record<string, unknown>` from public snapshot interfaces;
ClientDevtoolsBridge constraint relaxed to `extends object` and the
wire-envelope widening is pushed to emitSnapshot
- Drop pointless `as Record<string, unknown>` casts at JsonTree call sites
(JsonTree's TData accepts arbitrary value)
Comment hygiene
- Strip file-top docblocks and class-banner JSDoc rewriting the PR
description (devtools-noop, use-real-devtools-bridges, devtools-system-
prompt-mirror.test, several blocks in devtools.ts)
- Remove "for backward compatibility" / "exactly like it did before the
devtools work landed" PR-narrative phrases
- Drop ASCII section-banner separators in devtools.ts, use-styles.ts,
ai-context.tsx
- Compress multi-line JSDoc on short methods to one-liners or remove
where the name was self-describing
- Strip obvious line-narration comments in ai-context.tsx batching helpers
* fix(ai-devtools): address re-review nits
- formatUnknown / stringifyToolArguments: warn + return explicit
unserializable-value placeholder (mirroring jsonSafeValue) instead of
silently returning String(value) on JSON.stringify failure
- Delete dead visibleHooks identity function and the redundant `active`
summary field (== total after the unmounted lifecycle was removed);
drop the two duplicate "active" overview metrics so the dashboard grid
isn't showing the same number under three labels
- Strip remaining "what"-narration comments in ai-context.tsx and the
section-divider comments in use-styles.ts
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* Revert "fix(ai-devtools): address re-review nits"
This reverts commit 6ae5aaf.
* fix(ai-devtools): surface unserializable values in placeholder helpers
formatUnknown and stringifyToolArguments previously fell back to
String(value) (yielding "[object Object]") on JSON.stringify failure.
Mirror the jsonSafeValue pattern: warn with the original error and
return a self-describing placeholder so the failure is visible in both
the console and the rendered devtools panel.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Tom Beckenham <34339192+tombeckenham@users.noreply.github.com>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent ef029a0 commit 5634f18
139 files changed
Lines changed: 19125 additions & 2569 deletions
File tree
- .changeset
- docs/getting-started
- examples/ts-react-chat/src
- components
- routes
- packages
- ai-client
- src
- tests
- ai-devtools
- src
- components
- conversation
- hooks
- list
- utils
- store
- styles
- tests
- ai-event-client
- src
- tests
- ai-preact
- src
- tests
- ai-react
- src
- tests
- ai-solid
- src
- tests
- ai-svelte
- src
- tests
- ai-vue
- src
- tests
- ai
- src/activities/chat
- middleware
- stream
- tests
- react-ai-devtools/src
- testing/e2e
- fixtures
- audio-gen
- tts
- src
- components
- lib
- routes
- tests
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
215 | 215 | | |
216 | 216 | | |
217 | 217 | | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
218 | 244 | | |
219 | 245 | | |
220 | 246 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
| 20 | + | |
19 | 21 | | |
20 | 22 | | |
| 23 | + | |
21 | 24 | | |
22 | 25 | | |
23 | 26 | | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
24 | 81 | | |
25 | 82 | | |
26 | 83 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
76 | 77 | | |
77 | 78 | | |
78 | 79 | | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
79 | 93 | | |
80 | 94 | | |
81 | 95 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
55 | 56 | | |
56 | 57 | | |
57 | 58 | | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
58 | 64 | | |
59 | 65 | | |
60 | 66 | | |
| |||
166 | 172 | | |
167 | 173 | | |
168 | 174 | | |
| 175 | + | |
169 | 176 | | |
170 | 177 | | |
171 | 178 | | |
| |||
193 | 200 | | |
194 | 201 | | |
195 | 202 | | |
| 203 | + | |
196 | 204 | | |
197 | 205 | | |
198 | 206 | | |
| |||
221 | 229 | | |
222 | 230 | | |
223 | 231 | | |
| 232 | + | |
224 | 233 | | |
225 | 234 | | |
226 | 235 | | |
| |||
250 | 259 | | |
251 | 260 | | |
252 | 261 | | |
| 262 | + | |
253 | 263 | | |
254 | 264 | | |
255 | 265 | | |
| |||
277 | 287 | | |
278 | 288 | | |
279 | 289 | | |
| 290 | + | |
280 | 291 | | |
281 | 292 | | |
282 | 293 | | |
| |||
304 | 315 | | |
305 | 316 | | |
306 | 317 | | |
| 318 | + | |
307 | 319 | | |
308 | 320 | | |
309 | 321 | | |
| |||
332 | 344 | | |
333 | 345 | | |
334 | 346 | | |
| 347 | + | |
335 | 348 | | |
336 | 349 | | |
337 | 350 | | |
| |||
388 | 401 | | |
389 | 402 | | |
390 | 403 | | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
391 | 411 | | |
392 | 412 | | |
393 | 413 | | |
| |||
540 | 560 | | |
541 | 561 | | |
542 | 562 | | |
| 563 | + | |
543 | 564 | | |
544 | 565 | | |
545 | 566 | | |
| |||
0 commit comments