Wire graph→text navigation: cycle node occurrences in the SQL editor#31
Merged
Wire graph→text navigation: cycle node occurrences in the SQL editor#31
Conversation
Closes #23. Builds on the name_spans / body_span fields shipped in #20. Behavior: - Single-clicking a graph node highlights and scrolls to the first occurrence from `nameSpans` (falling back to the legacy single `span` for column nodes, which intentionally don't populate `nameSpans` yet). - Double-clicking a CTE node jumps to its `bodySpan` instead. - Each selected table/CTE node renders a small ◀ n/total ▶ badge in its header for cycling through occurrences. The badge is hidden when the node has fewer than two occurrences. - Global keyboard shortcut: `n` advances, `Shift+n` returns to the previous occurrence. The handler is suppressed inside inputs, textareas, and the CodeMirror editor. Editor coordinate fix: - SqlView previously dispatched the analyzer's UTF-8 byte offsets directly to CodeMirror, which expects character offsets. Now uses `byteOffsetToCharOffset` from core for both the active highlight and the issue highlights. No-op for ASCII SQL; correct for non-ASCII. Store: - New `focusedOccurrenceIndex` slice plus `cycleOccurrence(direction)` and `focusOccurrence(index)` actions. Keeps cycling logic in the store so it is testable in isolation and shared by the per-node controls and the keyboard shortcut. Tests: 8 vitest cases covering forward/back cycling, wrap-around, < 2-spans no-op, no-selection no-op, and out-of-range guards. Refs #17, #20.
Consumers such as the demo app mount GraphView + SqlView directly without wrapping them in LineageExplorer, so the keyboard hook was never installed in practice. Moving the hook inside GraphView binds it to the actual surface the user interacts with. Found during a browser smoke test where the badge and ▶ button cycled correctly but n / Shift+n had no effect.
Regenerates wasm bindings against current Rust sources so downstream TypeScript consumers see the up-to-date types. No behavior change.
Extract node-merging logic into `nodeOccurrences` so graph builders, the worker, and the store all cycle through the same combined `nameSpans` when the same node appears in multiple statements. Route span→char conversion through `trySpanToCharRange` to tolerate stale spans during file switches, and pull `requestNavigation` from the store via a stable selector to break a render loop triggered by the transient `actions` object from `useLineage()`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #23. Builds on the
nameSpans/bodySpanfields shipped in #20.Behavior
nameSpan(falls back to the legacy singlespanfor column nodes, which intentionally don't populatenameSpansyet — gated on IntelliSense: alias.column completion (semantic resolver) [epic] #27).bodySpaninstead.Editor coordinate fix
SqlViewpreviously dispatched the analyzer's UTF-8 byte offsets directly to CodeMirror, which expects character offsets. This is a no-op for ASCII SQL but produces incorrect highlights when SQL contains multi-byte characters (e.g., a column comment or table name in CJK / emoji). Now uses `byteOffsetToCharOffset` from `@pondpilot/flowscope-core` for both the active highlight and the issue highlights.Store changes
Files added
Validation
What I did NOT verify
I did not run the dev server and click around in a browser — I have no browser access in this environment. The compilation / lint / unit-test surface is green, but please do a quick visual smoke test before merging:
Out of scope