Skip to content

Add rich link previews#1334

Open
klopez4212 wants to merge 3 commits into
mainfrom
kennylopez-link-rendering-pr
Open

Add rich link previews#1334
klopez4212 wants to merge 3 commits into
mainfrom
kennylopez-link-rendering-pr

Conversation

@klopez4212

@klopez4212 klopez4212 commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add compact rich link previews for GitHub, Linear, Google Drive, Docs, Sheets, and Slides links in sent messages.
  • Add composer affordances for recognized pasted links without forcing the edit-link popover open.
  • Resolve Google document titles through a limited native preview fetch, with safe fallbacks for private or unavailable files.

Checks

  • Code checks: no findings.
  • cd desktop && pnpm check
  • cd desktop && pnpm typecheck
  • cd desktop && node --import ./test-loader.mjs --experimental-strip-types --test src/shared/lib/linkPreview.test.mjs
  • cargo test --manifest-path desktop/src-tauri/Cargo.toml link_preview
  • just 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 1280x720
  • just 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 1280x720

Snapshots

Link preview cards

GitHub, Linear, and Google document links render as compact attachment cards.

link-previews-cards

Hover open affordance

The right-side open icon appears on card hover.

link-previews-hover

@klopez4212 klopez4212 changed the title [codex] Add rich link previews Add rich link previews Jun 28, 2026
@klopez4212 klopez4212 marked this pull request as ready for review June 28, 2026 11:40
@klopez4212 klopez4212 requested a review from wesbillman June 28, 2026 11:42
klopez4212 added a commit that referenced this pull request Jun 28, 2026
@klopez4212 klopez4212 marked this pull request as draft June 28, 2026 11:44

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread desktop/src/shared/ui/markdown.tsx Outdated
Comment thread desktop/src/shared/ui/markdown.tsx
@klopez4212 klopez4212 marked this pull request as ready for review June 28, 2026 11:44

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread desktop/src/shared/lib/linkPreview.ts Outdated
Comment on lines +42 to +44
.replace(/```[\s\S]*?```/g, " ")
.replace(/~~~[\s\S]*?~~~/g, " ")
.replace(/`[^`\n]*`/g, " ");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread desktop/src/shared/lib/linkPreview.ts Outdated

@wesbillman wesbillman left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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 ![...](url) 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('![alt](https://docs.google.com/document/d/doc123/edit)').map(p => p.kind + ':' + p.title));
console.log(extractSupportedLinkPreviews('![alt](https://github.com/block/sprout)').map(p => p.kind + ':' + p.title));
EOF

Current 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.

@klopez4212

Copy link
Copy Markdown
Contributor Author

🤖 Addressed the markdown-image changes request in 3a5e1c3: markdown image link ranges are now masked before raw URL extraction, so ![alt](https://docs.google.com/...) and ![alt](https://github.com/...) no longer produce link preview cards. I also added regression coverage for that case, bare URL boundary matching, and indented code blocks.

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