feat: add final result rendering with status badges and artifacts
- FinalResult component showing SubagentResult summary and artifacts - Status badges: Success (green), Partial (amber), Failed (red) - Quality and source badges (Verified/Inferred, Tool Output/Web/etc) - Artifact list with file icons - Integrated into chat page after stream completes Closes #10 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
77
src/lib/components/FinalResult.svelte
Normal file
77
src/lib/components/FinalResult.svelte
Normal file
@@ -0,0 +1,77 @@
|
||||
<script lang="ts">
|
||||
import type { SubagentResult } from '$lib/proto/llm_multiverse/v1/common_pb';
|
||||
import { ResultStatus, ResultQuality, ResultSource } from '$lib/proto/llm_multiverse/v1/common_pb';
|
||||
|
||||
let { result }: { result: SubagentResult } = $props();
|
||||
|
||||
const statusConfig = $derived.by(() => {
|
||||
switch (result.status) {
|
||||
case ResultStatus.SUCCESS:
|
||||
return { label: 'Success', bg: 'bg-green-100', text: 'text-green-800', border: 'border-green-200' };
|
||||
case ResultStatus.PARTIAL:
|
||||
return { label: 'Partial', bg: 'bg-amber-100', text: 'text-amber-800', border: 'border-amber-200' };
|
||||
case ResultStatus.FAILED:
|
||||
return { label: 'Failed', bg: 'bg-red-100', text: 'text-red-800', border: 'border-red-200' };
|
||||
default:
|
||||
return { label: 'Unknown', bg: 'bg-gray-100', text: 'text-gray-800', border: 'border-gray-200' };
|
||||
}
|
||||
});
|
||||
|
||||
const qualityLabel = $derived.by(() => {
|
||||
switch (result.resultQuality) {
|
||||
case ResultQuality.VERIFIED: return 'Verified';
|
||||
case ResultQuality.INFERRED: return 'Inferred';
|
||||
case ResultQuality.UNCERTAIN: return 'Uncertain';
|
||||
default: return '';
|
||||
}
|
||||
});
|
||||
|
||||
const sourceLabel = $derived.by(() => {
|
||||
switch (result.source) {
|
||||
case ResultSource.TOOL_OUTPUT: return 'Tool Output';
|
||||
case ResultSource.MODEL_KNOWLEDGE: return 'Model Knowledge';
|
||||
case ResultSource.WEB: return 'Web';
|
||||
default: return '';
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<div class="mx-4 mb-3 rounded-xl border {statusConfig.border} {statusConfig.bg} p-4">
|
||||
<div class="mb-2 flex items-center gap-2">
|
||||
<span class="rounded-full px-2.5 py-0.5 text-xs font-medium {statusConfig.bg} {statusConfig.text}">
|
||||
{statusConfig.label}
|
||||
</span>
|
||||
{#if qualityLabel}
|
||||
<span class="rounded-full bg-blue-100 px-2.5 py-0.5 text-xs font-medium text-blue-800">
|
||||
{qualityLabel}
|
||||
</span>
|
||||
{/if}
|
||||
{#if sourceLabel}
|
||||
<span class="rounded-full bg-purple-100 px-2.5 py-0.5 text-xs font-medium text-purple-800">
|
||||
{sourceLabel}
|
||||
</span>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
{#if result.summary}
|
||||
<p class="text-sm {statusConfig.text}">{result.summary}</p>
|
||||
{/if}
|
||||
|
||||
{#if result.failureReason}
|
||||
<p class="mt-2 text-sm text-red-700">Reason: {result.failureReason}</p>
|
||||
{/if}
|
||||
|
||||
{#if result.artifacts.length > 0}
|
||||
<div class="mt-3 border-t {statusConfig.border} pt-3">
|
||||
<p class="mb-1.5 text-xs font-medium text-gray-600">Artifacts</p>
|
||||
<ul class="space-y-1">
|
||||
{#each result.artifacts as artifact (artifact)}
|
||||
<li class="flex items-center gap-2 text-sm">
|
||||
<span class="text-gray-400">📄</span>
|
||||
<span class="font-mono text-xs text-gray-700">{artifact}</span>
|
||||
</li>
|
||||
{/each}
|
||||
</ul>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
Reference in New Issue
Block a user