From 122e4a10d0dd741b1a811056628b47a9010a4824 Mon Sep 17 00:00:00 2001 From: icarus Date: Fri, 26 Sep 2025 05:44:23 +0800 Subject: [PATCH] refactor(api): improve session messages path handling by returning object with base and withId Simplify deleteSessionMessage implementation by using the new paths object structure --- src/renderer/src/api/agent.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/renderer/src/api/agent.ts b/src/renderer/src/api/agent.ts index 4d22b5a727..2b31873ce1 100644 --- a/src/renderer/src/api/agent.ts +++ b/src/renderer/src/api/agent.ts @@ -75,8 +75,10 @@ export class AgentApiClient { withId: (id: string) => `/${this.apiVersion}/agents/${agentId}/sessions/${id}` }) - public getSessionMessagesPath = (agentId: string, sessionId: string) => - `/${this.apiVersion}/agents/${agentId}/sessions/${sessionId}/messages` + public getSessionMessagesPaths = (agentId: string, sessionId: string) => ({ + base: `/${this.apiVersion}/agents/${agentId}/sessions/${sessionId}/messages`, + withId: (id: number) => `/${this.apiVersion}/agents/${agentId}/sessions/${sessionId}/messages/${id}` + }) public getModelsPath = (props?: ApiModelsFilter) => { const base = `/${this.apiVersion}/models` @@ -207,8 +209,7 @@ export class AgentApiClient { } public async deleteSessionMessage(agentId: string, sessionId: string, messageId: number): Promise { - const base = this.getSessionMessagesPath(agentId, sessionId) - const url = `${base}/${messageId}` + const url = this.getSessionMessagesPaths(agentId, sessionId).withId(messageId) try { await this.axios.delete(url) } catch (error) {