Skip to content

refactor(ai): move worksheet tools to block documents - #765

Merged
ilyabo merged 3 commits into
mainfrom
codex/block-document-ai-refactor
Jun 23, 2026
Merged

ilyabo merged 3 commits into
mainfrom
codex/block-document-ai-refactor

Conversation

@ilyabo

@ilyabo ilyabo commented Jun 23, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • add generic BlockDocument AI adapter, text-block, and listing tools to @sqlrooms/documents
  • move Mosaic-owned chart/dashboard/data-table block-document tools under packages/mosaic/src/ai/block-document
  • move worksheet agent orchestration and HTML app block wrapper into apps/sqlrooms-cli-ui
  • update docs/tests and mark the Obsidian plan checklist complete

Validation

  • pnpm build
  • pnpm --filter @sqlrooms/documents typecheck
  • pnpm --filter @sqlrooms/mosaic typecheck
  • pnpm --filter sqlrooms-cli-app typecheck
  • pnpm --filter @sqlrooms/documents test
  • pnpm --filter @sqlrooms/mosaic test
  • pnpm --filter sqlrooms-cli-app build
  • pre-push hook: turbo typecheck + turbo test

Summary by CodeRabbit

  • New Features
    • Added AI tool support for block-document content: text blocks, dashboards, charts, and data-table explorer blocks.
    • Added tools to list and summarize existing block-document blocks.
    • Enabled optional HTML app block support in block-document workflows when the feature flag is on.
  • Refactor
    • Migrated worksheet AI tooling to a block-document architecture for more consistent block handling.
  • Tests / Documentation
    • Added/updated Jest test coverage for the new block-document tools and HTML app block registration behavior.
    • Updated block-document AI integration documentation and CLI AI guidance text.

@coderabbitai

coderabbitai Bot commented Jun 23, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 94cfc5a8-7e62-4922-8f50-fcd5710b4c93

📥 Commits

Reviewing files that changed from the base of the PR and between 913f175 and cbbd6ba.

📒 Files selected for processing (10)
  • apps/sqlrooms-cli-ui/src/ai/__tests__/createWorksheetBlockDocumentAiTools.test.ts
  • apps/sqlrooms-cli-ui/src/ai/constants.ts
  • apps/sqlrooms-cli-ui/src/ai/createAddHtmlAppBlockDocumentBlockTool.ts
  • apps/sqlrooms-cli-ui/src/ai/createWorksheetAgentTool.ts
  • apps/sqlrooms-cli-ui/src/ai/createWorksheetBlockDocumentAiTools.ts
  • apps/sqlrooms-cli-ui/src/createWorksheetAgent.ts
  • apps/sqlrooms-cli-ui/src/store.ts
  • packages/documents/__tests__/BlockDocumentAi.test.ts
  • packages/documents/src/BlockDocumentAi.ts
  • packages/documents/src/index.ts
🚧 Files skipped from review as they are similar to previous changes (5)
  • apps/sqlrooms-cli-ui/src/ai/tests/createWorksheetBlockDocumentAiTools.test.ts
  • packages/documents/tests/BlockDocumentAi.test.ts
  • apps/sqlrooms-cli-ui/src/ai/createAddHtmlAppBlockDocumentBlockTool.ts
  • packages/documents/src/BlockDocumentAi.ts
  • apps/sqlrooms-cli-ui/src/ai/createWorksheetAgentTool.ts

📝 Walkthrough

Walkthrough

Worksheet-scoped AI tools (createWorksheetChartTools, createAddDashboardBlockTool, createAddTextBlockTool, createListWorksheetBlocksTool, and WorksheetAiAdapter) are removed from packages/mosaic and replaced with generic block-document equivalents in packages/documents and packages/mosaic/src/ai/block-document/. The CLI worksheet agent is rewired to use a BlockDocumentAiAdapter and new createWorksheetBlockDocumentAiTools factory. Jest test infrastructure is added to the CLI, and instruction templates are updated to reference block-document chart tools and stateful block instance identifiers.

Changes

Block-Document AI Tool Migration

Layer / File(s) Summary
BlockDocumentAiAdapter contract and shared types
packages/documents/package.json, packages/documents/src/BlockDocumentAi.ts, packages/mosaic/src/ai/block-document/constants.ts, packages/mosaic/src/ai/types.ts
Defines BlockDocumentAiAdapter interface (setCurrentBlockDocument, ensureBlockDocument, getBlocks, addBlock), tool-name constants (BLOCK_DOCUMENT_TEXT_TOOL_NAME, BLOCK_DOCUMENT_LIST_BLOCKS_TOOL_NAME, BLOCK_DOCUMENT_CHART_TOOL_PREFIX, KnownMosaicBlockDocumentTools), BlockDocumentBlockSummary type, and extra-tool factory types. Adds ai as a dependency to packages/documents.
Generic block-document text tool
packages/documents/src/createAddBlockDocumentTextBlockTool.ts
Implements createAddBlockDocumentTextBlockTool with Zod-validated heading/paragraph/list creation and createBlockDocumentTextBlock helper that generates unique block IDs and applies type-specific defaults.
Generic block-document list tool
packages/documents/src/createListBlockDocumentBlocksTool.ts
Implements createListBlockDocumentBlocksTool with Zod validation, summarizeBlock helper that conditionally extracts metadata (title, caption, tableName, statefulBlock details), and error-safe execution.
Block-document tools documentation and exports
packages/documents/src/index.ts, packages/documents/README.md
Re-exports both text and list tools from index. Documents usage patterns in README showing BlockDocumentAiAdapter integration.
Block-document tool test coverage
packages/documents/__tests__/BlockDocumentAi.test.ts
Jest tests for both text and list tools covering success/failure scenarios with stubbed adapters, block creation validation, and block summarization with legacy field omission.
Mosaic block-document chart tools
packages/mosaic/src/ai/block-document/createBlockDocumentChartTools.ts
Introduces createBlockDocumentChartTools factory with chart-type resolution, chart tool parameters, and addChart callback that validates tableName and appends chart blocks to the adapter.
Mosaic dashboard block tool
packages/mosaic/src/ai/block-document/createAddMosaicDashboardBlockTool.ts
Introduces createAddMosaicDashboardBlockTool with Zod-validated input (dashboardTitle, tableName, optional intent, reasoning) and structured success/failure responses.
Mosaic data-table explorer tool
packages/mosaic/src/ai/block-document/createBlockDocumentDataTableExplorerTool.ts
Introduces createBlockDocumentDataTableExplorerTool wrapping createDataTableExplorerTool with validation, adapter integration, and default title handling.
Mosaic constants and JSDoc updates
packages/mosaic/src/ai/worksheet/constants.ts, packages/mosaic/src/charts/chart-types/createChartTools.ts
Removes WORKSHEET_CHART_TOOL_PREFIX and KnownWorksheetTools. Updates chart tools JSDoc example to reference block-document prefix.
Mosaic public API exports reorganization
packages/mosaic/src/ai.ts, packages/mosaic/src/index.ts, packages/mosaic/README.md
Replaces worksheet-specific exports with block-document tool factories, error/metadata helpers, and chart utilities. Updates README to document block-document integrations. Removes createWorksheetAgentTool and worksheet-specific types.
Mosaic block-document tool test coverage
packages/mosaic/__tests__/block-document-ai.test.ts
Comprehensive Jest tests for dashboard and data-table explorer tools, including success paths with adapter/callback verification and failure scenarios with error handling.
CLI WorksheetAiAdapter refactored to BlockDocumentAiAdapter
apps/sqlrooms-cli-ui/src/createWorksheetAiAdapter.ts
Renames return type to BlockDocumentAiAdapter. Renames methods (setCurrentWorksheet → setCurrentBlockDocument, ensureWorksheet → ensureBlockDocument). Removes addDashboardBlock and addDataTableExplorerBlock from adapter contract.
CLI worksheet AI constants
apps/sqlrooms-cli-ui/src/ai/constants.ts
New module exporting WORKSHEET_AGENT_TOOL_NAME, composed KnownWorksheetTools, and EXPERIMENTAL_WORKSHEET_AGENT_INSTRUCTIONS template.
CLI HTML app block-document tool
apps/sqlrooms-cli-ui/src/ai/createAddHtmlAppBlockDocumentBlockTool.ts
Introduces createAddHtmlAppBlockDocumentBlockTool and createHtmlAppBlockDocumentBlock helper for creating stateful HTML app blocks with auto-generated IDs, default height (560), and optional intent metadata.
CLI worksheet block-document tool collection
apps/sqlrooms-cli-ui/src/ai/createWorksheetBlockDocumentAiTools.ts
New factory composing chart, text, dashboard, data-table, and list tools with optional HTML app blocks and extraTools extensibility. Includes ensureNoOverride guard and validation that embedded HTML app agent is present when enabled.
CLI worksheet block-document tools test coverage
apps/sqlrooms-cli-ui/src/ai/__tests__/createWorksheetBlockDocumentAiTools.test.ts
Jest tests verifying default tool absence, error throwing when HTML app blocks enabled without embedded agent, and conditional tool registration with reference equality.
CLI worksheet agent instructions refactored
apps/sqlrooms-cli-ui/src/ai/createWorksheetAgentTool.ts (instructions)
getWorksheetAgentInstructions now generates non-generic templates using BLOCK_DOCUMENT_CHART_TOOL_PREFIX and statefulBlock.blockInstanceId for dashboard/app/map ID references. Rewrites guidance for block-document chart tool invocation patterns.
CLI worksheet agent execution wired to block-document
apps/sqlrooms-cli-ui/src/ai/createWorksheetAgentTool.ts (execute)
Updates execute to call ensureBlockDocument/setCurrentBlockDocument, wires createWorksheetBlockDocumentAiTools instead of createWorksheetAiTools, and passes blockDocumentAdapter. Preserves agent loop and result shape.
CLI worksheet agent options restructured
apps/sqlrooms-cli-ui/src/createWorksheetAgent.ts
Imports block-document tool factories and constants. Rebuilds worksheetAgentOptions with blockDocumentAdapter, explicit createDashboardBlock/createDataTableExplorerBlock callbacks returning stateful blocks, and revised extraTools wiring for experimental HTML app and map block tools.
CLI store instruction template updates
apps/sqlrooms-cli-ui/src/store.ts
Updates EXPERIMENTAL_SQLROOMS_CLI_AI_INSTRUCTIONS to use interpolated tool name constants (WORKSHEET_AGENT_TOOL_NAME, KnownWorksheetTools.embedded_html_app_agent) instead of hardcoded strings.
CLI Jest configuration and test infrastructure
apps/sqlrooms-cli-ui/jest.config.js, apps/sqlrooms-cli-ui/package.json
Adds Jest configuration with ts-jest and ESM support, test npm script with experimental VM modules, and Jest/ts-jest/preset tooling to devDependencies.

Sequence Diagram(s)

sequenceDiagram
  participant Host as createWorksheetAgent
  participant AgentTool as createWorksheetAgentTool
  participant Adapter as BlockDocumentAiAdapter
  participant ToolFactory as createWorksheetBlockDocumentAiTools
  participant Agent as ToolLoopAgent

  Host->>AgentTool: execute(worksheetId, intent)
  AgentTool->>Adapter: ensureBlockDocument(worksheetId)
  AgentTool->>Adapter: setCurrentBlockDocument(worksheetId)
  AgentTool->>ToolFactory: create tools with blockDocumentAdapter
  ToolFactory-->>AgentTool: Record<string, Tool>
  AgentTool->>Agent: runSubAgent(tools, instructions)
  Agent->>Adapter: addBlock or getBlocks via individual tools
  Adapter-->>Agent: blockId or nodes
  Agent-->>AgentTool: finalOutput
  AgentTool-->>Host: WorksheetAgentResult
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • sqlrooms/sqlrooms#749: Introduces the intent field migration for AI-created blocks, which threads through the new createAddHtmlAppBlockDocumentBlockTool and dashboard block tool options in this PR.
  • sqlrooms/sqlrooms#757: Adds and conditions the direct worksheet map block tool and map-specific agent instructions in the same CLI worksheet agent file this PR updates.

Suggested reviewers

  • dmitriy-kostianetskiy
  • lixun910

🐇 Hops along the block-document lane,
Old worksheet tools? Gone, not in vain!
A new adapter blooms — ensureBlockDocument it cries,
Charts and dashboards added, no more worksheet ties.
The rabbit builds tools that compose just right! 🛠️✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 55.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 PR title 'refactor(ai): move worksheet tools to block documents' clearly and accurately summarizes the primary change: restructuring AI tools from a worksheet-focused architecture to a block-document-based architecture.
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 codex/block-document-ai-refactor

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.

@ilyabo
ilyabo marked this pull request as ready for review June 23, 2026 07:25

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

2. For an existing map, call ${KnownWorksheetTools.list_blocks} and pass the mapId to create_worksheet_map_block`

P2 Badge Point map updates at blockInstanceId

When experimental worksheet maps are enabled, the new generic lister no longer returns a top-level mapId; it returns the resource id as statefulBlock.blockInstanceId. This instruction still tells the agent to pass mapId, so update requests for an existing worksheet map can fail to target the existing block (or create a duplicate) depending on which conflicting prompt line the model follows. Update this text to use statefulBlock.blockInstanceId or restore a mapId alias in the list output.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

inputSchema: AddMosaicDashboardBlockToolInput,
execute: async ({dashboardTitle, tableName, intent}) => {
try {
const {dashboardId, block} = createDashboardBlock({

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Validate the target document before creating dashboards

When addBlock rejects (for example because the target block document was deleted or an adapter requires ensureBlockDocument before mutation), the host callback has already created durable dashboard state; in the CLI callback that means createDashboard/setSelectedTable have run, so the tool reports failure while leaving an unattached dashboard. Call blockDocumentAdapter.ensureBlockDocument(blockDocumentId) before createDashboardBlock, or roll back the created dashboard if appending the block fails.

Useful? React with 👍 / 👎.

@ilyabo
ilyabo force-pushed the codex/block-document-ai-refactor branch from 1038639 to cbf9962 Compare June 23, 2026 07:48

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

Actionable comments posted: 3

🧹 Nitpick comments (1)
apps/sqlrooms-cli-ui/src/ai/createWorksheetAgentTool.ts (1)

362-379: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Prevent worksheet tools from shadowing data tools.

createWorksheetBlockDocumentAiTools guards only against overriding worksheet built-ins. Since its result is spread after dataTools, an extra tool named query, list_tables, or read_table_schema would silently replace the core data tool and break analysis.

Proposed collision check
         const dataTools = options.createDataTools?.({store}) ?? {};
+        const worksheetTools = createWorksheetBlockDocumentAiTools({
+          databaseAdapter,
+          blockDocumentAdapter,
+          worksheetId,
+          chartToolsOptions,
+          dashboardAgentTool,
+          extraTools,
+          htmlAppBlocksEnabled,
+          createDashboardBlock,
+          createDataTableExplorerBlock,
+        });
+        const duplicateToolNames = Object.keys(worksheetTools).filter(
+          (toolName) => toolName in dataTools,
+        );
+
+        if (duplicateToolNames.length > 0) {
+          throw new Error(
+            `Worksheet AI tools cannot override data tools: ${duplicateToolNames.join(
+              ', ',
+            )}`,
+          );
+        }
 
         const agent = new ToolLoopAgent({
           model: options.getModel({state: store.getState()}),
           tools: {
             ...dataTools,
-            ...createWorksheetBlockDocumentAiTools({
-              databaseAdapter,
-              blockDocumentAdapter,
-              worksheetId,
-              chartToolsOptions,
-              dashboardAgentTool,
-              extraTools,
-              htmlAppBlocksEnabled,
-              createDashboardBlock,
-              createDataTableExplorerBlock,
-            }),
+            ...worksheetTools,
           },
🤖 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 `@apps/sqlrooms-cli-ui/src/ai/createWorksheetAgentTool.ts` around lines 362 -
379, The tools object spreads dataTools first and then spreads the result of
createWorksheetBlockDocumentAiTools second, which means any tools returned from
createWorksheetBlockDocumentAiTools with names like query, list_tables, or
read_table_schema will override the core data tools. Reorder the spread
operators in the tools object so that dataTools is spread after
createWorksheetBlockDocumentAiTools, ensuring that the core data tools take
precedence and cannot be shadowed by worksheet-specific tools.
🤖 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.

Inline comments:
In `@apps/sqlrooms-cli-ui/src/ai/createWorksheetBlockDocumentAiTools.ts`:
- Line 99: The `htmlAppBlocksEnabled` field is hardcoded to true, which allows
the `add_html_app_block` tool to be registered and the agent to call
`embedded_html_app_agent`, but this embedded tool is only available if the
optional `extraTools` parameter supplies it, creating a dead-end for default
configuration users. Either set `htmlAppBlocksEnabled` to false by default, or
add validation logic that checks whether `embedded_html_app_agent` is actually
present in `extraTools` when `htmlAppBlocksEnabled` is true, throwing an error
if it is not. Additionally, add tests to verify this behavior works correctly in
both scenarios (with and without the embedded tool available).

In `@packages/documents/src/createAddBlockDocumentTextBlockTool.ts`:
- Around line 117-121: In the execute function, before calling
blockDocumentAdapter.addBlock on line 120, you need to call ensureBlockDocument
with the blockDocumentId to ensure the block document exists. Add a call to
ensureBlockDocument(blockDocumentId) before the createBlockDocumentTextBlock
call or before the addBlock call to satisfy the precondition that the document
must exist before mutation operations are performed.

In
`@packages/mosaic/src/ai/block-document/createBlockDocumentDataTableExplorerTool.ts`:
- Around line 39-53: The addDataTable function calls
createDataTableExplorerBlock before verifying that the target block document
exists, which can cause the host-side block state to be created even if the
subsequent addBlock call fails. To fix this, call ensureBlockDocument to confirm
the block document exists before invoking createDataTableExplorerBlock.
Additionally, add a regression test that mirrors the dashboard missing-document
case to verify that the host callback is not invoked when ensureBlockDocument
fails.

---

Nitpick comments:
In `@apps/sqlrooms-cli-ui/src/ai/createWorksheetAgentTool.ts`:
- Around line 362-379: The tools object spreads dataTools first and then spreads
the result of createWorksheetBlockDocumentAiTools second, which means any tools
returned from createWorksheetBlockDocumentAiTools with names like query,
list_tables, or read_table_schema will override the core data tools. Reorder the
spread operators in the tools object so that dataTools is spread after
createWorksheetBlockDocumentAiTools, ensuring that the core data tools take
precedence and cannot be shadowed by worksheet-specific tools.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 74b3ccbf-2ed4-424f-93ec-0e98c2072897

📥 Commits

Reviewing files that changed from the base of the PR and between 213239f and cbf9962.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (32)
  • apps/sqlrooms-cli-ui/src/ai/createAddHtmlAppBlockDocumentBlockTool.ts
  • apps/sqlrooms-cli-ui/src/ai/createWorksheetAgentTool.ts
  • apps/sqlrooms-cli-ui/src/ai/createWorksheetBlockDocumentAiTools.ts
  • apps/sqlrooms-cli-ui/src/createWorksheetAgent.ts
  • apps/sqlrooms-cli-ui/src/createWorksheetAiAdapter.ts
  • packages/documents/README.md
  • packages/documents/__tests__/BlockDocumentAi.test.ts
  • packages/documents/package.json
  • packages/documents/src/BlockDocumentAi.ts
  • packages/documents/src/createAddBlockDocumentTextBlockTool.ts
  • packages/documents/src/createListBlockDocumentBlocksTool.ts
  • packages/documents/src/index.ts
  • packages/mosaic/README.md
  • packages/mosaic/__tests__/block-document-ai.test.ts
  • packages/mosaic/__tests__/worksheet-ai.test.ts
  • packages/mosaic/src/ai.ts
  • packages/mosaic/src/ai/block-document/constants.ts
  • packages/mosaic/src/ai/block-document/createAddMosaicDashboardBlockTool.ts
  • packages/mosaic/src/ai/block-document/createBlockDocumentChartTools.ts
  • packages/mosaic/src/ai/block-document/createBlockDocumentDataTableExplorerTool.ts
  • packages/mosaic/src/ai/types.ts
  • packages/mosaic/src/ai/worksheet/constants.ts
  • packages/mosaic/src/ai/worksheet/createAddDashboardBlockTool.ts
  • packages/mosaic/src/ai/worksheet/createAddHtmlAppBlockTool.ts
  • packages/mosaic/src/ai/worksheet/createAddTextBlockTool.ts
  • packages/mosaic/src/ai/worksheet/createListWorksheetBlocksTool.ts
  • packages/mosaic/src/ai/worksheet/createWorksheetAiTools.ts
  • packages/mosaic/src/ai/worksheet/createWorksheetChartTools.ts
  • packages/mosaic/src/ai/worksheet/createWorksheetDataTableExplorerTool.ts
  • packages/mosaic/src/ai/worksheet/worksheet-types.ts
  • packages/mosaic/src/charts/chart-types/createChartTools.ts
  • packages/mosaic/src/index.ts
💤 Files with no reviewable changes (10)
  • packages/mosaic/src/ai/worksheet/createWorksheetChartTools.ts
  • packages/mosaic/tests/worksheet-ai.test.ts
  • packages/mosaic/src/ai/worksheet/createWorksheetAiTools.ts
  • packages/mosaic/src/ai/worksheet/constants.ts
  • packages/mosaic/src/ai/worksheet/createAddTextBlockTool.ts
  • packages/mosaic/src/ai/worksheet/createAddHtmlAppBlockTool.ts
  • packages/mosaic/src/ai/worksheet/createWorksheetDataTableExplorerTool.ts
  • packages/mosaic/src/ai/worksheet/createAddDashboardBlockTool.ts
  • packages/mosaic/src/ai/worksheet/worksheet-types.ts
  • packages/mosaic/src/ai/worksheet/createListWorksheetBlocksTool.ts

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cbf9962fae

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

mapBlocksEnabled
? '✅ For map requests, use the direct worksheet map block tool; call list_worksheet_blocks first when updating an existing map and pass its mapId'
: `✅ For map requests, use ${KnownWorksheetTools.list_blocks} then ${KnownWorksheetTools.embedded_dashboard_agent} so the map is added as a dashboard panel`
? `- For map requests, use the direct worksheet map block tool; call ${KnownWorksheetTools.list_blocks} first when updating an existing map and pass its mapId`

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Use the nested map id returned by list_blocks

When experimental map blocks are enabled, list_block_document_blocks no longer returns the old flat mapId; the new generic summarizer only exposes the stateful resource id as statefulBlock.blockInstanceId. Leaving this instruction as mapId (also repeated in the short tool description below) makes updates to an existing worksheet map likely call create_worksheet_map_block without the existing id, creating a duplicate map block instead of updating the one that was listed. Update the prompt to pass statefulBlock.blockInstanceId as the mapId.

Useful? React with 👍 / 👎.

@ilyabo
ilyabo force-pushed the codex/block-document-ai-refactor branch from cbf9962 to 913f175 Compare June 23, 2026 08:54
@ilyabo
ilyabo merged commit 4fb3249 into main Jun 23, 2026
6 checks passed
@ilyabo
ilyabo deleted the codex/block-document-ai-refactor branch June 23, 2026 11:29
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