- 知识库笔记列表支持按实体精确筛选(路由/服务/仓储层透传,关系图索引查询) - 自定义智能体技能白名单在 skill_view 与 skill_manage 的 list/view 别名上同样生效; config 未声明 skills 时视为无可见技能 - 嵌入圆桌主题解析默认深蓝,强制主题期间不再写 localStorage 覆盖主站选择 - 智能体提问建议拆出 agent-question-chips 组件,编辑器与详情面板联动优化 - 新增 qa-client 问答测试脚本 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
79 lines
2.6 KiB
TypeScript
79 lines
2.6 KiB
TypeScript
"use client";
|
||
|
||
import { ArrowRightIcon, ChevronDownIcon, ChevronUpIcon } from "lucide-react";
|
||
import { useState } from "react";
|
||
|
||
import type { AgentQuestion } from "@/core/agents";
|
||
import { desensitize } from "@/lib/desensitize";
|
||
import { cn } from "@/lib/utils";
|
||
|
||
/** Chips shown before the rest folds behind the 更多问题 toggle. */
|
||
const VISIBLE_COUNT = 4;
|
||
|
||
/**
|
||
* 常用问题 prompt chips on the agent chat landing screen — light-gray
|
||
* borderless pills stacked left-aligned between the welcome hero and the
|
||
* input box. Clicking a chip sends the question's full prompt through the
|
||
* page's existing submit flow. Lists longer than {@link VISIBLE_COUNT} fold
|
||
* behind a 更多问题 toggle; an empty list renders nothing.
|
||
*/
|
||
export function AgentQuestionChips({
|
||
questions,
|
||
onAsk,
|
||
disabled,
|
||
className,
|
||
}: {
|
||
questions: AgentQuestion[];
|
||
onAsk: (prompt: string) => void;
|
||
disabled?: boolean;
|
||
className?: string;
|
||
}) {
|
||
const [expanded, setExpanded] = useState(false);
|
||
|
||
if (questions.length === 0) return null;
|
||
|
||
const visible = expanded ? questions : questions.slice(0, VISIBLE_COUNT);
|
||
const foldedCount = questions.length - VISIBLE_COUNT;
|
||
|
||
return (
|
||
<div className={cn("flex flex-col items-start gap-2 px-1", className)}>
|
||
{visible.map((question, index) => (
|
||
<button
|
||
key={index}
|
||
type="button"
|
||
disabled={disabled}
|
||
onClick={() => onAsk(question.prompt)}
|
||
title={desensitize(question.prompt)}
|
||
className={cn(
|
||
"group bg-muted text-foreground/90 flex max-w-full items-center gap-2 rounded-full px-4 py-2.5 text-left text-sm leading-5 transition",
|
||
"hover:bg-accent active:scale-[0.98]",
|
||
"disabled:cursor-not-allowed disabled:opacity-50",
|
||
)}
|
||
>
|
||
<span className="min-w-0 truncate">{desensitize(question.title)}</span>
|
||
<ArrowRightIcon className="text-muted-foreground size-3.5 shrink-0 transition-transform group-hover:translate-x-0.5" />
|
||
</button>
|
||
))}
|
||
{foldedCount > 0 && (
|
||
<button
|
||
type="button"
|
||
onClick={() => setExpanded((v) => !v)}
|
||
className="text-muted-foreground hover:text-foreground flex items-center gap-1 rounded-full px-4 py-1.5 text-xs transition-colors"
|
||
>
|
||
{expanded ? (
|
||
<>
|
||
收起
|
||
<ChevronUpIcon className="size-3.5" />
|
||
</>
|
||
) : (
|
||
<>
|
||
更多问题({foldedCount})
|
||
<ChevronDownIcon className="size-3.5" />
|
||
</>
|
||
)}
|
||
</button>
|
||
)}
|
||
</div>
|
||
);
|
||
}
|