ODS V3 Pre-Release: Public testing and refinement ahead of the official V3 launch. Turn your PC, Mac, or Linux box into a private AI server.
Python ai-agentsamdcomfyuidockerllama-cppllmlocal-ain8nnvidiaopen-webuiragself-hostedspeech-to-textstrix-halotext-to-speechworkflow-automation
fix(portal): no error-looking text after a build that published a preview (#8190)
Mike Bradleyc62ceaced181
diff --git a/ods/extensions/services/dashboard/src/components/PortalStreamingText.jsx b/ods/extensions/services/dashboard/src/components/PortalStreamingText.jsxindex e516462a3..0ecc30692 100644--- a/ods/extensions/services/dashboard/src/components/PortalStreamingText.jsx+++ b/ods/extensions/services/dashboard/src/components/PortalStreamingText.jsx@@ -6,17 +6,22 @@ import PortalInlineCitation from './PortalInlineCitation'import {useMemo,useLayoutEffect} from 'react'import {useResponseReveal} from '../lib/useResponseReveal'import {EMBED_NOTES} from '../lib/embedDisplay'+import {DELIVERY_NOTES} from '../lib/portalDeliveryNotes'import {parseDeliveredArtifacts} from '../lib/pixelDeliveredArtifacts'import {suppressDeliveredMediaLines} from '../lib/deliveredMediaDisplay'-// Portal's own note, in its own paragraph where an embed it can't display-// was, reads as a muted aside rather than as the model's words.-function muteEmbedNotes() {+// Portal's own notes, each in a paragraph of its own (a reply of embeds it+// can't display, or its line about a preview after the reply), read as muted+// asides rather than as the model's words. Never an alert.+const NOTE_CLASSES=new Map([...EMBED_NOTES.map(note=>[note,'portal-embed-note']),+ ...DELIVERY_NOTES.map(note=>[note,'portal-delivery-note'])])+function mutePortalNotes() {return tree=>{function visit(node) {for(const child of node.children || []) {const text=child.tagName==='p' && child.children.length===1 && child.children[0]- if(text?.type==='text' && EMBED_NOTES.includes(text.value)) child.properties={...child.properties,className:['portal-embed-note']}+ const className=text?.type==='text' && NOTE_CLASSES.get(text.value)+ if(className) child.properties={...child.properties,className:[className]}else visit(child)}}@@ -97,7 +102,7 @@ function markDocumentDownloads() {visit(tree)}}-const PLUGINS=[rehypeHighlight,muteEmbedNotes,markDocumentDownloads,revealNewText]+const PLUGINS=[rehypeHighlight,mutePortalNotes,markDocumentDownloads,revealNewText]export default function PortalStreamingText({children, active=false, animate=active, instant=false, onReveal, components=EMPTY_COMPONENTS, artifacts=null}) {const fullSource=String(children ?? '')// Once a completed answer has verified files, show its complete Markdown.@@ -108,7 +113,7 @@ export default function PortalStreamingText({children, active=false, animate=actconst source=useResponseReveal(fullSource,{animate,instant:instant || delivered})const revealing=source!==fullSourceconst plugins=useMemo(()=>delivered && !revealing- ? [rehypeHighlight,muteEmbedNotes,markDocumentDownloads,[suppressDeliveredMediaLines,{source,artifacts}],revealNewText]+ ? [rehypeHighlight,mutePortalNotes,markDocumentDownloads,[suppressDeliveredMediaLines,{source,artifacts}],revealNewText]: PLUGINS,[delivered,revealing,source,artifacts])useLayoutEffect(()=>{onReveal?.()},[source,onReveal])const renderers=useMemo(()=>({...components,a:props=><PortalInlineCitation {...props} artifacts={artifacts}/>,span:StreamSpan}),[components,artifacts])diff --git a/ods/extensions/services/dashboard/src/components/PortalStreamingText.test.jsx b/ods/extensions/services/dashboard/src/components/PortalStreamingText.test.jsxindex 028b20bb7..c24a17113 100644--- a/ods/extensions/services/dashboard/src/components/PortalStreamingText.test.jsx+++ b/ods/extensions/services/dashboard/src/components/PortalStreamingText.test.jsx@@ -1,6 +1,7 @@import {act,render,screen} from '@testing-library/react'import PortalStreamingText from './PortalStreamingText'-import {EMBED_NOTE,EMBED_ONLY_NOTE} from '../lib/embedDisplay'+import {EMBED_ONLY_NOTE} from '../lib/embedDisplay'+import {DELIVERY_NOTES} from '../lib/portalDeliveryNotes'const mediaReceipt=(digit='a')=>({schemaVersion:1,kind:'ods-pixel-workspace-artifact',relativePath:'report.csv',siteId:`site-${digit.repeat(24)}`,sha256:digit.repeat(64),file:{path:'report.csv',bytes:37,sha256:'c'.repeat(64)}})@@ -178,12 +179,23 @@ it('does not replay delivered prose when a publication receipt is stripped',()=>expect(container.firstChild).toHaveAttribute('aria-busy','false')})it('mutes only paragraphs that are exactly a Portal note about an embed it cannot display',()=>{- const source=`Before\n\n${EMBED_NOTE}\n\n- Item\n\n ${EMBED_ONLY_NOTE}\n\nThe model wrote ${EMBED_NOTE} inline.\n\n\`\`\`\n${EMBED_NOTE}\n\`\`\``+ const source=`Before\n\n${EMBED_ONLY_NOTE}\n\n- Item\n\n ${EMBED_ONLY_NOTE}\n\nThe model wrote ${EMBED_ONLY_NOTE} inline.\n\n\`\`\`\n${EMBED_ONLY_NOTE}\n\`\`\``const {container}=render(<PortalStreamingText>{source}</PortalStreamingText>)const muted=[...container.querySelectorAll('.portal-embed-note')].map(element=>[element.tagName,element.textContent])- expect(muted).toEqual([['P',EMBED_NOTE],['P',EMBED_ONLY_NOTE]])+ expect(muted).toEqual([['P',EMBED_ONLY_NOTE],['P',EMBED_ONLY_NOTE]])expect(screen.getByText('Before').closest('p')).not.toHaveClass('portal-embed-note')- expect(container.querySelector('pre code')).toHaveTextContent(EMBED_NOTE)+ expect(container.querySelector('pre code')).toHaveTextContent(EMBED_ONLY_NOTE)+})++// RTX Spark, 2026-10-25: a working preview was followed only by alarming+// check text. Portal's line after a reply is a muted paragraph of its own.+it.each(DELIVERY_NOTES)('mutes Portal\'s own line about a preview: %s',note=>{+ const {container}=render(<PortalStreamingText>{`The arena draws again.\n\n${note}\n\nThe model wrote ${note} inline.`}</PortalStreamingText>)+ const muted=[...container.querySelectorAll('.portal-delivery-note')]+ expect(muted.map(element=>[element.tagName,element.textContent])).toEqual([['P',note]])+ expect(screen.getByText('The arena draws again.').closest('p')).not.toHaveClass('portal-delivery-note')+ expect(container.querySelector('[role="alert"]')).toBeNull()+ expect(container.querySelector('svg')).toBeNull()})it('renders a document download image label as text before a receipt arrives',()=>{diff --git a/ods/extensions/services/dashboard/src/components/PortalSubagents.test.jsx b/ods/extensions/services/dashboard/src/components/PortalSubagents.test.jsxindex c5e02e5f7..991f750f3 100644--- a/ods/extensions/services/dashboard/src/components/PortalSubagents.test.jsx+++ b/ods/extensions/services/dashboard/src/components/PortalSubagents.test.jsx@@ -1,7 +1,7 @@import {useState} from 'react'import {act,fireEvent,render,screen,waitFor,within} from '@testing-library/react'import PortalSubagents from './PortalSubagents'-import {EMBED_NOTE,EMBED_ONLY_NOTE} from '../lib/embedDisplay'+import {EMBED_ONLY_NOTE} from '../lib/embedDisplay'const first = 'a'.repeat(32), second = 'b'.repeat(32)const worker = (id,name,status,extra={}) => ({id,name,status,turn:0,task:`${name} assignment`,conversation:[],...extra})@@ -120,7 +120,7 @@ it('renders safe Markdown, copies exact response text, places approvals with theexpect(screen.getByRole('button',{name:'Review requested action'})).toBeVisible()})-it('shows notes instead of embeds Portal cannot display and copies the original reply',async()=>{+it('shows a note instead of a reply of embeds Portal cannot display, leaves other embeds out and copies the original reply',async()=>{const reply='[embed ref="cv_456e4732d60d4117b731214838589d22" height="320"]'const output='Status:\n[embed url="/__openclaw__/canvas/documents/cv_123/index.html" height="320" /]'const writeText=vi.fn().mockResolvedValue(undefined)@@ -128,9 +128,9 @@ it('shows notes instead of embeds Portal cannot display and copies the originalconst teams=[team(first,'One assignment','completed',[worker('0','Builder','completed',{conversation:[{role:'user',content:'One assignment'},{role:'assistant',content:reply}],output})])]render(<Fixture teams={teams}/>)expect(screen.getByText(EMBED_ONLY_NOTE).closest('p')).toHaveClass('portal-embed-note')- expect(screen.getByText(EMBED_NOTE).closest('p')).toHaveClass('portal-embed-note')+ expect(screen.getAllByText(EMBED_ONLY_NOTE)).toHaveLength(1)expect(screen.getByText('Status:')).toBeVisible()- expect(screen.queryByText(/\[embed/)).toBeNull()+ expect(screen.queryByText(/\[embed|can’t display it/)).toBeNull()fireEvent.click(screen.getAllByRole('button',{name:'Copy response'})[0])await waitFor(()=>expect(writeText).toHaveBeenCalledExactlyOnceWith(reply))})diff --git a/ods/extensions/services/dashboard/src/components/portal-agent-experience.css b/ods/extensions/services/dashboard/src/components/portal-agent-experience.cssindex 81692da84..caffa7610 100644--- a/ods/extensions/services/dashboard/src/components/portal-agent-experience.css+++ b/ods/extensions/services/dashboard/src/components/portal-agent-experience.css@@ -41,6 +41,7 @@@media (prefers-reduced-motion:reduce) { .portal-stream-reveal { animation:none; } }.portal-streaming-text { min-width:0; overflow-wrap:anywhere; }.portal-streaming-text .portal-embed-note { color:rgb(var(--theme-text-muted)); }+.portal-streaming-text .portal-delivery-note { color:rgb(var(--theme-text-muted)); font-size:12px; line-height:18px; }.portal-stream-cursor { display:inline-block; width:5px; height:13px; margin:4px 3px 0; border-radius:3px; background:currentColor; animation:portal-silver-pulse 1.3s ease-in-out infinite; }.portal-citation { position:relative; }.portal-citation > a { color:rgb(var(--theme-text)); text-decoration:underline; text-decoration-color:rgb(var(--theme-text-muted) / .5); text-underline-offset:3px; }diff --git a/ods/extensions/services/dashboard/src/lib/embedDisplay.js b/ods/extensions/services/dashboard/src/lib/embedDisplay.jsindex ab2b26b81..e4f8e825f 100644--- a/ods/extensions/services/dashboard/src/lib/embedDisplay.js+++ b/ods/extensions/services/dashboard/src/lib/embedDisplay.js@@ -2,12 +2,14 @@// embed directives such as [embed ref="cv_123" title="Status" height="320" /]// or [embed url="/__openclaw__/canvas/..." /]. Portal displays none of them:// conversation text never becomes a URL, link, iframe, download or file-// selection. A delivered file's own directive is resolved before this by-// deliveredArtifactDisplayText. Presentation only: stored chat, model history-// and the copy button keep the reply's original text.-export const EMBED_NOTE = '(An embedded view was left out: Portal can’t display it.)'+// selection. A directive line is left out of the shown reply, without a note.+// Seen live: a dragon picture's reply ended with [embed ref="site-..." /] for+// the very site its preview card was showing, so a note saying Portal can't+// display it read as an error and was false. A delivered file's own directive+// is resolved before this by deliveredArtifactDisplayText. Presentation only:+// stored chat, model history and the copy button keep the reply's original text.export const EMBED_ONLY_NOTE = 'This reply tried to show an embedded view, which Portal can’t display. Ask again for a plain-text answer.'-export const EMBED_NOTES = [EMBED_NOTE, EMBED_ONLY_NOTE]+export const EMBED_NOTES = [EMBED_ONLY_NOTE]const VALUE = String.raw`(?:"[^"\r\n]*"|'[^'\r\n]*'|[^\s"'\]]+)`// A line holding only one directive, in any attribute order or quoting, with or@@ -17,15 +19,20 @@ const DIRECTIVE = new RegExp(String.raw`^ {0,3}\[embed(?:\s+[\w:.-]+\s*=\s*${VAL// The unfinished last line of a streaming reply that may still become one.const UNFINISHED = /^ {0,3}\[(?:e(?:m(?:b(?:e(?:d(?:\s[^\]\r\n]*)?)?)?)?)?)?$/iconst FENCE = /^ {0,3}(`{3,}|~{3,})([^\n]*)$/+// The workspace preview a directive names, as ref="site-<24 hex>".+const SITE_REF = /\sref\s*=\s*["']?(site-[a-f0-9]{24})(?![\w-])/i-// Replaces each stand-alone directive line outside fenced code with a note in-// its own paragraph, and a reply of nothing but directives with one note.-// While streaming, a reply of only directives shows nothing yet and an-// unfinished last line is held back, so the shown text only ever grows.-export function embedDisplayText(content, { streaming = false } = {}) {+// Leaves out each stand-alone directive line outside fenced code; an empty line+// in its place keeps the paragraphs around it apart. A reply of nothing but+// directives shows nothing when its message shows something else (`shown`: a+// preview card or delivered files) or each names a preview the chat shows+// (`shownSite`), and one note otherwise. While streaming, such a reply shows+// nothing yet and an unfinished last line is held back, so the shown text only+// ever grows.+export function embedDisplayText(content, { streaming = false, shown = false, shownSite = () => false } = {}) {if (typeof content !== 'string' || !/^ {0,3}\[/m.test(content)) return contentconst lines = content.split('\n')- const shown = []+ const kept = [], sites = []let fence = null, changed = false, other = falsefor (const [index, line] of lines.entries()) {const text = line.endsWith('\r') ? line.slice(0, -1) : line@@ -35,18 +42,19 @@ export function embedDisplayText(content, { streaming = false } = {}) {} else if (marker && !(marker[1][0] === '`' && marker[2].includes('`'))) {fence = marker[1]} else if (DIRECTIVE.test(text)) {- shown.push('', /^ */.exec(text)[0] + EMBED_NOTE, '')+ kept.push('')+ sites.push(SITE_REF.exec(text)?.[1])changed = truecontinue} else if (streaming && index === lines.length - 1 && UNFINISHED.test(text)) {- shown.push('')+ kept.push('')changed = truecontinue}- shown.push(line)+ kept.push(line)other ||= text.trim() !== ''}if (!changed) return content- if (!other) return streaming ? '' : EMBED_ONLY_NOTE- return shown.join('\n')+ if (!other) return streaming || shown || sites.every(site => site && shownSite(site)) ? '' : EMBED_ONLY_NOTE+ return kept.join('\n')}diff --git a/ods/extensions/services/dashboard/src/lib/embedDisplay.test.js b/ods/extensions/services/dashboard/src/lib/embedDisplay.test.jsindex 8fdeb3eb1..67960b445 100644--- a/ods/extensions/services/dashboard/src/lib/embedDisplay.test.js+++ b/ods/extensions/services/dashboard/src/lib/embedDisplay.test.js@@ -1,28 +1,61 @@-import { EMBED_NOTE, EMBED_ONLY_NOTE, embedDisplayText } from './embedDisplay'+import { EMBED_ONLY_NOTE, embedDisplayText } from './embedDisplay'import { deliveredArtifactDisplayText, parseDeliveredArtifacts } from './pixelDeliveredArtifacts'// The whole reply a fleet test showed verbatim (Qwen3.5-4B, 2026-10-18).const FLEET = '[embed ref="cv_456e4732d60d4117b731214838589d22" height="320"]'// The hosted canvas form OpenClaw's webchat prompt teaches.const CANVAS = '[embed url="/__openclaw__/canvas/documents/cv_123/index.html" title="Status" height="320" /]'+// RTX Spark, 2026-10-25: "Draw me a picture of a dragon" published an SVG site+// that the preview card showed, and the reply ended with an embed of that site.+const DRAGON = '[embed ref="site-fca81965eeec4e16e761822a" title="Dragon" height="560" /]'const paragraphs = text => text.split(/\n\s*\n/).map(part => part.trim()).filter(Boolean)-it('shows a note instead of a reply that is only an embed Portal cannot display', () => {+it('shows a note instead of a reply that is only an embed Portal cannot display, unless something else shows', () => {expect(embedDisplayText(FLEET)).toBe(EMBED_ONLY_NOTE)expect(embedDisplayText(`${FLEET}\n`)).toBe(EMBED_ONLY_NOTE)expect(embedDisplayText(`\n${FLEET}\n\n${CANVAS}\r\n`)).toBe(EMBED_ONLY_NOTE)+ // A preview card or delivered files show with the message: nothing to explain.+ expect(embedDisplayText(FLEET, { shown: true })).toBe('')+ expect(embedDisplayText(`\n${FLEET}\n\n${CANVAS}\r\n`, { shown: true })).toBe('')})-it('keeps the prose around an embed and leaves a note in its place', () => {+it('keeps the prose around an embed and leaves the embed out, without a note', () => {expect(embedDisplayText(`Here is the result:\n${FLEET}\nThe image shows a red circle.`))- .toBe(`Here is the result:\n\n${EMBED_NOTE}\n\nThe image shows a red circle.`)+ .toBe('Here is the result:\n\nThe image shows a red circle.')const shown = embedDisplayText(`Status:\n\n${CANVAS}\n\nDone.\n\n${FLEET}`)- expect(paragraphs(shown)).toEqual(['Status:', EMBED_NOTE, 'Done.', EMBED_NOTE])+ expect(paragraphs(shown)).toEqual(['Status:', 'Done.'])expect(shown).not.toContain('[embed')+ expect(shown).not.toContain('Portal')+})++it('leaves the run\'s own preview embed out under its card, and shows nothing for a reply of only that embed', () => {+ const reply = `Here is your dragon, curled around a mountain peak.\n\n${DRAGON}`+ for (const options of [{ shown: true }, {}, { streaming: true, shown: true }])+ expect(paragraphs(embedDisplayText(reply, options))).toEqual(['Here is your dragon, curled around a mountain peak.'])+ expect(embedDisplayText(DRAGON, { shown: true })).toBe('')+ expect(embedDisplayText(`${DRAGON}\n${CANVAS}`, { shown: true })).toBe('')+ expect(embedDisplayText(DRAGON, { streaming: true })).toBe('')+ // Nothing else shows: say why the reply is empty.+ expect(embedDisplayText(DRAGON)).toBe(EMBED_ONLY_NOTE)+})++it('shows nothing for a reply of only embeds of previews the chat already shows, and the note otherwise', () => {+ const seen = []+ const shownSite = site => (seen.push(site), site === 'site-fca81965eeec4e16e761822a')+ expect(embedDisplayText(DRAGON, { shownSite })).toBe('')+ expect(embedDisplayText(`${DRAGON}\n[embed ref='site-fca81965eeec4e16e761822a' /]`, { shownSite })).toBe('')+ expect(seen).toEqual(['site-fca81965eeec4e16e761822a', 'site-fca81965eeec4e16e761822a', 'site-fca81965eeec4e16e761822a'])+ // Another preview, a canvas, or a site id that only starts like one: the chat does not show it.+ for (const other of ['[embed ref="site-000000000000000000000000" /]', CANVAS, FLEET,+ '[embed ref="site-fca81965eeec4e16e761822a0" /]', `${DRAGON}\n${FLEET}`])+ expect(embedDisplayText(other, { shownSite })).toBe(EMBED_ONLY_NOTE)+ // Prose around them is shown as written either way, without the embed.+ expect(embedDisplayText(`Your dragon again:\n${DRAGON}`, { shownSite })).toBe('Your dragon again:\n')})it.each([CANVAS,+ DRAGON,'[embed ref="cv_123" title="Status" height="320" /]','[embed height="320" ref="cv_123"]',"[embed ref='cv_123' height='320' /]",@@ -32,13 +65,14 @@ it.each([' [embed ref="cv_123" /] ','[embed url="https://example.com/chart" /]',`[embed ref="artifact_${'c'.repeat(64)}" title="report.md" height="480" /]`,-])('treats %s as an embed Portal cannot display', line => {+])('treats %s as an embed Portal does not display', line => {expect(embedDisplayText(line)).toBe(EMBED_ONLY_NOTE)- expect(paragraphs(embedDisplayText(`Before\r\n${line}\r\nAfter`))).toEqual(['Before', EMBED_NOTE, 'After'])+ expect(embedDisplayText(line, { shown: true })).toBe('')+ expect(paragraphs(embedDisplayText(`Before\r\n${line}\r\nAfter`))).toEqual(['Before', 'After'])})-it('keeps a list item\'s embed note inside the item', () => {- expect(embedDisplayText(`1. Status\n ${FLEET}\n2. Next`)).toBe(`1. Status\n\n ${EMBED_NOTE}\n\n2. Next`)+it('keeps the list around a left-out embed', () => {+ expect(embedDisplayText(`1. Status\n ${FLEET}\n2. Next`)).toBe('1. Status\n\n2. Next')})it('leaves embed syntax in code untouched', () => {@@ -54,8 +88,9 @@ it('leaves embed syntax in code untouched', () => {]) {expect(embedDisplayText(content)).toBe(content)expect(embedDisplayText(content, { streaming: true })).toBe(content)+ expect(embedDisplayText(content, { shown: true })).toBe(content)}- expect(paragraphs(embedDisplayText('```\ncode\n```\n' + FLEET))).toEqual(['```\ncode\n```', EMBED_NOTE])+ expect(paragraphs(embedDisplayText('```\ncode\n```\n' + FLEET))).toEqual(['```\ncode\n```'])})it('leaves other bracketed text and inline mentions as written', () => {@@ -84,6 +119,9 @@ it('leaves a delivered file\'s exact directive to its receipt check', () => {expect(embedDisplayText(deliveredArtifactDisplayText(directive, artifacts))).toBe('')// Without a matching receipt it is one more embed Portal cannot display.expect(embedDisplayText(deliveredArtifactDisplayText(directive, []))).toBe(EMBED_ONLY_NOTE)+ // Beside the delivered files' own cards, an embed after prose needs no note either.+ expect(embedDisplayText(deliveredArtifactDisplayText(`Your report:\n${directive}`, artifacts), { shown: true }))+ .toBe('Your report:\n')// The receipt arrives with the end of the stream: show nothing until then.expect(embedDisplayText(directive, { streaming: true })).toBe('')})@@ -102,21 +140,27 @@ it.each([`${FLEET}\nThe image shows a red circle.`,`${CANVAS}\n${FLEET}`,`Two views:\n${CANVAS}\n${FLEET}\nThat is all.`,+ `Here is your dragon.\n\n${DRAGON}`,])('never shows directive text while %j streams, and the shown text only grows', reply => {- let previous = ''- for (let end = 1; end <= reply.length; end++) {- const shown = embedDisplayText(reply.slice(0, end), { streaming: true })- expect(shown).not.toContain('[')- expect(shown.startsWith(previous)).toBe(true)- previous = shown+ for (const shown of [false, true]) {+ let previous = ''+ for (let end = 1; end <= reply.length; end++) {+ const text = embedDisplayText(reply.slice(0, end), { streaming: true, shown })+ expect(text).not.toContain('[')+ expect(text.startsWith(previous)).toBe(true)+ previous = text+ }+ expect(embedDisplayText(reply, { shown }).startsWith(previous)).toBe(true)}- expect(embedDisplayText(reply).startsWith(previous)).toBe(true)})it('stays linear on long lines that only look like an embed or a fence', () => {// Quadratic backtracking would take minutes on these, far past the test timeout.const spaces = ' '.repeat(200000)- for (const content of [`[embed a=b${spaces}x]`, `[embed a=x/${spaces}y]`, '`'.repeat(200000) + '\u2028\n' + FLEET])+ for (const content of [`[embed a=b${spaces}x]`, `[embed a=x/${spaces}y]`, '`'.repeat(200000) + ' \n' + FLEET])expect(embedDisplayText(content)).toBe(content)expect(embedDisplayText(`[embed a=b${spaces}/]`)).toBe(EMBED_ONLY_NOTE)+ // Reading a directive's preview ref stays linear too.+ expect(embedDisplayText(`[embed ref=${spaces}x a=b /]`, { shownSite: () => true })).toBe(EMBED_ONLY_NOTE)+ expect(embedDisplayText(`[embed${' ref=x'.repeat(50000)} /]`, { shownSite: () => true })).toBe(EMBED_ONLY_NOTE)})diff --git a/ods/extensions/services/dashboard/src/lib/portalDeliveryNotes.js b/ods/extensions/services/dashboard/src/lib/portalDeliveryNotes.jsnew file mode 100644index 000000000..cf5d24806--- /dev/null+++ b/ods/extensions/services/dashboard/src/lib/portalDeliveryNotes.js@@ -0,0 +1,18 @@+// Portal's own one-line notes about a reply's preview: what its checks could+// not confirm, a page that broke while it tested it, an earlier version, a+// step that has not started, or a preview it could not publish. Each is a+// paragraph of its own after the reply, shown muted and never as an alert.+// The pixel-agent plugin writes them (plugin/preview-explanation.mjs and+// tool-loop-guard.mjs); its tests keep this list equal to the plugin's.+export const DELIVERY_NOTES = Object.freeze([+ "Portal couldn't test every control automatically. Try it, and tell Portal if something isn't right.",+ "Portal couldn't confirm everything automatically. Have a look, and tell Portal if something isn't right.",+ "Portal's checks were still running when it replied. Have a look, and tell Portal if something isn't right.",+ 'The page ran into a script problem while Portal was testing it, so parts of it may not work yet. Ask Portal to fix it.',+ "The page doesn't match everything you asked for yet. Ask Portal to fix it.",+ "This preview shows the version from before Portal's latest changes. Ask Portal to publish the current files.",+ 'Portal stopped before it finished, so this preview shows an earlier version. Send a message to continue.',+ "The next step above hasn't started yet. Send a message to continue.",+ "Portal saved the website files in your workspace but couldn't publish a preview of them, so they haven't been checked and there is no preview to open yet. Ask Portal to publish the preview.",+ "Portal didn't create the website files for this request, so there is no preview to open yet. Ask Portal to try the build again.",+])diff --git a/ods/extensions/services/dashboard/src/lib/publicationDisplay.test.js b/ods/extensions/services/dashboard/src/lib/publicationDisplay.test.jsindex c5ed707d4..240a441e9 100644--- a/ods/extensions/services/dashboard/src/lib/publicationDisplay.test.js+++ b/ods/extensions/services/dashboard/src/lib/publicationDisplay.test.js@@ -70,15 +70,11 @@ it('keeps host-authored storage scope while removing the preview receipt', () =>expect(publicationDisplayText(`${model}\n\n${storage}\n\n${receipt}`, publication)).toBe(`${model}\n\n${storage}`)})-// A failed preview check keeps the agent's own explanation ahead of the host-// note (pixel-agent preview-explanation.mjs); only the receipt becomes the card.-it('keeps a kept agent explanation and the failed-check note while removing the receipt', () => {+// A failed preview check keeps the agent's own explanation ahead of Portal's+// line (pixel-agent preview-explanation.mjs); only the receipt becomes the card.+it('keeps a kept agent explanation and Portal\'s line while removing the receipt', () => {const failedReceipt = `Your preview is ready.\n\n${link}\n\nPublished from your workspace.`- const note = "**Portal check:** The reply above is the agent's own account, not a verified result. " +- "This request did not pass Portal's checks.\n\n" +- 'Latest browser inspection of this preview: step 2 (assert-painted) on `#arena` captured one color only (#8fce3a).\n\n' +- 'The attempted preview interaction checks have not passed browser inspection. ' +- 'The published preview is available, but those checks remain unverified.'+ const note = "Portal couldn't test every control automatically. Try it, and tell Portal if something isn't right."const explanation = 'The cause is `ui.js:748`: a canvas is not a valid `fillStyle`.\n\n- The last full-viewport fill covers the arena.'expect(publicationDisplayText(`${explanation}\n\n${note}\n\n${failedReceipt}`, publication)).toBe(`${explanation}\n\n${note}`)// The plugin closes a code block the agent left open with that block's owndiff --git a/ods/extensions/services/dashboard/src/pages/Pixel.jsx b/ods/extensions/services/dashboard/src/pages/Pixel.jsxindex 71a722b17..6737eede2 100644--- a/ods/extensions/services/dashboard/src/pages/Pixel.jsx+++ b/ods/extensions/services/dashboard/src/pages/Pixel.jsx@@ -2036,9 +2036,13 @@ export default function Pixel({ systemStatus = null }) {const publicationContent=message.role==='assistant' ? publicationDisplayText(message.content,message.publication) : message.contentconst displayedContent=message.role==='assistant' && message.status==='done'? deliveredArtifactDisplayText(publicationContent,message.artifacts) : publicationContent- // Notes replace embeds Portal can't display; Copy keeps the reply's own text.+ // Embeds Portal can't display are left out; a reply of only embeds gets+ // a note unless a preview card or delivered files show, or the chat+ // already shows each preview it names. Copy keeps the reply's own text.const shownContent=message.role==='assistant'- ? embedDisplayText(displayedContent,{streaming:message.status==='streaming'}) : displayedContent+ ? embedDisplayText(displayedContent,{streaming:message.status==='streaming',+ shown:Boolean(message.publication || deliveredArtifactMetadata(message).artifacts),+ shownSite:siteId=>siteId===preview?.siteId || messages.some(item=>item.publication?.siteId===siteId)}) : displayedContentreturn (<div key={index} data-pixel-message-index={index} tabIndex={-1} data-pixel-response={message.role === 'assistant' ? '' : undefined} className={`mx-auto flex min-w-0 w-full max-w-5xl ${message.role === 'user' ? 'justify-end gap-2' : 'justify-start'}`}>{message.role === 'assistant' && <PixelMascot state={pixelReplyPose(message, sending && index === messages.length - 1)} settled={message.status !== 'streaming'} className="pixel-reply-character" />}diff --git a/ods/extensions/services/dashboard/src/pages/Pixel.test.jsx b/ods/extensions/services/dashboard/src/pages/Pixel.test.jsxindex f3b1c302c..ad092a212 100644--- a/ods/extensions/services/dashboard/src/pages/Pixel.test.jsx+++ b/ods/extensions/services/dashboard/src/pages/Pixel.test.jsx@@ -1166,9 +1166,10 @@ describe('Pixel', () => {expect(send).toBeEnabled()})- // RTX Spark Elf of Doom: a failed preview check now keeps the agent's own- // explanation ahead of Portal's note instead of replacing it.- it('renders a kept agent explanation and the failed-check note as Markdown with the preview card', async () => {+ // RTX Spark Elf of Doom: a failed preview check keeps the agent's own+ // explanation, and (2026-10-25) Portal's line after it is one calm, muted+ // sentence above a preview that works, never error-looking text.+ it('renders a kept agent explanation as Markdown, then Portal\'s muted line, with the preview card', async () => {const matchMedia = globalThis.matchMediavi.stubGlobal('matchMedia', query => query === '(prefers-reduced-motion: reduce)'? { matches: true, addEventListener: vi.fn(), removeEventListener: vi.fn() }@@ -1178,13 +1179,10 @@ describe('Pixel', () => {const preview = {schemaVersion: 1, kind: 'ods-pixel-workspace-preview', relativeDirectory: 'elf-of-doom', siteId, port: 9437,url: `http://${siteId}.localhost:9437/${siteId}/`, files: 3, bytes: 4096, sha256, entrySha256: 'd'.repeat(64)}previewManifests.set(`/pixel-preview/${siteId}/__ods_manifest__.json`, preview)+ const note = "Portal couldn't test every control automatically. Try it, and tell Portal if something isn't right."const content = 'The cause is `ui.js:748`: a canvas is not a valid `fillStyle`, so the previous colour stays set.\n\n' +'- The last full-viewport fill covers the arena.\n\n' +- "**Portal check:** The reply above is the agent's own account, not a verified result. " +- "This request did not pass Portal's checks.\n\n" +- 'Latest browser inspection of this preview: step 2 (assert-painted) on `#arena` captured one color only (#8fce3a).\n\n' +- 'The attempted preview interaction checks have not passed browser inspection. ' +- 'The published preview is available, but those checks remain unverified.\n\n' ++ `${note}\n\n` +`Your preview is ready.\n\n[Open preview](${preview.url})\n\nPublished from your workspace.`globalThis.fetch.mockResolvedValueOnce(response({ available: true, model: 'pixel/default', detail: 'local' }))globalThis.fetch.mockResolvedValueOnce(sseResponse([@@ -1193,27 +1191,115 @@ describe('Pixel', () => {pixel_outcome: { schemaVersion: 1, status: 'failed' } }),'[DONE]',]))- render(<Pixel />)+ const {container} = render(<Pixel />)await waitFor(() => expect(screen.getByText('Available')).toBeInTheDocument())fireEvent.change(screen.getByPlaceholderText('Message Portal...'), { target: { value: 'Fix the arena, then look at the preview.' } })fireEvent.click(screen.getByTitle('Send'))- const label = await screen.findByText('Portal check:')- expect(label.closest('strong')).not.toBeNull()+ const line = await screen.findByText(note)+ expect(line.closest('p')).toHaveClass('portal-delivery-note')expect(screen.getByText('ui.js:748').closest('code')).not.toBeNull()expect(screen.getByText('The last full-viewport fill covers the arena.').closest('li')).not.toBeNull()- expect(screen.getByText(/did not pass Portal's checks/)).toBeVisible()- expect(screen.getByText('#arena').closest('code')).not.toBeNull()- expect(screen.getByText(/attempted preview interaction checks have not passed browser inspection/)).toBeVisible()+ expect(screen.getByText(/^The cause is/).closest('p')).not.toHaveClass('portal-delivery-note')+ const reply = line.closest('[data-pixel-response]')+ expect(reply.textContent).not.toMatch(/failed|did not pass|not verified|unverified|error|Portal check/i)+ expect(within(reply).queryByRole('alert')).toBeNull()+ expect(reply.querySelector('[class*="red-"]')).toBeNull()expect(screen.queryByText('Your preview is ready.')).toBeNull()expect(screen.queryByText(/Published from your workspace/)).toBeNull()expect(screen.queryByRole('link', { name: 'Open preview' })).toBeNull()+ expect(within(reply).getByRole('button', { name: /Web preview/ })).toBeVisible()expect(await screen.findByTitle('Interactive Portal preview')).toHaveAttribute('src', `/pixel-preview/${siteId}/__ods_view__.html`)+ expect(container.querySelector('.portal-embed-note')).toBeNull()// The stored reply and the model's history keep the full delivered text.await waitFor(() => expect(JSON.parse(globalThis.localStorage.getItem('ods.pixel.chat.v1')).messages.at(-1)).toMatchObject({ role: 'assistant', content, publication: preview }))})+ // RTX Spark, 2026-10-25: "Draw me a picture of a dragon" published an SVG+ // site that the preview card showed, and the reply ended with the model's+ // own embed of that site. Portal said it could not display it.+ it.each([+ ['after the reply', "Here's your dragon, curled around a mountain peak.\n\n"],+ ['as the whole reply', ''],+ ])('leaves out the embed of the preview its card shows, %s, and copies the original text', async (_name, prose) => {+ const matchMedia = globalThis.matchMedia+ vi.stubGlobal('matchMedia', query => query === '(prefers-reduced-motion: reduce)'+ ? { matches: true, addEventListener: vi.fn(), removeEventListener: vi.fn() }+ : matchMedia?.(query) ?? { matches: false, addEventListener: vi.fn(), removeEventListener: vi.fn() })+ const sha256 = 'fca81965eeec4e16e761822a' + 'b'.repeat(40)+ const siteId = `site-${sha256.slice(0, 24)}`+ const preview = {schemaVersion: 1, kind: 'ods-pixel-workspace-preview', relativeDirectory: 'Playground/dragon', siteId, port: 9437,+ url: `http://${siteId}.localhost:9437/${siteId}/`, files: 1, bytes: 2048, sha256, entrySha256: 'e'.repeat(64)}+ previewManifests.set(`/pixel-preview/${siteId}/__ods_manifest__.json`, preview)+ const content = `${prose}[embed ref="${siteId}" title="Dragon" height="560" /]\n\n` ++ `Your preview is ready.\n\n[Open preview](${preview.url})\n\nCreated by Portal.\n` ++ 'Publication scope: this receipt verifies the published snapshot, not functional behavior or completion of other requested work.'+ const writeText = vi.fn().mockResolvedValue(undefined)+ const clipboard = Object.getOwnPropertyDescriptor(navigator, 'clipboard')+ Object.defineProperty(navigator, 'clipboard', { configurable: true, value: { writeText } })+ try {+ globalThis.fetch.mockResolvedValueOnce(response({ available: true, model: 'pixel/default', detail: 'local' }))+ globalThis.fetch.mockResolvedValueOnce(sseResponse([+ JSON.stringify({ choices: [{ delta: { content } }] }),+ JSON.stringify({ choices: [{ delta: {}, finish_reason: 'stop' }], pixel: { schemaVersion: 1, preview },+ pixel_outcome: { schemaVersion: 1, status: 'passed' } }),+ '[DONE]',+ ]))+ const {container} = render(<Pixel />)+ await waitFor(() => expect(screen.getByText('Available')).toBeInTheDocument())+ fireEvent.change(screen.getByPlaceholderText('Message Portal...'), { target: { value: 'Draw me a picture of a dragon' } })+ fireEvent.click(screen.getByTitle('Send'))+ expect(await screen.findByTitle('Interactive Portal preview')).toHaveAttribute('src', `/pixel-preview/${siteId}/__ods_view__.html`)+ const reply = [...container.querySelectorAll('[data-pixel-response]')].at(-1)+ expect(await within(reply).findByRole('button', { name: /Web preview/ })).toBeVisible()+ if (prose) expect(await within(reply).findByText("Here's your dragon, curled around a mountain peak.")).toBeVisible()+ await waitFor(() => expect(within(reply).getByRole('button', { name: 'Copy response' })).toBeVisible())+ expect(reply.textContent).not.toMatch(/\[embed|embedded view|can’t display|Your preview is ready/)+ expect(container.querySelector('.portal-embed-note')).toBeNull()+ fireEvent.click(within(reply).getByRole('button', { name: 'Copy response' }))+ await waitFor(() => expect(writeText).toHaveBeenCalledOnce())+ expect(writeText.mock.calls[0][0]).toContain(`[embed ref="${siteId}" title="Dragon" height="560" /]`)+ await waitFor(() => expect(JSON.parse(globalThis.localStorage.getItem('ods.pixel.chat.v1')).messages.at(-1))+ .toMatchObject({ role: 'assistant', content, publication: preview }))+ } finally {+ if (clipboard) Object.defineProperty(navigator, 'clipboard', clipboard)+ else delete navigator.clipboard+ }+ })++ it('shows nothing, not a note, for a later reply of only an embed of a preview the chat already shows', async () => {+ // Reveal replies at once, so a note would already show.+ const matchMedia = globalThis.matchMedia+ vi.stubGlobal('matchMedia', query => query === '(prefers-reduced-motion: reduce)'+ ? { matches: true, addEventListener: vi.fn(), removeEventListener: vi.fn() }+ : matchMedia?.(query) ?? { matches: false, addEventListener: vi.fn(), removeEventListener: vi.fn() })+ const sha256 = 'fca81965eeec4e16e761822a' + 'b'.repeat(40)+ const siteId = `site-${sha256.slice(0, 24)}`+ const preview = {schemaVersion: 1, kind: 'ods-pixel-workspace-preview', relativeDirectory: 'Playground/dragon', siteId, port: 9437,+ url: `http://${siteId}.localhost:9437/${siteId}/`, files: 1, bytes: 2048, sha256, entrySha256: 'e'.repeat(64)}+ const embed = `[embed ref="${siteId}" title="Dragon" height="560" /]`+ globalThis.localStorage.setItem('ods.pixel.chat.v1', JSON.stringify({schema: 1, chatId: 'dragon-chat', messages: [+ {role: 'user', content: 'Draw me a picture of a dragon'},+ {role: 'assistant', content: `Here's your dragon.\n\nYour preview is ready.\n\n[Open preview](${preview.url})\n\nCreated by Portal.`,+ publication: preview},+ ]}))+ globalThis.fetch.mockImplementation(async url => url === '/api/pixel/chat/stream'+ ? sseResponse([JSON.stringify({choices: [{delta: {content: embed}}]}),+ JSON.stringify({choices: [{delta: {}, finish_reason: 'stop'}], pixel_outcome: {schemaVersion: 1, status: 'none'}}), '[DONE]'])+ : response({available: true, model: 'pixel/default'}))+ const {container} = render(<Pixel />)+ await screen.findByText('Available')+ expect(screen.getByText("Here's your dragon.")).toBeVisible()+ fireEvent.change(screen.getByPlaceholderText('Message Portal...'), {target: {value: 'Show it to me again'}})+ fireEvent.click(screen.getByTitle('Send'))+ await waitFor(() => expect(JSON.parse(globalThis.localStorage.getItem('ods.pixel.chat.v1')).messages.at(-1))+ .toMatchObject({role: 'assistant', content: embed}))+ await waitFor(() => expect(within([...container.querySelectorAll('[data-pixel-response]')].at(-1))+ .getByRole('button', {name: 'Copy response'})).toBeVisible())+ expect(container.textContent).not.toMatch(/embedded view|can’t display|\[embed/)+ })+// Seen live: "what is 12 squared?" was answered exactly "144.", which// Markdown reads as an ordered list that starts at 144 with one empty item.// Without its start number the reply showed an empty "1." and lost the answer.diff --git a/ods/extensions/services/dashboard/src/pages/PixelArtifacts.test.jsx b/ods/extensions/services/dashboard/src/pages/PixelArtifacts.test.jsxindex fece0b9b6..aa6994e07 100644--- a/ods/extensions/services/dashboard/src/pages/PixelArtifacts.test.jsx+++ b/ods/extensions/services/dashboard/src/pages/PixelArtifacts.test.jsx@@ -2,7 +2,7 @@ import { act, fireEvent, screen, waitFor } from '@testing-library/react'import { createHash } from 'node:crypto'import { render } from '../test/test-utils'import { saveConversation, SELECT_EVENT } from '../lib/pixelConversations'-import { EMBED_NOTE, EMBED_ONLY_NOTE } from '../lib/embedDisplay'+import { EMBED_ONLY_NOTE } from '../lib/embedDisplay'import Pixel from './Pixel'const bytes = new TextEncoder().encode('A verified document\n')@@ -298,7 +298,7 @@ it('shows the verified download without a matching generated embed tag and retaiconst download=await screen.findByRole('button',{name:'Download report.md'})expect(screen.queryByText(content)).toBeNull()expect(screen.queryByText(EMBED_ONLY_NOTE)).toBeNull()- expect(screen.queryByText(EMBED_NOTE)).toBeNull()+ expect(screen.queryByText(/can’t display/)).toBeNull()expect(JSON.parse(localStorage.getItem('ods.pixel.chat.v1')).messages.at(-1).content).toBe(content)fireEvent.click(download)await screen.findByText('Verified download started')diff --git a/ods/extensions/services/pixel-agent/COMPLETION-RELIABILITY.md b/ods/extensions/services/pixel-agent/COMPLETION-RELIABILITY.mdindex 5af187ed1..c9a694811 100644--- a/ods/extensions/services/pixel-agent/COMPLETION-RELIABILITY.md+++ b/ods/extensions/services/pixel-agent/COMPLETION-RELIABILITY.md@@ -846,49 +846,88 @@ saw it. `preview-explanation.mjs` changes only that substitution: when aworkspace preview outcome is `failed` or `pending` (a browser, interaction orrequested-text check that did not pass, a stale snapshot, no publication, averification command still running, or any of these with extension, lane-stop-or missing-download facts added), the agent's final reply comes first. A fixed-note follows under **Portal check:**, then the unchanged host result:--- The note always says "The reply above is the agent's own account, not a- verified result." and then "This request did not pass Portal's checks." (or,- when pending, "Portal's checks for this request have not finished."). No- wording heuristic decides this, so a claim of success in any wording, quoted,- in code or in a checklist, is still followed by that plain statement. The- reply itself is never rewritten.+or missing-download facts added), the agent's final reply comes first, then+Portal's text in the owner's wording (next section).+- When the reply promises more work ("I'll fix line 748 now") or ends by- narrating its next action, the note adds that Portal has stopped for this- message and the step has not started.-- When the current snapshot's latest inspection failed, one host line names- the failed step from the validated receipt, for example "step 2- (assert-painted) on `#arena` captured one color only (#8fce3a)". Only the- step number, action, error code, the capsule's color and the plan's locator- (quoted as code) are used. This line is not added to a host-only delivery.-- The outcome keeps its status, and every host failure line and the preview- receipt still follow, so the dashboard still shows the preview card and the- failure. An open code block in the reply is closed with its own fence, read- as the dashboard's `publicationDisplayText` reads it.-- The host-only delivery stays as before when the reply is empty, silent, too+ narrating its next action, Portal's line is "The next step above hasn't+ started yet. Send a message to continue."+- The outcome keeps its status and preview receipt, so the dashboard still+ shows the preview card. An open code block in the reply is closed with its+ own fence, read as the dashboard's `publicationDisplayText` reads it.+- The host-only delivery stands alone when the reply is empty, silent, tooshort, tool-call text, over 20,000 characters, links any local URL other than- this outcome's own preview, or carries Portal's wording: its label or receipt- lines ("Your preview is ready.", "[Open preview]", "Published from your- workspace."), however markdown or HTML draws them (character references,- no-break or zero-width spaces, fullwidth letters, emphasis split across the- words).+ this outcome's own preview, or carries Portal's wording: a "Portal check"+ label or receipt lines ("Your preview is ready.", "[Open preview]",+ "Published from your workspace."), however markdown or HTML draws them+ (character references, no-break or zero-width spaces, fullwidth letters,+ emphasis split across the words).- The reply is the `lastAssistantMessage` seen at `before_agent_finalize`, andonly when the transcript's last assistant message, a turn without tool calls,holds exactly that visible text. When that turn has none, OpenClaw 2026.6.33fills `lastAssistantMessage` with the joined narration of earlier tool-callturns, which is no reply. Any later model call, and an owner cancel, clear it.-- Passing (`append`) outcomes are unchanged, and so is the ingress verification- schema. A run-deadline, tool-limit, recursive-delete or clarification- delivery keeps its own text.+- The ingress verification schema is unchanged. A tool-limit,+ recursive-delete or clarification delivery keeps its own text; a run+ deadline or output limit quotes the preview outcome in the owner's wording.- The reply is filtered like a tool-limit answer, not scrubbed: a path or other- text the agent quotes is delivered as in any passing reply.+ text the agent quotes is delivered as in any passing reply. It is never+ evidence, and no wording heuristic reads it: a claim of success in any+ wording is followed by the same line.++## What the owner reads after a preview++On the RTX Spark (2026-10-25), two of four builds ended with only "The+attempted preview interaction checks have not passed browser inspection. The+published preview is available, but those checks remain unverified." under a+preview that worked, and a kept explanation was followed by four host pieces+(a "Portal check" note, the failed step, that text, the receipt). When a run+publishes a preview that loads, the owner now reads no error-looking text.++- The guard's record (`verificationForRun`) keeps every check fact, and the+ model is told them during the run exactly as before, so it can repair the+ page and cannot claim the checks passed. Only the delivered text changes+ (`deliveryVerificationForRun`): its check facts become one short line+ (`previewCheckNote`), and the preview receipt follows, which the dashboard+ shows as the preview card. The dashboard shows Portal's line as a muted+ paragraph (`dashboard/src/lib/portalDeliveryNotes.js`, kept equal to the+ plugin's lines by `tests/preview_explanation_delivery.test.mjs`).+- The line, by the facts: a page that threw uncaught script errors while it was+ inspected ("The page ran into a script problem while Portal was testing it,+ so parts of it may not work yet. Ask Portal to fix it."); requested text,+ headings, files or control names missing ("The page doesn't match everything+ you asked for yet. Ask Portal to fix it."); a verification command still+ running ("Portal's checks were still running when it replied. ..."); an+ interaction check that did not pass ("Portal couldn't test every control+ automatically. Try it, and tell Portal if something isn't right."); anything+ else, such as a failed test command or a page that was never inspected+ ("Portal couldn't confirm everything automatically. ..."). Each line says+ what Portal could not confirm, or what is wrong, and what to do next.+- Steps, assertion names, colors and selectors leave the delivered text. The+ model still reads the inspection result in full (the transcript keeps it);+ the owner-facing failed-step line was removed.+- A passing preview delivers only its receipt: the record's "Browser+ inspection passed for the submitted ... checks only" scope line is dropped.+- A snapshot edited after publication: "This preview shows the version from+ before Portal's latest changes. Ask Portal to publish the current files.",+ or, after Portal stopped a repeated coding loop, "Portal stopped before it+ finished, so this preview shows an earlier version. Send a message to+ continue.", each followed by the link to the last publication.+- No preview at all is a real failure and says so plainly, with the next step:+ "Portal saved the website files in your workspace but couldn't publish a+ preview of them, so they haven't been checked and there is no preview to+ open yet. Ask Portal to publish the preview." or "Portal didn't create the+ website files for this request, so there is no preview to open yet. Ask+ Portal to try the build again."+- Other host lines of the same outcome (a requested download that was not+ attached, a stopped lane, extension facts) are kept as they are.`tests/preview_explanation_delivery.test.mjs` replays the Elf of Doom casethrough the real guard, inspection receipt and ingress, plus the regressioncases (success claims in many forms, empty, silent and narration-only replies,-imitated notes, passing and pending checks, local links, code fences).+imitated notes, passing, pending, page-error and stale checks, local links,+code fences), and checks that no line after a published preview reads as an+error.## Passing checks that do not countdiff --git a/ods/extensions/services/pixel-agent/README.md b/ods/extensions/services/pixel-agent/README.mdindex a2915c7be..97879dd7f 100644--- a/ods/extensions/services/pixel-agent/README.md+++ b/ods/extensions/services/pixel-agent/README.md@@ -117,10 +117,10 @@ upstream default. Other agents and existing jobs are unaffected.verification state over a gateway-authenticated loopback route. Failed orstill-running verification replaces model-authored success text with anhonest host-authored result. A failed or still-running workspace preview- check keeps the agent's own explanation first, then a fixed note that it is- the agent's own account and that the request did not pass (or has not- finished) Portal's checks, then that host result (see- COMPLETION-RELIABILITY.md). Streaming responses are bounded and buffered+ check keeps the agent's own explanation first. When a preview was+ published, Portal's one plain line about what it could not confirm follows,+ with the preview receipt; the check facts stay in the guard's record and the+ model's run (see COMPLETION-RELIABILITY.md). Streaming responses are bounded and buffereduntil that check completes, so false content is never released and thenretracted.- **Protected local host commands.** An explicit owner request to run onediff --git a/ods/extensions/services/pixel-agent/plugin/index.js b/ods/extensions/services/pixel-agent/plugin/index.jsindex df827ee23..b74c44ec6 100644--- a/ods/extensions/services/pixel-agent/plugin/index.js+++ b/ods/extensions/services/pixel-agent/plugin/index.js@@ -639,7 +639,7 @@ export default definePluginEntry({// Delivery rewriting is limited to host-authoritative failed or pending// verification state. It neither requests nor receives conversation data;// a failed or pending preview delivery carries the agent's final reply,- // seen at before_agent_finalize, ahead of its host facts+ // seen at before_agent_finalize, ahead of Portal's one line about it// (preview-explanation.mjs).api.on("reply_payload_sending", (event) =>toolLoopGuard.replyPayloadSending(event)diff --git a/ods/extensions/services/pixel-agent/plugin/preview-explanation.mjs b/ods/extensions/services/pixel-agent/plugin/preview-explanation.mjsindex c4829af64..ce9da1bda 100644--- a/ods/extensions/services/pixel-agent/plugin/preview-explanation.mjs+++ b/ods/extensions/services/pixel-agent/plugin/preview-explanation.mjs@@ -1,46 +1,62 @@-// Keep the agent's own explanation when a workspace preview check fails.+// What the owner reads after a workspace preview run.//-// A failed or still-running preview outcome (a browser or interaction check-// that did not pass, requested text missing, a stale or unpublished snapshot,-// a verification command still running) used to replace the agent's whole-// final reply with the host's delivery text. On the RTX Spark (Elf of Doom,-// round 9) that hid the agent's correct root-cause explanation: the owner saw-// only "The attempted preview interaction checks have not passed browser-// inspection ... Your preview is ready."+// Owner wording. The guard keeps every check fact of a preview outcome in its+// own record (verificationForRun: "The attempted preview interaction checks+// have not passed browser inspection ..."), and the model reads what failed+// during the run (its inspection results and the guard's next-step+// instructions), so it can repair the page. The owner reads one short, plain+// line in place of those facts, which the dashboard shows muted. On the RTX Spark+// (2026-10-25) two of four builds ended with only that fact text under a+// preview that worked. The outcome keeps its status and its preview receipt,+// and nothing here certifies anything: each line says what Portal could not+// confirm, or what is wrong, and what the owner can do next.//-// Now the agent's final prose comes first and the host facts follow it,-// unchanged, under a fixed label. The prose is delivered as written and is-// never evidence: the outcome keeps its status, every host failure line and-// the preview receipt still follow it, and the note after it always says the-// reply is the agent's own account and that the request did not pass (or has-// not finished) Portal's checks. No wording heuristic decides that: it is true-// for every outcome this applies to, whatever the prose claims.+// The agent's explanation. A failed or still-running preview outcome (a+// browser or interaction check that did not pass, requested text missing, a+// stale or unpublished snapshot, a verification command still running) used+// to replace the agent's whole final reply with the host's delivery text. On+// the RTX Spark (Elf of Doom, round 9) that hid the agent's correct root-cause+// explanation. Now the agent's final prose comes first and Portal's line and+// the host's remaining text follow it. The prose is delivered as written and+// is never evidence.//// The prose passes the filter every host-composed answer passes// (deliverableAnswer in progress-finalization.mjs). It is dropped, and the host-// delivery stands alone as before, when it is empty or too short, silent-// (NO_REPLY), tool-call text, when it links any local URL other than this-// outcome's own preview, or when it carries Portal's own wording (its label or-// receipt lines, however markdown or HTML draws them): a copied or imitated-// host note must not read as Portal's. Everything added here is fixed English-// text, apart from an inspection step's locator, which is quoted as code.+// delivery stands alone, when it is empty or too short, silent (NO_REPLY),+// tool-call text, when it links any local URL other than this outcome's own+// preview, or when it carries Portal's own wording (its check label or receipt+// lines, however markdown or HTML draws them): a copied or imitated host note+// must not read as Portal's. Everything added here is fixed English text.import { NARRATION, deliverableAnswer } from './progress-finalization.mjs';import { promisesExecution } from './completion-assurance.mjs';import { silentReplyText } from './owner-visible-reply.mjs';-export const PREVIEW_CHECK_LABEL = '**Portal check:**';-export const PREVIEW_ACCOUNT_NOTE = "The reply above is the agent's own account, not a verified result.";-export const PREVIEW_FAILED_NOTE = "This request did not pass Portal's checks.";-export const PREVIEW_PENDING_NOTE = "Portal's checks for this request have not finished.";-// The run has ended: a step the reply announces will not start on its own.+// Portal's line after a preview outcome that did not pass. The dashboard+// mutes these exact paragraphs (dashboard/src/lib/portalDeliveryNotes.js).+export const PREVIEW_CONTROLS_NOTE =+ "Portal couldn't test every control automatically. Try it, and tell Portal if something isn't right.";+export const PREVIEW_UNCONFIRMED_NOTE =+ "Portal couldn't confirm everything automatically. Have a look, and tell Portal if something isn't right.";+export const PREVIEW_RUNNING_NOTE =+ "Portal's checks were still running when it replied. Have a look, and tell Portal if something isn't right.";+export const PREVIEW_SCRIPT_NOTE =+ 'The page ran into a script problem while Portal was testing it, so parts of it may not work yet. Ask Portal to fix it.';+export const PREVIEW_MISSING_NOTE = "The page doesn't match everything you asked for yet. Ask Portal to fix it.";+// The preview card shows the last publication; the files changed after it.+export const PREVIEW_EARLIER_NOTE =+ "This preview shows the version from before Portal's latest changes. Ask Portal to publish the current files.";export const PREVIEW_STOPPED_NOTE =- 'Portal has stopped for this message, so the next step described above has not started. Send a message to continue.';+ 'Portal stopped before it finished, so this preview shows an earlier version. Send a message to continue.';+// The run has ended: a step the reply announces will not start on its own.+export const PREVIEW_CONTINUE_NOTE = "The next step above hasn't started yet. Send a message to continue.";+export const PREVIEW_NOTES = Object.freeze([PREVIEW_CONTROLS_NOTE, PREVIEW_UNCONFIRMED_NOTE, PREVIEW_RUNNING_NOTE,+ PREVIEW_SCRIPT_NOTE, PREVIEW_MISSING_NOTE, PREVIEW_EARLIER_NOTE, PREVIEW_STOPPED_NOTE, PREVIEW_CONTINUE_NOTE]);// The combined reply is host verification text (ingress limit: 32 KiB). Leave// room for the extension and progress-lane notes that can follow it.const MAX_EXPLAINED_CHARS = 24 * 1024;-// Portal's label and receipt lines, matched on folded text (foldedText).+// Portal's check label and receipt lines, matched on folded text (foldedText).const HOST_WORDING = /\bportal[\s\p{P}]{0,3}checks?\b|\byour (?:last published )?preview is (?:ready|still available)\b|\bpublished from your workspace\b|\bcreated by portal\b|\[open (?:last published )?preview\]|\bpublication scope\b/iu;const codePoint = value => value > 0 && value <= 0x10ffff ? String.fromCodePoint(value) : ' ';@@ -81,60 +97,50 @@ function announcesMoreWork(answer) {return promisesExecution(answer) || NARRATION.test(sentence);}-// A locator as an inline code span that no backtick inside it can close.-function codeSpan(value) {- const text = value.replace(/\s+/g, ' ').trim();- if (!text.includes('`')) return `\`${text}\``;- const ticks = '`'.repeat(Math.max(0, ...[...text.matchAll(/`+/g)].map(match => match[0].length)) + 1);- return `${ticks} ${text} ${ticks}`;+// Portal's line for a published preview whose checks did not pass, from the+// guard's facts about it. A page that throws is broken and a requested text+// that is missing is a known gap; anything else is what Portal could not+// confirm, and the owner can try it.+export function previewCheckNote({pending = false, pageErrors = false, missing = false, testFailed = false, controls = false} = {}) {+ if (pageErrors) return PREVIEW_SCRIPT_NOTE;+ if (missing) return PREVIEW_MISSING_NOTE;+ if (pending) return PREVIEW_RUNNING_NOTE;+ return controls && !testFailed ? PREVIEW_CONTROLS_NOTE : PREVIEW_UNCONFIRMED_NOTE;}-const STEP_FAILURES = new Map([- ['no_match', 'matched no element'],- ['selector_not_unique', 'matched more than one element'],- ['invalid_selector', 'has an invalid CSS selector'],- ['visibility_mismatch', 'did not show the requested visibility'],- ['text_mismatch', 'did not show the expected text'],- ['not_in_viewport', 'captured nothing on screen'],- ['press_failed', 'could not complete the key press'],- ['focus_failed', 'could not focus the page'],- ['text_field_press_unsupported', 'was refused because its target accepts text'],-]);--// One fixed-English line naming the first failed step of a failed inspection-// receipt of `preview` (the inspect tool validated the receipt), or undefined.-// Only bounded fields are read: the step number, action, error code, the-// capsule-computed color and the plan's own locator. Never page text.-export function inspectionFailureLine(details, preview) {- if (!preview || details?.status !== 'failed' || details.siteId !== preview.siteId || details.sha256 !== preview.sha256) return undefined;- const lead = 'Latest browser inspection of this preview';- const code = value => typeof value === 'string' && /^[a-z_]{1,40}$/.test(value) ? value : undefined;- const step = Array.isArray(details.steps) ? details.steps.find(item => item?.status === 'failed') : undefined;- if (!step) return code(details.errorCode) ? `${lead} did not complete (${details.errorCode}).` : undefined;- if (!Number.isInteger(step.index) || step.index < 0 || step.index > 11 || !/^[a-z-]{1,20}$/.test(step.action ?? '')) return undefined;- const locator = step.locator ?? {};- const target = typeof locator.selector === 'string' && locator.selector.length <= 256 ? ` on ${codeSpan(locator.selector)}`- : /^[a-z]{1,20}$/.test(locator.role ?? '') && typeof locator.name === 'string' && locator.name.length <= 120- ? ` on the ${locator.role} named ${codeSpan(locator.name)}` : '';- const hex = step.paint?.dominant?.hex;- const failure = step.errorCode === 'uniform_paint' && /^#[0-9a-f]{6}$/.test(hex ?? '') ? `captured one color only (${hex})`- : STEP_FAILURES.get(step.errorCode) ?? (code(step.errorCode) ? `did not pass (${step.errorCode})` : 'did not pass');- return `${lead}: step ${step.index + 1} (${step.action})${target} ${failure}.`;+// `text` as the owner reads it. `presentation` ({text, rest, note}) is a+// preview outcome's own host text, the part of it the owner keeps (its preview+// receipt or link) and Portal's line. Within `text`, which can carry other+// host lines around that host text (a missing download, a stopped lane), the+// host text becomes `line` and the kept part. Without it, `line` leads.+export function ownerPreviewText(text, presentation, line = presentation?.note) {+ const at = presentation ? text.indexOf(presentation.text) : -1;+ if (at < 0) return line ? `${line}\n\n${text}` : text;+ return text.slice(0, at) + [line, presentation.rest].filter(Boolean).join('\n\n') ++ text.slice(at + presentation.text.length);}-// Returns `result` with the agent's prose ahead of its host text, or `result`-// itself when it is not a failed or pending outcome or the prose cannot be-// delivered. `inspection` is a line from inspectionFailureLine.-export function explainedPreviewDelivery(result, {reply, inspection} = {}) {- if (!['failed', 'pending'].includes(result?.status) || typeof result.text !== 'string' || !result.text) return result;- if (typeof reply !== 'string' || silentReplyText(reply)) return result;+// The agent's final reply, when it can be delivered ahead of Portal's text.+function keptAnswer(reply, result) {+ if (typeof reply !== 'string' || silentReplyText(reply)) return undefined;const answer = deliverableAnswer(reply, {localUrlsForbidden: true,allowedUrls: result.preview?.url ? [result.preview.url] : []});- if (!answer || HOST_WORDING.test(foldedText(answer))) return result;- const fence = openFence(answer);- const note = [PREVIEW_ACCOUNT_NOTE, result.status === 'pending' ? PREVIEW_PENDING_NOTE : PREVIEW_FAILED_NOTE,- ...(announcesMoreWork(answer) ? [PREVIEW_STOPPED_NOTE] : [])].join(' ');- const text = [fence ? `${answer}\n${fence}` : answer, `${PREVIEW_CHECK_LABEL} ${note}`, inspection, result.text]- .filter(Boolean).join('\n\n');- return text.length > MAX_EXPLAINED_CHARS ? result : {...result, text};+ return answer && !HOST_WORDING.test(foldedText(answer)) ? answer : undefined;+}++// Returns `result` in the owner's wording (ownerPreviewText), with the agent's+// final reply first when the outcome is failed or pending and the reply can be+// delivered. A reply that announces more work is followed by the line saying+// that step has not started. Returns `result` itself when nothing changes.+export function explainedPreviewDelivery(result, {reply, presentation} = {}) {+ if (typeof result?.text !== 'string' || !result.text) return result;+ const answer = ['failed', 'pending'].includes(result.status) ? keptAnswer(reply, result) : undefined;+ if (answer) {+ const fence = openFence(answer);+ const line = announcesMoreWork(answer) ? PREVIEW_CONTINUE_NOTE : presentation?.note;+ const text = [fence ? `${answer}\n${fence}` : answer, ownerPreviewText(result.text, presentation, line)].join('\n\n');+ if (text.length <= MAX_EXPLAINED_CHARS) return {...result, text};+ }+ const text = ownerPreviewText(result.text, presentation);+ return text === result.text ? result : {...result, text};}diff --git a/ods/extensions/services/pixel-agent/plugin/tool-loop-guard.mjs b/ods/extensions/services/pixel-agent/plugin/tool-loop-guard.mjsindex 3dda7e542..bf3205648 100644--- a/ods/extensions/services/pixel-agent/plugin/tool-loop-guard.mjs+++ b/ods/extensions/services/pixel-agent/plugin/tool-loop-guard.mjs@@ -51,7 +51,8 @@ import { PREVIEW_INSPECTION_TOOL, requestsVisibilityInteraction, requestsBehavioattemptedPreviewBehavior, boundPreviewBehavior, previewBehaviorInstruction, unassertedBehaviorStep } from './preview-interaction-assurance.mjs';import { workspaceRevalidationCandidate, workspaceReadOnlyCall, settledRevalidationReceipt, boundedPreviewVerification } from "./preview-revalidation.mjs";import { boundedPreviewDelivery } from './preview-delivery-recovery.mjs';-import { explainedPreviewDelivery, inspectionFailureLine } from './preview-explanation.mjs';+import { PREVIEW_EARLIER_NOTE, PREVIEW_STOPPED_NOTE, explainedPreviewDelivery, ownerPreviewText,+ previewCheckNote } from './preview-explanation.mjs';import { extractRequestedLiterals, requestedTextCheck, requestedTextInstruction, requestedTextRevisionInstruction,requestedTextDeliveryNote, publishedElementOutline, extractRequestedControlNames, requestedControlSources,requestedControlNameCheck, requestedControlNameInstruction, requestedControlNameRevisionInstruction,@@ -325,11 +326,13 @@ export const WORKSPACE_VISUAL_CONTINUATION_SCOPE_REASON ="Keep this visual follow-up in the bound artifact directory. Read existing files before editing or replacing them, use sandbox exec/process for inspection and verification, then republish the same directory with pixel_ods_workspace_preview. Do not blindly overwrite files, create a replacement project, or modify another directory.";+// No preview was published: a real failure, said plainly with the next step.+// The dashboard shows each muted, like Portal's other notes.export const WORKSPACE_PREVIEW_UNVERIFIED_DELIVERY_PREFIX =- "Portal saved the website files in your workspace, but ODS did not verify a browser-accessible preview. No localhost URL is live or claimed; ask Portal to continue and publish the static site through the workspace preview capability.";+ "Portal saved the website files in your workspace but couldn't publish a preview of them, so they haven't been checked and there is no preview to open yet. Ask Portal to publish the preview.";export const WORKSPACE_PREVIEW_NOT_CREATED_DELIVERY_PREFIX =- "Portal did not create or verify the requested website files, so ODS did not publish a browser preview. No localhost URL is live or claimed; ask Portal to retry the build.";+ "Portal didn't create the website files for this request, so there is no preview to open yet. Ask Portal to try the build again.";export const WORKSPACE_PREVIEW_PUBLISHED_DELIVERY_PREFIX ="Your preview is ready.";@@ -7840,15 +7843,6 @@ export function createToolLoopGuard({gap.sessionId === state.currentSessionId && gap.sessionKey === state.currentSessionKey ? gap : undefined;}- // The failed step of the current snapshot's latest inspection, for the note- // beside a kept explanation (preview-explanation.mjs). Never evidence.- function workspaceInspectionFailureLine(state) {- const failure = state.workspaceInspectionFailure;- return visibilityInspectionMatches(failure, state.workspacePreview) &&- failure.sessionId === state.currentSessionId && failure.sessionKey === state.currentSessionKey- ? failure.line : undefined;- }-function rememberSessionDownload(sessionId, jobId) {if (typeof sessionId !== "string" || !sessionId || !OPS_JOB_ID.test(jobId)) return;const jobs = sessionDownloadJobs.get(sessionId) ?? new Set();@@ -8178,7 +8172,6 @@ export function createToolLoopGuard({state.workspaceVisibilityInspection = undefined;state.workspaceBehaviorInspection = undefined;state.workspaceRenderedInspection = undefined;- state.workspaceInspectionFailure = undefined;state.workspaceBehaviorGap = undefined;state.workspaceInspectionGeneration = (state.workspaceInspectionGeneration ?? 0) + 1;}@@ -11341,11 +11334,6 @@ export function createToolLoopGuard({? unassertedBehaviorStep(inspected.params.steps) : undefined;state.workspaceBehaviorGap = behaviorGap ? Object.freeze({...behaviorGap, siteId: renderedProof.siteId,sha256: renderedProof.sha256, sessionId: state.currentSessionId, sessionKey: state.currentSessionKey}) : undefined;- // Names the first failed step to the owner beside a kept explanation.- const failureLine = inspectionFailureLine(inspected.result?.details, state.workspacePreview);- state.workspaceInspectionFailure = failureLine ? Object.freeze({siteId: state.workspacePreview.siteId,- sha256: state.workspacePreview.sha256, sessionId: state.currentSessionId, sessionKey: state.currentSessionKey,- line: failureLine}) : undefined;state.workspaceVisibilityInspectionUnavailable =inspected.result?.details?.errorCode === 'unavailable';// Selects the repair instruction only; bound to this exact snapshot.@@ -13765,11 +13753,24 @@ export function createToolLoopGuard({// Workspace preview outcomes (the preview branch of taskVerificationForRun),// also once lane-stop or extension facts are added to one. Delivered as is,- // a failed or pending one keeps the agent's final explanation ahead of its- // host facts (deliveryVerificationForRun, preview-explanation.mjs).+ // a failed or pending one keeps the agent's final explanation ahead of+ // Portal's text (deliveryVerificationForRun, preview-explanation.mjs).const previewOutcomes = new WeakSet();- const previewOutcome = result => (previewOutcomes.add(result), result);- const derivedOutcome = (from, result) => previewOutcomes.has(from) ? previewOutcome(result) : result;+ // The owner's wording of a published preview's outcome ({text, rest, note},+ // ownerPreviewText). The outcome's text keeps every check fact for this+ // record, as the model read them in its tool results; the owner reads+ // Portal's one line and `rest` (the receipt or link) instead.+ const previewPresentations = new WeakMap();+ const previewOutcome = (result, presentation) => {+ previewOutcomes.add(result);+ if (presentation) previewPresentations.set(result, presentation);+ return result;+ };+ // A derived text starts with the outcome's own text, so its wording carries over.+ const derivedOutcome = (from, result) => previewOutcomes.has(from)+ ? previewOutcome(result, previewPresentations.get(from)) : result;+ // A preview outcome's text as the owner reads it, where a stop text quotes it.+ const ownerOutcomeText = result => ownerPreviewText(result.text, previewPresentations.get(result));function verificationForRun(runId) {const verification = mixedTaskVerificationForRun(runId);@@ -13870,7 +13871,9 @@ export function createToolLoopGuard({!state.exactDownloadRequested) {// Every result here is a preview outcome (previewOutcomes): the texts- // stay host-only, and delivery adds the agent's explanation.+ // stay host-only, and delivery adds the agent's explanation. With a+ // published preview, the owner reads Portal's line in place of the+ // check facts (previewPresentations).if (!state.workspacePreview) {if (state.workspacePreviewRestrictions?.mutation && state.workspacePreviewAttempted) return previewOutcome({status: "failed",@@ -13889,24 +13892,26 @@ export function createToolLoopGuard({const stopText = state.codingExhausted? "Portal stopped before the requested work was complete. Saved files are preserved.": "";+ const link = `[Open last published preview](${preview.url})`;+ const text =+ (stopText ? `${stopText}\n\n` : "") ++ (checkText ? `${checkText}\n\n` : "") ++ "Your last published preview is still available.\n\n" ++ `${link}\n\n` ++ "The workspace has not been verified again since later tool activity. " ++ "This snapshot may not include subsequent changes and does not verify completion of this request. " ++ (state.codingExhausted+ ? "Start a fresh message to continue repairing, verifying, and publishing the current files."+ : "Ask Portal to verify and publish the current files.");return previewOutcome({status: "failed",- text:- (stopText ? `${stopText}\n\n` : "") +- (checkText ? `${checkText}\n\n` : "") +- "Your last published preview is still available.\n\n" +- `[Open last published preview](${preview.url})\n\n` +- "The workspace has not been verified again since later tool activity. " +- "This snapshot may not include subsequent changes and does not verify completion of this request. " +- (state.codingExhausted- ? "Start a fresh message to continue repairing, verifying, and publishing the current files."- : "Ask Portal to verify and publish the current files."),+ text,preview: {schemaVersion: 1,kind: "ods-pixel-workspace-preview",...preview,},- });+ }, {text, rest: link, note: state.codingExhausted ? PREVIEW_STOPPED_NOTE : PREVIEW_EARLIER_NOTE});}const hasIndexEvidence = [...state.successfulWritePaths,@@ -13936,29 +13941,38 @@ export function createToolLoopGuard({// showed missing withhold certification, whatever else passed.const requestedTextMissing = requestedTextDeliveryNote(state.workspacePreview, state.workspaceRequestedTextCheck,state.workspaceControlNameCheck);+ const status = checkIncomplete ? checkStatus+ : interactionUnverified || behaviorUnverified || renderedUnverified || requestedTextMissing ? "failed" : "passed";+ const facts = [+ checkText,+ requestedTextMissing,+ renderedUnverified && "The published page has not passed browser inspection. Its browser check remains unverified.",+ interactionUnverified && "The requested show/hide interaction has not passed browser inspection. The published preview is available, but that behavior remains unverified.",+ behaviorUnverified && "The attempted preview interaction checks have not passed browser inspection. The published preview is available, but those checks remain unverified.",+ workspaceBehaviorAttempt(state) && !behaviorUnverified && !state.workspaceVisibilityInteractionRequired &&+ "Browser inspection passed for the submitted interaction checks only; this does not verify all requested behavior.",+ state.workspaceVisibilityInteractionRequired && !interactionUnverified &&+ "Browser inspection passed for the submitted show/hide checks only; this does not verify all requested behavior.",+ ].filter(Boolean);+ const receipt = `${WORKSPACE_PREVIEW_PUBLISHED_DELIVERY_PREFIX}\n\n` ++ `[Open preview](${state.workspacePreview.url})\n\n` ++ (state.workspacePreviewModelAuthored+ ? "Created by Portal."+ : "Published from your workspace.");+ const text = [...facts, receipt].join("\n\n");return previewOutcome({- status: checkIncomplete ? checkStatus : interactionUnverified || behaviorUnverified || renderedUnverified || requestedTextMissing ? "failed" : "passed",- text:- (checkText ? `${checkText}\n\n` : "") +- (requestedTextMissing ? `${requestedTextMissing}\n\n` : "") +- (renderedUnverified ? "The published page has not passed browser inspection. Its browser check remains unverified.\n\n" : "") +- (interactionUnverified ? "The requested show/hide interaction has not passed browser inspection. The published preview is available, but that behavior remains unverified.\n\n" : "") +- (behaviorUnverified ? "The attempted preview interaction checks have not passed browser inspection. The published preview is available, but those checks remain unverified.\n\n" : "") +- (workspaceBehaviorAttempt(state) && !behaviorUnverified && !state.workspaceVisibilityInteractionRequired- ? "Browser inspection passed for the submitted interaction checks only; this does not verify all requested behavior.\n\n" : "") +- (state.workspaceVisibilityInteractionRequired && !interactionUnverified- ? "Browser inspection passed for the submitted show/hide checks only; this does not verify all requested behavior.\n\n" : "") +- `${WORKSPACE_PREVIEW_PUBLISHED_DELIVERY_PREFIX}\n\n` +- `[Open preview](${state.workspacePreview.url})\n\n` +- (state.workspacePreviewModelAuthored- ? "Created by Portal."- : "Published from your workspace."),+ status,+ text,preview: {schemaVersion: 1,kind: "ods-pixel-workspace-preview",...state.workspacePreview,},- });+ }, {text, rest: receipt, note: status === "passed" ? undefined : previewCheckNote({+ pending: status === "pending", testFailed: checkStatus === "failed", missing: Boolean(requestedTextMissing),+ pageErrors: visibilityInspectionMatches(state.workspaceInspectionPageErrors, state.workspacePreview),+ controls: interactionUnverified || behaviorUnverified,+ })});}if (state.exactDownloadRequested) {const terminalText = exactDownloadTerminalText(state.exactDownloadTerminalOutcome);@@ -14206,8 +14220,10 @@ export function createToolLoopGuard({const state=runs.get(runId);const artifacts=state?.workspaceArtifacts;// A preview outcome delivered as is (no stop, deadline or question text- // replaced it) keeps the agent's final reply ahead of all its host facts.- const explainable=previewOutcomes.has(result) && !state.clientCancelled;+ // replaced it) reads in the owner's wording, with the agent's final reply+ // ahead of Portal's text unless the owner cancelled.+ const owner=previewOutcomes.has(result) ? {presentation: previewPresentations.get(result),+ reply: state.clientCancelled ? undefined : state.finalReplyText} : undefined;// Passing tests or creating an archive cannot stand in for its download// receipt. Keep pending questions, cancellation and existing failure facts.if (state?.workspaceDocumentDeliveryRequested && state.artifactOwnerInteractive &&@@ -14218,8 +14234,7 @@ export function createToolLoopGuard({? `${missing}\n\n${result.text}`.slice(0, MAX_INGRESS_VERIFICATION_TEXT) : missing};delete result.deliveryMode;}- if (explainable) result=explainedPreviewDelivery(result, {reply: state.finalReplyText,- inspection: workspaceInspectionFailureLine(state)});+ if (owner) result=explainedPreviewDelivery(result, owner);// The shipped example's one owner line, which Portal's ingress adds after// the reply it delivers (host/pixel_ingress.mjs). A pending question card// carries none.@@ -14250,7 +14265,7 @@ export function createToolLoopGuard({const preview = failure?.preview ? undefined : progressStopPreview(state);return {status: 'failed', text: [runDeadlineStopText(state.runDeadline, state.workspaceMutationObserved),preview && `[Open last published preview](${preview.url})\n\nThis is the last verified publication, not proof that all requested work completed.`,- failure?.text].filter(Boolean).join('\n\n').slice(0, MAX_INGRESS_VERIFICATION_TEXT),+ failure && ownerOutcomeText(failure)].filter(Boolean).join('\n\n').slice(0, MAX_INGRESS_VERIFICATION_TEXT),...(failure?.preview ? {preview: failure.preview}: preview ? {preview: {schemaVersion: 1, kind: 'ods-pixel-workspace-preview', ...preview}} : {})};}@@ -14265,7 +14280,7 @@ export function createToolLoopGuard({const preview = prior?.preview ? undefined : progressStopPreview(state);return {status: 'failed', text: [outputLimitStopText(outputLimit, {remote: remoteModelRoute() === true}),preview && `[Open last published preview](${preview.url})\n\nThis is the last verified publication, not proof that all requested work completed.`,- prior?.text].filter(Boolean).join('\n\n').slice(0, MAX_INGRESS_VERIFICATION_TEXT),+ prior && ownerOutcomeText(prior)].filter(Boolean).join('\n\n').slice(0, MAX_INGRESS_VERIFICATION_TEXT),...(prior?.preview ? {preview: prior.preview}: preview ? {preview: {schemaVersion: 1, kind: 'ods-pixel-workspace-preview', ...preview}} : {})};}@@ -14416,7 +14431,6 @@ export function createToolLoopGuard({state.workspaceVisibilityInspection = undefined;state.workspaceBehaviorInspection = undefined;state.workspaceRenderedInspection = undefined;- state.workspaceInspectionFailure = undefined;state.workspaceBehaviorGap = undefined;state.previewVerificationGeneration = (state.previewVerificationGeneration ?? 0) + 1;sessionPreviews.delete(state.currentSessionId);diff --git a/ods/extensions/services/pixel-agent/plugin/workspace-preview.mjs b/ods/extensions/services/pixel-agent/plugin/workspace-preview.mjsindex 4c9394464..c80d02e21 100644--- a/ods/extensions/services/pixel-agent/plugin/workspace-preview.mjs+++ b/ods/extensions/services/pixel-agent/plugin/workspace-preview.mjs@@ -177,6 +177,12 @@ function publishedPathFeedback(response) {// Informational only: empty files can be legitimate, so publication stands.export const EMPTY_PUBLISHED_FILES_PREFIX = "Published files that are empty (0 bytes): ";+// OpenClaw teaches webchat models to show views with [embed ...] directives.+// Portal's dashboard already shows this preview in its own card, so such a+// directive (seen live: [embed ref="site-..." title="Dragon" height="560" /])+// is at best repeated markup.+export const PREVIEW_CARD_GUIDANCE = "Portal shows this preview to the owner in a card with your reply, so do not add an [embed ...] directive for it.";+// Displayed with host-authoritative publication evidence, independently of model prose.export const PREVIEW_STORAGE_DISCLOSURE = "Inputs in the embedded preview may be lost on reload. Storage behavior can differ in a separate tab; publishing alone does not guarantee saved data.";@@ -332,6 +338,7 @@ export function createWorkspacePreviewTool({ request, transport = "unix" } = {})text:`ODS independently published and read back ${response.files} workspace static files ` +`(${response.bytes} bytes). Verified browser URL: ${response.url}. ` ++ PREVIEW_CARD_GUIDANCE + ' ' +`Inspection snapshot: ${JSON.stringify({siteId:response.siteId,sha256:response.sha256})}. ` +'Use pixel_ods_workspace_preview_inspect for this owned preview, not public web_fetch or shell HTTP. Copy both identifiers exactly; sha256 is the full snapshot digest, not entrySha256 or the shortened site suffix. ' +'Publication does not render the page; the inspection result also reports its rendered colors by area. Check them before claiming a visible color or style change. ' +diff --git a/ods/extensions/services/pixel-agent/tests/control_names_transition.test.mjs b/ods/extensions/services/pixel-agent/tests/control_names_transition.test.mjsindex 6e7b47ca9..638baa2e3 100644--- a/ods/extensions/services/pixel-agent/tests/control_names_transition.test.mjs+++ b/ods/extensions/services/pixel-agent/tests/control_names_transition.test.mjs@@ -17,6 +17,7 @@ import os from 'node:os';import path from 'node:path';import {createToolLoopGuard, WORKSPACE_PREVIEW_COMPLETE_REASON} from '../plugin/tool-loop-guard.mjs';import {REQUESTED_CONTROL_NAME_REVISION_INSTRUCTION} from '../plugin/requested-literals.mjs';+import {PREVIEW_MISSING_NOTE} from '../plugin/preview-explanation.mjs';import {PREVIEW_INSPECTION_TOOL, boundInspectionControls, boundInspectionPageErrors, boundStaticPreviewInspection,boundVisibilityInspection} from '../plugin/preview-interaction-assurance.mjs';import {INSPECTION_KIND, INSPECTION_SCOPE, TRANSITION_UNTESTED, createWorkspacePreviewInspectTool, inspectionPlanHash,@@ -176,7 +177,8 @@ function fixture(t, prompt = TOWER2.prompt) {};const finalize = answer => guard.beforeAgentFinalize({lastAssistantMessage: answer}, context);const delivered = () => guard.deliveryVerificationForRun(context.runId);- return {publish, inspect, finalize, delivered};+ const recorded = () => guard.verificationForRun(context.runId);+ return {publish, inspect, finalize, delivered, recorded};}// Laptop round 100's plan shape: the button, a click, the card afterwards; the@@ -208,7 +210,7 @@ for (const transport of ['direct', 'tool_call']) {const args = assertIncomplete(incomplete, receipt);assert.doesNotMatch(incomplete.text, NAME_REPAIR, 'a correct name is never reported missing');assert.equal(f.delivered().status, 'failed', 'the show/hide change is still untested');- assert.doesNotMatch(f.delivered().text, /has no button named/);+ assert.doesNotMatch(f.recorded().text, /has no button named/);const corrected = await f.inspect(receipt, args.steps, 'corrected', transport);assert.equal(corrected.result.details.status, 'passed');assert.doesNotMatch(corrected.text, NAME_REPAIR);@@ -233,7 +235,9 @@ for (const transport of ['direct', 'tool_call']) {reason: 'Pixel has not completed every owner-requested verified step.',retry: {instruction: REQUESTED_CONTROL_NAME_REVISION_INSTRUCTION.join('["Show sold out"]'),idempotencyKey: 'pixel-ods-workspace-preview-control-name', maxAttempts: 1}});- assert.ok(f.delivered().text.startsWith(FAILURE_NOTE), f.delivered().text);+ // The record names the control; the owner reads Portal's line about it.+ assert.ok(f.recorded().text.startsWith(FAILURE_NOTE), f.recorded().text);+ assert.ok(f.delivered().text.startsWith(PREVIEW_MISSING_NOTE), f.delivered().text);assert.equal(f.delivered().status, 'failed');// The repaired snapshot needs its own show/hide check; the same untested// plan is INCOMPLETE again, now without a name repair.@@ -258,7 +262,8 @@ test('a failed direct inspection with the harness error set still records the loassert.equal(failed.result.details.status, 'failed');assert.ok(failed.text.includes(NEXT), failed.text);assert.equal(f.delivered().status, 'failed');- assert.ok(f.delivered().text.startsWith(FAILURE_NOTE), f.delivered().text);+ assert.ok(f.recorded().text.startsWith(FAILURE_NOTE), f.recorded().text);+ assert.ok(f.delivered().text.startsWith(PREVIEW_MISSING_NOTE), f.delivered().text);});test('the aria-hidden icon page: an exact-name click the inspector cannot match is no missing name', async t => {@@ -288,7 +293,7 @@ test('the aria-hidden icon page: an exact-name click the inspector cannot match'"Show sold out", so that name is on the page;') &&unmatched.own.includes('Address that button with a CSS selector such as its id in this step, keep the other steps unchanged'),unmatched.own);- assert.doesNotMatch(f.delivered().text, /has no button named/);+ assert.doesNotMatch(f.recorded().text, /has no button named/);const css = await f.inspect(receipt, args.steps.map(step => step.action === 'click' ? {...step, locator: BUTTON_CSS} : step),'css', transport);assert.equal(css.result.details.status, 'passed');diff --git a/ods/extensions/services/pixel-agent/tests/post_publication_currency.test.mjs b/ods/extensions/services/pixel-agent/tests/post_publication_currency.test.mjsindex 7bf4ad428..621204d69 100644--- a/ods/extensions/services/pixel-agent/tests/post_publication_currency.test.mjs+++ b/ods/extensions/services/pixel-agent/tests/post_publication_currency.test.mjs@@ -10,6 +10,7 @@ import {dirname, join} from 'node:path';import {fileURLToPath} from 'node:url';import {createToolLoopGuard} from '../plugin/tool-loop-guard.mjs';import {createWorkspacePreviewVerifier} from '../plugin/workspace-preview.mjs';+import {PREVIEW_EARLIER_NOTE} from '../plugin/preview-explanation.mjs';const HOST = fileURLToPath(new URL('../host/workspace_preview.py', import.meta.url));// Publication reuses publish_snapshot; verification goes through the real@@ -98,10 +99,13 @@ async function finalAnswer({guard, context, url}) {await guard.revalidateWorkspacePreview({}, context);const delivered = guard.replyPayloadSending({runId: context.runId, kind: 'final',payload: {text: `${MODEL_ANSWER}\n\nPublished preview: ${url}`}});- return {status: guard.verificationForRun(context.runId).status, text: delivered?.payload?.text ?? ''};+ const recorded = guard.verificationForRun(context.runId);+ return {status: recorded.status, text: delivered?.payload?.text ?? '', recorded: recorded.text ?? ''};}+// The guard records why a snapshot is stale; the owner reads Portal's line.const STALE = /has not been verified again since later tool activity/;+const EARLIER = text => text.startsWith(`${PREVIEW_EARLIER_NOTE}\n\n[Open last published preview](`);const scenarios = {// Tower2 round 060: the extra CLI demo read files and wrote only stdout.'read-only exec': f => assert.equal(f.exec('python3 expense-report/report.py expense-report/data.csv', 'demo').status, 0),@@ -129,10 +133,12 @@ for (const wrapped of [false, true]) for (const [name, act] of Object.entries(scif (verified.has(name)) {assert.equal(delivered.status, 'passed');assert.ok(delivered.text.startsWith(MODEL_ANSWER), delivered.text);- assert.doesNotMatch(delivered.text, STALE);+ assert.doesNotMatch(delivered.recorded, STALE);+ assert.equal(EARLIER(delivered.text), false, delivered.text);} else {assert.equal(delivered.status, 'failed');- assert.match(delivered.text, STALE);+ assert.match(delivered.recorded, STALE);+ assert.ok(EARLIER(delivered.text), delivered.text);assert.doesNotMatch(delivered.text, new RegExp(MODEL_ANSWER), 'no verification claim for changed bytes');}});@@ -148,7 +154,8 @@ test('read-only calls after the fleet exec neither advance nor revoke the pendinfixture.invoke('read', {path: 'expense-report/public/index.html'}, {content: [{type: 'text', text: 'Expense report'}]}, 'readback');const delivered = await finalAnswer(fixture);assert.equal(delivered.status, 'passed');- assert.doesNotMatch(delivered.text, STALE);+ assert.doesNotMatch(delivered.recorded, STALE);+ assert.equal(EARLIER(delivered.text), false, delivered.text);});// Tower2 round 061 (main 17dfce8a, #6673 installed): website-create and@@ -245,6 +252,7 @@ for (const [name, run] of Object.entries(runs)) {assert.equal(delivered.status, 'passed');assert.ok(delivered.text.startsWith(run.final), delivered.text);assert.doesNotMatch(delivered.text, STALE);+ assert.ok(!delivered.text.includes(PREVIEW_EARLIER_NOTE), delivered.text);const published = publication(run.calls.findLast(publication));assert.equal(PREVIEW_READY.exec(delivered.text)?.[1], published.details.url);});diff --git a/ods/extensions/services/pixel-agent/tests/preview_explanation_delivery.test.mjs b/ods/extensions/services/pixel-agent/tests/preview_explanation_delivery.test.mjsindex f570a020a..4abe700c8 100644--- a/ods/extensions/services/pixel-agent/tests/preview_explanation_delivery.test.mjs+++ b/ods/extensions/services/pixel-agent/tests/preview_explanation_delivery.test.mjs@@ -5,21 +5,28 @@// the owner that explanation. Its press + assert-painted check had failed, so// Portal replaced the whole reply with its host delivery and the explanation// never reached the owner. A failed preview outcome now keeps the agent's-// final prose, then a fixed note (the reply is the agent's own account; the-// request did not pass Portal's checks), the failed step, and the unchanged-// host facts.+// final prose first.+//+// RTX Spark, 2026-10-25: two of four builds then ended with only "The+// attempted preview interaction checks have not passed browser inspection ...+// those checks remain unverified" under a preview that worked. The guard's+// record keeps those facts; the owner reads one plain line instead, then the+// preview receipt, which the dashboard shows as the preview card.import test from 'node:test';import assert from 'node:assert/strict';import * as fs from 'node:fs';import {createHash} from 'node:crypto';import {createServer} from 'node:http';-import {createToolLoopGuard} from '../plugin/tool-loop-guard.mjs';+import {createToolLoopGuard, WORKSPACE_PREVIEW_NOT_CREATED_DELIVERY_PREFIX,+ WORKSPACE_PREVIEW_UNVERIFIED_DELIVERY_PREFIX} from '../plugin/tool-loop-guard.mjs';import {createIngressServer} from '../host/pixel_ingress.mjs';import {PREVIEW_INSPECTION_TOOL} from '../plugin/preview-interaction-assurance.mjs';import {INSPECTION_KIND, PAINT_INSPECTION_SCOPE, PRESS_INSPECTION_SCOPE, STEP_INSPECTION_SCOPE, createWorkspacePreviewInspectTool,inspectionPlanHash} from '../plugin/workspace-preview-inspect.mjs';-import {PREVIEW_ACCOUNT_NOTE, PREVIEW_CHECK_LABEL, PREVIEW_FAILED_NOTE, PREVIEW_PENDING_NOTE, PREVIEW_STOPPED_NOTE,- explainedPreviewDelivery, foldedText, inspectionFailureLine, openFence} from '../plugin/preview-explanation.mjs';+import {PREVIEW_CONTINUE_NOTE, PREVIEW_CONTROLS_NOTE, PREVIEW_EARLIER_NOTE, PREVIEW_MISSING_NOTE, PREVIEW_NOTES,+ PREVIEW_RUNNING_NOTE, PREVIEW_SCRIPT_NOTE, PREVIEW_STOPPED_NOTE, PREVIEW_UNCONFIRMED_NOTE, explainedPreviewDelivery,+ foldedText, openFence, ownerPreviewText, previewCheckNote} from '../plugin/preview-explanation.mjs';+import {DELIVERY_NOTES} from '../../dashboard/src/lib/portalDeliveryNotes.js';const USER = 'ods-' + 'e1f'.repeat(21) + 'e';const runId = 'chatcmpl_7e1f0d2c-4b8a-4c3e-9d5f-0a1b2c3d4e5f';@@ -35,9 +42,10 @@ const EXPLANATION = 'Your observation is exactly the diagnostic I needed. The ca'My preview check reported the same single colour even with the canvas fully blanked, so my tool cannot see canvas pixels at all. ' +'Let me use your eyes instead: the fix is to draw the vignette with `drawImage` or drop that fill. I have not changed line 748 yet.';const FALSE_CLAIM = 'Fixed! The arena renders again and every check passed.';-const FAILED = `${PREVIEW_CHECK_LABEL} ${PREVIEW_ACCOUNT_NOTE} ${PREVIEW_FAILED_NOTE}`;-const PAINT_FAILURE = 'Latest browser inspection of this preview: step 2 (assert-painted) on `#arena` captured one color only (#8fce3a).';const SCOPE = 'Publication scope: this receipt verifies the published snapshot, not functional behavior or completion of other requested work.';+const receiptText = preview => `Your preview is ready.\n\n[Open preview](${preview.url})\n\nPublished from your workspace.`;+// What an owner must not read after a build that published a working preview.+const ALARM = /\b(?:fail(?:ed|s|ure)?|did not pass|not (?:been )?verified|unverified|errors?|invalid)\b|\bstep \d|assert-|#[0-9a-f]{6}\b/i;const PLAN = {viewport: {width: 1280, height: 800}, steps: [{action: 'press', locator: {selector: '#arena'}, key: 'Space'},{action: 'assert-painted', locator: {selector: '#arena'}},@@ -55,7 +63,7 @@ function transcript(reply, terminal = {role: 'assistant', content: [{type: 'text}const shown = {count: 1, visible: true, display: 'block', visibility: 'visible', opacity: '1', hidden: false, hiddenUntilFound: false, rectCount: 1};-function receipt(params, {painted}) {+function receipt(params, {painted, pageErrors}) {const paint = painted? {width: 256, height: 144, distinctColors: 212, dominant: {hex: '#1b2a1f', percent: 41},colors: [{name: 'dark gray', hex: '#1b2a1f', percent: 41}, {name: 'green', hex: '#3f7a2c', percent: 22}], fingerprint: '0f1e2d3c4b5a6978'}@@ -70,14 +78,16 @@ function receipt(params, {painted}) {status: painted ? 'passed' : 'failed', ...(painted ? {} : {errorCode: 'uniform_paint'}), paint},],diagnostics: {renderedHiddenAttributeCount: 0, hiddenUntilFoundCount: 0}, blockedRequests: [],+ ...(pageErrors ? {pageErrors: {count: 1, messages: ["TypeError: Cannot read properties of null (reading 'getContext')"]}} : {}),scope: STEP_INSPECTION_SCOPE + PRESS_INSPECTION_SCOPE + PAINT_INSPECTION_SCOPE});}// One Elf of Doom turn through the real guard: write, publish, then the-// press + assert-painted check (failed: one colour; or painted), and the-// agent's final reply at finalization when `reply` is a string (with its-// transcript, or `messages` when given).-async function elfTurn({reply, painted = false, before, after, messages, prompt = OWNER, guardOptions = {}, runOptions} = {}) {+// press + assert-painted check (failed: one colour; or painted, with or+// without page script errors), and the agent's final reply at finalization+// when `reply` is a string (with its transcript, or `messages` when given).+async function elfTurn({reply, painted = false, pageErrors = false, before, after, messages, prompt = OWNER, guardOptions = {},+ runOptions} = {}) {const guard = createToolLoopGuard({workspacePreviewInspectionAvailable: true, ...guardOptions});guard.observeRun({...context, trigger: 'user'}, 'pixel', {prompt}, runOptions);let sequence = 0;@@ -99,7 +109,7 @@ async function elfTurn({reply, painted = false, before, after, messages, prompturl: `http://${siteId}.localhost:9437/${siteId}/`, httpStatus: 200, readbackVerified: true, executable: false, overwritten: false};invoke('pixel_ods_workspace_preview', {relativeDirectory}, {details: preview});const params = {siteId, sha256, ...structuredClone(PLAN)};- const capsule = receipt(params, {painted});+ const capsule = receipt(params, {painted, pageErrors});const tool = createWorkspacePreviewInspectTool({request: async request => capsule(request)});const prepared = invoke(PREVIEW_INSPECTION_TOOL, params);const ctx = {...context, toolName: PREVIEW_INSPECTION_TOOL, toolCallId: `call-${sequence - 1}`};@@ -134,24 +144,29 @@ test('a passed visual preview cannot replace an explicitly requested project dowassert.doesNotMatch(complete.text,/requested download was not attached/);});-test('Elf of Doom: the failed paint check is the real uniform-colour receipt', async () => {- const {inspection, delivery} = await elfTurn();+test('Elf of Doom: the record keeps the failed paint check; the owner reads one plain line and the receipt', async () => {+ const {guard, preview, inspection, delivery} = await elfTurn();+ // The model still reads exactly what failed.assert.equal(inspection.isError, true);assert.equal(inspection.details.status, 'failed');assert.match(inspection.content[0].text, /captured one color only \(#8fce3a\)/);+ const recorded = guard.verificationForRun(runId);+ assert.equal(recorded.status, 'failed');+ assert.match(recorded.text, /^The attempted preview interaction checks have not passed browser inspection\./m);assert.equal(delivery.status, 'failed');- assert.match(delivery.text, /^The attempted preview interaction checks have not passed browser inspection\./m);- assert.doesNotMatch(delivery.text, /Latest browser inspection/, 'the host-only delivery is unchanged');+ assert.equal(delivery.text, `${PREVIEW_CONTROLS_NOTE}\n\n${receiptText(preview)}`);+ assert.deepEqual(delivery.preview, recorded.preview);+ assert.doesNotMatch(delivery.text, ALARM);});-test('Elf of Doom: the explanation reaches the owner, then the fixed note, the failed step and the unchanged host facts', async () => {+test('Elf of Doom: the explanation reaches the owner, then Portal\'s line and the receipt', async () => {const plain = await elfTurn({reply: ''});const {guard, preview, delivery} = await elfTurn({reply: EXPLANATION});assert.equal(delivery.status, 'failed', 'keeping the prose never certifies the preview');assert.deepEqual(delivery.preview, plain.delivery.preview);- assert.equal(delivery.text, `${EXPLANATION}\n\n${FAILED}\n\n${PAINT_FAILURE}\n\n${plain.delivery.text}`);- assert.match(delivery.text, /attempted preview interaction checks have not passed browser inspection/);- assert.ok(delivery.text.endsWith(`Your preview is ready.\n\n[Open preview](${preview.url})\n\nPublished from your workspace.`));+ assert.equal(delivery.text, `${EXPLANATION}\n\n${PREVIEW_CONTROLS_NOTE}\n\n${receiptText(preview)}`);+ assert.equal(delivery.text, `${EXPLANATION}\n\n${plain.delivery.text}`);+ assert.doesNotMatch(delivery.text.slice(EXPLANATION.length), ALARM);assert.equal(Object.keys(delivery).sort().join(), Object.keys(plain.delivery).sort().join(), 'the ingress schema is unchanged');// Channel delivery sends the same text in place of the model's reply.assert.equal(guard.replyPayloadSending({runId, kind: 'final', payload: {text: EXPLANATION}}).payload.text, delivery.text);@@ -192,7 +207,7 @@ for (const stream of [false, true]) test(`Elf of Doom: Portal ingress delivers tcontent = frames.map(frame => frame.choices?.[0]?.delta?.content ?? '').join('');} else content = JSON.parse(raw).choices[0].message.content;assert.equal(content, delivery.text);- assert.ok(content.startsWith(`${EXPLANATION}\n\n${FAILED}`));+ assert.ok(content.startsWith(`${EXPLANATION}\n\n${PREVIEW_CONTROLS_NOTE}\n\n`));if (stream) {assert.equal(terminal.pixel_outcome.status, 'failed');assert.deepEqual(terminal.pixel.preview, delivery.preview);@@ -200,9 +215,9 @@ for (const stream of [false, true]) test(`Elf of Doom: Portal ingress delivers t} finally { await close(ingress); await close(gateway); }});-// The note is the same whatever the prose claims: no wording heuristic can+// The line is the same whatever the prose claims: no wording heuristic can// miss a claim (quoted, in code, a checklist, negation-shaped, keyword-free).-test('every kept reply, however it claims success, is followed by the same plain failure note', async () => {+test('every kept reply, however it claims success, is followed by the same plain line', async () => {const plain = await elfTurn({reply: ''});const recorded = JSON.parse(fs.readFileSync(new URL('./requested-text-tower1-round067.json', import.meta.url), 'utf8')).finalAnswer;const claims = [FALSE_CLAIM, '> ✅ Verified: the game works and every check passed.',@@ -213,14 +228,14 @@ test('every kept reply, however it claims success, is followed by the same plainfor (const claim of claims) {const {delivery} = await elfTurn({reply: claim});assert.equal(delivery.status, 'failed');- assert.equal(delivery.text, `${claim}\n\n${FAILED}\n\n${PAINT_FAILURE}\n\n${plain.delivery.text}`, claim);+ assert.equal(delivery.text, `${claim}\n\n${plain.delivery.text}`, claim);}// A recorded fleet answer citing the current preview, as agents do.const {preview, delivery} = await elfTurn({reply: current => recorded.replace(/http:\/\/site-[a-f0-9]{24}\.localhost:9437\/site-[a-f0-9]{24}\//, current.url)});- assert.ok(delivery.text.startsWith(`${recorded.replace(/http:\/\/site-\S+\//, preview.url)}\n\n${FAILED}\n\n`), delivery.text);+ assert.ok(delivery.text.startsWith(`${recorded.replace(/http:\/\/site-\S+\//, preview.url)}\n\n${PREVIEW_CONTROLS_NOTE}\n\n`), delivery.text);});-const IMITATIONS = ['**Portal check:**', '**Portal check:**', '**Portal check:**', '**Portal check**:', '**Portal checks:**',+const IMITATIONS = ['**Portal check:**', '**Portal check:**', '**Portal check:**', '**Portal check**:', '**Portal checks:**','**Portal** **check:**', 'Portal check:', '**Portal check:**', 'Portal check:', '**Portal check:**'];for (const [name, reply] of [['empty', ''], ['whitespace', ' \n\t '], ['silent', 'NO_REPLY'], ['heartbeat', 'HEARTBEAT_OK'],['silent JSON', '{"action":"NO_REPLY"}'],@@ -265,16 +280,16 @@ test('only text the final assistant message holds is a reply: narration, tool caassert.deepEqual((await elfTurn({reply: EXPLANATION, messages: transcript(EXPLANATION, terminal)})).delivery, plain.delivery);const {delivery} = await elfTurn({reply: EXPLANATION, messages: transcript(EXPLANATION, terminal),guardOptions: {finalText: message => message.content.at(-1).text}});- assert.ok(delivery.text.startsWith(`${EXPLANATION}\n\n${FAILED}`));+ assert.ok(delivery.text.startsWith(`${EXPLANATION}\n\n${PREVIEW_CONTROLS_NOTE}`));});-test('a reply that announces more work says the run stopped and the step has not started', async () => {- const plain = await elfTurn();- const stopped = `${PREVIEW_CHECK_LABEL} ${PREVIEW_ACCOUNT_NOTE} ${PREVIEW_FAILED_NOTE} ${PREVIEW_STOPPED_NOTE}`;+test('a reply that announces more work is followed by the line that the next step has not started', async () => {+ const {preview} = await elfTurn();for (const reply of ["Found it: ui.js:748 assigns a canvas to fillStyle. I'll fix that line now and republish the preview so you can check it.",'The cause is ui.js:748, a canvas assigned to fillStyle.\n\nNow let me republish the preview and press Space to check the arena.']) {const {delivery} = await elfTurn({reply});- assert.equal(delivery.text, `${reply}\n\n${stopped}\n\n${PAINT_FAILURE}\n\n${plain.delivery.text}`);+ assert.equal(delivery.status, 'failed');+ assert.equal(delivery.text, `${reply}\n\n${PREVIEW_CONTINUE_NOTE}\n\n${receiptText(preview)}`);}});@@ -285,7 +300,7 @@ test('a later model call voids the reply seen at finalization (the run continuedassert.deepEqual(guard.deliveryVerificationForRun(runId), plain.delivery);// The next final reply is captured again.guard.beforeAgentFinalize({lastAssistantMessage: EXPLANATION, messages: transcript(EXPLANATION)}, context);- assert.ok(guard.deliveryVerificationForRun(runId).text.startsWith(`${EXPLANATION}\n\n${FAILED}`));+ assert.ok(guard.deliveryVerificationForRun(runId).text.startsWith(`${EXPLANATION}\n\n${PREVIEW_CONTROLS_NOTE}`));});test('the owner cancelling after finalization keeps the host-only delivery', async () => {@@ -299,7 +314,7 @@ test('the owner cancelling after finalization keeps the host-only delivery', asytest('the current preview link stays deliverable and an open code block is closed with its own fence', async () => {const {preview} = await elfTurn();const linked = `The arena is still one colour in [the preview](${preview.url}); line 748 is the cause.`;- assert.ok((await elfTurn({reply: linked})).delivery.text.startsWith(`${linked}\n\n${FAILED}\n\n`));+ assert.ok((await elfTurn({reply: linked})).delivery.text.startsWith(`${linked}\n\n${PREVIEW_CONTROLS_NOTE}\n\n`));const code = 'g.fillStyle = vignetteSprite();\ng.fillRect(0, 0, W, H);';for (const [reply, closing] of [[`The last draw call covers the frame:\n\n\`\`\`js\n${code}`, '```'],@@ -310,51 +325,63 @@ test('the current preview link stays deliverable and an open code block is close[`Inline marker:\n\n\`\`\`inline\`\`\` is not a fence, and line 748 is the cause.`, ''],]) {const {delivery} = await elfTurn({reply});- assert.ok(delivery.text.startsWith(`${reply}${closing ? `\n${closing}` : ''}\n\n${FAILED}\n\n`), delivery.text.slice(0, 400));+ assert.ok(delivery.text.startsWith(`${reply}${closing ? `\n${closing}` : ''}\n\n${PREVIEW_CONTROLS_NOTE}\n\n`), delivery.text.slice(0, 400));assert.equal(openFence(delivery.text), undefined, 'nothing after the reply is inside a code block');}});-test('passing checks keep the existing appended delivery, without repeating the prose', async () => {+test('passing checks keep the appended delivery: the receipt alone, without the record\'s scope line', async () => {const plain = await elfTurn({painted: true});- const {guard, delivery} = await elfTurn({painted: true, reply: EXPLANATION});+ const {guard, preview, delivery} = await elfTurn({painted: true, reply: EXPLANATION});assert.equal(plain.delivery.status, 'passed');assert.deepEqual(delivery, plain.delivery);assert.equal(delivery.deliveryMode, 'append');- assert.ok(!delivery.text.includes(EXPLANATION));+ assert.equal(delivery.text, receiptText(preview));+ assert.match(guard.verificationForRun(runId).text, /^Browser inspection passed for the submitted interaction checks only;/);assert.equal(guard.replyPayloadSending({runId, kind: 'final', payload: {text: EXPLANATION}}).payload.text,`${EXPLANATION}\n\n${delivery.text}\n${SCOPE}`);});-test('a still-running check keeps the explanation and says the checks have not finished', async () => {+test('a still-running check keeps the explanation and says the checks were still running', async () => {const pending = ({invoke}) => invoke('exec', {command: 'python3 -m unittest -v', background: true},{details: {status: 'running', sessionId: 'elf-check-session'}});const plain = await elfTurn({before: pending});assert.equal(plain.delivery.status, 'pending');+ assert.match(plain.guard.verificationForRun(runId).text, /^Portal stopped before the verification process reached a terminal result/);+ assert.equal(plain.delivery.text, `${PREVIEW_RUNNING_NOTE}\n\n${receiptText(plain.preview)}`);const {delivery} = await elfTurn({before: pending, reply: EXPLANATION});assert.equal(delivery.status, 'pending');- assert.equal(delivery.text, `${EXPLANATION}\n\n${PREVIEW_CHECK_LABEL} ${PREVIEW_ACCOUNT_NOTE} ${PREVIEW_PENDING_NOTE}\n\n` +- `${PAINT_FAILURE}\n\n${plain.delivery.text}`);+ assert.equal(delivery.text, `${EXPLANATION}\n\n${plain.delivery.text}`);assert.deepEqual(delivery.preview, plain.delivery.preview);+ assert.doesNotMatch(delivery.text.slice(EXPLANATION.length), ALARM);+});++test('a page that throws while Portal tests it gets a short, honest line to fix it, not an alert', async () => {+ const plain = await elfTurn({painted: true, pageErrors: true});+ assert.equal(plain.inspection.isError, undefined, 'the steps passed, but the page threw');+ assert.match(plain.inspection.content[0].text, /the page threw 1 uncaught script error/);+ assert.equal(plain.delivery.status, 'failed');+ assert.equal(plain.delivery.text, `${PREVIEW_SCRIPT_NOTE}\n\n${receiptText(plain.preview)}`);+ assert.doesNotMatch(plain.delivery.text, ALARM);+ const {delivery} = await elfTurn({painted: true, pageErrors: true, reply: EXPLANATION});+ assert.equal(delivery.text, `${EXPLANATION}\n\n${plain.delivery.text}`);});-test('a stale snapshot keeps the explanation ahead of the last-published-preview note', async () => {+test('a stale snapshot keeps the explanation ahead of the plain line about the earlier version', async () => {const stale = ({invoke}) => invoke('exec', {command: 'python3 -c "print(42)"'},{details: {status: 'completed', exitCode: 0, aggregated: '42'}});const plain = await elfTurn({after: stale});- assert.match(plain.delivery.text, /^Your last published preview is still available\./);+ assert.match(plain.guard.verificationForRun(runId).text, /^Your last published preview is still available\./);+ assert.equal(plain.delivery.text, `${PREVIEW_EARLIER_NOTE}\n\n[Open last published preview](${plain.preview.url})`);+ assert.doesNotMatch(plain.delivery.text, ALARM);const {delivery} = await elfTurn({after: stale, reply: EXPLANATION});assert.equal(delivery.status, 'failed');- // The failed step named an earlier snapshot state, so it is not repeated.- assert.equal(delivery.text, `${EXPLANATION}\n\n${FAILED}\n\n${plain.delivery.text}`);+ assert.equal(delivery.text, `${EXPLANATION}\n\n${plain.delivery.text}`);assert.deepEqual(delivery.preview, plain.delivery.preview);-});--test('a newer inspection of the snapshot that has not returned voids the failed-step line', async () => {- const rerun = ({invoke, preview}) => invoke(PREVIEW_INSPECTION_TOOL, {siteId: preview.siteId, sha256: preview.sha256, ...structuredClone(PLAN)});- const plain = await elfTurn({after: rerun});- const {delivery} = await elfTurn({after: rerun, reply: EXPLANATION});- assert.equal(delivery.text, `${EXPLANATION}\n\n${FAILED}\n\n${plain.delivery.text}`);+ // The usual live case: the agent repaired a file and was about to republish.+ const reply = 'I changed line 748 to draw the vignette with drawImage. Now let me republish the preview.';+ assert.equal((await elfTurn({after: stale, reply})).delivery.text,+ `${reply}\n\n${PREVIEW_CONTINUE_NOTE}\n\n[Open last published preview](${plain.preview.url})`);});test('a requested download that was not attached follows the explanation, even over a passing preview', async () => {@@ -362,8 +389,9 @@ test('a requested download that was not attached follows the explanation, even oconst plain = await elfTurn({painted: true, prompt});assert.equal(plain.delivery.status, 'failed');assert.match(plain.delivery.text, /^The requested download was not attached/);+ assert.ok(plain.delivery.text.endsWith(`\n\n${receiptText(plain.preview)}`), plain.delivery.text);const {delivery} = await elfTurn({painted: true, prompt, reply: EXPLANATION});- assert.equal(delivery.text, `${EXPLANATION}\n\n${FAILED}\n\n${plain.delivery.text}`);+ assert.equal(delivery.text, `${EXPLANATION}\n\n${plain.delivery.text}`);});test('a stopped extension lane over a passing preview keeps the explanation ahead of both results', async () => {@@ -376,52 +404,61 @@ test('a stopped extension lane over a passing preview keeps the explanation aheaconst plain = await elfTurn({painted: true, prompt, before: extensionFailures, runOptions});assert.equal(plain.delivery.status, 'failed');assert.match(plain.delivery.text, /extension portion.*stopped/);+ assert.ok(plain.delivery.text.startsWith(`${receiptText(plain.preview)}\n\n`), 'the passing preview keeps only its receipt');const {delivery} = await elfTurn({painted: true, prompt, before: extensionFailures, runOptions, reply: EXPLANATION});- assert.equal(delivery.text, `${EXPLANATION}\n\n${FAILED}\n\n${plain.delivery.text}`);+ assert.equal(delivery.text, `${EXPLANATION}\n\n${plain.delivery.text}`);});-test('an unpublished site keeps the explanation and still forbids local links', () => {- const turn = reply => {+test('an unpublished site keeps the explanation and an honest line with a next step, and still forbids local links', () => {+ const turn = (reply, write = true) => {const guard = createToolLoopGuard({workspacePreviewInspectionAvailable: true});guard.observeRun(context, 'pixel', {prompt: 'Build the Elf of Doom game in elf-of-doom and publish a preview.'});const ctx = {...context, toolName: 'write', toolCallId: 'write'};- const prepared = guard.beforeToolCall({toolName: 'write', runId, toolCallId: 'write', params: {path: 'elf-of-doom/index.html', content: GAME}}, ctx);- guard.afterToolCall({toolName: 'write', runId, toolCallId: 'write', params: prepared?.params ?? {path: 'elf-of-doom/index.html', content: GAME},- result: {content: [{type: 'text', text: 'Successfully wrote file.'}]}}, ctx);+ if (write) {+ const prepared = guard.beforeToolCall({toolName: 'write', runId, toolCallId: 'write', params: {path: 'elf-of-doom/index.html', content: GAME}}, ctx);+ guard.afterToolCall({toolName: 'write', runId, toolCallId: 'write', params: prepared?.params ?? {path: 'elf-of-doom/index.html', content: GAME},+ result: {content: [{type: 'text', text: 'Successfully wrote file.'}]}}, ctx);+ }if (reply !== undefined) guard.beforeAgentFinalize({lastAssistantMessage: reply, messages: transcript(reply)}, context);return guard.deliveryVerificationForRun(runId);};const plain = turn();assert.equal(plain.status, 'failed');assert.equal(plain.preview, undefined);+ assert.equal(plain.text, WORKSPACE_PREVIEW_UNVERIFIED_DELIVERY_PREFIX);+ assert.equal(turn(undefined, false).text, WORKSPACE_PREVIEW_NOT_CREATED_DELIVERY_PREFIX);+ for (const line of [WORKSPACE_PREVIEW_UNVERIFIED_DELIVERY_PREFIX, WORKSPACE_PREVIEW_NOT_CREATED_DELIVERY_PREFIX]) {+ assert.match(line, /^Portal (?:saved|didn't create) .*\bno preview to open yet\. Ask Portal to [^.]+\.$/);+ assert.doesNotMatch(line, /\bODS\b|localhost|capability|browser-accessible/);+ }const reason = 'The publish step was refused because the .harness folder in the game directory is not allowed in a preview.';- assert.equal(turn(reason).text, `${reason}\n\n${FAILED}\n\n${plain.text}`);+ assert.equal(turn(reason).text, `${reason}\n\n${plain.text}`);assert.deepEqual(turn('Your game is live at http://localhost:8080/ and works.'), plain);});-test('the failed-step line reads only bounded receipt fields, bound to the snapshot', () => {- const preview = {siteId: `site-${'a'.repeat(24)}`, sha256: 'a'.repeat(64)};- const failed = (step, extra = {}) => ({status: 'failed', siteId: preview.siteId, sha256: preview.sha256,- steps: [{index: 0, action: 'press', status: 'passed'}, {index: 1, status: 'failed', ...step}], ...extra});- assert.equal(inspectionFailureLine(failed({action: 'assert-painted', locator: {selector: '#arena'}, errorCode: 'uniform_paint',- paint: {dominant: {hex: '#8fce3a'}}}), preview), PAINT_FAILURE);- assert.equal(inspectionFailureLine(failed({action: 'click', locator: {role: 'button', name: 'Start `realm`', exact: true},- errorCode: 'no_match'}), preview),- 'Latest browser inspection of this preview: step 2 (click) on the button named `` Start `realm` `` matched no element.');- assert.equal(inspectionFailureLine(failed({action: 'assert-text', locator: {selector: '#score'}, errorCode: 'constructor'}), preview),- 'Latest browser inspection of this preview: step 2 (assert-text) on `#score` did not pass (constructor).');- assert.equal(inspectionFailureLine(failed({action: 'assert-painted', locator: {selector: '#arena'}, errorCode: 'uniform_paint',- paint: {dominant: {hex: 'url(javascript:alert(1))'}}}), preview),- 'Latest browser inspection of this preview: step 2 (assert-painted) on `#arena` did not pass (uniform_paint).');- assert.equal(inspectionFailureLine({status: 'failed', siteId: preview.siteId, sha256: preview.sha256, errorCode: 'timeout'}, preview),- 'Latest browser inspection of this preview did not complete (timeout).');- for (const details of [failed({action: 'click'}, {status: 'passed'}), failed({action: 'click'}, {sha256: 'b'.repeat(64)}),- failed({action: 'click', index: 'x'}), {status: 'failed', errorCode: 'invalid_request'}, undefined])- assert.equal(inspectionFailureLine(details, preview), undefined);- assert.equal(inspectionFailureLine(failed({action: 'click'}), undefined), undefined);+test('Portal picks one line from the check facts: a broken page, a missing request, unfinished checks, then what it could not confirm', () => {+ assert.equal(previewCheckNote({pageErrors: true, missing: true, pending: true, controls: true}), PREVIEW_SCRIPT_NOTE);+ assert.equal(previewCheckNote({missing: true, pending: true, controls: true}), PREVIEW_MISSING_NOTE);+ assert.equal(previewCheckNote({pending: true, controls: true, testFailed: true}), PREVIEW_RUNNING_NOTE);+ assert.equal(previewCheckNote({controls: true}), PREVIEW_CONTROLS_NOTE);+ assert.equal(previewCheckNote({controls: true, testFailed: true}), PREVIEW_UNCONFIRMED_NOTE, 'a failing test is not a control');+ assert.equal(previewCheckNote({}), PREVIEW_UNCONFIRMED_NOTE, 'the page itself was not checked');+ assert.equal(previewCheckNote(), PREVIEW_UNCONFIRMED_NOTE);});-test('folded text sees the label however markdown or HTML draws it; fences follow CommonMark', () => {+test('Portal\'s lines are short, calm, fixed English, and the dashboard mutes exactly these', () => {+ const lines = [...PREVIEW_NOTES, WORKSPACE_PREVIEW_UNVERIFIED_DELIVERY_PREFIX, WORKSPACE_PREVIEW_NOT_CREATED_DELIVERY_PREFIX];+ assert.equal(new Set(lines).size, lines.length);+ for (const line of lines) {+ assert.match(line, /^[\x20-\x7e]+$/, line);+ assert.ok(line.length <= 200, line);+ assert.doesNotMatch(line, /[*_`[\]<>#]/, 'plain text: no Markdown or HTML');+ }+ for (const line of PREVIEW_NOTES) assert.doesNotMatch(line, ALARM, line);+ assert.deepEqual([...DELIVERY_NOTES].sort(), [...lines].sort());+});++test('the folded text sees the label however markdown or HTML draws it; fences follow CommonMark', () => {for (const label of IMITATIONS) assert.match(foldedText(label), /portal[\s\p{P}]{0,3}checks?\b/iu, label);assert.equal(foldedText("Portal's checks"), "Portal's checks");assert.equal(openFence('```js\ncode'), '```');@@ -433,20 +470,41 @@ test('folded text sees the label however markdown or HTML draws it; fences folloassert.equal(openFence(' ```\ncode'), undefined, 'an indented line is code, not a fence');});-test('only failed or pending outcomes with host text are explained, within the ingress bound, in fixed English', () => {+test('the owner wording replaces only the outcome\'s own host text, wherever other host lines put it', () => {+ const presentation = {text: 'Fact one.\n\nFact two.\n\nReceipt.', rest: 'Receipt.', note: PREVIEW_CONTROLS_NOTE};+ assert.equal(ownerPreviewText(presentation.text, presentation), `${PREVIEW_CONTROLS_NOTE}\n\nReceipt.`);+ assert.equal(ownerPreviewText(`Download missing.\n\n${presentation.text}\n\nLane stopped.`, presentation),+ `Download missing.\n\n${PREVIEW_CONTROLS_NOTE}\n\nReceipt.\n\nLane stopped.`);+ assert.equal(ownerPreviewText(presentation.text, {...presentation, note: undefined}), 'Receipt.', 'a pass keeps the receipt only');+ assert.equal(ownerPreviewText(presentation.text, presentation, PREVIEW_CONTINUE_NOTE), `${PREVIEW_CONTINUE_NOTE}\n\nReceipt.`);+ assert.equal(ownerPreviewText('Host text.', undefined), 'Host text.');+ assert.equal(ownerPreviewText('Host text.', undefined, PREVIEW_CONTINUE_NOTE), `${PREVIEW_CONTINUE_NOTE}\n\nHost text.`);+ assert.equal(ownerPreviewText('Other text.', presentation), `${PREVIEW_CONTROLS_NOTE}\n\nOther text.`, 'never loses host text');+ assert.equal(ownerPreviewText(presentation.text, {...presentation, note: PREVIEW_STOPPED_NOTE}), `${PREVIEW_STOPPED_NOTE}\n\nReceipt.`);+});++test('only failed or pending outcomes are explained, within the ingress bound; the owner wording applies to every outcome', () => {for (const result of [{status: 'passed', text: 'Ready.'}, {status: 'none'}, {status: 'failed'}, undefined])assert.equal(explainedPreviewDelivery(result, {reply: EXPLANATION}), result);const failed = {status: 'failed', text: 'The browser check failed.'};assert.deepEqual(explainedPreviewDelivery(failed, {reply: EXPLANATION}), {status: 'failed',- text: `${EXPLANATION}\n\n${FAILED}\n\nThe browser check failed.`});- assert.deepEqual(explainedPreviewDelivery(failed, {reply: EXPLANATION, inspection: PAINT_FAILURE}), {status: 'failed',- text: `${EXPLANATION}\n\n${FAILED}\n\n${PAINT_FAILURE}\n\nThe browser check failed.`});+ text: `${EXPLANATION}\n\nThe browser check failed.`});+ const presentation = {text: 'Facts.\n\nReceipt.', rest: 'Receipt.', note: PREVIEW_CONTROLS_NOTE};+ const owned = {status: 'failed', text: `Download missing.\n\n${presentation.text}`};+ assert.deepEqual(explainedPreviewDelivery(owned, {presentation}), {status: 'failed',+ text: `Download missing.\n\n${PREVIEW_CONTROLS_NOTE}\n\nReceipt.`});+ assert.deepEqual(explainedPreviewDelivery(owned, {presentation, reply: EXPLANATION}), {status: 'failed',+ text: `${EXPLANATION}\n\nDownload missing.\n\n${PREVIEW_CONTROLS_NOTE}\n\nReceipt.`});+ assert.deepEqual(explainedPreviewDelivery({status: 'passed', text: presentation.text, deliveryMode: 'append'},+ {presentation: {...presentation, note: undefined}, reply: EXPLANATION}), {status: 'passed', text: 'Receipt.', deliveryMode: 'append'});assert.equal(explainedPreviewDelivery({status: 'pending', text: 'Still running.'}, {reply: EXPLANATION}).text,- `${EXPLANATION}\n\n${PREVIEW_CHECK_LABEL} ${PREVIEW_ACCOUNT_NOTE} ${PREVIEW_PENDING_NOTE}\n\nStill running.`);+ `${EXPLANATION}\n\nStill running.`);assert.equal(failed.text, 'The browser check failed.', 'the host result is not mutated');+ assert.equal(owned.text, `Download missing.\n\n${presentation.text}`);assert.equal(explainedPreviewDelivery(failed), failed);const long = {status: 'failed', text: 'x'.repeat(12000)};assert.equal(explainedPreviewDelivery(long, {reply: `${'The arena fill comes from line 748. '.repeat(400)}`}), long);- for (const fixed of [PREVIEW_CHECK_LABEL, PREVIEW_ACCOUNT_NOTE, PREVIEW_FAILED_NOTE, PREVIEW_PENDING_NOTE, PREVIEW_STOPPED_NOTE])- assert.match(fixed, /^[\x20-\x7e]+$/);+ assert.deepEqual(explainedPreviewDelivery({...long, text: `${long.text}\n\n${presentation.text}`},+ {presentation, reply: `${'The arena fill comes from line 748. '.repeat(400)}`}),+ {status: 'failed', text: `${long.text}\n\n${PREVIEW_CONTROLS_NOTE}\n\nReceipt.`}, 'too long: the host text alone, in the owner wording');});diff --git a/ods/extensions/services/pixel-agent/tests/requested_control_names.test.mjs b/ods/extensions/services/pixel-agent/tests/requested_control_names.test.mjsindex 65bcba6cf..25ef7a4d7 100644--- a/ods/extensions/services/pixel-agent/tests/requested_control_names.test.mjs+++ b/ods/extensions/services/pixel-agent/tests/requested_control_names.test.mjs@@ -20,6 +20,7 @@ import {extractRequestedControlNames, extractRequestedLiterals, requestedControlrequestedControlNameInstruction, requestedControlNameRevisionInstruction, requestedTextDeliveryNote,REQUESTED_CONTROL_NAME_REVISION_INSTRUCTION, MAX_REQUESTED_CONTROL_NAMES} from '../plugin/requested-literals.mjs';import {PREVIEW_INSPECTION_TOOL, boundInspectionControls} from '../plugin/preview-interaction-assurance.mjs';+import {PREVIEW_MISSING_NOTE} from '../plugin/preview-explanation.mjs';import {createWorkspacePreviewInspectTool, normalizeWorkspacePreviewInspectionParams, inspectionPlanHash}from '../plugin/workspace-preview-inspect.mjs';@@ -307,7 +308,8 @@ function fixture(t, {inspectionAvailable = true} = {}) {};const finalize = answer => guard.beforeAgentFinalize({lastAssistantMessage: answer}, context);const delivered = () => guard.deliveryVerificationForRun(context.runId);- return {write, publish, inspect, finalize, delivered};+ const recorded = () => guard.verificationForRun(context.runId);+ return {write, publish, inspect, finalize, delivered, recorded};}async function round100(t) {@@ -341,7 +343,10 @@ test('tower2 round 100: both inspections of the replaced-name snapshot carry the{action: 'finalize', reason: 'Owner-requested control names are still not met after the bounded revision.'});const outcome = f.delivered();assert.equal(outcome.status, 'failed');- assert.ok(outcome.text.startsWith(`${FAILURE_NOTE}\n\nBrowser inspection passed for the submitted show/hide checks only;`), outcome.text);+ // The record names the control; the owner reads Portal's line about it.+ assert.ok(f.recorded().text.startsWith(`${FAILURE_NOTE}\n\nBrowser inspection passed for the submitted show/hide checks only;`),+ f.recorded().text);+ assert.ok(outcome.text.startsWith(`${PREVIEW_MISSING_NOTE}\n\nYour preview is ready.`), outcome.text);assert.equal(outcome.preview.sha256, RECEIPT.sha256);});@@ -358,7 +363,7 @@ test('tower2 round 100: removing the script override, republishing and inspectinassert.equal(f.finalize('Removed the aria-label override and republished.'), undefined);const outcome = f.delivered();assert.equal(outcome.status, 'passed', outcome.text);- assert.doesNotMatch(outcome.text, /has no button named/);+ assert.doesNotMatch(f.recorded().text, /has no button named/);assert.equal(outcome.preview.sha256, republished.receipt.sha256);});diff --git a/ods/extensions/services/pixel-agent/tests/requested_heading_revision.test.mjs b/ods/extensions/services/pixel-agent/tests/requested_heading_revision.test.mjsindex 7f58bf2ea..523fd366f 100644--- a/ods/extensions/services/pixel-agent/tests/requested_heading_revision.test.mjs+++ b/ods/extensions/services/pixel-agent/tests/requested_heading_revision.test.mjs@@ -14,6 +14,7 @@ import {extractRequestedLiterals, missingRequestedText, requestedTextInstructionrequestedTextDeliveryNote, REQUESTED_HEADING_REVISION_INSTRUCTION, REQUESTED_TEXT_REVISION_INSTRUCTION}from '../plugin/requested-literals.mjs';import {PREVIEW_INSPECTION_TOOL} from '../plugin/preview-interaction-assurance.mjs';+import {PREVIEW_MISSING_NOTE} from '../plugin/preview-explanation.mjs';import {INSPECTION_KIND, INSPECTION_SCOPE, inspectionPlanHash, normalizeWorkspacePreviewInspectionParams}from '../plugin/workspace-preview-inspect.mjs';@@ -109,8 +110,9 @@ function fixture(t) {};const finalize = answer => guard.beforeAgentFinalize({lastAssistantMessage: answer}, context);const delivered = () => guard.deliveryVerificationForRun(context.runId);+ const recorded = () => guard.verificationForRun(context.runId);const revisions = () => results.filter(text => text.includes(REVISION_START)).length;- return {write, edit, publish, inspect, finalize, delivered, revisions};+ return {write, edit, publish, inspect, finalize, delivered, recorded, revisions};}// Round 073 as recorded: three writes, publish (note), inspect the same snapshot.@@ -214,7 +216,7 @@ test('tower2 round 073: the revision fires once and an exact card heading is verassert.equal(f.revisions(), 1);const outcome = f.delivered();assert.equal(outcome.status, 'passed');- assert.doesNotMatch(outcome.text, /longer headings/);+ assert.doesNotMatch(f.recorded().text, /longer headings/);assert.equal(outcome.preview.sha256, second.receipt.sha256);});@@ -225,7 +227,9 @@ test('tower2 round 073: the recorded answer after the revision gets the honest dassert.equal(f.revisions(), 1);const outcome = f.delivered();assert.equal(outcome.status, 'failed');- assert.ok(outcome.text.startsWith(`${FAILURE_NOTE}\n\n`), outcome.text);+ // The record names the headings; the owner reads Portal's line about them.+ assert.ok(f.recorded().text.startsWith(`${FAILURE_NOTE}\n\n`), f.recorded().text);+ assert.ok(outcome.text.startsWith(`${PREVIEW_MISSING_NOTE}\n\nYour preview is ready.`), outcome.text);assert.doesNotMatch(f.inspect(f.first.receipt, 'inspect-again'), new RegExp(REVISION_START), 'never a second revision');assert.equal(f.revisions(), 1);});@@ -238,5 +242,6 @@ test('tower2 round 073: an answer straight after the receipt gets the same revisretry: {instruction: REVISION.replace('[ODS Pixel next step] ', ''),idempotencyKey: 'pixel-ods-workspace-preview-requested-text', maxAttempts: 1}});assert.equal(f.finalize(TOWER2.finalAnswer)?.action, 'finalize');- assert.ok(f.delivered().text.startsWith(FAILURE_NOTE));+ assert.ok(f.recorded().text.startsWith(FAILURE_NOTE));+ assert.ok(f.delivered().text.startsWith(PREVIEW_MISSING_NOTE));});diff --git a/ods/extensions/services/pixel-agent/tests/requested_text_revision.test.mjs b/ods/extensions/services/pixel-agent/tests/requested_text_revision.test.mjsindex ee2ed6e55..75ddc318d 100644--- a/ods/extensions/services/pixel-agent/tests/requested_text_revision.test.mjs+++ b/ods/extensions/services/pixel-agent/tests/requested_text_revision.test.mjs@@ -12,6 +12,7 @@ import path from 'node:path';import {createToolLoopGuard} from '../plugin/tool-loop-guard.mjs';import {REQUESTED_TEXT_REVISION_INSTRUCTION, requestedTextRevisionInstruction} from '../plugin/requested-literals.mjs';import {PREVIEW_INSPECTION_TOOL} from '../plugin/preview-interaction-assurance.mjs';+import {PREVIEW_MISSING_NOTE} from '../plugin/preview-explanation.mjs';import {INSPECTION_KIND, INSPECTION_SCOPE, inspectionPlanHash, normalizeWorkspacePreviewInspectionParams}from '../plugin/workspace-preview-inspect.mjs';@@ -27,12 +28,14 @@ const REVISION = '[ODS Pixel next step] Requested text is still missing from the'Add the exact text as requested (for example, as the card heading if the owner described it as a card title, ' +'or as the page title or h1 if the owner named them), republish with pixel_ods_workspace_preview, and keep everything else unchanged.';const NOTE = '[ODS Pixel next step] Requested text not found: "Midnight sold-out concert". Use the owner\'s exact wording, republish and re-inspect.';-// Historical requested-text failure, as delivered now (no preview storage note).+// Historical requested-text failure, as the guard records it (no preview+// storage note), and as the owner reads it: Portal's line and the receipt.const FAILURE = 'The published page does not contain text the owner requested: "Midnight sold-out concert". ' +'The preview is available, but that requirement is not met.\n\n' +'Browser inspection passed for the submitted show/hide checks only; this does not verify all requested behavior.\n\n' +'Your preview is ready.\n\n[Open preview](http://site-877a095eea047108badd1b3b.localhost:9437/site-877a095eea047108badd1b3b/)\n\n' +'Published from your workspace.';+const OWNER_FAILURE = `${PREVIEW_MISSING_NOTE}\n\n${FAILURE.slice(FAILURE.indexOf('Your preview is ready.'))}`;// The closing provenance line depends on whether Tool Search's inner hook// also reported the publication; it is independent of the requested text.const body = text => text.replace(/\n\n(?:Created by Portal|Published from your workspace)\.$/, '');@@ -109,8 +112,9 @@ function fixture(t) {};const finalize = answer => guard.beforeAgentFinalize({lastAssistantMessage: answer}, context);const delivered = () => guard.deliveryVerificationForRun(context.runId);+ const recorded = () => guard.verificationForRun(context.runId);const revisions = () => results.filter(text => text.includes(REVISION_START)).length;- return {guard, write, edit, publish, inspect, finalize, delivered, revisions, results};+ return {guard, write, edit, publish, inspect, finalize, delivered, recorded, revisions, results};}const REVISION_START = 'Requested text is still missing from the published page';@@ -151,7 +155,7 @@ test('tower1 round 067: the revision fires once and a republish with the literalassert.equal(f.revisions(), 1);const outcome = f.delivered();assert.equal(outcome.status, 'passed');- assert.doesNotMatch(outcome.text, /does not contain text the owner requested/);+ assert.doesNotMatch(f.recorded().text, /does not contain text the owner requested/);assert.equal(outcome.preview.sha256, second.receipt.sha256);});@@ -167,7 +171,8 @@ test('tower1 round 067: a second miss ends in the unchanged honest failure', t =assert.equal(f.revisions(), 1);const outcome = f.delivered();assert.equal(outcome.status, 'failed');- assert.equal(body(outcome.text), body(FAILURE).replaceAll(f.first.receipt.url, second.receipt.url));+ assert.equal(body(f.recorded().text), body(FAILURE).replaceAll(f.first.receipt.url, second.receipt.url));+ assert.equal(body(outcome.text), body(OWNER_FAILURE).replaceAll(f.first.receipt.url, second.receipt.url));});test('tower1 round 067: answering after the revision keeps the recorded failure delivery', t => {@@ -176,7 +181,8 @@ test('tower1 round 067: answering after the revision keeps the recorded failure{action: 'finalize', reason: 'Owner-requested text is still missing after the bounded revision.'});assert.equal(f.finalize(TOWER1.finalAnswer)?.action, 'finalize', 'no loop on a repeated finalization');assert.equal(f.revisions(), 1);- assert.deepEqual({status: f.delivered().status, text: body(f.delivered().text)}, {status: 'failed', text: body(FAILURE)});+ assert.deepEqual({status: f.delivered().status, text: body(f.delivered().text)}, {status: 'failed', text: body(OWNER_FAILURE)});+ assert.equal(body(f.recorded().text), body(FAILURE));// Further tool results for that snapshot may repeat the note, never the revision.assert.doesNotMatch(f.inspect(f.first.receipt, 'inspect-again'), new RegExp(REVISION_START));assert.equal(f.revisions(), 1);@@ -196,7 +202,8 @@ test('an answer straight after the receipt gets the same revision once at finaliassert.equal(f.inspect(f.publish(ORIGINAL, 'same-bytes').receipt, 'inspect').includes(REVISION_START), false,'the finalization revision was the one revision');assert.equal(f.delivered().status, 'failed');- assert.match(f.delivered().text, /^The published page does not contain text the owner requested: "Midnight sold-out concert"\./);+ assert.match(f.recorded().text, /^The published page does not contain text the owner requested: "Midnight sold-out concert"\./);+ assert.ok(f.delivered().text.startsWith(`${PREVIEW_MISSING_NOTE}\n\nYour preview is ready.`));});test('no revision after the owner cancelled', async t => {diff --git a/ods/extensions/services/pixel-agent/tests/run_deadline_delivery.test.mjs b/ods/extensions/services/pixel-agent/tests/run_deadline_delivery.test.mjsindex 79092bee2..92a5e79e8 100644--- a/ods/extensions/services/pixel-agent/tests/run_deadline_delivery.test.mjs+++ b/ods/extensions/services/pixel-agent/tests/run_deadline_delivery.test.mjs@@ -10,6 +10,7 @@ import {createHash} from 'node:crypto';import {readFileSync} from 'node:fs';import {createIngressServer} from '../host/pixel_ingress.mjs';import {createToolLoopGuard} from '../plugin/tool-loop-guard.mjs';+import {PREVIEW_EARLIER_NOTE} from '../plugin/preview-explanation.mjs';import {RUN_PROGRESS_LIMITS, RUN_PROGRESS_STOP_REASON} from '../plugin/run-progress-budget.mjs';const RUN_ID = 'chatcmpl_3d1f6c0a-6b1e-4f7a-9a52-2e6f0c7d1a30';@@ -288,7 +289,9 @@ test('a preview edited since it was published is linked once, with what it doesf.at(30);f.guard.observeAgentEnd(CUT_OFF, OWNER);const verification = f.guard.deliveryVerificationForRun(RUN_ID);- assert.equal(verification.text, `${STOP_COPY}\n\n${stale.text}`);+ // The owner reads Portal's plain line about the stale preview, not its facts.+ assert.equal(verification.text, `${STOP_COPY}\n\n${PREVIEW_EARLIER_NOTE}\n\n[Open last published preview](${url})`);+ assert.match(stale.text, /may not include subsequent changes and does not verify completion/);assert.equal(verification.text.split(url).length, 2, 'one link');assert.deepEqual(verification.preview, stale.preview);});diff --git a/ods/extensions/services/pixel-agent/tests/tool_loop_guard.test.mjs b/ods/extensions/services/pixel-agent/tests/tool_loop_guard.test.mjsindex 587e2f8ba..433aa12da 100644--- a/ods/extensions/services/pixel-agent/tests/tool_loop_guard.test.mjs+++ b/ods/extensions/services/pixel-agent/tests/tool_loop_guard.test.mjs@@ -1,5 +1,6 @@import { RUN_PROGRESS_STOP_REASON } from "../plugin/run-progress-budget.mjs";import { PROGRESS_FINALIZATION_INSTRUCTION } from "../plugin/progress-finalization.mjs";+import { PREVIEW_EARLIER_NOTE, PREVIEW_STOPPED_NOTE } from "../plugin/preview-explanation.mjs";import test from "node:test";import vm from 'node:vm';@@ -16526,13 +16527,14 @@ test("historical preview cannot hide a later coding stop from the final reply",result: deferred ? wrappedCoreResult("exec", result) : result,}, context, "pixel");assert.equal(invoke("exec", params).blockReason, CODING_RETRY_EXHAUSTED_REASON);+ // The record keeps the stop and the failed check; the owner reads one line.+ const verification = guard.verificationForRun("coding-run");+ assert.equal(verification.status, "failed");+ assert.match(verification.text, /stopped before the requested work was complete/);+ assert.ok(verification.text.includes(VERIFICATION_FAILED_DELIVERY_PREFIX));+ assert.doesNotMatch(verification.text, /publish again to verify/);const delivered = reply(guard, {event: {runId: "coding-run", payload: {text: ""}}});- assert.match(delivered.payload.text, /stopped before the requested work was complete/);- assert.ok(delivered.payload.text.includes(VERIFICATION_FAILED_DELIVERY_PREFIX));- assert.ok(delivered.payload.text.includes(details.url));- assert.match(delivered.payload.text, /last published preview/);- assert.doesNotMatch(delivered.payload.text, /publish again to verify/);- assert.equal(guard.verificationForRun("coding-run").status, "failed");+ assert.equal(delivered.payload.text, `${PREVIEW_STOPPED_NOTE}\n\n[Open last published preview](${details.url})`);}});@@ -16544,12 +16546,13 @@ test("historical publication preserves failed and pending verification truth", (call(guard, "exec", {event: {params}});afterCall(guard, "exec", {event: {params, result: {details: status === "pending"? {status: "running", sessionId: "pending-check"} : {status: "completed", exitCode: 1}}}});- const result = reply(guard);- assert.ok(result.payload.text.includes(status === "pending"+ const verification = guard.verificationForRun("run-1");+ assert.equal(verification.status, "failed");+ assert.ok(verification.text.includes(status === "pending"? VERIFICATION_PENDING_DELIVERY_PREFIX : VERIFICATION_FAILED_DELIVERY_PREFIX));- assert.ok(result.payload.text.includes(details.url));- assert.match(result.payload.text, /last published preview/);- assert.equal(guard.verificationForRun("run-1").status, "failed");+ // The owner reads that the preview is an earlier version, with its link.+ const result = reply(guard);+ assert.equal(result.payload.text, `${PREVIEW_EARLIER_NOTE}\n\n[Open last published preview](${details.url})`);}});@@ -16740,7 +16743,7 @@ test('invalid JSON publication stays failed until repaired files are republishedinvoke('write',{path:'export-site/export.json',content:'{"source":"""broken"""}'},written);invoke('pixel_ods_workspace_preview',{relativeDirectory:'export-site'},{isError:true,content:[{type:'text',text:'Invalid JSON at export.json line 1 column 13'}],details:{schemaVersion:1,kind:'ods-pixel-workspace-preview',status:'failed',errorCode:'invalid_json_artifact'}});assert.equal(guard.verificationForRun(context.runId).status,'failed');- assert.match(guard.verificationForRun(context.runId).text,/did not verify a browser-accessible preview/i);+ assert.equal(guard.verificationForRun(context.runId).text,WORKSPACE_PREVIEW_UNVERIFIED_DELIVERY_PREFIX);const repaired={path:'export-site/export.json',content:JSON.stringify({source:'"""valid source text"""\n'})};invoke('write',repaired,written);assert.equal(guard.verificationForRun(context.runId).status,'failed','a repair alone cannot publish a preview');diff --git a/ods/extensions/services/pixel-agent/tests/workspace_preview.test.mjs b/ods/extensions/services/pixel-agent/tests/workspace_preview.test.mjsindex ba0b91fd9..51b97b3bd 100644--- a/ods/extensions/services/pixel-agent/tests/workspace_preview.test.mjs+++ b/ods/extensions/services/pixel-agent/tests/workspace_preview.test.mjs@@ -50,6 +50,7 @@ import {createWorkspacePreviewTool,EMPTY_PUBLISHED_FILES_PREFIX,normalizeWorkspacePreviewParams,+ PREVIEW_CARD_GUIDANCE,testing,} from "../plugin/workspace-preview.mjs";@@ -196,6 +197,10 @@ test("publishes only the exact existing workspace directory", async () => {assert.notEqual(snapshot.sha256,result.details.entrySha256);assert.match(result.content[0].text,/pixel_ods_workspace_preview_inspect/);assert.match(result.content[0].text, /independently published and read back/);+ // RTX Spark, 2026-10-25: a dragon picture's reply ended with an embed of the+ // site its own preview card was showing.+ assert.ok(result.content[0].text.includes(`Verified browser URL: ${result.details.url}. ${PREVIEW_CARD_GUIDANCE} Inspection snapshot:`));+ assert.match(PREVIEW_CARD_GUIDANCE, /card .*do not add an \[embed \.\.\.\] directive/);assert.match(result.content[0].text, /publication and HTTP readback only, not successful startup, interactions or durable browser storage/);// Publication renders nothing; the palette arrives with inspection.assert.match(result.content[0].text, /Publication does not render the page; the inspection result also reports its rendered colors by area\. Check them before claiming a visible color or style change\. /);