From 496b386504c133d1db9ea9e43da4ff3a9625f373 Mon Sep 17 00:00:00 2001 From: Abdul Wahab Date: Fri, 11 Sep 2026 00:07:15 +0500 Subject: [PATCH] overlay: a lane session shows the variant bar and nothing else The generate lane hides the helper's global bar, but the overlay drew it first and hid it on `connected`, the Tune chip spun for the seconds between the variants mounting and the done reply even though the lane declares no knobs, and the agent-target pick rendered the edit-copy pencil with its "disabled while applying" tooltip. The served script's prelude now says when the bar is hidden so it is never drawn; a session records who fired its Go (`sessionOrigin`, saved with the session) and never shows the pending Tune chip when the generate verb did; the agent-target pick suppresses the edit-copy badge for the session. A user's own pick, Go, and session are unchanged, and the source test pins every gate. Written with AI assistance (Claude). Co-Authored-By: Claude Fable 5 --- skill/scripts/live-browser.js | 36 +++++++++++++++++++++++++++--- tests/live-browser-source.test.mjs | 32 ++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 3 deletions(-) diff --git a/skill/scripts/live-browser.js b/skill/scripts/live-browser.js index 22623fe5c..d4f79335c 100644 --- a/skill/scripts/live-browser.js +++ b/skill/scripts/live-browser.js @@ -165,6 +165,14 @@ } let parameterGenerationState = 'idle'; let parameterReadyAnnouncedSession = null; + // 'agent' when the generate verb fired this session's Go (the generate + // lane declares no knobs, so its bar never shows a pending Tune chip); + // null for every Go a user presses. + let sessionOrigin = null; + // The generate lane picks for the agent and never edits copy in the + // browser, so its selection carries no edit-copy badge (set on the + // agent-target pick, cleared with the session; a user's pick never sets it). + let editBadgeSuppressed = false; let svelteComponentSession = null; let svelteRuntimePromise = null; let pendingSvelteComponentRetryObserver = null; @@ -2687,7 +2695,9 @@ // then becomes interactive as soon as this variant exposes controls. const visParams = parseVariantParams(getVisibleVariantEl()); const hasParams = visParams.length > 0; - const paramsPending = !hasParams && (parameterGenerationState === 'pending' || parameterGenerationState === 'loading'); + // A generate-lane session declares no knobs, so it never shows the + // pending chip; a user's session keeps it exactly as before. + const paramsPending = !hasParams && sessionOrigin !== 'agent' && (parameterGenerationState === 'pending' || parameterGenerationState === 'loading'); if (hasParams || paramsPending) { const tune = el('button', { display: 'inline-flex', alignItems: 'center', gap: '6px', @@ -4691,6 +4701,7 @@ } function renderEditBadge(mode) { + if (editBadgeSuppressed || sessionOrigin === 'agent') mode = 'hidden'; if (mode === 'hidden' || !editBadgeEl) { hideConfigureBarTooltip(); if (editBadgeEl) editBadgeEl.style.display = 'none'; @@ -6184,6 +6195,8 @@ resetSessionFileMeta(); currentSessionId = null; parameterGenerationState = 'idle'; + sessionOrigin = null; + editBadgeSuppressed = false; parameterReadyAnnouncedSession = null; expectedVariants = 0; arrivedVariants = 0; @@ -7468,7 +7481,8 @@ clearAnnotations(); showAnnotOverlay(selectedElement); showBar('configure'); - renderEditBadge(hasTextRows(selectedElement) ? 'idle' : 'hidden'); + editBadgeSuppressed = true; + renderEditBadge('hidden'); startScrollTracking(); maybePrefetchPage(); maybeWarnConditionalAncestor(selectedElement); @@ -8221,6 +8235,7 @@ visibleVariant = 0; generationPhase = 'queued'; parameterGenerationState = 'pending'; + sessionOrigin = agentTargetForGo ? 'agent' : null; parameterReadyAnnouncedSession = null; resetSessionFileMeta(); @@ -8324,6 +8339,7 @@ visibleVariant = 0; generationPhase = 'queued'; parameterGenerationState = 'pending'; + sessionOrigin = agentTargetForGo ? 'agent' : null; parameterReadyAnnouncedSession = null; resetSessionFileMeta(); selectedElement = placeholderElement; @@ -9370,6 +9386,8 @@ void main() { pagePickSkipClick = false; currentSessionId = null; parameterGenerationState = 'idle'; + sessionOrigin = null; + editBadgeSuppressed = false; parameterReadyAnnouncedSession = null; selectedAction = 'impeccable'; pendingAcceptedSession = null; @@ -9461,6 +9479,7 @@ void main() { paramsCurrentValues = { ...saved.paramValues }; } if (saved.parameterState) parameterGenerationState = saved.parameterState; + sessionOrigin = saved.origin === 'agent' ? 'agent' : null; if (saved.generationPhase) generationPhase = saved.generationPhase; } @@ -9666,6 +9685,7 @@ void main() { pageUrl: location.pathname, paramValues: { ...paramsCurrentValues }, parameterState: parameterGenerationState, + origin: sessionOrigin || undefined, insertPlaceholder: insertPlaceholderSnapshot || undefined, pickedAnchor: pickedAnchorSnapshot || undefined, pickedAnchorViewportTop: Number.isFinite(pickedAnchorViewportTop) ? pickedAnchorViewportTop : undefined, @@ -9791,6 +9811,8 @@ void main() { pagePickSkipClick = false; currentSessionId = null; parameterGenerationState = 'idle'; + sessionOrigin = null; + editBadgeSuppressed = false; parameterReadyAnnouncedSession = null; selectedAction = 'impeccable'; renderEditBadge('hidden'); @@ -11575,11 +11597,15 @@ void main() { uiAppendStyle(s); } + // The generate lane's helper says so in the served script itself, so a + // lane session never draws the bar at all; every other session mounts + // it exactly as before. + const barHiddenFromStart = window.__IMPECCABLE_LIVE_BAR_HIDDEN__ === true; globalBarEl = el('div', { position: 'fixed', bottom: '14px', left: '50%', transform: 'translateX(-50%) translateY(20px)', zIndex: Z.bar + 5, - display: 'flex', alignItems: 'stretch', + display: barHiddenFromStart ? 'none' : 'flex', alignItems: 'stretch', gap: '0', width: 'max-content', background: P.surface, @@ -11595,6 +11621,10 @@ void main() { }); globalBarEl.id = PREFIX + '-global-bar'; globalBarEl.dataset.theme = theme; + if (barHiddenFromStart) { + liveBarHiddenByHelper = true; + globalBarEl.dataset.liveBarDisplay = 'flex'; + } // Brand mark - kinpaku Impeccable icon (site header / favicon paths). const brand = el('span', { diff --git a/tests/live-browser-source.test.mjs b/tests/live-browser-source.test.mjs index 193d48694..b9513520e 100644 --- a/tests/live-browser-source.test.mjs +++ b/tests/live-browser-source.test.mjs @@ -846,6 +846,38 @@ describe('live-browser source contracts', () => { ); }); + it('never shows a pending Tune chip for a session the generate verb started', () => { + // The generate lane declares no knobs, so the chip that spins between + // the variants mounting and the done reply is noise there; a user's Go + // keeps the chip exactly as before (origin null). + assert.equal((SOURCE.match(/parameterGenerationState = 'pending';\s*sessionOrigin = agentTargetForGo \? 'agent' : null;/g) || []).length, 2, 'every Go records who fired it'); + assert.match( + SOURCE, + /const paramsPending = !hasParams && sessionOrigin !== 'agent' && \(parameterGenerationState === 'pending' \|\| parameterGenerationState === 'loading'\);/, + 'the pending chip is gated on the origin and nothing else changed', + ); + assert.match(SOURCE, /origin: sessionOrigin \|\| undefined,/, 'the origin is saved with the session'); + assert.match(SOURCE, /sessionOrigin = saved\.origin === 'agent' \? 'agent' : null;/, 'and restored across a reload'); + assert.equal((SOURCE.match(/parameterGenerationState = 'idle';\s*sessionOrigin = null;/g) || []).length, 3, 'every session reset clears the origin'); + }); + + it('shows no edit-copy badge on a selection the generate verb made', () => { + // The lane never edits copy in the browser; the pencil badge (and its + // "disabled while applying" tooltip) belongs to a user's own pick. + assert.match(SOURCE, /function renderEditBadge\(mode\) \{\s*if \(editBadgeSuppressed \|\| sessionOrigin === 'agent'\) mode = 'hidden';/); + assert.match(SOURCE, /showBar\('configure'\);\s*editBadgeSuppressed = true;\s*renderEditBadge\('hidden'\);/, 'the agent-target pick sets the suppression before its first render'); + assert.equal((SOURCE.match(/sessionOrigin = null;\s*editBadgeSuppressed = false;/g) || []).length, 3, 'every session reset clears it'); + }); + + it('mounts the global bar hidden when the helper served the lane preference', () => { + // The generate lane's helper says so in the script prelude, so the bar + // is never drawn and then hidden (no entrance flash, no leftover); a + // plain helper serves no such line and the bar mounts exactly as before. + assert.match(SOURCE, /const barHiddenFromStart = window\.__IMPECCABLE_LIVE_BAR_HIDDEN__ === true;/); + assert.match(SOURCE, /display: barHiddenFromStart \? 'none' : 'flex', alignItems: 'stretch',/); + assert.match(SOURCE, /if \(barHiddenFromStart\) \{\s*liveBarHiddenByHelper = true;\s*globalBarEl\.dataset\.liveBarDisplay = 'flex';\s*\}/); + }); + it('re-claims busy-declined agent targets only while the overlay can still serve them', () => { const teardownSource = SOURCE.match(/function teardown\(\) \{[\s\S]*?\n \}/)?.[0] || ''; const clearAt = teardownSource.indexOf('busyDeclinedTargets.clear();');