feat: Add session description editing functionality (#3819)
Co-authored-by: Zane Staggs <zane@squareup.com>
This commit is contained in:
committed by
GitHub
parent
7e40b930da
commit
a5371af4c1
@@ -1,6 +1,7 @@
|
||||
import { Message } from './types/message';
|
||||
import { getSessionHistory, listSessions, SessionInfo } from './api';
|
||||
import { convertApiMessageToFrontendMessage } from './components/context_management';
|
||||
import { getApiUrl } from './config';
|
||||
|
||||
export interface SessionMetadata {
|
||||
description: string;
|
||||
@@ -126,3 +127,33 @@ export async function fetchSessionDetails(sessionId: string): Promise<SessionDet
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the metadata for a specific session
|
||||
* @param sessionId The ID of the session to update
|
||||
* @param description The new description (name) for the session
|
||||
* @returns Promise that resolves when the update is complete
|
||||
*/
|
||||
export async function updateSessionMetadata(sessionId: string, description: string): Promise<void> {
|
||||
try {
|
||||
const url = getApiUrl(`/sessions/${sessionId}/metadata`);
|
||||
const secretKey = await window.electron.getSecretKey();
|
||||
|
||||
const response = await fetch(url, {
|
||||
method: 'PUT',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-Secret-Key': secretKey,
|
||||
},
|
||||
body: JSON.stringify({ description }),
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
const errorText = await response.text();
|
||||
throw new Error(`Failed to update session metadata: ${response.statusText} - ${errorText}`);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`Error updating session metadata for ${sessionId}:`, error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user