Skip to content

feat(explain): save raw plan output to file (#1162) - #1178

Open
markankamaransheogarat-sys wants to merge 3 commits into
TabularisDB:mainfrom
markankamaransheogarat-sys:feat/save-raw-explain-file
Open

markankamaransheogarat-sys wants to merge 3 commits into
TabularisDB:mainfrom
markankamaransheogarat-sys:feat/save-raw-explain-file

Conversation

@markankamaransheogarat-sys

Copy link
Copy Markdown
Contributor

Closes #1162

Summary

Adds "Save raw plan…" action to the raw EXPLAIN view in VisualExplainView, allowing users to directly save the original raw_output to a file without manual copy-pasting or re-running queries.

Details & Acceptance Criteria

  • Language-based file extensions: Uses detectRawExplainLanguage via new getRawExplainExtension and getRawExplainFileOptions helpers to automatically default to .json for JSON plans, .xml for SHOWPLAN XML, and .txt for plaintext output.
  • Save original content: Writes the original raw_output verbatim without reformatting or re-running EXPLAIN.
  • Snapshot capture: Synchronously captures plan?.raw_output before awaiting the save dialog, preventing subsequent queries from overriding the exported content.
  • Edge cases & accessibility: Button is disabled when raw_output is absent or while save is in progress. Handles user cancellation without errors, logs and alerts on write failures. Complies with jsx-a11y and theme token styling rules.
  • Full localization: Adds saveRawPlan and saveRawError keys across all 11 supported locales.
  • Tests: Added unit test coverage in tests/utils/explainRaw.test.ts and component interaction test coverage in tests/components/explain/VisualExplainView.test.tsx.

- add getRawExplainExtension and getRawExplainFileOptions to pick json/xml/txt extensions
- add saveRawExplainOutput helper to prompt native file save dialog and write original raw_output
- add 'Save raw plan…' button to the raw EXPLAIN view in VisualExplainView
- synchronously capture plan snapshot before awaiting dialog so later queries cannot replace exported content
- disable save button when raw_output is unavailable
- handle user cancellation without error and alert on write failure
- add localized translations across all 11 supported locales
- add unit tests in tests/utils/explainRaw.test.ts and component tests in tests/components/explain/VisualExplainView.test.tsx
<div className="flex flex-col h-full min-h-0">
<div className="flex items-center justify-between px-4 py-2 border-b border-default bg-base/40">
<span className="text-xs font-mono uppercase text-muted">
{rawLanguage}

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.

SUGGESTION: Internal language identifier rendered as user-facing text

rawLanguage is a Monaco language id ("json" | "xml" | "plaintext"), so the new header badge shows the literal, non-localized string PLAINTEXT for plain-text plans. The i18n rule requires user-visible strings to go through t(). Either drop the badge (the save button is the only functional element in this bar) or map the language to a localized label, e.g. a editor.visualExplain.rawFormat.* key set added to all locales.


Reply with @kilocode-bot fix it to have Kilo Code address this issue.

@kilo-code-bot

kilo-code-bot Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Notes

  • The previous suggestion is resolved: VisualExplainView now calls getRawExplainFormatLabel(rawLanguage, t("editor.visualExplain.formatText", "Text")), so the helper is the single source of truth for the format label. It also passes the localized label for plain-text plans.
  • The helper's new formatTextLabel = "Text" default keeps the existing unit tests in tests/utils/explainRaw.test.ts valid.
  • Not run (read-only review): the test suite, lint, and the app itself.
Files Reviewed (2 files in incremental diff)
  • src/components/explain/VisualExplainView.tsx
  • src/utils/explainRaw.ts
Previous Review Summaries (2 snapshots, latest commit 0ade37e)

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

Previous review (commit 0ade37e)

Status: 1 Issue Found | Recommendation: Merge after considering the suggestion

Overview

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

SUGGESTION

File Line Issue
src/utils/explainRaw.ts 43 getRawExplainFormatLabel is only used by its own tests; VisualExplainView duplicates the same switch inline (with the localized Text label), so the tested helper is dead code and the real mapping is untested.

Notes

  • The previous finding (non-localized PLAINTEXT badge) is fixed: the header now maps to JSON/XML/localized Text via the new editor.visualExplain.formatText key, present in all 11 locales.
  • Not run (read-only review): the test suite, lint, and the app itself.

Fix these issues in Kilo Cloud

Files Reviewed (15 files)
  • src/components/explain/VisualExplainView.tsx
  • src/utils/explainRaw.ts - 1 issue
  • src/i18n/locales/{de,en,es,fr,it,ja,ko,pt-BR,ru,tl,zh}.json
  • tests/utils/explainRaw.test.ts

Previous review (commit 5f58019)

Status: 1 Issue Found | Recommendation: Merge after considering the suggestion

Overview

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

SUGGESTION

File Line Issue
src/components/explain/VisualExplainView.tsx 153 The new header badge renders the internal Monaco language id (PLAINTEXT for plain-text plans) as non-localized user-facing text.

Notes

  • The save flow reads plan.raw_output before awaiting the dialog, writes it verbatim, treats cancel as a no-op, and alerts on failure. The helper tests and component tests cover these paths.
  • Raw view now always renders its own pane. A plan without raw_output shows the existing noRawOutput message instead of falling through to the graph view. This looks intentional and is covered by a test, but it is a behavior change.
  • The new saveRawPlan and saveRawError keys are present in all 11 locales. Theme tokens and a11y attributes follow repo rules.
  • Not run (read-only review): the test suite, lint, and the app itself.

Fix these issues in Kilo Cloud

Files Reviewed (15 files)
  • src/components/explain/VisualExplainView.tsx - 1 issue
  • src/utils/explainRaw.ts
  • src/i18n/locales/{de,en,es,fr,it,ja,ko,pt-BR,ru,tl,zh}.json
  • tests/components/explain/VisualExplainView.test.tsx
  • tests/utils/explainRaw.test.ts

Reviewed by claude-sonnet-5.5 · Input: 252 · Output: 1.2K · Cached: 186.7K

Review guidance: REVIEW.md from base branch main

- add getRawExplainFormatLabel helper in explainRaw.ts
- render localized Text format badge instead of internal PLAINTEXT language id
- add formatText translations across all 11 locales
@github-actions

github-actions Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Preview build

The preview build of commit 014e35f failed (skipped). See the workflow run for logs.

Comment thread src/utils/explainRaw.ts Outdated
* Return a clean user-facing format label for a raw EXPLAIN payload.
* "json" maps to "JSON", "xml" to "XML", and "plaintext" to "Text".
*/
export function getRawExplainFormatLabel(language: RawExplainLanguage): string {

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.

SUGGESTION: Unused helper duplicates inline logic

getRawExplainFormatLabel is only referenced by its own unit tests; VisualExplainView re-implements the same json/xml/plaintext switch inline (with a localized Text label). The tests therefore cover a function that production code never calls, while the real, localized mapping in the component is untested. Remove this helper and its tests, or move the mapping here (e.g. return a key/fallback pair that the component passes to t()) so there is a single source of truth.


Reply with @kilocode-bot fix it to have Kilo Code address this issue.

This branch has not been deployed

No deployments
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]: Save the raw EXPLAIN output to a file

1 participant