Add rich link previews#1334
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c818f0f81e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c818f0f81e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| .replace(/```[\s\S]*?```/g, " ") | ||
| .replace(/~~~[\s\S]*?~~~/g, " ") | ||
| .replace(/`[^`\n]*`/g, " "); |
There was a problem hiding this comment.
Strip indented code before link previews
In CommonMark, four-space/tab-indented blocks render as code, but this pre-scan only removes fenced and inline code. When a user pastes an indented snippet containing a supported URL, such as a command/output line with a Google Doc URL, we still append a preview card and may invoke the Google title fetch even though the URL is not a rendered link. Please exclude indented code blocks here or extract previews from the parsed markdown tree after code nodes are filtered.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: eef04bc396
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
From my Pinky Agent...
Thanks for the link-preview work — the parser/rendering shape looks good overall. I found one edge case that should be fixed before merge:
extractSupportedLinkPreviews skips markdown image links in the markdown-link pass (if (match[0]?.startsWith("!")) continue;), but then the raw URL pass scans the same source text and re-adds the URL inside  as a preview candidate.
I reproduced this locally:
cd desktop
node --import ./test-loader.mjs --experimental-strip-types --input-type=module <<'EOF'
import { extractSupportedLinkPreviews } from './src/shared/lib/linkPreview.ts';
console.log(extractSupportedLinkPreviews('').map(p => p.kind + ':' + p.title));
console.log(extractSupportedLinkPreviews('').map(p => p.kind + ':' + p.title));
EOFCurrent output:
[ 'google-docs-document:Document' ]
[ 'github-repository:block/sprout' ]
Expected: [] for image markdown, since that URL is image content rather than a message link to preview. Otherwise messages that embed an image whose URL happens to be GitHub/Google/etc. get an extra link-preview attachment card.
A small fix would be to mask markdown image URL ranges before the raw URL scan, or make the raw URL loop ignore matches that fall inside  ranges.
|
🤖 Addressed the markdown-image changes request in |
Summary
Checks
cd desktop && pnpm checkcd desktop && pnpm typecheckcd desktop && node --import ./test-loader.mjs --experimental-strip-types --test src/shared/lib/linkPreview.test.mjscargo test --manifest-path desktop/src-tauri/Cargo.toml link_previewjust desktop-screenshot --name link-previews-cards --active-channel engineering --messages /tmp/sprout-link-preview/messages.json --outdir test-results/link-preview-screens --hover "[data-link-preview-list]" --wait 2500 --viewport 1280x720just desktop-screenshot --name link-previews-hover --active-channel engineering --messages /tmp/sprout-link-preview/messages.json --outdir test-results/link-preview-screens --hover "[data-link-preview='github-pull-request']" --wait 2500 --viewport 1280x720Snapshots
Link preview cards
GitHub, Linear, and Google document links render as compact attachment cards.
Hover open affordance
The right-side open icon appears on card hover.