Skip to content

feat(ai, frontend): Session Summary Enhancement & Code Quality (Issue #79)#84

Merged
hrygo merged 10 commits into
mainfrom
feat/79-session-summary-enhancement
Feb 6, 2026
Merged

feat(ai, frontend): Session Summary Enhancement & Code Quality (Issue #79)#84
hrygo merged 10 commits into
mainfrom
feat/79-session-summary-enhancement

Conversation

@hrygo

@hrygo hrygo commented Feb 6, 2026

Copy link
Copy Markdown
Owner

概述

完成 Issue #79 的会话摘要功能增强,包括 UI 组件、统计数据收集、分支管理和代码质量改进。

变更内容

AI 后端

  • LLM 统计收集: 实现 token 使用、成本追踪功能
  • 对话分支: 支持 Block 分支、切换、删除和派生
  • CC Runner: 异步会话管理和双向流式处理
  • 路由器缓存: 移除未使用的字段,优化性能

前端 UI

  • SessionSummaryBar: 实时会话统计显示(tokens/cost/时间)
  • EventBadge: 工具调用事件徽章
  • ToolCallCard: 工具调用详情卡片
  • BranchIndicator: 分支路径指示器
  • UnifiedMessageBlock: 统一消息块组件优化

代码质量

  • P1 类型安全: BigInt 转换添加 MAX_SAFE_INTEGER 检查
  • P2 边界检查: Base26 编码添加最大迭代限制
  • P2 性能优化: 会话统计处理限制为 100 blocks
  • P3 国际化: 工具调用和文件修改内容使用 i18n
  • P3 文档: 添加详细注释说明常量含义
  • 测试修复: 所有 TypeScript 测试文件 lint 错误修复

关联 Issue

Resolves #79

测试计划

  • 本地测试通过
  • 单元测试更新
  • `make check-all` 通过
  • 前端 lint + build 通过
  • 后端 lint + test 通过

Co-Authored-By: Claude Opus 4.5 noreply@anthropic.com

hotplex-ai and others added 8 commits February 6, 2026 11:50
…tion branching (Issue #79)

This commit implements three interconnected specifications:
- P1-A006: LLM Stats Collection + Session Summary for Normal Mode
- ai-block-fields-extension: Token usage, cost estimate, model version fields
- tree-conversation-branching: Fork/switch/delete conversation branches

Backend changes:
- Add LLMCallStats struct with token usage and timing metrics
- Refactor LLMService.Chat/ChatStream to return stats
- Implement BaseParrot with stats accumulation for all Parrot agents
- Add TokenUsage, CostEstimate fields to Block proto/message
- Add parent_block_id, branch_path for tree branching support
- Add ForkBlock, ListBlockBranches, SwitchBranch, DeleteBranch RPCs
- Implement postgres migration for new Block fields
- Add comprehensive tests for stats, ForkBlock, and cost calculation

Frontend changes:
- Add TokenUsageBadge and BlockCostBadge components for displaying stats
- Add BranchIndicator and BranchSelector for conversation branching
- Implement useBranchTree hook for branch operations
- Update SessionSummaryPanel to display token usage and timing
- Add frontend integration tests with Vitest
- Update i18n keys for new features

Documentation:
- Add AI_CHAT_INTERFACE.md with complete UI architecture diagrams
- Update ARCHITECTURE.md with Unified Block Model references

All 51 Loki Mode tasks completed. make check-all passes.

Refs #79

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Restructure from patch collection to纲领性 document
- Add "第一性原理" section defining project essence
- Consolidate architecture decisions with clear mappings
- Streamline workflow and coding standards
- Remove troubleshooting details (defer to DEBUG_LESSONS.md)
- Reduce from 150 to 112 lines while increasing clarity

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Features:
- Add SessionBar component displaying aggregated session stats (cost, tokens, duration)
- Add BlockEditDialog for editing user inputs and creating branches
- Add type guards isStreamingStatus(), isErrorStatus() for BlockStatus checks
- Add isCompletedStatus() helper function

Code quality fixes (P0/P1/P2/P3):
- Fix JSX syntax errors: rename test files from .test.ts to .test.tsx
- Fix BlockStatus comparison bug (String() was always false)
- Reduce 'any' type usage in useBlockQueries.ts
- Extract magic number MILLI_CENTS_TO_USD constant
- Remove unused imports and variables

i18n:
- Add translations for session bar, edit dialog, and status labels

Refs #79

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Condense decision tree from verbose Chinese to concise English
- Simplify idea-researcher trigger flow
- Add language directive to CCRunner system prompt

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Backend changes:
- Add replaceUserInputs parameter to ForkBlock API for message editing
- Add reason validation and return InvalidArgument for empty reason
- Store fork metadata (forked_from, fork_reason, fork_type) for debugging
- Remove duplicate log entry from ForkBlock (keep service layer only)
- Add unit tests: TestForkBlock_WithReplaceUserInputs, TestForkBlock_EmptyReason

Frontend changes:
- Simplify BlockEditDialog UI: remove "original message" display area
- Merge multiple user inputs (with newlines) for editing
- Fix handleEdit to pass complete MessageBlock for input merging
- Remove onSend call after ForkBlock (was creating duplicate block)
- Add new i18n keys: message, edit_placeholder

Bug fix:
- Fix mouse cursor flickering on /auth/signup page caused by overly
  broad [tabIndex] CSS selector targeting Radix UI components

Refs #79

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
… audit fixes (Issue #79)

This commit completes the P0-P3 phase tasks and addresses all code audit findings:

**P2 Tasks:**
- Add BlockSummary restoration from persisted Block.sessionStats after page refresh
- Implement friendly branch path numbering (0/1/2 → A.2.3) with Base26 conversion
- Integrate SessionBar into ChatHeader for PC, mobile-only standalone display

**P3 Tasks:**
- Update AI_CHAT_INTERFACE.md to v0.93.1 with new UI patterns

**Code Audit Fixes:**
- P1-#1: Add safeBigIntToNumber with MAX_SAFE_INTEGER boundary check
- P2-#1: Add MAX_ITERATIONS limit to toBase26 to prevent potential infinite loops
- P2-#2: Optimize calculateSessionStats to process only last 100 blocks
- P3-#1: Replace hardcoded Chinese text with i18n t() calls
- P3-#2: Add detailed comment for MILLI_CENTS_TO_USD constant

**New Components:**
- HeaderSessionStats: Mode-differentiated session stats (Normal/Geek/Evolution)

**Bug Fixes:**
- Fix ForkBlock protobuf serialization using create(UserInputSchema, ...)
- Fix ToolCalls duplication with occurrence-based deduplication
- Fix import ordering per Biome lint rules

Refs #79

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The sync.RWMutex field was declared but never used since the underlying
LRUCache handles its own locking internally.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Remove unused BlockListCacheData interface (re-added for internal use)
- Fix protobuf mock creation using proper types
- Change \`as any\` to \`as unknown as Type\` for observer mocks
- Use EmptySchema for delete/append operations
- Use ListBlocksResponseSchema for list operations
- Import EmptySchema from @bufbuild/protobuf/wkt

Refs #79

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@hrygo hrygo force-pushed the feat/79-session-summary-enhancement branch from b6dc93f to 8a7ebe5 Compare February 6, 2026 10:08
- Update @testing-library/jest-dom from 6.6.0 to 6.9.1
- Update @testing-library/react from 16.2.0 to 16.3.2
@hrygo hrygo merged commit 1f2ca0f into main Feb 6, 2026
11 checks passed
@hrygo hrygo deleted the feat/79-session-summary-enhancement branch February 6, 2026 10:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[feat] 普通模式 Session Summary 增强与 CC Session 隔离验证

2 participants