feat(v1.1): items 7-8 — fresh counter pill + loud 'No more new bikes!' empty state

Item 7: /api/stats gains fresh (actives with no swipe row — the deck's
new-pool predicate verbatim); the header pill reads 'N live · M fresh'
(new badge unchanged); old APIs without fresh render no segment.

Item 8: sections.pool_counts() answers can-the-forge-serve-anything from
the composer's own candidate SQLs (stock answer, LAST_TWO not applied)
and rides every section_state body. The FE adds #empty2 ('No more new
bikes!' + 08:30 line + undo note): shown whenever the pile/buffer drain
and pool is 0/0/0 (report masked), on a zero-item dry forge too; undo
hides it; legacy .empty untouched. UpdateUI repaints the caption per
hydrate; the stats key-set selfcheck gains fresh.
This commit is contained in:
Torres
2026-11-13 13:42:08 -04:00
parent 0d2e5a592f
commit a1455aade4
4 changed files with 155 additions and 3 deletions

View File

@@ -97,6 +97,10 @@ nav{height:calc(68px + env(safe-area-inset-bottom,0px));display:flex;align-items
.empty{position:absolute;inset:6px 14px 2px;display:none;flex-direction:column;align-items:center;justify-content:center;gap:8px;border:1px dashed #2a2a33;border-radius:18px;color:var(--mut);text-align:center;padding:24px;font-size:13.5px}
.empty.on{display:flex}
.empty b{color:#fff;font-size:16px}
/* item 8: loud exhausted state — section mode only (legacy .empty stays) */
.empty2{position:absolute;inset:6px 14px 2px;display:none;flex-direction:column;align-items:center;justify-content:center;gap:10px;border:1px dashed #4a4a55;border-radius:18px;background:#141419;color:var(--mut);text-align:center;padding:32px;font-size:14px;min-height:220px;z-index:3}
.empty2.on{display:flex}
.empty2 b{color:#fff;font-size:22px;font-weight:800}
/* list screen */
.list{position:absolute;inset:0;display:none;flex-direction:column;background:var(--bg);z-index:50;padding-bottom:68px}
.list.on{display:flex}
@@ -212,6 +216,7 @@ nav{height:calc(68px + env(safe-area-inset-bottom,0px));display:flex;align-items
<div class="stage" id="stage">
<div class="empty" id="empty"><b>You're all caught up.</b>New bikes arrive nightly — next import 08:30.<br>↺ brings the last card back.</div>
<div class="empty2" id="empty2"><b>No more new bikes!</b>New bikes arrive nightly — next import 08:30.<br>↺ brings the last card back.</div>
<div class="report" id="report">
<b>Section complete.</b>
<div id="repCounts"></div>
@@ -652,6 +657,12 @@ async function loadSection(){
finally{ deckLoading=false; }
maybeRefill();
}
/* item 8: the deck can serve nothing at all (pool all-zero) -> loud empty */
function poolDead(){
return !!(section && section.pool
&& section.pool.fresh===0 && section.pool.returns===0
&& section.pool.wildcards===0);
}
function maybeRefill(){
if(legacyMode){
if(buffer.length<DEPTH&&deckCursor&&!deckLoaded) loadDeck();
@@ -659,23 +670,31 @@ function maybeRefill(){
return;
}
if(!pile.length&&!buffer.length&&!deckLoading){
if(section&&sectDecided>=sectTotal){
if(poolDead()){
// nothing to serve at all: the loud empty owns the stage (no report)
$('empty2').classList.add('on');
$('report').classList.remove('on');
$('empty').classList.remove('on');
}else if(section&&sectDecided>=sectTotal){
// locally exhausted (last POSTs may still be flushing — the report
// shows from localDecisions; a quiet resync freshens counts and the
// server's report flip, rate-limited so a failing last POST can't
// cause a resync loop)
$('report').classList.add('on');
$('empty').classList.remove('on');
$('empty2').classList.remove('on');
if(!section.exhausted&&Date.now()-lastResyncAt>2000){
lastResyncAt=Date.now();
loadSection();
}
}else if(section){
$('empty').classList.remove('on'); $('report').classList.remove('on');
$('empty2').classList.remove('on');
}
}else{
$('empty').classList.remove('on');
$('report').classList.remove('on');
$('empty2').classList.remove('on');
}
}
@@ -723,6 +742,7 @@ function undo(){
preloadPhotos();
$('empty').classList.remove('on');
$('report').classList.remove('on');
$('empty2').classList.remove('on');
}
$('btnLike').onclick=()=>{ if(pile[0]) commit(pile[0].el,'like'); };
$('btnNope').onclick=()=>{ if(pile[0]) commit(pile[0].el,'nope'); };
@@ -1163,7 +1183,8 @@ let badgeFired=false;
async function loadStats(){
const res=await getJSON('/api/stats');
if(!res) return;
$('pill').innerHTML=`<b>${res.live}</b> live`+(res.new>0?` · <b>${res.new}</b> new`:'');
const fresh=typeof res.fresh==='number'?res.fresh:null; // old API: no segment
$('pill').innerHTML=`<b>${res.live}</b> live${fresh!=null?` · <b>${fresh}</b> fresh`:''}`+(res.new>0?` · <b>${res.new}</b> new`:'');
$('lsub').innerHTML=`${res.live} active · `+(res.new>0?`<b style="color:#fff">${res.new} new</b>`:res.new+' new')+' since your last visit';
if(!badgeFired){
badgeFired=true;
@@ -1262,6 +1283,12 @@ $('btnForge').onclick=async()=>{
fillPile();
updateSectionUI(body);
if(pile.length){ $('report').classList.remove('on'); }
// item 8: a zero-item forge on a fully drained catalog -> empty2,
// no lone Forge button inviting a wasted agent run
if((body.items||[]).length===0 && poolDead()){
$('report').classList.remove('on');
$('empty2').classList.add('on');
}
}else{
$('forgeStatus').textContent= body.detail||'Forge failed';
paintMode();