feat: 去掉demo按钮

This commit is contained in:
ZyGuo committed 2026-06-01 18:13:23 +08:00
1 parent 5f88efb2c9
commit 2e6eff43ad
1 file changed
+14 -35
+14 -35
View File
@@ -4,7 +4,6 @@ import { useRouter } from "next/navigation";
import { useCallback, useEffect, useMemo, useState } from "react";
import { type PromptInputMessage } from "@/components/ai-elements/prompt-input";
import { usePromptPrefixSettings } from "@/core/system-settings/hooks";
import { useArtifacts } from "@/components/workspace/artifacts";
import {
ChatBox,
@@ -12,7 +11,6 @@ import {
useThreadChat,
} from "@/components/workspace/chats";
import { ExportTrigger } from "@/components/workspace/export-trigger";
import { InputBox } from "@/components/workspace/input-box";
import {
MessageList,
MESSAGE_LIST_DEFAULT_PADDING_BOTTOM,
@@ -22,13 +20,13 @@ import { ThreadContext } from "@/components/workspace/messages/context";
import { ThreadTitle } from "@/components/workspace/thread-title";
import { TodoList } from "@/components/workspace/todo-list";
import { TokenUsageIndicator } from "@/components/workspace/token-usage-indicator";
import { Button } from "@/components/ui/button";
import { useI18n } from "@/core/i18n/hooks";
import { useModels } from "@/core/models/hooks";
import { useNotification } from "@/core/notification/hooks";
import { useThreadSettings } from "@/core/settings";
import { useThreadStream } from "@/core/threads/hooks";
import { useRouteBase } from "@/core/route-base";
import { useThreadSettings } from "@/core/settings";
import { usePromptPrefixSettings } from "@/core/system-settings/hooks";
import { useThreadStream } from "@/core/threads/hooks";
import { textOfMessage } from "@/core/threads/utils";
import { env } from "@/env";
import { cn } from "@/lib/utils";
@@ -97,7 +95,7 @@ export default function IframeChatPage() {
const [hasStartedConversation, setHasStartedConversation] = useState(false);
const { threadId, setThreadId, isNewThread, setIsNewThread, isMock } =
useThreadChat();
const [settings, setSettings] = useThreadSettings(threadId);
const [settings] = useThreadSettings(threadId);
const [mounted, setMounted] = useState(false);
const { tokenUsageEnabled } = useModels();
const { data: promptPrefixSettings } = usePromptPrefixSettings();
@@ -142,7 +140,7 @@ export default function IframeChatPage() {
if (textContent) {
body =
textContent.length > 200
? textContent.substring(0, 200) + "..."
? `${textContent.substring(0, 200)}...`
: textContent;
}
}
@@ -195,6 +193,7 @@ export default function IframeChatPage() {
window.dispatchEvent(
new CustomEvent("workspace:sandbox-resume-autoscroll"),
);
const extraContext: Record<string, unknown> = {};
if (shouldApplyPrefix) {
extraContext.prompt_prefix_enabled = true;
@@ -205,6 +204,7 @@ export default function IframeChatPage() {
if (externalContext) {
Object.assign(extraContext, externalContext);
}
void sendMessage(
threadId,
message,
@@ -212,15 +212,15 @@ export default function IframeChatPage() {
);
},
[
sendMessage,
threadId,
isNewThread,
hasStartedConversation,
isNewThread,
promptPrefixOn,
promptPrefixSettings,
selectedAgentId,
router,
selectedAgentId,
sendMessage,
settings.context.writing_mode,
threadId,
writingArtifactPath,
],
);
@@ -232,13 +232,6 @@ export default function IframeChatPage() {
},
[sendMessage, threadId],
);
const handleStop = useCallback(async () => {
await thread.stop();
}, [thread]);
const handleCreateDemoThread = useCallback(() => {
handleSubmit({ text: "hello", files: [] });
}, [handleSubmit]);
useEffect(() => {
const handleMessage = (event: MessageEvent<BrainyChatSubmitMessage>) => {
@@ -262,16 +255,15 @@ export default function IframeChatPage() {
: {}),
}
: undefined;
const hasPageContext =
!!pageContext &&
Object.values(pageContext).some((value) => value.length > 0);
const submitText = buildIframeMessageText({ text, prompt, pageContext });
console.log("收到插件消息", {
text,
prompt,
pageContext,
requestId: data.requestId,
});
if (!submitText) return;
const iframeContext: Record<string, unknown> = {};
@@ -291,16 +283,6 @@ export default function IframeChatPage() {
};
}, [handleSubmit]);
const promptPrefixProp = useMemo(() => {
if (!promptPrefixSettings?.enabled) return undefined;
if (!isNewThread || hasStartedConversation) return undefined;
return {
label: promptPrefixSettings.switch_label || "前缀",
on: promptPrefixOn,
onToggle: () => setPromptPrefixOn((v) => !v),
};
}, [promptPrefixSettings, isNewThread, hasStartedConversation, promptPrefixOn]);
const messageListPaddingBottom = showFollowups
? MESSAGE_LIST_DEFAULT_PADDING_BOTTOM +
MESSAGE_LIST_FOLLOWUPS_EXTRA_PADDING_BOTTOM
@@ -365,11 +347,8 @@ export default function IframeChatPage() {
</div>
</div>
{isLandingState && mounted && (
<div className="mb-6 flex min-h-40 flex-col items-center justify-center gap-4">
<div className="mb-6 flex min-h-40 flex-col items-center justify-center">
<div className="text-2xl font-medium">你好</div>
<Button onClick={handleCreateDemoThread}>
建立线程demo
</Button>
</div>
)}
{env.NEXT_PUBLIC_STATIC_WEBSITE_ONLY === "true" && (