Skip to content

feat: parse rich smart chips (person, date, rich link) in Google Docs - #263

Merged
allenhutchison merged 5 commits into
mainfrom
feat/smart-chip-parsing
Mar 5, 2026
Merged

feat: parse rich smart chips (person, date, rich link) in Google Docs#263
allenhutchison merged 5 commits into
mainfrom
feat/smart-chip-parsing

Conversation

@allenhutchison

Copy link
Copy Markdown
Contributor

Adds smart chip parsing to the DocsService getText method, correctly rendering person, date, and rich link chips as readable text/markdown.

Changes

DocsService.ts_readStructuralElement now handles:

  • Person chips[Name](mailto:email) with fallback to email when name is missing
  • Rich link chips[Title](uri) with fallback to URI when title is missing
  • Date chipsdisplayText with fallback to timestamp

DocsService.test.ts — Added tests for:

  • Combined smart chip extraction (all three types in one paragraph)
  • Fallback behavior for each chip type using it.each (person → email, rich link → URI, date → timestamp)

Review Items Addressed (from PR #215)

  • ✅ Rich link title || uri fallback bug fixed
  • ✅ Missing fallback test for rich links added
  • ✅ Fallback tests refactored to it.each
  • ✅ Prettier formatting applied
  • ✅ Rebased on main

Closes #215

Co-authored-by: MrwanBaghdad marwan.nabil@deliveryhero.com

MrwanBaghdad and others added 3 commits March 4, 2026 13:43
Currently docs.getText skip over smart chip elements within Google docs.
Leaving out information.
This commit adds support to render smart chip elements in google docs to
simple text
Adds smart chip parsing to the DocsService getText method, rendering:
- Person chips as markdown mailto links with name fallback to email
- Rich link chips as markdown links with title fallback to URI
- Date chips as displayText with fallback to timestamp

Based on PR #215 by @MrwanBaghdad. Fixes reviewed items:
- Rich link title fallback bug (title || uri)
- Missing rich link fallback test
- Refactored fallback tests to it.each
- Prettier formatting applied

Co-authored-by: MrwanBaghdad <marwan.nabil@deliveryhero.com>
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the DocsService by enabling it to intelligently parse and convert various Google Docs smart chips (person, date, rich link) into a more human-readable and markdown-compatible text format. This improves the utility of the getText method by providing a more complete and structured representation of document content, including embedded rich data elements.

Highlights

  • Smart Chip Parsing: Implemented parsing logic within DocsService.ts to correctly render Google Docs person, date, and rich link smart chips into readable text/markdown format.
  • Fallback Mechanisms: Ensured robust fallback behavior for smart chips: person chips fall back to email if a name is missing, rich links fall back to the URI if a title is missing, and date chips fall back to the timestamp if displayText is unavailable.
  • Comprehensive Testing: Added new test cases in DocsService.test.ts to validate the extraction of text from combined smart chips and to verify the fallback logic for each chip type using it.each.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • workspace-server/src/tests/services/DocsService.test.ts
    • Added a test case to verify the extraction of text from a paragraph containing a combination of date, person, and rich link smart chips.
    • Introduced it.each tests to specifically cover fallback scenarios for person (name to email), rich link (title to URI), and date (displayText to timestamp) elements.
  • workspace-server/src/services/DocsService.ts
    • Added logic to _readStructuralElement to process person, richLink, and dateElement types.
    • Implemented markdown formatting for person chips (e.g., [Name](mailto:email)).
    • Implemented markdown formatting for rich link chips (e.g., [Title](uri)).
    • Handled date elements by prioritizing displayText or falling back to timestamp.
Activity
  • Rich link title || uri fallback bug fixed.
  • Missing fallback test for rich links added.
  • Fallback tests refactored to it.each.
  • Prettier formatting applied.
  • Rebased on main.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request enhances the getText method in DocsService to parse rich smart chips for persons, dates, and links. However, the current implementation is vulnerable to markdown injection due to direct concatenation of user-controlled strings into markdown link structures without proper escaping, which could be exploited for phishing attacks. Additionally, there are edge cases where missing email (for person chips) or uri (for rich link chips) properties can result in malformed markdown output.

Comment thread workspace-server/src/services/DocsService.ts Outdated
Comment thread workspace-server/src/services/DocsService.ts Outdated
- Person chips: guard against missing email, fall back to name only
- Rich link chips: guard against missing uri, fall back to title only
- Added 2 new it.each test cases for these edge cases

Addresses review feedback from Gemini Code Assist on PR #263

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

Approved. 2 nits on readability, but non-blocking!

Comment thread workspace-server/src/__tests__/services/DocsService.test.ts Outdated
Comment thread workspace-server/src/services/DocsService.ts
- Extract _renderPersonChip, _renderRichLinkChip, _renderDateChip from
  _readStructuralElement for cleaner dispatch logic
- Add mockDocWithElements test helper to reduce mock boilerplate

Addresses readability nits from @abhipatel12 on PR #263
@allenhutchison
allenhutchison merged commit 28c3a02 into main Mar 5, 2026
16 of 19 checks passed
@allenhutchison
allenhutchison deleted the feat/smart-chip-parsing branch March 5, 2026 21:13
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.

3 participants