Skip to content

Yj/feat/ai 05 07#3685

Merged
song-xiao-lin merged 13 commits intomasterfrom
yj/feat/ai-05-07
May 9, 2026
Merged

Yj/feat/ai 05 07#3685
song-xiao-lin merged 13 commits intomasterfrom
yj/feat/ai-05-07

Conversation

@youngster-yj
Copy link
Copy Markdown
Contributor

No description provided.

@youngster-yj youngster-yj added the need more test 需要更多的测试 label May 8, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 8, 2026

PR CI 汇总

状态:全部通过

  • ✅ i18n(zh/en)
  • ✅ ESLint(renderer src/main)
  • ✅ TypeScript(renderer src/main)
  • ✅ ESLint(engine-link-startup)
  • ✅ TypeScript(engine-link-startup)
  • ✅ 图片/视频体积
  • ○ Vitest(main / renderer / engine-link;test 同目录·别名·相对路径)(skipped)
  • ✅ Prettier

由 pull_request test workflow 自动生成

@Vernon818 Vernon818 added ready and removed need more test 需要更多的测试 labels May 8, 2026
@luoluoTH luoluoTH requested a review from Copilot May 9, 2026 02:22
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_risk to yak_httpflow_count / yak_risk_count and 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])
@b1rdfree b1rdfree added need more test 需要更多的测试 and removed ready labels May 9, 2026
@Vernon818 Vernon818 added ready and removed need more test 需要更多的测试 labels May 9, 2026
@song-xiao-lin song-xiao-lin merged commit 8ea4ade into master May 9, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants