mirror of
https://github.com/infinilabs/coco-app.git
synced 2026-09-01 19:51:52 +02:00
chore: update assistant icon & think mode (#397)
* fix: assistant icon & think model * docs: update notes * chore: optimize the code
This commit is contained in:
@@ -42,6 +42,7 @@ Information about release notes of Coco Server is provided here.
|
||||
- style: modify the style #370
|
||||
- style: search list details display #378
|
||||
- refactor: refactoring api error handling #382
|
||||
- chore: update assistant icon & think mode #397
|
||||
|
||||
## 0.3.0 (2025-03-31)
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -31,7 +31,7 @@ async function invokeWithErrorHandler<T>(
|
||||
if (failedResult.failed?.length > 0) {
|
||||
failedResult.failed.forEach((error: any) => {
|
||||
// addError(error.error, 'error');
|
||||
console.log(error.error);
|
||||
console.error(error.error);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ export function AssistantList({ showChatHistory = true }: AssistantListProps) {
|
||||
onClick={() => setIsOpen(!isOpen)}
|
||||
className="h-6 p-1 px-1.5 flex items-center gap-1 rounded-full bg-white dark:bg-[#202126] text-sm/6 font-semibold text-gray-800 dark:text-[#d8d8d8] border border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700 focus:outline-none"
|
||||
>
|
||||
<div className="w-4 h-4 flex justify-center items-center bg-white rounded-full">
|
||||
<div className="w-4 h-4 flex justify-center items-center rounded-full bg-gray-200 dark:bg-gray-800">
|
||||
{currentAssistant?._source?.icon?.startsWith("font_") ? (
|
||||
<FontIcon
|
||||
name={currentAssistant._source.icon}
|
||||
|
||||
@@ -133,7 +133,7 @@ export const ChatMessage = memo(function ChatMessage({
|
||||
>
|
||||
<div className="w-full flex items-center gap-1 font-semibold text-sm text-[#333] dark:text-[#d8d8d8]">
|
||||
{isAssistant ? (
|
||||
<div className="w-6 h-6 flex justify-center items-center bg-white rounded-full">
|
||||
<div className="w-6 h-6 flex justify-center items-center rounded-full bg-gray-200 dark:bg-gray-800">
|
||||
{currentAssistant?._source?.icon?.startsWith("font_") ? (
|
||||
<FontIcon
|
||||
name={currentAssistant._source.icon}
|
||||
|
||||
@@ -77,7 +77,7 @@ export default function ChatInput({
|
||||
isChatPage = false,
|
||||
getDataSourcesByServer,
|
||||
setupWindowFocusListener,
|
||||
hasFeature = ["think", "search", "think_icon", "search_icon"],
|
||||
hasFeature = ["think", "search", "think_active", "search_active"],
|
||||
hideCoco,
|
||||
hasModules = [],
|
||||
searchPlaceholder,
|
||||
@@ -474,6 +474,7 @@ export default function ChatInput({
|
||||
getDataSourcesByServer={getDataSourcesByServer}
|
||||
/>
|
||||
)}
|
||||
|
||||
{!hasFeature.includes("search") && !hasFeature.includes("think") ? (
|
||||
<div className="px-[9px]">
|
||||
<Copyright />
|
||||
|
||||
33
src/hooks/useFeatureControl.ts
Normal file
33
src/hooks/useFeatureControl.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { useState, useEffect } from "react";
|
||||
|
||||
import { useConnectStore } from "@/stores/connectStore";
|
||||
|
||||
interface UseFeatureControlProps {
|
||||
initialFeatures: string[];
|
||||
featureToToggle: string;
|
||||
condition: (assistant: any) => boolean;
|
||||
}
|
||||
|
||||
export const useFeatureControl = ({
|
||||
initialFeatures,
|
||||
featureToToggle,
|
||||
condition,
|
||||
}: UseFeatureControlProps) => {
|
||||
const currentAssistant = useConnectStore((state) => state.currentAssistant);
|
||||
const [features, setFeatures] = useState<string[]>(initialFeatures);
|
||||
|
||||
useEffect(() => {
|
||||
if (condition(currentAssistant)) {
|
||||
setFeatures((prev) => prev.filter((feature) => feature !== featureToToggle));
|
||||
} else {
|
||||
setFeatures((prev) => {
|
||||
if (!prev.includes(featureToToggle)) {
|
||||
return [...prev, featureToToggle];
|
||||
}
|
||||
return prev;
|
||||
});
|
||||
}
|
||||
}, [currentAssistant?._id, featureToToggle]);
|
||||
|
||||
return features;
|
||||
};
|
||||
@@ -30,6 +30,7 @@ import {
|
||||
import { DataSource } from "@/types/commands";
|
||||
import HistoryList from "@/components/Common/HistoryList";
|
||||
import { useSyncStore } from "@/hooks/useSyncStore";
|
||||
import { useFeatureControl } from "@/hooks/useFeatureControl";
|
||||
|
||||
interface ChatProps {}
|
||||
|
||||
@@ -261,6 +262,12 @@ export default function Chat({}: ChatProps) {
|
||||
await delete_session_chat(currentService.id, id);
|
||||
};
|
||||
|
||||
const hasFeature = useFeatureControl({
|
||||
initialFeatures: ["think", "search"],
|
||||
featureToToggle: "think",
|
||||
condition: (item) => item?._source?.type === "simple"
|
||||
});
|
||||
|
||||
return (
|
||||
<div className="h-screen">
|
||||
<div className="h-full flex">
|
||||
@@ -331,6 +338,7 @@ export default function Chat({}: ChatProps) {
|
||||
openFileDialog={openFileDialog}
|
||||
getFileMetadata={getFileMetadata}
|
||||
getFileIcon={getFileIcon}
|
||||
hasFeature={hasFeature}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -4,6 +4,7 @@ import SearchChat from "@/components/SearchChat";
|
||||
import platformAdapter from "@/utils/platformAdapter";
|
||||
import { useAppStore } from "@/stores/appStore";
|
||||
import { useSyncStore } from "@/hooks/useSyncStore";
|
||||
import { useFeatureControl } from "@/hooks/useFeatureControl";
|
||||
|
||||
function MainApp() {
|
||||
const setIsTauri = useAppStore((state) => state.setIsTauri);
|
||||
@@ -55,6 +56,12 @@ function MainApp() {
|
||||
|
||||
useSyncStore();
|
||||
|
||||
const hasFeature = useFeatureControl({
|
||||
initialFeatures: ["think", "search"],
|
||||
featureToToggle: "think",
|
||||
condition: (item) => item?._source?.type === "simple"
|
||||
});
|
||||
|
||||
return (
|
||||
<SearchChat
|
||||
isTauri={true}
|
||||
@@ -62,6 +69,7 @@ function MainApp() {
|
||||
queryDocuments={queryDocuments}
|
||||
hideCoco={hideCoco}
|
||||
hasModules={["search", "chat"]}
|
||||
hasFeature={hasFeature}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import { Get } from "@/api/axiosRequest";
|
||||
import { useShortcutsStore } from "@/stores/shortcutsStore";
|
||||
import { useIsMobile } from '@/hooks/useIsMobile';
|
||||
import { useModifierKeyPress } from "@/hooks/useModifierKeyPress";
|
||||
import { useFeatureControl } from "@/hooks/useFeatureControl";
|
||||
|
||||
import "@/i18n";
|
||||
import "@/web.css";
|
||||
@@ -125,6 +126,12 @@ function WebApp({
|
||||
|
||||
const [isChatMode, setIsChatMode] = useState(false);
|
||||
|
||||
const hasFeatureCopy = useFeatureControl({
|
||||
initialFeatures: hasFeature,
|
||||
featureToToggle: "think",
|
||||
condition: (item) => item?._source?.type === "simple"
|
||||
});
|
||||
|
||||
return (
|
||||
<div
|
||||
id="searchChat-container"
|
||||
@@ -158,7 +165,7 @@ function WebApp({
|
||||
hideCoco={hideCoco}
|
||||
hasModules={hasModules}
|
||||
defaultModule={defaultModule}
|
||||
hasFeature={hasFeature}
|
||||
hasFeature={hasFeatureCopy}
|
||||
theme={theme}
|
||||
searchPlaceholder={searchPlaceholder}
|
||||
chatPlaceholder={chatPlaceholder}
|
||||
|
||||
Reference in New Issue
Block a user