Compare commits
No commits in common. "19b888f69a8dd4cec9ddcec0bd026b6451da06f9" and "df95190d70c7665e7beea67855b5d322dbfd4b91" have entirely different histories.
19b888f69a
...
df95190d70
|
|
@ -135,16 +135,10 @@ export default function ChatPage() {
|
||||||
setHistoryCutoff(null);
|
setHistoryCutoff(null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (hasSubmitted) return;
|
if (historyCutoff === null && !thread.isThreadLoading) {
|
||||||
// Welcome 态下、未提交前,把当前已有消息都当作“历史”切掉。
|
setHistoryCutoff(thread.messages.length);
|
||||||
// 这样即使历史消息是后续异步补齐,也不会重新露出。
|
}
|
||||||
setHistoryCutoff((prev) => {
|
|
||||||
const next = thread.messages.length;
|
|
||||||
if (prev === null) return next;
|
|
||||||
return next > prev ? next : prev;
|
|
||||||
});
|
|
||||||
}, [
|
}, [
|
||||||
hasSubmitted,
|
|
||||||
historyCutoff,
|
historyCutoff,
|
||||||
shouldRenderHistory,
|
shouldRenderHistory,
|
||||||
thread.isThreadLoading,
|
thread.isThreadLoading,
|
||||||
|
|
@ -206,9 +200,9 @@ export default function ChatPage() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setHasSubmitted(true);
|
setHasSubmitted(true);
|
||||||
void sendMessage(safeThreadId, message);
|
void sendMessage(threadId, message);
|
||||||
},
|
},
|
||||||
[isSelectedSkillBootstrapping, safeThreadId, sendMessage],
|
[isSelectedSkillBootstrapping, sendMessage, threadId],
|
||||||
);
|
);
|
||||||
const handleStop = useCallback(async () => {
|
const handleStop = useCallback(async () => {
|
||||||
await thread.stop();
|
await thread.stop();
|
||||||
|
|
@ -337,11 +331,9 @@ export default function ChatPage() {
|
||||||
threadId={threadId}
|
threadId={threadId}
|
||||||
thread={thread}
|
thread={thread}
|
||||||
messagesOverride={
|
messagesOverride={
|
||||||
shouldRenderHistory
|
shouldRenderHistory || historyCutoff === null
|
||||||
? undefined
|
? undefined
|
||||||
: historyCutoff === null
|
: thread.messages.slice(historyCutoff)
|
||||||
? []
|
|
||||||
: thread.messages.slice(historyCutoff)
|
|
||||||
}
|
}
|
||||||
paddingBottom={todoListCollapsed ? 160 : 280}
|
paddingBottom={todoListCollapsed ? 160 : 280}
|
||||||
showScrollToBottomButton={!showWelcomeStyle}
|
showScrollToBottomButton={!showWelcomeStyle}
|
||||||
|
|
|
||||||
|
|
@ -691,13 +691,13 @@ function IframeSkillDialogButton({
|
||||||
<Tag key={`${skill.skill_id}-${skill.title}-${index}`} className="shrink-0">
|
<Tag key={`${skill.skill_id}-${skill.title}-${index}`} className="shrink-0">
|
||||||
{skill.title}
|
{skill.title}
|
||||||
{/* TODO: 因为后端接口不支持取消选择skill,所以暂时禁用取消选择按钮 */}
|
{/* TODO: 因为后端接口不支持取消选择skill,所以暂时禁用取消选择按钮 */}
|
||||||
<button
|
{/* <button
|
||||||
onClick={() => clearSkill(skill.skill_id)}
|
onClick={() => clearSkill(skill.skill_id)}
|
||||||
className="hover:bg-muted-foreground/20 ml-1 rounded-full"
|
className="hover:bg-muted-foreground/20 ml-1 rounded-full"
|
||||||
type="button"
|
type="button"
|
||||||
>
|
>
|
||||||
<XIcon className="size-3" />
|
<XIcon className="size-3" />
|
||||||
</button>
|
</button> */}
|
||||||
</Tag>
|
</Tag>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -69,15 +69,6 @@ function getStreamErrorMessage(error: unknown): string {
|
||||||
return "Request failed.";
|
return "Request failed.";
|
||||||
}
|
}
|
||||||
|
|
||||||
function normalizeThreadId(
|
|
||||||
value: string | null | undefined,
|
|
||||||
): string | undefined {
|
|
||||||
if (!value) return undefined;
|
|
||||||
const normalized = value.trim();
|
|
||||||
if (!normalized || normalized === "new") return undefined;
|
|
||||||
return normalized;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function useThreadStreamLegacy({
|
export function useThreadStreamLegacy({
|
||||||
threadId,
|
threadId,
|
||||||
isNewThread,
|
isNewThread,
|
||||||
|
|
@ -164,14 +155,12 @@ export function useThreadStream({
|
||||||
}, [onStart, onFinish, onToolEnd]);
|
}, [onStart, onFinish, onToolEnd]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const normalizedThreadId = normalizeThreadId(threadId) ?? null;
|
const normalizedThreadId = threadId ?? null;
|
||||||
if (!normalizedThreadId) {
|
if (!normalizedThreadId) {
|
||||||
// Just reset for new thread creation when threadId becomes null/undefined
|
// Just reset for new thread creation when threadId becomes null/undefined
|
||||||
startedRef.current = false;
|
startedRef.current = false;
|
||||||
|
setOnStreamThreadId(normalizedThreadId);
|
||||||
}
|
}
|
||||||
setOnStreamThreadId((prev) =>
|
|
||||||
prev === normalizedThreadId ? prev : normalizedThreadId,
|
|
||||||
);
|
|
||||||
threadIdRef.current = normalizedThreadId;
|
threadIdRef.current = normalizedThreadId;
|
||||||
}, [threadId]);
|
}, [threadId]);
|
||||||
|
|
||||||
|
|
@ -299,9 +288,7 @@ export function useThreadStream({
|
||||||
|
|
||||||
const text = message.text.trim();
|
const text = message.text.trim();
|
||||||
const resolvedThreadId =
|
const resolvedThreadId =
|
||||||
normalizeThreadId(threadId) ??
|
threadId ?? threadIdRef.current ?? undefined;
|
||||||
normalizeThreadId(threadIdRef.current) ??
|
|
||||||
undefined;
|
|
||||||
if (resolvedThreadId === "new") {
|
if (resolvedThreadId === "new") {
|
||||||
toast.error("Invalid thread id 'new'. Please refresh and retry.");
|
toast.error("Invalid thread id 'new'. Please refresh and retry.");
|
||||||
sendInFlightRef.current = false;
|
sendInFlightRef.current = false;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue