Skip to content

Route Ask AI widget tickets through Help WebView log-attach flow#5262

Open
joashrajin wants to merge 1 commit into
Automattic:mainfrom
joashrajin:feat/help-webview-chatbot-support-recipient
Open

Route Ask AI widget tickets through Help WebView log-attach flow#5262
joashrajin wants to merge 1 commit into
Automattic:mainfrom
joashrajin:feat/help-webview-chatbot-support-recipient

Conversation

@joashrajin
Copy link
Copy Markdown
Contributor

@joashrajin joashrajin commented Apr 30, 2026

Summary

The Ask AI widget on the in-app help WebView is moving to a new dedicated support recipient so widget-originated tickets bypass the AI auto-reply loop.

Full context, motivation, and test plan: PCDROID-557.

Today, when a user taps the widget's "contact us here" link inside the in-app Help WebView, HelpWebViewClient intercepts the mailto: and routes it through Support.shareLogs(), which builds an Intent.ACTION_SEND with debug.txt attached. The recipient list and outgoing address are hardcoded — so once the widget renders the new recipient, the WebView would stop recognising the link, fall through to onTapUri(), and the user would email the new inbox without debug logs attached.

This PR makes the recipient address configurable end-to-end while preserving existing behaviour for every other caller of shareLogs().

Changes

  • HelpPage.kt — replaced the prefix-match allowlist with an exact-recipient Set<String> (supportRecipients) that now includes the new AI-assistant recipient. Parses the recipient from the matched mailto URL and passes it through. Falls back to onTapUri() for any mailto whose recipient isn't in the set. The WebViewError "Contact support" button (shown when the help page fails to load) explicitly uses the existing support recipient.
  • HelpViewModel.getSupportIntent() — accepts an optional recipient: String (default: existing support recipient) and forwards it.
  • Support.shareLogs() — adds an optional recipient: String parameter (default: existing support recipient) and uses it for Intent.EXTRA_EMAIL instead of the hardcoded address. Other callers (LogsViewModel, StatusViewModel, the getFeedbackIntent path, and emailWearLogsToSupportIntent) are unaffected via the default.

Security note

The previous contactSupportAction.any { url.startsWith(it) } check matched by prefix, so a mailto: whose recipient was crafted as <allowlisted>@example.com.attacker.com would also match. This was harmless before because the to-address was hardcoded — but parsing the recipient from the URL would have made it exploitable. This PR tightens to exact-equality matching against the supportRecipients set.

Test plan

Full test plan in PCDROID-557. Highlights:

  • Ask AI widget → "contact us here" link → email composer opens with the new recipient and debug.txt attached.
  • Regular "Contact support" button on the Help page still uses the existing recipient and debug.txt (regression).
  • Standalone Logs share flow still uses the existing recipient (regression).
  • WebViewError "Contact support" button (airplane mode → help page fails) still uses the existing recipient (regression).
  • A mailto: whose recipient isn't in supportRecipients falls through to the system email composer with no log attachment, no crash.

Coordination

Draft until the widget HTML swap is timed.

iOS counterpart: Automattic/pocket-casts-ios#4227.

Copilot AI review requested due to automatic review settings April 30, 2026 11:42
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the in-app Help WebView mailto interception so that “Ask AI” contact links can route to a new chatbot-support@pocketcasts.com inbox while still attaching debug logs, without changing behavior for existing support/log-sharing entry points.

Changes:

  • Make the support email recipient configurable through HelpPage -> HelpViewModel -> Support.shareLogs.
  • Tighten Help WebView mailto handling to exact-recipient allowlisting (and add chatbot-support@pocketcasts.com).
  • Keep the Help-page load error “Contact support” button targeting support@pocketcasts.com.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
modules/services/repositories/src/main/java/au/com/shiftyjelly/pocketcasts/repositories/support/Support.kt Adds optional recipient parameter to shareLogs() and uses it for Intent.EXTRA_EMAIL.
modules/features/settings/src/main/java/au/com/shiftyjelly/pocketcasts/settings/viewmodel/HelpViewModel.kt Threads optional recipient through getSupportIntent() to Support.shareLogs().
modules/features/settings/src/main/java/au/com/shiftyjelly/pocketcasts/settings/HelpPage.kt Parses mailto recipient in HelpWebViewClient, allowlists recipients (including chatbot-support), and passes recipient into support flow.

@joashrajin
Copy link
Copy Markdown
Contributor Author

Some context on p1777549631343759/1774527906.406489-slack-C06DGE41ENN

@joashrajin joashrajin self-assigned this Apr 30, 2026
@joashrajin joashrajin marked this pull request as ready for review April 30, 2026 16:14
@joashrajin joashrajin requested a review from a team as a code owner April 30, 2026 16:14
@joashrajin joashrajin requested review from sztomek and removed request for a team April 30, 2026 16:14
@joashrajin joashrajin changed the title Route chatbot-support mailto through Help WebView log-attach flow Route Ask AI widget tickets through Help WebView log-attach flow May 19, 2026
The Ask AI widget on the in-app help WebView is moving to a new
dedicated support recipient so widget-originated tickets bypass the
AI auto-reply loop. Without this change, the WebView client at
HelpPage.kt does not recognize the new recipient and the mailto
falls through to the system email composer with no debug.txt
attached.

Linear: PCDROID-557

- Replace HelpPage.kt's prefix-match allowlist with an exact-equality
  Set<String> of recognized recipients
- Tighten mailto matching from prefix-startsWith (which would also
  match crafted lookalike domains) to exact equality
- Thread the parsed recipient through HelpWebViewClient ->
  HelpViewModel.getSupportIntent -> Support.shareLogs so the intent's
  EXTRA_EMAIL reflects the URL the user tapped
- Other shareLogs callers (LogsViewModel, StatusViewModel, the
  feedback intent, the wear-logs intent) continue to default to the
  existing support recipient via parameter defaults
@joashrajin joashrajin force-pushed the feat/help-webview-chatbot-support-recipient branch from 103a05a to 98e3b84 Compare May 19, 2026 11:23
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