Skip to content

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

JavaScript

Sync generated provider output

github-actions[bot]ab524607fdea
diff --git a/.agent/skills/impeccable/reference/typeset.md b/.agent/skills/impeccable/reference/typeset.md
index 1188191dc..a0413a2c4 100644
--- a/.agent/skills/impeccable/reference/typeset.md
+++ b/.agent/skills/impeccable/reference/typeset.md
@@ -56,6 +56,16 @@ Use the fewest roles and families that make the hierarchy unmistakable. Combine
Do not make type decorative at the expense of comprehension, or introduce a second family without a clear role it alone can perform.
+## Line breaks
+
+After Matthew Butterick's *Practical Typography*, paraphrased; where his numbers differ from these, these stand.
+
+- Set `text-wrap: balance` on headings and short centered blocks, and `text-wrap: pretty` on body copy. Both are progressive: a browser that ignores them keeps its default wrap.
+- `pretty` pulls a word down beside a lone last word. It does not fill the last line, and a two-word tail is fine.
+- In a column too narrow for either to help, edit the copy or widen the column.
+- Break a heading by hand only between phrases, and check the break at every width the heading renders at. A hard break that lands mid-line on a phone is worse than the default wrap.
+- An uneven break can carry meaning: a headline that lands on one word for weight, a poster line, a pull quote. Make it deliberate with a hard break or a wrap set on that element, and keep it rare. The detector's `straggler` and `unbalanced-heading` findings are advisory for this reason; say which breaks are intended.
+
## Verify
- Primary, secondary, body, and metadata roles are recognizable without reading the copy.
diff --git a/.agent/skills/impeccable/scripts/live-browser-dom.js b/.agent/skills/impeccable/scripts/live-browser-dom.js
index 864694498..ef1ca8928 100644
--- a/.agent/skills/impeccable/scripts/live-browser-dom.js
+++ b/.agent/skills/impeccable/scripts/live-browser-dom.js
@@ -85,7 +85,16 @@
}
function id8() {
- if (crypto?.randomUUID) return crypto.randomUUID().replace(/-/g, '').slice(0, 8);
+ // randomUUID is secure-context only (issue #1055); getRandomValues is not.
+ try {
+ if (typeof crypto?.randomUUID === 'function') return crypto.randomUUID().replace(/-/g, '').slice(0, 8);
+ } catch { /* fall through */ }
+ try {
+ if (typeof crypto?.getRandomValues === 'function') {
+ const bytes = crypto.getRandomValues(new Uint8Array(4));
+ return Array.from(bytes, (b) => b.toString(16).padStart(2, '0')).join('');
+ }
+ } catch { /* fall through */ }
return (Math.random().toString(16).slice(2) + Date.now().toString(16)).slice(0, 8);
}
@@ -196,6 +205,35 @@
return el;
}
+ // Copy text through a selected textarea and execCommand, for origins where
+ // navigator.clipboard is missing or refused (plain HTTP, issue #1055).
+ // The textarea mounts like any page-level chrome, so while a modal
+ // <dialog> is open it sits in that dialog's top-layer host: on <body> it
+ // would be inert, and inert text cannot be selected or copied.
+ function copyTextViaSelection(text) {
+ let ta = null;
+ const previous = activeElementDeep();
+ try {
+ ta = doc.createElement('textarea');
+ ta.id = prefix + '-clipboard';
+ ta.value = text;
+ ta.setAttribute('readonly', '');
+ ta.setAttribute('aria-hidden', 'true');
+ ta.tabIndex = -1;
+ ta.style.cssText = 'position:fixed;top:0;left:0;width:1px;height:1px;opacity:0;pointer-events:none;';
+ uiAppendToPage(ta);
+ ta.select();
+ return doc.execCommand('copy');
+ } catch {
+ return false;
+ } finally {
+ ta?.remove();
+ if (previous && previous !== activeElementDeep() && typeof previous.focus === 'function') {
+ try { previous.focus({ preventScroll: true }); } catch { /* best effort */ }
+ }
+ }
+ }
+
function uiAppend(el) {
const uiRoot = liveUiRoot();
if (uiRoot === doc.body) return uiAppendToPage(el);
@@ -263,6 +301,7 @@
liveUiRoot,
uiAppend,
uiAppendToPage,
+ copyTextViaSelection,
topLayerHost,
watchModalDialogs,
cloneWithoutChrome,
diff --git a/.agent/skills/impeccable/scripts/live-browser-session.js b/.agent/skills/impeccable/scripts/live-browser-session.js
index ad9cdf008..388d2c2f9 100644
--- a/.agent/skills/impeccable/scripts/live-browser-session.js
+++ b/.agent/skills/impeccable/scripts/live-browser-session.js
@@ -8,10 +8,42 @@
(function (root) {
'use strict';
+ // crypto.randomUUID() exists only in secure contexts (HTTPS, localhost), so a
+ // dev site on a LAN IP, a Tailscale address, or a custom hostname over plain
+ // HTTP has no randomUUID at all (issue #1055). getRandomValues() is available
+ // in every context; Math.random() covers runtimes with no crypto. Live ids
+ // only have to be unique per session, not unguessable.
+ function randomUUID(cryptoImpl) {
+ const c = cryptoImpl === undefined ? root.crypto : cryptoImpl;
+ try {
+ if (c && typeof c.randomUUID === 'function') return c.randomUUID();
+ } catch { /* fall through to getRandomValues */ }
+ const bytes = new Uint8Array(16);
+ let filled = false;
+ try {
+ if (c && typeof c.getRandomValues === 'function') {
+ c.getRandomValues(bytes);
+ filled = true;
+ }
+ } catch { /* fall through to Math.random */ }
+ if (!filled) {
+ for (let i = 0; i < 16; i++) bytes[i] = Math.floor(Math.random() * 256);
+ }
+ bytes[6] = (bytes[6] & 0x0f) | 0x40; // version 4
+ bytes[8] = (bytes[8] & 0x3f) | 0x80; // RFC 4122 variant
+ const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, '0')).join('');
+ return hex.slice(0, 8) + '-' + hex.slice(8, 12) + '-' + hex.slice(12, 16)
+ + '-' + hex.slice(16, 20) + '-' + hex.slice(20);
+ }
+
+ function randomId8(cryptoImpl) {
+ return randomUUID(cryptoImpl).replace(/-/g, '').slice(0, 8);
+ }
+
function createLiveBrowserSessionState({ prefix, storage, idFactory }) {
if (!prefix) throw new Error('prefix required');
const store = storage || root.localStorage;
- const makeId = idFactory || function () { return Math.random().toString(16).slice(2, 10); };
+ const makeId = idFactory || function () { return randomId8(); };
const sessionKey = prefix + '-session';
const handledKey = sessionKey + '-handled';
const scrollKey = sessionKey + '-scroll';
@@ -144,5 +176,5 @@
};
}
- root.__IMPECCABLE_LIVE_SESSION__ = { createLiveBrowserSessionState };
+ root.__IMPECCABLE_LIVE_SESSION__ = { createLiveBrowserSessionState, randomUUID, randomId8 };
})(typeof window !== 'undefined' ? window : globalThis);
diff --git a/.agent/skills/impeccable/scripts/live-browser.js b/.agent/skills/impeccable/scripts/live-browser.js
index f706898e4..75abdf0c0 100644
--- a/.agent/skills/impeccable/scripts/live-browser.js
+++ b/.agent/skills/impeccable/scripts/live-browser.js
@@ -61,11 +61,19 @@
const IMPECCABLE_COMMAND = (window.__IMPECCABLE_COMMAND_PREFIX__ || '/') + 'impeccable';
const PICK_CURSOR_STYLE_ID = PREFIX + '-pick-cursor-style';
const MANUAL_APPLY_STATE_TTL_MS = 15 * 60 * 1000;
- const sessionState = window.__IMPECCABLE_LIVE_SESSION__?.createLiveBrowserSessionState({
- prefix: PREFIX,
- storage: localStorage,
- idFactory: () => crypto.randomUUID().replace(/-/g, '').slice(0, 8),
- });
+ // No idFactory: the session helper's default works on plain-HTTP origins,
+ // where the secure-context-only randomUUID does not exist (issue #1055).
+ let sessionState = null;
+ try {
+ sessionState = window.__IMPECCABLE_LIVE_SESSION__?.createLiveBrowserSessionState({
+ prefix: PREFIX,
+ storage: localStorage,
+ });
+ } catch (err) {
+ console.error('[impeccable] Live mode could not create its session state.', err);
+ window.__IMPECCABLE_LIVE_INIT__ = false; // let a later injection retry
+ return;
+ }
if (!sessionState) {
console.error('[impeccable] live-browser-session.js was not loaded. Live mode cannot start safely.');
window.__IMPECCABLE_LIVE_INIT__ = false;
@@ -293,6 +301,7 @@
liveUiRoot,
uiAppend,
uiAppendToPage,
+ copyTextViaSelection,
topLayerHost,
watchModalDialogs,
cloneWithoutChrome,
@@ -13466,12 +13475,24 @@ void main() {
.replace(/'/g, '&#39;');
}
+ // navigator.clipboard exists only in secure contexts, and writeText can
+ // reject even where it exists (no focus, permission). Fall back
+ // to the DOM helpers' selection copy (execCommand), which plain-HTTP origins
+ // still allow and which stays usable under an open modal dialog.
function copyToClipboard(text) {
if (!text) return;
+ const report = (ok) => showToast(ok ? 'Copied: ' + text : 'Could not copy: ' + text);
+ let pending = null;
try {
- navigator.clipboard.writeText(text);
- showToast('Copied: ' + text);
- } catch { /* ignore */ }
+ if (navigator.clipboard && typeof navigator.clipboard.writeText === 'function') {
+ pending = navigator.clipboard.writeText(text);
+ }
+ } catch { pending = null; }
+ if (pending && typeof pending.then === 'function') {
+ pending.then(() => report(true), () => report(copyTextViaSelection(text)));
+ return;
+ }
+ report(copyTextViaSelection(text));
}
//
diff --git a/.agents/skills/impeccable/reference/typeset.md b/.agents/skills/impeccable/reference/typeset.md
index 6f117f429..683175632 100644
--- a/.agents/skills/impeccable/reference/typeset.md
+++ b/.agents/skills/impeccable/reference/typeset.md
@@ -56,6 +56,16 @@ Use the fewest roles and families that make the hierarchy unmistakable. Combine
Do not make type decorative at the expense of comprehension, or introduce a second family without a clear role it alone can perform.
+## Line breaks
+
+After Matthew Butterick's *Practical Typography*, paraphrased; where his numbers differ from these, these stand.
+
+- Set `text-wrap: balance` on headings and short centered blocks, and `text-wrap: pretty` on body copy. Both are progressive: a browser that ignores them keeps its default wrap.
+- `pretty` pulls a word down beside a lone last word. It does not fill the last line, and a two-word tail is fine.
+- In a column too narrow for either to help, edit the copy or widen the column.
+- Break a heading by hand only between phrases, and check the break at every width the heading renders at. A hard break that lands mid-line on a phone is worse than the default wrap.
+- An uneven break can carry meaning: a headline that lands on one word for weight, a poster line, a pull quote. Make it deliberate with a hard break or a wrap set on that element, and keep it rare. The detector's `straggler` and `unbalanced-heading` findings are advisory for this reason; say which breaks are intended.
+
## Verify
- Primary, secondary, body, and metadata roles are recognizable without reading the copy.
diff --git a/.agents/skills/impeccable/scripts/live-browser-dom.js b/.agents/skills/impeccable/scripts/live-browser-dom.js
index 864694498..ef1ca8928 100644
--- a/.agents/skills/impeccable/scripts/live-browser-dom.js
+++ b/.agents/skills/impeccable/scripts/live-browser-dom.js
@@ -85,7 +85,16 @@
}
function id8() {
- if (crypto?.randomUUID) return crypto.randomUUID().replace(/-/g, '').slice(0, 8);
+ // randomUUID is secure-context only (issue #1055); getRandomValues is not.
+ try {
+ if (typeof crypto?.randomUUID === 'function') return crypto.randomUUID().replace(/-/g, '').slice(0, 8);
+ } catch { /* fall through */ }
+ try {
+ if (typeof crypto?.getRandomValues === 'function') {
+ const bytes = crypto.getRandomValues(new Uint8Array(4));
+ return Array.from(bytes, (b) => b.toString(16).padStart(2, '0')).join('');
+ }
+ } catch { /* fall through */ }
return (Math.random().toString(16).slice(2) + Date.now().toString(16)).slice(0, 8);
}
@@ -196,6 +205,35 @@
return el;
}
+ // Copy text through a selected textarea and execCommand, for origins where
+ // navigator.clipboard is missing or refused (plain HTTP, issue #1055).
+ // The textarea mounts like any page-level chrome, so while a modal
+ // <dialog> is open it sits in that dialog's top-layer host: on <body> it
+ // would be inert, and inert text cannot be selected or copied.
+ function copyTextViaSelection(text) {
+ let ta = null;
+ const previous = activeElementDeep();
+ try {
+ ta = doc.createElement('textarea');
+ ta.id = prefix + '-clipboard';
+ ta.value = text;
+ ta.setAttribute('readonly', '');
+ ta.setAttribute('aria-hidden', 'true');
+ ta.tabIndex = -1;
+ ta.style.cssText = 'position:fixed;top:0;left:0;width:1px;height:1px;opacity:0;pointer-events:none;';
+ uiAppendToPage(ta);
+ ta.select();
+ return doc.execCommand('copy');
+ } catch {
+ return false;
+ } finally {
+ ta?.remove();
+ if (previous && previous !== activeElementDeep() && typeof previous.focus === 'function') {
+ try { previous.focus({ preventScroll: true }); } catch { /* best effort */ }
+ }
+ }
+ }
+
function uiAppend(el) {
const uiRoot = liveUiRoot();
if (uiRoot === doc.body) return uiAppendToPage(el);
@@ -263,6 +301,7 @@
liveUiRoot,
uiAppend,
uiAppendToPage,
+ copyTextViaSelection,
topLayerHost,
watchModalDialogs,
cloneWithoutChrome,
diff --git a/.agents/skills/impeccable/scripts/live-browser-session.js b/.agents/skills/impeccable/scripts/live-browser-session.js
index ad9cdf008..388d2c2f9 100644
--- a/.agents/skills/impeccable/scripts/live-browser-session.js
+++ b/.agents/skills/impeccable/scripts/live-browser-session.js
@@ -8,10 +8,42 @@
(function (root) {
'use strict';
+ // crypto.randomUUID() exists only in secure contexts (HTTPS, localhost), so a
+ // dev site on a LAN IP, a Tailscale address, or a custom hostname over plain
+ // HTTP has no randomUUID at all (issue #1055). getRandomValues() is available
+ // in every context; Math.random() covers runtimes with no crypto. Live ids
+ // only have to be unique per session, not unguessable.
+ function randomUUID(cryptoImpl) {
+ const c = cryptoImpl === undefined ? root.crypto : cryptoImpl;
+ try {
+ if (c && typeof c.randomUUID === 'function') return c.randomUUID();
+ } catch { /* fall through to getRandomValues */ }
+ const bytes = new Uint8Array(16);
+ let filled = false;
+ try {
+ if (c && typeof c.getRandomValues === 'function') {
+ c.getRandomValues(bytes);
+ filled = true;
+ }
+ } catch { /* fall through to Math.random */ }
+ if (!filled) {
+ for (let i = 0; i < 16; i++) bytes[i] = Math.floor(Math.random() * 256);
+ }
+ bytes[6] = (bytes[6] & 0x0f) | 0x40; // version 4
+ bytes[8] = (bytes[8] & 0x3f) | 0x80; // RFC 4122 variant
+ const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, '0')).join('');
+ return hex.slice(0, 8) + '-' + hex.slice(8, 12) + '-' + hex.slice(12, 16)
+ + '-' + hex.slice(16, 20) + '-' + hex.slice(20);
+ }
+
+ function randomId8(cryptoImpl) {
+ return randomUUID(cryptoImpl).replace(/-/g, '').slice(0, 8);
+ }
+
function createLiveBrowserSessionState({ prefix, storage, idFactory }) {
if (!prefix) throw new Error('prefix required');
const store = storage || root.localStorage;
- const makeId = idFactory || function () { return Math.random().toString(16).slice(2, 10); };
+ const makeId = idFactory || function () { return randomId8(); };
const sessionKey = prefix + '-session';
const handledKey = sessionKey + '-handled';
const scrollKey = sessionKey + '-scroll';
@@ -144,5 +176,5 @@
};
}
- root.__IMPECCABLE_LIVE_SESSION__ = { createLiveBrowserSessionState };
+ root.__IMPECCABLE_LIVE_SESSION__ = { createLiveBrowserSessionState, randomUUID, randomId8 };
})(typeof window !== 'undefined' ? window : globalThis);
diff --git a/.agents/skills/impeccable/scripts/live-browser.js b/.agents/skills/impeccable/scripts/live-browser.js
index f706898e4..75abdf0c0 100644
--- a/.agents/skills/impeccable/scripts/live-browser.js
+++ b/.agents/skills/impeccable/scripts/live-browser.js
@@ -61,11 +61,19 @@
const IMPECCABLE_COMMAND = (window.__IMPECCABLE_COMMAND_PREFIX__ || '/') + 'impeccable';
const PICK_CURSOR_STYLE_ID = PREFIX + '-pick-cursor-style';
const MANUAL_APPLY_STATE_TTL_MS = 15 * 60 * 1000;
- const sessionState = window.__IMPECCABLE_LIVE_SESSION__?.createLiveBrowserSessionState({
- prefix: PREFIX,
- storage: localStorage,
- idFactory: () => crypto.randomUUID().replace(/-/g, '').slice(0, 8),
- });
+ // No idFactory: the session helper's default works on plain-HTTP origins,
+ // where the secure-context-only randomUUID does not exist (issue #1055).
+ let sessionState = null;
+ try {
+ sessionState = window.__IMPECCABLE_LIVE_SESSION__?.createLiveBrowserSessionState({
+ prefix: PREFIX,
+ storage: localStorage,
+ });
+ } catch (err) {
+ console.error('[impeccable] Live mode could not create its session state.', err);
+ window.__IMPECCABLE_LIVE_INIT__ = false; // let a later injection retry
+ return;
+ }
if (!sessionState) {
console.error('[impeccable] live-browser-session.js was not loaded. Live mode cannot start safely.');
window.__IMPECCABLE_LIVE_INIT__ = false;
@@ -293,6 +301,7 @@
liveUiRoot,
uiAppend,
uiAppendToPage,
+ copyTextViaSelection,
topLayerHost,
watchModalDialogs,
cloneWithoutChrome,
@@ -13466,12 +13475,24 @@ void main() {
.replace(/'/g, '&#39;');
}
+ // navigator.clipboard exists only in secure contexts, and writeText can
+ // reject even where it exists (no focus, permission). Fall back
+ // to the DOM helpers' selection copy (execCommand), which plain-HTTP origins
+ // still allow and which stays usable under an open modal dialog.
function copyToClipboard(text) {
if (!text) return;
+ const report = (ok) => showToast(ok ? 'Copied: ' + text : 'Could not copy: ' + text);
+ let pending = null;
try {
- navigator.clipboard.writeText(text);
- showToast('Copied: ' + text);
- } catch { /* ignore */ }
+ if (navigator.clipboard && typeof navigator.clipboard.writeText === 'function') {
+ pending = navigator.clipboard.writeText(text);
+ }
+ } catch { pending = null; }
+ if (pending && typeof pending.then === 'function') {
+ pending.then(() => report(true), () => report(copyTextViaSelection(text)));
+ return;
+ }
+ report(copyTextViaSelection(text));
}
//
diff --git a/.claude/skills/impeccable/reference/typeset.md b/.claude/skills/impeccable/reference/typeset.md
index 9fcdc5b63..87a33d3e1 100644
--- a/.claude/skills/impeccable/reference/typeset.md
+++ b/.claude/skills/impeccable/reference/typeset.md
@@ -56,6 +56,16 @@ Use the fewest roles and families that make the hierarchy unmistakable. Combine
Do not make type decorative at the expense of comprehension, or introduce a second family without a clear role it alone can perform.
+## Line breaks
+
+After Matthew Butterick's *Practical Typography*, paraphrased; where his numbers differ from these, these stand.
+
+- Set `text-wrap: balance` on headings and short centered blocks, and `text-wrap: pretty` on body copy. Both are progressive: a browser that ignores them keeps its default wrap.
+- `pretty` pulls a word down beside a lone last word. It does not fill the last line, and a two-word tail is fine.
+- In a column too narrow for either to help, edit the copy or widen the column.
+- Break a heading by hand only between phrases, and check the break at every width the heading renders at. A hard break that lands mid-line on a phone is worse than the default wrap.
+- An uneven break can carry meaning: a headline that lands on one word for weight, a poster line, a pull quote. Make it deliberate with a hard break or a wrap set on that element, and keep it rare. The detector's `straggler` and `unbalanced-heading` findings are advisory for this reason; say which breaks are intended.
+
## Verify
- Primary, secondary, body, and metadata roles are recognizable without reading the copy.
diff --git a/.claude/skills/impeccable/scripts/live-browser-dom.js b/.claude/skills/impeccable/scripts/live-browser-dom.js
index 864694498..ef1ca8928 100644
--- a/.claude/skills/impeccable/scripts/live-browser-dom.js
+++ b/.claude/skills/impeccable/scripts/live-browser-dom.js
@@ -85,7 +85,16 @@
}
function id8() {
- if (crypto?.randomUUID) return crypto.randomUUID().replace(/-/g, '').slice(0, 8);
+ // randomUUID is secure-context only (issue #1055); getRandomValues is not.
+ try {
+ if (typeof crypto?.randomUUID === 'function') return crypto.randomUUID().replace(/-/g, '').slice(0, 8);
+ } catch { /* fall through */ }
+ try {
+ if (typeof crypto?.getRandomValues === 'function') {
+ const bytes = crypto.getRandomValues(new Uint8Array(4));
+ return Array.from(bytes, (b) => b.toString(16).padStart(2, '0')).join('');
+ }
+ } catch { /* fall through */ }
return (Math.random().toString(16).slice(2) + Date.now().toString(16)).slice(0, 8);
}
@@ -196,6 +205,35 @@
return el;
}
+ // Copy text through a selected textarea and execCommand, for origins where
+ // navigator.clipboard is missing or refused (plain HTTP, issue #1055).
+ // The textarea mounts like any page-level chrome, so while a modal
+ // <dialog> is open it sits in that dialog's top-layer host: on <body> it
+ // would be inert, and inert text cannot be selected or copied.
+ function copyTextViaSelection(text) {
+ let ta = null;
+ const previous = activeElementDeep();
+ try {
+ ta = doc.createElement('textarea');
+ ta.id = prefix + '-clipboard';
+ ta.value = text;
+ ta.setAttribute('readonly', '');
+ ta.setAttribute('aria-hidden', 'true');
+ ta.tabIndex = -1;
+ ta.style.cssText = 'position:fixed;top:0;left:0;width:1px;height:1px;opacity:0;pointer-events:none;';
+ uiAppendToPage(ta);
+ ta.select();
+ return doc.execCommand('copy');
+ } catch {
+ return false;
+ } finally {
+ ta?.remove();
+ if (previous && previous !== activeElementDeep() && typeof previous.focus === 'function') {
+ try { previous.focus({ preventScroll: true }); } catch { /* best effort */ }
+ }
+ }
+ }
+
function uiAppend(el) {
const uiRoot = liveUiRoot();
if (uiRoot === doc.body) return uiAppendToPage(el);
@@ -263,6 +301,7 @@
liveUiRoot,
uiAppend,
uiAppendToPage,
+ copyTextViaSelection,
topLayerHost,
watchModalDialogs,
cloneWithoutChrome,
diff --git a/.claude/skills/impeccable/scripts/live-browser-session.js b/.claude/skills/impeccable/scripts/live-browser-session.js
index ad9cdf008..388d2c2f9 100644
--- a/.claude/skills/impeccable/scripts/live-browser-session.js
+++ b/.claude/skills/impeccable/scripts/live-browser-session.js
@@ -8,10 +8,42 @@
(function (root) {
'use strict';
+ // crypto.randomUUID() exists only in secure contexts (HTTPS, localhost), so a
+ // dev site on a LAN IP, a Tailscale address, or a custom hostname over plain
+ // HTTP has no randomUUID at all (issue #1055). getRandomValues() is available
+ // in every context; Math.random() covers runtimes with no crypto. Live ids
+ // only have to be unique per session, not unguessable.
+ function randomUUID(cryptoImpl) {
+ const c = cryptoImpl === undefined ? root.crypto : cryptoImpl;
+ try {
+ if (c && typeof c.randomUUID === 'function') return c.randomUUID();
+ } catch { /* fall through to getRandomValues */ }
+ const bytes = new Uint8Array(16);
+ let filled = false;
+ try {
+ if (c && typeof c.getRandomValues === 'function') {
+ c.getRandomValues(bytes);
+ filled = true;
+ }
+ } catch { /* fall through to Math.random */ }
+ if (!filled) {
+ for (let i = 0; i < 16; i++) bytes[i] = Math.floor(Math.random() * 256);
+ }
+ bytes[6] = (bytes[6] & 0x0f) | 0x40; // version 4
+ bytes[8] = (bytes[8] & 0x3f) | 0x80; // RFC 4122 variant
+ const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, '0')).join('');
+ return hex.slice(0, 8) + '-' + hex.slice(8, 12) + '-' + hex.slice(12, 16)
+ + '-' + hex.slice(16, 20) + '-' + hex.slice(20);
+ }
+
+ function randomId8(cryptoImpl) {
+ return randomUUID(cryptoImpl).replace(/-/g, '').slice(0, 8);
+ }
+
function createLiveBrowserSessionState({ prefix, storage, idFactory }) {
if (!prefix) throw new Error('prefix required');
const store = storage || root.localStorage;
- const makeId = idFactory || function () { return Math.random().toString(16).slice(2, 10); };
+ const makeId = idFactory || function () { return randomId8(); };
const sessionKey = prefix + '-session';
const handledKey = sessionKey + '-handled';
const scrollKey = sessionKey + '-scroll';
@@ -144,5 +176,5 @@
};
}
- root.__IMPECCABLE_LIVE_SESSION__ = { createLiveBrowserSessionState };
+ root.__IMPECCABLE_LIVE_SESSION__ = { createLiveBrowserSessionState, randomUUID, randomId8 };
})(typeof window !== 'undefined' ? window : globalThis);
diff --git a/.claude/skills/impeccable/scripts/live-browser.js b/.claude/skills/impeccable/scripts/live-browser.js
index f706898e4..75abdf0c0 100644
--- a/.claude/skills/impeccable/scripts/live-browser.js
+++ b/.claude/skills/impeccable/scripts/live-browser.js
@@ -61,11 +61,19 @@
const IMPECCABLE_COMMAND = (window.__IMPECCABLE_COMMAND_PREFIX__ || '/') + 'impeccable';
const PICK_CURSOR_STYLE_ID = PREFIX + '-pick-cursor-style';
const MANUAL_APPLY_STATE_TTL_MS = 15 * 60 * 1000;
- const sessionState = window.__IMPECCABLE_LIVE_SESSION__?.createLiveBrowserSessionState({
- prefix: PREFIX,
- storage: localStorage,
- idFactory: () => crypto.randomUUID().replace(/-/g, '').slice(0, 8),
- });
+ // No idFactory: the session helper's default works on plain-HTTP origins,
+ // where the secure-context-only randomUUID does not exist (issue #1055).
+ let sessionState = null;
+ try {
+ sessionState = window.__IMPECCABLE_LIVE_SESSION__?.createLiveBrowserSessionState({
+ prefix: PREFIX,
+ storage: localStorage,
+ });
+ } catch (err) {
+ console.error('[impeccable] Live mode could not create its session state.', err);
+ window.__IMPECCABLE_LIVE_INIT__ = false; // let a later injection retry
+ return;
+ }
if (!sessionState) {
console.error('[impeccable] live-browser-session.js was not loaded. Live mode cannot start safely.');
window.__IMPECCABLE_LIVE_INIT__ = false;
@@ -293,6 +301,7 @@
liveUiRoot,
uiAppend,
uiAppendToPage,
+ copyTextViaSelection,
topLayerHost,
watchModalDialogs,
cloneWithoutChrome,
@@ -13466,12 +13475,24 @@ void main() {
.replace(/'/g, '&#39;');
}
+ // navigator.clipboard exists only in secure contexts, and writeText can
+ // reject even where it exists (no focus, permission). Fall back
+ // to the DOM helpers' selection copy (execCommand), which plain-HTTP origins
+ // still allow and which stays usable under an open modal dialog.
function copyToClipboard(text) {
if (!text) return;
+ const report = (ok) => showToast(ok ? 'Copied: ' + text : 'Could not copy: ' + text);
+ let pending = null;
try {
- navigator.clipboard.writeText(text);
- showToast('Copied: ' + text);
- } catch { /* ignore */ }
+ if (navigator.clipboard && typeof navigator.clipboard.writeText === 'function') {
+ pending = navigator.clipboard.writeText(text);
+ }
+ } catch { pending = null; }
+ if (pending && typeof pending.then === 'function') {
+ pending.then(() => report(true), () => report(copyTextViaSelection(text)));
+ return;
+ }
+ report(copyTextViaSelection(text));
}
//
diff --git a/.cursor/skills/impeccable/reference/typeset.md b/.cursor/skills/impeccable/reference/typeset.md
index 9802aa84b..e03cb0547 100644
--- a/.cursor/skills/impeccable/reference/typeset.md
+++ b/.cursor/skills/impeccable/reference/typeset.md
@@ -56,6 +56,16 @@ Use the fewest roles and families that make the hierarchy unmistakable. Combine
Do not make type decorative at the expense of comprehension, or introduce a second family without a clear role it alone can perform.
+## Line breaks
+
+After Matthew Butterick's *Practical Typography*, paraphrased; where his numbers differ from these, these stand.
+
+- Set `text-wrap: balance` on headings and short centered blocks, and `text-wrap: pretty` on body copy. Both are progressive: a browser that ignores them keeps its default wrap.
+- `pretty` pulls a word down beside a lone last word. It does not fill the last line, and a two-word tail is fine.
+- In a column too narrow for either to help, edit the copy or widen the column.
+- Break a heading by hand only between phrases, and check the break at every width the heading renders at. A hard break that lands mid-line on a phone is worse than the default wrap.
+- An uneven break can carry meaning: a headline that lands on one word for weight, a poster line, a pull quote. Make it deliberate with a hard break or a wrap set on that element, and keep it rare. The detector's `straggler` and `unbalanced-heading` findings are advisory for this reason; say which breaks are intended.
+
## Verify
- Primary, secondary, body, and metadata roles are recognizable without reading the copy.
diff --git a/.cursor/skills/impeccable/scripts/live-browser-dom.js b/.cursor/skills/impeccable/scripts/live-browser-dom.js
index 864694498..ef1ca8928 100644
--- a/.cursor/skills/impeccable/scripts/live-browser-dom.js
+++ b/.cursor/skills/impeccable/scripts/live-browser-dom.js
@@ -85,7 +85,16 @@
}
function id8() {
- if (crypto?.randomUUID) return crypto.randomUUID().replace(/-/g, '').slice(0, 8);
+ // randomUUID is secure-context only (issue #1055); getRandomValues is not.
+ try {
+ if (typeof crypto?.randomUUID === 'function') return crypto.randomUUID().replace(/-/g, '').slice(0, 8);
+ } catch { /* fall through */ }
+ try {
+ if (typeof crypto?.getRandomValues === 'function') {
+ const bytes = crypto.getRandomValues(new Uint8Array(4));
+ return Array.from(bytes, (b) => b.toString(16).padStart(2, '0')).join('');
+ }
+ } catch { /* fall through */ }
return (Math.random().toString(16).slice(2) + Date.now().toString(16)).slice(0, 8);
}
@@ -196,6 +205,35 @@
return el;
}
+ // Copy text through a selected textarea and execCommand, for origins where
+ // navigator.clipboard is missing or refused (plain HTTP, issue #1055).
+ // The textarea mounts like any page-level chrome, so while a modal
+ // <dialog> is open it sits in that dialog's top-layer host: on <body> it
+ // would be inert, and inert text cannot be selected or copied.
+ function copyTextViaSelection(text) {
+ let ta = null;
+ const previous = activeElementDeep();
+ try {
+ ta = doc.createElement('textarea');
+ ta.id = prefix + '-clipboard';
+ ta.value = text;
+ ta.setAttribute('readonly', '');
+ ta.setAttribute('aria-hidden', 'true');
+ ta.tabIndex = -1;
+ ta.style.cssText = 'position:fixed;top:0;left:0;width:1px;height:1px;opacity:0;pointer-events:none;';
+ uiAppendToPage(ta);
+ ta.select();
+ return doc.execCommand('copy');
+ } catch {
+ return false;
+ } finally {
+ ta?.remove();
+ if (previous && previous !== activeElementDeep() && typeof previous.focus === 'function') {
+ try { previous.focus({ preventScroll: true }); } catch { /* best effort */ }
+ }
+ }
+ }
+
function uiAppend(el) {
const uiRoot = liveUiRoot();
if (uiRoot === doc.body) return uiAppendToPage(el);
@@ -263,6 +301,7 @@
liveUiRoot,
uiAppend,
uiAppendToPage,
+ copyTextViaSelection,
topLayerHost,
watchModalDialogs,
cloneWithoutChrome,
diff --git a/.cursor/skills/impeccable/scripts/live-browser-session.js b/.cursor/skills/impeccable/scripts/live-browser-session.js
index ad9cdf008..388d2c2f9 100644
--- a/.cursor/skills/impeccable/scripts/live-browser-session.js
+++ b/.cursor/skills/impeccable/scripts/live-browser-session.js
@@ -8,10 +8,42 @@
(function (root) {
'use strict';
+ // crypto.randomUUID() exists only in secure contexts (HTTPS, localhost), so a
+ // dev site on a LAN IP, a Tailscale address, or a custom hostname over plain
+ // HTTP has no randomUUID at all (issue #1055). getRandomValues() is available
+ // in every context; Math.random() covers runtimes with no crypto. Live ids
+ // only have to be unique per session, not unguessable.
+ function randomUUID(cryptoImpl) {
+ const c = cryptoImpl === undefined ? root.crypto : cryptoImpl;
+ try {
+ if (c && typeof c.randomUUID === 'function') return c.randomUUID();
+ } catch { /* fall through to getRandomValues */ }
+ const bytes = new Uint8Array(16);
+ let filled = false;
+ try {
+ if (c && typeof c.getRandomValues === 'function') {
+ c.getRandomValues(bytes);
+ filled = true;
+ }
+ } catch { /* fall through to Math.random */ }
+ if (!filled) {
+ for (let i = 0; i < 16; i++) bytes[i] = Math.floor(Math.random() * 256);
+ }
+ bytes[6] = (bytes[6] & 0x0f) | 0x40; // version 4
+ bytes[8] = (bytes[8] & 0x3f) | 0x80; // RFC 4122 variant
+ const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, '0')).join('');
+ return hex.slice(0, 8) + '-' + hex.slice(8, 12) + '-' + hex.slice(12, 16)
+ + '-' + hex.slice(16, 20) + '-' + hex.slice(20);
+ }
+
+ function randomId8(cryptoImpl) {
+ return randomUUID(cryptoImpl).replace(/-/g, '').slice(0, 8);
+ }
+
function createLiveBrowserSessionState({ prefix, storage, idFactory }) {
if (!prefix) throw new Error('prefix required');
const store = storage || root.localStorage;
- const makeId = idFactory || function () { return Math.random().toString(16).slice(2, 10); };
+ const makeId = idFactory || function () { return randomId8(); };
const sessionKey = prefix + '-session';
const handledKey = sessionKey + '-handled';
const scrollKey = sessionKey + '-scroll';
@@ -144,5 +176,5 @@
};
}
- root.__IMPECCABLE_LIVE_SESSION__ = { createLiveBrowserSessionState };
+ root.__IMPECCABLE_LIVE_SESSION__ = { createLiveBrowserSessionState, randomUUID, randomId8 };
})(typeof window !== 'undefined' ? window : globalThis);
diff --git a/.cursor/skills/impeccable/scripts/live-browser.js b/.cursor/skills/impeccable/scripts/live-browser.js
index f706898e4..75abdf0c0 100644
--- a/.cursor/skills/impeccable/scripts/live-browser.js
+++ b/.cursor/skills/impeccable/scripts/live-browser.js
@@ -61,11 +61,19 @@
const IMPECCABLE_COMMAND = (window.__IMPECCABLE_COMMAND_PREFIX__ || '/') + 'impeccable';
const PICK_CURSOR_STYLE_ID = PREFIX + '-pick-cursor-style';
const MANUAL_APPLY_STATE_TTL_MS = 15 * 60 * 1000;
- const sessionState = window.__IMPECCABLE_LIVE_SESSION__?.createLiveBrowserSessionState({
- prefix: PREFIX,
- storage: localStorage,
- idFactory: () => crypto.randomUUID().replace(/-/g, '').slice(0, 8),
- });
+ // No idFactory: the session helper's default works on plain-HTTP origins,
+ // where the secure-context-only randomUUID does not exist (issue #1055).
+ let sessionState = null;
+ try {
+ sessionState = window.__IMPECCABLE_LIVE_SESSION__?.createLiveBrowserSessionState({
+ prefix: PREFIX,
+ storage: localStorage,
+ });
+ } catch (err) {
+ console.error('[impeccable] Live mode could not create its session state.', err);
+ window.__IMPECCABLE_LIVE_INIT__ = false; // let a later injection retry
+ return;
+ }
if (!sessionState) {
console.error('[impeccable] live-browser-session.js was not loaded. Live mode cannot start safely.');
window.__IMPECCABLE_LIVE_INIT__ = false;
@@ -293,6 +301,7 @@
liveUiRoot,
uiAppend,
uiAppendToPage,
+ copyTextViaSelection,
topLayerHost,
watchModalDialogs,
cloneWithoutChrome,
@@ -13466,12 +13475,24 @@ void main() {
.replace(/'/g, '&#39;');
}
+ // navigator.clipboard exists only in secure contexts, and writeText can
+ // reject even where it exists (no focus, permission). Fall back
+ // to the DOM helpers' selection copy (execCommand), which plain-HTTP origins
+ // still allow and which stays usable under an open modal dialog.
function copyToClipboard(text) {
if (!text) return;
+ const report = (ok) => showToast(ok ? 'Copied: ' + text : 'Could not copy: ' + text);
+ let pending = null;
try {
- navigator.clipboard.writeText(text);
- showToast('Copied: ' + text);
- } catch { /* ignore */ }
+ if (navigator.clipboard && typeof navigator.clipboard.writeText === 'function') {
+ pending = navigator.clipboard.writeText(text);
+ }
+ } catch { pending = null; }
+ if (pending && typeof pending.then === 'function') {
+ pending.then(() => report(true), () => report(copyTextViaSelection(text)));
+ return;
+ }
+ report(copyTextViaSelection(text));
}
//
diff --git a/.dsh/skills/impeccable/reference/typeset.md b/.dsh/skills/impeccable/reference/typeset.md
index 96171996f..15ae997fe 100644
--- a/.dsh/skills/impeccable/reference/typeset.md
+++ b/.dsh/skills/impeccable/reference/typeset.md
@@ -56,6 +56,16 @@ Use the fewest roles and families that make the hierarchy unmistakable. Combine
Do not make type decorative at the expense of comprehension, or introduce a second family without a clear role it alone can perform.
+## Line breaks
+
+After Matthew Butterick's *Practical Typography*, paraphrased; where his numbers differ from these, these stand.
+
+- Set `text-wrap: balance` on headings and short centered blocks, and `text-wrap: pretty` on body copy. Both are progressive: a browser that ignores them keeps its default wrap.
+- `pretty` pulls a word down beside a lone last word. It does not fill the last line, and a two-word tail is fine.
+- In a column too narrow for either to help, edit the copy or widen the column.
+- Break a heading by hand only between phrases, and check the break at every width the heading renders at. A hard break that lands mid-line on a phone is worse than the default wrap.
+- An uneven break can carry meaning: a headline that lands on one word for weight, a poster line, a pull quote. Make it deliberate with a hard break or a wrap set on that element, and keep it rare. The detector's `straggler` and `unbalanced-heading` findings are advisory for this reason; say which breaks are intended.
+
## Verify
- Primary, secondary, body, and metadata roles are recognizable without reading the copy.
diff --git a/.dsh/skills/impeccable/scripts/live-browser-dom.js b/.dsh/skills/impeccable/scripts/live-browser-dom.js
index 864694498..ef1ca8928 100644
--- a/.dsh/skills/impeccable/scripts/live-browser-dom.js
+++ b/.dsh/skills/impeccable/scripts/live-browser-dom.js
@@ -85,7 +85,16 @@
}
function id8() {
- if (crypto?.randomUUID) return crypto.randomUUID().replace(/-/g, '').slice(0, 8);
+ // randomUUID is secure-context only (issue #1055); getRandomValues is not.
+ try {
+ if (typeof crypto?.randomUUID === 'function') return crypto.randomUUID().replace(/-/g, '').slice(0, 8);
+ } catch { /* fall through */ }
+ try {
+ if (typeof crypto?.getRandomValues === 'function') {
+ const bytes = crypto.getRandomValues(new Uint8Array(4));
+ return Array.from(bytes, (b) => b.toString(16).padStart(2, '0')).join('');
+ }
+ } catch { /* fall through */ }
return (Math.random().toString(16).slice(2) + Date.now().toString(16)).slice(0, 8);
}
@@ -196,6 +205,35 @@
return el;
}
+ // Copy text through a selected textarea and execCommand, for origins where
+ // navigator.clipboard is missing or refused (plain HTTP, issue #1055).
+ // The textarea mounts like any page-level chrome, so while a modal
+ // <dialog> is open it sits in that dialog's top-layer host: on <body> it
+ // would be inert, and inert text cannot be selected or copied.
+ function copyTextViaSelection(text) {
+ let ta = null;
+ const previous = activeElementDeep();
+ try {
+ ta = doc.createElement('textarea');
+ ta.id = prefix + '-clipboard';
+ ta.value = text;
+ ta.setAttribute('readonly', '');
+ ta.setAttribute('aria-hidden', 'true');
+ ta.tabIndex = -1;
+ ta.style.cssText = 'position:fixed;top:0;left:0;width:1px;height:1px;opacity:0;pointer-events:none;';
+ uiAppendToPage(ta);
+ ta.select();
+ return doc.execCommand('copy');
+ } catch {
+ return false;
+ } finally {
+ ta?.remove();
+ if (previous && previous !== activeElementDeep() && typeof previous.focus === 'function') {
+ try { previous.focus({ preventScroll: true }); } catch { /* best effort */ }
+ }
+ }
+ }
+
function uiAppend(el) {
const uiRoot = liveUiRoot();
if (uiRoot === doc.body) return uiAppendToPage(el);
@@ -263,6 +301,7 @@
liveUiRoot,
uiAppend,
uiAppendToPage,
+ copyTextViaSelection,
topLayerHost,
watchModalDialogs,
cloneWithoutChrome,
diff --git a/.dsh/skills/impeccable/scripts/live-browser-session.js b/.dsh/skills/impeccable/scripts/live-browser-session.js
index ad9cdf008..388d2c2f9 100644
--- a/.dsh/skills/impeccable/scripts/live-browser-session.js
+++ b/.dsh/skills/impeccable/scripts/live-browser-session.js
@@ -8,10 +8,42 @@
(function (root) {
'use strict';
+ // crypto.randomUUID() exists only in secure contexts (HTTPS, localhost), so a
+ // dev site on a LAN IP, a Tailscale address, or a custom hostname over plain
+ // HTTP has no randomUUID at all (issue #1055). getRandomValues() is available
+ // in every context; Math.random() covers runtimes with no crypto. Live ids
+ // only have to be unique per session, not unguessable.
+ function randomUUID(cryptoImpl) {
+ const c = cryptoImpl === undefined ? root.crypto : cryptoImpl;
+ try {
+ if (c && typeof c.randomUUID === 'function') return c.randomUUID();
+ } catch { /* fall through to getRandomValues */ }
+ const bytes = new Uint8Array(16);
+ let filled = false;
+ try {
+ if (c && typeof c.getRandomValues === 'function') {
+ c.getRandomValues(bytes);
+ filled = true;
+ }
+ } catch { /* fall through to Math.random */ }
+ if (!filled) {
+ for (let i = 0; i < 16; i++) bytes[i] = Math.floor(Math.random() * 256);
+ }
+ bytes[6] = (bytes[6] & 0x0f) | 0x40; // version 4
+ bytes[8] = (bytes[8] & 0x3f) | 0x80; // RFC 4122 variant
+ const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, '0')).join('');
+ return hex.slice(0, 8) + '-' + hex.slice(8, 12) + '-' + hex.slice(12, 16)
+ + '-' + hex.slice(16, 20) + '-' + hex.slice(20);
+ }
+
+ function randomId8(cryptoImpl) {
+ return randomUUID(cryptoImpl).replace(/-/g, '').slice(0, 8);
+ }
+
function createLiveBrowserSessionState({ prefix, storage, idFactory }) {
if (!prefix) throw new Error('prefix required');
const store = storage || root.localStorage;
- const makeId = idFactory || function () { return Math.random().toString(16).slice(2, 10); };
+ const makeId = idFactory || function () { return randomId8(); };
const sessionKey = prefix + '-session';
const handledKey = sessionKey + '-handled';
const scrollKey = sessionKey + '-scroll';
@@ -144,5 +176,5 @@
};
}
- root.__IMPECCABLE_LIVE_SESSION__ = { createLiveBrowserSessionState };
+ root.__IMPECCABLE_LIVE_SESSION__ = { createLiveBrowserSessionState, randomUUID, randomId8 };
})(typeof window !== 'undefined' ? window : globalThis);
diff --git a/.dsh/skills/impeccable/scripts/live-browser.js b/.dsh/skills/impeccable/scripts/live-browser.js
index f706898e4..75abdf0c0 100644
--- a/.dsh/skills/impeccable/scripts/live-browser.js
+++ b/.dsh/skills/impeccable/scripts/live-browser.js
@@ -61,11 +61,19 @@
const IMPECCABLE_COMMAND = (window.__IMPECCABLE_COMMAND_PREFIX__ || '/') + 'impeccable';
const PICK_CURSOR_STYLE_ID = PREFIX + '-pick-cursor-style';
const MANUAL_APPLY_STATE_TTL_MS = 15 * 60 * 1000;
- const sessionState = window.__IMPECCABLE_LIVE_SESSION__?.createLiveBrowserSessionState({
- prefix: PREFIX,
- storage: localStorage,
- idFactory: () => crypto.randomUUID().replace(/-/g, '').slice(0, 8),
- });
+ // No idFactory: the session helper's default works on plain-HTTP origins,
+ // where the secure-context-only randomUUID does not exist (issue #1055).
+ let sessionState = null;
+ try {
+ sessionState = window.__IMPECCABLE_LIVE_SESSION__?.createLiveBrowserSessionState({
+ prefix: PREFIX,
+ storage: localStorage,
+ });
+ } catch (err) {
+ console.error('[impeccable] Live mode could not create its session state.', err);
+ window.__IMPECCABLE_LIVE_INIT__ = false; // let a later injection retry
+ return;
+ }
if (!sessionState) {
console.error('[impeccable] live-browser-session.js was not loaded. Live mode cannot start safely.');
window.__IMPECCABLE_LIVE_INIT__ = false;
@@ -293,6 +301,7 @@
liveUiRoot,
uiAppend,
uiAppendToPage,
+ copyTextViaSelection,
topLayerHost,
watchModalDialogs,
cloneWithoutChrome,
@@ -13466,12 +13475,24 @@ void main() {
.replace(/'/g, '&#39;');
}
+ // navigator.clipboard exists only in secure contexts, and writeText can
+ // reject even where it exists (no focus, permission). Fall back
+ // to the DOM helpers' selection copy (execCommand), which plain-HTTP origins
+ // still allow and which stays usable under an open modal dialog.
function copyToClipboard(text) {
if (!text) return;
+ const report = (ok) => showToast(ok ? 'Copied: ' + text : 'Could not copy: ' + text);
+ let pending = null;
try {
- navigator.clipboard.writeText(text);
- showToast('Copied: ' + text);
- } catch { /* ignore */ }
+ if (navigator.clipboard && typeof navigator.clipboard.writeText === 'function') {
+ pending = navigator.clipboard.writeText(text);
+ }
+ } catch { pending = null; }
+ if (pending && typeof pending.then === 'function') {
+ pending.then(() => report(true), () => report(copyTextViaSelection(text)));
+ return;
+ }
+ report(copyTextViaSelection(text));
}
//
diff --git a/.gemini/skills/impeccable/reference/typeset.md b/.gemini/skills/impeccable/reference/typeset.md
index 723e8a586..b1ae1fb45 100644
--- a/.gemini/skills/impeccable/reference/typeset.md
+++ b/.gemini/skills/impeccable/reference/typeset.md
@@ -56,6 +56,16 @@ Use the fewest roles and families that make the hierarchy unmistakable. Combine
Do not make type decorative at the expense of comprehension, or introduce a second family without a clear role it alone can perform.
+## Line breaks
+
+After Matthew Butterick's *Practical Typography*, paraphrased; where his numbers differ from these, these stand.
+
+- Set `text-wrap: balance` on headings and short centered blocks, and `text-wrap: pretty` on body copy. Both are progressive: a browser that ignores them keeps its default wrap.
+- `pretty` pulls a word down beside a lone last word. It does not fill the last line, and a two-word tail is fine.
+- In a column too narrow for either to help, edit the copy or widen the column.
+- Break a heading by hand only between phrases, and check the break at every width the heading renders at. A hard break that lands mid-line on a phone is worse than the default wrap.
+- An uneven break can carry meaning: a headline that lands on one word for weight, a poster line, a pull quote. Make it deliberate with a hard break or a wrap set on that element, and keep it rare. The detector's `straggler` and `unbalanced-heading` findings are advisory for this reason; say which breaks are intended.
+
## Verify
- Primary, secondary, body, and metadata roles are recognizable without reading the copy.
diff --git a/.gemini/skills/impeccable/scripts/live-browser-dom.js b/.gemini/skills/impeccable/scripts/live-browser-dom.js
index 864694498..ef1ca8928 100644
--- a/.gemini/skills/impeccable/scripts/live-browser-dom.js
+++ b/.gemini/skills/impeccable/scripts/live-browser-dom.js
@@ -85,7 +85,16 @@
}
function id8() {
- if (crypto?.randomUUID) return crypto.randomUUID().replace(/-/g, '').slice(0, 8);
+ // randomUUID is secure-context only (issue #1055); getRandomValues is not.
+ try {
+ if (typeof crypto?.randomUUID === 'function') return crypto.randomUUID().replace(/-/g, '').slice(0, 8);
+ } catch { /* fall through */ }
+ try {
+ if (typeof crypto?.getRandomValues === 'function') {
+ const bytes = crypto.getRandomValues(new Uint8Array(4));
+ return Array.from(bytes, (b) => b.toString(16).padStart(2, '0')).join('');
+ }
+ } catch { /* fall through */ }
return (Math.random().toString(16).slice(2) + Date.now().toString(16)).slice(0, 8);
}
@@ -196,6 +205,35 @@
return el;
}
+ // Copy text through a selected textarea and execCommand, for origins where
+ // navigator.clipboard is missing or refused (plain HTTP, issue #1055).
+ // The textarea mounts like any page-level chrome, so while a modal
+ // <dialog> is open it sits in that dialog's top-layer host: on <body> it
+ // would be inert, and inert text cannot be selected or copied.
+ function copyTextViaSelection(text) {
+ let ta = null;
+ const previous = activeElementDeep();
+ try {
+ ta = doc.createElement('textarea');
+ ta.id = prefix + '-clipboard';
+ ta.value = text;
+ ta.setAttribute('readonly', '');
+ ta.setAttribute('aria-hidden', 'true');
+ ta.tabIndex = -1;
+ ta.style.cssText = 'position:fixed;top:0;left:0;width:1px;height:1px;opacity:0;pointer-events:none;';
+ uiAppendToPage(ta);
+ ta.select();
+ return doc.execCommand('copy');
+ } catch {
+ return false;
+ } finally {
+ ta?.remove();
+ if (previous && previous !== activeElementDeep() && typeof previous.focus === 'function') {
+ try { previous.focus({ preventScroll: true }); } catch { /* best effort */ }
+ }
+ }
+ }
+
function uiAppend(el) {
const uiRoot = liveUiRoot();
if (uiRoot === doc.body) return uiAppendToPage(el);
@@ -263,6 +301,7 @@
liveUiRoot,
uiAppend,
uiAppendToPage,
+ copyTextViaSelection,
topLayerHost,
watchModalDialogs,
cloneWithoutChrome,
diff --git a/.gemini/skills/impeccable/scripts/live-browser-session.js b/.gemini/skills/impeccable/scripts/live-browser-session.js
index ad9cdf008..388d2c2f9 100644
--- a/.gemini/skills/impeccable/scripts/live-browser-session.js
+++ b/.gemini/skills/impeccable/scripts/live-browser-session.js
@@ -8,10 +8,42 @@
(function (root) {
'use strict';
+ // crypto.randomUUID() exists only in secure contexts (HTTPS, localhost), so a
+ // dev site on a LAN IP, a Tailscale address, or a custom hostname over plain
+ // HTTP has no randomUUID at all (issue #1055). getRandomValues() is available
+ // in every context; Math.random() covers runtimes with no crypto. Live ids
+ // only have to be unique per session, not unguessable.
+ function randomUUID(cryptoImpl) {
+ const c = cryptoImpl === undefined ? root.crypto : cryptoImpl;
+ try {
+ if (c && typeof c.randomUUID === 'function') return c.randomUUID();
+ } catch { /* fall through to getRandomValues */ }
+ const bytes = new Uint8Array(16);
+ let filled = false;
+ try {
+ if (c && typeof c.getRandomValues === 'function') {
+ c.getRandomValues(bytes);
+ filled = true;
+ }
+ } catch { /* fall through to Math.random */ }
+ if (!filled) {
+ for (let i = 0; i < 16; i++) bytes[i] = Math.floor(Math.random() * 256);
+ }
+ bytes[6] = (bytes[6] & 0x0f) | 0x40; // version 4
+ bytes[8] = (bytes[8] & 0x3f) | 0x80; // RFC 4122 variant
+ const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, '0')).join('');
+ return hex.slice(0, 8) + '-' + hex.slice(8, 12) + '-' + hex.slice(12, 16)
+ + '-' + hex.slice(16, 20) + '-' + hex.slice(20);
+ }
+
+ function randomId8(cryptoImpl) {
+ return randomUUID(cryptoImpl).replace(/-/g, '').slice(0, 8);
+ }
+
function createLiveBrowserSessionState({ prefix, storage, idFactory }) {
if (!prefix) throw new Error('prefix required');
const store = storage || root.localStorage;
- const makeId = idFactory || function () { return Math.random().toString(16).slice(2, 10); };
+ const makeId = idFactory || function () { return randomId8(); };
const sessionKey = prefix + '-session';
const handledKey = sessionKey + '-handled';
const scrollKey = sessionKey + '-scroll';
@@ -144,5 +176,5 @@
};
}
- root.__IMPECCABLE_LIVE_SESSION__ = { createLiveBrowserSessionState };
+ root.__IMPECCABLE_LIVE_SESSION__ = { createLiveBrowserSessionState, randomUUID, randomId8 };
})(typeof window !== 'undefined' ? window : globalThis);
diff --git a/.gemini/skills/impeccable/scripts/live-browser.js b/.gemini/skills/impeccable/scripts/live-browser.js
index f706898e4..75abdf0c0 100644
--- a/.gemini/skills/impeccable/scripts/live-browser.js
+++ b/.gemini/skills/impeccable/scripts/live-browser.js
@@ -61,11 +61,19 @@
const IMPECCABLE_COMMAND = (window.__IMPECCABLE_COMMAND_PREFIX__ || '/') + 'impeccable';
const PICK_CURSOR_STYLE_ID = PREFIX + '-pick-cursor-style';
const MANUAL_APPLY_STATE_TTL_MS = 15 * 60 * 1000;
- const sessionState = window.__IMPECCABLE_LIVE_SESSION__?.createLiveBrowserSessionState({
- prefix: PREFIX,
- storage: localStorage,
- idFactory: () => crypto.randomUUID().replace(/-/g, '').slice(0, 8),
- });
+ // No idFactory: the session helper's default works on plain-HTTP origins,
+ // where the secure-context-only randomUUID does not exist (issue #1055).
+ let sessionState = null;
+ try {
+ sessionState = window.__IMPECCABLE_LIVE_SESSION__?.createLiveBrowserSessionState({
+ prefix: PREFIX,
+ storage: localStorage,
+ });
+ } catch (err) {
+ console.error('[impeccable] Live mode could not create its session state.', err);
+ window.__IMPECCABLE_LIVE_INIT__ = false; // let a later injection retry
+ return;
+ }
if (!sessionState) {
console.error('[impeccable] live-browser-session.js was not loaded. Live mode cannot start safely.');
window.__IMPECCABLE_LIVE_INIT__ = false;
@@ -293,6 +301,7 @@
liveUiRoot,
uiAppend,
uiAppendToPage,
+ copyTextViaSelection,
topLayerHost,
watchModalDialogs,
cloneWithoutChrome,
@@ -13466,12 +13475,24 @@ void main() {
.replace(/'/g, '&#39;');
}
+ // navigator.clipboard exists only in secure contexts, and writeText can
+ // reject even where it exists (no focus, permission). Fall back
+ // to the DOM helpers' selection copy (execCommand), which plain-HTTP origins
+ // still allow and which stays usable under an open modal dialog.
function copyToClipboard(text) {
if (!text) return;
+ const report = (ok) => showToast(ok ? 'Copied: ' + text : 'Could not copy: ' + text);
+ let pending = null;
try {
- navigator.clipboard.writeText(text);
- showToast('Copied: ' + text);
- } catch { /* ignore */ }
+ if (navigator.clipboard && typeof navigator.clipboard.writeText === 'function') {
+ pending = navigator.clipboard.writeText(text);
+ }
+ } catch { pending = null; }
+ if (pending && typeof pending.then === 'function') {
+ pending.then(() => report(true), () => report(copyTextViaSelection(text)));
+ return;
+ }
+ report(copyTextViaSelection(text));
}
//
diff --git a/.github/skills/impeccable/reference/typeset.md b/.github/skills/impeccable/reference/typeset.md
index 11c57ae99..26b2ef8a6 100644
--- a/.github/skills/impeccable/reference/typeset.md
+++ b/.github/skills/impeccable/reference/typeset.md
@@ -56,6 +56,16 @@ Use the fewest roles and families that make the hierarchy unmistakable. Combine
Do not make type decorative at the expense of comprehension, or introduce a second family without a clear role it alone can perform.
+## Line breaks
+
+After Matthew Butterick's *Practical Typography*, paraphrased; where his numbers differ from these, these stand.
+
+- Set `text-wrap: balance` on headings and short centered blocks, and `text-wrap: pretty` on body copy. Both are progressive: a browser that ignores them keeps its default wrap.
+- `pretty` pulls a word down beside a lone last word. It does not fill the last line, and a two-word tail is fine.
+- In a column too narrow for either to help, edit the copy or widen the column.
+- Break a heading by hand only between phrases, and check the break at every width the heading renders at. A hard break that lands mid-line on a phone is worse than the default wrap.
+- An uneven break can carry meaning: a headline that lands on one word for weight, a poster line, a pull quote. Make it deliberate with a hard break or a wrap set on that element, and keep it rare. The detector's `straggler` and `unbalanced-heading` findings are advisory for this reason; say which breaks are intended.
+
## Verify
- Primary, secondary, body, and metadata roles are recognizable without reading the copy.
diff --git a/.github/skills/impeccable/scripts/live-browser-dom.js b/.github/skills/impeccable/scripts/live-browser-dom.js
index 864694498..ef1ca8928 100644
--- a/.github/skills/impeccable/scripts/live-browser-dom.js
+++ b/.github/skills/impeccable/scripts/live-browser-dom.js
@@ -85,7 +85,16 @@
}
function id8() {
- if (crypto?.randomUUID) return crypto.randomUUID().replace(/-/g, '').slice(0, 8);
+ // randomUUID is secure-context only (issue #1055); getRandomValues is not.
+ try {
+ if (typeof crypto?.randomUUID === 'function') return crypto.randomUUID().replace(/-/g, '').slice(0, 8);
+ } catch { /* fall through */ }
+ try {
+ if (typeof crypto?.getRandomValues === 'function') {
+ const bytes = crypto.getRandomValues(new Uint8Array(4));
+ return Array.from(bytes, (b) => b.toString(16).padStart(2, '0')).join('');
+ }
+ } catch { /* fall through */ }
return (Math.random().toString(16).slice(2) + Date.now().toString(16)).slice(0, 8);
}
@@ -196,6 +205,35 @@
return el;
}
+ // Copy text through a selected textarea and execCommand, for origins where
+ // navigator.clipboard is missing or refused (plain HTTP, issue #1055).
+ // The textarea mounts like any page-level chrome, so while a modal
+ // <dialog> is open it sits in that dialog's top-layer host: on <body> it
+ // would be inert, and inert text cannot be selected or copied.
+ function copyTextViaSelection(text) {
+ let ta = null;
+ const previous = activeElementDeep();
+ try {
+ ta = doc.createElement('textarea');
+ ta.id = prefix + '-clipboard';
+ ta.value = text;
+ ta.setAttribute('readonly', '');
+ ta.setAttribute('aria-hidden', 'true');
+ ta.tabIndex = -1;
+ ta.style.cssText = 'position:fixed;top:0;left:0;width:1px;height:1px;opacity:0;pointer-events:none;';
+ uiAppendToPage(ta);
+ ta.select();
+ return doc.execCommand('copy');
+ } catch {
+ return false;
+ } finally {
+ ta?.remove();
+ if (previous && previous !== activeElementDeep() && typeof previous.focus === 'function') {
+ try { previous.focus({ preventScroll: true }); } catch { /* best effort */ }
+ }
+ }
+ }
+
function uiAppend(el) {
const uiRoot = liveUiRoot();
if (uiRoot === doc.body) return uiAppendToPage(el);
@@ -263,6 +301,7 @@
liveUiRoot,
uiAppend,
uiAppendToPage,
+ copyTextViaSelection,
topLayerHost,
watchModalDialogs,
cloneWithoutChrome,
diff --git a/.github/skills/impeccable/scripts/live-browser-session.js b/.github/skills/impeccable/scripts/live-browser-session.js
index ad9cdf008..388d2c2f9 100644
--- a/.github/skills/impeccable/scripts/live-browser-session.js
+++ b/.github/skills/impeccable/scripts/live-browser-session.js
@@ -8,10 +8,42 @@
(function (root) {
'use strict';
+ // crypto.randomUUID() exists only in secure contexts (HTTPS, localhost), so a
+ // dev site on a LAN IP, a Tailscale address, or a custom hostname over plain
+ // HTTP has no randomUUID at all (issue #1055). getRandomValues() is available
+ // in every context; Math.random() covers runtimes with no crypto. Live ids
+ // only have to be unique per session, not unguessable.
+ function randomUUID(cryptoImpl) {
+ const c = cryptoImpl === undefined ? root.crypto : cryptoImpl;
+ try {
+ if (c && typeof c.randomUUID === 'function') return c.randomUUID();
+ } catch { /* fall through to getRandomValues */ }
+ const bytes = new Uint8Array(16);
+ let filled = false;
+ try {
+ if (c && typeof c.getRandomValues === 'function') {
+ c.getRandomValues(bytes);
+ filled = true;
+ }
+ } catch { /* fall through to Math.random */ }
+ if (!filled) {
+ for (let i = 0; i < 16; i++) bytes[i] = Math.floor(Math.random() * 256);
+ }
+ bytes[6] = (bytes[6] & 0x0f) | 0x40; // version 4
+ bytes[8] = (bytes[8] & 0x3f) | 0x80; // RFC 4122 variant
+ const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, '0')).join('');
+ return hex.slice(0, 8) + '-' + hex.slice(8, 12) + '-' + hex.slice(12, 16)
+ + '-' + hex.slice(16, 20) + '-' + hex.slice(20);
+ }
+
+ function randomId8(cryptoImpl) {
+ return randomUUID(cryptoImpl).replace(/-/g, '').slice(0, 8);
+ }
+
function createLiveBrowserSessionState({ prefix, storage, idFactory }) {
if (!prefix) throw new Error('prefix required');
const store = storage || root.localStorage;
- const makeId = idFactory || function () { return Math.random().toString(16).slice(2, 10); };
+ const makeId = idFactory || function () { return randomId8(); };
const sessionKey = prefix + '-session';
const handledKey = sessionKey + '-handled';
const scrollKey = sessionKey + '-scroll';
@@ -144,5 +176,5 @@
};
}
- root.__IMPECCABLE_LIVE_SESSION__ = { createLiveBrowserSessionState };
+ root.__IMPECCABLE_LIVE_SESSION__ = { createLiveBrowserSessionState, randomUUID, randomId8 };
})(typeof window !== 'undefined' ? window : globalThis);
diff --git a/.github/skills/impeccable/scripts/live-browser.js b/.github/skills/impeccable/scripts/live-browser.js
index f706898e4..75abdf0c0 100644
--- a/.github/skills/impeccable/scripts/live-browser.js
+++ b/.github/skills/impeccable/scripts/live-browser.js
@@ -61,11 +61,19 @@
const IMPECCABLE_COMMAND = (window.__IMPECCABLE_COMMAND_PREFIX__ || '/') + 'impeccable';
const PICK_CURSOR_STYLE_ID = PREFIX + '-pick-cursor-style';
const MANUAL_APPLY_STATE_TTL_MS = 15 * 60 * 1000;
- const sessionState = window.__IMPECCABLE_LIVE_SESSION__?.createLiveBrowserSessionState({
- prefix: PREFIX,
- storage: localStorage,
- idFactory: () => crypto.randomUUID().replace(/-/g, '').slice(0, 8),
- });
+ // No idFactory: the session helper's default works on plain-HTTP origins,
+ // where the secure-context-only randomUUID does not exist (issue #1055).
+ let sessionState = null;
+ try {
+ sessionState = window.__IMPECCABLE_LIVE_SESSION__?.createLiveBrowserSessionState({
+ prefix: PREFIX,
+ storage: localStorage,
+ });
+ } catch (err) {
+ console.error('[impeccable] Live mode could not create its session state.', err);
+ window.__IMPECCABLE_LIVE_INIT__ = false; // let a later injection retry
+ return;
+ }
if (!sessionState) {
console.error('[impeccable] live-browser-session.js was not loaded. Live mode cannot start safely.');
window.__IMPECCABLE_LIVE_INIT__ = false;
@@ -293,6 +301,7 @@
liveUiRoot,
uiAppend,
uiAppendToPage,
+ copyTextViaSelection,
topLayerHost,
watchModalDialogs,
cloneWithoutChrome,
@@ -13466,12 +13475,24 @@ void main() {
.replace(/'/g, '&#39;');
}
+ // navigator.clipboard exists only in secure contexts, and writeText can
+ // reject even where it exists (no focus, permission). Fall back
+ // to the DOM helpers' selection copy (execCommand), which plain-HTTP origins
+ // still allow and which stays usable under an open modal dialog.
function copyToClipboard(text) {
if (!text) return;
+ const report = (ok) => showToast(ok ? 'Copied: ' + text : 'Could not copy: ' + text);
+ let pending = null;
try {
- navigator.clipboard.writeText(text);
- showToast('Copied: ' + text);
- } catch { /* ignore */ }
+ if (navigator.clipboard && typeof navigator.clipboard.writeText === 'function') {
+ pending = navigator.clipboard.writeText(text);
+ }
+ } catch { pending = null; }
+ if (pending && typeof pending.then === 'function') {
+ pending.then(() => report(true), () => report(copyTextViaSelection(text)));
+ return;
+ }
+ report(copyTextViaSelection(text));
}
//
diff --git a/.grok/skills/impeccable/reference/typeset.md b/.grok/skills/impeccable/reference/typeset.md
index b6a1e4e39..999045e11 100644
--- a/.grok/skills/impeccable/reference/typeset.md
+++ b/.grok/skills/impeccable/reference/typeset.md
@@ -56,6 +56,16 @@ Use the fewest roles and families that make the hierarchy unmistakable. Combine
Do not make type decorative at the expense of comprehension, or introduce a second family without a clear role it alone can perform.
+## Line breaks
+
+After Matthew Butterick's *Practical Typography*, paraphrased; where his numbers differ from these, these stand.
+
+- Set `text-wrap: balance` on headings and short centered blocks, and `text-wrap: pretty` on body copy. Both are progressive: a browser that ignores them keeps its default wrap.
+- `pretty` pulls a word down beside a lone last word. It does not fill the last line, and a two-word tail is fine.
+- In a column too narrow for either to help, edit the copy or widen the column.
+- Break a heading by hand only between phrases, and check the break at every width the heading renders at. A hard break that lands mid-line on a phone is worse than the default wrap.
+- An uneven break can carry meaning: a headline that lands on one word for weight, a poster line, a pull quote. Make it deliberate with a hard break or a wrap set on that element, and keep it rare. The detector's `straggler` and `unbalanced-heading` findings are advisory for this reason; say which breaks are intended.
+
## Verify
- Primary, secondary, body, and metadata roles are recognizable without reading the copy.
diff --git a/.grok/skills/impeccable/scripts/live-browser-dom.js b/.grok/skills/impeccable/scripts/live-browser-dom.js
index 864694498..ef1ca8928 100644
--- a/.grok/skills/impeccable/scripts/live-browser-dom.js
+++ b/.grok/skills/impeccable/scripts/live-browser-dom.js
@@ -85,7 +85,16 @@
}
function id8() {
- if (crypto?.randomUUID) return crypto.randomUUID().replace(/-/g, '').slice(0, 8);
+ // randomUUID is secure-context only (issue #1055); getRandomValues is not.
+ try {
+ if (typeof crypto?.randomUUID === 'function') return crypto.randomUUID().replace(/-/g, '').slice(0, 8);
+ } catch { /* fall through */ }
+ try {
+ if (typeof crypto?.getRandomValues === 'function') {
+ const bytes = crypto.getRandomValues(new Uint8Array(4));
+ return Array.from(bytes, (b) => b.toString(16).padStart(2, '0')).join('');
+ }
+ } catch { /* fall through */ }
return (Math.random().toString(16).slice(2) + Date.now().toString(16)).slice(0, 8);
}
@@ -196,6 +205,35 @@
return el;
}
+ // Copy text through a selected textarea and execCommand, for origins where
+ // navigator.clipboard is missing or refused (plain HTTP, issue #1055).
+ // The textarea mounts like any page-level chrome, so while a modal
+ // <dialog> is open it sits in that dialog's top-layer host: on <body> it
+ // would be inert, and inert text cannot be selected or copied.
+ function copyTextViaSelection(text) {
+ let ta = null;
+ const previous = activeElementDeep();
+ try {
+ ta = doc.createElement('textarea');
+ ta.id = prefix + '-clipboard';
+ ta.value = text;
+ ta.setAttribute('readonly', '');
+ ta.setAttribute('aria-hidden', 'true');
+ ta.tabIndex = -1;
+ ta.style.cssText = 'position:fixed;top:0;left:0;width:1px;height:1px;opacity:0;pointer-events:none;';
+ uiAppendToPage(ta);
+ ta.select();
+ return doc.execCommand('copy');
+ } catch {
+ return false;
+ } finally {
+ ta?.remove();
+ if (previous && previous !== activeElementDeep() && typeof previous.focus === 'function') {
+ try { previous.focus({ preventScroll: true }); } catch { /* best effort */ }
+ }
+ }
+ }
+
function uiAppend(el) {
const uiRoot = liveUiRoot();
if (uiRoot === doc.body) return uiAppendToPage(el);
@@ -263,6 +301,7 @@
liveUiRoot,
uiAppend,
uiAppendToPage,
+ copyTextViaSelection,
topLayerHost,
watchModalDialogs,
cloneWithoutChrome,
diff --git a/.grok/skills/impeccable/scripts/live-browser-session.js b/.grok/skills/impeccable/scripts/live-browser-session.js
index ad9cdf008..388d2c2f9 100644
--- a/.grok/skills/impeccable/scripts/live-browser-session.js
+++ b/.grok/skills/impeccable/scripts/live-browser-session.js
@@ -8,10 +8,42 @@
(function (root) {
'use strict';
+ // crypto.randomUUID() exists only in secure contexts (HTTPS, localhost), so a
+ // dev site on a LAN IP, a Tailscale address, or a custom hostname over plain
+ // HTTP has no randomUUID at all (issue #1055). getRandomValues() is available
+ // in every context; Math.random() covers runtimes with no crypto. Live ids
+ // only have to be unique per session, not unguessable.
+ function randomUUID(cryptoImpl) {
+ const c = cryptoImpl === undefined ? root.crypto : cryptoImpl;
+ try {
+ if (c && typeof c.randomUUID === 'function') return c.randomUUID();
+ } catch { /* fall through to getRandomValues */ }
+ const bytes = new Uint8Array(16);
+ let filled = false;
+ try {
+ if (c && typeof c.getRandomValues === 'function') {
+ c.getRandomValues(bytes);
+ filled = true;
+ }
+ } catch { /* fall through to Math.random */ }
+ if (!filled) {
+ for (let i = 0; i < 16; i++) bytes[i] = Math.floor(Math.random() * 256);
+ }
+ bytes[6] = (bytes[6] & 0x0f) | 0x40; // version 4
+ bytes[8] = (bytes[8] & 0x3f) | 0x80; // RFC 4122 variant
+ const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, '0')).join('');
+ return hex.slice(0, 8) + '-' + hex.slice(8, 12) + '-' + hex.slice(12, 16)
+ + '-' + hex.slice(16, 20) + '-' + hex.slice(20);
+ }
+
+ function randomId8(cryptoImpl) {
+ return randomUUID(cryptoImpl).replace(/-/g, '').slice(0, 8);
+ }
+
function createLiveBrowserSessionState({ prefix, storage, idFactory }) {
if (!prefix) throw new Error('prefix required');
const store = storage || root.localStorage;
- const makeId = idFactory || function () { return Math.random().toString(16).slice(2, 10); };
+ const makeId = idFactory || function () { return randomId8(); };
const sessionKey = prefix + '-session';
const handledKey = sessionKey + '-handled';
const scrollKey = sessionKey + '-scroll';
@@ -144,5 +176,5 @@
};
}
- root.__IMPECCABLE_LIVE_SESSION__ = { createLiveBrowserSessionState };
+ root.__IMPECCABLE_LIVE_SESSION__ = { createLiveBrowserSessionState, randomUUID, randomId8 };
})(typeof window !== 'undefined' ? window : globalThis);
diff --git a/.grok/skills/impeccable/scripts/live-browser.js b/.grok/skills/impeccable/scripts/live-browser.js
index f706898e4..75abdf0c0 100644
--- a/.grok/skills/impeccable/scripts/live-browser.js
+++ b/.grok/skills/impeccable/scripts/live-browser.js
@@ -61,11 +61,19 @@
const IMPECCABLE_COMMAND = (window.__IMPECCABLE_COMMAND_PREFIX__ || '/') + 'impeccable';
const PICK_CURSOR_STYLE_ID = PREFIX + '-pick-cursor-style';
const MANUAL_APPLY_STATE_TTL_MS = 15 * 60 * 1000;
- const sessionState = window.__IMPECCABLE_LIVE_SESSION__?.createLiveBrowserSessionState({
- prefix: PREFIX,
- storage: localStorage,
- idFactory: () => crypto.randomUUID().replace(/-/g, '').slice(0, 8),
- });
+ // No idFactory: the session helper's default works on plain-HTTP origins,
+ // where the secure-context-only randomUUID does not exist (issue #1055).
+ let sessionState = null;
+ try {
+ sessionState = window.__IMPECCABLE_LIVE_SESSION__?.createLiveBrowserSessionState({
+ prefix: PREFIX,
+ storage: localStorage,
+ });
+ } catch (err) {
+ console.error('[impeccable] Live mode could not create its session state.', err);
+ window.__IMPECCABLE_LIVE_INIT__ = false; // let a later injection retry
+ return;
+ }
if (!sessionState) {
console.error('[impeccable] live-browser-session.js was not loaded. Live mode cannot start safely.');
window.__IMPECCABLE_LIVE_INIT__ = false;
@@ -293,6 +301,7 @@
liveUiRoot,
uiAppend,
uiAppendToPage,
+ copyTextViaSelection,
topLayerHost,
watchModalDialogs,
cloneWithoutChrome,
@@ -13466,12 +13475,24 @@ void main() {
.replace(/'/g, '&#39;');
}
+ // navigator.clipboard exists only in secure contexts, and writeText can
+ // reject even where it exists (no focus, permission). Fall back
+ // to the DOM helpers' selection copy (execCommand), which plain-HTTP origins
+ // still allow and which stays usable under an open modal dialog.
function copyToClipboard(text) {
if (!text) return;
+ const report = (ok) => showToast(ok ? 'Copied: ' + text : 'Could not copy: ' + text);
+ let pending = null;
try {
- navigator.clipboard.writeText(text);
- showToast('Copied: ' + text);
- } catch { /* ignore */ }
+ if (navigator.clipboard && typeof navigator.clipboard.writeText === 'function') {
+ pending = navigator.clipboard.writeText(text);
+ }
+ } catch { pending = null; }
+ if (pending && typeof pending.then === 'function') {
+ pending.then(() => report(true), () => report(copyTextViaSelection(text)));
+ return;
+ }
+ report(copyTextViaSelection(text));
}
//
diff --git a/.hermes/skills/impeccable/reference/typeset.md b/.hermes/skills/impeccable/reference/typeset.md
index c9fd99d60..b7b6cfd76 100644
--- a/.hermes/skills/impeccable/reference/typeset.md
+++ b/.hermes/skills/impeccable/reference/typeset.md
@@ -56,6 +56,16 @@ Use the fewest roles and families that make the hierarchy unmistakable. Combine
Do not make type decorative at the expense of comprehension, or introduce a second family without a clear role it alone can perform.
+## Line breaks
+
+After Matthew Butterick's *Practical Typography*, paraphrased; where his numbers differ from these, these stand.
+
+- Set `text-wrap: balance` on headings and short centered blocks, and `text-wrap: pretty` on body copy. Both are progressive: a browser that ignores them keeps its default wrap.
+- `pretty` pulls a word down beside a lone last word. It does not fill the last line, and a two-word tail is fine.
+- In a column too narrow for either to help, edit the copy or widen the column.
+- Break a heading by hand only between phrases, and check the break at every width the heading renders at. A hard break that lands mid-line on a phone is worse than the default wrap.
+- An uneven break can carry meaning: a headline that lands on one word for weight, a poster line, a pull quote. Make it deliberate with a hard break or a wrap set on that element, and keep it rare. The detector's `straggler` and `unbalanced-heading` findings are advisory for this reason; say which breaks are intended.
+
## Verify
- Primary, secondary, body, and metadata roles are recognizable without reading the copy.
diff --git a/.hermes/skills/impeccable/scripts/live-browser-dom.js b/.hermes/skills/impeccable/scripts/live-browser-dom.js
index 864694498..ef1ca8928 100644
--- a/.hermes/skills/impeccable/scripts/live-browser-dom.js
+++ b/.hermes/skills/impeccable/scripts/live-browser-dom.js
@@ -85,7 +85,16 @@
}
function id8() {
- if (crypto?.randomUUID) return crypto.randomUUID().replace(/-/g, '').slice(0, 8);
+ // randomUUID is secure-context only (issue #1055); getRandomValues is not.
+ try {
+ if (typeof crypto?.randomUUID === 'function') return crypto.randomUUID().replace(/-/g, '').slice(0, 8);
+ } catch { /* fall through */ }
+ try {
+ if (typeof crypto?.getRandomValues === 'function') {
+ const bytes = crypto.getRandomValues(new Uint8Array(4));
+ return Array.from(bytes, (b) => b.toString(16).padStart(2, '0')).join('');
+ }
+ } catch { /* fall through */ }
return (Math.random().toString(16).slice(2) + Date.now().toString(16)).slice(0, 8);
}
@@ -196,6 +205,35 @@
return el;
}
+ // Copy text through a selected textarea and execCommand, for origins where
+ // navigator.clipboard is missing or refused (plain HTTP, issue #1055).
+ // The textarea mounts like any page-level chrome, so while a modal
+ // <dialog> is open it sits in that dialog's top-layer host: on <body> it
+ // would be inert, and inert text cannot be selected or copied.
+ function copyTextViaSelection(text) {
+ let ta = null;
+ const previous = activeElementDeep();
+ try {
+ ta = doc.createElement('textarea');
+ ta.id = prefix + '-clipboard';
+ ta.value = text;
+ ta.setAttribute('readonly', '');
+ ta.setAttribute('aria-hidden', 'true');
+ ta.tabIndex = -1;
+ ta.style.cssText = 'position:fixed;top:0;left:0;width:1px;height:1px;opacity:0;pointer-events:none;';
+ uiAppendToPage(ta);
+ ta.select();
+ return doc.execCommand('copy');
+ } catch {
+ return false;
+ } finally {
+ ta?.remove();
+ if (previous && previous !== activeElementDeep() && typeof previous.focus === 'function') {
+ try { previous.focus({ preventScroll: true }); } catch { /* best effort */ }
+ }
+ }
+ }
+
function uiAppend(el) {
const uiRoot = liveUiRoot();
if (uiRoot === doc.body) return uiAppendToPage(el);
@@ -263,6 +301,7 @@
liveUiRoot,
uiAppend,
uiAppendToPage,
+ copyTextViaSelection,
topLayerHost,
watchModalDialogs,
cloneWithoutChrome,
diff --git a/.hermes/skills/impeccable/scripts/live-browser-session.js b/.hermes/skills/impeccable/scripts/live-browser-session.js
index ad9cdf008..388d2c2f9 100644
--- a/.hermes/skills/impeccable/scripts/live-browser-session.js
+++ b/.hermes/skills/impeccable/scripts/live-browser-session.js
@@ -8,10 +8,42 @@
(function (root) {
'use strict';
+ // crypto.randomUUID() exists only in secure contexts (HTTPS, localhost), so a
+ // dev site on a LAN IP, a Tailscale address, or a custom hostname over plain
+ // HTTP has no randomUUID at all (issue #1055). getRandomValues() is available
+ // in every context; Math.random() covers runtimes with no crypto. Live ids
+ // only have to be unique per session, not unguessable.
+ function randomUUID(cryptoImpl) {
+ const c = cryptoImpl === undefined ? root.crypto : cryptoImpl;
+ try {
+ if (c && typeof c.randomUUID === 'function') return c.randomUUID();
+ } catch { /* fall through to getRandomValues */ }
+ const bytes = new Uint8Array(16);
+ let filled = false;
+ try {
+ if (c && typeof c.getRandomValues === 'function') {
+ c.getRandomValues(bytes);
+ filled = true;
+ }
+ } catch { /* fall through to Math.random */ }
+ if (!filled) {
+ for (let i = 0; i < 16; i++) bytes[i] = Math.floor(Math.random() * 256);
+ }
+ bytes[6] = (bytes[6] & 0x0f) | 0x40; // version 4
+ bytes[8] = (bytes[8] & 0x3f) | 0x80; // RFC 4122 variant
+ const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, '0')).join('');
+ return hex.slice(0, 8) + '-' + hex.slice(8, 12) + '-' + hex.slice(12, 16)
+ + '-' + hex.slice(16, 20) + '-' + hex.slice(20);
+ }
+
+ function randomId8(cryptoImpl) {
+ return randomUUID(cryptoImpl).replace(/-/g, '').slice(0, 8);
+ }
+
function createLiveBrowserSessionState({ prefix, storage, idFactory }) {
if (!prefix) throw new Error('prefix required');
const store = storage || root.localStorage;
- const makeId = idFactory || function () { return Math.random().toString(16).slice(2, 10); };
+ const makeId = idFactory || function () { return randomId8(); };
const sessionKey = prefix + '-session';
const handledKey = sessionKey + '-handled';
const scrollKey = sessionKey + '-scroll';
@@ -144,5 +176,5 @@
};
}
- root.__IMPECCABLE_LIVE_SESSION__ = { createLiveBrowserSessionState };
+ root.__IMPECCABLE_LIVE_SESSION__ = { createLiveBrowserSessionState, randomUUID, randomId8 };
})(typeof window !== 'undefined' ? window : globalThis);
diff --git a/.hermes/skills/impeccable/scripts/live-browser.js b/.hermes/skills/impeccable/scripts/live-browser.js
index f706898e4..75abdf0c0 100644
--- a/.hermes/skills/impeccable/scripts/live-browser.js
+++ b/.hermes/skills/impeccable/scripts/live-browser.js
@@ -61,11 +61,19 @@
const IMPECCABLE_COMMAND = (window.__IMPECCABLE_COMMAND_PREFIX__ || '/') + 'impeccable';
const PICK_CURSOR_STYLE_ID = PREFIX + '-pick-cursor-style';
const MANUAL_APPLY_STATE_TTL_MS = 15 * 60 * 1000;
- const sessionState = window.__IMPECCABLE_LIVE_SESSION__?.createLiveBrowserSessionState({
- prefix: PREFIX,
- storage: localStorage,
- idFactory: () => crypto.randomUUID().replace(/-/g, '').slice(0, 8),
- });
+ // No idFactory: the session helper's default works on plain-HTTP origins,
+ // where the secure-context-only randomUUID does not exist (issue #1055).
+ let sessionState = null;
+ try {
+ sessionState = window.__IMPECCABLE_LIVE_SESSION__?.createLiveBrowserSessionState({
+ prefix: PREFIX,
+ storage: localStorage,
+ });
+ } catch (err) {
+ console.error('[impeccable] Live mode could not create its session state.', err);
+ window.__IMPECCABLE_LIVE_INIT__ = false; // let a later injection retry
+ return;
+ }
if (!sessionState) {
console.error('[impeccable] live-browser-session.js was not loaded. Live mode cannot start safely.');
window.__IMPECCABLE_LIVE_INIT__ = false;
@@ -293,6 +301,7 @@
liveUiRoot,
uiAppend,
uiAppendToPage,
+ copyTextViaSelection,
topLayerHost,
watchModalDialogs,
cloneWithoutChrome,
@@ -13466,12 +13475,24 @@ void main() {
.replace(/'/g, '&#39;');
}
+ // navigator.clipboard exists only in secure contexts, and writeText can
+ // reject even where it exists (no focus, permission). Fall back
+ // to the DOM helpers' selection copy (execCommand), which plain-HTTP origins
+ // still allow and which stays usable under an open modal dialog.
function copyToClipboard(text) {
if (!text) return;
+ const report = (ok) => showToast(ok ? 'Copied: ' + text : 'Could not copy: ' + text);
+ let pending = null;
try {
- navigator.clipboard.writeText(text);
- showToast('Copied: ' + text);
- } catch { /* ignore */ }
+ if (navigator.clipboard && typeof navigator.clipboard.writeText === 'function') {
+ pending = navigator.clipboard.writeText(text);
+ }
+ } catch { pending = null; }
+ if (pending && typeof pending.then === 'function') {
+ pending.then(() => report(true), () => report(copyTextViaSelection(text)));
+ return;
+ }
+ report(copyTextViaSelection(text));
}
//
diff --git a/.kiro/skills/impeccable/reference/typeset.md b/.kiro/skills/impeccable/reference/typeset.md
index c50a38151..acda73770 100644
--- a/.kiro/skills/impeccable/reference/typeset.md
+++ b/.kiro/skills/impeccable/reference/typeset.md
@@ -56,6 +56,16 @@ Use the fewest roles and families that make the hierarchy unmistakable. Combine
Do not make type decorative at the expense of comprehension, or introduce a second family without a clear role it alone can perform.
+## Line breaks
+
+After Matthew Butterick's *Practical Typography*, paraphrased; where his numbers differ from these, these stand.
+
+- Set `text-wrap: balance` on headings and short centered blocks, and `text-wrap: pretty` on body copy. Both are progressive: a browser that ignores them keeps its default wrap.
+- `pretty` pulls a word down beside a lone last word. It does not fill the last line, and a two-word tail is fine.
+- In a column too narrow for either to help, edit the copy or widen the column.
+- Break a heading by hand only between phrases, and check the break at every width the heading renders at. A hard break that lands mid-line on a phone is worse than the default wrap.
+- An uneven break can carry meaning: a headline that lands on one word for weight, a poster line, a pull quote. Make it deliberate with a hard break or a wrap set on that element, and keep it rare. The detector's `straggler` and `unbalanced-heading` findings are advisory for this reason; say which breaks are intended.
+
## Verify
- Primary, secondary, body, and metadata roles are recognizable without reading the copy.
diff --git a/.kiro/skills/impeccable/scripts/live-browser-dom.js b/.kiro/skills/impeccable/scripts/live-browser-dom.js
index 864694498..ef1ca8928 100644
--- a/.kiro/skills/impeccable/scripts/live-browser-dom.js
+++ b/.kiro/skills/impeccable/scripts/live-browser-dom.js
@@ -85,7 +85,16 @@
}
function id8() {
- if (crypto?.randomUUID) return crypto.randomUUID().replace(/-/g, '').slice(0, 8);
+ // randomUUID is secure-context only (issue #1055); getRandomValues is not.
+ try {
+ if (typeof crypto?.randomUUID === 'function') return crypto.randomUUID().replace(/-/g, '').slice(0, 8);
+ } catch { /* fall through */ }
+ try {
+ if (typeof crypto?.getRandomValues === 'function') {
+ const bytes = crypto.getRandomValues(new Uint8Array(4));
+ return Array.from(bytes, (b) => b.toString(16).padStart(2, '0')).join('');
+ }
+ } catch { /* fall through */ }
return (Math.random().toString(16).slice(2) + Date.now().toString(16)).slice(0, 8);
}
@@ -196,6 +205,35 @@
return el;
}
+ // Copy text through a selected textarea and execCommand, for origins where
+ // navigator.clipboard is missing or refused (plain HTTP, issue #1055).
+ // The textarea mounts like any page-level chrome, so while a modal
+ // <dialog> is open it sits in that dialog's top-layer host: on <body> it
+ // would be inert, and inert text cannot be selected or copied.
+ function copyTextViaSelection(text) {
+ let ta = null;
+ const previous = activeElementDeep();
+ try {
+ ta = doc.createElement('textarea');
+ ta.id = prefix + '-clipboard';
+ ta.value = text;
+ ta.setAttribute('readonly', '');
+ ta.setAttribute('aria-hidden', 'true');
+ ta.tabIndex = -1;
+ ta.style.cssText = 'position:fixed;top:0;left:0;width:1px;height:1px;opacity:0;pointer-events:none;';
+ uiAppendToPage(ta);
+ ta.select();
+ return doc.execCommand('copy');
+ } catch {
+ return false;
+ } finally {
+ ta?.remove();
+ if (previous && previous !== activeElementDeep() && typeof previous.focus === 'function') {
+ try { previous.focus({ preventScroll: true }); } catch { /* best effort */ }
+ }
+ }
+ }
+
function uiAppend(el) {
const uiRoot = liveUiRoot();
if (uiRoot === doc.body) return uiAppendToPage(el);
@@ -263,6 +301,7 @@
liveUiRoot,
uiAppend,
uiAppendToPage,
+ copyTextViaSelection,
topLayerHost,
watchModalDialogs,
cloneWithoutChrome,
diff --git a/.kiro/skills/impeccable/scripts/live-browser-session.js b/.kiro/skills/impeccable/scripts/live-browser-session.js
index ad9cdf008..388d2c2f9 100644
--- a/.kiro/skills/impeccable/scripts/live-browser-session.js
+++ b/.kiro/skills/impeccable/scripts/live-browser-session.js
@@ -8,10 +8,42 @@
(function (root) {
'use strict';
+ // crypto.randomUUID() exists only in secure contexts (HTTPS, localhost), so a
+ // dev site on a LAN IP, a Tailscale address, or a custom hostname over plain
+ // HTTP has no randomUUID at all (issue #1055). getRandomValues() is available
+ // in every context; Math.random() covers runtimes with no crypto. Live ids
+ // only have to be unique per session, not unguessable.
+ function randomUUID(cryptoImpl) {
+ const c = cryptoImpl === undefined ? root.crypto : cryptoImpl;
+ try {
+ if (c && typeof c.randomUUID === 'function') return c.randomUUID();
+ } catch { /* fall through to getRandomValues */ }
+ const bytes = new Uint8Array(16);
+ let filled = false;
+ try {
+ if (c && typeof c.getRandomValues === 'function') {
+ c.getRandomValues(bytes);
+ filled = true;
+ }
+ } catch { /* fall through to Math.random */ }
+ if (!filled) {
+ for (let i = 0; i < 16; i++) bytes[i] = Math.floor(Math.random() * 256);
+ }
+ bytes[6] = (bytes[6] & 0x0f) | 0x40; // version 4
+ bytes[8] = (bytes[8] & 0x3f) | 0x80; // RFC 4122 variant
+ const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, '0')).join('');
+ return hex.slice(0, 8) + '-' + hex.slice(8, 12) + '-' + hex.slice(12, 16)
+ + '-' + hex.slice(16, 20) + '-' + hex.slice(20);
+ }
+
+ function randomId8(cryptoImpl) {
+ return randomUUID(cryptoImpl).replace(/-/g, '').slice(0, 8);
+ }
+
function createLiveBrowserSessionState({ prefix, storage, idFactory }) {
if (!prefix) throw new Error('prefix required');
const store = storage || root.localStorage;
- const makeId = idFactory || function () { return Math.random().toString(16).slice(2, 10); };
+ const makeId = idFactory || function () { return randomId8(); };
const sessionKey = prefix + '-session';
const handledKey = sessionKey + '-handled';
const scrollKey = sessionKey + '-scroll';
@@ -144,5 +176,5 @@
};
}
- root.__IMPECCABLE_LIVE_SESSION__ = { createLiveBrowserSessionState };
+ root.__IMPECCABLE_LIVE_SESSION__ = { createLiveBrowserSessionState, randomUUID, randomId8 };
})(typeof window !== 'undefined' ? window : globalThis);
diff --git a/.kiro/skills/impeccable/scripts/live-browser.js b/.kiro/skills/impeccable/scripts/live-browser.js
index f706898e4..75abdf0c0 100644
--- a/.kiro/skills/impeccable/scripts/live-browser.js
+++ b/.kiro/skills/impeccable/scripts/live-browser.js
@@ -61,11 +61,19 @@
const IMPECCABLE_COMMAND = (window.__IMPECCABLE_COMMAND_PREFIX__ || '/') + 'impeccable';
const PICK_CURSOR_STYLE_ID = PREFIX + '-pick-cursor-style';
const MANUAL_APPLY_STATE_TTL_MS = 15 * 60 * 1000;
- const sessionState = window.__IMPECCABLE_LIVE_SESSION__?.createLiveBrowserSessionState({
- prefix: PREFIX,
- storage: localStorage,
- idFactory: () => crypto.randomUUID().replace(/-/g, '').slice(0, 8),
- });
+ // No idFactory: the session helper's default works on plain-HTTP origins,
+ // where the secure-context-only randomUUID does not exist (issue #1055).
+ let sessionState = null;
+ try {
+ sessionState = window.__IMPECCABLE_LIVE_SESSION__?.createLiveBrowserSessionState({
+ prefix: PREFIX,
+ storage: localStorage,
+ });
+ } catch (err) {
+ console.error('[impeccable] Live mode could not create its session state.', err);
+ window.__IMPECCABLE_LIVE_INIT__ = false; // let a later injection retry
+ return;
+ }
if (!sessionState) {
console.error('[impeccable] live-browser-session.js was not loaded. Live mode cannot start safely.');
window.__IMPECCABLE_LIVE_INIT__ = false;
@@ -293,6 +301,7 @@
liveUiRoot,
uiAppend,
uiAppendToPage,
+ copyTextViaSelection,
topLayerHost,
watchModalDialogs,
cloneWithoutChrome,
@@ -13466,12 +13475,24 @@ void main() {
.replace(/'/g, '&#39;');
}
+ // navigator.clipboard exists only in secure contexts, and writeText can
+ // reject even where it exists (no focus, permission). Fall back
+ // to the DOM helpers' selection copy (execCommand), which plain-HTTP origins
+ // still allow and which stays usable under an open modal dialog.
function copyToClipboard(text) {
if (!text) return;
+ const report = (ok) => showToast(ok ? 'Copied: ' + text : 'Could not copy: ' + text);
+ let pending = null;
try {
- navigator.clipboard.writeText(text);
- showToast('Copied: ' + text);
- } catch { /* ignore */ }
+ if (navigator.clipboard && typeof navigator.clipboard.writeText === 'function') {
+ pending = navigator.clipboard.writeText(text);
+ }
+ } catch { pending = null; }
+ if (pending && typeof pending.then === 'function') {
+ pending.then(() => report(true), () => report(copyTextViaSelection(text)));
+ return;
+ }
+ report(copyTextViaSelection(text));
}
//
diff --git a/.omp/skills/impeccable/reference/typeset.md b/.omp/skills/impeccable/reference/typeset.md
index f66094e53..ad5f13264 100644
--- a/.omp/skills/impeccable/reference/typeset.md
+++ b/.omp/skills/impeccable/reference/typeset.md
@@ -56,6 +56,16 @@ Use the fewest roles and families that make the hierarchy unmistakable. Combine
Do not make type decorative at the expense of comprehension, or introduce a second family without a clear role it alone can perform.
+## Line breaks
+
+After Matthew Butterick's *Practical Typography*, paraphrased; where his numbers differ from these, these stand.
+
+- Set `text-wrap: balance` on headings and short centered blocks, and `text-wrap: pretty` on body copy. Both are progressive: a browser that ignores them keeps its default wrap.
+- `pretty` pulls a word down beside a lone last word. It does not fill the last line, and a two-word tail is fine.
+- In a column too narrow for either to help, edit the copy or widen the column.
+- Break a heading by hand only between phrases, and check the break at every width the heading renders at. A hard break that lands mid-line on a phone is worse than the default wrap.
+- An uneven break can carry meaning: a headline that lands on one word for weight, a poster line, a pull quote. Make it deliberate with a hard break or a wrap set on that element, and keep it rare. The detector's `straggler` and `unbalanced-heading` findings are advisory for this reason; say which breaks are intended.
+
## Verify
- Primary, secondary, body, and metadata roles are recognizable without reading the copy.
diff --git a/.omp/skills/impeccable/scripts/live-browser-dom.js b/.omp/skills/impeccable/scripts/live-browser-dom.js
index 864694498..ef1ca8928 100644
--- a/.omp/skills/impeccable/scripts/live-browser-dom.js
+++ b/.omp/skills/impeccable/scripts/live-browser-dom.js
@@ -85,7 +85,16 @@
}
function id8() {
- if (crypto?.randomUUID) return crypto.randomUUID().replace(/-/g, '').slice(0, 8);
+ // randomUUID is secure-context only (issue #1055); getRandomValues is not.
+ try {
+ if (typeof crypto?.randomUUID === 'function') return crypto.randomUUID().replace(/-/g, '').slice(0, 8);
+ } catch { /* fall through */ }
+ try {
+ if (typeof crypto?.getRandomValues === 'function') {
+ const bytes = crypto.getRandomValues(new Uint8Array(4));
+ return Array.from(bytes, (b) => b.toString(16).padStart(2, '0')).join('');
+ }
+ } catch { /* fall through */ }
return (Math.random().toString(16).slice(2) + Date.now().toString(16)).slice(0, 8);
}
@@ -196,6 +205,35 @@
return el;
}
+ // Copy text through a selected textarea and execCommand, for origins where
+ // navigator.clipboard is missing or refused (plain HTTP, issue #1055).
+ // The textarea mounts like any page-level chrome, so while a modal
+ // <dialog> is open it sits in that dialog's top-layer host: on <body> it
+ // would be inert, and inert text cannot be selected or copied.
+ function copyTextViaSelection(text) {
+ let ta = null;
+ const previous = activeElementDeep();
+ try {
+ ta = doc.createElement('textarea');
+ ta.id = prefix + '-clipboard';
+ ta.value = text;
+ ta.setAttribute('readonly', '');
+ ta.setAttribute('aria-hidden', 'true');
+ ta.tabIndex = -1;
+ ta.style.cssText = 'position:fixed;top:0;left:0;width:1px;height:1px;opacity:0;pointer-events:none;';
+ uiAppendToPage(ta);
+ ta.select();
+ return doc.execCommand('copy');
+ } catch {
+ return false;
+ } finally {
+ ta?.remove();
+ if (previous && previous !== activeElementDeep() && typeof previous.focus === 'function') {
+ try { previous.focus({ preventScroll: true }); } catch { /* best effort */ }
+ }
+ }
+ }
+
function uiAppend(el) {
const uiRoot = liveUiRoot();
if (uiRoot === doc.body) return uiAppendToPage(el);
@@ -263,6 +301,7 @@
liveUiRoot,
uiAppend,
uiAppendToPage,
+ copyTextViaSelection,
topLayerHost,
watchModalDialogs,
cloneWithoutChrome,
diff --git a/.omp/skills/impeccable/scripts/live-browser-session.js b/.omp/skills/impeccable/scripts/live-browser-session.js
index ad9cdf008..388d2c2f9 100644
--- a/.omp/skills/impeccable/scripts/live-browser-session.js
+++ b/.omp/skills/impeccable/scripts/live-browser-session.js
@@ -8,10 +8,42 @@
(function (root) {
'use strict';
+ // crypto.randomUUID() exists only in secure contexts (HTTPS, localhost), so a
+ // dev site on a LAN IP, a Tailscale address, or a custom hostname over plain
+ // HTTP has no randomUUID at all (issue #1055). getRandomValues() is available
+ // in every context; Math.random() covers runtimes with no crypto. Live ids
+ // only have to be unique per session, not unguessable.
+ function randomUUID(cryptoImpl) {
+ const c = cryptoImpl === undefined ? root.crypto : cryptoImpl;
+ try {
+ if (c && typeof c.randomUUID === 'function') return c.randomUUID();
+ } catch { /* fall through to getRandomValues */ }
+ const bytes = new Uint8Array(16);
+ let filled = false;
+ try {
+ if (c && typeof c.getRandomValues === 'function') {
+ c.getRandomValues(bytes);
+ filled = true;
+ }
+ } catch { /* fall through to Math.random */ }
+ if (!filled) {
+ for (let i = 0; i < 16; i++) bytes[i] = Math.floor(Math.random() * 256);
+ }
+ bytes[6] = (bytes[6] & 0x0f) | 0x40; // version 4
+ bytes[8] = (bytes[8] & 0x3f) | 0x80; // RFC 4122 variant
+ const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, '0')).join('');
+ return hex.slice(0, 8) + '-' + hex.slice(8, 12) + '-' + hex.slice(12, 16)
+ + '-' + hex.slice(16, 20) + '-' + hex.slice(20);
+ }
+
+ function randomId8(cryptoImpl) {
+ return randomUUID(cryptoImpl).replace(/-/g, '').slice(0, 8);
+ }
+
function createLiveBrowserSessionState({ prefix, storage, idFactory }) {
if (!prefix) throw new Error('prefix required');
const store = storage || root.localStorage;
- const makeId = idFactory || function () { return Math.random().toString(16).slice(2, 10); };
+ const makeId = idFactory || function () { return randomId8(); };
const sessionKey = prefix + '-session';
const handledKey = sessionKey + '-handled';
const scrollKey = sessionKey + '-scroll';
@@ -144,5 +176,5 @@
};
}
- root.__IMPECCABLE_LIVE_SESSION__ = { createLiveBrowserSessionState };
+ root.__IMPECCABLE_LIVE_SESSION__ = { createLiveBrowserSessionState, randomUUID, randomId8 };
})(typeof window !== 'undefined' ? window : globalThis);
diff --git a/.omp/skills/impeccable/scripts/live-browser.js b/.omp/skills/impeccable/scripts/live-browser.js
index f706898e4..75abdf0c0 100644
--- a/.omp/skills/impeccable/scripts/live-browser.js
+++ b/.omp/skills/impeccable/scripts/live-browser.js
@@ -61,11 +61,19 @@
const IMPECCABLE_COMMAND = (window.__IMPECCABLE_COMMAND_PREFIX__ || '/') + 'impeccable';
const PICK_CURSOR_STYLE_ID = PREFIX + '-pick-cursor-style';
const MANUAL_APPLY_STATE_TTL_MS = 15 * 60 * 1000;
- const sessionState = window.__IMPECCABLE_LIVE_SESSION__?.createLiveBrowserSessionState({
- prefix: PREFIX,
- storage: localStorage,
- idFactory: () => crypto.randomUUID().replace(/-/g, '').slice(0, 8),
- });
+ // No idFactory: the session helper's default works on plain-HTTP origins,
+ // where the secure-context-only randomUUID does not exist (issue #1055).
+ let sessionState = null;
+ try {
+ sessionState = window.__IMPECCABLE_LIVE_SESSION__?.createLiveBrowserSessionState({
+ prefix: PREFIX,
+ storage: localStorage,
+ });
+ } catch (err) {
+ console.error('[impeccable] Live mode could not create its session state.', err);
+ window.__IMPECCABLE_LIVE_INIT__ = false; // let a later injection retry
+ return;
+ }
if (!sessionState) {
console.error('[impeccable] live-browser-session.js was not loaded. Live mode cannot start safely.');
window.__IMPECCABLE_LIVE_INIT__ = false;
@@ -293,6 +301,7 @@
liveUiRoot,
uiAppend,
uiAppendToPage,
+ copyTextViaSelection,
topLayerHost,
watchModalDialogs,
cloneWithoutChrome,
@@ -13466,12 +13475,24 @@ void main() {
.replace(/'/g, '&#39;');
}
+ // navigator.clipboard exists only in secure contexts, and writeText can
+ // reject even where it exists (no focus, permission). Fall back
+ // to the DOM helpers' selection copy (execCommand), which plain-HTTP origins
+ // still allow and which stays usable under an open modal dialog.
function copyToClipboard(text) {
if (!text) return;
+ const report = (ok) => showToast(ok ? 'Copied: ' + text : 'Could not copy: ' + text);
+ let pending = null;
try {
- navigator.clipboard.writeText(text);
- showToast('Copied: ' + text);
- } catch { /* ignore */ }
+ if (navigator.clipboard && typeof navigator.clipboard.writeText === 'function') {
+ pending = navigator.clipboard.writeText(text);
+ }
+ } catch { pending = null; }
+ if (pending && typeof pending.then === 'function') {
+ pending.then(() => report(true), () => report(copyTextViaSelection(text)));
+ return;
+ }
+ report(copyTextViaSelection(text));
}
//
diff --git a/.opencode/skills/impeccable/reference/typeset.md b/.opencode/skills/impeccable/reference/typeset.md
index c3b045cd1..0a633c5c6 100644
--- a/.opencode/skills/impeccable/reference/typeset.md
+++ b/.opencode/skills/impeccable/reference/typeset.md
@@ -56,6 +56,16 @@ Use the fewest roles and families that make the hierarchy unmistakable. Combine
Do not make type decorative at the expense of comprehension, or introduce a second family without a clear role it alone can perform.
+## Line breaks
+
+After Matthew Butterick's *Practical Typography*, paraphrased; where his numbers differ from these, these stand.
+
+- Set `text-wrap: balance` on headings and short centered blocks, and `text-wrap: pretty` on body copy. Both are progressive: a browser that ignores them keeps its default wrap.
+- `pretty` pulls a word down beside a lone last word. It does not fill the last line, and a two-word tail is fine.
+- In a column too narrow for either to help, edit the copy or widen the column.
+- Break a heading by hand only between phrases, and check the break at every width the heading renders at. A hard break that lands mid-line on a phone is worse than the default wrap.
+- An uneven break can carry meaning: a headline that lands on one word for weight, a poster line, a pull quote. Make it deliberate with a hard break or a wrap set on that element, and keep it rare. The detector's `straggler` and `unbalanced-heading` findings are advisory for this reason; say which breaks are intended.
+
## Verify
- Primary, secondary, body, and metadata roles are recognizable without reading the copy.
diff --git a/.opencode/skills/impeccable/scripts/live-browser-dom.js b/.opencode/skills/impeccable/scripts/live-browser-dom.js
index 864694498..ef1ca8928 100644
--- a/.opencode/skills/impeccable/scripts/live-browser-dom.js
+++ b/.opencode/skills/impeccable/scripts/live-browser-dom.js
@@ -85,7 +85,16 @@
}
function id8() {
- if (crypto?.randomUUID) return crypto.randomUUID().replace(/-/g, '').slice(0, 8);
+ // randomUUID is secure-context only (issue #1055); getRandomValues is not.
+ try {
+ if (typeof crypto?.randomUUID === 'function') return crypto.randomUUID().replace(/-/g, '').slice(0, 8);
+ } catch { /* fall through */ }
+ try {
+ if (typeof crypto?.getRandomValues === 'function') {
+ const bytes = crypto.getRandomValues(new Uint8Array(4));
+ return Array.from(bytes, (b) => b.toString(16).padStart(2, '0')).join('');
+ }
+ } catch { /* fall through */ }
return (Math.random().toString(16).slice(2) + Date.now().toString(16)).slice(0, 8);
}
@@ -196,6 +205,35 @@
return el;
}
+ // Copy text through a selected textarea and execCommand, for origins where
+ // navigator.clipboard is missing or refused (plain HTTP, issue #1055).
+ // The textarea mounts like any page-level chrome, so while a modal
+ // <dialog> is open it sits in that dialog's top-layer host: on <body> it
+ // would be inert, and inert text cannot be selected or copied.
+ function copyTextViaSelection(text) {
+ let ta = null;
+ const previous = activeElementDeep();
+ try {
+ ta = doc.createElement('textarea');
+ ta.id = prefix + '-clipboard';
+ ta.value = text;
+ ta.setAttribute('readonly', '');
+ ta.setAttribute('aria-hidden', 'true');
+ ta.tabIndex = -1;
+ ta.style.cssText = 'position:fixed;top:0;left:0;width:1px;height:1px;opacity:0;pointer-events:none;';
+ uiAppendToPage(ta);
+ ta.select();
+ return doc.execCommand('copy');
+ } catch {
+ return false;
+ } finally {
+ ta?.remove();
+ if (previous && previous !== activeElementDeep() && typeof previous.focus === 'function') {
+ try { previous.focus({ preventScroll: true }); } catch { /* best effort */ }
+ }
+ }
+ }
+
function uiAppend(el) {
const uiRoot = liveUiRoot();
if (uiRoot === doc.body) return uiAppendToPage(el);
@@ -263,6 +301,7 @@
liveUiRoot,
uiAppend,
uiAppendToPage,
+ copyTextViaSelection,
topLayerHost,
watchModalDialogs,
cloneWithoutChrome,
diff --git a/.opencode/skills/impeccable/scripts/live-browser-session.js b/.opencode/skills/impeccable/scripts/live-browser-session.js
index ad9cdf008..388d2c2f9 100644
--- a/.opencode/skills/impeccable/scripts/live-browser-session.js
+++ b/.opencode/skills/impeccable/scripts/live-browser-session.js
@@ -8,10 +8,42 @@
(function (root) {
'use strict';
+ // crypto.randomUUID() exists only in secure contexts (HTTPS, localhost), so a
+ // dev site on a LAN IP, a Tailscale address, or a custom hostname over plain
+ // HTTP has no randomUUID at all (issue #1055). getRandomValues() is available
+ // in every context; Math.random() covers runtimes with no crypto. Live ids
+ // only have to be unique per session, not unguessable.
+ function randomUUID(cryptoImpl) {
+ const c = cryptoImpl === undefined ? root.crypto : cryptoImpl;
+ try {
+ if (c && typeof c.randomUUID === 'function') return c.randomUUID();
+ } catch { /* fall through to getRandomValues */ }
+ const bytes = new Uint8Array(16);
+ let filled = false;
+ try {
+ if (c && typeof c.getRandomValues === 'function') {
+ c.getRandomValues(bytes);
+ filled = true;
+ }
+ } catch { /* fall through to Math.random */ }
+ if (!filled) {
+ for (let i = 0; i < 16; i++) bytes[i] = Math.floor(Math.random() * 256);
+ }
+ bytes[6] = (bytes[6] & 0x0f) | 0x40; // version 4
+ bytes[8] = (bytes[8] & 0x3f) | 0x80; // RFC 4122 variant
+ const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, '0')).join('');
+ return hex.slice(0, 8) + '-' + hex.slice(8, 12) + '-' + hex.slice(12, 16)
+ + '-' + hex.slice(16, 20) + '-' + hex.slice(20);
+ }
+
+ function randomId8(cryptoImpl) {
+ return randomUUID(cryptoImpl).replace(/-/g, '').slice(0, 8);
+ }
+
function createLiveBrowserSessionState({ prefix, storage, idFactory }) {
if (!prefix) throw new Error('prefix required');
const store = storage || root.localStorage;
- const makeId = idFactory || function () { return Math.random().toString(16).slice(2, 10); };
+ const makeId = idFactory || function () { return randomId8(); };
const sessionKey = prefix + '-session';
const handledKey = sessionKey + '-handled';
const scrollKey = sessionKey + '-scroll';
@@ -144,5 +176,5 @@
};
}
- root.__IMPECCABLE_LIVE_SESSION__ = { createLiveBrowserSessionState };
+ root.__IMPECCABLE_LIVE_SESSION__ = { createLiveBrowserSessionState, randomUUID, randomId8 };
})(typeof window !== 'undefined' ? window : globalThis);
diff --git a/.opencode/skills/impeccable/scripts/live-browser.js b/.opencode/skills/impeccable/scripts/live-browser.js
index f706898e4..75abdf0c0 100644
--- a/.opencode/skills/impeccable/scripts/live-browser.js
+++ b/.opencode/skills/impeccable/scripts/live-browser.js
@@ -61,11 +61,19 @@
const IMPECCABLE_COMMAND = (window.__IMPECCABLE_COMMAND_PREFIX__ || '/') + 'impeccable';
const PICK_CURSOR_STYLE_ID = PREFIX + '-pick-cursor-style';
const MANUAL_APPLY_STATE_TTL_MS = 15 * 60 * 1000;
- const sessionState = window.__IMPECCABLE_LIVE_SESSION__?.createLiveBrowserSessionState({
- prefix: PREFIX,
- storage: localStorage,
- idFactory: () => crypto.randomUUID().replace(/-/g, '').slice(0, 8),
- });
+ // No idFactory: the session helper's default works on plain-HTTP origins,
+ // where the secure-context-only randomUUID does not exist (issue #1055).
+ let sessionState = null;
+ try {
+ sessionState = window.__IMPECCABLE_LIVE_SESSION__?.createLiveBrowserSessionState({
+ prefix: PREFIX,
+ storage: localStorage,
+ });
+ } catch (err) {
+ console.error('[impeccable] Live mode could not create its session state.', err);
+ window.__IMPECCABLE_LIVE_INIT__ = false; // let a later injection retry
+ return;
+ }
if (!sessionState) {
console.error('[impeccable] live-browser-session.js was not loaded. Live mode cannot start safely.');
window.__IMPECCABLE_LIVE_INIT__ = false;
@@ -293,6 +301,7 @@
liveUiRoot,
uiAppend,
uiAppendToPage,
+ copyTextViaSelection,
topLayerHost,
watchModalDialogs,
cloneWithoutChrome,
@@ -13466,12 +13475,24 @@ void main() {
.replace(/'/g, '&#39;');
}
+ // navigator.clipboard exists only in secure contexts, and writeText can
+ // reject even where it exists (no focus, permission). Fall back
+ // to the DOM helpers' selection copy (execCommand), which plain-HTTP origins
+ // still allow and which stays usable under an open modal dialog.
function copyToClipboard(text) {
if (!text) return;
+ const report = (ok) => showToast(ok ? 'Copied: ' + text : 'Could not copy: ' + text);
+ let pending = null;
try {
- navigator.clipboard.writeText(text);
- showToast('Copied: ' + text);
- } catch { /* ignore */ }
+ if (navigator.clipboard && typeof navigator.clipboard.writeText === 'function') {
+ pending = navigator.clipboard.writeText(text);
+ }
+ } catch { pending = null; }
+ if (pending && typeof pending.then === 'function') {
+ pending.then(() => report(true), () => report(copyTextViaSelection(text)));
+ return;
+ }
+ report(copyTextViaSelection(text));
}
//
diff --git a/.pi/skills/impeccable/reference/typeset.md b/.pi/skills/impeccable/reference/typeset.md
index 865ff7f71..6d3c6d866 100644
--- a/.pi/skills/impeccable/reference/typeset.md
+++ b/.pi/skills/impeccable/reference/typeset.md
@@ -56,6 +56,16 @@ Use the fewest roles and families that make the hierarchy unmistakable. Combine
Do not make type decorative at the expense of comprehension, or introduce a second family without a clear role it alone can perform.
+## Line breaks
+
+After Matthew Butterick's *Practical Typography*, paraphrased; where his numbers differ from these, these stand.
+
+- Set `text-wrap: balance` on headings and short centered blocks, and `text-wrap: pretty` on body copy. Both are progressive: a browser that ignores them keeps its default wrap.
+- `pretty` pulls a word down beside a lone last word. It does not fill the last line, and a two-word tail is fine.
+- In a column too narrow for either to help, edit the copy or widen the column.
+- Break a heading by hand only between phrases, and check the break at every width the heading renders at. A hard break that lands mid-line on a phone is worse than the default wrap.
+- An uneven break can carry meaning: a headline that lands on one word for weight, a poster line, a pull quote. Make it deliberate with a hard break or a wrap set on that element, and keep it rare. The detector's `straggler` and `unbalanced-heading` findings are advisory for this reason; say which breaks are intended.
+
## Verify
- Primary, secondary, body, and metadata roles are recognizable without reading the copy.
diff --git a/.pi/skills/impeccable/scripts/live-browser-dom.js b/.pi/skills/impeccable/scripts/live-browser-dom.js
index 864694498..ef1ca8928 100644
--- a/.pi/skills/impeccable/scripts/live-browser-dom.js
+++ b/.pi/skills/impeccable/scripts/live-browser-dom.js
@@ -85,7 +85,16 @@
}
function id8() {
- if (crypto?.randomUUID) return crypto.randomUUID().replace(/-/g, '').slice(0, 8);
+ // randomUUID is secure-context only (issue #1055); getRandomValues is not.
+ try {
+ if (typeof crypto?.randomUUID === 'function') return crypto.randomUUID().replace(/-/g, '').slice(0, 8);
+ } catch { /* fall through */ }
+ try {
+ if (typeof crypto?.getRandomValues === 'function') {
+ const bytes = crypto.getRandomValues(new Uint8Array(4));
+ return Array.from(bytes, (b) => b.toString(16).padStart(2, '0')).join('');
+ }
+ } catch { /* fall through */ }
return (Math.random().toString(16).slice(2) + Date.now().toString(16)).slice(0, 8);
}
@@ -196,6 +205,35 @@
return el;
}
+ // Copy text through a selected textarea and execCommand, for origins where
+ // navigator.clipboard is missing or refused (plain HTTP, issue #1055).
+ // The textarea mounts like any page-level chrome, so while a modal
+ // <dialog> is open it sits in that dialog's top-layer host: on <body> it
+ // would be inert, and inert text cannot be selected or copied.
+ function copyTextViaSelection(text) {
+ let ta = null;
+ const previous = activeElementDeep();
+ try {
+ ta = doc.createElement('textarea');
+ ta.id = prefix + '-clipboard';
+ ta.value = text;
+ ta.setAttribute('readonly', '');
+ ta.setAttribute('aria-hidden', 'true');
+ ta.tabIndex = -1;
+ ta.style.cssText = 'position:fixed;top:0;left:0;width:1px;height:1px;opacity:0;pointer-events:none;';
+ uiAppendToPage(ta);
+ ta.select();
+ return doc.execCommand('copy');
+ } catch {
+ return false;
+ } finally {
+ ta?.remove();
+ if (previous && previous !== activeElementDeep() && typeof previous.focus === 'function') {
+ try { previous.focus({ preventScroll: true }); } catch { /* best effort */ }
+ }
+ }
+ }
+
function uiAppend(el) {
const uiRoot = liveUiRoot();
if (uiRoot === doc.body) return uiAppendToPage(el);
@@ -263,6 +301,7 @@
liveUiRoot,
uiAppend,
uiAppendToPage,
+ copyTextViaSelection,
topLayerHost,
watchModalDialogs,
cloneWithoutChrome,
diff --git a/.pi/skills/impeccable/scripts/live-browser-session.js b/.pi/skills/impeccable/scripts/live-browser-session.js
index ad9cdf008..388d2c2f9 100644
--- a/.pi/skills/impeccable/scripts/live-browser-session.js
+++ b/.pi/skills/impeccable/scripts/live-browser-session.js
@@ -8,10 +8,42 @@
(function (root) {
'use strict';
+ // crypto.randomUUID() exists only in secure contexts (HTTPS, localhost), so a
+ // dev site on a LAN IP, a Tailscale address, or a custom hostname over plain
+ // HTTP has no randomUUID at all (issue #1055). getRandomValues() is available
+ // in every context; Math.random() covers runtimes with no crypto. Live ids
+ // only have to be unique per session, not unguessable.
+ function randomUUID(cryptoImpl) {
+ const c = cryptoImpl === undefined ? root.crypto : cryptoImpl;
+ try {
+ if (c && typeof c.randomUUID === 'function') return c.randomUUID();
+ } catch { /* fall through to getRandomValues */ }
+ const bytes = new Uint8Array(16);
+ let filled = false;
+ try {
+ if (c && typeof c.getRandomValues === 'function') {
+ c.getRandomValues(bytes);
+ filled = true;
+ }
+ } catch { /* fall through to Math.random */ }
+ if (!filled) {
+ for (let i = 0; i < 16; i++) bytes[i] = Math.floor(Math.random() * 256);
+ }
+ bytes[6] = (bytes[6] & 0x0f) | 0x40; // version 4
+ bytes[8] = (bytes[8] & 0x3f) | 0x80; // RFC 4122 variant
+ const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, '0')).join('');
+ return hex.slice(0, 8) + '-' + hex.slice(8, 12) + '-' + hex.slice(12, 16)
+ + '-' + hex.slice(16, 20) + '-' + hex.slice(20);
+ }
+
+ function randomId8(cryptoImpl) {
+ return randomUUID(cryptoImpl).replace(/-/g, '').slice(0, 8);
+ }
+
function createLiveBrowserSessionState({ prefix, storage, idFactory }) {
if (!prefix) throw new Error('prefix required');
const store = storage || root.localStorage;
- const makeId = idFactory || function () { return Math.random().toString(16).slice(2, 10); };
+ const makeId = idFactory || function () { return randomId8(); };
const sessionKey = prefix + '-session';
const handledKey = sessionKey + '-handled';
const scrollKey = sessionKey + '-scroll';
@@ -144,5 +176,5 @@
};
}
- root.__IMPECCABLE_LIVE_SESSION__ = { createLiveBrowserSessionState };
+ root.__IMPECCABLE_LIVE_SESSION__ = { createLiveBrowserSessionState, randomUUID, randomId8 };
})(typeof window !== 'undefined' ? window : globalThis);
diff --git a/.pi/skills/impeccable/scripts/live-browser.js b/.pi/skills/impeccable/scripts/live-browser.js
index f706898e4..75abdf0c0 100644
--- a/.pi/skills/impeccable/scripts/live-browser.js
+++ b/.pi/skills/impeccable/scripts/live-browser.js
@@ -61,11 +61,19 @@
const IMPECCABLE_COMMAND = (window.__IMPECCABLE_COMMAND_PREFIX__ || '/') + 'impeccable';
const PICK_CURSOR_STYLE_ID = PREFIX + '-pick-cursor-style';
const MANUAL_APPLY_STATE_TTL_MS = 15 * 60 * 1000;
- const sessionState = window.__IMPECCABLE_LIVE_SESSION__?.createLiveBrowserSessionState({
- prefix: PREFIX,
- storage: localStorage,
- idFactory: () => crypto.randomUUID().replace(/-/g, '').slice(0, 8),
- });
+ // No idFactory: the session helper's default works on plain-HTTP origins,
+ // where the secure-context-only randomUUID does not exist (issue #1055).
+ let sessionState = null;
+ try {
+ sessionState = window.__IMPECCABLE_LIVE_SESSION__?.createLiveBrowserSessionState({
+ prefix: PREFIX,
+ storage: localStorage,
+ });
+ } catch (err) {
+ console.error('[impeccable] Live mode could not create its session state.', err);
+ window.__IMPECCABLE_LIVE_INIT__ = false; // let a later injection retry
+ return;
+ }
if (!sessionState) {
console.error('[impeccable] live-browser-session.js was not loaded. Live mode cannot start safely.');
window.__IMPECCABLE_LIVE_INIT__ = false;
@@ -293,6 +301,7 @@
liveUiRoot,
uiAppend,
uiAppendToPage,
+ copyTextViaSelection,
topLayerHost,
watchModalDialogs,
cloneWithoutChrome,
@@ -13466,12 +13475,24 @@ void main() {
.replace(/'/g, '&#39;');
}
+ // navigator.clipboard exists only in secure contexts, and writeText can
+ // reject even where it exists (no focus, permission). Fall back
+ // to the DOM helpers' selection copy (execCommand), which plain-HTTP origins
+ // still allow and which stays usable under an open modal dialog.
function copyToClipboard(text) {
if (!text) return;
+ const report = (ok) => showToast(ok ? 'Copied: ' + text : 'Could not copy: ' + text);
+ let pending = null;
try {
- navigator.clipboard.writeText(text);
- showToast('Copied: ' + text);
- } catch { /* ignore */ }
+ if (navigator.clipboard && typeof navigator.clipboard.writeText === 'function') {
+ pending = navigator.clipboard.writeText(text);
+ }
+ } catch { pending = null; }
+ if (pending && typeof pending.then === 'function') {
+ pending.then(() => report(true), () => report(copyTextViaSelection(text)));
+ return;
+ }
+ report(copyTextViaSelection(text));
}
//
diff --git a/.qoder/skills/impeccable/reference/typeset.md b/.qoder/skills/impeccable/reference/typeset.md
index c782d4409..7bd31aec2 100644
--- a/.qoder/skills/impeccable/reference/typeset.md
+++ b/.qoder/skills/impeccable/reference/typeset.md
@@ -56,6 +56,16 @@ Use the fewest roles and families that make the hierarchy unmistakable. Combine
Do not make type decorative at the expense of comprehension, or introduce a second family without a clear role it alone can perform.
+## Line breaks
+
+After Matthew Butterick's *Practical Typography*, paraphrased; where his numbers differ from these, these stand.
+
+- Set `text-wrap: balance` on headings and short centered blocks, and `text-wrap: pretty` on body copy. Both are progressive: a browser that ignores them keeps its default wrap.
+- `pretty` pulls a word down beside a lone last word. It does not fill the last line, and a two-word tail is fine.
+- In a column too narrow for either to help, edit the copy or widen the column.
+- Break a heading by hand only between phrases, and check the break at every width the heading renders at. A hard break that lands mid-line on a phone is worse than the default wrap.
+- An uneven break can carry meaning: a headline that lands on one word for weight, a poster line, a pull quote. Make it deliberate with a hard break or a wrap set on that element, and keep it rare. The detector's `straggler` and `unbalanced-heading` findings are advisory for this reason; say which breaks are intended.
+
## Verify
- Primary, secondary, body, and metadata roles are recognizable without reading the copy.
diff --git a/.qoder/skills/impeccable/scripts/live-browser-dom.js b/.qoder/skills/impeccable/scripts/live-browser-dom.js
index 864694498..ef1ca8928 100644
--- a/.qoder/skills/impeccable/scripts/live-browser-dom.js
+++ b/.qoder/skills/impeccable/scripts/live-browser-dom.js
@@ -85,7 +85,16 @@
}
function id8() {
- if (crypto?.randomUUID) return crypto.randomUUID().replace(/-/g, '').slice(0, 8);
+ // randomUUID is secure-context only (issue #1055); getRandomValues is not.
+ try {
+ if (typeof crypto?.randomUUID === 'function') return crypto.randomUUID().replace(/-/g, '').slice(0, 8);
+ } catch { /* fall through */ }
+ try {
+ if (typeof crypto?.getRandomValues === 'function') {
+ const bytes = crypto.getRandomValues(new Uint8Array(4));
+ return Array.from(bytes, (b) => b.toString(16).padStart(2, '0')).join('');
+ }
+ } catch { /* fall through */ }
return (Math.random().toString(16).slice(2) + Date.now().toString(16)).slice(0, 8);
}
@@ -196,6 +205,35 @@
return el;
}
+ // Copy text through a selected textarea and execCommand, for origins where
+ // navigator.clipboard is missing or refused (plain HTTP, issue #1055).
+ // The textarea mounts like any page-level chrome, so while a modal
+ // <dialog> is open it sits in that dialog's top-layer host: on <body> it
+ // would be inert, and inert text cannot be selected or copied.
+ function copyTextViaSelection(text) {
+ let ta = null;
+ const previous = activeElementDeep();
+ try {
+ ta = doc.createElement('textarea');
+ ta.id = prefix + '-clipboard';
+ ta.value = text;
+ ta.setAttribute('readonly', '');
+ ta.setAttribute('aria-hidden', 'true');
+ ta.tabIndex = -1;
+ ta.style.cssText = 'position:fixed;top:0;left:0;width:1px;height:1px;opacity:0;pointer-events:none;';
+ uiAppendToPage(ta);
+ ta.select();
+ return doc.execCommand('copy');
+ } catch {
+ return false;
+ } finally {
+ ta?.remove();
+ if (previous && previous !== activeElementDeep() && typeof previous.focus === 'function') {
+ try { previous.focus({ preventScroll: true }); } catch { /* best effort */ }
+ }
+ }
+ }
+
function uiAppend(el) {
const uiRoot = liveUiRoot();
if (uiRoot === doc.body) return uiAppendToPage(el);
@@ -263,6 +301,7 @@
liveUiRoot,
uiAppend,
uiAppendToPage,
+ copyTextViaSelection,
topLayerHost,
watchModalDialogs,
cloneWithoutChrome,
diff --git a/.qoder/skills/impeccable/scripts/live-browser-session.js b/.qoder/skills/impeccable/scripts/live-browser-session.js
index ad9cdf008..388d2c2f9 100644
--- a/.qoder/skills/impeccable/scripts/live-browser-session.js
+++ b/.qoder/skills/impeccable/scripts/live-browser-session.js
@@ -8,10 +8,42 @@
(function (root) {
'use strict';
+ // crypto.randomUUID() exists only in secure contexts (HTTPS, localhost), so a
+ // dev site on a LAN IP, a Tailscale address, or a custom hostname over plain
+ // HTTP has no randomUUID at all (issue #1055). getRandomValues() is available
+ // in every context; Math.random() covers runtimes with no crypto. Live ids
+ // only have to be unique per session, not unguessable.
+ function randomUUID(cryptoImpl) {
+ const c = cryptoImpl === undefined ? root.crypto : cryptoImpl;
+ try {
+ if (c && typeof c.randomUUID === 'function') return c.randomUUID();
+ } catch { /* fall through to getRandomValues */ }
+ const bytes = new Uint8Array(16);
+ let filled = false;
+ try {
+ if (c && typeof c.getRandomValues === 'function') {
+ c.getRandomValues(bytes);
+ filled = true;
+ }
+ } catch { /* fall through to Math.random */ }
+ if (!filled) {
+ for (let i = 0; i < 16; i++) bytes[i] = Math.floor(Math.random() * 256);
+ }
+ bytes[6] = (bytes[6] & 0x0f) | 0x40; // version 4
+ bytes[8] = (bytes[8] & 0x3f) | 0x80; // RFC 4122 variant
+ const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, '0')).join('');
+ return hex.slice(0, 8) + '-' + hex.slice(8, 12) + '-' + hex.slice(12, 16)
+ + '-' + hex.slice(16, 20) + '-' + hex.slice(20);
+ }
+
+ function randomId8(cryptoImpl) {
+ return randomUUID(cryptoImpl).replace(/-/g, '').slice(0, 8);
+ }
+
function createLiveBrowserSessionState({ prefix, storage, idFactory }) {
if (!prefix) throw new Error('prefix required');
const store = storage || root.localStorage;
- const makeId = idFactory || function () { return Math.random().toString(16).slice(2, 10); };
+ const makeId = idFactory || function () { return randomId8(); };
const sessionKey = prefix + '-session';
const handledKey = sessionKey + '-handled';
const scrollKey = sessionKey + '-scroll';
@@ -144,5 +176,5 @@
};
}
- root.__IMPECCABLE_LIVE_SESSION__ = { createLiveBrowserSessionState };
+ root.__IMPECCABLE_LIVE_SESSION__ = { createLiveBrowserSessionState, randomUUID, randomId8 };
})(typeof window !== 'undefined' ? window : globalThis);
diff --git a/.qoder/skills/impeccable/scripts/live-browser.js b/.qoder/skills/impeccable/scripts/live-browser.js
index f706898e4..75abdf0c0 100644
--- a/.qoder/skills/impeccable/scripts/live-browser.js
+++ b/.qoder/skills/impeccable/scripts/live-browser.js
@@ -61,11 +61,19 @@
const IMPECCABLE_COMMAND = (window.__IMPECCABLE_COMMAND_PREFIX__ || '/') + 'impeccable';
const PICK_CURSOR_STYLE_ID = PREFIX + '-pick-cursor-style';
const MANUAL_APPLY_STATE_TTL_MS = 15 * 60 * 1000;
- const sessionState = window.__IMPECCABLE_LIVE_SESSION__?.createLiveBrowserSessionState({
- prefix: PREFIX,
- storage: localStorage,
- idFactory: () => crypto.randomUUID().replace(/-/g, '').slice(0, 8),
- });
+ // No idFactory: the session helper's default works on plain-HTTP origins,
+ // where the secure-context-only randomUUID does not exist (issue #1055).
+ let sessionState = null;
+ try {
+ sessionState = window.__IMPECCABLE_LIVE_SESSION__?.createLiveBrowserSessionState({
+ prefix: PREFIX,
+ storage: localStorage,
+ });
+ } catch (err) {
+ console.error('[impeccable] Live mode could not create its session state.', err);
+ window.__IMPECCABLE_LIVE_INIT__ = false; // let a later injection retry
+ return;
+ }
if (!sessionState) {
console.error('[impeccable] live-browser-session.js was not loaded. Live mode cannot start safely.');
window.__IMPECCABLE_LIVE_INIT__ = false;
@@ -293,6 +301,7 @@
liveUiRoot,
uiAppend,
uiAppendToPage,
+ copyTextViaSelection,
topLayerHost,
watchModalDialogs,
cloneWithoutChrome,
@@ -13466,12 +13475,24 @@ void main() {
.replace(/'/g, '&#39;');
}
+ // navigator.clipboard exists only in secure contexts, and writeText can
+ // reject even where it exists (no focus, permission). Fall back
+ // to the DOM helpers' selection copy (execCommand), which plain-HTTP origins
+ // still allow and which stays usable under an open modal dialog.
function copyToClipboard(text) {
if (!text) return;
+ const report = (ok) => showToast(ok ? 'Copied: ' + text : 'Could not copy: ' + text);
+ let pending = null;
try {
- navigator.clipboard.writeText(text);
- showToast('Copied: ' + text);
- } catch { /* ignore */ }
+ if (navigator.clipboard && typeof navigator.clipboard.writeText === 'function') {
+ pending = navigator.clipboard.writeText(text);
+ }
+ } catch { pending = null; }
+ if (pending && typeof pending.then === 'function') {
+ pending.then(() => report(true), () => report(copyTextViaSelection(text)));
+ return;
+ }
+ report(copyTextViaSelection(text));
}
//
diff --git a/.rovodev/skills/impeccable/reference/typeset.md b/.rovodev/skills/impeccable/reference/typeset.md
index f14030fee..2c03d3fe8 100644
--- a/.rovodev/skills/impeccable/reference/typeset.md
+++ b/.rovodev/skills/impeccable/reference/typeset.md
@@ -56,6 +56,16 @@ Use the fewest roles and families that make the hierarchy unmistakable. Combine
Do not make type decorative at the expense of comprehension, or introduce a second family without a clear role it alone can perform.
+## Line breaks
+
+After Matthew Butterick's *Practical Typography*, paraphrased; where his numbers differ from these, these stand.
+
+- Set `text-wrap: balance` on headings and short centered blocks, and `text-wrap: pretty` on body copy. Both are progressive: a browser that ignores them keeps its default wrap.
+- `pretty` pulls a word down beside a lone last word. It does not fill the last line, and a two-word tail is fine.
+- In a column too narrow for either to help, edit the copy or widen the column.
+- Break a heading by hand only between phrases, and check the break at every width the heading renders at. A hard break that lands mid-line on a phone is worse than the default wrap.
+- An uneven break can carry meaning: a headline that lands on one word for weight, a poster line, a pull quote. Make it deliberate with a hard break or a wrap set on that element, and keep it rare. The detector's `straggler` and `unbalanced-heading` findings are advisory for this reason; say which breaks are intended.
+
## Verify
- Primary, secondary, body, and metadata roles are recognizable without reading the copy.
diff --git a/.rovodev/skills/impeccable/scripts/live-browser-dom.js b/.rovodev/skills/impeccable/scripts/live-browser-dom.js
index 864694498..ef1ca8928 100644
--- a/.rovodev/skills/impeccable/scripts/live-browser-dom.js
+++ b/.rovodev/skills/impeccable/scripts/live-browser-dom.js
@@ -85,7 +85,16 @@
}
function id8() {
- if (crypto?.randomUUID) return crypto.randomUUID().replace(/-/g, '').slice(0, 8);
+ // randomUUID is secure-context only (issue #1055); getRandomValues is not.
+ try {
+ if (typeof crypto?.randomUUID === 'function') return crypto.randomUUID().replace(/-/g, '').slice(0, 8);
+ } catch { /* fall through */ }
+ try {
+ if (typeof crypto?.getRandomValues === 'function') {
+ const bytes = crypto.getRandomValues(new Uint8Array(4));
+ return Array.from(bytes, (b) => b.toString(16).padStart(2, '0')).join('');
+ }
+ } catch { /* fall through */ }
return (Math.random().toString(16).slice(2) + Date.now().toString(16)).slice(0, 8);
}
@@ -196,6 +205,35 @@
return el;
}
+ // Copy text through a selected textarea and execCommand, for origins where
+ // navigator.clipboard is missing or refused (plain HTTP, issue #1055).
+ // The textarea mounts like any page-level chrome, so while a modal
+ // <dialog> is open it sits in that dialog's top-layer host: on <body> it
+ // would be inert, and inert text cannot be selected or copied.
+ function copyTextViaSelection(text) {
+ let ta = null;
+ const previous = activeElementDeep();
+ try {
+ ta = doc.createElement('textarea');
+ ta.id = prefix + '-clipboard';
+ ta.value = text;
+ ta.setAttribute('readonly', '');
+ ta.setAttribute('aria-hidden', 'true');
+ ta.tabIndex = -1;
+ ta.style.cssText = 'position:fixed;top:0;left:0;width:1px;height:1px;opacity:0;pointer-events:none;';
+ uiAppendToPage(ta);
+ ta.select();
+ return doc.execCommand('copy');
+ } catch {
+ return false;
+ } finally {
+ ta?.remove();
+ if (previous && previous !== activeElementDeep() && typeof previous.focus === 'function') {
+ try { previous.focus({ preventScroll: true }); } catch { /* best effort */ }
+ }
+ }
+ }
+
function uiAppend(el) {
const uiRoot = liveUiRoot();
if (uiRoot === doc.body) return uiAppendToPage(el);
@@ -263,6 +301,7 @@
liveUiRoot,
uiAppend,
uiAppendToPage,
+ copyTextViaSelection,
topLayerHost,
watchModalDialogs,
cloneWithoutChrome,
diff --git a/.rovodev/skills/impeccable/scripts/live-browser-session.js b/.rovodev/skills/impeccable/scripts/live-browser-session.js
index ad9cdf008..388d2c2f9 100644
--- a/.rovodev/skills/impeccable/scripts/live-browser-session.js
+++ b/.rovodev/skills/impeccable/scripts/live-browser-session.js
@@ -8,10 +8,42 @@
(function (root) {
'use strict';
+ // crypto.randomUUID() exists only in secure contexts (HTTPS, localhost), so a
+ // dev site on a LAN IP, a Tailscale address, or a custom hostname over plain
+ // HTTP has no randomUUID at all (issue #1055). getRandomValues() is available
+ // in every context; Math.random() covers runtimes with no crypto. Live ids
+ // only have to be unique per session, not unguessable.
+ function randomUUID(cryptoImpl) {
+ const c = cryptoImpl === undefined ? root.crypto : cryptoImpl;
+ try {
+ if (c && typeof c.randomUUID === 'function') return c.randomUUID();
+ } catch { /* fall through to getRandomValues */ }
+ const bytes = new Uint8Array(16);
+ let filled = false;
+ try {
+ if (c && typeof c.getRandomValues === 'function') {
+ c.getRandomValues(bytes);
+ filled = true;
+ }
+ } catch { /* fall through to Math.random */ }
+ if (!filled) {
+ for (let i = 0; i < 16; i++) bytes[i] = Math.floor(Math.random() * 256);
+ }
+ bytes[6] = (bytes[6] & 0x0f) | 0x40; // version 4
+ bytes[8] = (bytes[8] & 0x3f) | 0x80; // RFC 4122 variant
+ const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, '0')).join('');
+ return hex.slice(0, 8) + '-' + hex.slice(8, 12) + '-' + hex.slice(12, 16)
+ + '-' + hex.slice(16, 20) + '-' + hex.slice(20);
+ }
+
+ function randomId8(cryptoImpl) {
+ return randomUUID(cryptoImpl).replace(/-/g, '').slice(0, 8);
+ }
+
function createLiveBrowserSessionState({ prefix, storage, idFactory }) {
if (!prefix) throw new Error('prefix required');
const store = storage || root.localStorage;
- const makeId = idFactory || function () { return Math.random().toString(16).slice(2, 10); };
+ const makeId = idFactory || function () { return randomId8(); };
const sessionKey = prefix + '-session';
const handledKey = sessionKey + '-handled';
const scrollKey = sessionKey + '-scroll';
@@ -144,5 +176,5 @@
};
}
- root.__IMPECCABLE_LIVE_SESSION__ = { createLiveBrowserSessionState };
+ root.__IMPECCABLE_LIVE_SESSION__ = { createLiveBrowserSessionState, randomUUID, randomId8 };
})(typeof window !== 'undefined' ? window : globalThis);
diff --git a/.rovodev/skills/impeccable/scripts/live-browser.js b/.rovodev/skills/impeccable/scripts/live-browser.js
index f706898e4..75abdf0c0 100644
--- a/.rovodev/skills/impeccable/scripts/live-browser.js
+++ b/.rovodev/skills/impeccable/scripts/live-browser.js
@@ -61,11 +61,19 @@
const IMPECCABLE_COMMAND = (window.__IMPECCABLE_COMMAND_PREFIX__ || '/') + 'impeccable';
const PICK_CURSOR_STYLE_ID = PREFIX + '-pick-cursor-style';
const MANUAL_APPLY_STATE_TTL_MS = 15 * 60 * 1000;
- const sessionState = window.__IMPECCABLE_LIVE_SESSION__?.createLiveBrowserSessionState({
- prefix: PREFIX,
- storage: localStorage,
- idFactory: () => crypto.randomUUID().replace(/-/g, '').slice(0, 8),
- });
+ // No idFactory: the session helper's default works on plain-HTTP origins,
+ // where the secure-context-only randomUUID does not exist (issue #1055).
+ let sessionState = null;
+ try {
+ sessionState = window.__IMPECCABLE_LIVE_SESSION__?.createLiveBrowserSessionState({
+ prefix: PREFIX,
+ storage: localStorage,
+ });
+ } catch (err) {
+ console.error('[impeccable] Live mode could not create its session state.', err);
+ window.__IMPECCABLE_LIVE_INIT__ = false; // let a later injection retry
+ return;
+ }
if (!sessionState) {
console.error('[impeccable] live-browser-session.js was not loaded. Live mode cannot start safely.');
window.__IMPECCABLE_LIVE_INIT__ = false;
@@ -293,6 +301,7 @@
liveUiRoot,
uiAppend,
uiAppendToPage,
+ copyTextViaSelection,
topLayerHost,
watchModalDialogs,
cloneWithoutChrome,
@@ -13466,12 +13475,24 @@ void main() {
.replace(/'/g, '&#39;');
}
+ // navigator.clipboard exists only in secure contexts, and writeText can
+ // reject even where it exists (no focus, permission). Fall back
+ // to the DOM helpers' selection copy (execCommand), which plain-HTTP origins
+ // still allow and which stays usable under an open modal dialog.
function copyToClipboard(text) {
if (!text) return;
+ const report = (ok) => showToast(ok ? 'Copied: ' + text : 'Could not copy: ' + text);
+ let pending = null;
try {
- navigator.clipboard.writeText(text);
- showToast('Copied: ' + text);
- } catch { /* ignore */ }
+ if (navigator.clipboard && typeof navigator.clipboard.writeText === 'function') {
+ pending = navigator.clipboard.writeText(text);
+ }
+ } catch { pending = null; }
+ if (pending && typeof pending.then === 'function') {
+ pending.then(() => report(true), () => report(copyTextViaSelection(text)));
+ return;
+ }
+ report(copyTextViaSelection(text));
}
//
diff --git a/.trae-cn/skills/impeccable/reference/typeset.md b/.trae-cn/skills/impeccable/reference/typeset.md
index a9015b8c3..e61eda3e6 100644
--- a/.trae-cn/skills/impeccable/reference/typeset.md
+++ b/.trae-cn/skills/impeccable/reference/typeset.md
@@ -56,6 +56,16 @@ Use the fewest roles and families that make the hierarchy unmistakable. Combine
Do not make type decorative at the expense of comprehension, or introduce a second family without a clear role it alone can perform.
+## Line breaks
+
+After Matthew Butterick's *Practical Typography*, paraphrased; where his numbers differ from these, these stand.
+
+- Set `text-wrap: balance` on headings and short centered blocks, and `text-wrap: pretty` on body copy. Both are progressive: a browser that ignores them keeps its default wrap.
+- `pretty` pulls a word down beside a lone last word. It does not fill the last line, and a two-word tail is fine.
+- In a column too narrow for either to help, edit the copy or widen the column.
+- Break a heading by hand only between phrases, and check the break at every width the heading renders at. A hard break that lands mid-line on a phone is worse than the default wrap.
+- An uneven break can carry meaning: a headline that lands on one word for weight, a poster line, a pull quote. Make it deliberate with a hard break or a wrap set on that element, and keep it rare. The detector's `straggler` and `unbalanced-heading` findings are advisory for this reason; say which breaks are intended.
+
## Verify
- Primary, secondary, body, and metadata roles are recognizable without reading the copy.
diff --git a/.trae-cn/skills/impeccable/scripts/live-browser-dom.js b/.trae-cn/skills/impeccable/scripts/live-browser-dom.js
index 864694498..ef1ca8928 100644
--- a/.trae-cn/skills/impeccable/scripts/live-browser-dom.js
+++ b/.trae-cn/skills/impeccable/scripts/live-browser-dom.js
@@ -85,7 +85,16 @@
}
function id8() {
- if (crypto?.randomUUID) return crypto.randomUUID().replace(/-/g, '').slice(0, 8);
+ // randomUUID is secure-context only (issue #1055); getRandomValues is not.
+ try {
+ if (typeof crypto?.randomUUID === 'function') return crypto.randomUUID().replace(/-/g, '').slice(0, 8);
+ } catch { /* fall through */ }
+ try {
+ if (typeof crypto?.getRandomValues === 'function') {
+ const bytes = crypto.getRandomValues(new Uint8Array(4));
+ return Array.from(bytes, (b) => b.toString(16).padStart(2, '0')).join('');
+ }
+ } catch { /* fall through */ }
return (Math.random().toString(16).slice(2) + Date.now().toString(16)).slice(0, 8);
}
@@ -196,6 +205,35 @@
return el;
}
+ // Copy text through a selected textarea and execCommand, for origins where
+ // navigator.clipboard is missing or refused (plain HTTP, issue #1055).
+ // The textarea mounts like any page-level chrome, so while a modal
+ // <dialog> is open it sits in that dialog's top-layer host: on <body> it
+ // would be inert, and inert text cannot be selected or copied.
+ function copyTextViaSelection(text) {
+ let ta = null;
+ const previous = activeElementDeep();
+ try {
+ ta = doc.createElement('textarea');
+ ta.id = prefix + '-clipboard';
+ ta.value = text;
+ ta.setAttribute('readonly', '');
+ ta.setAttribute('aria-hidden', 'true');
+ ta.tabIndex = -1;
+ ta.style.cssText = 'position:fixed;top:0;left:0;width:1px;height:1px;opacity:0;pointer-events:none;';
+ uiAppendToPage(ta);
+ ta.select();
+ return doc.execCommand('copy');
+ } catch {
+ return false;
+ } finally {
+ ta?.remove();
+ if (previous && previous !== activeElementDeep() && typeof previous.focus === 'function') {
+ try { previous.focus({ preventScroll: true }); } catch { /* best effort */ }
+ }
+ }
+ }
+
function uiAppend(el) {
const uiRoot = liveUiRoot();
if (uiRoot === doc.body) return uiAppendToPage(el);
@@ -263,6 +301,7 @@
liveUiRoot,
uiAppend,
uiAppendToPage,
+ copyTextViaSelection,
topLayerHost,
watchModalDialogs,
cloneWithoutChrome,
diff --git a/.trae-cn/skills/impeccable/scripts/live-browser-session.js b/.trae-cn/skills/impeccable/scripts/live-browser-session.js
index ad9cdf008..388d2c2f9 100644
--- a/.trae-cn/skills/impeccable/scripts/live-browser-session.js
+++ b/.trae-cn/skills/impeccable/scripts/live-browser-session.js
@@ -8,10 +8,42 @@
(function (root) {
'use strict';
+ // crypto.randomUUID() exists only in secure contexts (HTTPS, localhost), so a
+ // dev site on a LAN IP, a Tailscale address, or a custom hostname over plain
+ // HTTP has no randomUUID at all (issue #1055). getRandomValues() is available
+ // in every context; Math.random() covers runtimes with no crypto. Live ids
+ // only have to be unique per session, not unguessable.
+ function randomUUID(cryptoImpl) {
+ const c = cryptoImpl === undefined ? root.crypto : cryptoImpl;
+ try {
+ if (c && typeof c.randomUUID === 'function') return c.randomUUID();
+ } catch { /* fall through to getRandomValues */ }
+ const bytes = new Uint8Array(16);
+ let filled = false;
+ try {
+ if (c && typeof c.getRandomValues === 'function') {
+ c.getRandomValues(bytes);
+ filled = true;
+ }
+ } catch { /* fall through to Math.random */ }
+ if (!filled) {
+ for (let i = 0; i < 16; i++) bytes[i] = Math.floor(Math.random() * 256);
+ }
+ bytes[6] = (bytes[6] & 0x0f) | 0x40; // version 4
+ bytes[8] = (bytes[8] & 0x3f) | 0x80; // RFC 4122 variant
+ const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, '0')).join('');
+ return hex.slice(0, 8) + '-' + hex.slice(8, 12) + '-' + hex.slice(12, 16)
+ + '-' + hex.slice(16, 20) + '-' + hex.slice(20);
+ }
+
+ function randomId8(cryptoImpl) {
+ return randomUUID(cryptoImpl).replace(/-/g, '').slice(0, 8);
+ }
+
function createLiveBrowserSessionState({ prefix, storage, idFactory }) {
if (!prefix) throw new Error('prefix required');
const store = storage || root.localStorage;
- const makeId = idFactory || function () { return Math.random().toString(16).slice(2, 10); };
+ const makeId = idFactory || function () { return randomId8(); };
const sessionKey = prefix + '-session';
const handledKey = sessionKey + '-handled';
const scrollKey = sessionKey + '-scroll';
@@ -144,5 +176,5 @@
};
}
- root.__IMPECCABLE_LIVE_SESSION__ = { createLiveBrowserSessionState };
+ root.__IMPECCABLE_LIVE_SESSION__ = { createLiveBrowserSessionState, randomUUID, randomId8 };
})(typeof window !== 'undefined' ? window : globalThis);
diff --git a/.trae-cn/skills/impeccable/scripts/live-browser.js b/.trae-cn/skills/impeccable/scripts/live-browser.js
index f706898e4..75abdf0c0 100644
--- a/.trae-cn/skills/impeccable/scripts/live-browser.js
+++ b/.trae-cn/skills/impeccable/scripts/live-browser.js
@@ -61,11 +61,19 @@
const IMPECCABLE_COMMAND = (window.__IMPECCABLE_COMMAND_PREFIX__ || '/') + 'impeccable';
const PICK_CURSOR_STYLE_ID = PREFIX + '-pick-cursor-style';
const MANUAL_APPLY_STATE_TTL_MS = 15 * 60 * 1000;
- const sessionState = window.__IMPECCABLE_LIVE_SESSION__?.createLiveBrowserSessionState({
- prefix: PREFIX,
- storage: localStorage,
- idFactory: () => crypto.randomUUID().replace(/-/g, '').slice(0, 8),
- });
+ // No idFactory: the session helper's default works on plain-HTTP origins,
+ // where the secure-context-only randomUUID does not exist (issue #1055).
+ let sessionState = null;
+ try {
+ sessionState = window.__IMPECCABLE_LIVE_SESSION__?.createLiveBrowserSessionState({
+ prefix: PREFIX,
+ storage: localStorage,
+ });
+ } catch (err) {
+ console.error('[impeccable] Live mode could not create its session state.', err);
+ window.__IMPECCABLE_LIVE_INIT__ = false; // let a later injection retry
+ return;
+ }
if (!sessionState) {
console.error('[impeccable] live-browser-session.js was not loaded. Live mode cannot start safely.');
window.__IMPECCABLE_LIVE_INIT__ = false;
@@ -293,6 +301,7 @@
liveUiRoot,
uiAppend,
uiAppendToPage,
+ copyTextViaSelection,
topLayerHost,
watchModalDialogs,
cloneWithoutChrome,
@@ -13466,12 +13475,24 @@ void main() {
.replace(/'/g, '&#39;');
}
+ // navigator.clipboard exists only in secure contexts, and writeText can
+ // reject even where it exists (no focus, permission). Fall back
+ // to the DOM helpers' selection copy (execCommand), which plain-HTTP origins
+ // still allow and which stays usable under an open modal dialog.
function copyToClipboard(text) {
if (!text) return;
+ const report = (ok) => showToast(ok ? 'Copied: ' + text : 'Could not copy: ' + text);
+ let pending = null;
try {
- navigator.clipboard.writeText(text);
- showToast('Copied: ' + text);
- } catch { /* ignore */ }
+ if (navigator.clipboard && typeof navigator.clipboard.writeText === 'function') {
+ pending = navigator.clipboard.writeText(text);
+ }
+ } catch { pending = null; }
+ if (pending && typeof pending.then === 'function') {
+ pending.then(() => report(true), () => report(copyTextViaSelection(text)));
+ return;
+ }
+ report(copyTextViaSelection(text));
}
//
diff --git a/.trae/skills/impeccable/reference/typeset.md b/.trae/skills/impeccable/reference/typeset.md
index d8e0cbf48..3fea44967 100644
--- a/.trae/skills/impeccable/reference/typeset.md
+++ b/.trae/skills/impeccable/reference/typeset.md
@@ -56,6 +56,16 @@ Use the fewest roles and families that make the hierarchy unmistakable. Combine
Do not make type decorative at the expense of comprehension, or introduce a second family without a clear role it alone can perform.
+## Line breaks
+
+After Matthew Butterick's *Practical Typography*, paraphrased; where his numbers differ from these, these stand.
+
+- Set `text-wrap: balance` on headings and short centered blocks, and `text-wrap: pretty` on body copy. Both are progressive: a browser that ignores them keeps its default wrap.
+- `pretty` pulls a word down beside a lone last word. It does not fill the last line, and a two-word tail is fine.
+- In a column too narrow for either to help, edit the copy or widen the column.
+- Break a heading by hand only between phrases, and check the break at every width the heading renders at. A hard break that lands mid-line on a phone is worse than the default wrap.
+- An uneven break can carry meaning: a headline that lands on one word for weight, a poster line, a pull quote. Make it deliberate with a hard break or a wrap set on that element, and keep it rare. The detector's `straggler` and `unbalanced-heading` findings are advisory for this reason; say which breaks are intended.
+
## Verify
- Primary, secondary, body, and metadata roles are recognizable without reading the copy.
diff --git a/.trae/skills/impeccable/scripts/live-browser-dom.js b/.trae/skills/impeccable/scripts/live-browser-dom.js
index 864694498..ef1ca8928 100644
--- a/.trae/skills/impeccable/scripts/live-browser-dom.js
+++ b/.trae/skills/impeccable/scripts/live-browser-dom.js
@@ -85,7 +85,16 @@
}
function id8() {
- if (crypto?.randomUUID) return crypto.randomUUID().replace(/-/g, '').slice(0, 8);
+ // randomUUID is secure-context only (issue #1055); getRandomValues is not.
+ try {
+ if (typeof crypto?.randomUUID === 'function') return crypto.randomUUID().replace(/-/g, '').slice(0, 8);
+ } catch { /* fall through */ }
+ try {
+ if (typeof crypto?.getRandomValues === 'function') {
+ const bytes = crypto.getRandomValues(new Uint8Array(4));
+ return Array.from(bytes, (b) => b.toString(16).padStart(2, '0')).join('');
+ }
+ } catch { /* fall through */ }
return (Math.random().toString(16).slice(2) + Date.now().toString(16)).slice(0, 8);
}
@@ -196,6 +205,35 @@
return el;
}
+ // Copy text through a selected textarea and execCommand, for origins where
+ // navigator.clipboard is missing or refused (plain HTTP, issue #1055).
+ // The textarea mounts like any page-level chrome, so while a modal
+ // <dialog> is open it sits in that dialog's top-layer host: on <body> it
+ // would be inert, and inert text cannot be selected or copied.
+ function copyTextViaSelection(text) {
+ let ta = null;
+ const previous = activeElementDeep();
+ try {
+ ta = doc.createElement('textarea');
+ ta.id = prefix + '-clipboard';
+ ta.value = text;
+ ta.setAttribute('readonly', '');
+ ta.setAttribute('aria-hidden', 'true');
+ ta.tabIndex = -1;
+ ta.style.cssText = 'position:fixed;top:0;left:0;width:1px;height:1px;opacity:0;pointer-events:none;';
+ uiAppendToPage(ta);
+ ta.select();
+ return doc.execCommand('copy');
+ } catch {
+ return false;
+ } finally {
+ ta?.remove();
+ if (previous && previous !== activeElementDeep() && typeof previous.focus === 'function') {
+ try { previous.focus({ preventScroll: true }); } catch { /* best effort */ }
+ }
+ }
+ }
+
function uiAppend(el) {
const uiRoot = liveUiRoot();
if (uiRoot === doc.body) return uiAppendToPage(el);
@@ -263,6 +301,7 @@
liveUiRoot,
uiAppend,
uiAppendToPage,
+ copyTextViaSelection,
topLayerHost,
watchModalDialogs,
cloneWithoutChrome,
diff --git a/.trae/skills/impeccable/scripts/live-browser-session.js b/.trae/skills/impeccable/scripts/live-browser-session.js
index ad9cdf008..388d2c2f9 100644
--- a/.trae/skills/impeccable/scripts/live-browser-session.js
+++ b/.trae/skills/impeccable/scripts/live-browser-session.js
@@ -8,10 +8,42 @@
(function (root) {
'use strict';
+ // crypto.randomUUID() exists only in secure contexts (HTTPS, localhost), so a
+ // dev site on a LAN IP, a Tailscale address, or a custom hostname over plain
+ // HTTP has no randomUUID at all (issue #1055). getRandomValues() is available
+ // in every context; Math.random() covers runtimes with no crypto. Live ids
+ // only have to be unique per session, not unguessable.
+ function randomUUID(cryptoImpl) {
+ const c = cryptoImpl === undefined ? root.crypto : cryptoImpl;
+ try {
+ if (c && typeof c.randomUUID === 'function') return c.randomUUID();
+ } catch { /* fall through to getRandomValues */ }
+ const bytes = new Uint8Array(16);
+ let filled = false;
+ try {
+ if (c && typeof c.getRandomValues === 'function') {
+ c.getRandomValues(bytes);
+ filled = true;
+ }
+ } catch { /* fall through to Math.random */ }
+ if (!filled) {
+ for (let i = 0; i < 16; i++) bytes[i] = Math.floor(Math.random() * 256);
+ }
+ bytes[6] = (bytes[6] & 0x0f) | 0x40; // version 4
+ bytes[8] = (bytes[8] & 0x3f) | 0x80; // RFC 4122 variant
+ const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, '0')).join('');
+ return hex.slice(0, 8) + '-' + hex.slice(8, 12) + '-' + hex.slice(12, 16)
+ + '-' + hex.slice(16, 20) + '-' + hex.slice(20);
+ }
+
+ function randomId8(cryptoImpl) {
+ return randomUUID(cryptoImpl).replace(/-/g, '').slice(0, 8);
+ }
+
function createLiveBrowserSessionState({ prefix, storage, idFactory }) {
if (!prefix) throw new Error('prefix required');
const store = storage || root.localStorage;
- const makeId = idFactory || function () { return Math.random().toString(16).slice(2, 10); };
+ const makeId = idFactory || function () { return randomId8(); };
const sessionKey = prefix + '-session';
const handledKey = sessionKey + '-handled';
const scrollKey = sessionKey + '-scroll';
@@ -144,5 +176,5 @@
};
}
- root.__IMPECCABLE_LIVE_SESSION__ = { createLiveBrowserSessionState };
+ root.__IMPECCABLE_LIVE_SESSION__ = { createLiveBrowserSessionState, randomUUID, randomId8 };
})(typeof window !== 'undefined' ? window : globalThis);
diff --git a/.trae/skills/impeccable/scripts/live-browser.js b/.trae/skills/impeccable/scripts/live-browser.js
index f706898e4..75abdf0c0 100644
--- a/.trae/skills/impeccable/scripts/live-browser.js
+++ b/.trae/skills/impeccable/scripts/live-browser.js
@@ -61,11 +61,19 @@
const IMPECCABLE_COMMAND = (window.__IMPECCABLE_COMMAND_PREFIX__ || '/') + 'impeccable';
const PICK_CURSOR_STYLE_ID = PREFIX + '-pick-cursor-style';
const MANUAL_APPLY_STATE_TTL_MS = 15 * 60 * 1000;
- const sessionState = window.__IMPECCABLE_LIVE_SESSION__?.createLiveBrowserSessionState({
- prefix: PREFIX,
- storage: localStorage,
- idFactory: () => crypto.randomUUID().replace(/-/g, '').slice(0, 8),
- });
+ // No idFactory: the session helper's default works on plain-HTTP origins,
+ // where the secure-context-only randomUUID does not exist (issue #1055).
+ let sessionState = null;
+ try {
+ sessionState = window.__IMPECCABLE_LIVE_SESSION__?.createLiveBrowserSessionState({
+ prefix: PREFIX,
+ storage: localStorage,
+ });
+ } catch (err) {
+ console.error('[impeccable] Live mode could not create its session state.', err);
+ window.__IMPECCABLE_LIVE_INIT__ = false; // let a later injection retry
+ return;
+ }
if (!sessionState) {
console.error('[impeccable] live-browser-session.js was not loaded. Live mode cannot start safely.');
window.__IMPECCABLE_LIVE_INIT__ = false;
@@ -293,6 +301,7 @@
liveUiRoot,
uiAppend,
uiAppendToPage,
+ copyTextViaSelection,
topLayerHost,
watchModalDialogs,
cloneWithoutChrome,
@@ -13466,12 +13475,24 @@ void main() {
.replace(/'/g, '&#39;');
}
+ // navigator.clipboard exists only in secure contexts, and writeText can
+ // reject even where it exists (no focus, permission). Fall back
+ // to the DOM helpers' selection copy (execCommand), which plain-HTTP origins
+ // still allow and which stays usable under an open modal dialog.
function copyToClipboard(text) {
if (!text) return;
+ const report = (ok) => showToast(ok ? 'Copied: ' + text : 'Could not copy: ' + text);
+ let pending = null;
try {
- navigator.clipboard.writeText(text);
- showToast('Copied: ' + text);
- } catch { /* ignore */ }
+ if (navigator.clipboard && typeof navigator.clipboard.writeText === 'function') {
+ pending = navigator.clipboard.writeText(text);
+ }
+ } catch { pending = null; }
+ if (pending && typeof pending.then === 'function') {
+ pending.then(() => report(true), () => report(copyTextViaSelection(text)));
+ return;
+ }
+ report(copyTextViaSelection(text));
}
//
diff --git a/.veto/skills/impeccable/reference/typeset.md b/.veto/skills/impeccable/reference/typeset.md
index 8676e40c8..147825fcd 100644
--- a/.veto/skills/impeccable/reference/typeset.md
+++ b/.veto/skills/impeccable/reference/typeset.md
@@ -56,6 +56,16 @@ Use the fewest roles and families that make the hierarchy unmistakable. Combine
Do not make type decorative at the expense of comprehension, or introduce a second family without a clear role it alone can perform.
+## Line breaks
+
+After Matthew Butterick's *Practical Typography*, paraphrased; where his numbers differ from these, these stand.
+
+- Set `text-wrap: balance` on headings and short centered blocks, and `text-wrap: pretty` on body copy. Both are progressive: a browser that ignores them keeps its default wrap.
+- `pretty` pulls a word down beside a lone last word. It does not fill the last line, and a two-word tail is fine.
+- In a column too narrow for either to help, edit the copy or widen the column.
+- Break a heading by hand only between phrases, and check the break at every width the heading renders at. A hard break that lands mid-line on a phone is worse than the default wrap.
+- An uneven break can carry meaning: a headline that lands on one word for weight, a poster line, a pull quote. Make it deliberate with a hard break or a wrap set on that element, and keep it rare. The detector's `straggler` and `unbalanced-heading` findings are advisory for this reason; say which breaks are intended.
+
## Verify
- Primary, secondary, body, and metadata roles are recognizable without reading the copy.
diff --git a/.veto/skills/impeccable/scripts/live-browser-dom.js b/.veto/skills/impeccable/scripts/live-browser-dom.js
index 864694498..ef1ca8928 100644
--- a/.veto/skills/impeccable/scripts/live-browser-dom.js
+++ b/.veto/skills/impeccable/scripts/live-browser-dom.js
@@ -85,7 +85,16 @@
}
function id8() {
- if (crypto?.randomUUID) return crypto.randomUUID().replace(/-/g, '').slice(0, 8);
+ // randomUUID is secure-context only (issue #1055); getRandomValues is not.
+ try {
+ if (typeof crypto?.randomUUID === 'function') return crypto.randomUUID().replace(/-/g, '').slice(0, 8);
+ } catch { /* fall through */ }
+ try {
+ if (typeof crypto?.getRandomValues === 'function') {
+ const bytes = crypto.getRandomValues(new Uint8Array(4));
+ return Array.from(bytes, (b) => b.toString(16).padStart(2, '0')).join('');
+ }
+ } catch { /* fall through */ }
return (Math.random().toString(16).slice(2) + Date.now().toString(16)).slice(0, 8);
}
@@ -196,6 +205,35 @@
return el;
}
+ // Copy text through a selected textarea and execCommand, for origins where
+ // navigator.clipboard is missing or refused (plain HTTP, issue #1055).
+ // The textarea mounts like any page-level chrome, so while a modal
+ // <dialog> is open it sits in that dialog's top-layer host: on <body> it
+ // would be inert, and inert text cannot be selected or copied.
+ function copyTextViaSelection(text) {
+ let ta = null;
+ const previous = activeElementDeep();
+ try {
+ ta = doc.createElement('textarea');
+ ta.id = prefix + '-clipboard';
+ ta.value = text;
+ ta.setAttribute('readonly', '');
+ ta.setAttribute('aria-hidden', 'true');
+ ta.tabIndex = -1;
+ ta.style.cssText = 'position:fixed;top:0;left:0;width:1px;height:1px;opacity:0;pointer-events:none;';
+ uiAppendToPage(ta);
+ ta.select();
+ return doc.execCommand('copy');
+ } catch {
+ return false;
+ } finally {
+ ta?.remove();
+ if (previous && previous !== activeElementDeep() && typeof previous.focus === 'function') {
+ try { previous.focus({ preventScroll: true }); } catch { /* best effort */ }
+ }
+ }
+ }
+
function uiAppend(el) {
const uiRoot = liveUiRoot();
if (uiRoot === doc.body) return uiAppendToPage(el);
@@ -263,6 +301,7 @@
liveUiRoot,
uiAppend,
uiAppendToPage,
+ copyTextViaSelection,
topLayerHost,
watchModalDialogs,
cloneWithoutChrome,
diff --git a/.veto/skills/impeccable/scripts/live-browser-session.js b/.veto/skills/impeccable/scripts/live-browser-session.js
index ad9cdf008..388d2c2f9 100644
--- a/.veto/skills/impeccable/scripts/live-browser-session.js
+++ b/.veto/skills/impeccable/scripts/live-browser-session.js
@@ -8,10 +8,42 @@
(function (root) {
'use strict';
+ // crypto.randomUUID() exists only in secure contexts (HTTPS, localhost), so a
+ // dev site on a LAN IP, a Tailscale address, or a custom hostname over plain
+ // HTTP has no randomUUID at all (issue #1055). getRandomValues() is available
+ // in every context; Math.random() covers runtimes with no crypto. Live ids
+ // only have to be unique per session, not unguessable.
+ function randomUUID(cryptoImpl) {
+ const c = cryptoImpl === undefined ? root.crypto : cryptoImpl;
+ try {
+ if (c && typeof c.randomUUID === 'function') return c.randomUUID();
+ } catch { /* fall through to getRandomValues */ }
+ const bytes = new Uint8Array(16);
+ let filled = false;
+ try {
+ if (c && typeof c.getRandomValues === 'function') {
+ c.getRandomValues(bytes);
+ filled = true;
+ }
+ } catch { /* fall through to Math.random */ }
+ if (!filled) {
+ for (let i = 0; i < 16; i++) bytes[i] = Math.floor(Math.random() * 256);
+ }
+ bytes[6] = (bytes[6] & 0x0f) | 0x40; // version 4
+ bytes[8] = (bytes[8] & 0x3f) | 0x80; // RFC 4122 variant
+ const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, '0')).join('');
+ return hex.slice(0, 8) + '-' + hex.slice(8, 12) + '-' + hex.slice(12, 16)
+ + '-' + hex.slice(16, 20) + '-' + hex.slice(20);
+ }
+
+ function randomId8(cryptoImpl) {
+ return randomUUID(cryptoImpl).replace(/-/g, '').slice(0, 8);
+ }
+
function createLiveBrowserSessionState({ prefix, storage, idFactory }) {
if (!prefix) throw new Error('prefix required');
const store = storage || root.localStorage;
- const makeId = idFactory || function () { return Math.random().toString(16).slice(2, 10); };
+ const makeId = idFactory || function () { return randomId8(); };
const sessionKey = prefix + '-session';
const handledKey = sessionKey + '-handled';
const scrollKey = sessionKey + '-scroll';
@@ -144,5 +176,5 @@
};
}
- root.__IMPECCABLE_LIVE_SESSION__ = { createLiveBrowserSessionState };
+ root.__IMPECCABLE_LIVE_SESSION__ = { createLiveBrowserSessionState, randomUUID, randomId8 };
})(typeof window !== 'undefined' ? window : globalThis);
diff --git a/.veto/skills/impeccable/scripts/live-browser.js b/.veto/skills/impeccable/scripts/live-browser.js
index f706898e4..75abdf0c0 100644
--- a/.veto/skills/impeccable/scripts/live-browser.js
+++ b/.veto/skills/impeccable/scripts/live-browser.js
@@ -61,11 +61,19 @@
const IMPECCABLE_COMMAND = (window.__IMPECCABLE_COMMAND_PREFIX__ || '/') + 'impeccable';
const PICK_CURSOR_STYLE_ID = PREFIX + '-pick-cursor-style';
const MANUAL_APPLY_STATE_TTL_MS = 15 * 60 * 1000;
- const sessionState = window.__IMPECCABLE_LIVE_SESSION__?.createLiveBrowserSessionState({
- prefix: PREFIX,
- storage: localStorage,
- idFactory: () => crypto.randomUUID().replace(/-/g, '').slice(0, 8),
- });
+ // No idFactory: the session helper's default works on plain-HTTP origins,
+ // where the secure-context-only randomUUID does not exist (issue #1055).
+ let sessionState = null;
+ try {
+ sessionState = window.__IMPECCABLE_LIVE_SESSION__?.createLiveBrowserSessionState({
+ prefix: PREFIX,
+ storage: localStorage,
+ });
+ } catch (err) {
+ console.error('[impeccable] Live mode could not create its session state.', err);
+ window.__IMPECCABLE_LIVE_INIT__ = false; // let a later injection retry
+ return;
+ }
if (!sessionState) {
console.error('[impeccable] live-browser-session.js was not loaded. Live mode cannot start safely.');
window.__IMPECCABLE_LIVE_INIT__ = false;
@@ -293,6 +301,7 @@
liveUiRoot,
uiAppend,
uiAppendToPage,
+ copyTextViaSelection,
topLayerHost,
watchModalDialogs,
cloneWithoutChrome,
@@ -13466,12 +13475,24 @@ void main() {
.replace(/'/g, '&#39;');
}
+ // navigator.clipboard exists only in secure contexts, and writeText can
+ // reject even where it exists (no focus, permission). Fall back
+ // to the DOM helpers' selection copy (execCommand), which plain-HTTP origins
+ // still allow and which stays usable under an open modal dialog.
function copyToClipboard(text) {
if (!text) return;
+ const report = (ok) => showToast(ok ? 'Copied: ' + text : 'Could not copy: ' + text);
+ let pending = null;
try {
- navigator.clipboard.writeText(text);
- showToast('Copied: ' + text);
- } catch { /* ignore */ }
+ if (navigator.clipboard && typeof navigator.clipboard.writeText === 'function') {
+ pending = navigator.clipboard.writeText(text);
+ }
+ } catch { pending = null; }
+ if (pending && typeof pending.then === 'function') {
+ pending.then(() => report(true), () => report(copyTextViaSelection(text)));
+ return;
+ }
+ report(copyTextViaSelection(text));
}
//
diff --git a/.vibe/skills/impeccable/reference/typeset.md b/.vibe/skills/impeccable/reference/typeset.md
index 52035e126..ddc8fa78b 100644
--- a/.vibe/skills/impeccable/reference/typeset.md
+++ b/.vibe/skills/impeccable/reference/typeset.md
@@ -56,6 +56,16 @@ Use the fewest roles and families that make the hierarchy unmistakable. Combine
Do not make type decorative at the expense of comprehension, or introduce a second family without a clear role it alone can perform.
+## Line breaks
+
+After Matthew Butterick's *Practical Typography*, paraphrased; where his numbers differ from these, these stand.
+
+- Set `text-wrap: balance` on headings and short centered blocks, and `text-wrap: pretty` on body copy. Both are progressive: a browser that ignores them keeps its default wrap.
+- `pretty` pulls a word down beside a lone last word. It does not fill the last line, and a two-word tail is fine.
+- In a column too narrow for either to help, edit the copy or widen the column.
+- Break a heading by hand only between phrases, and check the break at every width the heading renders at. A hard break that lands mid-line on a phone is worse than the default wrap.
+- An uneven break can carry meaning: a headline that lands on one word for weight, a poster line, a pull quote. Make it deliberate with a hard break or a wrap set on that element, and keep it rare. The detector's `straggler` and `unbalanced-heading` findings are advisory for this reason; say which breaks are intended.
+
## Verify
- Primary, secondary, body, and metadata roles are recognizable without reading the copy.
diff --git a/.vibe/skills/impeccable/scripts/live-browser-dom.js b/.vibe/skills/impeccable/scripts/live-browser-dom.js
index 864694498..ef1ca8928 100644
--- a/.vibe/skills/impeccable/scripts/live-browser-dom.js
+++ b/.vibe/skills/impeccable/scripts/live-browser-dom.js
@@ -85,7 +85,16 @@
}
function id8() {
- if (crypto?.randomUUID) return crypto.randomUUID().replace(/-/g, '').slice(0, 8);
+ // randomUUID is secure-context only (issue #1055); getRandomValues is not.
+ try {
+ if (typeof crypto?.randomUUID === 'function') return crypto.randomUUID().replace(/-/g, '').slice(0, 8);
+ } catch { /* fall through */ }
+ try {
+ if (typeof crypto?.getRandomValues === 'function') {
+ const bytes = crypto.getRandomValues(new Uint8Array(4));
+ return Array.from(bytes, (b) => b.toString(16).padStart(2, '0')).join('');
+ }
+ } catch { /* fall through */ }
return (Math.random().toString(16).slice(2) + Date.now().toString(16)).slice(0, 8);
}
@@ -196,6 +205,35 @@
return el;
}
+ // Copy text through a selected textarea and execCommand, for origins where
+ // navigator.clipboard is missing or refused (plain HTTP, issue #1055).
+ // The textarea mounts like any page-level chrome, so while a modal
+ // <dialog> is open it sits in that dialog's top-layer host: on <body> it
+ // would be inert, and inert text cannot be selected or copied.
+ function copyTextViaSelection(text) {
+ let ta = null;
+ const previous = activeElementDeep();
+ try {
+ ta = doc.createElement('textarea');
+ ta.id = prefix + '-clipboard';
+ ta.value = text;
+ ta.setAttribute('readonly', '');
+ ta.setAttribute('aria-hidden', 'true');
+ ta.tabIndex = -1;
+ ta.style.cssText = 'position:fixed;top:0;left:0;width:1px;height:1px;opacity:0;pointer-events:none;';
+ uiAppendToPage(ta);
+ ta.select();
+ return doc.execCommand('copy');
+ } catch {
+ return false;
+ } finally {
+ ta?.remove();
+ if (previous && previous !== activeElementDeep() && typeof previous.focus === 'function') {
+ try { previous.focus({ preventScroll: true }); } catch { /* best effort */ }
+ }
+ }
+ }
+
function uiAppend(el) {
const uiRoot = liveUiRoot();
if (uiRoot === doc.body) return uiAppendToPage(el);
@@ -263,6 +301,7 @@
liveUiRoot,
uiAppend,
uiAppendToPage,
+ copyTextViaSelection,
topLayerHost,
watchModalDialogs,
cloneWithoutChrome,
diff --git a/.vibe/skills/impeccable/scripts/live-browser-session.js b/.vibe/skills/impeccable/scripts/live-browser-session.js
index ad9cdf008..388d2c2f9 100644
--- a/.vibe/skills/impeccable/scripts/live-browser-session.js
+++ b/.vibe/skills/impeccable/scripts/live-browser-session.js
@@ -8,10 +8,42 @@
(function (root) {
'use strict';
+ // crypto.randomUUID() exists only in secure contexts (HTTPS, localhost), so a
+ // dev site on a LAN IP, a Tailscale address, or a custom hostname over plain
+ // HTTP has no randomUUID at all (issue #1055). getRandomValues() is available
+ // in every context; Math.random() covers runtimes with no crypto. Live ids
+ // only have to be unique per session, not unguessable.
+ function randomUUID(cryptoImpl) {
+ const c = cryptoImpl === undefined ? root.crypto : cryptoImpl;
+ try {
+ if (c && typeof c.randomUUID === 'function') return c.randomUUID();
+ } catch { /* fall through to getRandomValues */ }
+ const bytes = new Uint8Array(16);
+ let filled = false;
+ try {
+ if (c && typeof c.getRandomValues === 'function') {
+ c.getRandomValues(bytes);
+ filled = true;
+ }
+ } catch { /* fall through to Math.random */ }
+ if (!filled) {
+ for (let i = 0; i < 16; i++) bytes[i] = Math.floor(Math.random() * 256);
+ }
+ bytes[6] = (bytes[6] & 0x0f) | 0x40; // version 4
+ bytes[8] = (bytes[8] & 0x3f) | 0x80; // RFC 4122 variant
+ const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, '0')).join('');
+ return hex.slice(0, 8) + '-' + hex.slice(8, 12) + '-' + hex.slice(12, 16)
+ + '-' + hex.slice(16, 20) + '-' + hex.slice(20);
+ }
+
+ function randomId8(cryptoImpl) {
+ return randomUUID(cryptoImpl).replace(/-/g, '').slice(0, 8);
+ }
+
function createLiveBrowserSessionState({ prefix, storage, idFactory }) {
if (!prefix) throw new Error('prefix required');
const store = storage || root.localStorage;
- const makeId = idFactory || function () { return Math.random().toString(16).slice(2, 10); };
+ const makeId = idFactory || function () { return randomId8(); };
const sessionKey = prefix + '-session';
const handledKey = sessionKey + '-handled';
const scrollKey = sessionKey + '-scroll';
@@ -144,5 +176,5 @@
};
}
- root.__IMPECCABLE_LIVE_SESSION__ = { createLiveBrowserSessionState };
+ root.__IMPECCABLE_LIVE_SESSION__ = { createLiveBrowserSessionState, randomUUID, randomId8 };
})(typeof window !== 'undefined' ? window : globalThis);
diff --git a/.vibe/skills/impeccable/scripts/live-browser.js b/.vibe/skills/impeccable/scripts/live-browser.js
index f706898e4..75abdf0c0 100644
--- a/.vibe/skills/impeccable/scripts/live-browser.js
+++ b/.vibe/skills/impeccable/scripts/live-browser.js
@@ -61,11 +61,19 @@
const IMPECCABLE_COMMAND = (window.__IMPECCABLE_COMMAND_PREFIX__ || '/') + 'impeccable';
const PICK_CURSOR_STYLE_ID = PREFIX + '-pick-cursor-style';
const MANUAL_APPLY_STATE_TTL_MS = 15 * 60 * 1000;
- const sessionState = window.__IMPECCABLE_LIVE_SESSION__?.createLiveBrowserSessionState({
- prefix: PREFIX,
- storage: localStorage,
- idFactory: () => crypto.randomUUID().replace(/-/g, '').slice(0, 8),
- });
+ // No idFactory: the session helper's default works on plain-HTTP origins,
+ // where the secure-context-only randomUUID does not exist (issue #1055).
+ let sessionState = null;
+ try {
+ sessionState = window.__IMPECCABLE_LIVE_SESSION__?.createLiveBrowserSessionState({
+ prefix: PREFIX,
+ storage: localStorage,
+ });
+ } catch (err) {
+ console.error('[impeccable] Live mode could not create its session state.', err);
+ window.__IMPECCABLE_LIVE_INIT__ = false; // let a later injection retry
+ return;
+ }
if (!sessionState) {
console.error('[impeccable] live-browser-session.js was not loaded. Live mode cannot start safely.');
window.__IMPECCABLE_LIVE_INIT__ = false;
@@ -293,6 +301,7 @@
liveUiRoot,
uiAppend,
uiAppendToPage,
+ copyTextViaSelection,
topLayerHost,
watchModalDialogs,
cloneWithoutChrome,
@@ -13466,12 +13475,24 @@ void main() {
.replace(/'/g, '&#39;');
}
+ // navigator.clipboard exists only in secure contexts, and writeText can
+ // reject even where it exists (no focus, permission). Fall back
+ // to the DOM helpers' selection copy (execCommand), which plain-HTTP origins
+ // still allow and which stays usable under an open modal dialog.
function copyToClipboard(text) {
if (!text) return;
+ const report = (ok) => showToast(ok ? 'Copied: ' + text : 'Could not copy: ' + text);
+ let pending = null;
try {
- navigator.clipboard.writeText(text);
- showToast('Copied: ' + text);
- } catch { /* ignore */ }
+ if (navigator.clipboard && typeof navigator.clipboard.writeText === 'function') {
+ pending = navigator.clipboard.writeText(text);
+ }
+ } catch { pending = null; }
+ if (pending && typeof pending.then === 'function') {
+ pending.then(() => report(true), () => report(copyTextViaSelection(text)));
+ return;
+ }
+ report(copyTextViaSelection(text));
}
//
diff --git a/cursor-plugin/skills/impeccable/reference/typeset.md b/cursor-plugin/skills/impeccable/reference/typeset.md
index 60a5029d7..013ddbae3 100644
--- a/cursor-plugin/skills/impeccable/reference/typeset.md
+++ b/cursor-plugin/skills/impeccable/reference/typeset.md
@@ -56,6 +56,16 @@ Use the fewest roles and families that make the hierarchy unmistakable. Combine
Do not make type decorative at the expense of comprehension, or introduce a second family without a clear role it alone can perform.
+## Line breaks
+
+After Matthew Butterick's *Practical Typography*, paraphrased; where his numbers differ from these, these stand.
+
+- Set `text-wrap: balance` on headings and short centered blocks, and `text-wrap: pretty` on body copy. Both are progressive: a browser that ignores them keeps its default wrap.
+- `pretty` pulls a word down beside a lone last word. It does not fill the last line, and a two-word tail is fine.
+- In a column too narrow for either to help, edit the copy or widen the column.
+- Break a heading by hand only between phrases, and check the break at every width the heading renders at. A hard break that lands mid-line on a phone is worse than the default wrap.
+- An uneven break can carry meaning: a headline that lands on one word for weight, a poster line, a pull quote. Make it deliberate with a hard break or a wrap set on that element, and keep it rare. The detector's `straggler` and `unbalanced-heading` findings are advisory for this reason; say which breaks are intended.
+
## Verify
- Primary, secondary, body, and metadata roles are recognizable without reading the copy.
diff --git a/cursor-plugin/skills/impeccable/scripts/live-browser-dom.js b/cursor-plugin/skills/impeccable/scripts/live-browser-dom.js
index 864694498..ef1ca8928 100644
--- a/cursor-plugin/skills/impeccable/scripts/live-browser-dom.js
+++ b/cursor-plugin/skills/impeccable/scripts/live-browser-dom.js
@@ -85,7 +85,16 @@
}
function id8() {
- if (crypto?.randomUUID) return crypto.randomUUID().replace(/-/g, '').slice(0, 8);
+ // randomUUID is secure-context only (issue #1055); getRandomValues is not.
+ try {
+ if (typeof crypto?.randomUUID === 'function') return crypto.randomUUID().replace(/-/g, '').slice(0, 8);
+ } catch { /* fall through */ }
+ try {
+ if (typeof crypto?.getRandomValues === 'function') {
+ const bytes = crypto.getRandomValues(new Uint8Array(4));
+ return Array.from(bytes, (b) => b.toString(16).padStart(2, '0')).join('');
+ }
+ } catch { /* fall through */ }
return (Math.random().toString(16).slice(2) + Date.now().toString(16)).slice(0, 8);
}
@@ -196,6 +205,35 @@
return el;
}
+ // Copy text through a selected textarea and execCommand, for origins where
+ // navigator.clipboard is missing or refused (plain HTTP, issue #1055).
+ // The textarea mounts like any page-level chrome, so while a modal
+ // <dialog> is open it sits in that dialog's top-layer host: on <body> it
+ // would be inert, and inert text cannot be selected or copied.
+ function copyTextViaSelection(text) {
+ let ta = null;
+ const previous = activeElementDeep();
+ try {
+ ta = doc.createElement('textarea');
+ ta.id = prefix + '-clipboard';
+ ta.value = text;
+ ta.setAttribute('readonly', '');
+ ta.setAttribute('aria-hidden', 'true');
+ ta.tabIndex = -1;
+ ta.style.cssText = 'position:fixed;top:0;left:0;width:1px;height:1px;opacity:0;pointer-events:none;';
+ uiAppendToPage(ta);
+ ta.select();
+ return doc.execCommand('copy');
+ } catch {
+ return false;
+ } finally {
+ ta?.remove();
+ if (previous && previous !== activeElementDeep() && typeof previous.focus === 'function') {
+ try { previous.focus({ preventScroll: true }); } catch { /* best effort */ }
+ }
+ }
+ }
+
function uiAppend(el) {
const uiRoot = liveUiRoot();
if (uiRoot === doc.body) return uiAppendToPage(el);
@@ -263,6 +301,7 @@
liveUiRoot,
uiAppend,
uiAppendToPage,
+ copyTextViaSelection,
topLayerHost,
watchModalDialogs,
cloneWithoutChrome,
diff --git a/cursor-plugin/skills/impeccable/scripts/live-browser-session.js b/cursor-plugin/skills/impeccable/scripts/live-browser-session.js
index ad9cdf008..388d2c2f9 100644
--- a/cursor-plugin/skills/impeccable/scripts/live-browser-session.js
+++ b/cursor-plugin/skills/impeccable/scripts/live-browser-session.js
@@ -8,10 +8,42 @@
(function (root) {
'use strict';
+ // crypto.randomUUID() exists only in secure contexts (HTTPS, localhost), so a
+ // dev site on a LAN IP, a Tailscale address, or a custom hostname over plain
+ // HTTP has no randomUUID at all (issue #1055). getRandomValues() is available
+ // in every context; Math.random() covers runtimes with no crypto. Live ids
+ // only have to be unique per session, not unguessable.
+ function randomUUID(cryptoImpl) {
+ const c = cryptoImpl === undefined ? root.crypto : cryptoImpl;
+ try {
+ if (c && typeof c.randomUUID === 'function') return c.randomUUID();
+ } catch { /* fall through to getRandomValues */ }
+ const bytes = new Uint8Array(16);
+ let filled = false;
+ try {
+ if (c && typeof c.getRandomValues === 'function') {
+ c.getRandomValues(bytes);
+ filled = true;
+ }
+ } catch { /* fall through to Math.random */ }
+ if (!filled) {
+ for (let i = 0; i < 16; i++) bytes[i] = Math.floor(Math.random() * 256);
+ }
+ bytes[6] = (bytes[6] & 0x0f) | 0x40; // version 4
+ bytes[8] = (bytes[8] & 0x3f) | 0x80; // RFC 4122 variant
+ const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, '0')).join('');
+ return hex.slice(0, 8) + '-' + hex.slice(8, 12) + '-' + hex.slice(12, 16)
+ + '-' + hex.slice(16, 20) + '-' + hex.slice(20);
+ }
+
+ function randomId8(cryptoImpl) {
+ return randomUUID(cryptoImpl).replace(/-/g, '').slice(0, 8);
+ }
+
function createLiveBrowserSessionState({ prefix, storage, idFactory }) {
if (!prefix) throw new Error('prefix required');
const store = storage || root.localStorage;
- const makeId = idFactory || function () { return Math.random().toString(16).slice(2, 10); };
+ const makeId = idFactory || function () { return randomId8(); };
const sessionKey = prefix + '-session';
const handledKey = sessionKey + '-handled';
const scrollKey = sessionKey + '-scroll';
@@ -144,5 +176,5 @@
};
}
- root.__IMPECCABLE_LIVE_SESSION__ = { createLiveBrowserSessionState };
+ root.__IMPECCABLE_LIVE_SESSION__ = { createLiveBrowserSessionState, randomUUID, randomId8 };
})(typeof window !== 'undefined' ? window : globalThis);
diff --git a/cursor-plugin/skills/impeccable/scripts/live-browser.js b/cursor-plugin/skills/impeccable/scripts/live-browser.js
index f706898e4..75abdf0c0 100644
--- a/cursor-plugin/skills/impeccable/scripts/live-browser.js
+++ b/cursor-plugin/skills/impeccable/scripts/live-browser.js
@@ -61,11 +61,19 @@
const IMPECCABLE_COMMAND = (window.__IMPECCABLE_COMMAND_PREFIX__ || '/') + 'impeccable';
const PICK_CURSOR_STYLE_ID = PREFIX + '-pick-cursor-style';
const MANUAL_APPLY_STATE_TTL_MS = 15 * 60 * 1000;
- const sessionState = window.__IMPECCABLE_LIVE_SESSION__?.createLiveBrowserSessionState({
- prefix: PREFIX,
- storage: localStorage,
- idFactory: () => crypto.randomUUID().replace(/-/g, '').slice(0, 8),
- });
+ // No idFactory: the session helper's default works on plain-HTTP origins,
+ // where the secure-context-only randomUUID does not exist (issue #1055).
+ let sessionState = null;
+ try {
+ sessionState = window.__IMPECCABLE_LIVE_SESSION__?.createLiveBrowserSessionState({
+ prefix: PREFIX,
+ storage: localStorage,
+ });
+ } catch (err) {
+ console.error('[impeccable] Live mode could not create its session state.', err);
+ window.__IMPECCABLE_LIVE_INIT__ = false; // let a later injection retry
+ return;
+ }
if (!sessionState) {
console.error('[impeccable] live-browser-session.js was not loaded. Live mode cannot start safely.');
window.__IMPECCABLE_LIVE_INIT__ = false;
@@ -293,6 +301,7 @@
liveUiRoot,
uiAppend,
uiAppendToPage,
+ copyTextViaSelection,
topLayerHost,
watchModalDialogs,
cloneWithoutChrome,
@@ -13466,12 +13475,24 @@ void main() {
.replace(/'/g, '&#39;');
}
+ // navigator.clipboard exists only in secure contexts, and writeText can
+ // reject even where it exists (no focus, permission). Fall back
+ // to the DOM helpers' selection copy (execCommand), which plain-HTTP origins
+ // still allow and which stays usable under an open modal dialog.
function copyToClipboard(text) {
if (!text) return;
+ const report = (ok) => showToast(ok ? 'Copied: ' + text : 'Could not copy: ' + text);
+ let pending = null;
try {
- navigator.clipboard.writeText(text);
- showToast('Copied: ' + text);
- } catch { /* ignore */ }
+ if (navigator.clipboard && typeof navigator.clipboard.writeText === 'function') {
+ pending = navigator.clipboard.writeText(text);
+ }
+ } catch { pending = null; }
+ if (pending && typeof pending.then === 'function') {
+ pending.then(() => report(true), () => report(copyTextViaSelection(text)));
+ return;
+ }
+ report(copyTextViaSelection(text));
}
//
diff --git a/plugin/skills/impeccable/reference/typeset.md b/plugin/skills/impeccable/reference/typeset.md
index 60a5029d7..013ddbae3 100644
--- a/plugin/skills/impeccable/reference/typeset.md
+++ b/plugin/skills/impeccable/reference/typeset.md
@@ -56,6 +56,16 @@ Use the fewest roles and families that make the hierarchy unmistakable. Combine
Do not make type decorative at the expense of comprehension, or introduce a second family without a clear role it alone can perform.
+## Line breaks
+
+After Matthew Butterick's *Practical Typography*, paraphrased; where his numbers differ from these, these stand.
+
+- Set `text-wrap: balance` on headings and short centered blocks, and `text-wrap: pretty` on body copy. Both are progressive: a browser that ignores them keeps its default wrap.
+- `pretty` pulls a word down beside a lone last word. It does not fill the last line, and a two-word tail is fine.
+- In a column too narrow for either to help, edit the copy or widen the column.
+- Break a heading by hand only between phrases, and check the break at every width the heading renders at. A hard break that lands mid-line on a phone is worse than the default wrap.
+- An uneven break can carry meaning: a headline that lands on one word for weight, a poster line, a pull quote. Make it deliberate with a hard break or a wrap set on that element, and keep it rare. The detector's `straggler` and `unbalanced-heading` findings are advisory for this reason; say which breaks are intended.
+
## Verify
- Primary, secondary, body, and metadata roles are recognizable without reading the copy.
diff --git a/plugin/skills/impeccable/scripts/live-browser-dom.js b/plugin/skills/impeccable/scripts/live-browser-dom.js
index 864694498..ef1ca8928 100644
--- a/plugin/skills/impeccable/scripts/live-browser-dom.js
+++ b/plugin/skills/impeccable/scripts/live-browser-dom.js
@@ -85,7 +85,16 @@
}
function id8() {
- if (crypto?.randomUUID) return crypto.randomUUID().replace(/-/g, '').slice(0, 8);
+ // randomUUID is secure-context only (issue #1055); getRandomValues is not.
+ try {
+ if (typeof crypto?.randomUUID === 'function') return crypto.randomUUID().replace(/-/g, '').slice(0, 8);
+ } catch { /* fall through */ }
+ try {
+ if (typeof crypto?.getRandomValues === 'function') {
+ const bytes = crypto.getRandomValues(new Uint8Array(4));
+ return Array.from(bytes, (b) => b.toString(16).padStart(2, '0')).join('');
+ }
+ } catch { /* fall through */ }
return (Math.random().toString(16).slice(2) + Date.now().toString(16)).slice(0, 8);
}
@@ -196,6 +205,35 @@
return el;
}
+ // Copy text through a selected textarea and execCommand, for origins where
+ // navigator.clipboard is missing or refused (plain HTTP, issue #1055).
+ // The textarea mounts like any page-level chrome, so while a modal
+ // <dialog> is open it sits in that dialog's top-layer host: on <body> it
+ // would be inert, and inert text cannot be selected or copied.
+ function copyTextViaSelection(text) {
+ let ta = null;
+ const previous = activeElementDeep();
+ try {
+ ta = doc.createElement('textarea');
+ ta.id = prefix + '-clipboard';
+ ta.value = text;
+ ta.setAttribute('readonly', '');
+ ta.setAttribute('aria-hidden', 'true');
+ ta.tabIndex = -1;
+ ta.style.cssText = 'position:fixed;top:0;left:0;width:1px;height:1px;opacity:0;pointer-events:none;';
+ uiAppendToPage(ta);
+ ta.select();
+ return doc.execCommand('copy');
+ } catch {
+ return false;
+ } finally {
+ ta?.remove();
+ if (previous && previous !== activeElementDeep() && typeof previous.focus === 'function') {
+ try { previous.focus({ preventScroll: true }); } catch { /* best effort */ }
+ }
+ }
+ }
+
function uiAppend(el) {
const uiRoot = liveUiRoot();
if (uiRoot === doc.body) return uiAppendToPage(el);
@@ -263,6 +301,7 @@
liveUiRoot,
uiAppend,
uiAppendToPage,
+ copyTextViaSelection,
topLayerHost,
watchModalDialogs,
cloneWithoutChrome,
diff --git a/plugin/skills/impeccable/scripts/live-browser-session.js b/plugin/skills/impeccable/scripts/live-browser-session.js
index ad9cdf008..388d2c2f9 100644
--- a/plugin/skills/impeccable/scripts/live-browser-session.js
+++ b/plugin/skills/impeccable/scripts/live-browser-session.js
@@ -8,10 +8,42 @@
(function (root) {
'use strict';
+ // crypto.randomUUID() exists only in secure contexts (HTTPS, localhost), so a
+ // dev site on a LAN IP, a Tailscale address, or a custom hostname over plain
+ // HTTP has no randomUUID at all (issue #1055). getRandomValues() is available
+ // in every context; Math.random() covers runtimes with no crypto. Live ids
+ // only have to be unique per session, not unguessable.
+ function randomUUID(cryptoImpl) {
+ const c = cryptoImpl === undefined ? root.crypto : cryptoImpl;
+ try {
+ if (c && typeof c.randomUUID === 'function') return c.randomUUID();
+ } catch { /* fall through to getRandomValues */ }
+ const bytes = new Uint8Array(16);
+ let filled = false;
+ try {
+ if (c && typeof c.getRandomValues === 'function') {
+ c.getRandomValues(bytes);
+ filled = true;
+ }
+ } catch { /* fall through to Math.random */ }
+ if (!filled) {
+ for (let i = 0; i < 16; i++) bytes[i] = Math.floor(Math.random() * 256);
+ }
+ bytes[6] = (bytes[6] & 0x0f) | 0x40; // version 4
+ bytes[8] = (bytes[8] & 0x3f) | 0x80; // RFC 4122 variant
+ const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, '0')).join('');
+ return hex.slice(0, 8) + '-' + hex.slice(8, 12) + '-' + hex.slice(12, 16)
+ + '-' + hex.slice(16, 20) + '-' + hex.slice(20);
+ }
+
+ function randomId8(cryptoImpl) {
+ return randomUUID(cryptoImpl).replace(/-/g, '').slice(0, 8);
+ }
+
function createLiveBrowserSessionState({ prefix, storage, idFactory }) {
if (!prefix) throw new Error('prefix required');
const store = storage || root.localStorage;
- const makeId = idFactory || function () { return Math.random().toString(16).slice(2, 10); };
+ const makeId = idFactory || function () { return randomId8(); };
const sessionKey = prefix + '-session';
const handledKey = sessionKey + '-handled';
const scrollKey = sessionKey + '-scroll';
@@ -144,5 +176,5 @@
};
}
- root.__IMPECCABLE_LIVE_SESSION__ = { createLiveBrowserSessionState };
+ root.__IMPECCABLE_LIVE_SESSION__ = { createLiveBrowserSessionState, randomUUID, randomId8 };
})(typeof window !== 'undefined' ? window : globalThis);
diff --git a/plugin/skills/impeccable/scripts/live-browser.js b/plugin/skills/impeccable/scripts/live-browser.js
index f706898e4..75abdf0c0 100644
--- a/plugin/skills/impeccable/scripts/live-browser.js
+++ b/plugin/skills/impeccable/scripts/live-browser.js
@@ -61,11 +61,19 @@
const IMPECCABLE_COMMAND = (window.__IMPECCABLE_COMMAND_PREFIX__ || '/') + 'impeccable';
const PICK_CURSOR_STYLE_ID = PREFIX + '-pick-cursor-style';
const MANUAL_APPLY_STATE_TTL_MS = 15 * 60 * 1000;
- const sessionState = window.__IMPECCABLE_LIVE_SESSION__?.createLiveBrowserSessionState({
- prefix: PREFIX,
- storage: localStorage,
- idFactory: () => crypto.randomUUID().replace(/-/g, '').slice(0, 8),
- });
+ // No idFactory: the session helper's default works on plain-HTTP origins,
+ // where the secure-context-only randomUUID does not exist (issue #1055).
+ let sessionState = null;
+ try {
+ sessionState = window.__IMPECCABLE_LIVE_SESSION__?.createLiveBrowserSessionState({
+ prefix: PREFIX,
+ storage: localStorage,
+ });
+ } catch (err) {
+ console.error('[impeccable] Live mode could not create its session state.', err);
+ window.__IMPECCABLE_LIVE_INIT__ = false; // let a later injection retry
+ return;
+ }
if (!sessionState) {
console.error('[impeccable] live-browser-session.js was not loaded. Live mode cannot start safely.');
window.__IMPECCABLE_LIVE_INIT__ = false;
@@ -293,6 +301,7 @@
liveUiRoot,
uiAppend,
uiAppendToPage,
+ copyTextViaSelection,
topLayerHost,
watchModalDialogs,
cloneWithoutChrome,
@@ -13466,12 +13475,24 @@ void main() {
.replace(/'/g, '&#39;');
}
+ // navigator.clipboard exists only in secure contexts, and writeText can
+ // reject even where it exists (no focus, permission). Fall back
+ // to the DOM helpers' selection copy (execCommand), which plain-HTTP origins
+ // still allow and which stays usable under an open modal dialog.
function copyToClipboard(text) {
if (!text) return;
+ const report = (ok) => showToast(ok ? 'Copied: ' + text : 'Could not copy: ' + text);
+ let pending = null;
try {
- navigator.clipboard.writeText(text);
- showToast('Copied: ' + text);
- } catch { /* ignore */ }
+ if (navigator.clipboard && typeof navigator.clipboard.writeText === 'function') {
+ pending = navigator.clipboard.writeText(text);
+ }
+ } catch { pending = null; }
+ if (pending && typeof pending.then === 'function') {
+ pending.then(() => report(true), () => report(copyTextViaSelection(text)));
+ return;
+ }
+ report(copyTextViaSelection(text));
}
//