Skip to content

Scott/link click chart select#419

Open
sagrimson wants to merge 5 commits into
datacommonsorg:mainfrom
madebypxlp:scott/link-click-chart-select
Open

Scott/link click chart select#419
sagrimson wants to merge 5 commits into
datacommonsorg:mainfrom
madebypxlp:scott/link-click-chart-select

Conversation

@sagrimson

@sagrimson sagrimson commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Overview

When a user clicks a link on a card to create a chart, the atlas now intelligently handles the case where the chart already exists — instead of duplicating it, the camera pans to bring the existing chart into view alongside the source card. Additionally, the pan/zoom behavior when focusing a card pair has been refined: if the target chart is already fully visible no camera animation occurs, and when panning is needed the camera zooms out to frame both the source card and the chart together rather than simply centering on the chart.

Changes Made

  • Added focusTarget state to the atlas store to track which card pair (source + target) should be focused
  • When cardRegisterChart is called for an already-existing chart (or a generic chart already showing the same variable), set focusTarget to pan to it instead of creating a duplicate
  • Created register_card_focus.ts — a new atlas side-effect that watches focusTarget and moves the camera to frame both the source and target cards (using zoomToBounds with a capped zoom level), or waits for the shape to appear if it hasn't been created yet
  • Added FOCUS_ZOOM_DISPLAY_CAP config constant (125%) to prevent the camera from zooming in too far when both cards are close together
  • Exported resolveGrid and canFitWithinZoomCap from register_card_placement.ts for reuse in the focus logic
  • Refactored duplicated node-removal logic in queryCancel and nodeDismissFollowUp into a shared removeNode helper

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a card focusing mechanism that adjusts the camera zoom and position to keep both the source and target cards in view when a focus target is set. It integrates this behavior into the AtlasProvider and updates the AtlasStore to manage the focus target state, while also refactoring the store to reduce duplication using a new removeNode helper. Feedback on these changes suggests correcting a comment mismatch regarding the zoom cap percentage, simplifying shape ID handling by casting directly to TLShapeId instead of redundantly parsing the prefix, and refactoring the asynchronous afterCreate handler registration to prevent potential reference errors or memory leaks.

Comment thread dataweaver/apps/web/src/components/scopes/atlas/register_card_focus.ts Outdated
Comment thread dataweaver/apps/web/src/components/scopes/atlas/register_card_focus.ts Outdated
Comment thread dataweaver/apps/web/src/components/scopes/atlas/register_card_focus.ts Outdated

@beets beets left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update Scott!

The code looks great, but I have some concerns around the zoom behavior. My expectations when interacting is the zoom / scroll behavior will be the minimal movement required to get the source and selected card in frame, not the midpoint of the two.

In this example, I expected the canvas the selected card to be on the bottom left, not middle of the screen (which is quite different from the behavior when the right card is selected).

I wonder if the behavior should be updated to also account the currently selected card or the last added card, and we compute the midpoint of all three. Or other ideas to minimize the scroll.

Screen.Recording.2026-07-21.at.10.25.09.PM.mov

Could you upload this PR to dev so we can play with it more? I've also just approved all open PRs, so it would be nice to get a snapshot of all the latest code there. /cc @miss-o-soup

@sagrimson
sagrimson force-pushed the scott/link-click-chart-select branch from ff4d52e to 91c3f6c Compare July 22, 2026 16:01
…in view, instead of centering on chart when panning, zoom out a bit and center on the bounds of the card with the link and the chart
@sagrimson
sagrimson force-pushed the scott/link-click-chart-select branch from 91c3f6c to 4c3484d Compare July 23, 2026 17:37
@sagrimson

sagrimson commented Jul 23, 2026

Copy link
Copy Markdown
Contributor Author

@beets thanks for that feedback it made me rethink & it feels much nicer now! I updated so the minimum possible animation is used to get the newly selected card on screen -- It's live on .foo so let me know what you think!

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.

2 participants