Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@Karakatiza666
Copy link
Contributor

The implementation correctly handles nested collection types.

image

The result:

"cc_num","name","lat","long"
100000000000002,"Elwin Becker",38.675322903215616,-95.24527236636264
100000000000003,"Dillon Turner",31.299302184625372,-90.2092812664037
100000000000004,"Jose Christiansen",40.54722284074282,-95.0805152553869
100000000000013,"Frederic Oberbrunner",47.42061505582383,-83.07470872217422
100000000000017,"Davon Kerluke",41.41167950963154,-93.10512208724244
...

Also, Fix #4294: Cannot copy/paste value from adhoc-query output
image

Fixed adhoc query result flickering in Firefox

@Karakatiza666 Karakatiza666 added Web Console Related to the browser based UI javascript Pull requests that update Javascript code UX Issues that effect an end-user's experience labels Jan 19, 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

This pull request adds a copy button for ad-hoc query results and individual SQL values, implementing export functionality in CSJV (Comma-Separated JSON Values) format. It also fixes issue #4294 regarding copy/paste from ad-hoc query output and addresses query result flickering in Firefox.

Changes:

  • Adds tableToCSJV() function to export query results as comma-separated JSON values
  • Creates reusable SQLValueTooltip component with integrated copy button for displaying and copying SQL values
  • Refactors tooltip system to use generic type parameters for better type safety
  • Updates positioning and styling for copy buttons across multiple components

Reviewed changes

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

Show a summary per file
File Description
js-packages/web-console/src/lib/functions/sql.ts Adds display/serialization functions for SQL values and CSJV export functionality
js-packages/web-console/src/lib/compositions/common/usePopoverTooltip.svelte.ts Adds generic type parameter for better type safety
js-packages/web-console/src/lib/components/relationData/SQLValue.svelte Simplifies props interface by removing formatter function parameter
js-packages/web-console/src/lib/components/other/SQLValueTooltip.svelte New component for displaying SQL values with copy button in tooltip
js-packages/web-console/src/lib/components/other/ClipboardCopyButton.svelte Updates to accept Parameter type (string or function)
js-packages/web-console/src/lib/components/adhoc/Query.svelte Integrates copy button for query results and updated tooltip component
js-packages/web-console/src/lib/components/pipelines/editor/ChangeStream.svelte Updates to use new tooltip component
js-packages/web-console/src/lib/components/other/ScrollDownFab.svelte Adds optional class prop for positioning
js-packages/web-console/src/lib/components/pipelines/editor/MonitoringPanel.svelte Updates styling for Pipeline ID copy button
js-packages/web-console/README.md Minor formatting fix (adds blank line)
js-packages/web-console/.prettierignore Adds .svelte-kit/ and /build/ directories

<ClipboardCopyButton value={pipeline.current.id} class="h-8 w-auto preset-tonal-surface">
<ClipboardCopyButton
value={pipeline.current.id}
class="h-8 w-auto! gap-2 preset-tonal-surface px-4"
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

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

The class w-auto! on line 144 uses non-standard Tailwind syntax. In standard Tailwind CSS, the important modifier should be written as !w-auto (with the exclamation mark before the utility). If this is intentional for a specific framework or preprocessor, it should be documented. Otherwise, it should be changed to !w-auto.

Suggested change
class="h-8 w-auto! gap-2 preset-tonal-surface px-4"
class="h-8 !w-auto gap-2 preset-tonal-surface px-4"

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

@Karakatiza666 Karakatiza666 Jan 19, 2026

Choose a reason for hiding this comment

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

w-auto! is valid and preferred syntax in the new TailwindCSS 4

<div class="flex flex-nowrap justify-between gap-2">
<span class="flex-1">{tooltipData ? displaySQLValue(tooltipData.value) : ''}</span>
{#if tooltipData}
<ClipboardCopyButton class="flex-none p-0" value={() => serializeSQLValue(tooltipData!.value)}
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

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

On line 26, there's a non-null assertion tooltipData!.value used within the function passed to ClipboardCopyButton. While the parent conditional on line 25 checks if tooltipData exists, there's a potential race condition where the user could click the copy button just as tooltipData becomes undefined. Consider capturing the value in a local variable before passing it to avoid potential runtime errors.

Copilot uses AI. Check for mistakes.
// Build header row with column names as JSON strings
lines[0] = columns.map((col) => JSONbig.stringify(col.name)).join(',')

// Build data rows in single pass - only include rows with cells (skip errors/warnings)
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

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

The comment on line 91 says "only include rows with cells (skip errors/warnings)" but this information is somewhat misleading. The comment should clarify that data rows have the cells property while error/warning rows have error or warning properties, and only data rows are included in the export.

Suggested change
// Build data rows in single pass - only include rows with cells (skip errors/warnings)
// Build data rows in a single pass: data rows have a `cells` property,
// while error/warning rows use `error` or `warning`. Only data rows are exported.

Copilot uses AI. Check for mistakes.
Comment on lines 43 to 46
if (typeof value === 'object' && 'format' in value && typeof value.format === 'function') {
// Handle Dayjs objects - convert to ISO string
return (value as Dayjs).toISOString()
}
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

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

The Dayjs detection relies on duck-typing by checking for a format method. While this works in the current context since the input type is constrained to SQLValueJS, it would be more explicit and maintainable to use value.constructor.name === 'Dayjs' or import and check against the Dayjs class directly. This would make the code more robust and easier to understand.

Copilot uses AI. Check for mistakes.
const columns = result.columns

// Pre-allocate array for worst case (header + all rows)
const lines = new Array<string>(rows.length + 1)

// Build header row with column names as JSON strings
lines[0] = columns.map((col) => JSONbig.stringify(col.name)).join(',')
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

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

The function doesn't handle the edge case where result.columns might be empty or undefined. If columns is empty, line 89 would produce an empty header string. While this might be acceptable behavior, it would be more robust to add validation or document this behavior explicitly.

Suggested change
const columns = result.columns
// Pre-allocate array for worst case (header + all rows)
const lines = new Array<string>(rows.length + 1)
// Build header row with column names as JSON strings
lines[0] = columns.map((col) => JSONbig.stringify(col.name)).join(',')
const columns = result.columns ?? []
// Pre-allocate array for worst case (header + all rows)
const lines = new Array<string>(rows.length + 1)
// Build header row with column names as JSON strings
lines[0] = columns.length > 0 ? columns.map((col) => JSONbig.stringify(col.name)).join(',') : ''

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Documented this behavior

Comment on lines +67 to +65
export const serializeSQLValue = (value: SQLValueJS): string => {
return JSONbig.stringify(toJSONValue(value))
}

/**
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

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

The serializeSQLValue function doesn't have any error handling, unlike displaySQLValue which has a try-catch block. If JSONbig.stringify throws an error (e.g., with circular references or other edge cases), this will propagate to the caller. Consider adding error handling similar to displaySQLValue to prevent crashes when copying values.

Suggested change
export const serializeSQLValue = (value: SQLValueJS): string => {
return JSONbig.stringify(toJSONValue(value))
}
/**
* Serialize SQLValueJS to a JSON string representation suitable for CSV export
*/
export const serializeSQLValue = (value: SQLValueJS): string => {
try {
return JSONbig.stringify(toJSONValue(value))
} catch (e) {
console.log('Failed to serialize SQL value', e)
return ''
}
}

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The handling is implemented in the call site of serializeSQLValue. The function itself should throw on error

@Karakatiza666 Karakatiza666 marked this pull request as draft January 19, 2026 15:03
@Karakatiza666 Karakatiza666 marked this pull request as ready for review January 19, 2026 15:45
@Karakatiza666 Karakatiza666 changed the title Add a button to copy result of ad-hoc queries Add a button to copy the result of ad-hoc queries Jan 19, 2026
const lines = new Array<string>(rows.length + 1)

// Build header row with column names as JSON strings
// If there are no columns - the first row will be empty
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think it's possible to write a query that produces no columns

@Karakatiza666 Karakatiza666 added this pull request to the merge queue Jan 19, 2026
Merged via the queue into main with commit 60b2ecc Jan 20, 2026
1 check passed
@Karakatiza666 Karakatiza666 deleted the copy-adhoc branch January 20, 2026 01:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

javascript Pull requests that update Javascript code UX Issues that effect an end-user's experience Web Console Related to the browser based UI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[WEBUI] Cannot copy/paste value from adhoc-query output

3 participants