feat(docs): DR-7628 replace AI prompt banner with inline copy prompt button#7654
feat(docs): DR-7628 replace AI prompt banner with inline copy prompt button#7654ArthurGamby wants to merge 1 commit intomainfrom
Conversation
WalkthroughThis pull request refactors the prompt-copying functionality by removing the Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes The refactoring is straightforward—relocating component functionality with clear one-to-one mapping between removal and addition. The logic remains unchanged (copy-to-clipboard with visual feedback), and the scope is limited to three closely related files. The main review points are verifying the integration flow and confirming no edge cases in the conditional rendering were missed. 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 📝 Coding Plan
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. Comment Tip CodeRabbit can use TruffleHog to scan for secrets in your code with verification capabilities.Add a TruffleHog config file (e.g. trufflehog-config.yml, trufflehog.yml) to your project to customize detectors and scanning behavior. The tool runs only when a config file is present. |
|
The latest updates on your projects. Learn more about Argos notifications ↗︎
|
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
apps/docs/src/components/page-actions.tsx (1)
79-93:⚠️ Potential issue | 🟠 Major
LLMCopyButtoncan still copy error/404 payloads instead of markdown.You added fallback cache lookup on Line 79, but the uncached path still fetches only
markdownUrland copiesres.text()without checkingres.ok. For routes that require/index.mdx, this can cache/copy the wrong content.Proposed fix
try { - await navigator.clipboard.write([ - new ClipboardItem({ - "text/plain": fetch(markdownUrl).then(async (res) => { - const content = await res.text(); - cache.set(markdownUrl, content); - return content; - }), - }), - ]); + const { content, resolvedUrl } = await fetchMarkdownWithFallback(markdownUrl); + cache.set(resolvedUrl, content); + cache.set(markdownUrl, content); + await navigator.clipboard.writeText(content); } finally {🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/docs/src/components/page-actions.tsx` around lines 79 - 93, The LLMCopyButton logic currently fetches markdownUrl and unconditionally uses res.text(), which allows error/404 HTML to be cached and copied; update the fetch path used inside navigator.clipboard.write to check response.ok and only use and cache res.text() when res.ok is true, otherwise attempt fetching fallbackUrl (if provided) and only cache/copy successful responses; ensure you reference the existing cache lookup and the ClipboardItem creation that uses fetch(markdownUrl) and adjust it to throw or fallback when res.ok is false so error payloads are never written to cache or clipboard.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@apps/docs/src/components/page-actions.tsx`:
- Around line 79-93: The LLMCopyButton logic currently fetches markdownUrl and
unconditionally uses res.text(), which allows error/404 HTML to be cached and
copied; update the fetch path used inside navigator.clipboard.write to check
response.ok and only use and cache res.text() when res.ok is true, otherwise
attempt fetching fallbackUrl (if provided) and only cache/copy successful
responses; ensure you reference the existing cache lookup and the ClipboardItem
creation that uses fetch(markdownUrl) and adjust it to throw or fallback when
res.ok is false so error payloads are never written to cache or clipboard.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 39b99d02-ca0a-489b-b3ad-b10325324425
📒 Files selected for processing (3)
apps/docs/src/app/(docs)/(default)/[[...slug]]/page.tsxapps/docs/src/components/ai-prompt-banner.tsxapps/docs/src/components/page-actions.tsx
💤 Files with no reviewable changes (1)
- apps/docs/src/components/ai-prompt-banner.tsx
Summary
AIPromptBannercomponent that rendered between page description and body contentai-prompt-banner.tsxcomponentLinear
https://linear.app/prisma-company/issue/DR-7628/replace-ai-prompt-banner-with-inline-copy-prompt-button
Test plan
Summary by CodeRabbit