feat(logs): add copy button to AI log analysis result#4330
Open
alirizatuncer wants to merge 1 commit intoDokploy:canaryfrom
Open
feat(logs): add copy button to AI log analysis result#4330alirizatuncer wants to merge 1 commit intoDokploy:canaryfrom
alirizatuncer wants to merge 1 commit intoDokploy:canaryfrom
Conversation
Comment on lines
+191
to
+202
| <Button | ||
| size="sm" | ||
| variant="outline" | ||
| onClick={handleCopy} | ||
| title="Copy analysis" | ||
| > | ||
| {copied ? ( | ||
| <Check className="h-3.5 w-3.5" /> | ||
| ) : ( | ||
| <Copy className="h-3.5 w-3.5" /> | ||
| )} | ||
| </Button> |
Contributor
There was a problem hiding this comment.
Missing
aria-label on icon-only button
The button contains only an icon with no visible text label. The title attribute provides a tooltip for sighted users but is not reliably exposed to screen readers. Adding aria-label ensures assistive technologies announce the button's purpose.
Suggested change
| <Button | |
| size="sm" | |
| variant="outline" | |
| onClick={handleCopy} | |
| title="Copy analysis" | |
| > | |
| {copied ? ( | |
| <Check className="h-3.5 w-3.5" /> | |
| ) : ( | |
| <Copy className="h-3.5 w-3.5" /> | |
| )} | |
| </Button> | |
| <Button | |
| size="sm" | |
| variant="outline" | |
| onClick={handleCopy} | |
| title="Copy analysis" | |
| aria-label="Copy analysis" | |
| > |
| try { | ||
| await navigator.clipboard.writeText(data.analysis); | ||
| setCopied(true); | ||
| setTimeout(() => setCopied(false), 2000); |
Contributor
There was a problem hiding this comment.
setTimeout not cleaned up on unmount
If the popover is closed before the 2-second window expires, the pending timeout still fires and calls setCopied. While React 18 no longer warns about this, storing the timer ref and clearing it on unmount is the idiomatic approach and avoids the stale state update.
|
Duplicate of #4294 |
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.
Summary
The AI Log Analysis popover renders the AI response as Markdown but provides no
way to copy it. This adds a one-click Copy button to the result action row that
copies the raw Markdown to the clipboard. Same change covers both call sites
(Deployments view and container Logs view) since they share the
AnalyzeLogscomponent.Changes
apps/dokploy/components/dashboard/docker/logs/analyze-logs.tsxCopyandCheckicons to the lucide-react import.copiedboolean state.handleCopywritesdata.analysisto the clipboard, flips the iconto
Checkfor 2s, falls back to a sonner error toast if theclipboard API rejects.
provider-reset X.
Test plan
preserved when pasted.
pnpm lint+pnpm typecheckclean.Notes
Mirrors the existing copy-button pattern already used in
show-deployment.tsx.Greptile Summary
Adds a Copy button to the
AnalyzeLogspopover so users can copy the raw Markdown analysis to the clipboard. The implementation is clean and follows the existing pattern in the codebase — the button is correctly scoped to thedata?.analysisbranch, uses a 2-second visual confirmation state, and provides a fallback error toast. Two minor P2 items: the icon-only button usestitlebut is missingaria-labelfor screen-reader accessibility, and thesetTimeouthandle is not cleared on unmount.Confidence Score: 4/5
Safe to merge — only P2 style/accessibility findings, no logic or security issues.
All findings are P2 (missing aria-label, uncleared setTimeout). The core logic is correct, the button is properly conditionally rendered, and the clipboard API usage is standard.
No files require special attention beyond the two P2 suggestions in analyze-logs.tsx.
Reviews (1): Last reviewed commit: "feat(logs): add copy button to AI log an..." | Re-trigger Greptile