-
Notifications
You must be signed in to change notification settings - Fork 1
Develop #96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Develop #96
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -30,7 +30,7 @@ import type { ArtifactData } from './chat.types' | |||||||||||||||||||||||||||||||||||||||||||||||||
| interface AgentArtifactProps { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| artifact: ArtifactData | ||||||||||||||||||||||||||||||||||||||||||||||||||
| onClose?: () => void | ||||||||||||||||||||||||||||||||||||||||||||||||||
| // eslint-disable-next-line no-unused-vars | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| onCodeUpdate?: (artifactId: string, newCode: string) => void | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -59,14 +59,17 @@ export function AgentArtifact({ | |||||||||||||||||||||||||||||||||||||||||||||||||
| artifact.type === 'code' && | ||||||||||||||||||||||||||||||||||||||||||||||||||
| PREVIEWABLE_LANGUAGES.includes(normalizeLanguage(artifact.language)) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| const handleCopy = useCallback(async () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| await navigator.clipboard.writeText(editedCode) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| setCopied(true) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| setTimeout(() => setCopied(false), 2000) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } catch (err) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| void err | ||||||||||||||||||||||||||||||||||||||||||||||||||
| const handleCopy = useCallback(() => { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| const doCopy = async () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| await navigator.clipboard.writeText(editedCode) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| setCopied(true) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| setTimeout(() => setCopied(false), 2000) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } catch (err) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| void err | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| void doCopy() | ||||||||||||||||||||||||||||||||||||||||||||||||||
| }, [editedCode]) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+62
to
73
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick | 🔵 Trivial Fire-and-forget pattern is correct, but error is silently swallowed. The async IIFE pattern correctly handles the clipboard operation without returning a Promise. However, ♻️ Suggested: Log clipboard errors for debugging const handleCopy = useCallback(() => {
const doCopy = async () => {
try {
await navigator.clipboard.writeText(editedCode)
setCopied(true)
setTimeout(() => setCopied(false), 2000)
} catch (err) {
- void err
+ console.error('Failed to copy to clipboard:', err)
}
}
void doCopy()
}, [editedCode])📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| const handleDownload = useCallback(() => { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -233,7 +236,7 @@ export function AgentArtifactCompact({ | |||||||||||||||||||||||||||||||||||||||||||||||||
| // Floating action button for quick access to editor | ||||||||||||||||||||||||||||||||||||||||||||||||||
| interface ArtifactEditorFABProps { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| artifact: ArtifactData | ||||||||||||||||||||||||||||||||||||||||||||||||||
| // eslint-disable-next-line no-unused-vars | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| onCodeChange?: (newCode: string) => void | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The async wrapper function pattern is overly complex. Instead of wrapping handleCopy in a nested async function (doCopy), keep the original async/await pattern and use 'void handleCopy()' at the call site. This maintains cleaner code structure while still satisfying the floating promise constraint.