@@ -3,10 +3,10 @@ import { useShallowRef, onMounted } from 'veact'
33import { useLoading } from 'veact-use'
44import { Descriptions , Typography , List , Skeleton , Statistic , Avatar , Divider } from 'antd'
55import * as Icons from '@ant-design/icons'
6- import { AuthorName , AuthorEmail } from '@/components/common/AuthorProfile'
6+ import type { ChatSession , ChatMessage } from '@/constants/ai-agent'
7+ import { GeneralAuthorType , getAuthorTypeName } from '@/constants/author'
78import { UniversalText } from '@/components/common/UniversalText'
89import * as api from '@/apis/ai-agent'
9- import type { ChatSession , ChatMessage } from '@/constants/ai-agent'
1010import { timestampToYMD } from '@/transforms/date'
1111import { APP_PRIMARY_COLOR } from '@/config'
1212
@@ -26,46 +26,58 @@ export const SessionDetail: React.FC<SessionDetailProps> = (props) => {
2626
2727 const renderSessionInfos = ( ) => (
2828 < Descriptions
29- column = { 4 }
29+ column = { 1 }
3030 items = { [
3131 {
3232 key : 'id' ,
33- span : 4 ,
3433 label : 'Session ID' ,
3534 children : < UniversalText text = { props . session . session_id } copyable />
3635 } ,
3736 {
3837 key : 'content' ,
39- span : 4 ,
4038 label : '最后对话时间' ,
4139 children : < UniversalText text = { timestampToYMD ( props . session . last_active * 1000 ) } />
42- } ,
40+ }
41+ ] }
42+ />
43+ )
44+
45+ const renderUsageStats = ( ) => (
46+ < Descriptions
47+ column = { 4 }
48+ items = { [
4349 {
4450 key : 'user_id' ,
4551 label : '用户 ID' ,
46- children : < UniversalText text = { props . session . user_id } placeholder = "非登录用户" />
52+ children : (
53+ < UniversalText text = { props . session . user_id } placeholder = "非登录用户" strong = { true } />
54+ )
4755 } ,
4856 {
4957 key : 'author_name' ,
5058 label : '用户名称' ,
51- children : < AuthorName author_name = { props . session . author_name } />
59+ children : (
60+ < UniversalText
61+ text = { props . session . author_name }
62+ placeholder = { getAuthorTypeName ( GeneralAuthorType . Anonymous ) }
63+ />
64+ )
5265 } ,
5366 {
5467 key : 'author_email' ,
5568 span : 4 ,
56- label : '用户邮箱' ,
57- children : < AuthorEmail author_email = { props . session . author_email } />
58- } ,
59- {
60- key : 'message_count' ,
6169 children : (
62- < Statistic
63- title = "消息数量"
64- prefix = { < Icons . MessageOutlined /> }
65- value = { props . session . message_count }
70+ < UniversalText
71+ text = { props . session . author_email }
72+ copyable = { true }
73+ placeholder = "无邮箱"
6674 />
6775 )
6876 } ,
77+ {
78+ key : 'message_count' ,
79+ children : < Statistic title = "消息数量" value = { props . session . message_count } />
80+ } ,
6981 {
7082 key : 'total_tokens' ,
7183 children : < Statistic title = "总用 Token" value = { props . session . total_tokens } />
@@ -91,24 +103,38 @@ export const SessionDetail: React.FC<SessionDetailProps> = (props) => {
91103 < List . Item
92104 key = { index }
93105 style = { { overflow : 'hidden' } }
94- actions = { [
95- < UniversalText key = "model" text = { message . model } type = "secondary" /> ,
96- < UniversalText
97- key = "input_tokens"
98- prefix = "Input"
99- text = { message . input_tokens }
100- type = "secondary"
101- /> ,
102- < UniversalText
103- key = "output_tokens"
104- prefix = "Output"
105- text = { message . output_tokens }
106- type = "secondary"
107- />
108- ] }
106+ actions = {
107+ message . role === 'user'
108+ ? [ ]
109+ : [
110+ < UniversalText key = "model" text = { message . model } type = "secondary" /> ,
111+ < UniversalText
112+ key = "input_tokens"
113+ prefix = "Input"
114+ text = { message . input_tokens }
115+ type = "secondary"
116+ /> ,
117+ < UniversalText
118+ key = "output_tokens"
119+ prefix = "Output"
120+ text = { message . output_tokens }
121+ type = "secondary"
122+ />
123+ ]
124+ }
109125 >
110126 < List . Item . Meta
111- title = { < UniversalText text = { message . role . toUpperCase ( ) } strong = { true } /> }
127+ title = {
128+ message . role === 'user' ? (
129+ < UniversalText
130+ text = { props . session . author_name }
131+ placeholder = { getAuthorTypeName ( GeneralAuthorType . Anonymous ) }
132+ strong = { true }
133+ />
134+ ) : (
135+ < UniversalText text = { message . role } strong = { true } />
136+ )
137+ }
112138 description = { timestampToYMD ( message . created_at * 1000 ) }
113139 avatar = {
114140 < Avatar
@@ -147,6 +173,8 @@ export const SessionDetail: React.FC<SessionDetailProps> = (props) => {
147173 < div >
148174 { renderSessionInfos ( ) }
149175 < Divider />
176+ { renderUsageStats ( ) }
177+ < Divider />
150178 { fetching . state . value ? < Skeleton /> : renderMessages ( ) }
151179 </ div >
152180 )
0 commit comments