Kode-cli/src/components/LogSelector.tsx
CrazyBoyM 6cf566fb40 feat: Add comprehensive GPT-5 support with Responses API integration
- Add GPT-5 model definitions (gpt-5, gpt-5-mini, gpt-5-nano, gpt-5-chat-latest)
- Implement GPT-5 Responses API support with intelligent fallback to Chat Completions
- Add GPT-5 specific parameter handling (max_completion_tokens, temperature=1)
- Support custom tools and freeform function calling capabilities
- Add reasoning effort and verbosity control parameters
- Implement GPT-5 connection testing service
- Add model capability detection and automatic parameter transformation
- Support both official OpenAI and third-party GPT-5 providers
- Add todo list and sticker request UI components
- Improve notebook support with better type definitions
- Enhance debug logging and error handling for GPT-5
- Update model selector with GPT-5 compatibility checks

This commit provides full GPT-5 support while maintaining backward compatibility with existing models.
2025-08-13 01:38:15 +08:00

87 lines
2.6 KiB
TypeScript

import React from 'react'
import { Box, Text } from 'ink'
import { Select } from './CustomSelect/select'
import type { LogOption } from '../types/logs'
import { getTheme } from '../utils/theme'
import { useTerminalSize } from '../hooks/useTerminalSize'
import { formatDate } from '../utils/log'
type LogSelectorProps = {
logs: LogOption[]
onSelect: (logValue: number) => void
}
export function LogSelector({
logs,
onSelect,
}: LogSelectorProps): React.ReactNode {
const { rows, columns } = useTerminalSize()
if (logs.length === 0) {
return null
}
const visibleCount = rows - 3 // Account for header and footer
const hiddenCount = Math.max(0, logs.length - visibleCount)
// Create formatted options
// Calculate column widths
const indexWidth = 7 // [0] to [99] with extra spaces
const modifiedWidth = 21 // "Yesterday at 7:49 pm" with space
const createdWidth = 21 // "Yesterday at 7:49 pm" with space
const countWidth = 9 // "999 msgs" (right-aligned)
const options = logs.map((log, i) => {
const index = `[${i}]`.padEnd(indexWidth)
const modified = formatDate(log.modified).padEnd(modifiedWidth)
const created = formatDate(log.created).padEnd(createdWidth)
const msgCount = `${log.messageCount}`.padStart(countWidth)
const prompt = log.firstPrompt
let branchInfo = ''
if (log.forkNumber) branchInfo += ` (fork #${log.forkNumber})`
if (log.sidechainNumber)
branchInfo += ` (sidechain #${log.sidechainNumber})`
const labelTxt = `${index}${modified}${created}${msgCount} ${prompt}${branchInfo}`
const truncated =
labelTxt.length > columns - 2 // Account for "> " selection cursor
? `${labelTxt.slice(0, columns - 5)}...`
: labelTxt
return {
label: truncated,
value: log.value.toString(),
}
})
return (
<Box flexDirection="column" height="100%" width="100%">
<Box paddingLeft={9}>
<Text bold color={getTheme().text}>
Modified
</Text>
<Text>{' '}</Text>
<Text bold color={getTheme().text}>
Created
</Text>
<Text>{' '}</Text>
<Text bold color={getTheme().text}>
# Messages
</Text>
<Text> </Text>
<Text bold color={getTheme().text}>
First message
</Text>
</Box>
<Select
options={options}
onChange={index => onSelect(parseInt(index, 10))}
visibleOptionCount={visibleCount}
/>
{hiddenCount > 0 && (
<Box paddingLeft={2}>
<Text color={getTheme().secondaryText}>and {hiddenCount} more</Text>
</Box>
)}
</Box>
)
}