Skip to content

artifact-canvas: block navigation skips the first child of a container (whole list selected, then item 2) #1738

Closed

Description

@amrmelsayed

Symptom

While reviewing a spec/plan on the artifact canvas, stepping forward one block (the Stream Deck fine review dial, or the n key) from the paragraph that introduces a list selects the whole list rather than its first item, and the next step lands on item 2. The first list item is never individually selectable: it can only be reached as part of the whole-list selection. Items 2..n each select individually, so the asymmetry is immediately visible while reviewing. The same holds for blockquotes and nested lists: the first child of any container is swallowed by its container.

Observed live while reviewing a spec document: paragraph ("...That creates two problems:") -> whole ordered list -> item 2, with item 1 skipped.

Root cause

Two rules interact:

  1. The renderer stamps containers and their first children with the same line. packages/artifact-canvas/src/renderer/renderer.ts:75 stamps data-line on every block-open token that carries a source map. A list container (ordered_list_open) starts on the same source line as its first list_item_open and that item's inner paragraph_open, so all three carry the same data-line.

  2. Navigation dedupes to the outermost element per line. collectBlocks (packages/artifact-canvas/src/components/ArtifactCanvas.tsx:589) keeps only the first element per data-line in tree order, i.e. the outermost. For the first item's line that is the <ol>/<ul> itself, so the navigable block for that line is the whole list, and the first item has no slot of its own.

The Stream Deck dial is not a separate code path: block-next/block-prev (apps/streamdeck/src/actions.ts:1073) run the same focusMatchingBlock walk as the keyboard, so keyboard review reproduces this identically.

Note the outermost-wins dedupe is deliberate: it mirrors the marker-decoration guard (ArtifactCanvas.tsx:407) that anchors comment-card stacks to the outermost element per line (duplicate-stack / invalid-DOM fix from an earlier review iteration). Navigation and marker anchoring are intentionally coupled ("n/p land where the class is"), so a fix must keep them consistent rather than flipping only one side.

Fix shape (hypothesis to validate in the lane)

Stop stamping data-line on pure container open tokens (bullet_list_open, ordered_list_open, and likely blockquote_open) in the renderer. Consequences:

  • The outermost element for the first item's line becomes the <li>, so navigation visits item 1 like every other item.
  • Marker anchoring becomes consistent rather than changed: markers on items 2..n already anchor to their <li> today; first items join that existing behavior instead of ambiguously decorating the whole list.
  • The card-insertion DOM question (el.after() on an <li> placing the card <ul> directly inside an <ol>) is pre-existing for non-first items, not a new cost; the lane can address it once (e.g. append the stack inside the <li>).
  • renderer/__tests__/data-line.test.ts pins the current stamping and needs deliberate updating, plus a regression test that a paragraph -> list step sequence visits item 1.

Activity

  1. added
    area/vscode
    on Sep 23, 2026
  2. amrmelsayed commented on Sep 28, 2026

    @amrmelsayed
    CollaboratorAuthor

    On it! Working on a fix now.

  3. added 4 commits that reference this issue on Sep 28, 2026
    bc9fed7
    caa7168
    37059a9
    b9fc44e
  4. added 2 commits that reference this issue on Sep 28, 2026
    f010ba0
    2856ad0
  5. amrmelsayed commented on Sep 28, 2026

    @amrmelsayed
    CollaboratorAuthor

    Shipped. PR #1741 merged to main 2026-09-28T23:00:00Z as merge commit f010ba0 (owner admin-bypass merge, pr gate approved by the owner at 22:55Z).

    What landed (packages/artifact-canvas only): the renderer no longer stamps data-line/tabindex on bullet_list_open, ordered_list_open and blockquote_open, so a container's first child owns its line and is individually navigable and markable like items two onward. Containers get a CSS-only data-row attribute so the row model, gutter and in-row "+" affordance keep working. Marker cards for list items now live inside the <li>, fixing the pre-existing invalid ul > ul DOM. Two CMAP rounds; 183/183 unit and 44/44 Playwright green; CI 7/7 on the merged head.

    Deliberately out of scope: tables have the same first-child asymmetry (the <table> shares its line with the header row, <tbody> with the first body row) but need a row-versus-cell navigation decision plus <tr>/<td> card-DOM handling. Follow-up issue to be filed on the owner's word. Other non-blocking follow-ups from review are listed in the PR body.

    Release notes: docs/releases/UNRELEASED.md Other fixes updated on docs/vscode-changelog. No extension CHANGELOG entry, since no extension code changed.

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/vscode

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions