diff --git a/apps/dashboard/src/lib/types/index.ts b/apps/dashboard/src/lib/types/index.ts index 0e2a6de..8115163 100644 --- a/apps/dashboard/src/lib/types/index.ts +++ b/apps/dashboard/src/lib/types/index.ts @@ -178,12 +178,12 @@ export interface IntentionItem { id: string; content: string; trigger_type: string; - trigger_value: string; + trigger_data: string; // JSON-encoded trigger payload (e.g. {"type":"time","at":"..."} ) status: string; - priority: string; + priority: number; // 1=low, 2=normal, 3=high, 4=critical created_at: string; - deadline?: string; - snoozed_until?: string; + deadline?: string | null; + snoozed_until?: string | null; } // Node type colors for visualization — bioluminescent palette diff --git a/apps/dashboard/src/routes/(app)/intentions/+page.svelte b/apps/dashboard/src/routes/(app)/intentions/+page.svelte index 16236ac..ca078fb 100644 --- a/apps/dashboard/src/routes/(app)/intentions/+page.svelte +++ b/apps/dashboard/src/routes/(app)/intentions/+page.svelte @@ -15,19 +15,59 @@ snoozed: 'text-dream-glow bg-dream/10 border-dream/30', }; - const PRIORITY_COLORS: Record = { - critical: 'text-decay', - high: 'text-amber-400', - normal: 'text-dim', - low: 'text-muted', + const PRIORITY_LABELS: Record = { + 4: 'critical', + 3: 'high', + 2: 'normal', + 1: 'low', + }; + + const PRIORITY_COLORS: Record = { + 4: 'text-decay', + 3: 'text-amber-400', + 2: 'text-dim', + 1: 'text-muted', }; const TRIGGER_ICONS: Record = { time: '⏰', context: '◎', event: '⚡', + manual: '◇', }; + function summarizeTrigger(intention: IntentionItem): string { + // The API returns trigger_data as a JSON-encoded string. Parse it, pick the + // most human-readable field, then truncate for display. + let result: string; + try { + const data = JSON.parse(intention.trigger_data || '{}') as Record; + if (typeof data.condition === 'string' && data.condition) { + result = data.condition; + } else if (typeof data.topic === 'string' && data.topic) { + result = data.topic; + } else if (typeof data.at === 'string' && data.at) { + try { + result = new Date(data.at).toLocaleDateString('en-US', { month: 'short', day: 'numeric' }); + } catch { + result = data.at; + } + } else if (typeof data.in_minutes === 'number') { + result = `in ${data.in_minutes} min`; + } else if (typeof data.inMinutes === 'number') { + result = `in ${data.inMinutes} min`; + } else if (typeof data.codebase === 'string' && data.codebase) { + const fp = typeof data.filePattern === 'string' && data.filePattern ? `/${data.filePattern}` : ''; + result = `${data.codebase}${fp}`; + } else { + result = intention.trigger_type; + } + } catch { + result = intention.trigger_type; + } + return result.length > 40 ? result.slice(0, 37) + '...' : result; + } + onMount(async () => { await loadData(); }); @@ -116,13 +156,11 @@ - {intention.priority} priority + {PRIORITY_LABELS[intention.priority] || 'normal'} priority - {intention.trigger_type}: {intention.trigger_value.length > 40 - ? intention.trigger_value.slice(0, 37) + '...' - : intention.trigger_value} + {intention.trigger_type}: {summarizeTrigger(intention)} {#if intention.deadline}