Skip to content

feat(docs): add support for review and suggested edits - #919

Draft
dneto-vtex wants to merge 24 commits into
taylorwilsdon:mainfrom
dneto-vtex:feat/docs-developer-preview-review
Draft

feat(docs): add support for review and suggested edits#919
dneto-vtex wants to merge 24 commits into
taylorwilsdon:mainfrom
dneto-vtex:feat/docs-developer-preview-review

Conversation

@dneto-vtex

@dneto-vtex dneto-vtex commented Jul 11, 2026

Copy link
Copy Markdown

Description

This PR adds Google Docs review and suggested-edit workflows to the Google Workspace MCP, including anchored review comments, suggestion lifecycle operations, staged Markdown/native-table rendering, Drive label operations, and deployment hardening.

Preview requests use the authorized Google client transport directly because the stable discovery schema does not yet expose all Developer Preview fields.

References:

Capabilities

  • batch_update_doc supports EDIT|SUGGEST modes and revision guards.
  • Native Docs review tools support review-thread retrieval, anchored comments, replies, resolution, reopening, post updates/deletes, and suggestion accept/reject/delete operations.
  • Markdown can be rendered into staged prose and native Google Docs tables.
  • Document tabs, formatting inspection, UTF-16-safe indices, and Drive label operations are supported.
  • Docker and Helm startup now use direct arguments and WORKSPACE_MCP_* configuration, with credential storage restricted to mode 700.

Preview-dependent capabilities are optional. Stable Docs tools and EDIT mode work without Preview enrollment. SUGGEST mode and native review tools require enrollment in the Google Workspace Developer Preview Program; if unavailable, they fail closed and never fall back to direct edits. Deployments can omit them through WORKSPACE_MCP_TOOLS or the configured tool tier.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality not to work as expected)
  • Documentation update

Testing

  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have tested this change manually

Validation completed:

  • Ruff checks and formatting checks passed.
  • Relevant test suites: 482 passed before the latest review-fix tests; focused review/writer tests: 59 passed.
  • Helm lint and template rendering passed.
  • Docker image build and direct entrypoint verification passed.
  • Live rehearsal passed for labels, Markdown population, formatting, colors, suggestions, anchored comments, replies, resolution, acceptance, and final readback.

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • I have enabled "Allow edits from maintainers" for this pull request

Additional Notes

Native-table replacement with Markdown tables is intentionally rejected before mutation. Google assigns table-cell indices only after table creation, requiring multiple dependent writes without a cross-call transaction. Use replace_existing=false to append safely; transactional replacement can be added in a future change.

The PR remains draft for maintainer review.

Summary by CodeRabbit

  • New Features
    • Added Google Drive label browsing and atomic label modification tools.
    • Added Google Docs native comment/suggestion review threads, anchored workflows, and SUGGEST-mode updates with optional revision guarding/rebasing.
    • Added native Google Docs Markdown table rendering (including staged table insertion).
    • Enhanced document inspection to include optional detailed text-run formatting details.
  • Bug Fixes
    • Improved Docs text index accuracy for emojis and other non‑BMP characters across rendering and table styling.
    • Improved multi-tab selection behavior and anchored thread range handling.
  • Documentation
    • Updated Docker/Compose deployment instructions and Developer Preview documentation for Docs suggestions/review threads.

@coderabbitai

coderabbitai Bot commented Jul 11, 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: ac0470e3-382b-4d17-8149-88643b026862

📥 Commits

Reviewing files that changed from the base of the PR and between cadc745 and b4fdb54.

📒 Files selected for processing (6)
  • gdocs/docs_markdown_writer.py
  • gdocs/docs_tables.py
  • gdocs/docs_tools.py
  • gdocs/docs_utils.py
  • gdocs/managers/table_operation_manager.py
  • tests/gdocs/test_docs_review_tools.py
🚧 Files skipped from review as they are similar to previous changes (3)
  • gdocs/docs_markdown_writer.py
  • tests/gdocs/test_docs_review_tools.py
  • gdocs/docs_tools.py

📝 Walkthrough

Walkthrough

This PR adds Google Docs Developer Preview suggestion and anchored review-thread tools, staged native Markdown table rendering, Drive label APIs and scopes, expanded tab inspection, and updated Docker/Helm deployment configuration and documentation.

Changes

Container deployment configuration

Layer / File(s) Summary
Container startup and deployment wiring
Dockerfile, helm-chart/workspace-mcp/templates/deployment.yaml, README.md
Container startup uses the venv Python with streamable HTTP, tool configuration uses WORKSPACE_MCP_* variables, credentials permissions are tightened, and deployment docs use Docker Compose and Claude setup commands.

Drive labels access and tools

Layer / File(s) Summary
Drive Labels API access and MCP tools
auth/scopes.py, auth/permissions.py, auth/service_decorator.py, gdrive/drive_tools.py, core/tool_tiers.yaml
Adds the Drive Labels read-only scope, service and scope-group mappings, label listing and modification tools, payload validation, and tool-tier exposure.
Drive label and scope validation
tests/gdrive/test_drive_labels.py, tests/test_permissions.py, tests/test_scopes.py
Tests Drive label API requests, modification validation, permission inclusion, and scope hierarchy behavior.

Docs table and tab workflows

Layer / File(s) Summary
Markdown tables, UTF-16 indexing, and staged population
gdocs/docs_markdown_writer.py, gdocs/docs_tables.py, gdocs/managers/table_operation_manager.py, gdocs/docs_tools.py, tests/gdocs/*
Markdown tables are split into prose and table blocks, rendered as staged native Docs tables, and indexed using UTF-16 code units.
Tab selection and text-run inspection
gdocs/docs_structure.py, gdocs/docs_tools.py, tests/gdocs/test_inspect_doc_tabs.py
Document inspection supports explicit multi-tab selection, single-tab auto-selection, tab metadata, and paragraph text-run styles.

Docs suggestions and review threads

Layer / File(s) Summary
Preview REST and revision-controlled writes
gdocs/review.py, gdocs/managers/batch_operation_manager.py, gdocs/docs_tools.py
Adds preview REST execution, SUGGEST write mode, revision guards, unsupported-operation validation, suggestion response extraction, and partial-failure metadata.
Anchored review-thread and suggestion lifecycle tools
gdocs/review.py, gdocs/docs_tools.py
Adds review-thread retrieval and lifecycle actions, suggestion accept/reject/delete operations, and suggestion anchor resolution.
Documentation, schemas, and behavior tests
README.md, skills/managing-google-workspace/references/docs.md, tests/gdocs/golden/docs_tool_schemas.json, tests/gdocs/test_batch_write_mode.py, tests/gdocs/test_docs_review_tools.py
Documents Developer Preview requirements and revision controls, updates tool schemas, and tests preview requests, anchor resolution, lifecycle actions, and failure handling.

Estimated code review effort: 5 (Critical) | ~120 minutes

Possibly related PRs

Suggested labels: enhancement

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 36.52% 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
Title check ✅ Passed The title is concise and accurately summarizes the main change: adding review and suggested-edit support.
Description check ✅ Passed The PR description covers the required sections, change type, testing, checklist, and additional notes with sufficient detail.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@dneto-vtex

Copy link
Copy Markdown
Author

Closing this draft while we complete local validation against the Google Docs Developer Preview. The API surface is active, but the enrolled project currently receives the public schema for the preview fields, so the implementation and live end-to-end workflow are still being validated. We’ll return with a focused, fully tested proposal once the review workflow is confirmed. The development branch is being preserved.

@dneto-vtex dneto-vtex closed this Jul 13, 2026
@dneto-vtex dneto-vtex reopened this Jul 16, 2026
@dneto-vtex dneto-vtex changed the title feat(docs): add Developer Preview review workflows feat(docs): add support for review and suggested edits Jul 16, 2026
@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Caution

Review failed

An error occurred during the review process. Please try again later.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@dneto-vtex

Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

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.

Actionable comments posted: 5

🤖 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 `@gdocs/docs_tools.py`:
- Around line 94-122: The revision-conflict retry path must preserve
caller-supplied required_revision_id values and avoid treating every
FAILED_PRECONDITION as stale. Update _is_stale_revision_error to require a
specific revision-mismatch signal, and update the retry logic around the write
operation to retry only when the required revision was fetched internally;
otherwise propagate the original conflict unchanged.
- Around line 3055-3064: Update the has_native_tables staged-rendering flow
around clear_requests so existing tab content is not permanently cleared before
all prose, table, and refresh operations succeed. Stage rendering in temporary
content/tab or preserve the original and restore it on failure, while retaining
the existing clear behavior only after staged rendering completes successfully.
- Around line 3070-3086: Update markdown_to_docs_requests to use UTF-16 units
for every intra-block cursor, insertion location, and range calculation instead
of Python string lengths, reusing _utf16_length consistently. Preserve the
existing batch insertion flow and add a regression test covering an emoji before
later paragraphs or styles to verify generated Docs indices remain correct.

In `@README.md`:
- Around line 552-554: Remove the duplicated Google Docs suggestion and native
review-thread enrollment sentence in the README, leaving a single introduction
immediately before the Google Workspace Developer Preview Program link.

In `@tests/gdocs/test_docs_review_tools.py`:
- Around line 486-516: The parameterized test’s expected delete response field
is constructed incorrectly as “deleteedSuggestionIds.” Update
test_manage_doc_suggestion_actions to map the delete action to the real
“deletedSuggestionIds” field while preserving the existing accept and reject
mappings, so the test validates the Docs response contract.
🪄 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: 010f11a6-a6b3-4be6-a2ff-6e0247365052

📥 Commits

Reviewing files that changed from the base of the PR and between 3f19c7d and 5e0964c.

📒 Files selected for processing (23)
  • Dockerfile
  • README.md
  • auth/permissions.py
  • auth/scopes.py
  • auth/service_decorator.py
  • core/tool_tiers.yaml
  • gdocs/docs_markdown_writer.py
  • gdocs/docs_structure.py
  • gdocs/docs_tools.py
  • gdocs/managers/batch_operation_manager.py
  • gdocs/review.py
  • gdrive/drive_tools.py
  • helm-chart/workspace-mcp/templates/deployment.yaml
  • skills/managing-google-workspace/references/docs.md
  • tests/gdocs/golden/docs_tool_schemas.json
  • tests/gdocs/test_batch_write_mode.py
  • tests/gdocs/test_docs_markdown_writer.py
  • tests/gdocs/test_docs_review_tools.py
  • tests/gdocs/test_insert_doc_tab_response.py
  • tests/gdocs/test_inspect_doc_tabs.py
  • tests/gdrive/test_drive_labels.py
  • tests/test_permissions.py
  • tests/test_scopes.py

Comment thread gdocs/docs_tools.py Outdated
Comment thread gdocs/docs_tools.py
Comment on lines +3055 to +3064
if has_native_tables:
# Tables require staged writes because Docs assigns cell indices only
# after insertTable has completed and the document is fetched again.
clear_requests = all_requests[:1] if replace_existing and tab_end > 2 else []
if clear_requests:
await asyncio.to_thread(
service.documents()
.batchUpdate(documentId=document_id, body={"requests": clear_requests})
.execute
)

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.

🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift

Do not delete existing content before staged rendering succeeds.

The first batch permanently clears the tab, while later prose, table, or refresh calls can fail. This regresses the former atomic update into possible empty or partially rendered content. Stage into temporary content/tab or preserve and restore the original before clearing.

🤖 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 `@gdocs/docs_tools.py` around lines 3055 - 3064, Update the has_native_tables
staged-rendering flow around clear_requests so existing tab content is not
permanently cleared before all prose, table, and refresh operations succeed.
Stage rendering in temporary content/tab or preserve the original and restore it
on failure, while retaining the existing clear behavior only after staged
rendering completes successfully.

Comment thread gdocs/docs_tools.py
Comment on lines +3070 to +3086
for block in markdown_blocks:
if block["type"] == "markdown":
requests = markdown_to_docs_requests(
block["markdown"], tab_id=tab_id, start_index=insertion_index
)
if not requests:
continue
await asyncio.to_thread(
service.documents()
.batchUpdate(documentId=document_id, body={"requests": requests})
.execute
)
insertion_index += sum(
_utf16_length(request["insertText"]["text"])
for request in requests
if "insertText" in request
)

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.

🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

Use UTF-16 units throughout each Markdown request batch.

Line 3082 updates only the next block’s index with UTF-16 lengths, but markdown_to_docs_requests still advances intra-block request locations with Python len(text). Non-BMP characters before later paragraphs or styles therefore shift Docs indices. Convert all request cursors/ranges and add an emoji regression test.

🤖 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 `@gdocs/docs_tools.py` around lines 3070 - 3086, Update
markdown_to_docs_requests to use UTF-16 units for every intra-block cursor,
insertion location, and range calculation instead of Python string lengths,
reusing _utf16_length consistently. Preserve the existing batch insertion flow
and add a regression test covering an emoji before later paragraphs or styles to
verify generated Docs indices remain correct.

Comment thread README.md
Comment thread tests/gdocs/test_docs_review_tools.py
@dneto-vtex
dneto-vtex marked this pull request as ready for review July 17, 2026 15:23

@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)
gdocs/docs_markdown_writer.py (1)

23-26: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consolidate _utf16_length into a shared utility module.

The _utf16_length helper function is identically duplicated across four files. To adhere to the DRY principle, consider moving it to a common utility file (e.g., gdocs/docs_utils.py) and importing it where needed.

  • gdocs/docs_markdown_writer.py#L23-L26: Remove local definition and import the shared utility.
  • gdocs/docs_tables.py#L16-L20: Remove local definition and import the shared utility.
  • gdocs/managers/table_operation_manager.py#L19-L23: Remove local definition and import the shared utility.
  • gdocs/docs_tools.py#L89-L93: Remove local definition and import the shared utility.
🤖 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 `@gdocs/docs_markdown_writer.py` around lines 23 - 26, Move the duplicated
_utf16_length helper into the shared gdocs/docs_utils.py utility module,
preserving its current UTF-16 code-unit behavior. Remove the local definitions
and import the shared utility in gdocs/docs_markdown_writer.py (23-26),
gdocs/docs_tables.py (16-20), gdocs/managers/table_operation_manager.py (19-23),
and gdocs/docs_tools.py (89-93).
🤖 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 `@gdocs/docs_markdown_writer.py`:
- Around line 23-26: Move the duplicated _utf16_length helper into the shared
gdocs/docs_utils.py utility module, preserving its current UTF-16 code-unit
behavior. Remove the local definitions and import the shared utility in
gdocs/docs_markdown_writer.py (23-26), gdocs/docs_tables.py (16-20),
gdocs/managers/table_operation_manager.py (19-23), and gdocs/docs_tools.py
(89-93).

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e34b1975-adde-4225-bea9-7e363ac24fc0

📥 Commits

Reviewing files that changed from the base of the PR and between 5e0964c and cadc745.

📒 Files selected for processing (9)
  • README.md
  • gdocs/docs_markdown_writer.py
  • gdocs/docs_tables.py
  • gdocs/docs_tools.py
  • gdocs/managers/table_operation_manager.py
  • tests/gdocs/test_docs_markdown_writer.py
  • tests/gdocs/test_docs_review_tools.py
  • tests/gdocs/test_insert_doc_tab_response.py
  • tests/gdocs/test_table_cell_style.py
🚧 Files skipped from review as they are similar to previous changes (3)
  • tests/gdocs/test_docs_markdown_writer.py
  • README.md
  • tests/gdocs/test_insert_doc_tab_response.py

@dneto-vtex
dneto-vtex marked this pull request as draft July 17, 2026 16:22
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