Yj/feat/ai 05 07#3685
Merged
song-xiao-lin merged 13 commits intomasterfrom May 9, 2026
Merged
Conversation
Contributor
PR CI 汇总状态:全部通过
由 pull_request test workflow 自动生成 |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the AI Agent/ReAct event payloads and UI to support (1) traffic count notifications, (2) cache-hit token accounting, and (3) a role-based breakdown for prompt/context bytes, with corresponding chart + table updates.
Changes:
- Switch AI output events from
yak_httpflow/yak_risktoyak_httpflow_count/yak_risk_countand store absolute counts from payload fields. - Extend consumption metrics with
cache_hit_token(overall + per-tier) and display it in the token summary UI. - Replace legacy context-byte series (system/runtime/user) with a dynamic role-based series and update ECharts + context table role labeling/filtering accordingly.
Reviewed changes
Copilot reviewed 12 out of 13 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| app/renderer/src/main/src/pages/ai-re-act/hooks/useChatIPC.ts | Update traffic event type matching to new *_count variants. |
| app/renderer/src/main/src/pages/ai-re-act/hooks/useChatContent.ts | Parse new traffic count payloads and update tool result counters accordingly. |
| app/renderer/src/main/src/pages/ai-re-act/hooks/useAIPerfData.ts | Add cache-hit tokens; refactor prompt_profile handling to build role-based context stats series with trimming. |
| app/renderer/src/main/src/pages/ai-re-act/hooks/grpcApi.ts | Update TS API shapes: add cache_hit_token, change traffic notice payloads, add role stats + labels for prompt_profile. |
| app/renderer/src/main/src/pages/ai-agent/type/aiChat.d.ts | Update AIContextStatsDetail to new role-based series structure. |
| app/renderer/src/main/src/pages/ai-agent/store/ChatDataStore.ts | Initialize new fields: cache_hit_token and role-based context stats containers. |
| app/renderer/src/main/src/pages/ai-agent/chatTemplate/AIEcharts.tsx | Update “context bytes” chart to support dynamic stacked role series (fallback to total-only). |
| app/renderer/src/main/src/pages/ai-agent/aiChatContent/AIContextToken/utils.ts | Update perf-data change detection + context stats normalization for new shape. |
| app/renderer/src/main/src/pages/ai-agent/aiChatContent/AIContextToken/ContextTable/ContextTable.tsx | Improve role labeling (role_name_zh/legacy fallback) and allow multi-select role filters. |
| app/renderer/src/main/src/pages/ai-agent/aiChatContent/AIContextToken/ContextTable/ContextTable.module.scss | Add filter dropdown background styling. |
| app/renderer/src/main/src/pages/ai-agent/aiChatContent/AIContextToken/AIContextToken.tsx | Display cache-hit tokens (overall + per-tier) and pass role label map to context table. |
| app/renderer/src/main/public/locales/zh/aiAgent.json | Add AIContextToken.cache translation. |
| app/renderer/src/main/public/locales/en/aiAgent.json | Add AIContextToken.cache translation. |
Comment on lines
79
to
86
| const token = useCreation(() => { | ||
| const { consumption } = aiDataRef || {} | ||
| if (isEmpty(consumption)) return [0, 0] | ||
| const input = consumption?.input_consumption || 0 | ||
| const output = consumption?.output_consumption || 0 | ||
| return [formatNumberUnits(input), formatNumberUnits(output)] | ||
| const cacheHit = consumption?.cache_hit_token || 0 | ||
| return [formatNumberUnits(input), formatNumberUnits(output), formatNumberUnits(cacheHit)] | ||
| }, [renderNumber, aiDataRef?.consumption]) |
Comment on lines
258
to
272
| const intelligentToken = useCreation(() => { | ||
| if (!tierConsumption?.intelligent) return [0, 0] | ||
| const input = tierConsumption.intelligent.input_consumption || 0 | ||
| const output = tierConsumption.intelligent.output_consumption || 0 | ||
| return [formatNumberUnits(input), formatNumberUnits(output)] | ||
| const cacheHit = tierConsumption.intelligent.cache_hit_token || 0 | ||
| return [formatNumberUnits(input), formatNumberUnits(output), formatNumberUnits(cacheHit)] | ||
| }, [renderNumber, tierConsumption?.intelligent]) | ||
|
|
||
| const lightweightToken = useCreation(() => { | ||
| if (!tierConsumption?.lightweight) return [0, 0] | ||
| const input = tierConsumption.lightweight.input_consumption || 0 | ||
| const output = tierConsumption.lightweight.output_consumption || 0 | ||
| return [formatNumberUnits(input), formatNumberUnits(output)] | ||
| const cacheHit = tierConsumption.lightweight.cache_hit_token || 0 | ||
| return [formatNumberUnits(input), formatNumberUnits(output), formatNumberUnits(cacheHit)] | ||
| }, [renderNumber, tierConsumption?.lightweight]) |
song-xiao-lin
approved these changes
May 9, 2026
luoluoTH
approved these changes
May 9, 2026
EmbraceAn
approved these changes
May 9, 2026
song-xiao-lin
approved these changes
May 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.