Skip to content

Commit b7dd1d9

Browse files
committed
feat: add render function for nullable values in AIGateway log columns
1 parent b3eba5f commit b7dd1d9

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

src/client/components/aiGateway/useAIGatewayLogColumns.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ type AIGatewayLogItem = AppRouterOutput['aiGateway']['logs']['items'][number];
99

1010
const columnHelper = createColumnHelper<AIGatewayLogItem>();
1111

12+
// Generic render function for fields that should show "(null)" when value is -1
13+
const renderNullableValue = (value: number) => {
14+
if (value === -1) {
15+
return <span className="text-muted-foreground opacity-50">(null)</span>;
16+
}
17+
return value;
18+
};
19+
1220
export function useAIGatewayLogColumns(onRowSelect?: (index: number) => void) {
1321
const { t } = useTranslation();
1422

@@ -47,10 +55,12 @@ export function useAIGatewayLogColumns(onRowSelect?: (index: number) => void) {
4755
columnHelper.accessor('inputToken', {
4856
header: t('Input Tokens'),
4957
size: 120,
58+
cell: (props) => renderNullableValue(props.getValue()),
5059
}),
5160
columnHelper.accessor('outputToken', {
5261
header: t('Output Tokens'),
5362
size: 120,
63+
cell: (props) => renderNullableValue(props.getValue()),
5464
}),
5565
columnHelper.accessor('price', {
5666
header: t('Price ($)'),
@@ -59,11 +69,12 @@ export function useAIGatewayLogColumns(onRowSelect?: (index: number) => void) {
5969
columnHelper.accessor('duration', {
6070
header: t('Duration (ms)'),
6171
size: 120,
72+
cell: (props) => renderNullableValue(props.getValue()),
6273
}),
6374
columnHelper.accessor('ttft', {
6475
header: t('TTFT (ms)'),
6576
size: 100,
66-
cell: (props) => props.getValue() || '-',
77+
cell: (props) => renderNullableValue(props.getValue()),
6778
}),
6879
columnHelper.accessor('stream', {
6980
header: t('Stream'),

0 commit comments

Comments
 (0)