(
messageIndex: number,
newContent: string,
)
| 751 | }; |
| 752 | |
| 753 | const handleEditMessage = async ( |
| 754 | messageIndex: number, |
| 755 | newContent: string, |
| 756 | ) => { |
| 757 | logger.debug("handleEditMessage called", { |
| 758 | messageIndex, |
| 759 | currentHistoryLength: chatHistory.length, |
| 760 | }); |
| 761 | |
| 762 | // Rewind chat history to exclude the message being edited |
| 763 | const rewindedHistory = chatHistory.slice(0, messageIndex); |
| 764 | |
| 765 | logger.debug("Rewinding history for edit", { |
| 766 | from: chatHistory.length, |
| 767 | to: rewindedHistory.length, |
| 768 | }); |
| 769 | |
| 770 | // Clear any queued messages |
| 771 | setQueuedMessages([]); |
| 772 | |
| 773 | // Clear attached files |
| 774 | setAttachedFiles([]); |
| 775 | |
| 776 | // Update the session with the rewound history |
| 777 | updateSessionHistory(rewindedHistory); |
| 778 | |
| 779 | // Force refresh of StaticChatContent to show truncated history |
| 780 | if (onRefreshStatic) { |
| 781 | onRefreshStatic(); |
| 782 | } |
| 783 | |
| 784 | // Resubmit the edited message with the rewound history as the base |
| 785 | // This ensures processMessage uses the correct base history |
| 786 | await processMessage(newContent, undefined, false, rewindedHistory); |
| 787 | }; |
| 788 | |
| 789 | const handleToolPermissionResponse = async ( |
| 790 | requestId: string, |
no test coverage detected