feat(chat): add revert to previous message

Add revert button on user messages except first message
Restore reverted message text to input field
Filter out messages after revert point
This commit is contained in:
Bohdan Triapitsyn
2025-12-21 00:47:43 +02:00
parent 70c9a61189
commit ac53ec0bdc
8 changed files with 227 additions and 48 deletions
+19
View File
@@ -478,6 +478,25 @@ class OpencodeService {
return Boolean(response.data);
}
async revertSession(sessionId: string, messageId: string, partId?: string): Promise<Session> {
const response = await this.client.session.revert({
path: { id: sessionId },
query: this.currentDirectory ? { directory: this.currentDirectory } : undefined,
body: { messageID: messageId, partID: partId }
});
if (!response.data) throw new Error('Failed to revert session');
return response.data;
}
async unrevertSession(sessionId: string): Promise<Session> {
const response = await this.client.session.unrevert({
path: { id: sessionId },
query: this.currentDirectory ? { directory: this.currentDirectory } : undefined
});
if (!response.data) throw new Error('Failed to unrevert session');
return response.data;
}
async getSessionStatus(): Promise<
Record<string, { type: "idle" | "busy" | "retry"; attempt?: number; message?: string; next?: number }>
> {