diff --git a/.githooks/pre-commit b/.githooks/pre-commit deleted file mode 100755 index f18ee5b..0000000 --- a/.githooks/pre-commit +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh -# Reject commit if author or committer email is *@bytedance.com - -config_email="$(git config user.email)" -author_email="${GIT_AUTHOR_EMAIL:-$config_email}" -committer_email="${GIT_COMMITTER_EMAIL:-$config_email}" - -check() { - case "$1" in - *@bytedance.com) return 0;; # matched = bad - *) return 1;; - esac -} - -err=0 -if check "$author_email"; then - echo "pre-commit: 拒绝提交:作者邮箱不能为 *@bytedance.com (当前: $author_email)" - err=1 -fi -if check "$committer_email"; then - echo "pre-commit: 拒绝提交:提交者邮箱不能为 *@bytedance.com (当前: $committer_email)" - err=1 -fi - -if [ $err -eq 1 ]; then - echo "请使用: git config user.email \"lofisuchat@gmail.com\"" - exit 1 -fi -exit 0 diff --git a/.gitignore b/.gitignore index 1bfd7f6..559f548 100644 --- a/.gitignore +++ b/.gitignore @@ -35,5 +35,8 @@ coverage/ skills/custom/* logs/ +# Local git hooks (keep only on this machine, do not push) +.githooks/ + # pnpm .pnpm-store diff --git a/frontend/src/app/workspace/chats/[thread_id]/page.tsx b/frontend/src/app/workspace/chats/[thread_id]/page.tsx index d521b7d..5d39207 100644 --- a/frontend/src/app/workspace/chats/[thread_id]/page.tsx +++ b/frontend/src/app/workspace/chats/[thread_id]/page.tsx @@ -28,8 +28,9 @@ import { Welcome } from "@/components/workspace/welcome"; import { useI18n } from "@/core/i18n/hooks"; import { useNotification } from "@/core/notification/hooks"; import { useLocalSettings } from "@/core/settings"; -import { type AgentThread } from "@/core/threads"; +import { type AgentThread, type AgentThreadState } from "@/core/threads"; import { useSubmitThread, useThreadStream } from "@/core/threads/hooks"; +import type { Message } from "@langchain/langgraph-sdk"; import { pathOfThread, textOfMessage, @@ -88,10 +89,12 @@ export default function ChatPage() { }, [threadIdFromPath]); const { showNotification } = useNotification(); + const [finalState, setFinalState] = useState(null); const thread = useThreadStream({ isNewThread, threadId, onFinish: (state) => { + setFinalState(state); if (document.hidden || !document.hasFocus()) { let body = "Conversation finished"; const lastMessage = state.messages[state.messages.length - 1]; @@ -111,6 +114,9 @@ export default function ChatPage() { } }, }); + useEffect(() => { + if (thread.isLoading) setFinalState(null); + }, [thread.isLoading]); const title = useMemo(() => { let result = isNewThread @@ -239,6 +245,11 @@ export default function ChatPage() { className={cn("size-full", !isNewThread && "pt-10")} threadId={threadId} thread={thread} + messagesOverride={ + !thread.isLoading && finalState?.messages + ? (finalState.messages as Message[]) + : undefined + } paddingBottom={todoListCollapsed ? 160 : 280} /> diff --git a/frontend/src/components/workspace/messages/message-list.tsx b/frontend/src/components/workspace/messages/message-list.tsx index 24232aa..430d94e 100644 --- a/frontend/src/components/workspace/messages/message-list.tsx +++ b/frontend/src/components/workspace/messages/message-list.tsx @@ -18,6 +18,7 @@ import { useRehypeSplitWordsIntoSpans } from "@/core/rehype"; import type { Subtask } from "@/core/tasks"; import { useUpdateSubtask } from "@/core/tasks/context"; import type { AgentThreadState } from "@/core/threads"; +import type { Message } from "@langchain/langgraph-sdk"; import { cn } from "@/lib/utils"; import { ArtifactFileList } from "../artifacts/artifact-file-list"; @@ -33,16 +34,20 @@ export function MessageList({ className, threadId, thread, + messagesOverride, paddingBottom = 160, }: { className?: string; threadId: string; thread: UseStream; + /** When set (e.g. from onFinish), use instead of thread.messages so SSE end shows complete state. */ + messagesOverride?: Message[]; paddingBottom?: number; }) { const { t } = useI18n(); const rehypePlugins = useRehypeSplitWordsIntoSpans(thread.isLoading); const updateSubtask = useUpdateSubtask(); + const messages = messagesOverride ?? thread.messages; if (thread.isThreadLoading) { return ; } @@ -51,7 +56,7 @@ export function MessageList({ className={cn("flex size-full flex-col justify-center", className)} > - {groupMessages(thread.messages, (group) => { + {groupMessages(messages, (group) => { if (group.type === "human" || group.type === "assistant") { return ( block in stream); also show loading while streaming with citation block. */ export function shouldShowCitationLoading( rawContent: string, cleanContent: string, isLoading: boolean, ): boolean { - return ( - (isLoading && hasCitationsBlock(rawContent)) || - (hasCitationsBlock(rawContent) && hasUnreplacedCitationRefs(cleanContent)) - ); + if (hasUnreplacedCitationRefs(cleanContent)) return true; + return isLoading && hasCitationsBlock(rawContent); } /**