style: prettier

This commit is contained in:
肖应宇 2026-03-18 12:03:36 +08:00
parent b5b1cd6ad8
commit 917f0ef591
10 changed files with 174 additions and 76 deletions

View File

@ -82,7 +82,9 @@ export default function ChatPage() {
console.log("[ChatPage] skillBootstrap:", skillBootstrap);
if (!threadId || !skillBootstrap?.contentId) {
console.log("[ChatPage] skillBootstrap: skipping (no threadId or no contentId)");
console.log(
"[ChatPage] skillBootstrap: skipping (no threadId or no contentId)",
);
setIsSkillBootstrapping(false);
return;
}
@ -91,7 +93,10 @@ export default function ChatPage() {
const initKey = `${threadId}:${skillBootstrap.contentId}:${languageType}`;
console.log("[ChatPage] initKey:", initKey);
console.log("[ChatPage] alreadyBootstrapped:", skillBootstrappedKeyRef.current);
console.log(
"[ChatPage] alreadyBootstrapped:",
skillBootstrappedKeyRef.current,
);
if (skillBootstrappedKeyRef.current === initKey) {
console.log("[ChatPage] skillBootstrap already done for key:", initKey);
@ -130,21 +135,29 @@ export default function ChatPage() {
if (!cancelled) {
skillBootstrappedKeyRef.current = initKey;
setIsSkillBootstrapping(false);
console.log("[ChatPage] ========== SKILL BOOTSTRAP SUCCESS ==========");
console.log(
"[ChatPage] ========== SKILL BOOTSTRAP SUCCESS ==========",
);
// 使用 toast 显示成功状态
toast.success(`已加载 Skill #${skillBootstrap.contentId}大模型将根据情况触发此 Skill`, {
id: toastId,
icon: false,
});
toast.success(
`已加载 Skill #${skillBootstrap.contentId}大模型将根据情况触发此 Skill`,
{
id: toastId,
icon: false,
},
);
} else {
console.log("[ChatPage] bootstrap cancelled, not updating state");
toast.dismiss(toastId);
}
} catch (error) {
console.error("[ChatPage] ========== SKILL BOOTSTRAP FAILED ==========");
console.error(
"[ChatPage] ========== SKILL BOOTSTRAP FAILED ==========",
);
if (!cancelled) {
const message = error instanceof Error ? error.message : "Skill 初始化失败";
const message =
error instanceof Error ? error.message : "Skill 初始化失败";
console.error("[ChatPage] error message:", message);
setIsSkillBootstrapping(false);
@ -205,7 +218,9 @@ export default function ChatPage() {
// [移植自 main 分支 ef9a071] skill 初始化中禁止提交
if (isSkillBootstrapping) {
console.log("[ChatPage] handleSubmit BLOCKED: skill bootstrapping in progress");
console.log(
"[ChatPage] handleSubmit BLOCKED: skill bootstrapping in progress",
);
return;
}
@ -222,16 +237,18 @@ export default function ChatPage() {
return (
<ThreadContext.Provider value={{ thread, isMock }}>
<ChatBox threadId={threadId}>
<div className={cn(
"relative flex size-full min-h-0 justify-between",
!isNewThread && "bg-background"
)}>
<div
className={cn(
"relative flex size-full min-h-0 justify-between",
!isNewThread && "bg-background",
)}
>
<header
className={cn(
"absolute top-0 right-0 left-0 z-30 mx-[20px] grid h-[58px] shrink-0 grid-cols-3 items-center rounded-t-[20px] py-[15px]",
isNewThread
? "bg-background/0 backdrop-blur-none"
: "bg-background/80 backdrop-blur border-b",
: "bg-background/80 border-b backdrop-blur",
)}
>
{/* 返回查看结果左箭头 - 新会话时隐藏 */}
@ -313,7 +330,7 @@ export default function ChatPage() {
>
<InputBox
className={cn(
"-translate-y-4 w-[720px] rounded-[20px] bg-[#FBFAFC]",
"w-[720px] -translate-y-4 rounded-[20px] bg-[#FBFAFC]",
)}
isNewThread={isNewThread}
threadId={threadId}
@ -378,9 +395,7 @@ export default function ChatPage() {
<DevDialogHeader>
<DevDialogTitle>Skill </DevDialogTitle>
</DevDialogHeader>
<p className="text-muted-foreground text-sm">
{errorMessage}
</p>
<p className="text-muted-foreground text-sm">{errorMessage}</p>
<DevDialogFooter singleColumn>
<Button
className="w-full bg-[#f9f8fa] hover:bg-[#8E47F0] hover:text-white"

View File

@ -1099,25 +1099,25 @@ export const PromptInputSubmit = ({
return (
<Tooltip content="请注意此功能将消耗token请保证账户余额大于200可学豆。">
<InputGroupButton
aria-label="Submit"
// 被button{bgc:#fff}覆盖了,只能加"!"
className={cn(
"h-[40px] w-[140px] rounded-[10px] border-0 font-bold transition-all",
// isDisabled
// ? "cursor-not-allowed !bg-gray-200 text-gray-400":
"!bg-[#F0E8FB] text-[#8E47F0] hover:!bg-[#8E47F0] hover:text-[#FFFFFF]",
className,
)}
size={size}
type="submit"
variant={variant}
// disabled={isDisabled}
{...props}
>
{/* {children ?? Icon} */}
{text}
</InputGroupButton>
<InputGroupButton
aria-label="Submit"
// 被button{bgc:#fff}覆盖了,只能加"!"
className={cn(
"h-[40px] w-[140px] rounded-[10px] border-0 font-bold transition-all",
// isDisabled
// ? "cursor-not-allowed !bg-gray-200 text-gray-400":
"!bg-[#F0E8FB] text-[#8E47F0] hover:!bg-[#8E47F0] hover:text-[#FFFFFF]",
className,
)}
size={size}
type="submit"
variant={variant}
// disabled={isDisabled}
{...props}
>
{/* {children ?? Icon} */}
{text}
</InputGroupButton>
</Tooltip>
);
};

View File

@ -61,7 +61,7 @@ export const Suggestion = ({
return (
<Button
className={cn(
"text-muted-foreground cursor-pointer bg-[#F9F8FA] rounded-full px-[20px] py-[15px] text-xs font-normal",
"text-muted-foreground cursor-pointer rounded-full bg-[#F9F8FA] px-[20px] py-[15px] text-xs font-normal",
className,
)}
onClick={handleClick}

View File

@ -6,7 +6,7 @@ const Toaster = ({ ...props }: ToasterProps) => {
return (
<Sonner
theme="dark"
className="toaster group "
className="toaster group"
position="top-center"
icons={{
success: null,
@ -21,14 +21,15 @@ const Toaster = ({ ...props }: ToasterProps) => {
color: "#ffffff",
border: "none",
borderRadius: "12px",
fontFamily: "-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",
fontFamily:
"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",
fontSize: "14px",
fontWeight: 400,
padding: "12px 20px",
textAlign: "center",
maxWidth: "320px",
minWidth:"300px",
justifyContent:"center"
minWidth: "300px",
justifyContent: "center",
},
}}
style={

View File

@ -68,7 +68,12 @@ export function useThreadChat(): ThreadChatResult {
}
const isnewParam = searchParams.get("isnew")?.trim().toLowerCase();
const result = isnewParam !== "false";
console.log("[useThreadChat] isnew param:", isnewParam, "-> createNewSession:", result);
console.log(
"[useThreadChat] isnew param:",
isnewParam,
"-> createNewSession:",
result,
);
return result;
}, [threadIdFromPath, searchParams]);
@ -90,31 +95,45 @@ export function useThreadChat(): ThreadChatResult {
// [移植自 main 分支 ef9a071] 获取 skill 初始化参数 (从 URL)
const skillBootstrapFromUrl = useMemo(() => {
console.log("[useThreadChat] --- Parsing skillBootstrap params from URL ---");
console.log(
"[useThreadChat] --- Parsing skillBootstrap params from URL ---",
);
const skillIdRaw = searchParams.get("skill_id")?.trim();
console.log("[useThreadChat] skill_id raw:", skillIdRaw);
if (!skillIdRaw) {
console.log("[useThreadChat] skillBootstrapFromUrl: undefined (no skill_id)");
console.log(
"[useThreadChat] skillBootstrapFromUrl: undefined (no skill_id)",
);
return undefined;
}
const contentId = Number(skillIdRaw);
console.log("[useThreadChat] contentId parsed:", contentId, "isFinite:", Number.isFinite(contentId));
console.log(
"[useThreadChat] contentId parsed:",
contentId,
"isFinite:",
Number.isFinite(contentId),
);
if (!Number.isFinite(contentId)) {
console.log("[useThreadChat] skillBootstrapFromUrl: undefined (invalid contentId)");
console.log(
"[useThreadChat] skillBootstrapFromUrl: undefined (invalid contentId)",
);
return undefined;
}
const languageTypeRaw =
searchParams.get("languageType")?.trim() ??
searchParams.get("language_type")?.trim();
const languageType = languageTypeRaw
? Number(languageTypeRaw)
: 0;
const languageType = languageTypeRaw ? Number(languageTypeRaw) : 0;
console.log("[useThreadChat] languageType raw:", languageTypeRaw, "parsed:", languageType);
console.log(
"[useThreadChat] languageType raw:",
languageTypeRaw,
"parsed:",
languageType,
);
const result = {
contentId,
@ -125,10 +144,14 @@ export function useThreadChat(): ThreadChatResult {
}, [searchParams]);
// [新增] postMessage 方式获取 skill 初始化参数
const [skillBootstrapFromPostMessage, setSkillBootstrapFromPostMessage] = useState<{
contentId: number;
languageType: number;
} | undefined>(undefined);
const [skillBootstrapFromPostMessage, setSkillBootstrapFromPostMessage] =
useState<
| {
contentId: number;
languageType: number;
}
| undefined
>(undefined);
// [新增] 监听 postMessage 消息
useEffect(() => {
@ -139,19 +162,29 @@ export function useThreadChat(): ThreadChatResult {
// 检查消息类型
if (!isSelectedSkillMessage(event.data)) {
console.log("[useThreadChat] postMessage ignored: not a selectedSkill message");
console.log(
"[useThreadChat] postMessage ignored: not a selectedSkill message",
);
return;
}
const { id, title } = event.data;
console.log("[useThreadChat] selectedSkill message - id:", id, "title:", title);
console.log(
"[useThreadChat] selectedSkill message - id:",
id,
"title:",
title,
);
// 设置 skillBootstrap
const newSkillBootstrap = {
contentId: id,
languageType: 0, // 默认语言类型
};
console.log("[useThreadChat] Setting skillBootstrap from postMessage:", newSkillBootstrap);
console.log(
"[useThreadChat] Setting skillBootstrap from postMessage:",
newSkillBootstrap,
);
setSkillBootstrapFromPostMessage(newSkillBootstrap);
};
@ -165,7 +198,10 @@ export function useThreadChat(): ThreadChatResult {
// [新增] 合并 URL 和 postMessage 的 skillBootstrap (postMessage 优先)
const skillBootstrap = skillBootstrapFromPostMessage ?? skillBootstrapFromUrl;
console.log("[useThreadChat] skillBootstrap final:", skillBootstrap ? JSON.stringify(skillBootstrap) : undefined);
console.log(
"[useThreadChat] skillBootstrap final:",
skillBootstrap ? JSON.stringify(skillBootstrap) : undefined,
);
// [修复] 使用 useRef 缓存生成的 threadId避免 React StrictMode 下重复生成
const threadIdRef = useRef<string | null>(null);
@ -177,11 +213,19 @@ export function useThreadChat(): ThreadChatResult {
// [移植自 main 分支 4119fdc] 优先使用 URL 中的 thread_id
threadIdRef.current = queryThreadId || uuid();
isNewThreadRef.current = true;
console.log("[useThreadChat] initial threadId (new route):", threadIdRef.current, "queryThreadId:", queryThreadId);
console.log(
"[useThreadChat] initial threadId (new route):",
threadIdRef.current,
"queryThreadId:",
queryThreadId,
);
} else {
threadIdRef.current = threadIdFromPath;
isNewThreadRef.current = false;
console.log("[useThreadChat] initial threadId (existing):", threadIdRef.current);
console.log(
"[useThreadChat] initial threadId (existing):",
threadIdRef.current,
);
}
}
@ -212,7 +256,10 @@ export function useThreadChat(): ThreadChatResult {
console.log("[useThreadChat] isNewThread:", isNewThread);
console.log("[useThreadChat] createNewSession:", createNewSession);
console.log("[useThreadChat] uploadTarget:", uploadTarget);
console.log("[useThreadChat] skillBootstrap:", skillBootstrap ? JSON.stringify(skillBootstrap) : undefined);
console.log(
"[useThreadChat] skillBootstrap:",
skillBootstrap ? JSON.stringify(skillBootstrap) : undefined,
);
console.log("[useThreadChat] ======================================");
return {

View File

@ -333,7 +333,9 @@ function RichFileCard({
const handleMaterializeYaml = async () => {
if (isMaterializing || !file.path) return;
console.log("[RichFileCard] ========== handleMaterializeYaml START ==========");
console.log(
"[RichFileCard] ========== handleMaterializeYaml START ==========",
);
console.log("[RichFileCard] threadId:", threadId);
console.log("[RichFileCard] file.path:", file.path);
console.log("[RichFileCard] file.filename:", file.filename);
@ -359,7 +361,9 @@ function RichFileCard({
setMaterializeMessage(`失败: ${message}`);
} finally {
setIsMaterializing(false);
console.log("[RichFileCard] ========== handleMaterializeYaml END ==========");
console.log(
"[RichFileCard] ========== handleMaterializeYaml END ==========",
);
}
};

View File

@ -100,7 +100,10 @@ export async function materializeSkillYaml(
): Promise<MaterializeSkillYamlResponse> {
console.log("[skills/api] ========== materializeSkillYaml START ==========");
console.log("[skills/api] request:", JSON.stringify(request, null, 2));
console.log("[skills/api] API URL:", `${getBackendBaseURL()}/api/skills/materialize-yaml`);
console.log(
"[skills/api] API URL:",
`${getBackendBaseURL()}/api/skills/materialize-yaml`,
);
const response = await fetch(
`${getBackendBaseURL()}/api/skills/materialize-yaml`,
@ -113,7 +116,11 @@ export async function materializeSkillYaml(
},
);
console.log("[skills/api] response status:", response.status, response.statusText);
console.log(
"[skills/api] response status:",
response.status,
response.statusText,
);
if (!response.ok) {
const errorData = await response.json().catch(() => ({}));
@ -140,7 +147,10 @@ export async function bootstrapRemoteSkill(
console.log("[skills/api] content_id:", request.content_id);
console.log("[skills/api] language_type:", request.language_type);
console.log("[skills/api] target_dir:", request.target_dir);
console.log("[skills/api] API URL:", `${getBackendBaseURL()}/api/skills/bootstrap-remote`);
console.log(
"[skills/api] API URL:",
`${getBackendBaseURL()}/api/skills/bootstrap-remote`,
);
const response = await fetch(
`${getBackendBaseURL()}/api/skills/bootstrap-remote`,
@ -153,7 +163,11 @@ export async function bootstrapRemoteSkill(
},
);
console.log("[skills/api] response status:", response.status, response.statusText);
console.log(
"[skills/api] response status:",
response.status,
response.statusText,
);
if (!response.ok) {
const errorData = await response.json().catch(() => ({}));

View File

@ -188,7 +188,10 @@ export function useThreadStream({
) => {
console.log("[threads/hooks] ========== sendMessage START ==========");
console.log("[threads/hooks] threadId:", threadId);
console.log("[threads/hooks] message.text:", message.text?.substring(0, 100));
console.log(
"[threads/hooks] message.text:",
message.text?.substring(0, 100),
);
console.log("[threads/hooks] message.files:", message.files?.length || 0);
const text = message.text.trim();
@ -196,8 +199,12 @@ export function useThreadStream({
// [移植自 main 分支 ef9a071] 空提交保护:忽略空消息提交(避免页面初始化时的意外副作用)
const hasFiles = !!(message.files && message.files.length > 0);
if (!text && !hasFiles) {
console.log("[threads/hooks] sendMessage: IGNORING empty submit (no text, no files)");
console.log("[threads/hooks] ========== sendMessage END (ignored) ==========");
console.log(
"[threads/hooks] sendMessage: IGNORING empty submit (no text, no files)",
);
console.log(
"[threads/hooks] ========== sendMessage END (ignored) ==========",
);
return;
}
@ -377,7 +384,14 @@ export function useThreadStream({
throw error;
}
},
[thread, _handleOnStart, t.uploads.uploadingFiles, context, queryClient, uploadTarget],
[
thread,
_handleOnStart,
t.uploads.uploadingFiles,
context,
queryClient,
uploadTarget,
],
);
// Merge thread with optimistic messages for display

View File

@ -68,7 +68,11 @@ export async function uploadFiles(
body: formData,
});
console.log("[uploads/api] response status:", response.status, response.statusText);
console.log(
"[uploads/api] response status:",
response.status,
response.statusText,
);
if (!response.ok) {
const error = await response

View File

@ -244,7 +244,7 @@
--muted: #1500331a;
--muted-foreground: oklch(0.556 0 0);
/* --accent: oklch(0.94 0.0098 87.47); */
--accent: #EAE9EB;
--accent: #eae9eb;
--accent-foreground: oklch(0.205 0 0);
--destructive: oklch(0.577 0.245 27.325);
--border: oklch(0.922 0.0098 87.47);
@ -467,4 +467,3 @@ p {
[data-sonner-toast] {
margin: 0 auto;
}