From 86bb8f36cb4c02218b9e4d124237ec6e885235a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=B7=E7=94=B5=E8=8A=BD=E8=A1=A3?= Date: Thu, 28 May 2026 22:27:49 -0400 Subject: [PATCH] Attach files from the chat composer via the file picker --- AgentCompany-New/src/main/app/ipc-handlers.ts | 6 ++-- .../src/renderer/src/pages/ChatPage.tsx | 8 +++++ .../src/renderer/src/pages/FilesPage.tsx | 8 ++++- .../renderer/src/pages/chat/ChatComposer.tsx | 30 +++++++++++-------- .../src/pages/chat/ChatConversation.tsx | 3 ++ AgentCompany-New/src/shared/desktop-api.ts | 2 +- 6 files changed, 40 insertions(+), 17 deletions(-) diff --git a/AgentCompany-New/src/main/app/ipc-handlers.ts b/AgentCompany-New/src/main/app/ipc-handlers.ts index 7f2f9a6e..ffaff708 100644 --- a/AgentCompany-New/src/main/app/ipc-handlers.ts +++ b/AgentCompany-New/src/main/app/ipc-handlers.ts @@ -188,9 +188,9 @@ export function registerIpcHandlers(deps: IpcDeps): void { ipcMain.handle(IPC_CHANNELS.importFile, async (_event, input) => { try { - await files.importFile(input); - deps.mainWindow.webContents.send(IPC_CHANNELS.rendererEvent, { type: "snapshot-changed" }); - return ok(snapshot.load()); + const fileId = await files.importFile(input); + if (fileId) deps.mainWindow.webContents.send(IPC_CHANNELS.rendererEvent, { type: "snapshot-changed" }); + return ok(fileId); } catch (error) { return fail("file_import_failed", error instanceof Error ? error.message : String(error)); } diff --git a/AgentCompany-New/src/renderer/src/pages/ChatPage.tsx b/AgentCompany-New/src/renderer/src/pages/ChatPage.tsx index 686416c5..7e045bc2 100644 --- a/AgentCompany-New/src/renderer/src/pages/ChatPage.tsx +++ b/AgentCompany-New/src/renderer/src/pages/ChatPage.tsx @@ -224,6 +224,13 @@ export function ChatPage({ snapshot, actions }: PageProps) { actorId: employee.id, })); + const attachFile = () => { + void window.agentCompany.importFile({ orgId }).then((result) => { + if (!result.ok) throw new Error(result.error.message); + if (result.data) setAttachmentFileId(result.data); + }); + }; + return (
decideApproval(approvalId, "approved")} onDecline={(approvalId) => decideApproval(approvalId, "declined")} diff --git a/AgentCompany-New/src/renderer/src/pages/FilesPage.tsx b/AgentCompany-New/src/renderer/src/pages/FilesPage.tsx index 3c2ded6c..576a4bf2 100644 --- a/AgentCompany-New/src/renderer/src/pages/FilesPage.tsx +++ b/AgentCompany-New/src/renderer/src/pages/FilesPage.tsx @@ -35,6 +35,12 @@ export function FilesPage({ snapshot, actions }: PageProps) { const pinnedFiles = files.filter((file) => file.pinned); const totalBytes = visibleFiles.reduce((sum, file) => sum + file.sizeBytes, 0); + const upload = () => { + void window.agentCompany.importFile({ orgId }).then((result) => { + if (!result.ok) throw new Error(result.error.message); + }); + }; + return (
- diff --git a/AgentCompany-New/src/renderer/src/pages/chat/ChatComposer.tsx b/AgentCompany-New/src/renderer/src/pages/chat/ChatComposer.tsx index f0c4a78e..158a0834 100644 --- a/AgentCompany-New/src/renderer/src/pages/chat/ChatComposer.tsx +++ b/AgentCompany-New/src/renderer/src/pages/chat/ChatComposer.tsx @@ -8,6 +8,7 @@ export function ChatComposer({ files, attachmentFileId, onAttachmentChange, + onAttach, onSubmit, composerRef, }: { @@ -15,10 +16,12 @@ export function ChatComposer({ files: FileObjectRecord[]; attachmentFileId: string; onAttachmentChange: (next: string) => void; + onAttach: () => void; onSubmit: (event: FormEvent) => void; composerRef: MutableRefObject; }) { const [slashOpen, setSlashOpen] = useState(false); + const attachment = files.find((file) => file.id === attachmentFileId) ?? null; const insert = (text: string) => { const node = composerRef.current; @@ -61,19 +64,22 @@ export function ChatComposer({ }} />
- - + setSlashOpen((open) => !open)} /> + {attachment && ( + + + {attachment.name} + + + )}
⌘↵ diff --git a/AgentCompany-New/src/renderer/src/pages/chat/ChatConversation.tsx b/AgentCompany-New/src/renderer/src/pages/chat/ChatConversation.tsx index c704cf2a..f2007f1d 100644 --- a/AgentCompany-New/src/renderer/src/pages/chat/ChatConversation.tsx +++ b/AgentCompany-New/src/renderer/src/pages/chat/ChatConversation.tsx @@ -29,6 +29,7 @@ export function ChatConversation({ attachmentFileId, currentEmployeeId, onAttachmentChange, + onAttach, onOpenThread, onApprove, onDecline, @@ -51,6 +52,7 @@ export function ChatConversation({ attachmentFileId: string; currentEmployeeId: string; onAttachmentChange: (next: string) => void; + onAttach: () => void; onOpenThread: (threadId: string) => void; onApprove: (approvalId: string) => void; onDecline: (approvalId: string) => void; @@ -93,6 +95,7 @@ export function ChatConversation({ files={files} attachmentFileId={attachmentFileId} onAttachmentChange={onAttachmentChange} + onAttach={onAttach} onSubmit={onSubmit} composerRef={composerRef} /> diff --git a/AgentCompany-New/src/shared/desktop-api.ts b/AgentCompany-New/src/shared/desktop-api.ts index 15304897..87055859 100644 --- a/AgentCompany-New/src/shared/desktop-api.ts +++ b/AgentCompany-New/src/shared/desktop-api.ts @@ -96,7 +96,7 @@ export interface DesktopApi { launchSocialLogin(input: LaunchSocialLoginInput): Promise>; createScheduledPost(input: CreateScheduledPostInput): Promise>; setScheduledPostState(input: SetScheduledPostStateInput): Promise>; - importFile(input: ImportFileInput): Promise>; + importFile(input: ImportFileInput): Promise>; pickDirectory(): Promise>; setFilePinned(input: SetFilePinnedInput): Promise>; createMigrationReport(input: CreateMigrationReportInput): Promise>;