← back to Commercialrealestate
mls.html: agent-discover writes back to the row (searchable), not just the DOM
d3395bcb646a2d6e767a670ef7daedbf8f1eb791 · 2026-08-17 21:14:51 -0700 · Steve
On a successful "🔎 agent" discovery the handler wrote agent_site/phone only into
the DOM via outerHTML, never onto the row object — so searching by a just-discovered
agent site/phone silently missed, and a re-render dropped it. Now it writes the fields
onto every matching row (normalized broker_agent|broker_firm key, same as the
agent-sites enrichment) and invalidates that row._hay so the cached search haystack
rebuilds with the new fields. (yolo Pass 4; Cody-gated crack from the Pass-3 review.)
Verified: inline-script syntax clean; write-back match unit-tested (normalizes
"CBRE, Inc."≈"cbre inc"; non-matching rows untouched; _hay invalidated); page smoke
200 rows / 0 console errors.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Files touched
Diff
commit d3395bcb646a2d6e767a670ef7daedbf8f1eb791
Author: Steve <steve@designerwallcoverings.com>
Date: Mon Aug 17 21:14:51 2026 -0700
mls.html: agent-discover writes back to the row (searchable), not just the DOM
On a successful "🔎 agent" discovery the handler wrote agent_site/phone only into
the DOM via outerHTML, never onto the row object — so searching by a just-discovered
agent site/phone silently missed, and a re-render dropped it. Now it writes the fields
onto every matching row (normalized broker_agent|broker_firm key, same as the
agent-sites enrichment) and invalidates that row._hay so the cached search haystack
rebuilds with the new fields. (yolo Pass 4; Cody-gated crack from the Pass-3 review.)
Verified: inline-script syntax clean; write-back match unit-tested (normalizes
"CBRE, Inc."≈"cbre inc"; non-matching rows untouched; _hay invalidated); page smoke
200 rows / 0 console errors.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---
public/mls.html | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/public/mls.html b/public/mls.html
index 540bda8..52ce062 100644
--- a/public/mls.html
+++ b/public/mls.html
@@ -874,6 +874,12 @@ document.addEventListener('click', async e=>{
const r=await (await fetch('/api/agent/discover',{method:'POST',headers:{'Content-Type':'application/json'},
body:JSON.stringify({agent:b.dataset.a,firm:b.dataset.f,city:b.dataset.c})})).json();
if(r.status==='found'&&r.website){
+ // Write the discovery back onto the matching row object(s) — not just the DOM — so the agent's
+ // site/phone become searchable and survive a re-render. Invalidate _hay so the cached search
+ // haystack rebuilds with the new fields. (Cody Pass-3 gate: was DOM-only, silently unsearchable.)
+ const _n=s=>String(s||'').toLowerCase().replace(/[^a-z0-9]+/g,' ').trim();
+ const na=_n(b.dataset.a), nf=_n(b.dataset.f);
+ DATA.forEach(row=>{ if(_n(row.broker_agent)===na && _n(row.broker_firm)===nf){ row.agent_site=r.website; if(r.phone) row.agent_phone=r.phone; row._hay=null; } });
const bits=[]; if(r.phone) bits.push(`<a href="tel:${esc(r.phone)}">📞 ${esc(r.phone)}</a>`);
bits.push(`<a href="${esc(r.website)}" target="_blank" rel="noopener noreferrer">👤 agent ↗</a>`);
b.outerHTML=bits.join(' ');
← c630a2d CRCP: extend nav-agent blank-grid self-heal to all 22 nav-ag
·
back to Commercialrealestate
·
CRCP: gitignore CTA/screenrecord debug artifacts + scratch p 9106ef2 →