Skip to content

Commit 12b486a

Browse files
fix(web): drop stale Copied state when a retry starts
Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
1 parent d6c849a commit 12b486a

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

‎apps/web/src/components/ChatMarkdown.tsx‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -739,6 +739,12 @@ function MarkdownTable({ children, ...props }: React.ComponentProps<"table">) {
739739
format === "markdown"
740740
? serializeTableElementToMarkdown(table)
741741
: serializeTableElementToCsv(table);
742+
// A retry must not keep showing the previous attempt's Copied state.
743+
if (copiedTimerRef.current != null) {
744+
clearTimeout(copiedTimerRef.current);
745+
copiedTimerRef.current = null;
746+
}
747+
setCopied(false);
742748
const reportFailure = (cause: unknown) => {
743749
reportMarkdownActionFailure({ operation: "copy-table", format }, cause);
744750
toastManager.add(
@@ -943,6 +949,12 @@ function MarkdownCodeBlock({
943949
const copyLabel = copied ? "Copied" : "Copy code";
944950

945951
const handleCopy = useCallback(() => {
952+
// A retry must not keep showing the previous attempt's Copied state.
953+
if (copiedTimerRef.current != null) {
954+
clearTimeout(copiedTimerRef.current);
955+
copiedTimerRef.current = null;
956+
}
957+
setCopied(false);
946958
const reportFailure = (cause: unknown) => {
947959
reportMarkdownActionFailure(
948960
{

‎apps/web/src/components/preview/PreviewView.tsx‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,10 @@ export function PreviewView({
361361
);
362362
};
363363
const copyPath = () => {
364+
if (pathCopied) {
365+
pathCopied = false;
366+
updateRecordingToast();
367+
}
364368
void writeTextToClipboard(artifact.path, "recording path").then((didCopy) => {
365369
if (!didCopy) {
366370
reportCopyFailure(new Error("Clipboard write produced no result."));

0 commit comments

Comments
 (0)