feat: update knowledge and agent UI

This commit is contained in:
吉鑫升 committed 2026-06-11 16:18:38 +08:00
1 parent bebe4feccf
commit 7efd811e75
27 files changed
+2949 -782

No files matched your search

@@ -2,35 +2,31 @@
import { BotIcon } from "lucide-react";
import { type Agent, normalizeAgentQuestions } from "@/core/agents";
import { type Agent } from "@/core/agents";
import { desensitize } from "@/lib/desensitize";
import { cn } from "@/lib/utils";
/**
* Landing (home) hero shown above the input box before the first message of an
* agent conversation. Mirrors the qclaw landing screen: centered avatar, a
* "Hi,我是{name}" greeting, the agent's one-line description as a slogan, and
* the agent's admin-configured common questions surfaced as clickable starter
* pills. Clicking a pill sends it as the opening message via `onAskQuestion`.
* agent conversation: centered avatar, a "Hi,我是{name}" greeting and the
* agent's description as a slogan. The description is clamped to two lines
* (full text on hover) so a long blurb can never push the input box below the
* fold. The agent's 常用问题 are rendered by the page as a list beside the
* input box, not here.
*/
export function AgentWelcome({
className,
agent,
agentName,
onAskQuestion,
disabled,
}: {
className?: string;
agent: Agent | null | undefined;
agentName: string;
onAskQuestion?: (text: string) => void;
disabled?: boolean;
}) {
const displayName = desensitize(agent?.name ?? agentName);
const description = agent?.description
? desensitize(agent.description)
: undefined;
const questions = normalizeAgentQuestions(agent?.common_questions);
return (
<div
@@ -46,29 +42,13 @@ export function AgentWelcome({
Hi,我是{displayName}
</div>
{description && (
<p className="text-muted-foreground max-w-xl text-base leading-relaxed">
<p
className="text-muted-foreground line-clamp-2 max-w-xl text-base leading-relaxed"
title={description}
>
{description}
</p>
)}
{onAskQuestion && questions.length > 0 && (
<div className="mt-1 flex flex-wrap items-center justify-center gap-2">
{questions.slice(0, 6).map((question, index) => (
<button
key={index}
type="button"
disabled={disabled}
onClick={() => onAskQuestion(question.prompt)}
title={desensitize(question.prompt)}
className={cn(
"border-border/70 bg-card/60 hover:bg-accent hover:border-border max-w-[280px] truncate rounded-full border px-4 py-2 text-sm transition-colors",
"disabled:cursor-not-allowed disabled:opacity-50",
)}
>
{desensitize(question.title)}
</button>
))}
</div>
)}
</div>
);
}