From 0b54cdcc10f97b3ffe0603f45cb78f7473a25bcb Mon Sep 17 00:00:00 2001 From: Andrew Beal Date: Sat, 11 Jul 2026 14:04:19 +0100 Subject: [PATCH] refactor(ChatArea): extract message rendering into separate components Extract user and assistant message rendering logic from ChatArea into dedicated UserMessage and AssistantMessage components, removing unused dependencies and styles. --- Components/AssistantMessage.svelte | 292 +++++++++++++ Components/ChatArea.svelte | 407 +----------------- Components/UserMessage.svelte | 134 ++++++ .../OpenAIConversationNamingAgent.test.ts | 2 +- __tests__/Services/ExecutionAgent.test.ts | 3 +- 5 files changed, 433 insertions(+), 405 deletions(-) create mode 100644 Components/AssistantMessage.svelte create mode 100644 Components/UserMessage.svelte diff --git a/Components/AssistantMessage.svelte b/Components/AssistantMessage.svelte new file mode 100644 index 0000000..2a281f2 --- /dev/null +++ b/Components/AssistantMessage.svelte @@ -0,0 +1,292 @@ + + +
+
+
+
+
+ {#if message.artifacts.length > 0} + {@const artifactTally = tallyArtifactsByAction(message.artifacts)} +
+ {message.artifacts.length} FILES CHANGED +
+ {#each Object.values(ArtifactAction) as action} + {#if artifactTally[action]} +
+ + {artifactTally[action]} +
+ {/if} + {/each} +
+
+ {#each message.artifacts as artifact} +
+ +
+ {basename(artifact.filePath)} + {artifactActionToCopy(artifact.action)} +
+ {/each} +
+
+ {/if} +
+
+ + diff --git a/Components/ChatArea.svelte b/Components/ChatArea.svelte index d2df80f..1c08f3e 100644 --- a/Components/ChatArea.svelte +++ b/Components/ChatArea.svelte @@ -1,19 +1,15 @@ + +
+
+
+
+ {@html content} +
+
+ {#if message.references.length > 0} +
+
+ {#each message.references as reference} +
+
+
+
{reference.fileName}
+
{reference.size}MB
+
+
+ {/each} +
+ {/if} +
+
+ + diff --git a/__tests__/AIClasses/OpenAIConversationNamingAgent.test.ts b/__tests__/AIClasses/OpenAIConversationNamingAgent.test.ts index c14d83b..b954301 100644 --- a/__tests__/AIClasses/OpenAIConversationNamingAgent.test.ts +++ b/__tests__/AIClasses/OpenAIConversationNamingAgent.test.ts @@ -19,7 +19,7 @@ describe('OpenAIConversationNamingAgent', () => { // Mock SettingsService mockSettingsService = { settings: { - model: AIProviderModel.GPT_5_4_Nano, + model: AIProviderModel.GPT_5_6_Luna, apiKeys: { claude: 'test-claude-key', openai: 'test-openai-key', diff --git a/__tests__/Services/ExecutionAgent.test.ts b/__tests__/Services/ExecutionAgent.test.ts index 35b3bd4..e2e6525 100644 --- a/__tests__/Services/ExecutionAgent.test.ts +++ b/__tests__/Services/ExecutionAgent.test.ts @@ -8,6 +8,7 @@ import { AIToolResponse } from '../../AIClasses/ToolDefinitions/AIToolResponse'; import { AIToolResponsePayload } from '../../AIClasses/ToolDefinitions/AIToolResponsePayload'; import type { ExecutionStep } from '../../Types/ExecutionStep'; import { Artifact } from '../../Conversations/Artifact'; +import { ArtifactAction } from 'Enums/ArtifactAction'; /** * UNIT TESTS - ExecutionAgent @@ -406,7 +407,7 @@ describe('ExecutionAgent - Unit Tests', () => { instruction: 'Create new file with content' }; - const artifact = new Artifact('new-note.md', 'text/markdown', '', '# New Note\n\nContent here'); + const artifact = new Artifact('new-note.md', 'text/markdown', ArtifactAction.Create, '', '# New Note\n\nContent here'); mockAIToolService.performAITool.mockResolvedValueOnce( new AIToolResponse( AITool.WriteVaultFile,