From fc04d3f1af2e53427a2519950108591604b4db1e Mon Sep 17 00:00:00 2001 From: Alexander Kucera Date: Sat, 25 Oct 2025 10:49:01 +0200 Subject: [PATCH] Improves model listing and prompt parsing logic Adds sorting for model dropdown to ensure consistent user experience across sessions Enhances prompt extraction by supporting more list prefix formats, improving robustness of text parsing --- api/anthropicClient.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/api/anthropicClient.ts b/api/anthropicClient.ts index 43a1983..a800984 100644 --- a/api/anthropicClient.ts +++ b/api/anthropicClient.ts @@ -217,9 +217,14 @@ export class AnthropicClient { } } + // Sort models for stable dropdown UX across sessions/pages + const sorted = allModels.slice().sort((a, b) => + (a.display_name ?? a.id).localeCompare(b.display_name ?? b.id) + ); + // Return combined response with all models return { - data: allModels, + data: sorted, first_id: firstId, has_more: false, // We've fetched all pages last_id: lastId @@ -320,8 +325,8 @@ export class AnthropicClient { const prompts: string[] = []; for (const line of lines) { - // Remove numbering (1., 2., etc.) and clean up the prompt - const cleaned = line.replace(/^\d+\.\s*/, '').trim(); + // Remove list prefixes: numbered (1., 1)), bullets (-, *, •) + const cleaned = line.replace(/^\s*(?:\d+[.)]|[-*•])\s*/, '').trim(); if (cleaned.length > 0) { prompts.push(cleaned); }