Skip to content

feat(cua): virtual cursor overlay, surface snapshots, and pointer timeline drag - #562

Draft
sjungwon03 wants to merge 39 commits into
devfrom
feat/558-cua-overlay-ui
Draft

sjungwon03 wants to merge 39 commits into
devfrom
feat/558-cua-overlay-ui

Conversation

@sjungwon03

@sjungwon03 sjungwon03 commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

Summary

Implements the desktop Frontend CUA overlay, fail-closed SurfaceSnapshot reporting, synchronous drag rollback + cancelAck handshake, LLM cuaApproval/errorCode chat presentation, explicit Save DOM state markers (keeping Save strictly in the protected header outside [data-cua-safe-surface]), and Pointer Events timeline clip drag + 1-step Undo over the integrated Backend+LLM self-window CUA runtime.

  • Stacked / Integrated Base SHA: 2a7edd741993ab2f59cc15a137e546a1851fe3f2 (origin/feat/558-app-window-cua-driver, Draft PR feat(cua): add self-window input driver and session safety #560 — includes Backend ee7a24f/63eac3a/cf11d74/7bde903/bbf8835/c03f32c/2a7edd7 and LLM a1369cb/58a25f4)
  • Frontend HEAD SHA: a900bee19e93a97cd4226617209f03935c2f3977
  • Strict Ownership Boundary: git diff --name-only 2a7edd741993ab2f59cc15a137e546a1851fe3f2...HEAD touches only 23 Frontend-owned files + Frontend tests + tsconfig.node.json (0 Backend/LLM/lockfile modifications).

Implemented Capabilities

  1. Always-Mounted Fixed-Footprint Overlay & User Stop (src/renderer/src/cua/CuaOverlay.tsx, cuaOverlay.css)
    • Virtual cursor (state.cursor viewport CSS px), drag visualization (dragStart → cursor → target), phase/label/error/cleanupComplete/targetGone, and cleanup-failed + releaseFailures re-run lock banner.
    • Fixed-geometry [data-cua-protected="stop-button"] (data-testid="cua-stop-btn", 16,54,116×32 over workbench header, non-overlapping safe surfaces) mounted outside #app-shell-workspace's inert lock and kept mounted across idle (opacity: 0; pointer-events: none; disabled; tabIndex=-1) → ready → acting → stopping → stopped so protectedRects and layoutRevision never churn.
    • Global capture-phase Escape and cua-stop-btn run synchronous drag rollback before window.videoTool.cuaStop(), keeping stopping progress until main pushes stopped + cleanupComplete: true.
  2. Synchronous Drag Rollback Guard & cuaAckCancel (src/renderer/src/cua/cuaDragGuard.ts, useCuaOverlay.ts)
    • Runs at the top of onCuaStateChanged strictly before React setState: synchronously rolls back active timeline pointer drags (clearing preview + releasing pointer capture + setting aborted) and sends deduplicated window.videoTool.cuaAckCancel({ runId, cancelToken }) on stopping + cancelToken.
  3. Fail-Closed SurfaceSnapshot & inert Coordination (src/renderer/src/cua/cuaSurfaceSnapshot.ts, useCuaOverlay.ts, AppShell.tsx)
    • Reports executionBlocked, blockReason, layoutRevision, viewport, safeSurface, protectedRects, focusedInSafeSurface, focusedTestId.
    • Fails closed (safeSurface: null, executionBlocked: true) on init/unmount, onboarding/modals, Projects, Settings, and open menus.
    • Keeps layoutRevision and CuaFrame invariant when [data-cua-protected="approval-ui"] opens strictly inside the single fixed-width [data-cua-protected="agent-panel"] and across intra-safe-surface focus shifts; increments immediately on resize, scroll, modal/view change, panel resize/overlap, or focus leaving safeSurface.
  4. LLM cuaApproval & errorCode UI (AgentChatContext.tsx, AgentChatPanel.tsx)
    • Renders proposal.cuaApproval (actionKind, actionLabel, frameId, scopeRevision, coordinateSpace, coords/dragTo), disables Always allow on single-use CUA proposals, renders turn.errorCode guidance (CUA_FRAME_STALE..CUA_CLEANUP_FAILED), and wires window.videoTool.agentChatCancel.
  5. Pointer Events Timeline Clip Move/Trim, 1-Step Undo, & Protected Explicit Save DOM States (TimelineCanvas.tsx, TimelineEditor.tsx, useTimelineEditor.ts, timelinePointerDrag.ts)
    • Removed clip/handle draggable; implemented Pointer Events (setPointerCapture) with snapping/overlap preservation, synchronous abort check in pointerup, and 1-step Undo (Cmd/Ctrl+Z + [data-testid="timeline-undo-btn"]).
    • Kept explicit Save strictly in the protected header ([data-testid="editor-save-btn"] inside .oc-editor-host__header, never inside [data-cua-safe-surface] so CUA clicks cannot bypass persistence) and added data-dirty, data-saving, data-save-status="clean|dirty|saving|saved|error", data-save-error, aria-busy, and disabled on [data-testid="timeline-canvas"] and [data-testid="editor-save-btn"] (zero autosave, zero bypass API).

Confirmed DOM Selectors & Test IDs (for E2E / scripts/cua-agent-app.integration.mjs)

  • Safe surfaces (exactly 1 active per mode): [data-cua-safe-surface="timeline"] (data-testid="timeline-canvas"), [data-cua-safe-surface="canvas"], [data-cua-safe-surface="shorts-review"]
  • Protected anchors:
    • [data-cua-protected="agent-panel"] — exact count 1 (#app-shell-agent-chat, width <= viewport.width / 2, non-overlapping safeSurface)
    • [data-cua-protected="approval-ui"] — strictly inside [data-cua-protected="agent-panel"]
    • [data-cua-protected="stop-button"] + data-testid="cua-stop-btn" — fixed 16,54,116×32, outside inert
    • [data-cua-protected="settings"], [data-cua-protected="chrome-menu"], [data-cua-protected="modal"]
  • Explicit Save & Undo markers: [data-testid="editor-save-btn"] (protected inside .oc-editor-host__header; no Save button inside [data-cua-safe-surface]), [data-testid="timeline-undo-btn"], [data-testid="timeline-redo-btn"], with data-dirty, data-saving, data-save-status, data-save-error on timeline-canvas and editor-save-btn, plus data-timeline-start-ms on timeline-clip-<id>.
  • Key CUA data-testids: cua-overlay, cua-cursor, cua-drag-svg, cua-drag-start, cua-drag-progress-line, cua-drag-target-line, cua-drag-target, cua-hud, cua-phase-badge, cua-label, cua-cleanup-status, cua-target-gone, cua-error, cua-cleanup-failed-warning, cua-release-failures, cua-stop-btn, agent-cua-approval-summary, agent-cua-approval-action, agent-cua-approval-frame, agent-cua-approval-revision, agent-cua-approval-coords, agent-cua-error-code, timeline-canvas, timeline-track-<id>, timeline-lane-<id>, timeline-clip-<id>.

Verification Evidence

  • npm run typecheck — passed
  • npm test — passed (223/223 files, 1414/1414 tests)
  • npm run build — passed
  • cd mobile && npm run typecheck — passed
  • Real mounted Electron 43 Chromium verification against live CuaDriver + CuaApprovalAuthority + registerCuaIpc (2a7edd7):
    • Exact DOM invariants (agent-panel count 1, width 360px, safe-surface count 1, clip draggable === null, no timeline-save-btn in safe surface)
    • Fixed-footprint stop-button rect {x:16, y:54, width:116, height:32} invariant (layoutRevision delta = 0) across idle → ready → acting (short/240-char long label) → stopping → stopped → idle and non-overlapping with safeSurface
    • Intra-safe-surface sendInputEvent focus shifts (lane → clip-1 → lane) keep layoutRevision invariant (6 → 6)
    • Full CuaDriver.observe() → AgentChatPanel cuaApproval (layoutRevision invariant) → CuaDriver.execute(drag) (0ms → 1519ms)
    • Security check: CuaDriver.execute({ kind: 'click' }) targeting protected header editor-save-btn refused with CUA_OUT_OF_BOUNDS_OR_PROTECTED (0 save calls); explicit manual editor-save-btn click verified saving → error → saved (data-dirty="false", data-save-status="saved")
    • 1-step UI Undo & CuaDriver.execute(key: Cmd/Ctrl+Z) restore to 0ms; mid-drag main cancel & Escape stop confirm cuaAckCancel with cleanupComplete: true, releaseFailures: [], clip at 0ms, and Undo stack unchanged
    • turn.errorCode (CUA_FRAME_STALE) guidance displayed; 0 console/page/runtime errors.

Follow-up Integration Scope

This branch has not been deployed

No deployments
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