Fix Native Mode Sessions: implemented fork, revert, and sync for native sessions

This commit is contained in:
Gemini AI
2025-12-27 10:40:45 +04:00
Unverified
parent 610057c058
commit ad76ade6ab
5 changed files with 405 additions and 83 deletions

View File

@@ -138,6 +138,26 @@ export const nativeSessionApi = {
return response.ok || response.status === 204
},
async forkSession(workspaceId: string, sessionId: string): Promise<NativeSession> {
const response = await fetch(`${CODENOMAD_API_BASE}/api/native/workspaces/${encodeURIComponent(workspaceId)}/sessions/${encodeURIComponent(sessionId)}/fork`, {
method: "POST"
})
if (!response.ok) throw new Error("Failed to fork session")
const data = await response.json()
return data.session
},
async revertSession(workspaceId: string, sessionId: string, messageId?: string): Promise<NativeSession> {
const response = await fetch(`${CODENOMAD_API_BASE}/api/native/workspaces/${encodeURIComponent(workspaceId)}/sessions/${encodeURIComponent(sessionId)}/revert`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ messageId })
})
if (!response.ok) throw new Error("Failed to revert session")
const data = await response.json()
return data.session
},
async getMessages(workspaceId: string, sessionId: string): Promise<NativeMessage[]> {
const response = await fetch(`${CODENOMAD_API_BASE}/api/native/workspaces/${encodeURIComponent(workspaceId)}/sessions/${encodeURIComponent(sessionId)}/messages`)
if (!response.ok) throw new Error("Failed to get messages")