mirror of
https://github.com/infinilabs/coco-app.git
synced 2025-12-16 11:37:47 +01:00
refactor: updated the upload endpoint for attachments (#759)
This commit is contained in:
@@ -24,7 +24,6 @@ pub struct DeleteAttachmentResponse {
|
||||
#[command]
|
||||
pub async fn upload_attachment(
|
||||
server_id: String,
|
||||
session_id: String,
|
||||
file_paths: Vec<PathBuf>,
|
||||
) -> Result<UploadAttachmentResponse, String> {
|
||||
let mut form = Form::new();
|
||||
@@ -47,7 +46,7 @@ pub async fn upload_attachment(
|
||||
}
|
||||
|
||||
let server = get_server_by_id(&server_id).ok_or("Server not found")?;
|
||||
let url = HttpClient::join_url(&server.endpoint, &format!("chat/{}/_upload", session_id));
|
||||
let url = HttpClient::join_url(&server.endpoint, &format!("attachment/_upload"));
|
||||
|
||||
let token = get_server_token(&server_id).await?;
|
||||
let mut headers = HashMap::new();
|
||||
|
||||
@@ -42,7 +42,6 @@ export const ChatContent = ({
|
||||
timedoutShow,
|
||||
Question,
|
||||
handleSendMessage,
|
||||
getFileUrl,
|
||||
}: ChatContentProps) => {
|
||||
const sessionId = useConnectStore((state) => state.currentSessionId);
|
||||
const setCurrentSessionId = useConnectStore((state) => {
|
||||
@@ -165,9 +164,9 @@ export const ChatContent = ({
|
||||
<div ref={messagesEndRef} />
|
||||
</div>
|
||||
|
||||
{sessionId && uploadFiles.length > 0 && (
|
||||
{uploadFiles.length > 0 && (
|
||||
<div key={sessionId} className="max-h-[120px] overflow-auto p-2">
|
||||
<FileList sessionId={sessionId} getFileUrl={getFileUrl} />
|
||||
<FileList />
|
||||
</div>
|
||||
)}
|
||||
|
||||
|
||||
@@ -10,13 +10,7 @@ import platformAdapter from "@/utils/platformAdapter";
|
||||
import Tooltip2 from "../Common/Tooltip2";
|
||||
import FileIcon from "../Common/Icons/FileIcon";
|
||||
|
||||
interface FileListProps {
|
||||
sessionId: string;
|
||||
getFileUrl: (path: string) => string;
|
||||
}
|
||||
|
||||
const FileList = (props: FileListProps) => {
|
||||
const { sessionId } = props;
|
||||
const FileList = () => {
|
||||
const { t } = useTranslation();
|
||||
const { uploadFiles, setUploadFiles } = useChatStore();
|
||||
const { currentService } = useConnectStore();
|
||||
@@ -44,7 +38,6 @@ const FileList = (props: FileListProps) => {
|
||||
"upload_attachment",
|
||||
{
|
||||
serverId,
|
||||
sessionId,
|
||||
filePaths: [path],
|
||||
}
|
||||
);
|
||||
|
||||
@@ -84,7 +84,6 @@ export default function ChatInput({
|
||||
const { t } = useTranslation();
|
||||
|
||||
const currentAssistant = useConnectStore((state) => state.currentAssistant);
|
||||
// const sessionId = useConnectStore((state) => state.currentSessionId);
|
||||
|
||||
const setBlurred = useAppStore((state) => state.setBlurred);
|
||||
const isTauri = useAppStore((state) => state.isTauri);
|
||||
|
||||
@@ -70,7 +70,7 @@ const InputControls = ({
|
||||
|
||||
const isTauri = useAppStore((state) => state.isTauri);
|
||||
|
||||
const { currentAssistant, currentSessionId } = useConnectStore();
|
||||
const { currentAssistant } = useConnectStore();
|
||||
const { modeSwitch, deepThinking } = useShortcutsStore();
|
||||
|
||||
const source = currentAssistant?._source;
|
||||
@@ -171,19 +171,17 @@ const InputControls = ({
|
||||
>
|
||||
{isChatMode ? (
|
||||
<div className="flex gap-2 text-[12px] leading-3 text-[#333] dark:text-[#d8d8d8]">
|
||||
{currentSessionId && (
|
||||
<InputUpload
|
||||
checkScreenPermission={checkScreenPermission}
|
||||
requestScreenPermission={requestScreenPermission}
|
||||
getScreenMonitors={getScreenMonitors}
|
||||
getScreenWindows={getScreenWindows}
|
||||
captureMonitorScreenshot={captureMonitorScreenshot}
|
||||
captureWindowScreenshot={captureWindowScreenshot}
|
||||
openFileDialog={openFileDialog}
|
||||
getFileMetadata={getFileMetadata}
|
||||
getFileIcon={getFileIcon}
|
||||
/>
|
||||
)}
|
||||
<InputUpload
|
||||
checkScreenPermission={checkScreenPermission}
|
||||
requestScreenPermission={requestScreenPermission}
|
||||
getScreenMonitors={getScreenMonitors}
|
||||
getScreenWindows={getScreenWindows}
|
||||
captureMonitorScreenshot={captureMonitorScreenshot}
|
||||
captureWindowScreenshot={captureWindowScreenshot}
|
||||
openFileDialog={openFileDialog}
|
||||
getFileMetadata={getFileMetadata}
|
||||
getFileIcon={getFileIcon}
|
||||
/>
|
||||
|
||||
{source?.type === "deep_think" && source?.config?.visible && (
|
||||
<button
|
||||
@@ -233,8 +231,7 @@ const InputControls = ({
|
||||
getMCPByServer={getMCPByServer}
|
||||
/>
|
||||
|
||||
{!currentSessionId &&
|
||||
!(source?.datasource?.enabled && source?.datasource?.visible) &&
|
||||
{!(source?.datasource?.enabled && source?.datasource?.visible) &&
|
||||
(source?.type !== "deep_think" || !source?.config?.visible) &&
|
||||
!(source?.mcp_servers?.enabled && source?.mcp_servers?.visible) && (
|
||||
<div className="px-[9px]">
|
||||
|
||||
Reference in New Issue
Block a user