feat(ui): revert indicator with undo/redo, message list, and attachment restore (#1279)
* feat(ui): revert indicator with undo/redo, message list, and attachment restore Add bidirectional undo/redo with redo stack navigation and expandable revert indicator in StatusRow. List reverted messages with inline revert/fork actions. Restore file attachments on revert. - Add revert indicator with count, expandable popover, per-button spinner - Restore file/image attachments when reverting to a message - Clear previous attachments on revert when target has none - Restore-all bypasses redo stack for direct unrevert - Survive popover close/reopen without losing loading state - Fix flash when sending message after revert - Fix count disappearing on browser refresh - Remove dead code (undoStack, getRevertHistory, fork-from-here) - Fix toast grammar (Undid -> Reverted, Redid -> Redone) - Add i18n keys for revert popover across all locales * fix(ui): Greptile review fixes and i18n for revert toasts - Fix handleSlashUndo toast always showing [No text] (moved getSyncParts before revertToMessage) - Add inputStore rollback in revertToMessage catch (restore attachments + text on API failure) - Change portal ID to per-session (prevent multi-session collisions) - Add i18n keys for undo/redo/restored toasts across all 7 locales - Use formatMessage in store for localized toast strings * fix(ui): add missing sessionId to click-outside effect deps * fix(ui): remove unused sessionActions import in ChatMessage * fix(ui): derive revert dock from session state --------- Co-authored-by: Bohdan Triapitsyn <artmore@protonmail.com>
This commit is contained in:
committed by
GitHub
co-authored by
Bohdan Triapitsyn
parent
947f725976
commit
9c71119835
@@ -86,6 +86,8 @@ export type InputState = {
|
||||
addVSCodeFileAttachment: (path: string, name: string, fileSize: number | null) => void
|
||||
addVSCodeSelectionAttachment: (path: string, file: File) => Promise<void>
|
||||
setActiveEditorFile: (file: VSCodeActiveEditorFile | null) => void
|
||||
/** Add attachments restored from a reverted message (file already on server) */
|
||||
addRestoredAttachment: (file: { url: string; mimeType: string; filename: string }) => void
|
||||
}
|
||||
|
||||
export const useInputStore = create<InputState>()((set, get) => ({
|
||||
@@ -210,4 +212,23 @@ export const useInputStore = create<InputState>()((set, get) => ({
|
||||
if (isSameVSCodeActiveEditorFile(get().activeEditorFile, file)) return
|
||||
set({ activeEditorFile: file })
|
||||
},
|
||||
|
||||
addRestoredAttachment: ({ url, mimeType, filename }) => {
|
||||
const id = `restored-${Date.now()}-${Math.random().toString(36).slice(2)}`
|
||||
// Use "local" source so the file renders in AttachedFilesList.
|
||||
// Set serverPath to the URL so ImagePreview can use it as the img src
|
||||
// when dataUrl is not a data: URL. sanitizeAttachmentsForSend leaves
|
||||
// dataUrl alone for non-server sources, so the URL stays intact on send.
|
||||
const attached: AttachedFile = {
|
||||
id,
|
||||
file: new File([], filename, { type: mimeType }),
|
||||
dataUrl: url,
|
||||
mimeType,
|
||||
filename,
|
||||
size: 0,
|
||||
source: "local",
|
||||
serverPath: url,
|
||||
}
|
||||
set((s) => ({ attachedFiles: [...s.attachedFiles, attached] }))
|
||||
},
|
||||
}))
|
||||
|
||||
Reference in New Issue
Block a user