fix(chat): restore file attachments when reverting or forking messages (#1288)
* chore: add .worktrees/ to gitignore for worktree workflow * fix(chat): restore file attachments when reverting or forking messages * fix(chat): address review findings in attachment restoration - Move filePartsToAttachments helper below all imports into its own 'Attachment helpers' section (was incorrectly placed between imports) - Compute size from base64 data URL for pasted screenshots instead of hardcoding 0; file:// URLs keep size 0 which formatFileSize suppresses gracefully - Capture prevAttachedFiles before optimistic mutation and restore on SDK revert failure - Always use source: 'local' for restored attachments so they are visible and removable in the composer regardless of URL scheme * fix(chat): resolve merge conflicts and restore attachments in fork - Merge upstream main which already added attachment restoration to revertToMessage via addRestoredAttachment - Add !isSyntheticPart filter to revertToMessage file part collection (upstream was missing this) - Add attachment restoration to forkFromMessage (was not fixed upstream) - Use upstream's addRestoredAttachment approach for consistency * fix(chat): clear restored attachments when opening new session draft Reverted-message attachments (and any other pending attachments in the global input store) were carrying over to the new session input because openNewSessionDraft did not clear attachedFiles. Clear attachedFiles in openNewSessionDraft, which is the navigation-away event for new sessions (it already sets currentSessionId: null). This matches the semantics of starting a fresh conversation. --------- Co-authored-by: Bohdan Triapitsyn <artmore@protonmail.com>
This commit is contained in:
committed by
GitHub
co-authored by
Bohdan Triapitsyn
parent
0779656d80
commit
4384d7a8d3
@@ -1652,7 +1652,7 @@ const ChatInputComponent: React.FC<ChatInputProps> = ({ onOpenSettings, scrollTo
|
||||
});
|
||||
}
|
||||
|
||||
if (!primaryText && additionalParts.length === 0) return;
|
||||
if (!primaryText && primaryAttachments.length === 0 && additionalParts.length === 0) return;
|
||||
|
||||
// Clear queue and input
|
||||
if (currentSessionId && hasQueuedMessages) {
|
||||
|
||||
Reference in New Issue
Block a user