Autonomous AI sales agent powered by Claude Code or Codex. Finds prospects, writes cold emails, sends campaigns, handles replies, books meetings. No API keys needed — runs on your Claude or Codex subscriptions.
Cobalt accent; conversations show the whole exchange; readable activity
Ethan612dd41ed1ee
diff --git a/harvey/dashboard.py b/harvey/dashboard.pyindex 7c3a7ca..cd3bee8 100644--- a/harvey/dashboard.py+++ b/harvey/dashboard.py@@ -1230,11 +1230,29 @@ async def get_conversations():LEFT JOIN prospects p ON c.prospect_id = p.idORDER BY c.updated_at DESC LIMIT 100""")+ # The stored thread holds replies and Harvey's answers; the cold emails+ # a reply answers live in the Outbox. Attach those (sent ones only) and+ # any answer still waiting for approval, so the page shows the exchange.+ pids = sorted({r["prospect_id"] for r in rows if r.get("prospect_id")})+ emails: dict[str, list] = {}+ if pids:+ for e in await query_db(+ "SELECT prospect_id, step, subject, body, sent_at FROM outbox "+ f"WHERE kind = 'sequence' AND status = 'sent' AND prospect_id IN ({_in(pids)}) "+ "ORDER BY sent_at", tuple(pids)):+ emails.setdefault(e.pop("prospect_id"), []).append(e)+ cids = [r["id"] for r in rows]+ drafts = {d.pop("conversation_id"): d for d in (await query_db(+ "SELECT id, conversation_id, subject, body, send_at FROM outbox "+ f"WHERE kind = 'reply' AND status = 'pending_review' AND conversation_id IN ({_in(cids)}) "+ "ORDER BY created_at", tuple(cids)) if cids else [])}for row in rows:try:row["thread"] = json.loads(row.get("thread_json", "[]"))except (json.JSONDecodeError, TypeError):row["thread"] = []+ row["emails"] = emails.get(row.get("prospect_id"), [])+ row["draft"] = drafts.get(row["id"])return rowsdiff --git a/harvey/web/app.css b/harvey/web/app.cssindex 21bdc8b..d441888 100644--- a/harvey/web/app.css+++ b/harvey/web/app.css@@ -3,7 +3,7 @@The rules this sheet follows:- 1. One accent. Indigo marks the primary action, the current page+ 1. One accent. Cobalt marks the primary action, the current pageand the main series in a chart. Status hues (good, waiting, bad,active, note) appear only on status, so colour always meanssomething.@@ -68,17 +68,17 @@--text: #111113;--text-2: #5B5B63;--text-3: #8B8B93;- --accent: #4F46E5;- --accent-hover:#4338CA;+ --accent: #1D4ED8;+ --accent-hover:#1E40AF;--accent-text: #FFFFFF;- --accent-soft: #EEF0FF;- --accent-line: #D9DCFF;- --chart-muted: #C9CAF7;+ --accent-soft: #EBF1FE;+ --accent-line: #CCDBFC;+ --chart-muted: #BCD0FA;--good: #1F7A4D; --good-bg: #E8F6EE; --good-line: #C6EAD5;--wait: #8A5A00; --wait-bg: #FFF4DE; --wait-line: #F6DFAE;--bad: #B4232F; --bad-bg: #FDECEE; --bad-line: #F7CDD2;- --active: #1D5FA8; --active-bg: #E8F1FC; --active-line: #C9DDF6;+ --active: #0E7490; --active-bg: #E5F6F9; --active-line: #BDE5EE;--note: #6A3FB0; --note-bg: #F2ECFC; --note-line: #DFD1F6;--shadow-border:@@ -91,7 +91,7 @@0 2px 6px 0 rgb(17 17 19 / 0.06);--shadow-pop: 0 0 0 1px rgb(17 17 19 / 0.08), 0 12px 32px -8px rgb(17 17 19 / 0.18);--btn-shadow: 0 0 0 1px rgb(17 17 19 / 0.10), 0 1px 2px rgb(17 17 19 / 0.06);- --btn-primary-shadow: inset 0 1px 0 rgb(255 255 255 / 0.18), 0 0 0 1px #3F37C9, 0 1px 2px rgb(17 17 19 / 0.12);+ --btn-primary-shadow: inset 0 1px 0 rgb(255 255 255 / 0.18), 0 0 0 1px #1A44C2, 0 1px 2px rgb(17 17 19 / 0.12);color-scheme: light;}@@ -107,17 +107,17 @@--text: #F3F3F5;--text-2: #A3A3AC;--text-3: #6E6E77;- --accent: #7B74FF;- --accent-hover:#8D87FF;+ --accent: #3D6FF5;+ --accent-hover:#5A85FF;--accent-text: #FFFFFF;- --accent-soft: #1E1C3A;- --accent-line: #2E2B5C;- --chart-muted: #34315F;+ --accent-soft: #111C36;+ --accent-line: #1E3366;+ --chart-muted: #22365F;--good: #5CCB8F; --good-bg: #10261B; --good-line: #1C4130;--wait: #F0B84F; --wait-bg: #2A2010; --wait-line: #4A3817;--bad: #FF7A85; --bad-bg: #2C1316; --bad-line: #4C1F25;- --active: #6AA8F2; --active-bg: #11202F; --active-line: #1D3650;+ --active: #4CC3D9; --active-bg: #0C2328; --active-line: #164049;--note: #B79BF5; --note-bg: #1E1730; --note-line: #352857;--shadow-border: 0 0 0 1px rgb(255 255 255 / 0.07);@@ -133,12 +133,12 @@--bg:#0E0E10; --surface:#161618; --surface-2:#1D1D20; --surface-3:#26262A;--line:#26262A; --line-strong:#34343A;--text:#F3F3F5; --text-2:#A3A3AC; --text-3:#6E6E77;- --accent:#7B74FF; --accent-hover:#8D87FF; --accent-text:#FFFFFF;- --accent-soft:#1E1C3A; --accent-line:#2E2B5C; --chart-muted:#34315F;+ --accent:#3D6FF5; --accent-hover:#5A85FF; --accent-text:#FFFFFF;+ --accent-soft:#111C36; --accent-line:#1E3366; --chart-muted:#22365F;--good:#5CCB8F; --good-bg:#10261B; --good-line:#1C4130;--wait:#F0B84F; --wait-bg:#2A2010; --wait-line:#4A3817;--bad:#FF7A85; --bad-bg:#2C1316; --bad-line:#4C1F25;- --active:#6AA8F2; --active-bg:#11202F; --active-line:#1D3650;+ --active:#4CC3D9; --active-bg:#0C2328; --active-line:#164049;--note:#B79BF5; --note-bg:#1E1730; --note-line:#352857;--shadow-border: 0 0 0 1px rgb(255 255 255 / 0.07);--shadow-border-hover: 0 0 0 1px rgb(255 255 255 / 0.12);@@ -321,7 +321,7 @@ main.content { min-width: 0; padding: var(--sp-6) var(--sp-6) 96px; }.kpi-label { font-size: var(--fs-ui); color: var(--text-2); display: flex; align-items: center; gap: 6px; }.kpi-value { font-size: var(--fs-kpi); font-weight: 600; letter-spacing: -0.03em; line-height: 1.1; }.kpi-value.zero { color: var(--text-3); }-.kpi-foot { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--sp-2); min-height: 28px; flex-wrap: wrap; }+.kpi-main { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--sp-3); min-height: 32px; }.kpi-note { font-size: var(--fs-caption); color: var(--text-3); }.kpi-note b { color: var(--text-2); font-weight: 500; }.spark { display: flex; align-items: flex-end; gap: 2px; height: 28px; flex: 1; max-width: 140px; justify-content: flex-end; }@@ -605,6 +605,7 @@ tr:focus-within .row-action { opacity: 1; }.tl-text { font-size: var(--fs-ui); color: var(--text); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }.tl-text::first-letter { text-transform: uppercase; }.tl-agent { font-size: var(--fs-caption); color: var(--text-3); }+.tl-item.quiet .tl-text { color: var(--text-3); }/* Setup progress, check list */.check-item { display: flex; gap: 10px; padding: 10px 0; }@@ -865,6 +866,27 @@ textarea.form-input { height: auto; padding: 8px 12px; }.thread-msg.sent { align-self: flex-end; background: var(--accent-soft); color: var(--text); box-shadow: inset 0 0 0 1px var(--accent-line); border-bottom-right-radius: 4px; }.thread-msg.received { align-self: flex-start; background: var(--surface-2); color: var(--text); border-bottom-left-radius: 4px; }.thread-msg .sender { font-size: 11px; opacity: 0.7; margin-bottom: 2px; }+.thread-email {+ align-self: flex-end; width: min(78%, 64ch); border-radius: 14px; border-bottom-right-radius: 4px;+ background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); overflow: hidden;+}+.te-head {+ display: flex; align-items: center; gap: 8px; padding: 8px 14px; font-size: var(--fs-caption);+ color: var(--text-2); background: var(--surface-2); border-bottom: 1px solid var(--line);+}+.te-head .icon { width: 13px; height: 13px; color: var(--accent); }+.te-head b { color: var(--text); font-weight: 600; }+.te-head span:not(.te-when) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }+.te-when { margin-left: auto; color: var(--text-3); white-space: nowrap; }+.te-body { padding: 10px 14px; font-size: var(--fs-ui); line-height: 1.55; white-space: pre-wrap; color: var(--text-2); }+.thread-draft {+ align-self: flex-end; width: min(78%, 64ch); padding: 10px 14px 12px; border-radius: 14px;+ border: 1.5px dashed var(--accent-line); background: var(--accent-soft);+}+.thread-draft .sender { display: flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 600; color: var(--accent); margin-bottom: 4px; }+.thread-draft .sender .icon { width: 12px; height: 12px; }+.td-body { font-size: var(--fs-ui); line-height: 1.55; white-space: pre-wrap; margin-bottom: 10px; }+@media (max-width: 640px) { .thread-email, .thread-draft, .thread-msg { width: auto; max-width: 92%; } }/* ── Controls, help, misc ────────────────────────────────────── */diff --git a/harvey/web/app.js b/harvey/web/app.jsindex 10e04cc..0ad7048 100644--- a/harvey/web/app.js+++ b/harvey/web/app.js@@ -68,6 +68,8 @@ const STATUS = {not_interested: ['Not interested', 'bad'],bounced: ['Bounced', 'bad'],write_failed: ["Couldn't write", 'bad'],+ queued: ['Queued', 'active'],+ opted_out: ['Opted out', 'bad'],// campaignsdraft: ['Draft', 'waiting'],active: ['Active', 'good'],@@ -79,6 +81,12 @@ const STATUS = {closed_won: ['Won', 'good'],closed_lost: ['Lost', 'bad'],objection: ['Objection', 'waiting'],+ question: ['Question', 'active'],+ ooo: ['Out of office', 'idle'],+ wrong_person: ['Wrong person', 'waiting'],+ unsubscribe: ['Unsubscribed', 'bad'],+ escalate: ['Needs a human', 'bad'],+ needs_human: ['Needs you', 'waiting'],// outboxpending_review: ['Waiting on you', 'waiting'],approved: ['Approved', 'good'],@@ -207,9 +215,34 @@ function sourceLabel(s) {}const AGENT_ICONS = {scout: 'discover', writer: 'pen', sender: 'campaigns', handler: 'message',- analyst: 'usage', user: 'contacts'};+ analyst: 'usage', user: 'contacts', main: 'refresh'};+// One plain sentence per logged action, from the details each agent records.function actionText(a) {- return escHtml(String(a.action_type || '').replace(/_/g, ' '));+ const d = a.details || {};+ const who = escHtml(d.prospect_email || d.prospect || d.to || '');+ const camp = escHtml(d.campaign_name || d.campaign || '');+ const intent = d.intent ? ' · ' + escHtml(String(d.intent).replace(/_/g, ' ')) : '';+ const n = (v, one, many) => (Number(v) || 0) + ' ' + ((Number(v) || 0) === 1 ? one : many);+ switch (a.action_type) {+ case 'prospect': return 'Found ' + n(d.prospects_found, 'new contact', 'new contacts');+ case 'write_campaign': return 'Wrote “' + camp + '” for ' + n(d.prospect_count, 'contact', 'contacts');+ case 'write_failed': return 'Couldn’t write for some contacts' + (camp ? ' in “' + camp + '”' : '');+ case 'stage_campaign': return 'Queued ' + n(d.staged, 'email', 'emails') + ' from “' + camp + '”' ++ (d.mode ? ' · ' + escHtml(d.mode) : '');+ case 'send_campaign': return 'Sent “' + camp + '” to Instantly · ' + n(d.leads_added, 'lead', 'leads');+ case 'email_sent': return d.kind === 'reply' ? 'Sent a reply to ' + who+ : 'Sent email ' + escHtml(String(d.step || 1)) + ' to ' + who;+ case 'reply': return 'Answered ' + who + intent;+ case 'reply_queued': return 'Drafted a reply to ' + who + intent;+ case 'opt_out': return who + ' opted out';+ case 'escalation': return 'Flagged ' + who + ' for you' + (d.reason ? ' · ' + escHtml(d.reason) : '');+ case 'bounce': return 'Email to ' + who + ' bounced';+ case 'manual_send': return 'You marked a contact as emailed by hand';+ case 'manual_send_undone': return 'You undid a hand-sent mark';+ case 'outbox_edited': return 'You edited a draft';+ }+ const text = escHtml(String(a.action_type || '').replace(/_/g, ' '));+ return a.agent === 'main' ? 'Heartbeat: ' + text : text;}function emptyState(glyph, title, copy) {@@ -449,8 +482,8 @@ function renderFigures(stats) {const last7 = a => sum((a || []).slice(-7));const card = (label, value, spark, note) =>'<div class="kpi"><div class="kpi-label">' + label + '</div>' +- '<div class="kpi-value' + (value ? '' : ' zero') + '">' + value + '</div>' +- '<div class="kpi-foot"><span class="kpi-note">' + note + '</span>' + spark + '</div></div>';+ '<div class="kpi-main"><span class="kpi-value' + (value ? '' : ' zero') + '">' + value + '</span>' + spark + '</div>' ++ '<span class="kpi-note">' + note + '</span></div>';el.innerHTML = '<div class="kpis">' +card('Contacts found', stats.prospects || 0, sparkBars(t.found, 'Contacts found per day, last 14 days'),@@ -486,7 +519,8 @@ async function loadFunnel() {['To write', n(['new', 'queued']), 'c-accent-soft'],['Contacted', n(['contacted']), 'c-accent'],['Replied', n(['replied']), 'c-active'],- ['Interested', n(['interested', 'meeting']), 'c-good'],+ ['Interested', n(['interested']), 'c-good'],+ ['Meeting booked', n(['meeting']), 'c-note'],['Closed out', total - n(known), 'c-idle'],];if (!total) {@@ -514,7 +548,7 @@ async function loadTodayActivity() {'Nothing yet. Every action Harvey takes shows up here.</p>';return;}- el.innerHTML = '<div class="timeline">' + data.slice(0, 8).map(a =>+ el.innerHTML = '<div class="timeline">' + data.filter(a => a.agent !== 'main').slice(0, 8).map(a =>'<div class="tl-item">' +'<span class="tl-time">' + relTime(a.created_at) + '</span>' +'<span class="tl-icon">' + icon(AGENT_ICONS[a.agent] || 'activity') + '</span>' +@@ -1961,34 +1995,84 @@ async function loadCampaigns() {el.innerHTML = html;}+// The whole exchange in order: Harvey's cold emails (from the Outbox), the+// replies, Harvey's answers, and any answer still waiting for approval.+let _convos = [], _convoFilter = 'needs';+const STAGE_LABELS = {+ initial_outreach: 'Outreach', engaged: 'Engaged', qualifying: 'Qualifying', presenting: 'Presenting',+ negotiating: 'Negotiating', closing: 'Closing', closed_won: 'Won', closed_lost: 'Lost',+};+const CONVO_FILTERS = [+ ['needs', 'Needs you', c => !!c.draft || c.status === 'needs_human'],+ ['open', 'Open', c => c.status !== 'closed'],+ ['closed', 'Closed', c => c.status === 'closed'],+ ['all', 'All', () => true],+];+async function loadConversations() {const el = document.getElementById('conversations-list');const data = await api('/api/conversations');if (!data) { el.innerHTML = offlineState(); return; }+ _convos = data;if (!data.length) {el.innerHTML = emptyState(icon('conversations'), 'No conversations yet','No prospects have replied so far. When they do, the Handler agent classifies each reply and responds — every thread shows up here.');return;}- let html = '';- for (const c of data) {- let threadHtml = '';- for (const msg of (c.thread || [])) {- const cls = msg.sender === 'harvey' ? 'sent' : 'received';- threadHtml += '<div class="thread-msg ' + cls + '"><div class="sender">' +- (cls === 'sent' ? 'Harvey' : escHtml(c.first_name || msg.sender)) +- ' · ' + relTime(msg.timestamp) + '</div>' + escHtml(msg.content) + '</div>';- }- const name = [c.first_name, c.last_name].filter(Boolean).join(' ') || 'Unknown';- html += '<div class="convo-card"><div class="convo-head">' +- '<span class="avatar">' + initials(c.first_name, c.last_name) + '</span>' +- '<div><h3>' + escHtml(name) + '</h3><div class="sub">' +- escHtml([c.company, c.prospect_email].filter(Boolean).join(' · ')) + ' · ' + relTime(c.updated_at) + '</div></div>' +- '<div class="tags">' + (c.intent ? badge(c.intent) : '') + badge(c.status) + '</div></div>' +- '<div class="thread">' + (threadHtml || '<p class="muted" style="font-size:13px">No messages in this thread yet.</p>') +- '</div></div>';+ // Open on "Needs you" only when something needs you.+ if (_convoFilter === 'needs' && !data.some(CONVO_FILTERS[0][2])) _convoFilter = 'open';+ renderConversations();+}++function setConvoFilter(f) { _convoFilter = f; renderConversations(); }++function renderConversations() {+ const el = document.getElementById('conversations-list');+ const filter = CONVO_FILTERS.find(f => f[0] === _convoFilter) || CONVO_FILTERS[3];+ const bar = '<div class="toolbar"><div class="segmented" role="group" aria-label="Filter conversations">' ++ CONVO_FILTERS.map(f => '<button class="' + (f[0] === filter[0] ? 'on' : '') ++ '" onclick="setConvoFilter(\'' + f[0] + '\')">' + f[1] + ' <span class="n">' ++ _convos.filter(f[2]).length + '</span></button>').join('') + '</div></div>';+ const shown = _convos.filter(filter[2]);+ if (!shown.length) {+ el.innerHTML = bar + '<div class="card">' + emptyState(icon('check'), 'Nothing here',+ 'No conversation matches this filter.') + '</div>';+ return;}- el.innerHTML = html;+ el.innerHTML = bar + shown.map(convoCard).join('');+}++function convoCard(c) {+ const items = (c.emails || []).map(e => ({ts: e.sent_at, email: e}))+ .concat((c.thread || []).map(m => ({ts: m.timestamp, msg: m})))+ .sort((a, b) => parseTs(a.ts) - parseTs(b.ts));+ const first = c.first_name || 'Them';+ const thread = items.map(it => {+ if (it.email) {+ return '<div class="thread-email"><div class="te-head">' + icon('campaigns') ++ '<b>Email ' + escHtml(String(it.email.step)) + '</b><span>' + escHtml(it.email.subject) + '</span>' ++ '<span class="te-when">' + relTime(it.email.sent_at) + '</span></div>' ++ '<div class="te-body">' + escHtml(it.email.body) + '</div></div>';+ }+ const m = it.msg, sent = m.sender === 'harvey';+ return '<div class="thread-msg ' + (sent ? 'sent' : 'received') + '"><div class="sender">' ++ (sent ? 'Harvey' : escHtml(first)) + ' · ' + relTime(m.timestamp) + '</div>' ++ escHtml(m.content) + '</div>';+ }).join('');+ const draft = c.draft+ ? '<div class="thread-draft"><div class="sender">' + icon('pen') + 'Harvey drafted a reply · waiting for you</div>' ++ '<div class="td-body">' + escHtml(c.draft.body) + '</div>' ++ '<button class="btn btn-primary btn-sm" onclick="goTab(\'outbox\')">Review in Outbox' + icon('arrow') + '</button></div>'+ : '';+ const name = [c.first_name, c.last_name].filter(Boolean).join(' ') || 'Unknown';+ const stage = STAGE_LABELS[c.stage] ? '<span class="tag">' + STAGE_LABELS[c.stage] + '</span>' : '';+ return '<div class="convo-card"><div class="convo-head">' ++ '<span class="avatar">' + initials(c.first_name, c.last_name) + '</span>' ++ '<div><h3>' + escHtml(name) + '</h3><div class="sub">' ++ escHtml([c.company, c.prospect_email].filter(Boolean).join(' · ')) + ' · ' + relTime(c.updated_at) + '</div></div>' ++ '<div class="tags">' + (c.intent ? badge(c.intent) : '') + stage + badge(c.status) + '</div></div>' ++ '<div class="thread">' + (thread || '<p class="muted" style="font-size:13px">No messages in this thread yet.</p>') ++ draft + '</div></div>';}async function loadActivity() {@@ -2005,7 +2089,7 @@ async function loadActivity() {for (const a of data) {const label = dayLabel(a.created_at);if (label !== day) { day = label; html += '<div class="tl-day">' + escHtml(label) + '</div>'; }- html += '<div class="tl-item"><span class="tl-time">' + timeOfDay(a.created_at) + '</span>' ++ html += '<div class="tl-item' + (a.agent === 'main' ? ' quiet' : '') + '"><span class="tl-time">' + timeOfDay(a.created_at) + '</span>' +'<span class="tl-icon">' + icon(AGENT_ICONS[a.agent] || 'activity') + '</span>' +'<span class="tl-text">' + actionText(a) + '</span>' +'<span class="tl-agent">' + escHtml(a.agent) + '</span></div>';diff --git a/tests/test_dashboard_conversations.py b/tests/test_dashboard_conversations.pynew file mode 100644index 0000000..6adf5af--- /dev/null+++ b/tests/test_dashboard_conversations.py@@ -0,0 +1,54 @@+"""/api/conversations carries the whole exchange: the cold emails a reply+answers live in the Outbox, not in the stored thread."""++import asyncio+import json+import sqlite3++from tests.test_dashboard_signals import client # noqa: F401 (fixture)+from harvey.state import StateManager+++def _sql(db, query, params=()):+ with sqlite3.connect(db) as conn:+ conn.execute(query, params)+ conn.close()+++def _seed(db):+ asyncio.run(StateManager(str(db)).init_db())+ _sql(db, "INSERT INTO prospects (id, first_name, email, status) VALUES ('p1', 'Iris', '[email protected]', 'replied')")+ _sql(db, "INSERT INTO prospects (id, first_name, email, status) VALUES ('p2', 'Ben', '[email protected]', 'contacted')")+ thread = [{"sender": "prospect", "content": "What does it cost?", "timestamp": "2026-10-18T10:00:00"}]+ _sql(db, "INSERT INTO conversations (id, prospect_id, campaign_id, thread_json, intent, status, updated_at) "+ "VALUES ('c1', 'p1', 'k1', ?, 'question', 'open', '2026-10-18T10:00:00')", (json.dumps(thread),))+ rows = [+ ("o1", "p1", "sequence", 1, "sent", "quick question", "Hi Iris, one.", "2026-10-10T09:00:00", ""),+ ("o2", "p1", "sequence", 2, "sent", "re: booking", "Hi Iris, two.", "2026-10-13T09:00:00", ""),+ ("o3", "p1", "sequence", 3, "cancelled", "closing", "Hi Iris, three.", None, ""),+ ("o4", "p1", "reply", 1, "pending_review", "Re: re: booking", "It's $49 a month.", None, "c1"),+ ("o5", "p1", "reply", 1, "sent", "Re: earlier", "Already in the thread.", "2026-10-18T11:00:00", "c1"),+ ("o6", "p2", "sequence", 1, "sent", "hello Ben", "Hi Ben.", "2026-10-11T09:00:00", ""),+ ]+ for oid, pid, kind, step, status, subject, body, sent_at, conv in rows:+ _sql(db, "INSERT INTO outbox (id, prospect_id, campaign_id, conversation_id, kind, step, to_email, "+ "subject, body, status, sent_at, send_at) VALUES (?,?,?,?,?,?,?,?,?,?,?,?)",+ (oid, pid, "k1" if kind == "sequence" else "", conv, kind, step, "[email protected]", subject, body,+ status, sent_at, "2026-10-19T09:00:00"))+++def test_conversations_include_the_emails_they_answer_and_a_waiting_draft(client):+ _seed(client.db_path)+ [convo] = client.get("/api/conversations").json()+ assert [(e["step"], e["subject"]) for e in convo["emails"]] == [(1, "quick question"), (2, "re: booking")]+ assert all("sent_at" in e and "body" in e for e in convo["emails"]) # cancelled step 3 left out+ assert convo["draft"]["id"] == "o4" and convo["draft"]["body"] == "It's $49 a month."+ assert convo["thread"][0]["content"] == "What does it cost?"+++def test_a_conversation_without_emails_or_draft(client):+ asyncio.run(StateManager(str(client.db_path)).init_db())+ _sql(client.db_path, "INSERT INTO prospects (id, first_name, email, status) VALUES ('p9', 'Ana', '[email protected]', 'replied')")+ _sql(client.db_path, "INSERT INTO conversations (id, prospect_id, thread_json, status) VALUES ('c9', 'p9', '[]', 'open')")+ [convo] = client.get("/api/conversations").json()+ assert convo["emails"] == [] and convo["draft"] is None