From 25530b3e755ca970e069e6f99c8f93b2cf76ad8d Mon Sep 17 00:00:00 2001 From: faligam Date: Sun, 6 Sep 2026 17:38:04 +0200 Subject: [PATCH] Normalize research history API response --- src/lib/sidebar.ts | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/lib/sidebar.ts b/src/lib/sidebar.ts index a8f6536..1475c5b 100644 --- a/src/lib/sidebar.ts +++ b/src/lib/sidebar.ts @@ -15,9 +15,23 @@ export interface ResearchListItem extends ResearchSummary { const HISTORY_LIMIT = 50; +interface ResearchListResponse { + items: Array<{ + research_id: string; + query: string; + state: string; + created_at: string; + }>; +} + export async function loadResearchHistory(apiKey: string): Promise { - const response = await apiGet<{ items: ResearchSummary[] }>('/v1/research', { apiKey }); - const list = response.items; + const response = await apiGet('/v1/research', { apiKey }); + const list = response.items.map(item => ({ + id: item.research_id, + query: item.query, + status: item.state, + created_at: item.created_at, + })); // Sort descending by created_at (newest first), limit to HISTORY_LIMIT const sorted = list .slice()