d5dfb7a928
真实演示中暴露的两个 bug: 1) Milvus 重连健壮性(mcp-go/internal/rag/milvus.go) 基础设施重启后向量集合丢失,但 ensure() 的 m.ok 缓存认定集合仍在、跳过重建, 导致 insert/search 报 "collection not found",必须重启进程才恢复。 修复:新增 invalidate() + isCollectionGone();insert/search 遇"集合不存在"类错误 时清缓存 + 重 ensure(重建集合)+ 重试一次。 实测:运行期 drop 集合后再入库 → 日志"清缓存重建后重试写入" → 写入成功且可检索(自愈,无需重启)。 2) 检索框布局塌陷(desktop frontend/src/ui/Input.tsx) Phase A 给 Input 基类内置了 w-full,与检索行调用方的 flex-1 / w-16 冲突, 查询框被挤成一条缝。修复:基类去掉 w-full,宽度交由调用方(Field 内 flex-col 自动撑满, 或显式 w-full/flex-1/w-16)。 实测(Preview):查询框 412px、topK 64px;报告页输入仍撑满(764/220px),无回归。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
35 lines
1.5 KiB
TypeScript
35 lines
1.5 KiB
TypeScript
import type { InputHTMLAttributes, TextareaHTMLAttributes, SelectHTMLAttributes, ReactNode } from "react";
|
|
import { cn } from "./cn";
|
|
|
|
// 注意:基类不含宽度。宽度由调用方决定(Field 内为 flex-col 自动撑满,
|
|
// 或显式 w-full / flex-1 / w-16),避免 w-full 与 flex-1/w-16 冲突塌陷。
|
|
const fieldBase =
|
|
"rounded-md border border-line bg-ink-950 text-sm text-slate-200 placeholder:text-slate-600 transition focus:border-brand focus:outline-none focus:ring-1 focus:ring-brand/40 disabled:opacity-50";
|
|
|
|
export function Input({ className, ...rest }: InputHTMLAttributes<HTMLInputElement>) {
|
|
return <input className={cn(fieldBase, "h-9 px-3", className)} {...rest} />;
|
|
}
|
|
|
|
export function Textarea({ className, ...rest }: TextareaHTMLAttributes<HTMLTextAreaElement>) {
|
|
return <textarea className={cn(fieldBase, "px-3 py-2 leading-relaxed", className)} {...rest} />;
|
|
}
|
|
|
|
export function Select({ className, children, ...rest }: SelectHTMLAttributes<HTMLSelectElement>) {
|
|
return (
|
|
<select className={cn(fieldBase, "h-9 cursor-pointer px-3", className)} {...rest}>
|
|
{children}
|
|
</select>
|
|
);
|
|
}
|
|
|
|
// Field 包一层标签 + 控件,统一表单纵向节奏。
|
|
export function Field({ label, hint, children }: { label: string; hint?: string; children: ReactNode }) {
|
|
return (
|
|
<label className="flex flex-col gap-1.5">
|
|
<span className="text-[11px] font-medium text-slate-400">{label}</span>
|
|
{children}
|
|
{hint && <span className="text-[10px] text-slate-600">{hint}</span>}
|
|
</label>
|
|
);
|
|
}
|