Skip to content

The design language that makes your AI harness better at design.

JavaScript

Merge pull request #571 from pbakaus/codex/issue-565-sketch-timeout

Paul Bakaus504b8f2a2259
diff --cc skill/scripts/serve-question.mjs
index db47ae466,fde5285fc..dd63f989c
--- a/skill/scripts/serve-question.mjs
+++ b/skill/scripts/serve-question.mjs
@@@ -1018,21 -882,44 +1021,46 @@@ ${buildPath?.toggle ? `<div id="bp-conf
// A live elapsed count is the difference between "working" and "frozen".
const tick = setInterval(() => { if (note) note.textContent = 'rendering · ' + Math.round((Date.now() - started) / 1000) + 's'; }, 1000);
const settle = () => { clearInterval(tick); m.classList.remove('comp-pending', 'stand-in'); m.querySelector('.shimmer')?.remove(); m.querySelector('.stand-in-label')?.remove(); };
- const standIn = () => {
+ const fallback = () => {
const pip = m.querySelector('.pip img');
- if (!pip || m.classList.contains('stand-in')) return;
- img.src = pip.getAttribute('src'); img.hidden = false;
- m.classList.add('stand-in');
- m.querySelector('.shimmer')?.remove();
- clearInterval(tick);
- const label = document.createElement('p');
- label.className = 'stand-in-label';
- label.textContent = 'inspiration · comp pending';
- m.appendChild(label);
+ if (pip) {
+ if (m.classList.contains('stand-in')) return false;
+ img.src = pip.getAttribute('src'); img.hidden = false;
+ m.classList.add('stand-in');
+ m.querySelector('.shimmer')?.remove();
+ clearInterval(tick);
+ const label = document.createElement('p');
+ label.className = 'stand-in-label';
+ label.textContent = 'inspiration · comp pending';
+ m.appendChild(label);
+ return false;
+ }
+
+ // No comp and no inspiration is the text-only card the payload would
+ // have rendered without a comp declaration. Bring the complete read
+ // forward before removing the now-unreachable back face.
+ const card = m.closest('.card');
+ const front = card?.querySelector('.face.front');
+ const body = front?.querySelector('.body');
+ const back = card?.querySelector('.face.back');
+ const textOnlyFacts = m.querySelector('template.text-only-facts');
+ const choose = body?.querySelector(':scope > button.choose');
+ if (body && textOnlyFacts && choose) {
+ const plainDetail = body.querySelector(':scope > .detail:not(.more)');
+ [...body.children].filter((el) => el.classList.contains('fact') || el.matches('.detail.more')).forEach((el) => el.remove());
+ choose.before(textOnlyFacts.content.cloneNode(true));
+ if (plainDetail) choose.before(plainDetail);
+ }
+ card?.classList.remove('flipped');
+ front?.classList.add('text-only');
+ back?.remove();
+ settle();
+ m.remove();
+ return true;
};
const tryLoad = () => {
+ // A slot the user flipped back out of leaves the DOM; let its loop die.
+ if (!m.isConnected) { clearInterval(tick); return; }
const probe = new Image();
probe.onload = () => { landTracker.last = Date.now(); img.src = probe.src; img.hidden = false; settle(); };
probe.onerror = () => {