Skip to content

view: node ids are ::-joined strings that the page splits again #2061

Closed

Description

@shunichironomura

Warning

This content was written by an AI agent and must be verified by a human developer. After human verification, this alert may be removed.

Found in the review of #2057, which adds the experimental view. It does not block that PR; #2059 fixed the findings that did. Paths refer to #2059's head.

Problem

Node ids in the view model are flat strings with structure in them, which the CLAUDE.md type-safety rules ban.

  • NodeBuilder::render_id in crates/graphcal-project/src/view_model/project.rs falls back to format!("{}::{}", module_leaf, name) for an imported declaration with no spelling.
  • web/view/src/formula.ts recovers the parts with lastIndexOf("::").
  • The fallback uses only the module's leaf name, so two modules with the same leaf (a/lib.gcl, b/lib.gcl) can produce the same id. Not reproduced. Since view: fix the must-fix findings of the #2057 review #2059, the projection rejects a duplicate id (DuplicateNodeId) instead of drawing wrong wires.
  • The page builds composite string keys too: `${from}->${to}` and "\u0000"-joined keys in main.ts and render.ts, and the keys in selection.ts.

Proposed fix

  • Make id an opaque key, and send the spelling a reader sees (e::p_budget) in its own field.
  • On the page, replace the composite keys with nested maps or a type for an id pair.

This changes the wire format, so it belongs with the other model contract changes.

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

    refactorrustwebviewThe experimental view (web/view, graphcal view, graphcal/viewModel)

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions