Delete and rename conversations

This commit is contained in:
dwrz
2026-10-31 12:13:36 +00:00
parent 9020167a92
commit 62bb1cbf32
10 changed files with 552 additions and 33 deletions
+23 -7
View File
@@ -90,6 +90,22 @@ export class Api {
return this._json('/conversations', { method: 'POST', body });
}
/**
* renameConversation sets a new title for a conversation. The
* server trims the title and rejects an empty one. The returned
* row holds the saved title; the caller uses it to update the
* picker.
* @param {string} id
* @param {string} title
* @returns {Promise<Object>} the saved conversation row.
*/
async renameConversation(id, title) {
return this._json(`/conversations/${encodeURIComponent(id)}`, {
method: 'PATCH',
body: { title },
});
}
/**
* deleteConversation removes the conversation, all its messages,
* and its tool execution records. It also cancels an ongoing
@@ -199,7 +215,7 @@ export class Api {
async updateMessage(id, mid, body) {
return this._json(
`/conversations/${encodeURIComponent(id)}` +
`/messages/${encodeURIComponent(mid)}`,
`/messages/${encodeURIComponent(mid)}`,
{ method: 'PUT', body },
);
}
@@ -215,7 +231,7 @@ export class Api {
async deleteMessage(id, mid, updatedAt) {
await this._request(
`/conversations/${encodeURIComponent(id)}` +
`/messages/${encodeURIComponent(mid)}`,
`/messages/${encodeURIComponent(mid)}`,
{ method: 'DELETE', body: { updated_at: updatedAt } },
);
}
@@ -234,8 +250,8 @@ export class Api {
async updateToolCall(id, mid, cid, body) {
return this._json(
`/conversations/${encodeURIComponent(id)}` +
`/messages/${encodeURIComponent(mid)}` +
`/calls/${encodeURIComponent(cid)}`,
`/messages/${encodeURIComponent(mid)}` +
`/calls/${encodeURIComponent(cid)}`,
{ method: 'PUT', body },
);
}
@@ -252,8 +268,8 @@ export class Api {
async deleteToolCall(id, mid, cid, updatedAt) {
await this._request(
`/conversations/${encodeURIComponent(id)}` +
`/messages/${encodeURIComponent(mid)}` +
`/calls/${encodeURIComponent(cid)}`,
`/messages/${encodeURIComponent(mid)}` +
`/calls/${encodeURIComponent(cid)}`,
{ method: 'DELETE', body: { updated_at: updatedAt } },
);
}
@@ -380,7 +396,7 @@ export async function* readEvents(response) {
if (result.done) break;
}
} finally {
await reader.cancel().catch(() => { });
await reader.cancel().catch(() => {});
reader.releaseLock();
}
}