Skip to content

[bug] canvas: selected node toolbar can block Switch project after dragging #513

Backlog

Description

@yefuyou

Summary

The floating toolbar of a selected canvas node can overlap the Switch project control in the top bar after a drag. When that happens, the toolbar intercepts pointer events, so the user (and Playwright) cannot click the project switcher.

This surfaced in the isolated browser CI for both PR #422 and PR #512, although neither PR changes the affected canvas/selection layout code. It should be diagnosed and fixed independently of those Agent PRs.

CI failure evidence

  • #512 browser isolated job: tests/browser/canvas_progressive_load.mjs, open() at line 107, called by verifyLocale() around line 151.
  • Playwright repeatedly found .cw-project-chevron (Switch project) visible and enabled, but .cw-node-toolbar-anchor [data-action="panorama"] (720 panorama) intercepted pointer events for the full 20-second click timeout.
  • The isolated browser lane passed 29/30 workflows. The earlier [feat] agent: download original conversation traces as a ZIP archive (#421) #422 failure had the same blocker signature.

Isolated investigation (2026-11-25)

A read-only investigation against upstream main b9b7e587 and #512 head 09606283 found a plausible concrete mechanism using temporary instrumentation (removed after the experiment):

  1. The fixture drags and selects the Delayed node initially located around canvas coordinates (40, 80).
  2. With an initial viewport (0, 0, 1), the selected node's floating toolbar can be placed at approximately y = 28, overlapping the project switcher's vertical region y = 17–51.
  3. The viewport adjustment that should move the toolbar down is gated by blocked === false, involving src/canvas/useSelectionPresentation.ts and the interaction state in src/canvas/workspace/useWorkspaceInteraction.tsx (around lines 615–621).
  4. During drag, blocked is true. Its calculation reads pointerGesture.current.moved, which is a mutable ref and does not itself schedule a React render after pointer release. In an instrumented local run, the toolbar still covered the switcher for ~1.4 seconds after release; a later Retry interaction triggered a render and the viewport adjustment finally ran.
  5. This indicates a real hit-testing/layout overlap. A later render can make the test pass incidentally; an exact reproduction of the CI sequence that leaves it overlapping for the full 20 seconds was not obtained. Potential interruption by userNavigation() / stopPresentation() remains a hypothesis, not a confirmed root cause.

Control runs (no production code changes)

Tree Scenario Pass
#512 head 09606283 canvas_progressive_load alone 7/7
Upstream main b9b7e587 canvas_progressive_load alone 7/7
#512 head canvas_switch then canvas_progressive_load 9/10; a different off-screen-node assertion failed once
Upstream main Same pair 10/10

The test runs shared a host and the experiments do not establish a failure probability. They do not reproduce the specific CI pointer-block failure locally. The repeated cross-PR CI signature and the overlapping DOM/geometry support tracking this as a separate baseline canvas problem, rather than attributing it to #512.

Scope / desired behavior

  • The selected-node toolbar must not prevent interacting with global top-bar controls after dragging, pointer release, or viewport changes.
  • Preserve actual node selection and toolbar functionality, keyboard/pointer interactions, and viewport positioning.
  • Review how the presentation adjustment is retriggered when a gesture ends, including whether a ref-only state transition or lastLayout suppresses a needed second attempt.
  • Prefer product behavior correctness over a test-only workaround. Do not use Playwright force: true, arbitrary waits, or broader timeouts to hide an obstruction.
  • Verify the behavior with the actual project-switch button and a selected/dragged node, not merely with a mocked click event.
  • Cover both en-US and zh-CN and ensure the progressive-loading browser workflow remains stable.

Overlap check

PR #511, merged 2026-11-25, changes other nightly browser tests and documentation. The inspected #511 diff does not include canvas_progressive_load.mjs or the selection presentation logic. Please recheck latest main before implementing.

Ownership

Tracking and investigation only. Unassigned, no implementation or PR committed by this issue. Once the remaining CI-only sequence is reproduced, propose a focused product-side fix and regression test. Related to #422 and #512 but should be independently reviewed.

Activity

  1. added
    area:canvas
    on Nov 25, 2026
  2. yefuyou commented on Nov 26, 2026

    @yefuyou
    ContributorAuthor

    Follow-up investigation on current main and PR #516

    I revisited #513 on upstream main at 91b7f8a6, with the CI browser environment and a deterministic hover timing variant. The toolbar/top-bar click interception is confirmed. I already have a focused fix in PR #516 (Draft, Fixes #513), and I can own this fix through review.

    Reproduction

    Evidence and mechanism

    The Switch project control spans approximately y=17–51, within a global top bar ending at y=68 (z-index: 12). After dragging a selected node, the floating toolbar can remain at y=28–64 (z-index: 16), with elementFromPoint identifying the toolbar's Panorama action at the switcher's click point.

    There are two layers:

    1. Direct product defect: selectionPlacement did not enforce a minimum toolbar top coordinate at safe.y. It relied on a viewport adjustment that intentionally need not run after user dragging or panning. The toolbar could therefore physically cover a global control.
    2. Timing-dependent persistence of the overlap: blocked in useWorkspaceInteraction.tsx reads pointerGesture.current.moved during render. That mutable ref is not reactive. After pointerup, a same-value state update and a discarded React render can leave the presentation effect without a committed update. In the instrumented reproduction, subsequent commits had blocked=false but the adjustment effect did not run. The React behavior was additionally confirmed with a minimal test (3/3), although the exact probability of this ordering on CI runners was not measured.

    The investigation did not support lastLayout, stopPresentation(), or userNavigation() as the cause of the #513 interception.

    Fix already available in PR #516

    PR #516 clamps the toolbar to the safe top boundary: top = Math.max(safe.y, calculatedTop). This addresses the click-blocking product behavior independently of when or whether the viewport-adjustment effect runs.

    On a temporary merge of #516 with current main:

    The remaining risk is that clamping may place the toolbar over the selected node's title when the node is very close to the top edge; that limitation is stated in PR #516.

    Separate issue #514

    The stale post-drag presentation adjustment is a distinct UX defect. #516 prevents top-bar hit-test obstruction, but intentionally does not change the lifecycle of a skipped viewport adjustment. I recommend preserving the user's viewport after a completed drag and retiring any skipped auto-fit for that drag, while keeping normal first-selection fitting. That behavior should be specified and tested independently under #514.

    Request: Please review the existing focused product fix in #516 as the resolution of #513. I can carry it through review, and keep #514 separate to avoid expanding the layout fix into a viewport-semantics change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:canvas

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions