@@ -31,7 +31,10 @@ import { IntCell, TextCell } from "../../components/table";
31
31
import { TokenCount } from "../../components/trace/TokenCount" ;
32
32
33
33
import { SessionsTable_sessions$key } from "./__generated__/SessionsTable_sessions.graphql" ;
34
- import { SessionsTableQuery } from "./__generated__/SessionsTableQuery.graphql" ;
34
+ import {
35
+ ProjectSessionColumn ,
36
+ SessionsTableQuery ,
37
+ } from "./__generated__/SessionsTableQuery.graphql" ;
35
38
import { useSessionSearchContext } from "./SessionSearchContext" ;
36
39
import { SessionSearchField } from "./SessionSearchField" ;
37
40
import { SessionsTableEmpty } from "./SessionsTableEmpty" ;
@@ -58,12 +61,17 @@ export function SessionsTable(props: SessionsTableProps) {
58
61
@argumentDefinitions (
59
62
after: { type : "String" , defaultValue: null }
60
63
first : { type : "Int" , defaultValue: 50 }
64
+ sort : {
65
+ type : "ProjectSessionSort"
66
+ defaultValue : { col : startTime, dir: desc }
67
+ }
61
68
filterIoSubstring : { type : "String" , defaultValue: null }
62
69
) {
63
70
name
64
71
sessions(
65
72
first: $first
66
73
after: $after
74
+ sor t: $sor t
67
75
filterIoSubstring: $filterIoSubstring
68
76
timeRange: $timeRange
69
77
) @connection (key : "SessionsTable_sessions" ) {
@@ -93,8 +101,11 @@ export function SessionsTable(props: SessionsTableProps) {
93
101
props . project
94
102
) ;
95
103
const tableData = useMemo ( ( ) => {
96
- return data . sessions . edges . map ( ( { session } ) => session ) ;
97
- } , [ data ] ) ;
104
+ return data . sessions . edges . map ( ( { session } ) => ( {
105
+ ...session ,
106
+ tokenCountTotal : session . tokenUsage . total ,
107
+ } ) ) ;
108
+ } , [ data . sessions ] ) ;
98
109
type TableRow = ( typeof tableData ) [ number ] ;
99
110
const columns : ColumnDef < TableRow > [ ] = [
100
111
{
@@ -118,19 +129,19 @@ export function SessionsTable(props: SessionsTableProps) {
118
129
{
119
130
header : "start time" ,
120
131
accessorKey : "startTime" ,
121
- enableSorting : false ,
132
+ enableSorting : true ,
122
133
cell : TimestampCell ,
123
134
} ,
124
135
{
125
136
header : "end time" ,
126
137
accessorKey : "endTime" ,
127
- enableSorting : false ,
138
+ enableSorting : true ,
128
139
cell : TimestampCell ,
129
140
} ,
130
141
{
131
142
header : "total tokens" ,
132
- accessorKey : "tokenUsage.total " ,
133
- enableSorting : false ,
143
+ accessorKey : "tokenCountTotal " ,
144
+ enableSorting : true ,
134
145
minSize : 80 ,
135
146
cell : ( { row, getValue } ) => {
136
147
const value = getValue ( ) ;
@@ -150,14 +161,21 @@ export function SessionsTable(props: SessionsTableProps) {
150
161
{
151
162
header : "total traces" ,
152
163
accessorKey : "numTraces" ,
153
- enableSorting : false ,
164
+ enableSorting : true ,
154
165
cell : IntCell ,
155
166
} ,
156
167
] ;
157
168
useEffect ( ( ) => {
169
+ const sort = sorting [ 0 ] ;
158
170
startTransition ( ( ) => {
159
171
refetch (
160
172
{
173
+ sort : sort
174
+ ? {
175
+ col : sort . id as ProjectSessionColumn ,
176
+ dir : sort . desc ? "desc" : "asc" ,
177
+ }
178
+ : { col : "startTime" , dir : "desc" } ,
161
179
after : null ,
162
180
first : PAGE_SIZE ,
163
181
filterIoSubstring : filterIoSubstring ,
0 commit comments