Skip to content

SmythOS Studio: Open-Source Visual AI Agent Builder and deployable runtime stack from SmythOS. Start with an intuitive drag-and-drop workspace, extend with custom code, and deploy your agents anywhere — local, cloud, or edge — with full governance and control.

feat: add functionality to copy selected text from debug output

Muhammad Hamza Khan51f8b72de4b2
diff --git a/packages/app/src/builder-ui/workspace/SelectionActions.ts b/packages/app/src/builder-ui/workspace/SelectionActions.ts
index 209eb8bb..6419cbe5 100644
--- a/packages/app/src/builder-ui/workspace/SelectionActions.ts
+++ b/packages/app/src/builder-ui/workspace/SelectionActions.ts
@@ -20,6 +20,14 @@ export function isInteractionContextOK(): boolean {
return !!active.closest('[data-context-menu="true"]');
}
+export function isOverDebugOutput(): boolean {
+ const active = document.activeElement as HTMLElement | null;
+ if (!active) return true; // safety
+ if (active === document.body) return true; // same as before
+ // check if focus is inside our debug output consider
+ return !!active.closest('.dbg-element .dbg-textarea');
+}
+
export function hasSelectedText(): boolean {
const text = window.getSelection()?.toString();
return !!text;
@@ -50,6 +58,8 @@ export function hasComponentSelection(): boolean {
export function canCopy(workspace: Workspace): boolean {
if (workspace.locked) return false;
+ // If text is selected in the debug output, allow copying
+ if (isOverDebugOutput() && hasSelectedText()) return true;
if (!isInteractionContextOK()) return false;
if (isEditableHover(workspace)) return false;
@@ -59,6 +69,19 @@ export function canCopy(workspace: Workspace): boolean {
}
export function copySelection(workspace: Workspace): void {
+ // If text is selected in the debug output, copy it to the clipboard
+ if (isOverDebugOutput() && hasSelectedText()) {
+ // Copy selected text to clipboard
+ const selectedText = window.getSelection()?.toString();
+ if (selectedText) {
+ navigator.clipboard.writeText(selectedText).catch((err) => {
+ console.error('Failed to copy text to clipboard:', err);
+ });
+ }
+ return;
+ }
+
+ // Fall back to component copying
const data = workspace.clipboard.copySelection();
if (data) workspace.clipboard.write(data);
}