代码修改

This commit is contained in:
fengxiangdebaozi committed 2026-05-29 11:19:58 +08:00
1 parent de597b602a
commit 1a122eb7fd
20 files changed
+812 -140

No files matched your search

@@ -36,7 +36,9 @@ import {
type RecommendCandidate,
type RecommendStreamPhase,
} from "../api/recommend";
import { useAutoScroll } from "../hooks/useAutoScroll";
import { splitInlineReasoning } from "../lib/reasoning";
import { ScrollToBottomButton } from "./ScrollToBottomButton";
/**
* Picks-selection dialog that sits between Step 1 (intent) and Step 2
@@ -453,6 +455,7 @@ export function RecommendAgentsDialog({
state.phase === "loading_agents" || state.phase === "recommending"
}
phase={state.phase}
scrollDeps={[state.rationale, state.steps, state.streamPhase]}
>
<RecommenderOutput state={state} />
</CollapsibleModelOutput>
@@ -593,16 +596,22 @@ const MODEL_OUTPUT_AUTO_CLOSE_DELAY_MS = 1000;
function CollapsibleModelOutput({
isLoading,
phase,
scrollDeps,
children,
}: {
/** True 时面板保持展开 + header 显示 spinner;涵盖加载候选 + 流式生成。 */
isLoading: boolean;
phase: DialogPhase;
/** 内容变化时触发自动滚到底(与 Step1/Step2 对话区同一套 useAutoScroll)。 */
scrollDeps: React.DependencyList;
children: React.ReactNode;
}) {
const [open, setOpen] = useState<boolean>(true);
const userTouchedRef = useRef<boolean>(false);
const hasAutoClosedRef = useRef<boolean>(false);
const modelOutputScrollRef = useRef<HTMLDivElement>(null);
const { atBottom: modelOutputAtBottom, scrollToBottom: scrollModelOutputToBottom } =
useAutoScroll(modelOutputScrollRef, scrollDeps);
// 加载中 → 保持展开(用户没手动动过的前提下)。
// 加载完成 → 延迟自动收起一次(仅一次),让出焦点给下方推荐卡片。
@@ -677,8 +686,16 @@ function CollapsibleModelOutput({
/>
</button>
{open && (
<div className="px-3 pb-3 min-h-0 flex-1 overflow-y-auto custom-scrollbar">
{children}
<div className="relative min-h-0 flex-1 flex flex-col">
<div
ref={modelOutputScrollRef}
className="px-3 pb-3 min-h-0 flex-1 overflow-y-auto custom-scrollbar"
>
{children}
</div>
{!modelOutputAtBottom && (
<ScrollToBottomButton onClick={scrollModelOutputToBottom} />
)}
</div>
)}
</section>
@@ -751,7 +768,10 @@ function RecommenderOutput({ state }: { state: InternalState }) {
{hasReasoning && (
<ReasoningBlock
streaming={isStreaming}
contentClassName="max-h-48 overflow-y-auto custom-scrollbar"
contentClassName={cn(
"overflow-y-auto custom-scrollbar",
isStreaming ? "max-h-none" : "max-h-48",
)}
>
{reasoning!}
</ReasoningBlock>
@@ -762,7 +782,12 @@ function RecommenderOutput({ state }: { state: InternalState }) {
)}
{hasRationale && (
<div className="max-h-40 overflow-y-auto custom-scrollbar rounded-md border border-slate-200 bg-white px-3 py-2.5 text-sm text-slate-700 leading-relaxed">
<div
className={cn(
"overflow-y-auto custom-scrollbar rounded-md border border-slate-200 bg-white px-3 py-2.5 text-sm text-slate-700 leading-relaxed",
isStreaming ? "max-h-none" : "max-h-40",
)}
>
<MarkdownContent>{cleanedRationale}</MarkdownContent>
{isStreaming && <StreamingCursor />}
</div>