Skip to content

feat(agent-chat): live reload completed artifact rewrites - #26238

Closed
teamleaderleo wants to merge 35 commits into
feat-cmux-nextfrom
nx-artifacts-resume-b2-integrated-1027
Closed

teamleaderleo wants to merge 35 commits into
feat-cmux-nextfrom
nx-artifacts-resume-b2-integrated-1027

Conversation

@teamleaderleo

Copy link
Copy Markdown
Collaborator

An open written-file artifact follows later successful rewrites of the same canonical file, including a tool completion that React coalesces out of its rendered snapshots. Choosing a historical version keeps it selected; failed or stale writes do not replace it.

Leo: "the /side thing i heard somebody really liked in codex... and i think html/html artifacts and that kinda good viewing and good support for it would be cool" / "like the claude.ai artifacts but imagien you didnt need to only have it on claude.ai...".

B2 extends B1's single RowUpdates producer with a per-open subscription and a changed-tool pending map. Publication flushes that map even without listeners, carries event order across producer replacement, and never retains a prior-snapshot chain. Closing the panel, switching chats or unmounting disposes the subscription. No timer, file read, project artifact storage, new scroll correction or scan of loaded rows per token is added.

This is the written-file part recovered from this PR's original combined implementation. The stack is A (sandboxed HTML), D (complete-write detection), B1 (streamed fences), then this B2. It preserves A's explicit Run/no-network/file boundary and D's canonical path identity. The #25208 activity/command/transcript metadata stamps remain independent of the artifact producer.

Observed / Not run

  • The recovered combined source45aa passed23/23 focused tests in hosted40497592765, including the intentionally-red semantic write-order discriminator. These are prior-source evidence, not a new-head SHIP.
  • Hosted40493008642 captured the real shared renderer in light/dark: before remains at Preparing release; after reaches Release ready. Existing media remains below.
  • Integrated head 51ef5efb8cf0fecc23d7f10d2f5961876c5b0e45 (tree 99ca2e51f449d09a4925d7300860e3417be3f5de) is stacked on B1 feat(agent-chat): live reload streamed artifact fences #26230 head bd110c44d31b9a3a20c0b86b95611b1a555ae72d; own delta +420/-71 across nine files. Final-head focused behavioral red→green, current web checks and independent Astra xhigh review are pending.

Agent session: agent session

Red: bun test test/artifact-html.test.tsx: 5 expected failures (no JSX kind or HTML write output). bun run check blocked by pre-existing design-token findings outside changed files; focused lint passed.
Agent-Session: https://cmux.com/deeplink/agent?harness=codex&session=01a1756c-cf95-7a30-a911-a4a2d18a4841&host=gcp-codex-lane-2
HTML/SVG/JSX use the existing side preview, with an offline native artifact endpoint, isolated scripts, and navigation refusal. Completed full HTML writes from normalized ACP tools appear in the transcript and Outputs, with file-based versions. React/Sucrase are bundled locally and loaded after Run.

Red 68de299107d: bun test test/artifact-html.test.tsx had 5 expected failures. Green: same command 7 passed; focused artifact/panel/Inspector suite 17 passed; scoped gallery suite 27 passed. Manual Chromium VM check: 10 fixtures and parent/storage/network/file/WebSocket/image/script policy probes passed, with captures. Web bundle build, typecheck, formatting and changed-file lint passed. Localization audit passed with no new keys.

Not run: native compilation and AgentPaneArtifactNavigationTests (Linux VM has no swiftc; integration owner runs fleet verification). Full web check remains red on untouched base design-token debt at a30f457. No PR or push; artifact A handoff to nx-chat.

Agent-Session: https://cmux.com/deeplink/agent?harness=codex&session=01a1756c-cf95-7a30-a911-a4a2d18a4841&host=gcp-codex-lane-2
Draw passive artifact markup in a script-disabled srcdoc frame, then reserve the native opaque allow-scripts endpoint for explicit Run. Parse inert HTML for consent markers and refuse srcdoc-origin navigation to allowed pane or loopback routes. Deduplicate the standalone opened-write version list by recorded body.

Validation: scoped vp fmt passes on seven web files; scoped vp lint passes on new safety/runtime files. App lint reports only existing unlift/follow exhaustive-deps warnings. Swift syntax parse and git diff --check pass. No tests, builds, browser execution, push or hosted dispatch were run locally; parent owns exact-head hosted red/green and review.
Agent-Session: https://cmux.com/deeplink/agent?id=aid-196c8c4a1f392915fbea
Carry toolCanonical onto synthesized full-write diffs so canonical creates and raw-input overwrites remain one document in Outputs and the opened artifact version list.

Validation: scoped vp fmt and vp lint pass on writtenArtifacts.tsx and artifact-html.test.tsx; git diff --check passes. The focused behavioral regression is committed first at fbfd741; tests and builds are deferred to the coordinator's hosted lane. No push or dispatch.
Agent-Session: https://cmux.com/deeplink/agent?id=aid-196c8c4a1f392915fbea
Preserve the fence regressions from the existing live-reload implementation before splitting its repair. Focused hosted red/green execution is deferred until the A/D prerequisite repairs stabilize, as requested; local scoped formatting passes. The test-only scoped lint reports the expected missing artifactLive and identity APIs.

Agent-Session: https://cmux.com/deeplink/agent?id=aid-7815c3051c74f136e044
Split the existing live-reload implementation into a standalone fence change with one bounded producer for row identity, event revision and generation. Preserve nested Markdown identities, plain/highlighter fallbacks, historical selection, Run consent and producer handoff. Written files retain their static D fallback; B2 will extend this producer.

Validation: scoped vp fmt passes on all 16 changed files; browser-lane and fixed-wait checks pass. Scoped type-aware lint reports only the same unlift/follow exhaustive-deps warnings reproduced in base 305c545. Tests/builds and hosted red/green are deferred by coordinator instruction until prerequisite A/D repairs stabilize. No dispatch or push.
Agent-Session: https://cmux.com/deeplink/agent?id=aid-7815c3051c74f136e044
Restore the existing written-file regressions before the B2 implementation. The two B1 fence producer cases move back into the shared original test file without source changes. Scoped formatting and type-aware lint pass; execution is deferred by coordinator instruction, with no tests or hosted dispatch.

Agent-Session: https://cmux.com/deeplink/agent?id=aid-7815c3051c74f136e044
Restore only the approved B2 remainder of the verified live-reload implementation: extend the B1 producer with bounded tool publications and content-event order, follow canonical written-file identity across reconnects, and add the written live gallery fixture. No ArtifactPanel delta or prerequisite integration. Staged tree exactly matches bfd4176.

Validation: scoped formatting passes on eight files; browser-lane and fixed-wait static checks pass. Scoped type-aware lint reports only the existing unlift/follow App warnings previously reproduced on D base. No tests, builds, hosted dispatch, push or PR; behavioral red/green deferred by coordinator instruction.
Agent-Session: https://cmux.com/deeplink/agent?id=aid-7815c3051c74f136e044
A removed earlier tool can shift a completed file write to index zero. The regression models the dropToolItem row update after a newer write in another row and requires the newer content to remain selected. Execution is deferred by coordinator instruction; scoped diff check passes.

Agent-Session: https://cmux.com/deeplink/agent?id=aid-7815c3051c74f136e044
@blacksmith-sh

This comment has been minimized.

A large activity row with many tools must not scan all prior items when only the trailing thought changes. The regression counts indexed reads through RowUpdates.note with an explicit changed index. Execution is deferred by coordinator instruction; diff check passes.

Agent-Session: https://cmux.com/deeplink/agent?id=aid-7815c3051c74f136e044
Pass the trailing thought index to OrderedRows so RowUpdates skips the row-wide structural map on every thought chunk. Tool item identity and removal signaling remain unchanged. Scoped formatting passes; no tests, builds, dispatch, push or PR.

Agent-Session: https://cmux.com/deeplink/agent?id=aid-7815c3051c74f136e044
Capture the actual AcpmuxDirectClient thought reducer calling OrderedRows.set after 1000 tools; this discriminator must fail before 28dc when no hint is passed. Exercise the real session reset seam followed by a lower-sequence write and reject snapshots from the old producer. Runtime execution is deferred by coordinator instruction; the earlier direct producer-note test alone is not red-before evidence.

Agent-Session: https://cmux.com/deeplink/agent?id=aid-7815c3051c74f136e044
A session with the same id but a new createdAt can restart its sequence numbers. Reset creates a fresh OrderedRows producer so the open written cursor hands over once and accepts the new lower-sequence writes. Old snapshots retain the old producer generation and stay rejected after handoff. Page and history rebuilds retain the existing producer. Scoped formatting and type-aware lint on direct.ts and the regression file pass; tests/builds/dispatch/push are deferred by coordinator instruction.

Agent-Session: https://cmux.com/deeplink/agent?id=aid-7815c3051c74f136e044
@cursor

cursor Bot commented Oct 27, 2026

Copy link
Copy Markdown

Bugbot needs on-demand usage enabled

Bugbot uses usage-based billing for this team and requires on-demand usage to be enabled.

A team admin can enable on-demand usage in the Cursor dashboard.

Restore the inner HTML keys while preserving the stable outer artifact identity and explicit Run consent. useRenderFrame sends its initial document once, so a new accepted revision needs a fresh inner frame. Passive previews retain the script-disabled path. Hosted run 40536139997 supplied the meaningful existing test failure: Run live artifact retained the same iframe after a revision. Scoped formatting and diff checks pass; no local tests/builds/dispatch/push.

Agent-Session: https://cmux.com/deeplink/agent?id=aid-7815c3051c74f136e044
@blacksmith-sh

blacksmith-sh Bot commented Oct 27, 2026

Copy link
Copy Markdown

Found 84 test failures on Blacksmith runners:

Failures

Test View Logs
---/--- View Logs
---/--- View Logs
---/--- View Logs
---/--- View Logs
---/--- View Logs
---/--- View Logs
---/--- View Logs
---/--- View Logs
---/--- View Logs
---/--- View Logs

...and 74 more test failures. View all on Blacksmith

Fix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

@cmux-bot

cmux-bot Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

cmux status (one comment, edited in place; each line is updated by the job that owns it)

Unclear: web / react-apps-check failed: no known signature; failed step: Check webview test shards.

CI failed on b7f3400717 (run 40537300967 attempt 1): 1 code, 1 unknown.

Job Verdict Why
web / react-apps-check (1) code a web test failed
web / react-apps-check unknown no known signature; failed step: Check webview test shards

Failures:

  • seen on other PRs agent-pane-background-tasks.test.ts the summary card lists the chat's background tasks: running ones first, the finished folded: failed (job)
  • seen on other PRs agent-pane-hairline-focus.test.ts composer at 1x: focus is the resting hairline a step brighter, no ring: failed (job)
  • seen on other PRs agent-pane-hairline-focus.test.ts newtab at 1x: focus is the resting hairline a step brighter, no ring: failed (job)
  • seen on other PRs agent-pane-hairline-focus.test.ts composer at 2x: focus is the resting hairline a step brighter, no ring: failed (job)
  • seen on other PRs agent-pane-hairline-focus.test.ts newtab at 2x: focus is the resting hairline a step brighter, no ring: failed (job)
  • seen on other PRs agent-pane-hairline-focus.test.ts under Increase Contrast a focused edge keeps the resting edge, never a dimmer one: failed (job)
  • seen on other PRs agent-pane-hairline-focus.test.ts keyboard focus changes what a solid Send, Stop, the prompt editor's Send and a plain button paint; s...: failed (job)
  • seen on other PRs agent-pane-jump-latest-motion.test.ts chromium: a reply streaming in during Jump to latest's glide is followed to its latest row: failed (job)
Matched log lines
web / react-apps-check (1): (fail) the summary card lists the chat's background tasks: running ones first, the finished folded [2476.95ms]

Not re-run automatically: web / react-apps-check (1), web / react-apps-check are not machine failures.

Written by scripts/ci/classify_failures.py (ci-failure-attribution.yml); signatures are its SIGNATURES table. A machine verdict is the runner's fault, not this PR's; yours means the failing file is one this PR changes, also red on main that main's latest full suite fails the same way, seen on other PRs that it failed on another pull request's run lately.

CI fast guards failed on b7f3400717 (https://github.com/manaflow-ai/cmux/actions/runs/40537300967). It does not block the merge; a red guard merged into main breaks it for every open PR.
The log named no failed step; see the run.

Agents: python3 scripts/ci/guard_attribution.py fix applies the mechanical fixes locally.

@teamleaderleo

Copy link
Copy Markdown
Collaborator Author

For awareness: two P2s from #26159's review (now closed as superseded by this stack) still apply at b7f3400.

  1. artifactWrittenLive.ts:72 resets this.order = -Infinity when the producer is replaced, so a replay after a reconnect can roll the preview backward. That contradicts the body's "carries event order across producer replacement".
  2. OutputsSection.tsx builds its write map in transcript order, so the last row wins rather than the last completed write.

@teamleaderleo
teamleaderleo force-pushed the nx-artifacts-resume-b1-integrated-1027 branch from ba7a5e9 to cb38a08 Compare October 31, 2026 17:48
Base automatically changed from nx-artifacts-resume-b1-integrated-1027 to feat-cmux-next November 3, 2026 01:48
@github-actions github-actions Bot added the risk:normal Risk tier (docs/ci/risk-tiers.md) label Nov 3, 2026
@teamleaderleo

Copy link
Copy Markdown
Collaborator Author

Review (codex gpt-6.1-sol high, sweep, via the review router; full diff from merge base aa82735 to this head): SHIP at b7f3400

No P1/P2 findings.

@teamleaderleo

Copy link
Copy Markdown
Collaborator Author

Review (subagent claude-opus-5-5 medium): BLOCK at b7f3400
Visual verdict: unchanged by this diff (no new images at this head; the artifact panel behaviour is covered by its gallery entries).

The B2 code is sound as written. I read the delta from the B1 head (bd110c4) to this head: ArtifactWrittenLive, the per-open RowUpdates subscription and pending map, the OrderedRows.set changed-item and removed-tool hints, the fresh OrderedRows on session reset, and the keyed frame remount. The problem is the branch, not that code. Its merge base is 5.8k commits behind feat-cmux-next, B1 (#26230) has since squash-landed, and git merge-tree against the current base conflicts in 24 files, including App.tsx, direct.ts, ArtifactPanel.tsx, artifactLive.ts, the Swift render frame and bun.lock. This head cannot land. Resolving those files by hand produces a substantially new tree, and none of this head's CI or reviews can vouch for it.

Follow-ups:

  • [blocking] Rebase or merge onto current feat-cmux-next, dropping the already-landed A/D/B1 commits, then review the resolved head.
  • [follow-up] artifactWrittenLive.ts read(): on producer replacement it still resets this.order = -Infinity before replay, the earlier P2. The replay picks the highest order in the new rows, so a reconnect whose rows end before the last write can still move the preview back.
  • [follow-up] OutputsSection.tsx: the write map is built in transcript order, so the last row wins rather than the last completed write (earlier P2).

@teamleaderleo

Copy link
Copy Markdown
Collaborator Author

Owned by an agent session · session

@teamleaderleo

Copy link
Copy Markdown
Collaborator Author

Superseded by #33165: re-ported onto the current feat-cmux-next (#26230 landed; this branch conflicted in 24 files). It carries the written-file live reload and fixes both review P2s (no move back on producer replacement; Outputs picks the last completed write).

teamleaderleo added a commit that referenced this pull request Nov 3, 2026
…26238) (#33165)

* test: written artifacts follow the last completed rewrite

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Agent-Session: https://cmux.com/deeplink/agent?id=aid-92f5e2b3a84ca0d6f951

* feat(agent-chat): live reload completed artifact rewrites

An open written-file artifact follows later completed writes of the same
file, ordered by when each write's tool ended. A chosen older version stays
put, failed or running writes never replace it, and rows replayed after a
reconnect that end before the shown write never move it back. Session Info's
Outputs lists each file as its last completed write, not its last row.

Ported from #26238 onto the current base (B1 #26230 landed).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Agent-Session: https://cmux.com/deeplink/agent?id=aid-92f5e2b3a84ca0d6f951

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

This branch was previously deployed

1 inactive deployment
ci-routing-agent — b7f34007 Deployed Oct 27, 2026 by teamleaderleo via wait for same-key tree publisher #65765
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk:normal Risk tier (docs/ci/risk-tiers.md)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant