feat: add fork assistant message to new session

Add fork button on assistant messages to start new execution session
Include synthetic meta-instruction when forking to explain context
This commit is contained in:
Bohdan Triapitsyn
2025-12-09 00:40:43 +02:00
parent 96aa5bdd18
commit 2779e19103
13 changed files with 937 additions and 46 deletions
@@ -0,0 +1,13 @@
import type { Part } from '@opencode-ai/sdk';
type TextLikePart = Part & { text?: string; content?: string };
export const flattenAssistantTextParts = (parts: Part[]): string => {
const textParts = parts
.filter((part): part is TextLikePart => part?.type === 'text')
.map((part) => (part.text || part.content || '').trim())
.filter((text) => text.length > 0);
const combined = textParts.join('\n');
return combined.replace(/\n\s*\n+/g, '\n');
};