feat: allow branching from both user and assistant messages

- Relax branchSessionRecord validation to accept user or assistant roles
- Show "Branch from here" hover button on all conversation messages
- Contextual tooltip: "starting from this message" vs "continuing from this response"
- Add test for branching from assistant message
- Replace non-user rejection test with non-conversation rejection test

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
David Kaya
2026-03-29 21:43:58 +02:00
co-authored by Copilot
parent c0a37b0cd4
commit 4726e2acea
3 changed files with 61 additions and 9 deletions
+2 -2
View File
@@ -237,8 +237,8 @@ export function branchSessionRecord(
throw new Error(`Message ${messageId} not found in session ${session.id}.`);
}
if (sourceMessage.role !== 'user') {
throw new Error('Only user messages can be used as a branch point.');
if (sourceMessage.role !== 'user' && sourceMessage.role !== 'assistant') {
throw new Error('Only user or assistant messages can be used as a branch point.');
}
const branchedMessages = session.messages.slice(0, sourceMessageIndex + 1).map(cloneChatMessageRecord);