Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .Jules/palette.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@
## 2025-10-26 - Scratchpad Focus Management
**Learning:** In VS Code Webviews, automatically returning focus to the main input (e.g. textarea) after a button click (like "Copy" or "Remove Empty Lines") can be disorienting for screen reader users and keyboard navigators. It interrupts the natural tab order and prevents users from hearing status updates on the button they just clicked.
**Action:** Avoid calling `.focus()` on the input element immediately after secondary actions unless the primary purpose of the action is to prepare for immediate typing. For status updates (like "Copied!"), keep focus on the trigger element.

## 2025-05-20 - Smart Copy Context Sensitivity
**Learning:** Users often select specific text expecting only that text to be copied, even if the general "Copy" button usually copies the entire document. Ignoring the selection in favor of a "Copy All" default feels like a loss of agency and utility.
**Action:** Implement "Smart Copy" logic in text-heavy interfaces: if text is selected, copy only the selection; otherwise, copy the full content. Provide clear feedback (e.g., "Copied Selection!") to confirm the action.
17 changes: 14 additions & 3 deletions src/features/scratchpad/scratchpad.html
Original file line number Diff line number Diff line change
Expand Up @@ -219,13 +219,24 @@
const content = textarea.value;
if (!content) return;

let textToCopy = content;
let feedbackText = 'Copied!';
let ariaLabel = 'Copied to Clipboard';

// Smart Copy: Copy selection if exists
if (textarea.selectionStart !== textarea.selectionEnd) {
textToCopy = content.substring(textarea.selectionStart, textarea.selectionEnd);
feedbackText = 'Copied Selection!';
ariaLabel = 'Copied Selection to Clipboard';
}

vscode.postMessage({
type: 'copyToClipboard',
content: content
content: textToCopy
});

btnCopy.textContent = 'Copied!';
btnCopy.setAttribute('aria-label', 'Copied to Clipboard');
btnCopy.textContent = feedbackText;
btnCopy.setAttribute('aria-label', ariaLabel);

if (copyTimeoutId) clearTimeout(copyTimeoutId);
copyTimeoutId = setTimeout(resetCopyButton, 2000);
Expand Down