Implement compact, undo, and init commands
- Add compact command with proper API parameters (providerID, modelID) - Implement undo command matching TUI behavior: - Find previous user message before revert point - Restore reverted message to prompt input - Filter messages client-side based on session.revert field - Add init command with proper hex-encoded message ID generation - Add session.revert field handling: - Parse revert field from API responses in fetchSessions and createSession - Update revert field via SSE session.updated events - Filter messages during render when revert point is set - Add SSE event handlers for session.compacted and session.error - Add force reload option to loadMessages for post-compact refresh - Messages now filter instantly based on revert state without API reload
This commit is contained in:
@@ -10,6 +10,12 @@ interface MessageStreamProps {
|
||||
sessionId: string
|
||||
messages: Message[]
|
||||
messagesInfo?: Map<string, any>
|
||||
revert?: {
|
||||
messageID: string
|
||||
partID?: string
|
||||
snapshot?: string
|
||||
diff?: string
|
||||
}
|
||||
loading?: boolean
|
||||
}
|
||||
|
||||
@@ -57,6 +63,12 @@ export default function MessageStream(props: MessageStreamProps) {
|
||||
|
||||
for (const message of props.messages) {
|
||||
const messageInfo = props.messagesInfo?.get(message.id)
|
||||
|
||||
// If we hit the revert point, stop rendering messages
|
||||
if (props.revert?.messageID && message.id === props.revert.messageID) {
|
||||
break
|
||||
}
|
||||
|
||||
const textParts = message.parts.filter((p) => p.type === "text" && !p.synthetic)
|
||||
const toolParts = message.parts.filter((p) => p.type === "tool")
|
||||
const reasoningParts = message.parts.filter((p) => p.type === "reasoning")
|
||||
|
||||
Reference in New Issue
Block a user