Skip to content

🐛 Fixed inbox links when user is logged into multiple Gmail accounts#26564

Merged
EvanHahn merged 1 commit intomainfrom
evanhahn-ny-1069-inbox-links-direct-to-correct-gmail-inbox-when-signed-into
Feb 25, 2026
Merged

🐛 Fixed inbox links when user is logged into multiple Gmail accounts#26564
EvanHahn merged 1 commit intomainfrom
evanhahn-ny-1069-inbox-links-direct-to-correct-gmail-inbox-when-signed-into

Conversation

@EvanHahn
Copy link
Contributor

closes https://linear.app/ghost/issue/NY-1069

When a user is logged into multiple Gmail accounts, we want to send them to the right inbox.

To do that, we shouldn't be escaping the @ sign.

closes https://linear.app/ghost/issue/NY-1069

When a user is logged into multiple Gmail accounts, we want to send them
to the right inbox.

To do that, we shouldn't be escaping the `@` sign.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 24, 2026

Walkthrough

A new helper function encodeRecipientForGmailUrl is introduced in the get-inbox-links implementation that encodes recipients using encodeURIComponent and then replaces all %40 sequences with @. The Gmail desktop link construction is updated to use this helper function for encoding the recipient segment. Corresponding test cases are added to verify behavior for both ASCII and non-ASCII recipients and senders.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description check ✅ Passed The description is directly related to the changeset, explaining the problem (multiple Gmail accounts) and solution (not escaping the @ sign) that the code changes implement.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title describes a bug fix for inbox links with multiple Gmail accounts, which matches the core change of modifying how the @ symbol is handled in Gmail URLs.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch evanhahn-ny-1069-inbox-links-direct-to-correct-gmail-inbox-when-signed-into

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
ghost/core/core/server/lib/get-inbox-links.ts (1)

64-66: Consider adding an inline comment explaining why @ is deliberately unescaped.

Gmail's multi-account URL routing (/mail/u/<account>/) requires the literal @ in the path segment – encoding it as %40 sends users to the wrong inbox. A brief doc comment would make this non-obvious invariant clear to future readers.

📝 Suggested docstring
+/**
+ * Encodes a recipient email address for use in a Gmail URL path segment.
+ * The `@` sign is intentionally left unencoded because Gmail uses it as a
+ * literal character when routing to the correct account when multiple Google
+ * accounts are signed in (e.g. `/mail/u/user@gmail.com/`).
+ */
 const encodeRecipientForGmailUrl = (recipient: string) => (
     encodeURIComponent(recipient).replaceAll('%40', '@')
 );
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ghost/core/core/server/lib/get-inbox-links.ts` around lines 64 - 66, The
function encodeRecipientForGmailUrl deliberately decodes the %40 back to '@' to
preserve Gmail's multi-account routing; add an inline doc comment above
encodeRecipientForGmailUrl explaining that Gmail requires a literal '@' in the
URL path (encoding it as %40 breaks inbox selection) so future maintainers
understand why replaceAll('%40', '@') is intentional; reference the function
name encodeRecipientForGmailUrl in the comment and briefly mention the Gmail
/mail/u/<account>/ routing invariant.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@ghost/core/core/server/lib/get-inbox-links.ts`:
- Around line 64-66: The function encodeRecipientForGmailUrl deliberately
decodes the %40 back to '@' to preserve Gmail's multi-account routing; add an
inline doc comment above encodeRecipientForGmailUrl explaining that Gmail
requires a literal '@' in the URL path (encoding it as %40 breaks inbox
selection) so future maintainers understand why replaceAll('%40', '@') is
intentional; reference the function name encodeRecipientForGmailUrl in the
comment and briefly mention the Gmail /mail/u/<account>/ routing invariant.

ℹ️ Review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0960849 and 55032b0.

📒 Files selected for processing (2)
  • ghost/core/core/server/lib/get-inbox-links.ts
  • ghost/core/test/unit/server/lib/get-inbox-links.test.ts

@EvanHahn EvanHahn changed the title 🐛 Fix inbox links when user is logged into multiple Gmail accounts 🐛 Fixed inbox links when user is logged into multiple Gmail accounts Feb 24, 2026
@EvanHahn EvanHahn requested a review from troyciesco February 24, 2026 19:33
@EvanHahn EvanHahn merged commit 96fd790 into main Feb 25, 2026
34 checks passed
@EvanHahn EvanHahn deleted the evanhahn-ny-1069-inbox-links-direct-to-correct-gmail-inbox-when-signed-into branch February 25, 2026 14:59
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.

2 participants