Skip to content

fix: Pass AI run context into dashboard chart tool resolution - #627

Merged
ilyabo merged 3 commits into
mainfrom
fix-chart-tool-target-resolution
May 15, 2026
Merged

ilyabo merged 3 commits into
mainfrom
fix-chart-tool-target-resolution

Conversation

@ilyabo

@ilyabo ilyabo commented May 14, 2026 •

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • New Features

    • Chart tools now accept an execution context so tools can infer the active dashboard/artifact and table from runtime AI session data when not explicitly provided.
  • Documentation

    • Added docs describing how execution context influences resource resolution and examples for using chart tools with AI run/session context.

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 14, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: eea3cbef-75a7-4c74-a96e-2c6cab8457f4

📥 Commits

Reviewing files that changed from the base of the PR and between 5d7cd16 and 7a1c104.

📒 Files selected for processing (2)
  • packages/mosaic/README.md
  • packages/mosaic/src/index.ts
✅ Files skipped from review due to trivial changes (1)
  • packages/mosaic/README.md

📝 Walkthrough

Walkthrough

Chart tools now support optional execution context for resource resolution. A new ChartToolExecutionContext type carries session and AI run metadata; resolveResources accepts this context as a second parameter, enabling implicit dashboard artifacts to be derived from run contexts instead of only live UI state defaults.

Changes

Chart Tool Execution Context

Layer / File(s) Summary
Context type contract and resolver signature
packages/mosaic/src/chart-types/base-types.ts, packages/mosaic/src/index.ts
New ChartToolExecutionContext type with optional sessionId and aiRunContext fields; ChartToolDeps.resolveResources updated from single params to separate (params, context?) signature; barrel export exposes the new type.
Context resolution logic
apps/sqlrooms-cli-ui/src/createChartToolDeps.ts
Import context type; add getRunContextDashboardArtifactId helper to extract dashboard artifact from run context; update resolveArtifact to prefer context-derived artifact id when artifactId not explicitly provided; thread context through resolveResources.
Chart tool context threading
packages/mosaic/src/chart-types/{box-plot,count-plot,heatmap,line-chart,bubble-chart,histogram}/tool.ts
All six chart tools updated to accept context parameter in execute handler and forward it to deps.resolveResources(params, context).
AI Chart Tools documentation
packages/mosaic/README.md
New section explaining createChartTools artifact resolution with context, guidance on using execution-scoped context over live UI state, and precedence of explicit params.artifactId; includes a TypeScript example.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Suggested reviewers

  • dmitriy-kostianetskiy

Poem

🐰 A context now flows through the charts so bright,
AI run whispers guide the artifact light,
Six tools dance in sync, their signatures new,
From type to implementation, the story rings true,
No dashboard assumed—just let context choose! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 14.29% 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 describes the main change: adding AI run context parameter to chart tool resolution logic across multiple files and implementing context-aware artifact resolution.
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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-chart-tool-target-resolution

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.

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

🧹 Nitpick comments (1)
packages/mosaic/README.md (1)

229-237: ⚡ Quick win

Consider adding a code example for consistency.

Other sections in this README (useMosaicClient, Mosaic Profiler, Dashboard Panels, Chart Builder) include code examples. Adding a brief example showing how createChartTools is used and how the execution context flows through resolveResources would improve consistency and help developers understand the feature.

Example structure you might consider:

  • Show createChartTools with a resolveResources callback
  • Demonstrate accessing context.sessionId and context.aiRunContext
  • Illustrate the fallback from execution context to explicit params.artifactId

As per coding guidelines: "When changing the public API of an @sqlrooms/* package or adding new public API, update the package's README.md accordingly"—the current documentation meets this requirement, but examples are a pattern established elsewhere in this README.

🤖 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/mosaic/README.md` around lines 229 - 237, Add a small code example
to the "AI Chart Tools" section showing how to call createChartTools and provide
a ChartToolDeps.resolveResources callback that receives (params, context),
demonstrates reading context.sessionId and context.aiRunContext, and shows that
an explicit params.artifactId takes precedence over any values derived from the
execution context; include a brief comment or note in the example that
execution-scoped context is preferred over live UI state when resolving implicit
dashboard targets.
🤖 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.

Nitpick comments:
In `@packages/mosaic/README.md`:
- Around line 229-237: Add a small code example to the "AI Chart Tools" section
showing how to call createChartTools and provide a
ChartToolDeps.resolveResources callback that receives (params, context),
demonstrates reading context.sessionId and context.aiRunContext, and shows that
an explicit params.artifactId takes precedence over any values derived from the
execution context; include a brief comment or note in the example that
execution-scoped context is preferred over live UI state when resolving implicit
dashboard targets.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 82c225c9-d128-44c2-b6ef-4c1a16832f9f

📥 Commits

Reviewing files that changed from the base of the PR and between 1332308 and 5d7cd16.

📒 Files selected for processing (9)
  • apps/sqlrooms-cli-ui/src/createChartToolDeps.ts
  • packages/mosaic/README.md
  • packages/mosaic/src/chart-types/base-types.ts
  • packages/mosaic/src/chart-types/box-plot/tool.ts
  • packages/mosaic/src/chart-types/bubble-chart/tool.ts
  • packages/mosaic/src/chart-types/count-plot/tool.ts
  • packages/mosaic/src/chart-types/heatmap/tool.ts
  • packages/mosaic/src/chart-types/histogram/tool.ts
  • packages/mosaic/src/chart-types/line-chart/tool.ts

@ilyabo
ilyabo merged commit 229b4d1 into main May 15, 2026
1 of 3 checks passed
@ilyabo
ilyabo deleted the fix-chart-tool-target-resolution branch May 15, 2026 19:49
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.

1 participant