Skip to content

Conversation

@mxyhi
Copy link
Owner

@mxyhi mxyhi commented Feb 3, 2026

概述

优化 token 显示格式和增强日志详情视图功能。

主要更改

1. Token 显示优化

  • Dashboard 卡片中的 token 数字采用紧凑格式显示(如 1.2K, 3.5M)
  • 新增 formatCompactNumber 工具函数

2. 日志详情视图增强

  • 新增请求详情侧边栏,展示完整请求信息
  • 支持一键复制所有详情到剪贴板
  • 显示字段:ID、时间、上游/Provider、模型(含映射)、状态、流式、上游请求ID、Usage JSON、请求头、请求体
  • 映射模型仅在与原始模型不同时显示

3. 后端支持

  • logs.rs 新增详情查询接口,返回完整请求信息
  • 新增 RequestLogDetail 类型定义

4. 代码质量

  • 复制按钮添加错误处理(兼容 Tauri/非安全上下文)
  • 正确清理 setTimeout 防止内存泄漏
  • 国际化支持(中英文)

文件变更

  • crates/token_proxy_core/src/proxy/logs.rs - 后端详情查询
  • src/features/logs/LogsPanel.tsx - 详情侧边栏组件
  • src/features/logs/types.ts - 类型定义
  • src/features/dashboard/format.ts - 紧凑数字格式化
  • src/components/section-cards.tsx - 应用紧凑格式
  • messages/en.json, messages/zh.json - i18n

mxyhi added 9 commits February 3, 2026 14:34
- Add formatCompact() for space-constrained displays (e.g., 1.5M, 986K)
- Apply compact formatting to dashboard cards to prevent overflow
- Simplify token column in logs table by removing redundant labels
- Remove duplicate cache info from token card footer (already shown in badge)
- expand RequestLogDetail data model with path, provider, model, and usage
- implement basic info section in detail panel to display request metadata
- add "Copy all" button to export log details to clipboard
- update i18n strings for log details and simplify update button text
- Add i18n key for mapped model label in copy text
- Add try-catch for clipboard API (may fail in Tauri/non-secure context)
- Fix timer cleanup with proper useEffect pattern
When no model mapping is configured, mapped_model was being set to the
same value as original_model, causing the UI to display duplicate model
information. Changed from map+unwrap_or_else to and_then so mapped_model
remains None when no mapping exists.
- implement median latency calculation using SQLite LIMIT/OFFSET
- display median and average latency in dashboard cards
- update dashboard summary types to include median latency

✨ feat(logs): integrate clipboard manager plugin
- add @tauri-apps/plugin-clipboard-manager for reliable copying
- add toast notifications for clipboard success and failure
- update tauri permissions to allow clipboard write access

✅ test(dashboard): add compact number formatting tests
- verify K, M, and B suffixes for large numbers in formatCompact utility
- change primary latency metric from median to average
- remove average from footer hint to simplify UI

🌐 i18n(locale): update latency hint strings
- remove average value from translation strings in English and Chinese

🔧 chore(version): bump dev version to 0.1.36
- update version in tauri dev configuration file
- implement test suite for query_median_latency using in-memory SQLite
- cover empty state, odd/even counts, and time range filtering
- verify integer division behavior for even-count medians
- fix race condition in LogsPanel detail loading with active flag
- add composite index (ts_ms, latency_ms) for median latency query
【refactor】
- implement single SQL query using CTEs to calculate median latency
- ensure data consistency by avoiding separate count and offset queries
- handle odd and even record counts directly within the database engine

🐛 fix(dashboard): refine token column tooltip display
【fix】
- filter out placeholders from tooltip text to prevent confusing labels
- ensure tooltip only shows available token and cache information
@mxyhi mxyhi merged commit 58cb1b6 into main Feb 3, 2026
1 check passed
@mxyhi mxyhi deleted the feat/compact-token-display branch February 3, 2026 11:51
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.

1 participant