feat(docs,sheets,slides): add docs.insertTable, sheets.getRanges, and slides.replaceImage#396
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
There was a problem hiding this comment.
Code Review
This pull request adds three new tools to the Google Workspace extension: docs.insertTable for inserting pre-filled tables in Google Docs, sheets.getRanges for batch-retrieving multiple disjoint ranges in Google Sheets, and slides.replaceImage for replacing images in Google Slides. The feedback highlights a critical bug in DocsService.ts where using cellStart + 1 for cell text insertion will trigger a 400 Bad Request error on empty cells, requiring a shift to cellStart and a corresponding test update. Additionally, the error handler in SheetsService.ts for getRanges needs to include isError: true to ensure MCP clients can correctly identify tool execution failures.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
… slides.replaceImage Three focused additions to the Docs/Sheets/Slides tool surfaces: - docs.insertTable (docs.write): inserts a table at the end of the body or at a specific index, optionally pre-filled with cell data. Cell fill re-reads the document to locate the inserted table and applies insertText requests in reverse document order so earlier indexes stay valid. Validates that data fits within the declared dimensions before any API call. - sheets.getRanges (sheets.read, readOnlyHint): batch read of multiple A1 ranges via spreadsheets.values.batchGet, with valueRenderOption and majorDimension controls. One API call instead of N sheets.getRange calls when reading disjoint ranges. - slides.replaceImage (slides.write): replaces an existing image by objectId with a new image URL via the replaceImage batchUpdate request, preserving position and size. CENTER_INSIDE (default) or CENTER_CROP fit. Pairs with slides.getImages / template workflows for refreshing charts and filling image placeholders. Includes feature-config registration, Jest coverage for all three services (request shapes, defaults, URL extraction, error paths, dimension validation), docs/index.md entries for the default-enabled tools, and skill recipes for google-docs and google-sheets.
…o getRanges failures Addresses gemini-code-assist review: cellStart already points at the cell's first paragraph, so inserting at cellStart + 1 landed on the terminating newline and 400'd on empty cells; sheets.getRanges error responses now carry isError: true so MCP clients can distinguish failures from content.
1492733 to
8eedd9f
Compare
Summary
Fixes #395 by adding one high-leverage tool to each of the Docs, Sheets, and Slides surfaces. All three follow the existing service-class, feature-group, and test patterns, and none of them adds a new OAuth scope (each tool reuses its feature group's existing scope, so the consent surface is unchanged).
docs.insertTable(docs.write group, default on)Inserts a rows x columns table at the end of the body (default) or at a specific index, optionally pre-filled with cell data in the same call:
Cell fill works by re-reading the document to locate the inserted table, then applying one
insertTextper non-empty cell in reverse document order so earlier indexes remain valid.datadimensions are validated againstrows/columnsbefore any API call. This avoids the brittle alternative of asking the model to compute table-cell indexes by hand after insertion.sheets.getRanges(sheets.read group, default on,readOnlyHint)Batch read of multiple A1 ranges via
spreadsheets.values.batchGet— one API call instead of Nsheets.getRangecalls when pulling disjoint ranges (e.g. KPI cells across sheets). SupportsvalueRenderOption(FORMATTED_VALUEdefault /UNFORMATTED_VALUE/FORMULA) andmajorDimension(ROWSdefault /COLUMNS). Results are returned in request order.slides.replaceImage(slides.write group, default off, like the other write tools)Replaces an existing image by
imageObjectIdwith a new URL via thereplaceImagebatchUpdate request, preserving the original position and size.imageReplaceMethod:CENTER_INSIDE(default) orCENTER_CROP. Pairs naturally withslides.getImages/slides.getMetadataand withslides.replaceAllTextfor template-deck workflows (refresh a chart, fill an image placeholder).What's included
DocsService,SheetsService,SlidesServicefollowing the existing logging/error-shape conventions (isErroron failures)index.tswith Zod schemas (integer/positive constraints, enums,min(1)on the ranges array) andreadOnlyHinton the read toolfeature-config.tsentries in the matching feature groupsdocs/index.mdentries for the default-enabled tools (the Slides section lists only read tools today, soslides.replaceImagefollows the existing convention of being config-documented only)google-docs(insertTable usage and why fill-at-insert beats post-hoc index math) andgoogle-sheets(when to prefergetRangesover repeatedgetRange)Verification
All passing locally: 29 suites, 632 tests (620 existing + 12 new), eslint and prettier clean, tsc clean.
Happy to split this into three per-product PRs if you prefer smaller reviews — the three changes are fully independent.
Made with Cursor