+import { computed } from 'vue';
+import { useMapGetter } from 'dashboard/composables/store';
+
+const currentUser = useMapGetter('getCurrentUser');
+
+const firstName = computed(() => {
+ const name = currentUser.value?.name?.trim();
+ return name ? name.split(' ')[0] : 'there';
+});
+
+// The summary is generated by the model from the assistant's stats using the
+// captain_overview_summary.liquid prompt (lib/integrations/openai/openai_prompts).
+// DUMMY: stands in for an LLM-generated summary. In production this markdown
+// string would come back from the model after we feed it the assistant's
+// stats; numbers are emphasised with **bold** so we can highlight them.
+const welcomeMarkdown = computed(
+ () =>
+ `Hey ${firstName.value}, your assistant handled **1,248 conversations** this month and saved your team **612 hours** of work. Auto-resolution climbed **4.1%** while keeping handoffs low. Knowledge coverage is running strong as well.\n\nI'd keep an eye out for credits, you seem to have exhaused nearly **80%** of it.`
+);
+
+// Split the markdown on **bold** runs so we can render emphasised numbers as
+// brand-highlighted spans with Tailwind (instead of styling raw HTML).
+const segments = computed(() => {
+ const parts = [];
+ const regex = /\*\*(.+?)\*\*/g;
+ let lastIndex = 0;
+ let match = regex.exec(welcomeMarkdown.value);
+ while (match) {
+ if (match.index > lastIndex) {
+ parts.push({ text: welcomeMarkdown.value.slice(lastIndex, match.index) });
+ }
+ parts.push({ text: match[1], bold: true });
+ lastIndex = regex.lastIndex;
+ match = regex.exec(welcomeMarkdown.value);
+ }
+ if (lastIndex < welcomeMarkdown.value.length) {
+ parts.push({ text: welcomeMarkdown.value.slice(lastIndex) });
+ }
+ return parts.map((part, index) => ({ ...part, key: index }));
+});
+
+
+
+
+- Conversations handled: {{ conversations_handled }}
+- Hours saved for the team: {{ hours_saved }}
+- Auto-resolution rate: {{ auto_resolution_rate }} ({{ auto_resolution_trend }} vs previous period)
+- Handoff rate: {{ handoff_rate }} ({{ handoff_trend }} vs previous period)
+- Reopen-after-resolve rate: {{ reopen_rate }} ({{ reopen_trend }} vs previous period)
+- Knowledge base coverage: {{ knowledge_coverage }}
+- Flagged response rate: {{ flagged_rate }}
+- Credits used: {{ credits_used_pct }} of the monthly allowance
+
+
+Rules:
+- Write 2 to 4 sentences in one short paragraph. Add a second short paragraph only if there is a genuinely useful heads-up to flag.
+- Open with "Hey {{ first_name }},". Be encouraging and conversational, never robotic.
+- Lead with the most impressive wins (conversations handled, hours saved, auto-resolution). Mention a trend only when it is meaningful.
+- Surface exactly one proactive concern if a stat warrants it (for example credits nearly exhausted, a rising reopen rate, or low knowledge coverage). Skip it entirely when everything looks healthy. Phrase it as a friendly nudge, not an alarm.
+- Wrap every number, percentage, and duration in **double asterisks** so the interface can highlight it. Bold only the figures, never whole phrases.
+- Output plain markdown only. No headings, no lists, no preamble, no closing sign-off.