Skip to content

Proper ConsoleLog text copying support#1919

Draft
AaronPlave wants to merge 2 commits into
developfrom
fix/copy-log-correctly
Draft

Proper ConsoleLog text copying support#1919
AaronPlave wants to merge 2 commits into
developfrom
fix/copy-log-correctly

Conversation

@AaronPlave
Copy link
Copy Markdown
Contributor

Problem. Copying log rows produced broken text — each chunk (timestamp, [, INFO, ], message) on its own line. The flex layout makes each header a block item and browsers insert newlines between block items when serializing a selection.

Fix. Two copy event handlers normalize the clipboard text:

  • per-<summary> handler for single-row selections
  • use:consoleLogCopy Svelte action on list containers for multi-row and summary which expanded selections (preserves <pre> newlines)

Why not just CSS or inline restructure. CSS alone can't fix the header/message split — flex items are block-level by spec. An inline restructure works but forces giving up the message wrapping behavior and text-ellipsis truncation.

@AaronPlave AaronPlave force-pushed the fix/copy-log-correctly branch from 910f4a6 to 47ee2c6 Compare April 29, 2026 17:53
@AaronPlave AaronPlave self-assigned this Apr 29, 2026
@AaronPlave AaronPlave added the feature New feature or request label Apr 29, 2026
@dandelany
Copy link
Copy Markdown
Collaborator

Decided to defer this to 4.3.0 to minimize risk & decide if this is the best approach

// Multi-row selections are handled by the list-level handler in ./consoleLogCopy.ts, which
// walks <details>/<summary>/<pre> — keep that file in sync if you change this template's structure.
const selection = window.getSelection();
if (!selection || selection.isCollapsed || !summaryEl) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think in cases of collapsed log lines, we should actually copy the entire expanded log line to clipboard, since this is most likely the user's intention

return;
}
const selection = window.getSelection();
if (!selection || selection.isCollapsed) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

same here re: copying expanded version of collapsed log lines

@dandelany
Copy link
Copy Markdown
Collaborator

Discussed with @AaronPlave & we're not sure this is the right approach - it works but it also adds a lot of complexity to be "hijacking" the copy/paste mechanism. We'll work on a simpler version which may:

  • separate action server logs from error console logs into a different component
  • try an approach with simpler, (nearly) plaintext action server logs (inline styles, no flex layout)
  • have a button on the action log to download the log output
    This would give up some UI interaction for action logs but would scale better to longer logs and ensure copyability without any fancy tricks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants