feat(s2ui): create chat add token show#2669
Conversation
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (3)
📝 WalkthroughWalkthroughExtracts token usage from A2UI responses (legacy and new shapes), accumulates prompt/output/total counts into React state during chat and action streams, displays formatted token counts in a header badge, and reformats server tsconfig (JSX setting and array formatting). ChangesToken Usage Tracking and Display in AI Chat
TypeScript Configuration Updates
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/genui/a2ui-playground/src/pages/AIChatPage.tsx`:
- Around line 664-670: The onUsage callback is updating token counters even if
its stream was aborted; guard the accumulation by checking the stream's abort
state before calling setTokenUsage. Locate the onUsage handler (the closure that
calls setTokenUsage) and add an early return if the associated
AbortSignal/abortController indicates aborted (e.g., signal.aborted or a local
isAborted flag passed into the closure), so setTokenUsage only runs for active
streams; apply the same guard to the other onUsage occurrence mentioned.
In `@packages/genui/server/tsconfig.json`:
- Line 11: Change the tsconfig.json "jsx" compiler option from "react-jsx" back
to "preserve" to restore Next.js 13+ compatibility; locate the "jsx" property in
the packages/genui/server tsconfig (currently set to "react-jsx") and set its
value to "preserve" so Next.js can handle JSX transformation through its own
pipeline.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: b2c771d4-2b9e-4f11-9ba2-4222f7bcc270
📒 Files selected for processing (3)
packages/genui/a2ui-playground/src/pages/AIChatPage.csspackages/genui/a2ui-playground/src/pages/AIChatPage.tsxpackages/genui/server/tsconfig.json
7c204b3 to
f5631dc
Compare
f5631dc to
d274067
Compare
❌ 1 Tests Failed:
View the top 2 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
Merging this PR will improve performance by 36.89%
|
| Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|
| ⚡ | 002-hello-reactLynx-destroyBackground |
916.7 µs | 669.7 µs | +36.89% |
Tip
Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.
Comparing Sherry-hue:feat/create-token (d274067) with main (531ef76)2
Footnotes
-
26 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩
-
No successful run was found on
main(9ac6751) during the generation of this report, so 531ef76 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩
React Example with Element Template#736 Bundle Size — 200.08KiB (0%).d274067(current) vs 531ef76 main#728(baseline) Bundle metrics
Bundle size by type
|
| Current #736 |
Baseline #728 |
|
|---|---|---|
145.76KiB |
145.76KiB |
|
54.32KiB |
54.32KiB |
Bundle analysis report Branch Sherry-hue:feat/create-token Project dashboard
Generated by RelativeCI Documentation Report issue
React MTF Example#1600 Bundle Size — 208.18KiB (0%).d274067(current) vs 531ef76 main#1592(baseline) Bundle metrics
|
| Current #1600 |
Baseline #1592 |
|
|---|---|---|
0B |
0B |
|
0B |
0B |
|
0% |
0% |
|
0 |
0 |
|
3 |
3 |
|
193 |
193 |
|
77 |
77 |
|
44.24% |
44.24% |
|
2 |
2 |
|
0 |
0 |
Bundle size by type no changes
| Current #1600 |
Baseline #1592 |
|
|---|---|---|
111.23KiB |
111.23KiB |
|
96.95KiB |
96.95KiB |
Bundle analysis report Branch Sherry-hue:feat/create-token Project dashboard
Generated by RelativeCI Documentation Report issue
React External#1582 Bundle Size — 695.64KiB (0%).d274067(current) vs 531ef76 main#1574(baseline) Bundle metrics
|
| Current #1582 |
Baseline #1574 |
|
|---|---|---|
0B |
0B |
|
0B |
0B |
|
0% |
0% |
|
0 |
0 |
|
3 |
3 |
|
17 |
17 |
|
5 |
5 |
|
8.59% |
8.59% |
|
0 |
0 |
|
0 |
0 |
Bundle analysis report Branch Sherry-hue:feat/create-token Project dashboard
Generated by RelativeCI Documentation Report issue
React Example#8467 Bundle Size — 237.24KiB (0%).d274067(current) vs 531ef76 main#8459(baseline) Bundle metrics
|
| Current #8467 |
Baseline #8459 |
|
|---|---|---|
0B |
0B |
|
0B |
0B |
|
0% |
0% |
|
0 |
0 |
|
4 |
4 |
|
198 |
198 |
|
80 |
80 |
|
44.74% |
44.74% |
|
2 |
2 |
|
0 |
0 |
Bundle size by type no changes
| Current #8467 |
Baseline #8459 |
|
|---|---|---|
145.76KiB |
145.76KiB |
|
91.48KiB |
91.48KiB |
Bundle analysis report Branch Sherry-hue:feat/create-token Project dashboard
Generated by RelativeCI Documentation Report issue
Web Explorer#10041 Bundle Size — 903.53KiB (0%).d274067(current) vs 531ef76 main#10033(baseline) Bundle metrics
Bundle size by type
|
| Current #10041 |
Baseline #10033 |
|
|---|---|---|
499.15KiB |
499.15KiB |
|
402.16KiB |
402.16KiB |
|
2.22KiB |
2.22KiB |
Bundle analysis report Branch Sherry-hue:feat/create-token Project dashboard
Generated by RelativeCI Documentation Report issue
Summary by CodeRabbit
New Features
Style
Chores
Checklist