Skip to content

feat: surface quotedFileContent (anchor text) in comment reading - #489

Merged
taylorwilsdon merged 1 commit into
taylorwilsdon:mainfrom
MaxGhenis:feat/comment-anchor-text
Feb 19, 2026
Merged

feat: surface quotedFileContent (anchor text) in comment reading#489
taylorwilsdon merged 1 commit into
taylorwilsdon:mainfrom
MaxGhenis:feat/comment-anchor-text

Conversation

@MaxGhenis

@MaxGhenis MaxGhenis commented Feb 19, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds quotedFileContent to the Drive API fields requested when reading document/spreadsheet/presentation comments
  • Surfaces the quoted (highlighted) text as "Quoted text: ..." in the comment output
  • This is the text the commenter highlighted when creating the comment — essential context for understanding what a comment refers to

Closes #210

Changes

  • core/comments.py: Added quotedFileContent to the fields parameter in the Drive API call, and added output formatting for the quoted text
  • tests/core/test_comments.py: 3 new async tests verifying quoted text is surfaced, empty quoted content is handled, and replies are included correctly
  • tests/core/__init__.py: New init file for test package

Test plan

  • 3 new unit tests pass (pytest tests/core/test_comments.py)
  • All 144 existing tests still pass
  • Manual test with a real Google Doc that has comments on highlighted text

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • New Features

    • Comments now display quoted text from referenced content, providing better context in conversations and threaded replies.
  • Tests

    • Added comprehensive test coverage for comment functionality across multiple scenarios.

When reading comments via read_document_comments / read_spreadsheet_comments /
read_presentation_comments, the Drive API's quotedFileContent.value field is
now requested and displayed as "Quoted text:" in the output. This shows which
specific text in the document each comment is anchored to.

Comments without anchor text (document-level comments) omit the line.

Relates to taylorwilsdon#210

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Feb 19, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

The changes enhance comment handling in Google Docs by extracting and displaying quoted text from comments. The read/list API now includes the quotedFileContent field, extracts its value as quoted_text, and conditionally appends "Quoted text: ..." to comment output. Comprehensive async tests validate quoted text inclusion, empty comment handling, and reply scenarios.

Changes

Cohort / File(s) Summary
Comment Quoted Text Support
core/comments.py
Updated field selection to include quotedFileContent, extracted quoted_text value, and conditionally appended "Quoted text: ..." line to comment output when quoted content exists.
Test Coverage for Comments
tests/core/test_comments.py
New async test module with three test scenarios: quoted text surfacing verification, empty comment list handling, and comments with replies, using mocked Google Drive-like data.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A rabbit hops through comments bright,
With quoted text now in sight!
Each fragment captured, nice and clean,
The finest quotes we've ever seen! 🌿✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Linked Issues check ❓ Inconclusive The PR addresses issue #210 by implementing quoted text display, but only partially satisfies the original request for adding comments to specific text ranges [#210]. Clarify whether surfacing quoted text in read operations fulfills the intent of #210 (adding comments anchored to text ranges) or if additional work is needed for comment creation.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely describes the main change: surfacing quotedFileContent (anchor text) in comment reading, which is the primary objective of this PR.
Description check ✅ Passed The description covers the summary, changes, and test plan, following the template structure. However, the checklist items are not completed and the 'Allow edits from maintainers' requirement is not explicitly confirmed.
Out of Scope Changes check ✅ Passed All changes are directly aligned with the PR objective: adding quotedFileContent field to API requests and surfacing it in output, plus corresponding test coverage.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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)
tests/core/test_comments.py (1)

3-10: Consider avoiding runtime sys.path mutation in tests.
If possible, prefer configuring the test runner’s Python path (e.g., via pyproject.toml/pytest.ini) or installing the package in editable mode to keep imports clean.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/core/test_comments.py` around lines 3 - 10, Remove the runtime sys.path
mutation in the test (the sys.path.insert(...) line) and instead import the
module via the package import path used in the project (so the test imports
core.comments._read_comments_impl directly without modifying sys.path) or
configure the test runner to recognize the package (e.g., via
pytest.ini/pyproject.toml or running in editable install) so the test uses the
normal package import resolution rather than mutating sys.path at runtime.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@tests/core/test_comments.py`:
- Around line 3-10: Remove the runtime sys.path mutation in the test (the
sys.path.insert(...) line) and instead import the module via the package import
path used in the project (so the test imports core.comments._read_comments_impl
directly without modifying sys.path) or configure the test runner to recognize
the package (e.g., via pytest.ini/pyproject.toml or running in editable install)
so the test uses the normal package import resolution rather than mutating
sys.path at runtime.

@taylorwilsdon

Copy link
Copy Markdown
Owner

Another excellent one, thanks!

@taylorwilsdon taylorwilsdon self-assigned this Feb 19, 2026
@taylorwilsdon taylorwilsdon added the enhancement New feature or request label Feb 19, 2026
@taylorwilsdon
taylorwilsdon merged commit 6f2a88c into taylorwilsdon:main Feb 19, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for Adding Comments to Specific Text Ranges in Google Docs via API

2 participants