fix(message-editor): preserve comment anchors in pasted GitHub links - #3795
Merged
Conversation
Pasting a GitHub comment link like .../pull/72409#discussion_r3647131256 into the composer converted it into a PR chip whose URL was rebuilt from owner/repo/number, silently dropping the comment anchor. The agent and the chip's click-through then pointed at the PR instead of the specific comment. parseGithubIssueUrl now keeps the suffix on normalizedUrl whenever it contains a non-empty fragment. The whole suffix is kept (not just the fragment) because anchors like #r123 only resolve on the /files subpage they were copied from. Fragment-less suffixes (/files, ?foo=bar) are still stripped as before. The mobile copy of the helper gets the same fix to stay in sync.
|
😎 Merged directly without going through the merge queue, as the queue was empty and the PR was up to date with the target branch - details. |
|
React Doctor found no issues in the changed files. 🎉 Reviewed by React Doctor for commit |
Contributor
|
Reviews (1): Last reviewed commit: "fix(message-editor): preserve comment an..." | Re-trigger Greptile |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Pasting a GitHub comment link into the composer — e.g.
auto-converts it into a PR chip, but
parseGithubIssueUrlrebuilt the chip URL from owner/repo/number only, silently dropping the#discussion_r…anchor. The chip's click-through and theurl="…"attribute sent to the agent both ended up pointing at the PR itself instead of the specific comment.Fix
parseGithubIssueUrlnow keeps the URL suffix onnormalizedUrlwhenever it contains a non-empty fragment. The whole suffix is preserved (path tail + query + fragment), not just the fragment, because anchors like#r123only resolve on the/filessubpage they were copied from —/pull/123#r123would land nowhere.Behavior without a fragment is unchanged: tab suffixes (
/files), query strings, and trailing junk are still stripped, andhttp://is still normalized tohttps://.apps/mobile/src/lib/githubIssueUrl.tsis a verbatim copy of the helper (used for PR badges and markdown link chips) and gets the identical fix to stay in sync.Testing
#discussion_r…link, a/files#r…link, and an empty#(still stripped).pnpm --filter @posthog/core exec vitest run src/message-editor/githubIssueUrl.test.ts src/message-editor/content.test.ts— 42 tests pass.pnpm typecheckand Biome pass (also enforced by the pre-commit hook).