Fix Native Mode Sessions: implemented fork, revert, and sync for native sessions
This commit is contained in:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user