Skip to content

feat(explain): copy selected node details to clipboard (#1400) - #1424

Merged
NewtTheWolf merged 5 commits into
TabularisDB:mainfrom
markankamaransheogarat-sys:feat/explain-copy-node-details-1400
Nov 10, 2026
Merged

NewtTheWolf merged 5 commits into
TabularisDB:mainfrom
markankamaransheogarat-sys:feat/explain-copy-node-details-1400

Conversation

@markankamaransheogarat-sys

@markankamaransheogarat-sys markankamaransheogarat-sys commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Resolves #1400.

Adds a "Copy Details" action to the EXPLAIN node details panel, allowing users to copy the selected node's displayed fields and metrics as stable, structured plain text for investigation notes and sharing.

Key Changes

  • Headless Formatter (@tabularis/explain):
    • Implemented formatExplainNodeDetails and getExplainNodeDetailSections in packages/explain/src/nodeDetails.ts (exported from package index).
    • Stable ordering: Operation, Table/Relation, Cost (range or single), Self Cost, Estimated Rows, Filter, Index Condition, Join Type, Hash Condition.
    • Runtime execution metrics (when analyzed): Actual Rows, Rows (All Loops), Self Time (with time share percentage), Total Time, Time per Loop, Loops, Shared Hit Blocks, Shared Read Blocks.
    • Omission of unavailable metrics (never inventing zeros or fabricated values).
    • Support for Extra properties and attached Diagnostics.
    • Safe Unicode/multilingual text handling.
  • Node Details UI (packages/explain/src/components/ExplainNodeDetails.tsx):
    • Sticky header with title and Copy Details action button.
    • Action is disabled when no node is selected (disabled={!node}).
    • Uses callback across the package boundary (onCopyDetails), falling back to navigator clipboard if unprovided.
    • Visual copied feedback with checkmark icon and 2-second timeout, resetting when the selected node changes.
  • Host Application Integration (packages/web-ui/src/components/explain/VisualExplainView.tsx):
    • Connected handleCopyNodeDetails to the host application's platform clipboard adapter (platform.writeClipboard).
    • Dispatches toast notifications on success (detailsCopied) and error (copyDetailsFailed).
    • Passed across Graph, Diagram, and Table views so node details can be copied regardless of current view mode.
  • Localization:
    • Added new strings (copyDetails, detailsCopied, copyDetailsFailed, nodeDetails) to all 13 supported locales (de, en, es, fr, it, ja, ko, pt-BR, ru, tl, vi, zh, zh-TW).
  • Tests:
    • Added comprehensive test suite in packages/explain/tests/nodeDetails.test.ts (estimated-only, analyzed, missing metrics, Unicode, custom translation, diagnostics, headers).
    • Extended packages/web-ui/tests/components/explain/VisualExplainView.test.tsx to verify disabled state with no node, successful clipboard copy with feedback, and clipboard rejection handling.

Verification

  • pnpm typecheck & pnpm typecheck:explain (clean, 0 errors)
  • vitest run packages/explain/ (212/212 tests pass)
  • vitest run packages/web-ui/tests/components/explain/ (27/27 tests pass)
  • eslint packages/explain packages/web-ui/src/components/explain (clean, 0 errors)
  • node scripts/check-theme-tokens.mjs (OK)
  • cargo check --no-default-features from src-tauri (passed, exit 0)

Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

<>
<Check size={12} className="text-accent-success" />
<span className="text-accent-success text-[11px]">
{t('editor.visualExplain.copied', 'Copied')}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

WARNING: editor.visualExplain.copied is not defined in any locale file

The PR adds copyDetails, detailsCopied, copyDetailsFailed and nodeDetails to all 13 locales, but not copied. In en.json the editor.visualExplain block has no copied key, so non-English users will see the hard-coded English fallback Copied on the button. Add editor.visualExplain.copied to every locale (the PR description also claims locale coverage is complete).

if (timerRef.current) {
clearTimeout(timerRef.current);
}
setCopied(true);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

WARNING: False "Copied" feedback when no clipboard path is available

success starts as true. When onCopyDetails is not provided and navigator.clipboard?.writeText is missing (the else if at line 80 is false), nothing is copied but setCopied(true) still runs and the button shows a checkmark. Initialise success to false and set it to true only after a clipboard write actually succeeds (also set it to true when onCopyDetails returns anything other than false).

@kilo-code-bot

kilo-code-bot Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Both earlier warnings stay resolved at current HEAD 49c9733b:

  • success defaults to false and is set to true only after a successful clipboard write or an onCopyDetails result other than false.
  • editor.visualExplain.copied is present in all 13 locale files.

Changes since the last review, in the explain-related files:

  • ExplainNodeDetails.tsx now tracks copiedNodeId instead of a boolean, so "Copied" feedback applies only to the node that was copied and clears when the selection changes. The reset effect is no longer needed.
  • The component no longer passes diagnostics to getExplainNodeDetailSections when rendering, so diagnostics appear once, in the dedicated block. The copy path still passes them to formatExplainNodeDetails, so copied text includes diagnostics.
  • ExplainNodeDetails.test.tsx covers both behaviours: diagnostics rendered once and included in copied text, and copy feedback resetting on node change.
Files Reviewed (23 files in PR)
  • packages/explain/src/components/ExplainNodeDetails.tsx
  • packages/explain/src/components/ExplainDiagramView.tsx
  • packages/explain/src/components/ExplainTableView.tsx
  • packages/explain/src/index.ts
  • packages/explain/src/nodeDetails.ts
  • packages/explain/tests/nodeDetails.test.ts
  • packages/web-ui/src/components/explain/VisualExplainView.tsx
  • packages/web-ui/src/i18n/locales/*.json (13 locales)
  • packages/web-ui/tests/components/explain/ExplainNodeDetails.test.tsx
  • packages/web-ui/tests/components/explain/VisualExplainView.test.tsx
  • src-tauri/resources/guest/runtime.js (generated bundle, not reviewed line by line)
Previous Review Summaries (3 snapshots, latest commit af218f7)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit af218f7)

Status: No Issues Found | Recommendation: Merge

Both previous warnings are resolved at commit af218f77:

  • success now defaults to false and is set to true only after a successful clipboard write or an onCopyDetails result other than false.
  • editor.visualExplain.copied is added to all 13 locale files.
Files Reviewed (14 files in incremental diff; 21 total in PR)
  • packages/explain/src/components/ExplainNodeDetails.tsx
  • packages/web-ui/src/i18n/locales/*.json (13 locales)

Previous review (commit 33112bb)

Status: 2 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 2
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
packages/explain/src/components/ExplainNodeDetails.tsx 131 editor.visualExplain.copied is not defined in any locale file; non-English users see the hard-coded English fallback "Copied".
packages/explain/src/components/ExplainNodeDetails.tsx 88 success defaults to true, so when no onCopyDetails is provided and navigator.clipboard.writeText is unavailable, nothing is copied but the "Copied" checkmark is still shown.
Files Reviewed (1 file in incremental diff; 21 total in PR)
  • packages/explain/tests/nodeDetails.test.ts - test-only refactor (typed makeNode/makeMetrics helpers), no issues
  • packages/explain/src/components/ExplainNodeDetails.tsx - 2 issues (carried forward, re-verified on current HEAD)

Fix these issues in Kilo Cloud

Previous review (commit d8dfdd8)

Status: 2 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 2
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
packages/explain/src/components/ExplainNodeDetails.tsx 131 editor.visualExplain.copied is not defined in any locale file; non-English users see the hard-coded English fallback "Copied".
packages/explain/src/components/ExplainNodeDetails.tsx 88 success defaults to true, so when no onCopyDetails is provided and navigator.clipboard.writeText is unavailable, nothing is copied but the "Copied" checkmark is still shown.
Files Reviewed (21 files)
  • packages/explain/src/components/ExplainDiagramView.tsx
  • packages/explain/src/components/ExplainNodeDetails.tsx - 2 issues
  • packages/explain/src/components/ExplainTableView.tsx
  • packages/explain/src/index.ts
  • packages/explain/src/nodeDetails.ts
  • packages/explain/tests/nodeDetails.test.ts
  • packages/web-ui/src/components/explain/VisualExplainView.tsx
  • packages/web-ui/src/i18n/locales/*.json (13 locale files)
  • packages/web-ui/tests/components/explain/VisualExplainView.test.tsx

Fix these issues in Kilo Cloud


Reviewed by claude-sonnet-5.5 · Input: 264 · Output: 3.3K · Cached: 773K

Review guidance: REVIEW.md from base branch main

debba
debba previously approved these changes Nov 9, 2026

@debba debba left a comment

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.

Thanks for sharing the formatter between the displayed details and clipboard text, and for routing the app copy action through platform.writeClipboard with error feedback. The 12 targeted web UI tests and typecheck pass.

Two follow-ups: avoid the synchronous setCopied call in useEffect, per .rules/react.md rule 2; also render Diagnostics once. getExplainNodeDetailSections now appends a Diagnostics section, while ExplainNodeDetails still renders ExplainDiagnosticList above all the returned sections.

These are follow-up nits, so I am approving this. I will leave the PR open for your manual checks before any merge.

NewtTheWolf
NewtTheWolf previously approved these changes Nov 10, 2026

@NewtTheWolf NewtTheWolf left a comment

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 updated the branch against main and addressed both earlier nits: copy feedback is derived from the node whose copy succeeded, without a synchronous state reset in an effect, and diagnostics render once while remaining in the copied text.

The new component regressions pass, along with all 8,794 frontend tests and 220 explain-package tests. Lint and typecheck are green. Approved on f4ff540, subject to the current CI checks.

@NewtTheWolf NewtTheWolf left a comment

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.

Regenerated the embedded plugin guest runtime after the Explain component changes. The resulting Git blob matches the one CI expected, and two consecutive locked builds produced identical output. The 14 related frontend tests, nine Rust sandbox-related tests and explain-package typecheck pass. Approved on 49c9733.

@NewtTheWolf
NewtTheWolf merged commit ececaea into TabularisDB:main Nov 10, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feat]: Visual EXPLAIN: copy the selected node's details

3 participants