FN-7628: allow editing sent chat messages and rewinding agent responses
Adds the ability to edit a previously sent message in an agent chat, which rewinds the session/task room and regenerates the response from the edited message. - Add chat-store support for locating/replacing a message and truncating subsequent history for a rewind - Add a chat-manager rewind-session flow and a new register-chat-routes endpoint to rewind a room to an edited message - Add legacy API route wiring and useChat hook support for issuing an edit request - Add ChatView/StandardChatSurface/TaskPlannerChatTab UI affordances (edit control, styling) to trigger message edits - Add a changeset documenting the new chat message-edit capability - Add unit/integration tests covering chat-store rewind logic, chat-manager rewind-session behavior, chat routes, useChat, and ChatView edit UI Files changed: .changeset/fn-7628-chat-message-edit.md | 7 + docs/dashboard-guide.md | 4 + packages/core/src/__tests__/chat-store.test.ts | 171 ++++++++++++++ packages/core/src/chat-store.ts | 95 ++++++++ packages/dashboard/app/api/legacy.ts | 22 ++ packages/dashboard/app/components/ChatView.css | 78 ++++++ packages/dashboard/app/components/ChatView.tsx | 14 ++ .../app/components/StandardChatSurface.tsx | 87 ++++++- .../app/components/TaskPlannerChatTab.tsx | 8 + .../__tests__/ChatView.autosize.test.tsx | 1 + .../__tests__/ChatView.default-model-icon.test.tsx | 1 + .../components/__tests__/ChatView.draft.test.tsx | 1 + .../__tests__/ChatView.hash-mention.test.tsx | 1 + .../__tests__/ChatView.message-edit.test.tsx | 262 +++++++++++++++++++++ .../__tests__/ChatView.mobile-render.test.tsx | 1 + .../components/__tests__/ChatView.rooms.test.tsx | 1 + .../__tests__/ChatView.scroll-to-top.test.tsx | 1 + .../components/__tests__/ChatView.test-harness.tsx | 1 + .../dashboard/app/hooks/__tests__/useChat.test.ts | 98 ++++++++ packages/dashboard/app/hooks/useChat.ts | 60 +++++ .../__tests__/chat-manager-rewind-session.test.ts | 185 +++++++++++++++ .../dashboard/src/__tests__/chat-manager.test.ts | 12 + .../dashboard/src/__tests__/chat-routes.test.ts | 124 ++++++++++ packages/dashboard/src/chat.ts | 147 +++++++++++- .../dashboard/src/routes/register-chat-routes.ts | 52 ++++ 25 files changed, 1429 insertions(+), 5 deletions(-) Fusion-Task-Id: FN-7628 Fusion-Task-Lineage: 36d98989-1b75-428c-baf1-b2c7e8e78013 Co-authored-by: Fusion (runfusion.ai) <noreply@runfusion.ai>
This commit is contained in:
@@ -10188,6 +10188,28 @@ export function deleteChatMessage(
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* FNXC:ChatMessageEdit 2026-07-07-09:00:
|
||||
* Edit an earlier user message in a direct (model-loop) chat session. Truncates the persisted
|
||||
* transcript from (and including) the target message onward AND rewinds the pi session context
|
||||
* server-side, so the returned `retained` list is the surviving pre-edit history. Does NOT
|
||||
* trigger regeneration — the caller resends the edited content via the existing streaming send.
|
||||
*/
|
||||
export function editChatMessage(
|
||||
sessionId: string,
|
||||
messageId: string,
|
||||
content: string,
|
||||
projectId?: string,
|
||||
): Promise<{ retained: ChatMessage[] }> {
|
||||
return api<{ retained: ChatMessage[] }>(
|
||||
withProjectId(`/chat/sessions/${encodeURIComponent(sessionId)}/messages/${encodeURIComponent(messageId)}`, projectId),
|
||||
{
|
||||
method: "PATCH",
|
||||
body: JSON.stringify({ content }),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
export function fetchChatRooms(
|
||||
options: { status?: string; agentId?: string } = {},
|
||||
projectId?: string,
|
||||
|
||||
Reference in New Issue
Block a user