Skip to content

Add "Copy to clipboard" button for Output Data and Logs in test step panel#109

Merged
seslash merged 5 commits intomainfrom
add_copy_button
Mar 18, 2026
Merged

Add "Copy to clipboard" button for Output Data and Logs in test step panel#109
seslash merged 5 commits intomainfrom
add_copy_button

Conversation

@seslash
Copy link
Contributor

@seslash seslash commented Mar 13, 2026

For more details see issue #108

Screenshot 2026-03-13 at 11 19 52

@seslash seslash self-assigned this Mar 13, 2026
@seslash seslash added the enhancement New feature or request label Mar 13, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a “Copy to clipboard” affordance to the ScenarioEditor bottom panel so users can quickly copy either the pretty-printed Output Data JSON or the currently filtered Logs for a step (per issue #108).

Changes:

  • Update the bottom panel tab header layout to make room for actions and add styling for a copy button (including success state styling).
  • Add copy-to-clipboard logic and UI (Copy/Copied states) to BottomPanel for Output Data and filtered Logs.
  • Refactor status badge color logic into named variables for readability.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
web-editor/src/styles/BottomPanel.module.css Adds layout/styles for tab grouping and the new copy button + success state.
web-editor/src/components/ScenarioEditor/BottomPanel.tsx Implements copy button behavior (output/logs), success feedback state, and small status badge refactor.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +80 to +82
setCopied(true);
setTimeout(() => setCopied(false), 2000);
});
Comment on lines +154 to +160
{canCopy && (
<button
className={`${styles.copyButton} ${copied ? styles.copyButtonSuccess : ''}`}
onClick={handleCopy}
aria-label="Copy to clipboard"
type="button"
>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a “Copy to clipboard” action to the ScenarioEditor bottom panel so users can quickly copy either the currently displayed Output Data (pretty JSON) or the currently filtered Logs from a selected test step.

Changes:

  • Adds a copy button to the Output Data / Logs tab bar with success feedback (“Copied!”).
  • Implements clipboard copy logic with navigator.clipboard.writeText and a legacy execCommand('copy') fallback.
  • Updates bottom panel tab bar layout/styles to accommodate the new action.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
web-editor/src/components/ScenarioEditor/BottomPanel.tsx Adds copy-to-clipboard behavior, success feedback state, and renders the Copy/Copied button in the tab bar.
web-editor/src/styles/BottomPanel.module.css Adjusts tab layout (tab group + right-aligned action) and styles the copy button + success state.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +70 to +125
const handleCopy = useCallback(() => {
let textToCopy = '';
if (activeTab === 'output' && result) {
textToCopy = JSON.stringify(result, null, 2);
} else if (activeTab === 'logs' && filteredLogs.length > 0) {
textToCopy = filteredLogs.join('\n');
}
if (!textToCopy) return;

const handleSuccess = () => {
setCopied(true);
setTimeout(() => setCopied(false), 2000);
};

const fallbackCopy = () => {
try {
const textarea = document.createElement('textarea');
textarea.value = textToCopy;
textarea.setAttribute('readonly', '');
textarea.style.position = 'absolute';
textarea.style.left = '-9999px';
document.body.appendChild(textarea);
const selection = document.getSelection();
const selected = selection && selection.rangeCount > 0 ? selection.getRangeAt(0) : null;
textarea.select();
const successful = document.execCommand('copy');
document.body.removeChild(textarea);
if (selected && selection) {
selection.removeAllRanges();
selection.addRange(selected);
}
if (successful) {
handleSuccess();
} else if (typeof window !== 'undefined' && typeof window.alert === 'function') {
window.alert('Failed to copy to clipboard.');
}
} catch {
if (typeof window !== 'undefined' && typeof window.alert === 'function') {
window.alert('Failed to copy to clipboard.');
}
}
};

if (navigator.clipboard && typeof navigator.clipboard.writeText === 'function') {
navigator.clipboard.writeText(textToCopy)
.then(handleSuccess)
.catch(() => {
fallbackCopy();
});
} else {
fallbackCopy();
}
}, [activeTab, result, filteredLogs]);

const canCopy = activeTab === 'output' ? !!result : filteredLogs.length > 0;

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a “Copy to clipboard” action in the ScenarioEditor BottomPanel so users can quickly copy the currently active “Output Data” or “Logs” content, with brief success feedback.

Changes:

  • Adds a Copy/Copied UI control to the Output/Logs tab bar and copies tab-specific content (pretty JSON for Output, filtered lines for Logs).
  • Introduces temporary “Copied!” feedback state with timeout cleanup.
  • Updates BottomPanel tab layout styling to accommodate a right-aligned action button.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
web-editor/src/styles/BottomPanel.module.css Adds layout styles for a tab group + copy button in the tab header.
web-editor/src/components/ScenarioEditor/BottomPanel.tsx Implements copy-to-clipboard logic, success feedback state, and integrates the Copy button into the tab header.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +210 to +216
{canCopy && (
<button
className={`${styles.copyButton} ${copied ? styles.copyButtonSuccess : ''}`}
onClick={handleCopy}
aria-label="Copy to clipboard"
type="button"
>
Copy link
Contributor

@RomanPszonka RomanPszonka left a comment

Choose a reason for hiding this comment

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

please address copilot suggestions

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a “Copy to clipboard” action to the ScenarioEditor BottomPanel so users can quickly copy the currently displayed Output Data (pretty-printed JSON) or Logs (respecting the active log-level filter), addressing issue #108.

Changes:

  • Introduces a copy-to-clipboard button with temporary “Copied!” success feedback in the BottomPanel tab bar.
  • Implements clipboard copy with navigator.clipboard.writeText plus a DOM-based fallback for older/blocked environments.
  • Updates BottomPanel tab bar styling to accommodate right-aligned actions and adjusts status badge coloring.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
web-editor/src/styles/BottomPanel.module.css Adds layout styles for a tab group + right-aligned copy button and success state styling.
web-editor/src/components/ScenarioEditor/BottomPanel.tsx Implements copy behavior, success feedback timing/cleanup, and UI placement next to the Output/Logs tabs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

}
}, [activeTab, result, filteredLogs]);

const canCopy = activeTab === 'output' ? !!result : filteredLogs.length > 0;
Comment on lines +138 to +143
if (typeof navigator !== 'undefined' && navigator.clipboard && typeof navigator.clipboard.writeText === 'function') {
navigator.clipboard.writeText(textToCopy)
.then(handleSuccess)
.catch(() => {
fallbackCopy();
});
Copy link
Contributor

@hrishiballal hrishiballal left a comment

Choose a reason for hiding this comment

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

Thank you for this, this is very handy and my JS is very basic so looking forward to testing it and will add issues if there is a problem.

@seslash seslash merged commit c19b6be into main Mar 18, 2026
2 checks passed
@seslash seslash deleted the add_copy_button branch March 18, 2026 20:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants