From 04d809762585f9d0f1291aa8c1bb626b8bb8781c Mon Sep 17 00:00:00 2001 From: Satyam Kumar Date: Thu, 5 Nov 2026 14:28:58 +0530 Subject: [PATCH 1/3] Add follow-up keyboard shortcut --- README.md | 2 +- leadhound/dashboard/leads.js | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index cf6a753..a38ebb9 100644 --- a/README.md +++ b/README.md @@ -126,7 +126,7 @@ You can try Pro a few times for free, then start a **7-day trial** with an email - The list is ranked best first. A pipeline tracks each lead: Inbox, Shortlist, Contacted, Replied, Won, Lost, Skipped. **NEW** marks what appeared since your last visit. - Each lead shows why it scored what it did, the original post or website problems, and contact buttons (Copy, Open, Call). **Write with AI** uses Claude, OpenAI or a local Ollama model if you set one up. - **Add lead** saves a post you found yourself; **Check for replies** looks for answers in your inbox (Pro). -- Every move has an **Undo**. Keyboard: `j`/`k` move, `s` shortlist, `c` contacted, `x` skip, `g` write, `o` open, `/` search. **Skip low scores…** clears weak leads; **Export CSV** gives you a spreadsheet. +- Every move has an **Undo**. Keyboard: `j`/`k` move, `s` shortlist, `c` contacted, `x` skip, `g` write, `f` write a follow-up for a contacted lead, `o` open, `/` search. **Skip low scores…** clears weak leads; **Export CSV** gives you a spreadsheet. **Settings**: app language, message language (automatic = the client's language), your work and skills, proof of your work, currency and minimum budget, follow-up timing, sources, **automatic search** every 6/12/24 hours, alerts, and the optional AI provider. **Updates**: the app tells you when a new version exists and installs it with one click. diff --git a/leadhound/dashboard/leads.js b/leadhound/dashboard/leads.js index e0383d8..cb15b01 100644 --- a/leadhound/dashboard/leads.js +++ b/leadhound/dashboard/leads.js @@ -260,12 +260,19 @@ async function followupBox(l) { el('p', { class: 'mut' }, o.stopped || !max ? t('fup.off') : t('fup.status', { days, n: o.followups, max })), !o.stopped && max > 0 && o.followups < max && el('div', { class: 'row' }, el('button', { class: 'btn', onclick: async () => { - try { $('#draft').value = (await api(`/api/leads/${l.id}/followup`, { action: 'draft' })).draft; $('#draft').focus(); } catch (e) { toast(e.message, 'err'); } + writeFollowup(l); } }, t('fup.write')), el('button', { class: 'btn', onclick: async () => { if (await copyText($('#draft').value)) act('sent', t('fup.sent'))(); } }, t('fup.mark')), el('button', { class: 'btn ghost', onclick: act('stop', t('fup.stopped')) }, t('fup.stop')))); } +async function writeFollowup(l) { + try { + $('#draft').value = (await api(`/api/leads/${l.id}/followup`, { action: 'draft' })).draft; + $('#draft').focus(); + } catch (e) { toast(e.message, 'err'); } +} + function auditBox(a) { const head = `${t('h.audit')} · ${a.final_url || a.url}${a.seconds ? ` · ${a.seconds}s` : ''}${a.tech?.length ? ' · ' + a.tech.join(', ') : ''}`; if (a.blocked) return el('div', {}, el('h3', {}, head), el('p', { class: 'mut' }, t('audit.blocked'))); @@ -288,6 +295,7 @@ function onKey(e) { j: () => go(i + 1), ArrowDown: () => go(i + 1), k: () => go(i - 1), ArrowUp: () => go(i - 1), s: () => sel && setStatus(sel, 'shortlisted'), c: () => sel && setStatus(sel, 'contacted'), x: () => sel && setStatus(sel, 'ignored'), g: () => sel && writeDraft(sel, false), + f: () => sel?.status === 'contacted' && writeFollowup(sel), o: () => sel && safeUrl(sel.url) && window.open(sel.url, '_blank', 'noopener'), '/': () => $('#q').focus(), }; if (keys[e.key]) { e.preventDefault(); keys[e.key](); } From 26b2920fc97645c404e3f779b6653060ff823907 Mon Sep 17 00:00:00 2001 From: Satyam Kumar Date: Thu, 5 Nov 2026 16:05:04 +0530 Subject: [PATCH 2/3] Enforce follow-up eligibility for shortcut drafts --- leadhound/dashboard/leads.js | 16 +++++++++++++--- leadhound/dashboard/server.py | 6 +++++- tests/test_features.py | 12 ++++++++++++ 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/leadhound/dashboard/leads.js b/leadhound/dashboard/leads.js index cb15b01..657f546 100644 --- a/leadhound/dashboard/leads.js +++ b/leadhound/dashboard/leads.js @@ -253,12 +253,13 @@ async function followupBox(l) { const box = $('#fu-box'); if (!box || sel?.id !== l.id || !o.contacted_at) return; const max = state.cfg.follow_up_max, days = Math.floor((Date.now() / 1000 - o.contacted_at) / 86400); + const canWrite = canWriteFollowup(l, o); const act = (action, msg) => async () => { try { await api(`/api/leads/${l.id}/followup`, { action }); toast(msg); followupBox(l); } catch (e) { toast(e.message, 'err'); } }; box.replaceChildren(el('h3', {}, t('fup.h')), el('p', { class: 'mut' }, o.stopped || !max ? t('fup.off') : t('fup.status', { days, n: o.followups, max })), - !o.stopped && max > 0 && o.followups < max && el('div', { class: 'row' }, + canWrite && el('div', { class: 'row' }, el('button', { class: 'btn', onclick: async () => { writeFollowup(l); } }, t('fup.write')), @@ -266,8 +267,17 @@ async function followupBox(l) { el('button', { class: 'btn ghost', onclick: act('stop', t('fup.stopped')) }, t('fup.stop')))); } -async function writeFollowup(l) { +function canWriteFollowup(l, o) { + return l.status === 'contacted' && !!o?.contacted_at && !o.stopped && + state.cfg.follow_up_max > 0 && o.followups < state.cfg.follow_up_max; +} + +async function writeFollowup(l, checkEligibility = false) { try { + if (checkEligibility) { + const { outreach } = await api('/api/leads/' + l.id); + if (!canWriteFollowup(l, outreach)) return; + } $('#draft').value = (await api(`/api/leads/${l.id}/followup`, { action: 'draft' })).draft; $('#draft').focus(); } catch (e) { toast(e.message, 'err'); } @@ -295,7 +305,7 @@ function onKey(e) { j: () => go(i + 1), ArrowDown: () => go(i + 1), k: () => go(i - 1), ArrowUp: () => go(i - 1), s: () => sel && setStatus(sel, 'shortlisted'), c: () => sel && setStatus(sel, 'contacted'), x: () => sel && setStatus(sel, 'ignored'), g: () => sel && writeDraft(sel, false), - f: () => sel?.status === 'contacted' && writeFollowup(sel), + f: () => sel?.status === 'contacted' && writeFollowup(sel, true), o: () => sel && safeUrl(sel.url) && window.open(sel.url, '_blank', 'noopener'), '/': () => $('#q').focus(), }; if (keys[e.key]) { e.preventDefault(); keys[e.key](); } diff --git a/leadhound/dashboard/server.py b/leadhound/dashboard/server.py index 4b616c8..946ac7d 100644 --- a/leadhound/dashboard/server.py +++ b/leadhound/dashboard/server.py @@ -108,7 +108,11 @@ def lead_followup(m, q, b): lead = need_lead(int(m.group(1))) action, cfg = b.get("action"), c.cfg() if action == "draft": - n = store.outreach(lead.id)["followups"] + 1 + outreach = store.outreach(lead.id) + if (lead.status != "contacted" or not outreach["contacted_at"] or outreach["stopped"] + or cfg.follow_up_max <= 0 or outreach["followups"] >= cfg.follow_up_max): + raise HttpError(409, "This lead is not eligible for another follow-up.") + n = outreach["followups"] + 1 return 200, {"draft": make_followup(lead, cfg, n), "n": n} if action == "sent": store.log(lead.id, "followup", str(b.get("via", "manual"))) diff --git a/tests/test_features.py b/tests/test_features.py index 32f976b..c2c11d0 100644 --- a/tests/test_features.py +++ b/tests/test_features.py @@ -380,6 +380,18 @@ def req(self, method, path, body=None): class FollowupApiTest(Api): + def test_followup_draft_requires_eligible_lead(self): + path = f"/api/leads/{self.lid}/followup" + self.assertEqual(self.req("POST", path, {"action": "draft"})[0], 409) + self.assertEqual(self.req("POST", f"/api/leads/{self.lid}", {"status": "contacted"})[0], 200) + self.assertEqual(self.req("POST", "/api/config", {"follow_up_max": 0})[0], 200) + self.assertEqual(self.req("POST", path, {"action": "draft"})[0], 409) + self.assertEqual(self.req("POST", "/api/config", {"follow_up_max": 1})[0], 200) + self.httpd.ctx.store.log(self.lid, "followup") + self.assertEqual(self.req("POST", path, {"action": "draft"})[0], 409) + self.httpd.ctx.store.log(self.lid, "nofollow") + self.assertEqual(self.req("POST", path, {"action": "draft"})[0], 409) + def test_follow_up_flow(self): self.assertEqual(self.req("POST", f"/api/leads/{self.lid}", {"status": "contacted", "draft": "first message"})[0], 200) self.assertEqual(self.req("GET", "/api/followups")[1], []) From 636f3049e6a3dd79f3225f223997cce4fd6bbb1f Mon Sep 17 00:00:00 2001 From: Satyam Kumar Date: Thu, 5 Nov 2026 16:14:43 +0530 Subject: [PATCH 3/3] Keep follow-up drafts with selected lead --- leadhound/dashboard/leads.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/leadhound/dashboard/leads.js b/leadhound/dashboard/leads.js index 657f546..c8b9c9f 100644 --- a/leadhound/dashboard/leads.js +++ b/leadhound/dashboard/leads.js @@ -274,12 +274,17 @@ function canWriteFollowup(l, o) { async function writeFollowup(l, checkEligibility = false) { try { + if (sel?.id !== l.id) return; if (checkEligibility) { const { outreach } = await api('/api/leads/' + l.id); - if (!canWriteFollowup(l, outreach)) return; + if (sel?.id !== l.id || !canWriteFollowup(l, outreach)) return; } - $('#draft').value = (await api(`/api/leads/${l.id}/followup`, { action: 'draft' })).draft; - $('#draft').focus(); + const { draft } = await api(`/api/leads/${l.id}/followup`, { action: 'draft' }); + if (sel?.id !== l.id) return; + const field = $('#draft'); + if (!field) return; + field.value = draft; + field.focus(); } catch (e) { toast(e.message, 'err'); } }