The design language that makes your AI harness better at design.
JavaScript
Fix: live mode no longer raises the phone keyboard on load (#1067) (#1091)
Abdul Wahab73038ce4e88a
diff --git a/skill/scripts/live-browser.js b/skill/scripts/live-browser.jsindex 75abdf0c0..504e75b9c 100644--- a/skill/scripts/live-browser.js+++ b/skill/scripts/live-browser.js@@ -2512,7 +2512,7 @@row.appendChild(buildConfigureTrailingCluster([action, count], voiceBtn, go));syncConfigureInputChrome();- if (!controlsLocked) setTimeout(() => input.focus(), 60);+ if (!controlsLocked && !touchPrimary()) setTimeout(() => input.focus(), 60);return row;}@@ -2616,7 +2616,7 @@row.appendChild(buildConfigureTrailingCluster([count], voiceBtn, create));syncInsertCreateButton(create, input);syncConfigureInputChrome();- if (!controlsLocked) setTimeout(() => input.focus(), 60);+ if (!controlsLocked && !touchPrimary()) setTimeout(() => input.focus(), 60);return row;}@@ -10592,6 +10592,11 @@ void main() {return true;}+ // Programmatic focus raises the soft keyboard on touch devices (#1067).+ function touchPrimary() {+ return !!window.matchMedia?.('(pointer: coarse)').matches;+ }+function shouldSteerAutoFocus() {return shouldFocusSteerChat()&& !steerFocusSuspended@@ -10800,6 +10805,7 @@ void main() {function syncPageChatFocus(reason) {steerFocusLog('syncPageChatFocus', { reason });+ if (touchPrimary()) return;if (state === 'CONFIGURING') focusConfigureInput(reason);else if (shouldSteerAutoFocus()) focusSteerChat(reason);}@@ -10987,7 +10993,8 @@ void main() {file: opts?.file || '',});}- if (keepExpanded) focusPageChatInput('steer-error-restore');+ if (keepExpanded && touchPrimary()) preparePageChatInputForTyping();+ else if (keepExpanded) focusPageChatInput('steer-error-restore');else syncPageChatFocus('steer-unlock');}diff --git a/tests/live-browser-source.test.mjs b/tests/live-browser-source.test.mjsindex 3518fc9ff..3b1b1df64 100644--- a/tests/live-browser-source.test.mjs+++ b/tests/live-browser-source.test.mjs@@ -1259,5 +1259,31 @@ describe('live-browser source contracts', () => {const boot = SOURCE.slice(0, SOURCE.indexOf('const HIGHLIGHT_TRANSITION'));assert.match(boot, /catch \(err\) \{[\s\S]*?__IMPECCABLE_LIVE_INIT__ = false;/);});++ it('never auto-focuses live inputs on a touch-primary device (#1067)', () => {+ const touch = SOURCE.match(/function touchPrimary\(\) \{[\s\S]*?\n \}/)?.[0];+ const sync = SOURCE.match(/function syncPageChatFocus\(reason\) \{[\s\S]*?\n \}/)?.[0];+ assert.ok(touch && sync);+ const run = (coarse, state) => {+ const calls = [];+ const fn = runInNewContext(`${touch}\n(${sync})`, {+ window: { matchMedia: (q) => ({ matches: coarse && q === '(pointer: coarse)' }) },+ steerFocusLog: () => {},+ state,+ shouldSteerAutoFocus: () => true,+ focusConfigureInput: () => calls.push('configure'),+ focusSteerChat: () => calls.push('steer'),+ });+ fn('test');+ return calls;+ };+ assert.deepEqual(run(true, 'IDLE'), []);+ assert.deepEqual(run(true, 'CONFIGURING'), []);+ assert.deepEqual(run(false, 'IDLE'), ['steer']);+ assert.deepEqual(run(false, 'CONFIGURING'), ['configure']);+ const lines = SOURCE.match(/if \(!controlsLocked && !touchPrimary\(\)\) setTimeout\(\(\) => input\.focus\(\), 60\);/g);+ assert.equal(lines?.length, 2, 'both configure rows skip auto-focus on touch');+ assert.match(SOURCE, /if \(keepExpanded && touchPrimary\(\)\) preparePageChatInputForTyping\(\);/);+ });});