Skip to content

CODAP-296: auto-connect new graph to dataset with visible table/card#2417

Merged
bfinzer merged 3 commits intomainfrom
CODAP-296-graph-display-visible-dataset
Feb 22, 2026
Merged

CODAP-296: auto-connect new graph to dataset with visible table/card#2417
bfinzer merged 3 commits intomainfrom
CODAP-296-graph-display-visible-dataset

Conversation

@bfinzer
Copy link
Contributor

@bfinzer bfinzer commented Feb 20, 2026

Summary

  • When multiple datasets exist, a new graph now auto-connects to a dataset if exactly one has a visible (non-hidden) case table or card
  • Preserves existing behavior: a new graph still auto-connects when only one dataset exists

Test plan

  • Create a document with one dataset and a table — new graph should show points (existing behavior)
  • Create a document with two datasets, each with a table — new graph should be empty (no single visible dataset)
  • Create a document with two datasets, only one having a visible table — new graph should show points from that dataset
  • Create a document with two datasets, hide one table — new graph should show points from the dataset with the visible table

Fixes CODAP-296

🤖 Generated with Claude Code

…when multiple datasets exist

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@cypress
Copy link

cypress bot commented Feb 20, 2026

codap-v3    Run #10362

Run Properties:  status check passed Passed #10362  •  git commit 888577f011: Increment the build number
Project codap-v3
Branch Review main
Run status status check passed Passed #10362
Run duration 02m 11s
Commit git commit 888577f011: Increment the build number
Committer eireland
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 4
View all changes introduced in this branch ↗︎

@codecov
Copy link

codecov bot commented Feb 20, 2026

Codecov Report

❌ Patch coverage is 64.86486% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.53%. Comparing base (f794bda) to head (dfa1765).
⚠️ Report is 13 commits behind head on main.

Files with missing lines Patch % Lines
v3/src/components/graph/graph-registration.ts 29.41% 12 Missing ⚠️
v3/src/models/document/document-content.ts 91.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2417      +/-   ##
==========================================
- Coverage   85.53%   83.53%   -2.01%     
==========================================
  Files         756      756              
  Lines       41958    41975      +17     
  Branches    10293    10388      +95     
==========================================
- Hits        35888    35062     -826     
- Misses       6055     6896     +841     
- Partials       15       17       +2     
Flag Coverage Δ
cypress 66.28% <61.76%> (-2.91%) ⬇️
jest 57.06% <51.35%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

…orting appState singleton

Adds IDocumentContentLike interface to tile-content-info.ts and threads
documentContent through createTileSnapshotOfType/createTileOfType so that
defaultContent callbacks can access document state without global imports.
Moves isTileHidden views block earlier in DocumentContentModel to avoid
needing a cast.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates graph tile creation to auto-connect to the most relevant dataset when multiple datasets exist, based on which dataset has a visible case table/card, while preserving the existing single-dataset auto-connect behavior.

Changes:

  • Adds a lightweight documentContent interface to default tile creation options to support tile-visibility-based decisions without introducing circular dependencies.
  • Threads documentContent through tile creation helpers so tile defaultContent can consider current document visibility state.
  • Updates graph tile defaultContent to auto-connect to a dataset only when exactly one dataset has a visible case table/card (or when only one dataset exists total).

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
v3/src/models/tiles/tile-content-info.ts Adds IDocumentContentLike and extends default content options to include documentContent.
v3/src/models/document/document-content.ts Exposes isTileHidden earlier and passes document content into tile snapshot creation.
v3/src/models/codap/create-tile.ts Threads documentContent into defaultContent creation path by extending helper function signatures.
v3/src/models/codap/add-default-content.ts Passes appState.document.content into tile creation so default tiles can inspect visibility.
v3/src/components/graph/graph-registration.ts Implements dataset auto-connect selection logic based on visible table/card when multiple datasets exist.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Member

@kswenson kswenson left a comment

Choose a reason for hiding this comment

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

👍 Looks good -- the following review was developed in conjunction with Claude Code 🤖.

PR Review Summary

Changes: 6 files, +41 / -28 lines (after reviewer commits)

What it does

When a user creates a new graph in a document with multiple datasets, the graph currently stays empty (no auto-connection). This PR adds logic so that if exactly one of those datasets has a visible (non-hidden) case table or case card tile, the new graph auto-connects to that dataset. The existing single-dataset auto-connect behavior is preserved.

The approach

The core change is in graph-registration.ts in the defaultContent callback. The original code checked sharedDataSets.length === 1 and used that dataset directly. The new code introduces a branching structure:

  1. Single dataset: Same behavior as before — auto-connect.
  2. Multiple datasets: Filter to datasets whose DataSetMetadata has a caseTableTileId or caseCardTileId that corresponds to a tile that exists and is not hidden. If exactly one dataset passes this filter, auto-connect to it; otherwise leave the graph empty.

Document content is accessed via options.documentContent (an IDocumentContentLike interface added to IDefaultContentOptions), threaded through the tile creation call chain from DocumentContentModel.createTile().

Assessment

The approach is sound and well-scoped. Edge cases are handled correctly (0, 1, 2+ qualifying datasets all behave sensibly).

Changes made during review

  1. Threaded documentContent through IDefaultContentOptions instead of importing appState singleton directly in graph-registration.ts. Added IDocumentContentLike interface to tile-content-info.ts, threaded through createTileSnapshotOfType/createTileOfType, and updated callers in document-content.ts and add-default-content.ts.

  2. Moved isTileHidden views block earlier in DocumentContentModel (before the createTile actions block) so self naturally has the view at the call site without needing a cast.

  3. Added consistent optional chaining for content?.isTileHidden() calls to match content?.getTile() usage.

Issues

No concerns. This is a clean, focused, well-tested fix.

@bfinzer bfinzer merged commit abc7de3 into main Feb 22, 2026
25 of 27 checks passed
@bfinzer bfinzer deleted the CODAP-296-graph-display-visible-dataset branch February 22, 2026 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants