feat: add models management and usage history components

- Introduced RequestContentDialog for displaying request content details.
- Added UsageBarChart for visualizing token usage data.
- Implemented UsageHistorySection to manage and display usage history with filtering and pagination.
- Created provider-types for managing provider-related types.
- Developed ModelsPage to encapsulate models configuration, providers, and usage history.
- Defined usage-history types and utility functions for managing usage data.
- Updated routing to include models page and redirect agents to models.
- Refactored chat store to integrate models instead of agents.
- Established models store for managing model-related state and data fetching.
This commit is contained in:
duanshuwen
2026-04-18 09:41:59 +08:00
parent 1205a96661
commit 85d92b937f
28 changed files with 343 additions and 258 deletions

View File

@@ -0,0 +1,44 @@
import DialogSurface from './DialogSurface';
import type { UsageHistoryEntry } from '../usage-history';
type RequestContentDialogProps = {
open: boolean;
entry: UsageHistoryEntry | null;
onClose: () => void;
};
function formatUsageTimestamp(timestamp?: string): string {
if (!timestamp) return '';
const date = new Date(timestamp);
if (Number.isNaN(date.getTime())) return timestamp;
return new Intl.DateTimeFormat(undefined, {
month: 'short',
day: 'numeric',
hour: '2-digit',
minute: '2-digit',
}).format(date);
}
export default function RequestContentDialog({
open,
entry,
onClose,
}: RequestContentDialogProps) {
return (
<DialogSurface
open={open}
onClose={onClose}
title="Request Content"
subtitle={entry ? `${entry.model || 'Unknown Model'}${formatUsageTimestamp(entry.timestamp)}` : undefined}
widthClassName="max-w-[800px]"
>
<div className="max-h-[60vh] overflow-y-auto rounded-[16px] border border-black/6 bg-white p-5 shadow-sm dark:border-white/8 dark:bg-[#1f1f22]">
<pre className="whitespace-pre-wrap break-words font-mono text-[13px] leading-relaxed text-[#171717] dark:text-[#f3f4f6]">
{entry?.content || ''}
</pre>
</div>
</DialogSurface>
);
}