Skip to content

feat: Kepler: Removing currentMapId to align with artifacts - #595

Merged
ilyabo merged 4 commits into
mainfrom
feat--Kepler--Removing-currentMapId-to-align-with-artifacts
May 6, 2026
Merged

ilyabo merged 4 commits into
mainfrom
feat--Kepler--Removing-currentMapId-to-align-with-artifacts

Conversation

@ilyabo

@ilyabo ilyabo commented May 5, 2026 •

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • New Features

    • Added addFile method to load external files into Kepler maps.
  • Documentation

    • Updated Kepler README with new "Selection model" section providing guidance on map management and multi-tab scenarios.
  • Refactor

    • Improved map selection logic for robust multi-map support.

@coderabbitai

coderabbitai Bot commented May 5, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@ilyabo has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 29 minutes and 5 seconds before requesting another review.

To continue reviewing without waiting, purchase usage credits in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 22197593-aa98-4198-82df-2ef218ca621b

📥 Commits

Reviewing files that changed from the base of the PR and between c401edc and 8f43e9a.

📒 Files selected for processing (2)
  • docs/upgrade-guide.md
  • packages/kepler/src/components/CustomFilterPanelHeader.tsx
📝 Walkthrough

Walkthrough

This PR refactors Kepler's map selection from an implicit currentMapId field to an artifact-driven model. The currentMapId field is removed from the config schema, and map resolution is now performed dynamically via getCurrentKeplerMapArtifactId(). Components and hooks updated to derive mapId on-demand rather than relying on a static current-map reference.

Changes

Map Selection Refactor: currentMapId → Artifact-Driven

Layer / File(s) Summary
Config Schema
packages/kepler-config/src/index.ts
currentMapId field removed from KeplerSliceConfig; migration logic no longer provides the field when parsing config.
Core Selection Helper
examples/kepler/src/store.ts
New getCurrentKeplerMapArtifactId() helper reads current artifact ID to identify the active map; RoomState.addFile method added for external file loading.
Slice Initialization & Wiring
packages/kepler/src/KeplerSlice.ts
Schema manager initialized; all maps in config are now initialized (not just current); forward dispatch built per-map from config; setCurrentMapId and getCurrentMap APIs removed; setConfig now parses input via schema.
Hook Updates
packages/kepler/src/hooks/useDndEffects.ts, packages/kepler/src/hooks/useDndLayers.ts
mapId parameter made optional (string | undefined); guards added to bail out when mapId is not provided.
Dynamic Map Resolution
packages/kepler/src/components/CustomDndContext.tsx, packages/kepler/src/components/CustomFilterPanelHeader.tsx
Instead of reading a static currentMapId, both components scan the map entries to find the active map by matching visState or filter membership.
Current Map Hook
examples/kepler/src/components/useCurrentMap.ts
Hook now derives mapId via getCurrentKeplerMapArtifactId(state) and looks up the map in state.kepler.config.maps rather than calling state.kepler.getCurrentMap().
UI Cleanup
examples/kepler/src/components/KeplerMapsContainer.tsx
Removed SyncCurrentKeplerMap component and its internal sync effect; tab/map synchronization no longer handled implicitly.
Documentation
packages/kepler/README.md
Added "Selection model" section explaining artifact-backed map selection; example updated to derive mapId from maps[0]?.id instead of currentMapId.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • sqlrooms/sqlrooms#519: Both PRs refactor Kepler map management APIs and behaviors in KeplerSlice.ts.
  • sqlrooms/sqlrooms#563: Both PRs modify map-selection and management surface, changing how current maps are resolved.
  • sqlrooms/sqlrooms#533: Both PRs update KeplerSlice.ts to change map/dataset resolution and synchronization logic.

Suggested reviewers

  • bdjulbic

🐰 No more currentMapId to find,
Artifacts now lead the way!
Maps dance free, unconfined,
Selection's bright and clear today.
Multi-tab dreams come to stay! 🗺️✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely describes the main change: removing the currentMapId concept from Kepler code and aligning with artifacts.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat--Kepler--Removing-currentMapId-to-align-with-artifacts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@ilyabo

ilyabo commented May 6, 2026

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 6, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai 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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/kepler/src/components/CustomFilterPanelHeader.tsx (1)

88-90: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Missing backtick: ${filter.id} is not interpolated in the error message.

Line 89 uses single quotes — the thrown error will literally read "Filter index not found by id ${filter.id}" rather than including the actual filter ID value.

🐛 Proposed fix
-                throw new Error('Filter index not found by id ${filter.id}');
+                throw new Error(`Filter index not found by id ${filter.id}`);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/kepler/src/components/CustomFilterPanelHeader.tsx` around lines 88 -
90, The error message thrown in CustomFilterPanelHeader when mapId is falsy or
filterIdx is undefined uses single quotes so `${filter.id}` is not interpolated;
change the throw in the block that checks mapId and filterIdx to use a template
literal (or string concatenation) so the actual filter.id value is included in
the thrown Error (refer to variables filter.id, mapId, filterIdx and the throw
site in CustomFilterPanelHeader.tsx).
🧹 Nitpick comments (1)
packages/kepler/src/KeplerSlice.ts (1)

869-871: 💤 Low value

Dead && mapId guard — unreachable after the unconditional throw above it.

Line 871: if (!SKIP_AUTO_SAVE_ACTIONS.includes(action.type) && mapId) — mapId is always truthy here because line 869 already throws when it's undefined. The && mapId condition can be removed.

🔧 Proposed fix
-          if (!SKIP_AUTO_SAVE_ACTIONS.includes(action.type) && mapId) {
+          if (!SKIP_AUTO_SAVE_ACTIONS.includes(action.type)) {
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/kepler/src/KeplerSlice.ts` around lines 869 - 871, In KeplerSlice
(around the middleware handling where mapId is retrieved and next(action) is
called), remove the redundant "&& mapId" from the if condition since mapId is
already guaranteed by the preceding "if (!mapId) throw" check; change "if
(!SKIP_AUTO_SAVE_ACTIONS.includes(action.type) && mapId)" to simply "if
(!SKIP_AUTO_SAVE_ACTIONS.includes(action.type))" (leave the surrounding logic
that throws when mapId is missing and the call to next(action) intact).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@packages/kepler/src/components/CustomFilterPanelHeader.tsx`:
- Around line 88-90: The error message thrown in CustomFilterPanelHeader when
mapId is falsy or filterIdx is undefined uses single quotes so `${filter.id}` is
not interpolated; change the throw in the block that checks mapId and filterIdx
to use a template literal (or string concatenation) so the actual filter.id
value is included in the thrown Error (refer to variables filter.id, mapId,
filterIdx and the throw site in CustomFilterPanelHeader.tsx).

---

Nitpick comments:
In `@packages/kepler/src/KeplerSlice.ts`:
- Around line 869-871: In KeplerSlice (around the middleware handling where
mapId is retrieved and next(action) is called), remove the redundant "&& mapId"
from the if condition since mapId is already guaranteed by the preceding "if
(!mapId) throw" check; change "if (!SKIP_AUTO_SAVE_ACTIONS.includes(action.type)
&& mapId)" to simply "if (!SKIP_AUTO_SAVE_ACTIONS.includes(action.type))" (leave
the surrounding logic that throws when mapId is missing and the call to
next(action) intact).

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f3d92440-fc6b-4e10-afc8-a6fa0c5f07f5

📥 Commits

Reviewing files that changed from the base of the PR and between 761bcaf and c401edc.

📒 Files selected for processing (10)
  • examples/kepler/src/components/KeplerMapsContainer.tsx
  • examples/kepler/src/components/useCurrentMap.ts
  • examples/kepler/src/store.ts
  • packages/kepler-config/src/index.ts
  • packages/kepler/README.md
  • packages/kepler/src/KeplerSlice.ts
  • packages/kepler/src/components/CustomDndContext.tsx
  • packages/kepler/src/components/CustomFilterPanelHeader.tsx
  • packages/kepler/src/hooks/useDndEffects.ts
  • packages/kepler/src/hooks/useDndLayers.ts
💤 Files with no reviewable changes (2)
  • packages/kepler-config/src/index.ts
  • examples/kepler/src/components/KeplerMapsContainer.tsx

Copilot AI 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.

Pull request overview

This PR refactors @sqlrooms/kepler to remove the slice-owned “current map” concept (currentMapId) so host applications (especially those using @sqlrooms/artifacts) own map/tab selection, enabling more robust multi-map scenarios.

Changes:

  • Removed KeplerSliceConfig.currentMapId and the corresponding runtime APIs (getCurrentMap, setCurrentMapId), shifting selection responsibility to the host/app layer.
  • Updated Kepler initialization and drag-and-drop plumbing to work with an explicit/derived mapId (including support for mapId being undefined in DnD hooks).
  • Updated docs and the Kepler example app to derive the active map from artifact selection and documented the new selection model + migration guidance.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/kepler/src/KeplerSlice.ts Removes currentMapId-based behaviors and initializes/registers Kepler redux state per configured map.
packages/kepler/src/hooks/useDndLayers.ts Accepts mapId?: string and safely no-ops DnD handlers when no map is resolved.
packages/kepler/src/hooks/useDndEffects.ts Accepts mapId?: string and safely no-ops DnD handlers when no map is resolved.
packages/kepler/src/components/CustomFilterPanelHeader.tsx Derives mapId by locating the map that owns the filter instead of relying on currentMapId.
packages/kepler/src/components/CustomDndContext.tsx Derives mapId from the provided visState by matching it to a map entry in store state.
packages/kepler/README.md Documents the new selection model and updates example usage away from currentMapId.
packages/kepler-config/src/index.ts Updates persisted schema to remove currentMapId while keeping legacy migration support.
examples/kepler/src/store.ts Moves “current map” determination to artifacts selection and uses that for actions like adding tables after file load.
examples/kepler/src/components/useCurrentMap.ts Updates hook to resolve current map from artifact selection rather than Kepler slice state.
examples/kepler/src/components/KeplerMapsContainer.tsx Removes syncing artifact tab selection into Kepler’s (now-removed) currentMapId.
docs/upgrade-guide.md Adds a breaking-change note and migration guidance for apps moving selection to @sqlrooms/artifacts.

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

Comment on lines 60 to +64
const mapId = useStoreWithKepler(
// TODO: pass the mapId via the props, currentMapId is not necessarily the map where filter is originated from
(state) => state.kepler.config.currentMapId,
(state) =>
Object.entries(state.kepler.map).find(([, mapState]) =>
mapState?.visState.filters.some((f: Filter) => f.id === filter.id),
)?.[0],
@ilyabo
ilyabo merged commit efe9eb7 into main May 6, 2026
3 checks passed
@ilyabo
ilyabo deleted the feat--Kepler--Removing-currentMapId-to-align-with-artifacts branch May 6, 2026 12:26
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