Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
27 changes: 25 additions & 2 deletions leadhound/dashboard/leads.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,19 +253,41 @@ 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 () => {
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'))));
}

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 (sel?.id !== l.id) return;
if (checkEligibility) {
const { outreach } = await api('/api/leads/' + l.id);
if (sel?.id !== l.id || !canWriteFollowup(l, outreach)) return;
}
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'); }
}

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')));
Expand All @@ -288,6 +310,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, true),
o: () => sel && safeUrl(sel.url) && window.open(sel.url, '_blank', 'noopener'), '/': () => $('#q').focus(),
};
if (keys[e.key]) { e.preventDefault(); keys[e.key](); }
Expand Down
6 changes: 5 additions & 1 deletion leadhound/dashboard/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")))
Expand Down
12 changes: 12 additions & 0 deletions tests/test_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -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], [])
Expand Down