From 7e812aa7f54c45f71f983fbb2a375b15e86b8e93 Mon Sep 17 00:00:00 2001 From: Federico Jaramillo Martinez Date: Thu, 25 Jun 2026 21:32:07 +0200 Subject: [PATCH] feat: support general chat file attachments --- .changeset/chat-file-uploads.md | 5 + src/client/src/components/PromptEditor.ts | 91 ++++++++++++------- src/client/src/components/shared.ts | 3 + .../src/promptAttachmentCapture.test.ts | 66 ++++++++++---- src/client/src/promptAttachmentCapture.ts | 73 +++++++++++---- src/server/sessions/attachmentService.test.ts | 75 ++++++++++++++- src/server/sessions/attachmentService.ts | 84 ++++++++++++++--- src/server/sessions/piSessionService.ts | 2 +- src/shared/apiTypes.ts | 24 +++-- src/shared/promptAttachments.test.ts | 25 +++++ src/shared/promptAttachments.ts | 45 +++++++-- 11 files changed, 397 insertions(+), 96 deletions(-) create mode 100644 .changeset/chat-file-uploads.md diff --git a/.changeset/chat-file-uploads.md b/.changeset/chat-file-uploads.md new file mode 100644 index 0000000..d65244b --- /dev/null +++ b/.changeset/chat-file-uploads.md @@ -0,0 +1,5 @@ +--- +"@jmfederico/pi-web": patch +--- + +Allow chat composer attachments to save and mention general files while preserving native inline image delivery for supported image-only batches. diff --git a/src/client/src/components/PromptEditor.ts b/src/client/src/components/PromptEditor.ts index a5dc404..6367c42 100644 --- a/src/client/src/components/PromptEditor.ts +++ b/src/client/src/components/PromptEditor.ts @@ -7,7 +7,7 @@ import { LitElement, html, type PropertyValues } from "lit"; import { customElement, property, query, state } from "lit/decorators.js"; import { api, type FileSuggestion, type PromptAttachment, type SessionStatus, type SlashCommand } from "../api"; import type { PromptAttachmentDelivery } from "../../../shared/apiTypes"; -import { captureImageAttachments } from "../promptAttachmentCapture"; +import { capturePromptAttachments, effectivePromptAttachmentDelivery, isInlinePromptAttachment, promptAttachmentsCanUseInlineDelivery, type CapturedAttachment } from "../promptAttachmentCapture"; import { inputModeForDraft } from "../inputModes"; import { machineSessionKey } from "../machineKeys"; import { detectPromptCompletionTrigger, fileCompletionInsertText, type PromptCompletionTrigger } from "../promptCompletions"; @@ -18,14 +18,7 @@ import { renderAttachIcon, renderSendIcon, renderQueueIcon, renderSteerIcon, ren import { thinkingGauge, thinkingLevelLabel } from "../../../shared/thinkingLevels"; import "./AutocompleteMenu"; -interface PendingAttachment { - id: string; - name: string; - mimeType: string; - /** Base64 payload without the data: URL prefix. */ - data: string; - size: number; -} +type PendingAttachment = CapturedAttachment & { id: string }; @customElement("prompt-editor") export class PromptEditor extends LitElement { @@ -96,8 +89,8 @@ export class PromptEditor extends LitElement {