[mirror] fix(site/src/pages/AgentsPage): persist chat draft attachments#1
[mirror] fix(site/src/pages/AgentsPage): persist chat draft attachments#1yashwant86 wants to merge 9 commits intomm-base-24709from
Conversation
⚡ Risk Assessment —
|
| Files | Summary |
|---|---|
Draft Attachment Persistence Infrastructuresite/src/pages/AgentsPage/utils/chatDraftAttachmentStorage.ts, chatDraftAttachmentStorage.test.ts |
Adds localStorage-backed persistence layer for chat draft attachments with data URL serialization, quota handling, expiration pruning, and deduplication by clientId and fileId. |
Draft Upload Registry and Hooksite/src/pages/AgentsPage/hooks/useChatDraftAttachments.ts, useChatDraftAttachments.test.ts |
Implements in-memory upload registry to share active uploads across hook instances, restore persisted drafts, track upload progress with draft warnings on quota failure, and manage lifecycle across chat scope changes. |
Attachment Utilities and Shared Helperssite/src/pages/AgentsPage/utils/fileAttachmentLimits.ts |
Extracts attachment size limit, error formatting, and text file reading into shared utilities used by both draft and transient attachment flows. |
Attachment Preview UI and Statesite/src/pages/AgentsPage/components/AttachmentPreview.tsx, AttachmentPreview.stories.tsx |
Adds pending upload state with spinner, draft warning display below attachments, and exports isUploadInProgress helper. Adds test stories for pending and draft-warning states. |
Chat Input Integrationsite/src/pages/AgentsPage/components/AgentChatInput.tsx |
Imports and uses isUploadInProgress helper to check for active uploads before enabling send button. |
Chat Page Content and Mode Switchingsite/src/pages/AgentsPage/components/ChatPageContent.tsx |
Adds dual attachment buckets (compose vs. edit), switches between them based on isEditing flag, clears edit bucket on scope change and mode exit while preserving compose drafts, and validates active uploads before sending. |
Chat Page View and Propssite/src/pages/AgentsPage/AgentChatPageView.tsx |
Computes isEditing flag from editing state and passes it to ChatPageInput for attachment mode switching. |
Transient Attachment Hook Refactorsite/src/pages/AgentsPage/hooks/useFileAttachments.ts |
Removes inline size limit and error formatting; delegates to shared fileAttachmentLimits utilities for consistency with draft attachment flow. |
Sequence Diagram
sequenceDiagram
participant User
participant UI as AttachmentPreview
participant Hook as useChatDraftAttachments
participant Registry as Upload Registry
participant Storage as localStorage
participant API as Server
User->>UI: Attach file
UI->>Hook: handleAttach([file])
Hook->>Registry: createRegistryEntry(clientId, file)
Hook->>Hook: beginUpload(entry)
Hook->>Storage: persistUploadPayload(entry)
Hook->>API: uploadChatFile(file)
API-->>Registry: upload completes
Hook->>Storage: persistUploadedRecord(entry)
Hook->>UI: notify (status: uploaded)
UI->>User: Show uploaded state
User->>Browser: Reload page
Hook->>Storage: restoreChatDraftAttachments()
Storage-->>Hook: [restored records]
Hook->>Registry: Resume in-flight uploads by clientId
Hook->>UI: Render restored attachments
UI->>User: Show draft attachments
Dig Deeper With Commands
/review <file-path> <function-optional>/chat <file-path> "<question>"/roast <file-path>
Runs only when explicitly triggered.
Mirror of upstream coder#24709 for benchmark. Do not merge.
Summary by MergeMonkey