Autonomous development for real products. Governed agents build from specs you approve, follow the rules you set, and nothing merges until another agent proves it. Your decisions, judgement and taste are the bar that work must clear. Declare your vision and let agents build it.
JavaScript agentic-codingai-agentsai-governanceautonomous-agentsclaude-codeclicode-reviewcodexcoding-agentsdeveloper-toolsgit-hooksllmlocal-firstmulti-agentsoftware-factoryspec-driven-developmentverificationvibe-coding
fix(view): a short code chip stays whole at a line end [N26]
Corey Olson4f0eb8abcdb5
diff --git a/src/cockpit.js b/src/cockpit.jsindex 047cdfa5..49713d57 100644--- a/src/cockpit.js+++ b/src/cockpit.js@@ -191,6 +191,8 @@ function theme(pick) {}theme(keep('pb.theme'));const esc = (text) => String(text ?? '').replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[c]);+// Inline code: a short chip stays whole on its line; one longer than a phone line's worth may wrap.+const codeChip = (text) => '<code class="inline' + (String(text).length > 24 ? ' long' : '') + '">' + esc(text) + '</code>';const ago = (iso) => { const m = Math.round((Date.now() - Date.parse(iso)) / 60000); return m < 1 ? 'now' : m < 60 ? m + 'm' : m < 2880 ? Math.round(m / 60) + 'h' : Math.round(m / 1440) + 'd'; };// An age as the page shows it: the moment it counts from stays on it, so tickAges can move it on.const age = (iso) => '<time data-ago="' + esc(iso) + '">' + ago(iso) + '</time>';@@ -810,7 +812,7 @@ function renderSide() {* @returns {string}*/function linked(text, titles, allowLinks = true) { return String(text ?? '').split(/(#\\d+|(?<![^\\s([{"'\`])[^\\s:@()[\\]{}"'\`]+:\\d+(?:-\\d+)?@[0-9a-f]{7,40}(?![^\\s)\\]}"'\`.,;:!?]))/).map((part, n, parts) => {- if (n % 2 && part[0] !== '#') return allowLinks ? codeRef(part, parts.slice(0, n).join('').split('\\n').pop().slice(-2000)) : '<code class="inline">' + esc(part) + '</code>';+ if (n % 2 && part[0] !== '#') return allowLinks ? codeRef(part, parts.slice(0, n).join('').split('\\n').pop().slice(-2000)) : codeChip(part);const id = /^#\\d+$/.test(part) ? String(Number(part.slice(1))) : '';return titles.has(id) && allowLinks ? '<button class="ref" data-go="item:' + id + '" title="' + esc(titles.get(id)) + '" type="button">' + esc(part) + '</button>' : esc(part);}).join(''); }@@ -821,7 +823,7 @@ function renderSide() {* @returns {string}*/function inline(text, titles, allowLinks = true) { return String(text ?? '').split(/(\`[^\`]*\`|[^\\s:@()[\\]{}"'\`]+:\\d+(?:-\\d+)?@[0-9a-f]{7,40}|pullboard(?:\\s+\\w+)+|--[\\w-]+|(?:\\/|\\.\\.?\\/|[\\w.-]+\\/)\\w[\\w./-]*\\.[A-Za-z0-9]+|\\b[0-9a-fA-F]{7,40}\\b|#\\d+)/g).map((part, n, parts) => {- if (part.startsWith('\`') && part.endsWith('\`')) return '<code class="inline">' + esc(part.slice(1, -1)) + '</code>';+ if (part.startsWith('\`') && part.endsWith('\`')) return codeChip(part.slice(1, -1));if (part.includes('@') && part.includes(':')) {const textBefore = parts.slice(0, n).join('');const fullText = parts.join('');@@ -830,9 +832,9 @@ function renderSide() {const rightBoundary = !after || [9, 10, 32, 41, 93, 125, 34, 39, 96, 46, 44, 59, 58, 33, 63].includes(after.charCodeAt(0));const validRef = leftBoundary && rightBoundary;if (allowLinks && validRef) return codeRef(part, textBefore.slice(-2000));- return '<code class="inline">' + esc(part) + '</code>';+ return codeChip(part);}- if (/^(?:pullboard(?:\\s+\\w+)+|--[\\w-]+|(?:\\/|\\.\\.?\\/|[\\w.-]+\\/)\\w[\\w./-]*\\.[A-Za-z0-9]+|\\b[0-9a-fA-F]{7,40}\\b)$/.test(part)) return '<code class="inline">' + esc(part) + '</code>';+ if (/^(?:pullboard(?:\\s+\\w+)+|--[\\w-]+|(?:\\/|\\.\\.?\\/|[\\w.-]+\\/)\\w[\\w./-]*\\.[A-Za-z0-9]+|\\b[0-9a-fA-F]{7,40}\\b)$/.test(part)) return codeChip(part);return linked(part, titles, allowLinks);}).join(''); }/** Render inline text and fenced or shell command blocks with escaped contents.diff --git a/src/view.css b/src/view.cssindex 1b3299d1..8dc6f264 100644--- a/src/view.css+++ b/src/view.css@@ -262,7 +262,8 @@ form.inline { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; paddin.feed .day { margin: 0; padding: 12px 0 4px; font: 600 11px/1 var(--mono); letter-spacing: .07em; text-transform: uppercase; color: var(--ink-faint); }.feed .day:first-child { padding-top: 6px; }button.ref { width: auto; min-height: 0; border: 0; border-radius: 0; background: none; padding: 0; color: var(--accent-strong); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; display: inline; vertical-align: baseline; line-height: inherit; font: inherit; }-code.inline { padding: 0 3px; border-radius: 3px; background: color-mix(in srgb, var(--ink) 8%, var(--surface)); font: .92em var(--mono); white-space: break-spaces; }+code.inline { padding: 0 3px; border-radius: 3px; background: color-mix(in srgb, var(--ink) 8%, var(--surface)); font: .92em var(--mono); white-space: nowrap; }+code.inline.long { white-space: break-spaces; overflow-wrap: anywhere; }.code { display: block; margin: 6px 0 2px; padding: 6px 0; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); font: 12px/1.55 var(--mono); white-space: pre; overflow-x: auto; overflow-wrap: normal; }.code > span { display: block; padding-right: 12px; }.code i { display: inline-block; min-width: 3.2em; padding: 0 10px 0 6px; text-align: right; font-style: normal; color: var(--ink-faint); user-select: none; }diff --git a/test/cockpit.test.js b/test/cockpit.test.jsindex 50bed301..15d98cec 100644--- a/test/cockpit.test.js+++ b/test/cockpit.test.js@@ -3700,6 +3700,54 @@ test('static export redacts structured checkout paths but preserves paths people}});+test('a short code chip at a line end stays whole, and long code still wraps inside the screen [N26]', { timeout: 90_000 }, async (t) => {+ const executable = chromeExecutable();+ if (!executable) return t.skip('Install Chrome or set PULLBOARD_CHROME for code chip checks.');++ const box = machine();+ const demo = project(box, 'chip-ends');+ const long = 'docs/a/very/long/path/that/keeps/going/well/past/any/phone/screen/width.md';+ box.run(demo.repo, 'shout', 'all', `Pass the --flag option, then read ${long} before you submit.`);+ const view = await startView(box);+ const profile = mkdtempSync(join(tmpdir(), 'pullboard-chip-end-chrome-'));+ let chrome;+ try {+ chrome = await openSnapshotChrome(executable, view.link.href, profile);+ await chrome.waitFor('!!document.querySelector(\'[data-tab="shouts"]\')');+ await chrome.evaluate('document.querySelector(\'[data-tab="shouts"]\').click()');+ await chrome.waitFor(`[...document.querySelectorAll('#feed code.inline')].some((code) => code.textContent === ${JSON.stringify(long)})`);+ for (const width of [375, 1280]) {+ await chrome.send('Emulation.setDeviceMetricsOverride', { width, height: 900, deviceScaleFactor: 1, mobile: false });+ await chrome.waitFor(`innerWidth === ${width}`);+ const seen = JSON.parse(await chrome.evaluate(`JSON.stringify((() => {+ const chips = [...document.querySelectorAll('#feed code.inline')];+ const flag = chips.find((code) => code.textContent === '--flag'), path = chips.find((code) => code.textContent === ${JSON.stringify(long)});+ const text = flag.parentElement.closest('div');+ // Long code wraps where the fonts put it, and stays inside the screen.+ const pathRects = [...path.getClientRects()];+ const longCode = { fragments: pathRects.length, right: Math.max(...pathRects.map((r) => r.right)), screen: document.documentElement.clientWidth,+ overflow: document.documentElement.scrollWidth > document.documentElement.clientWidth };+ // Then end the chip's line three pixels inside the chip, whatever this machine's fonts measure.+ const start = text.getBoundingClientRect().left, end = flag.getBoundingClientRect().right;+ text.style.width = (end - start - 3) + 'px';+ const rects = [...flag.getClientRects()], line = end - start - 3;+ const atEnd = { fragments: rects.length, display: getComputedStyle(flag).display, width: Math.max(...rects.map((r) => r.width)), line };+ text.style.width = '';+ return { atEnd, longCode };+ })())`));+ assert.equal(seen.atEnd.fragments, 1, `${width}: a short chip at a line's end moves to the next line whole, never broken after its "--": ${JSON.stringify(seen)}`);+ assert.equal(seen.atEnd.display, 'inline', `${width}: and it is still inline code, not a bar`);+ assert.ok(seen.atEnd.width < seen.atEnd.line / 2, `${width}: and compact: ${JSON.stringify(seen.atEnd)}`);+ if (width === 375) assert.ok(seen.longCode.fragments > 1, `${width}: code longer than its line wraps: ${JSON.stringify(seen.longCode)}`);+ assert.ok(seen.longCode.right <= seen.longCode.screen + 0.5 && !seen.longCode.overflow, `${width}: and never runs past the screen: ${JSON.stringify(seen.longCode)}`);+ }+ } finally {+ if (chrome) await closeSnapshotChrome(chrome);+ rmSync(profile, { recursive: true, force: true });+ await view.stop();+ }+});+test('real Chrome styles shout code and item text without growing linked lines [N26]', { timeout: 120_000 }, async (t) => {const executable = chromeExecutable();if (!executable) return t.skip('Install Chrome or set PULLBOARD_CHROME for rendered shout checks.');@@ -3799,14 +3847,14 @@ test('real Chrome styles shout code and item text without growing linked lines [assert.match(rendered.shoutHtml, /<code class="inline">pullboard shout<\/code>/, 'pullboard commands are inline code');assert.match(rendered.shoutHtml, /<code class="inline">--decision<\/code>/, 'flags are inline code');assert.match(rendered.shoutHtml, /<code class="inline">src\/cockpit\.js<\/code>/, 'slash paths are inline code');- assert.match(rendered.shoutHtml, /<code class="inline">0123456789abcdef0123456789abcdef01234567<\/code>/, 'hex SHAs are inline code');+ assert.match(rendered.shoutHtml, /<code class="inline long">0123456789abcdef0123456789abcdef01234567<\/code>/, 'hex SHAs are inline code, long enough to wrap');assert.ok((rendered.shoutHtml.match(/<code class="code block">/g) ?? []).length >= 2, 'fences and dollar-prefixed lines are code blocks');assert.match(rendered.shoutHtml, /<code class="code block">\$ pullboard claim 1<\/code>/, 'the shell prompt stays visible in command blocks');assert.match(rendered.shoutHtml, /<script>alert\(1\)<\/script>/, 'script text is escaped inside code');assert.equal(rendered.shoutScripts, 0, 'a shout cannot create a script element');assert.match(rendered.outsideHtml, /<script>alert\(2\)<\/script> outside code/, 'script text outside code is escaped too');assert.equal(rendered.previewLinks, 1, 'only a path:lines@SHA reference with the original whole-word boundaries becomes an actionable preview');- assert.match(rendered.shoutHtml, /Invalid prefix:<code class="inline">SPEC\.md:1-2@/, 'a path:lines@SHA suffix after a colon stays plain inline code');+ assert.match(rendered.shoutHtml, /Invalid prefix:<code class="inline long">SPEC\.md:1-2@/, 'a path:lines@SHA suffix after a colon stays plain inline code');await chrome.evaluate(`document.querySelector('#feed button[data-code^="SPEC.md:1-2@"]').click()`);await chrome.waitFor(`document.querySelector('#feed button[data-code^="SPEC.md:1-2@"]').getAttribute('aria-expanded') === 'true'`);await chrome.waitFor(`document.querySelector('#feed button[data-code^="SPEC.md:1-2@"] + .code')?.textContent.includes('Demo spec')`);