mirror of
https://github.com/davidkaya/aryx.git
synced 2026-08-03 18:38:35 +02:00
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:
@@ -380,11 +380,13 @@ export function ChatPane({
|
||||
{phaseLabel}
|
||||
</span>
|
||||
)}
|
||||
{isUser && onBranchFromMessage && (
|
||||
{onBranchFromMessage && (
|
||||
<button
|
||||
className="ml-auto flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[11px] text-[var(--color-text-muted)] opacity-0 transition-all duration-150 hover:bg-[var(--color-surface-2)] hover:text-[var(--color-accent)] group-hover:opacity-100"
|
||||
onClick={() => onBranchFromMessage(message.id)}
|
||||
title="Branch from here — create a new session starting from this message"
|
||||
title={isUser
|
||||
? 'Branch from here — create a new session starting from this message'
|
||||
: 'Branch from here — create a new session continuing from this response'}
|
||||
type="button"
|
||||
>
|
||||
<GitBranch className="size-3" />
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user