Skip to content

feat(frontend): copy query results as Markdown#1906

Open
auenger wants to merge 2 commits into
OtterMind:mainfrom
auenger:feat/copy-result-as-markdown
Open

feat(frontend): copy query results as Markdown#1906
auenger wants to merge 2 commits into
OtterMind:mainfrom
auenger:feat/copy-result-as-markdown

Conversation

@auenger

@auenger auenger commented Jul 21, 2026

Copy link
Copy Markdown

Related issue

N/A — this is a small, self-contained frontend enhancement without a linked issue.

Summary

Adds a Markdown table option under the query result selection context menu.

2867aefe-20e4-4dea-b0ec-730ee9a95281

The formatter:

  • includes selected data cells and their column titles
  • orders cells by grid row and column
  • preserves sparse selections as empty cells
  • renders nullish values as NULL
  • converts line breaks to <br>
  • escapes Markdown pipe characters

The new label is localized for English, Chinese, Japanese, Korean, and Spanish. A focused formatter test and package script are included.

Affected surfaces

  • Frontend / Web
  • Backend / API / Storage
  • Database plugin / Driver
  • JCEF / Desktop packaging
  • CI / Build / Release
  • Documentation only

Verification

  • Commands and results:
    • yarn run test:result-markdown — passed
    • yarn run test:i18n — passed
    • focused ESLint over all changed TypeScript and locale files — passed
    • git diff --check — passed
    • Community backend Maven package with Java 17 and tests skipped — 48 modules built successfully
  • Manual verification: Community frontend and backend started locally on loopback; GET /api/system through the frontend proxy returned HTTP 200.
  • UI evidence: N/A — no browser automation instance was available in the local environment.

Risk and compatibility

  • Public API or stored data: N/A; clipboard-only frontend behavior.
  • Database or driver compatibility: N/A.
  • Network, privacy, or security: No new network calls; selected result values are copied only through the existing clipboard utility.
  • Community / Local / Pro boundary: Implemented in the Community frontend.
  • Backward compatibility: Additive context-menu item; existing copy formats are unchanged.

Reviewer map

  • Start here: markdownTable.ts for formatting rules, then onContextmenuCell/index.ts for menu integration.
  • Failure condition: Incorrect ordering or escaping could produce malformed Markdown for sparse or multiline selections.
  • Rollback or disable path: Remove the markdownTable context-menu entry and its formatter/handler.

Contributor declaration

  • I linked the Issue that defines this change.
  • I tested the affected behavior and reported the actual results above.
  • I did not include credentials, private data, or generated build output.
  • I disclosed substantial AI assistance below, or this PR contains no substantial AI-generated code.

AI assistance: OpenAI Codex assisted with implementation and test drafting; the changes were reviewed and verified locally.

@openai0229

Copy link
Copy Markdown
Contributor

Thanks for the contribution. There are two potential issues worth checking before merging:

  1. Backslash followed by a pipe may break the generated table

    For a cell value such as left\|right, the current formatter produces left\\|right. In GFM, the two backslashes resolve to a literal backslash, leaving the pipe to act as a column separator. This can shift columns or drop subsequent values.

    Could you verify this case? One possible fix is to escape backslashes before escaping pipes:

    .replace(/\\/g, "\\\\")
    .replace(/\|/g, "\\|")

    It would also be useful to add a regression test covering \|.

  2. The new test script does not appear to run in CI

    test:result-markdown was added to package.json, but the frontend CI workflow runs each test script explicitly and does not currently invoke this one. Could you add a corresponding step to .github/workflows/ci.yml?

The existing formatter test, i18n validation, ESLint, and Community Web build otherwise passed in my local review.

@auenger
auenger force-pushed the feat/copy-result-as-markdown branch from 2ea11e2 to 5f08299 Compare July 22, 2026 03:51
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.

2 participants