// The Daffodil Lane team dashboard, demo edition. // The real dashboard reads a shared database inside Claude (claude.use('db')). Here a small in-memory stand-in // (DemoDB) answers the same calls, and a script replays one real working day of the shop's agent team, sped up. // Rewritten for the public: no customer, account, order or personal details; teammates are named by role. 'use strict'; (function () { const MIN = 60000; const iso = (t) => new Date(t).toISOString(); const ymd = (days) => { const d = new Date(Date.now() + days * 86400000); return d.toISOString().slice(0, 10); }; // ---------- DemoDB: the subset of the db namespace the dashboard uses ---------- function DemoDB() { const docs = new Map(); // "collection/id" -> data const subs = []; // { kind: 'doc'|'col', path, cb, order } let seq = 0; const snapDoc = (path) => ({ exists: docs.has(path), data: () => docs.get(path), metadata: { fromCache: false } }); const snapCol = (col, order) => { let rows = [...docs.entries()].filter(([k]) => k.split('/')[0] === col).map(([k, v]) => ({ id: k.split('/')[1], data: () => v, _v: v })); if (order) rows.sort((a, b) => (String(b._v[order] || '')).localeCompare(String(a._v[order] || ''))); return { docs: rows }; }; const notify = (path) => { const col = path.split('/')[0]; for (const s of subs) { if (s.kind === 'doc' && s.path === path) s.cb(snapDoc(path)); if (s.kind === 'col' && s.path === col) s.cb(snapCol(col, s.order)); } }; const api = { write(path, data, merge) { const old = docs.get(path) || {}; docs.set(path, merge ? { ...old, ...data } : { ...data }); notify(path); }, remove(path) { docs.delete(path); notify(path); }, get(path) { return docs.get(path); }, clear() { const paths = [...docs.keys()]; docs.clear(); for (const p of paths) notify(p); }, doc(path) { return { onSnapshot(cb) { subs.push({ kind: 'doc', path, cb }); cb(snapDoc(path)); return () => {}; }, async set(body) { api.write(path, body, false); if (api.onAnswer && path.startsWith('answers/')) api.onAnswer(path.slice(8), body); } }; }, collection(col) { const q = { order: null }; const chain = { orderBy(field) { q.order = field; return chain; }, limit() { return chain; }, onSnapshot(cb) { subs.push({ kind: 'col', path: col, cb, order: q.order }); cb(snapCol(col, q.order)); return () => {}; }, async add(body) { const id = 'x' + (++seq); api.write(col + '/' + id, body, false); if (api.onMessage && col === 'chat') api.onMessage(body); return { id }; } }; return chain; } }; return api; } // ---------- The day, in order. t = minutes after the day starts ---------- const TEAM = { lead: ['Team lead', 'Plans the work, briefs the team, reports to the owner'], developer: ['Web developer', 'Builds the site, the Studio and checkout'], qa: ['QA', 'Checks every change before it goes live'], photo: ['Photo editor', 'Matches real photos to products, strips location data'], copy: ['Copywriter', 'Writes product text in the shop\'s gentle voice'], bookkeeper: ['Bookkeeper', 'Works out what each order really earns'], ads: ['Ads strategist', 'Plans ads with sourced numbers and stop rules'], marketing: ['Marketing', 'Drafts posts and ad creative from real photos'], analytics: ['Analytics', 'Tracks which link or ad brought each order'] }; const board0 = () => ({ title: 'The Daffodil Lane HQ', summary: 'The shop is live with one piece for sale. Checkout opens once Stripe has the ID and bank. Today: legal pages, order tracking, an ads plan, and more pieces on sale.', status: [ { label: 'Shop', value: 'Live', sub: 'thedaffodillane.com', tone: 'good', go: 'https://thedaffodillane.com', cta: 'Open the shop', hint: 'Opens the real shop in a new tab' }, { label: 'Products', value: '1 for sale', sub: '17 coming soon', tone: 'wait', go: 'agent:photo', cta: 'See the photo check', hint: 'A piece goes on sale only with a real photo' }, { label: 'Payments', value: 'Waiting on Stripe', sub: 'ID + bank', tone: 'bad', go: 'todo:stripe-id,stripe-bank', cta: 'Show what\'s needed', hint: 'Stripe needs the owner\'s ID number and bank account' }, { label: 'Ads', value: 'Planning', sub: '3 scenarios', tone: 'wait', go: 'agent:ads', cta: 'See the plan', hint: 'No money is spent until the owner says yes' } ], dates: [ { label: 'Domain moves to the shop\'s own account', date: ymd(6), go: 'agent:lead', cta: 'What happens', hint: 'Runs by itself; it pauses on any login code' }, { label: 'Order-by date for Christmas', date: ymd(16), go: 'agent:ads', cta: 'See the ads plan', hint: 'The ads test runs before this date' } ], todos: [ { id: 'stripe-id', title: 'Add the representative\'s ID number in Stripe', why: 'Stripe keeps payments paused until it has it.', time: '5 min', where: 'Stripe', steps: ['Open Stripe, then Settings, then Business details.', 'Type the ID number yourself. Agents never type it.', 'Save. The team checks the status after.'] }, { id: 'stripe-bank', title: 'Add the payout bank account in Stripe', why: 'Where sales are paid out.', time: '5 min', where: 'Stripe', steps: ['Open Stripe, then Settings, then Payouts.', 'Add the account yourself.', 'Save.'] } ], decisions: [ { id: 'llc', q: 'Set Stripe up as the shop\'s company, not a sole owner?', detail: 'The shop is a registered company, so sales and taxes belong to it.', more: 'It keeps business money and personal money apart, and it matches the shop\'s tax registration. Not legal advice.', options: [{ label: 'Yes, as the company' }, { label: 'Keep as is' }] } ], done: [] }); const agent = (id, state, task, t, job) => ({ kind: 'agent', id, state, task, t, job }); const say = (from, to, text, t) => ({ kind: 'chat', from, to, text, t }); const boardFx = (t, fn) => ({ kind: 'board', t, fn }); const DAY = [ say('lead', 'all', 'Morning, team. Today: privacy and terms pages, order tracking, an ads plan, and getting more pieces on sale.', 0), agent('lead', 'working', 'Planning the day and briefing the team', 0), agent('developer', 'working', 'Building the privacy and terms pages', 4), say('lead', 'developer', 'Build the privacy and terms pages from the approved drafts, then send them to QA on the test site.', 4), say('developer', 'lead', 'Started. Both pages are drafted from the approved text.', 18), agent('qa', 'working', 'Checking privacy and terms on the test site', 52), agent('developer', 'idle', 'Finished: privacy and terms pages', 52, { title: 'Privacy and terms pages', outcome: 'Built and sent to QA', status: 'ok' }), say('qa', 'lead', 'Both pages pass on phone and desktop, and every footer link works. Ready for the shop.', 70), agent('qa', 'idle', 'Finished: privacy and terms', 70, { title: 'Checked privacy and terms', outcome: 'Passed on 3 screen sizes', status: 'ok' }), boardFx(72, (b) => { b.done.unshift({ text: 'Privacy and terms pages are live', detail: 'Both pages are written from the approved drafts and linked in every footer. QA checked them first. One command undoes it.', go: 'agent:qa', cta: 'See QA\'s check' }); }), say('lead', 'all', 'Ads planning: bookkeeper, ads strategist, marketing and analytics together. Three scenarios, with sources for every number.', 90), agent('bookkeeper', 'working', 'Working out what one order earns', 92), agent('ads', 'working', 'Sourcing click prices and conversion rates', 92), agent('marketing', 'working', 'Drafting 6 ad ideas from real photos', 92), agent('analytics', 'working', 'Adding order tracking: which link brought each order', 92), say('bookkeeper', 'lead', 'One $15 bookmark keeps about $7 after card fees, the label, materials and the tax set-aside.', 120), agent('bookkeeper', 'idle', 'Finished: what each order earns', 120, { title: 'Order economics', outcome: '$6.92 kept per $15 order', status: 'ok' }), say('ads', 'lead', 'Paid clicks cost $0.50 to $1.50 and 0.5 to 2% of visitors buy, so even the best case is $25 per order. Paid ads lose money on one $15 piece.', 150), say('analytics', 'lead', 'Every order now records which ad or link brought it. Nothing personal leaves the shop.', 165), agent('analytics', 'idle', 'Finished: order tracking', 165, { title: 'Order tracking', outcome: 'Live after QA', status: 'ok' }), say('marketing', 'lead', 'Six ad ideas ready, each from a real photo, with a calendar and three backup photos.', 175), agent('marketing', 'idle', 'Finished: ad creative', 175, { title: 'Ad creative', outcome: '6 ideas, drafts only', status: 'ok' }), agent('ads', 'waiting', 'Waiting on the owner: approve a small test?', 180, { title: 'Ads plan', outcome: '3 scenarios, ROI and stop rules', status: 'ok' }), boardFx(181, (b) => { b.decisions.unshift({ id: 'ads-test', q: 'Approve an $80 ads test once checkout is open?', detail: '$40 Pinterest and $40 Instagram, $5 a day. A channel stops at $40 with no order.', more: 'At $40 with no order we can be 99% sure that channel can\'t pay for itself (the rule of three). Smaller can\'t tell; bigger just buys more loss.', options: [{ label: 'Yes, $80' }, { label: 'Not yet' }] }); b.status[3] = { label: 'Ads', value: 'Your call', sub: '$80 test', tone: 'wait', go: 'todo:ads-test', cta: 'Decide', hint: 'The plan is ready; nothing is spent until you say yes' }; }), say('ceo', 'lead', 'Give yourself a little grace, make the odds better, then go ahead.', 200), { kind: 'answer', id: 'ads-test', label: 'Yes, $80', t: 201 }, say('lead', 'ceo', 'Approved: $40 Pinterest and $40 Instagram. It starts the day checkout passes a real order, and each channel stops at $40 with no order.', 203), agent('ads', 'idle', 'Finished: $80 test approved', 203), boardFx(203, (b) => { b.decisions = b.decisions.filter((d) => d.id !== 'ads-test'); b.status[3] = { label: 'Ads', value: '$80 test', sub: 'Starts with checkout', tone: 'good', go: 'agent:ads', cta: 'See the plan', hint: 'Stops at $40 per channel with no order' }; b.done.unshift({ text: 'Ads test approved: $80', detail: 'Two channels at $5 a day, starting the day checkout passes a real order. A channel that sells earns its next $40.', go: 'agent:ads', cta: 'See the plan' }); }), say('ceo', 'lead', 'Why are some items still coming soon? I have them. Make everything available, add pictures, price them.', 260), agent('lead', 'working', 'Getting every photographed piece on sale', 262), agent('photo', 'working', 'Matching all 52 photos to products', 262), say('photo', 'lead', '13 pieces have real photos and can go on sale. 9 listed pieces have no photo anywhere, so they need one first.', 285), agent('photo', 'idle', 'Finished: photo check', 285, { title: 'Photo check', outcome: '13 ready, 9 need a photo', status: 'ok' }), agent('developer', 'working', 'Putting 13 pieces on sale on the test site', 286), say('developer', 'lead', 'All 13 are on the test site with the colors, sizes and designs their photos show. Sticker and tote prices come from the price research.', 320), agent('developer', 'idle', 'Finished: 13 pieces on the test site', 320, { title: 'Open the shop', outcome: '14 for sale on the test site', status: 'ok' }), agent('qa', 'working', 'Checking the 14 pieces for sale', 322), say('qa', 'lead', 'Pages, photos, choices, prices and cart all pass. 4 wording slips: two pages still say "coming soon" in their search text.', 350), agent('qa', 'blocked', 'Waiting on 4 wording fixes', 350, { title: 'Checked 14 pieces', outcome: '4 wording fixes needed', status: 'fail' }), agent('copy', 'working', 'Fixing the 4 wording slips', 351), say('copy', 'lead', 'Fixed. Sticker choices now list only the designs the photos show.', 362), agent('copy', 'idle', 'Finished: wording fixes', 362, { title: 'Wording fixes', outcome: '4 fixed', status: 'ok' }), say('qa', 'lead', 'Re-check passed. Ready for the shop.', 372), agent('qa', 'idle', 'Finished: re-check', 372, { title: 'Re-checked the wording', outcome: 'Passed', status: 'ok' }), say('lead', 'ceo', 'Done: your shop now has 14 pieces for sale. The maker can change any of them in the Studio.', 378), boardFx(378, (b) => { b.status[1] = { label: 'Products', value: '14 for sale', sub: '9 need a photo', tone: 'good', go: 'https://thedaffodillane.com/shop/', cta: 'See the shop', hint: '9 more go on sale as their photos arrive' }; b.todos.unshift({ id: 'photos', title: 'Photograph the 9 pieces that have no photo', why: 'The shop only sells what a real photo shows.', time: '30 min', where: 'Phone + the Studio', steps: ['Two photos each in daylight: the whole piece and a close-up.', 'Upload them in the Studio.', 'The team writes the text and puts each one on sale.'] }); b.done.unshift({ text: '14 pieces now for sale', detail: 'Bookmarks, keychains, a sweatshirt, a kids tee, totes, stickers and teacher gifts, each with the choices its photos show. QA passed it twice.', go: 'https://thedaffodillane.com/shop/', cta: 'See the shop' }); b.summary = 'The shop has 14 pieces for sale. Checkout opens once Stripe has the ID and bank. 9 pieces still need a photo.'; }), say('qa', 'lead', 'Live check passed. One thing: the new account\'s copy shows an old page after a catalog change.', 400), agent('developer', 'working', 'Fixing a stale page after catalog changes', 402), say('developer', 'lead', 'Found it: a server could read the new version number with the old product list. Each catalog now carries its own version, so that can\'t happen.', 430), agent('developer', 'idle', 'Finished: stale-page fix', 430, { title: 'Stale-page fix', outcome: 'Tests 152/152', status: 'ok' }), say('qa', 'lead', 'Fix checked on the test site. Ready for live.', 448), agent('qa', 'idle', 'Finished: fix checked', 448, { title: 'Checked the stale-page fix', outcome: 'Passed', status: 'ok' }), boardFx(450, (b) => { b.done.unshift({ text: 'Fixed: shop changes always show right away', detail: 'QA found a timing slip that could show an old page for up to a day. Fixed, checked, and live.', go: 'agent:qa', cta: 'See QA\'s checks' }); b.todos.unshift({ id: 'practice', title: 'Place one practice order with Stripe\'s test card', why: 'Proves every choice reaches the order. No real money moves.', time: '3 min', where: 'The test copy', steps: ['Add a sweatshirt in 2XL to the bag.', 'Check out and pay with Stripe\'s test card.', 'Tick Mark done.'] }); }), { kind: 'answer', id: 'todo-practice', label: 'Done', t: 470 }, say('lead', 'ceo', 'Checked: your practice order was paid and saved with everything on it: 2XL at $44, the name, the sleeve and your note.', 474), boardFx(474, (b) => { b.todos = b.todos.filter((x) => x.id !== 'practice'); b.done.unshift({ text: 'Practice order went through', detail: 'Paid in test mode and saved with every choice and the right price. Checkout works end to end.', go: 'talk', cta: 'Read the thread' }); }), say('lead', 'ceo', 'What\'s left is yours: the Stripe ID and bank, and photos of 9 pieces. I check in every hour and act the moment something arrives.', 490), agent('lead', 'idle', 'Checking in hourly; everything left waits on the owner', 490, { title: 'Day wrap-up', outcome: '14 for sale, checkout tested', status: 'ok' }) ]; const DAY_LEN = 500; // minutes of the working day // ---------- Replay engine ---------- const db = DemoDB(); let timers = []; let dayStart = 0; let board = null; let n = 0; const STEP = 1500; // ms between events at normal speed function seed() { dayStart = Date.now() - (DAY_LEN + 30) * MIN; board = board0(); db.clear(); for (const [id, [name, role]] of Object.entries(TEAM)) db.write('agents/' + id, { name, role, state: 'idle', task: 'Waiting for the day to start', updatedAt: iso(dayStart), jobs: [] }); pushBoard(0); } function pushBoard(t) { board.updatedAt = iso(dayStart + t * MIN); board.done = board.done.slice(0, 10); db.write('hq/board', JSON.parse(JSON.stringify(board)), false); } function apply(ev) { const at = iso(dayStart + ev.t * MIN); if (ev.kind === 'chat') db.write('chat/d' + (++n), { from: ev.from, to: ev.to, text: ev.text, at, read: true }, false); if (ev.kind === 'agent') { const a = db.get('agents/' + ev.id); const jobs = ev.job ? [{ at, ...ev.job }, ...(a.jobs || [])].slice(0, 10) : a.jobs; db.write('agents/' + ev.id, { state: ev.state, task: ev.task, updatedAt: at, jobs }, true); } if (ev.kind === 'board') { ev.fn(board); board.done.forEach((d) => { d.at = d.at || at; }); pushBoard(ev.t); } if (ev.kind === 'answer') db.write('answers/' + ev.id, { label: ev.label, at, seen: true }, false); } function stop() { timers.forEach(clearTimeout); timers = []; setState(false); } function replay(fast) { stop(); seed(); setState(true); DAY.forEach((ev, i) => timers.push(setTimeout(() => { apply(ev); if (i === DAY.length - 1) setState(false); }, fast ? 0 : 600 + i * STEP))); } function setState(running) { const b = document.getElementById('demo-replay'); if (b) b.textContent = running ? 'Skip to the end' : 'Replay the day'; document.documentElement.dataset.replaying = running ? '1' : ''; } // Answers and messages from the visitor get a polite demo reply from the lead. db.onAnswer = (id, body) => { setTimeout(() => { db.write('chat/v' + (++n), { from: 'lead', to: 'ceo', text: `Got it: "${body.label}". In the real dashboard I act on this at my next check-in. This is a demo, so nothing changes.`, at: iso(Date.now()), read: true }, false); db.write('answers/' + id, { ...body, seen: true }, false); }, 900); }; db.onMessage = (body) => { if (body.from !== 'ceo') return; setTimeout(() => db.write('chat/v' + (++n), { from: 'lead', to: 'ceo', text: 'Seen. In the real dashboard the lead reads this at its next check-in and answers here. This demo only replays one day.', at: iso(Date.now()), read: true }, false), 900); }; window.Demo = { db, replay, stop, isRunning: () => timers.length > 0 && document.documentElement.dataset.replaying === '1' }; // ---------- Controls and the "Show me how" tour ---------- const TOUR = [ ['strip', 'Status at a glance', 'Four tiles: shop, products, payments, ads. Every tile opens what it is about.'], ['needs', 'Needs you', 'Only what the owner alone can do: yes/no decisions with a recommendation first, and to-dos with exact steps.'], ['team', 'The team', 'Each agent shows what it is doing now. Tap one to see its recent jobs and messages.'], ['feed', 'Conversation', 'Agents post short check-ins as they work, so the page stays live without anyone polling. Messages to a teammate go through the lead.'], ['demo-replay', 'Replay the day', 'One real working day of the shop, about 8 hours, replayed in 90 seconds. Private details are removed.'] ]; let tourAt = -1; function showTour(i) { const tip = document.getElementById('tour'); document.querySelectorAll('.tour-on').forEach((e) => e.classList.remove('tour-on')); if (i < 0 || i >= TOUR.length) { tip.hidden = true; tourAt = -1; return; } tourAt = i; const [id, h, p] = TOUR[i]; let target = document.getElementById(id); if (id === 'feed' && getComputedStyle(target).display === 'none') target = document.getElementById('tab-chat'); if (id === 'needs' || id === 'team') { const g = document.getElementById('grid'); if (g.dataset.tab !== 'main') document.getElementById('tab-main').click(); } target.classList.add('tour-on'); target.scrollIntoView({ block: 'start', behavior: matchMedia('(prefers-reduced-motion: reduce)').matches ? 'auto' : 'smooth' }); document.getElementById('tour-h').textContent = `${i + 1} of ${TOUR.length}: ${h}`; document.getElementById('tour-p').textContent = p; document.getElementById('tour-next').textContent = i === TOUR.length - 1 ? 'Done' : 'Next'; document.getElementById('tour-back').disabled = i === 0; tip.hidden = false; document.getElementById('tour-next').focus({ preventScroll: true }); } document.addEventListener('DOMContentLoaded', () => { document.getElementById('demo-replay').addEventListener('click', () => { if (window.Demo.isRunning()) { stop(); replay(true); } else replay(false); }); document.getElementById('demo-tour').addEventListener('click', () => showTour(0)); document.getElementById('tour-next').addEventListener('click', () => showTour(tourAt + 1)); document.getElementById('tour-back').addEventListener('click', () => showTour(tourAt - 1)); document.getElementById('tour-close').addEventListener('click', () => showTour(-1)); document.addEventListener('keydown', (e) => { if (e.key === 'Escape' && tourAt >= 0) showTour(-1); }); }); })();