Skip to content

feat(canvas): add targeted design revisions - #709

Open
beruro wants to merge 4 commits into
developfrom
junyu/canvas-design-revisions
Open

feat(canvas): add targeted design revisions#709
beruro wants to merge 4 commits into
developfrom
junyu/canvas-design-revisions

Conversation

@beruro

@beruro beruro commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

Problem

Canvas follow-up edits currently make the agent regenerate and resend the full Canvas source before the UI shows useful progress. Even small copy changes can therefore take minutes, and the existing flow does not preserve a clear logical relationship between the original Canvas and its revision. The Canvas Design composer also needs to reuse the shared inline pill/composer treatment, and completed revision activity needs to navigate back to the corresponding Canvas without overflowing narrow chat rows.

Solution

Add a complete Canvas Design revision lifecycle:

  • select an element or region in the existing Canvas and submit context through the shared compact InputArea;
  • register revise_inline_canvas with a required same-session target_event_id;
  • prefer bounded exact edits for localized changes while retaining complete replacement payloads for structural changes;
  • keep immutable tool events in persistence and project their latest valid materialized version into one logical Canvas;
  • expose receiving/applying progress from tool-call deltas, coalesced to at most 20 Hz, while keeping the last valid Canvas visible;
  • require 1–6 request-specific agent_steps in the user's language, persist them with the revision event, and derive completion/failure only from the real tool lifecycle; legacy events without valid steps omit the list instead of synthesizing a fixed template;
  • clear transient revision state on completion, failure, cancellation, reset, and session deletion;
  • reuse shared event headers, pills, icons, composer shells, and replay navigation for the completed activity.
  • contain generated previews that are wider than the viewport and truncate long revision titles, summaries, and Agent step labels inside narrow chat rows.

Potential risks

The change spans the Rust tool contract, persisted event projection, streaming UI state, and shared composer presentation. Compact revision ancestry is deliberately bounded to 32 events, and malformed/stale patches preserve the last valid Canvas instead of applying partial content. Agent step metadata is bounded to six labels of 80 characters each; malformed metadata is rejected for new calls and omitted defensively during legacy replay. No schema migration or persistence-format rewrite is introduced; rollback is a normal revert of this commit.

Real Tauri visual verification could not be repeated from the isolated browser surface because it cannot initialize without the desktop sidecar. Component/DOM behavior and the user-provided implementation screenshots were reviewed, but a final desktop recording remains an explicit review gap. GitHub full-repository Clippy and frontend CI were still running when the PR was marked Ready; their results remain required before merge.

Audit

  • Architecture: covered all ten layers—compilation, production call-chain/dead-path trace, naming, semantic ownership, default branches, domain boundaries, developer clarity, serialized tool schema, registration parity, and target-resolution symmetry. The persisted tool event remains authoritative; the Jotai draft is transient progress only.
  • Frontend UI: 3 fixes / 10 keeps / 0 abstracts for the contextual composer; 0 fixes / 7 keeps / 0 abstracts for revision navigation; 0 fixes / 9 keeps / 1 follow-up abstract candidate for progress UI.
  • Performance verdict: pass for the changed lifecycle. There is no polling or persistent per-token write; one trailing timer per Jotai store coalesces updates at 50 ms, subscription scope is per session, and terminal/reset/session-deletion paths evict state. This does not claim a measured end-to-end speed-up; rendered timing measurement was unavailable.
  • Effects: one retained Canvas inspector Effect synchronizes DOM listeners, ResizeObserver, and requestAnimationFrame; cleanup removes listeners, disconnects the observer, cancels the frame, and tolerates remounts. Existing unrelated Effects were not expanded.

Verification

Completed during clean-branch assembly before the non-overlapping develop rebase:

  • pnpm typecheck — passed.
  • changed-file ESLint — passed.
  • targeted Vitest suite — 24 files / 110 tests passed, covering selection, shared composer layout, exact revision projection, streaming coalescing/cleanup, navigation, truncation, and session isolation.
  • targeted Rust Canvas tool tests — passed, covering schema identity, exact-edit uniqueness, persisted-chain materialization, same-session target validation, registration metadata, and tool-name stability.
  • Prettier and Rustfmt checks — passed.

Completed after rebasing onto latest develop:

  • git fetch origin develop and ancestry check — branch based on the latest target; the six incoming commits touched no PR file.
  • git diff --check origin/develop...HEAD — passed.
  • final diff scope/secrets/debug-output inspection — passed; all 81 changed files map to the Canvas lifecycle and node_modules is not tracked.

Follow-up verification after the Agent-step and overflow fixes:

  • Both focused commits passed the repository pre-commit hooks; the dynamic-step commit also passed scoped agent_core Clippy.
  • Merged current origin/develop at bbc207c8fe6e592660d4bc478afac428eacce54f; resolved the single UserMessageContent.test.ts conflict by retaining both Canvas pill and current reference-interaction coverage.
  • Post-merge pnpm typecheck — passed.
  • Post-merge targeted Vitest suite — 11 files / 61 tests passed, covering dynamic/legacy steps, overflow containment, streaming, replay, and the conflict-resolved message behavior.
  • Post-merge Rust Canvas contract suite — 12 tests passed.
  • git diff --check origin/develop...HEAD and focused secrets/debug-output scan — passed; final PR scope remains 81 Canvas lifecycle files.

Not completed:

  • rendered Tauri recording, because the isolated browser cannot initialize the required desktop sidecar.

GitHub CI status at Ready transition: AI-attribution check passed; full Rust Clippy was running and full frontend typecheck/lint/test was queued.

@beruro
beruro marked this pull request as ready for review August 6, 2026 10:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant