Skip to content

fix(gmail): preserve rich message bodies in read - #897

Open
jokrasno wants to merge 1 commit into
googleworkspace:mainfrom
jokrasno:codex/issue-889-gmail-read
Open

fix(gmail): preserve rich message bodies in read#897
jokrasno wants to merge 1 commit into
googleworkspace:mainfrom
jokrasno:codex/issue-889-gmail-read

Conversation

@jokrasno

Copy link
Copy Markdown

Description

Fixes #889.

Gmail +read currently falls back to the truncated snippet for HTML-only messages and can prefer a short or empty text/plain alternative over substantially richer HTML. Naive tag stripping also loses link targets, entity decoding, and block structure.

This change:

  • renders HTML bodies to readable text with html2text, retaining links and document structure
  • prefers rendered HTML only when it is substantially richer than a non-empty plain-text alternative
  • keeps comparable valid plain text and uses the Gmail snippet only when neither body yields readable content
  • adds a patch changeset and locks the new dependency

All fixtures are synthetic; no Gmail account, credentials, or real messages were used.

Validation

The five initial regressions all failed on pristine a3768d0:

0 passed; 5 failed; 701 filtered out

They cover richer multipart selection, non-truncation, anchor href preservation, HTML entity decoding, and block line breaks. The final suite also covers empty and comparable plain-text alternatives.

  • cargo fmt --all -- --check
  • cargo test -p google-workspace-cli test_read_ — 7 passed
  • cargo test -p google-workspace-cli helpers::gmail:: — 242 passed
  • cargo build --workspace
  • cargo clippy --workspace -- -D warnings
  • serialized workspace suite — CLI 707 passed with two unrelated, pre-existing Windows ADC tests excluded
  • Changeset included

The two excluded ADC tests mutate HOME while dirs::home_dir() reads USERPROFILE on Windows; they are outside the Gmail helper and unchanged by this commit.

@changeset-bot

changeset-bot Bot commented Aug 12, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 3e25d9b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@googleworkspace/cli Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@google-cla

google-cla Bot commented Aug 12, 2026

Copy link
Copy Markdown

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.

@googleworkspace-bot googleworkspace-bot added area: distribution area: core Core CLI parsing, commands, error handling, utilities labels Aug 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: core Core CLI parsing, commands, error handling, utilities area: distribution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(gmail): +read silently loses body content — prefers empty text/plain part, truncates, drops anchor hrefs

2 participants