Update agent flow and frontend chat experience

This commit is contained in:
Xin Wang
2026-03-31 21:58:24 +08:00
parent e34e569de4
commit 0e2dafe440
13 changed files with 345 additions and 372 deletions

View File

@@ -6,10 +6,27 @@ import { WelcomeScreen } from "@/components/WelcomeScreen";
import { ChatMessagesView } from "@/components/ChatMessagesView";
import { Button } from "@/components/ui/button";
const getSourceDisplayName = (source: any): string | null => {
if (source?.title) {
return source.title;
}
if (source?.value) {
try {
return new URL(source.value).hostname.replace(/^www\./, "");
} catch {
return null;
}
}
return source?.label || null;
};
export default function App() {
const [processedEventsTimeline, setProcessedEventsTimeline] = useState<
ProcessedEvent[]
>([]);
const [selectedModel, setSelectedModel] = useState("openai/gpt-5.4");
const [historicalActivities, setHistoricalActivities] = useState<
Record<string, ProcessedEvent[]>
>({});
@@ -38,7 +55,7 @@ export default function App() {
const sources = event.web_research.sources_gathered || [];
const numSources = sources.length;
const uniqueLabels = [
...new Set(sources.map((s: any) => s.label).filter(Boolean)),
...new Set(sources.map(getSourceDisplayName).filter(Boolean)),
];
const exampleLabels = uniqueLabels.slice(0, 3).join(", ");
processedEvent = {
@@ -157,6 +174,8 @@ export default function App() {
handleSubmit={handleSubmit}
isLoading={thread.isLoading}
onCancel={handleCancel}
model={selectedModel}
onModelChange={setSelectedModel}
/>
) : error ? (
<div className="flex flex-col items-center justify-center h-full">
@@ -181,6 +200,8 @@ export default function App() {
onCancel={handleCancel}
liveActivityEvents={processedEventsTimeline}
historicalActivities={historicalActivities}
model={selectedModel}
onModelChange={setSelectedModel}
/>
)}
</main>

View File

@@ -230,6 +230,8 @@ interface ChatMessagesViewProps {
onCancel: () => void;
liveActivityEvents: ProcessedEvent[];
historicalActivities: Record<string, ProcessedEvent[]>;
model: string;
onModelChange: (model: string) => void;
}
export function ChatMessagesView({
@@ -240,6 +242,8 @@ export function ChatMessagesView({
onCancel,
liveActivityEvents,
historicalActivities,
model,
onModelChange,
}: ChatMessagesViewProps) {
const [copiedMessageId, setCopiedMessageId] = useState<string | null>(null);
@@ -316,6 +320,8 @@ export function ChatMessagesView({
isLoading={isLoading}
onCancel={onCancel}
hasHistory={messages.length > 0}
model={model}
onModelChange={onModelChange}
/>
</div>
);

View File

@@ -16,6 +16,8 @@ interface InputFormProps {
onCancel: () => void;
isLoading: boolean;
hasHistory: boolean;
model: string;
onModelChange: (model: string) => void;
}
export const InputForm: React.FC<InputFormProps> = ({
@@ -23,10 +25,11 @@ export const InputForm: React.FC<InputFormProps> = ({
onCancel,
isLoading,
hasHistory,
model,
onModelChange,
}) => {
const [internalInputValue, setInternalInputValue] = useState("");
const [effort, setEffort] = useState("medium");
const [model, setModel] = useState("gemini-2.5-flash-preview-04-17");
const handleInternalSubmit = (e?: React.FormEvent) => {
if (e) e.preventDefault();
@@ -130,33 +133,41 @@ export const InputForm: React.FC<InputFormProps> = ({
<Cpu className="h-4 w-4 mr-2" />
Model
</div>
<Select value={model} onValueChange={setModel}>
<Select value={model} onValueChange={onModelChange}>
<SelectTrigger className="w-[150px] bg-transparent border-none cursor-pointer">
<SelectValue placeholder="Model" />
</SelectTrigger>
<SelectContent className="bg-neutral-700 border-neutral-600 text-neutral-300 cursor-pointer">
<SelectItem
value="gemini-2.0-flash"
value="openai/gpt-5.4"
className="hover:bg-neutral-600 focus:bg-neutral-600 cursor-pointer"
>
<div className="flex items-center">
<Zap className="h-4 w-4 mr-2 text-yellow-400" /> 2.0 Flash
<Zap className="h-4 w-4 mr-2 text-emerald-400" /> openai/gpt-5.4
</div>
</SelectItem>
<SelectItem
value="gemini-2.5-flash-preview-04-17"
value="deepseek-v3"
className="hover:bg-neutral-600 focus:bg-neutral-600 cursor-pointer"
>
<div className="flex items-center">
<Zap className="h-4 w-4 mr-2 text-orange-400" /> 2.5 Flash
<Cpu className="h-4 w-4 mr-2 text-cyan-400" /> deepseek-v3
</div>
</SelectItem>
<SelectItem
value="gemini-2.5-pro-preview-05-06"
value="glm-4.5-air"
className="hover:bg-neutral-600 focus:bg-neutral-600 cursor-pointer"
>
<div className="flex items-center">
<Cpu className="h-4 w-4 mr-2 text-purple-400" /> 2.5 Pro
<Cpu className="h-4 w-4 mr-2 text-sky-400" /> glm-4.5-air
</div>
</SelectItem>
<SelectItem
value="glm-4.7"
className="hover:bg-neutral-600 focus:bg-neutral-600 cursor-pointer"
>
<div className="flex items-center">
<Cpu className="h-4 w-4 mr-2 text-violet-400" /> glm-4.7
</div>
</SelectItem>
</SelectContent>

View File

@@ -8,12 +8,16 @@ interface WelcomeScreenProps {
) => void;
onCancel: () => void;
isLoading: boolean;
model: string;
onModelChange: (model: string) => void;
}
export const WelcomeScreen: React.FC<WelcomeScreenProps> = ({
handleSubmit,
onCancel,
isLoading,
model,
onModelChange,
}) => (
<div className="h-full flex flex-col items-center justify-center text-center px-4 flex-1 w-full max-w-3xl mx-auto gap-4">
<div>
@@ -30,6 +34,8 @@ export const WelcomeScreen: React.FC<WelcomeScreenProps> = ({
isLoading={isLoading}
onCancel={onCancel}
hasHistory={false}
model={model}
onModelChange={onModelChange}
/>
</div>
<p className="text-xs text-neutral-500">