Skip to content

Render text/html support attachments as links#23011

Open
adalpari wants to merge 8 commits into
trunkfrom
feature/support-html-attachments-as-links
Open

Render text/html support attachments as links#23011
adalpari wants to merge 8 commits into
trunkfrom
feature/support-html-attachments-as-links

Conversation

@adalpari

@adalpari adalpari commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Description

Bot replies in the unified support screen can include text/html "citation" attachments — links to help articles (e.g. https://jetpack.com/support/...) rather than downloadable files.

Previously these were rendered as file cards with a generic page icon, and tapping one enqueued an Android DownloadManager download of the raw HTML — the wrong behavior for a web link. This is especially visible after a conversation is transferred to human support, where the bot's earlier messages render through the human-support path (file-card grid).

This PR introduces a new Link attachment type for text/html content and renders those attachments as tappable, underlined links (with an open-in-new icon) that open the URL in the browser:

  • Model: text/html (case-insensitive) now maps to AttachmentType.Link. All other content types — including text/plain — keep their existing behavior.
  • Human-support view (UnifiedAttachmentsList): link attachments are shown as a vertical list of links above the existing card grid; images/videos/other files are unchanged.
  • Bot-conversation view (AttachmentRow): link filenames become tappable links; the citation match-score badge is preserved.
  • Added a unit test covering the content-type → AttachmentType mapping.

Testing instructions

Before / after

screenshot_20260618_125357 / screenshot_20260618_131546

NOTE: You might not be able to reproduce it since it entirely depends on the bot answers
Note2: use a non-free account

  1. Enable the new support FF
  2. Open a bot conversation and act generic like "test" "new test" so you hopefully get some links
  • Verify you can click the links
  1. Ask to talk to a human
  2. Your conversation should be escalated and the UI changes
  • Verify you properly see the links and can click them.

Bot replies in the unified support screen can include text/html
citation attachments that point to web articles rather than
downloadable files. These were rendered as file cards (and tapping
one downloaded the raw HTML), which is confusing. Map text/html to a
new Link attachment type and render those attachments as tappable
links that open the URL in the browser, in both the bot and
human-support conversation views.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@dangermattic

dangermattic commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator
1 Warning
⚠️ PR is not assigned to a milestone.

Generated by 🚫 Danger

Use startsWith instead of equals so content types like
"text/html; charset=utf-8" map to AttachmentType.Link, consistent with
the image/ and video/ branches.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@wpmobilebot

wpmobilebot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

App Icon📲 You can test the changes from this Pull Request in WordPress Android by scanning the QR code below to install the corresponding build.

App NameWordPress Android
Build TypeDebug
Versionpr23011-24da00c
Build Number1497
Application IDorg.wordpress.android.prealpha
Commit24da00c
Installation URL1j8sjb9opbgig
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@wpmobilebot

wpmobilebot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

App Icon📲 You can test the changes from this Pull Request in Jetpack Android by scanning the QR code below to install the corresponding build.

App NameJetpack Android
Build TypeDebug
Versionpr23011-24da00c
Build Number1497
Application IDcom.jetpack.android.prealpha
Commit24da00c
Installation URL31bugq35dod70
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@codecov

codecov Bot commented Jun 18, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 9.58904% with 66 lines in your changes missing coverage. Please review.
✅ Project coverage is 37.41%. Comparing base (400d4d2) to head (24da00c).

Files with missing lines Patch % Lines
...port/unified/ui/UnifiedConversationDetailScreen.kt 0.00% 66 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##            trunk   #23011      +/-   ##
==========================================
- Coverage   37.42%   37.41%   -0.01%     
==========================================
  Files        2325     2325              
  Lines      125399   125451      +52     
  Branches    17205    17213       +8     
==========================================
+ Hits        46929    46942      +13     
- Misses      74656    74694      +38     
- Partials     3814     3815       +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@adalpari adalpari marked this pull request as ready for review June 18, 2026 12:05
@adalpari adalpari requested a review from nbradbury June 18, 2026 12:05
@nbradbury

Copy link
Copy Markdown
Contributor

@adalpari I've not tested this yet, but Claude had some suggestions:

Accessibility gap in the bot-view link (AttachmentRow). UnifiedAttachmentLink gets a descriptive contentDescription (“Open link: …”), but the clickable Text in AttachmentRow does not — a screen reader just reads the filename with no indication it’s an actionable link. Consider adding the same semantics/contentDescription (and ideally Role.Button/link) there for parity.

openUri can throw ActivityNotFoundException. This is the only LocalUriHandler.openUri usage in the app, so there’s no established pattern. If no browser/handler exists (or the URL is malformed), uriHandler.openUri(...) throws and crashes the screen. Low likelihood on real devices, but worth a runCatching {} with a graceful no-op/toast given this is bot-supplied data you don’t fully control.

@nbradbury

Copy link
Copy Markdown
Contributor

When I click a link, it correctly takes me to the web page, but when I click back it just shows an empty screen. I click back again and I see the "Get Help" screen but it never loads.

screen.mov

adalpari and others added 4 commits June 19, 2026 10:31
Give the clickable filename in AttachmentRow the same contentDescription
and Role.Button semantics as UnifiedAttachmentLink so screen readers
announce it as an actionable link. Guard both openUri call sites with
runCatching to avoid crashing on ActivityNotFoundException, notifying
the user via a toast instead.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Route attachment link taps through a hoisted onLinkClick callback that
the Activity wires to ActivityNavigator.openInCustomTab, matching how
Help Center opens URLs. This keeps users in-app and inherits its
graceful fallback to the external browser on ActivityNotFoundException.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- Lowercase content type once so image/video/text-html all match case-insensitively
- Compute link content description only for link attachments via shared helper

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@adalpari

Copy link
Copy Markdown
Contributor Author

@nbradbury I've made some changes. Can you give it another go?

@nbradbury

Copy link
Copy Markdown
Contributor

@adalpari I'm still seeing the issue with the back button and it turns out it was due to having "Don't keep activities" enabled, so it's something users are unlikely to experience. I had Claude write up a plan for resolving it in case you want to address the problem, but I'll go ahead an approve.

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

:shipit:

@adalpari

Copy link
Copy Markdown
Contributor Author

@adalpari I'm still seeing the issue with the back button and it turns out it was due to having "Don't keep activities" enabled, so it's something users are unlikely to experience. I had Claude write up a plan for resolving it in case you want to address the problem, but I'll go ahead an approve.

Cool!
Well, I don't think that's a case we want to "solve". I mean, if someone has enabled "don't keep" activities, then that behaviour is expected.

@adalpari adalpari enabled auto-merge (squash) June 19, 2026 11:21
@wpmobilebot

wpmobilebot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

🤖 Build Failure Analysis

This build has failures. Claude has analyzed them - check the build annotations for details.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants