Skip to content

Comments

feat: add export button to WEB UI#17

Merged
mickamy merged 2 commits intomainfrom
feature/export-in-web
Feb 21, 2026
Merged

feat: add export button to WEB UI#17
mickamy merged 2 commits intomainfrom
feature/export-in-web

Conversation

@mickamy
Copy link
Owner

@mickamy mickamy commented Feb 21, 2026

No description provided.

Copilot AI review requested due to automatic review settings February 21, 2026 07:22
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 PR adds export functionality to the web UI, allowing users to download query data in JSON or Markdown format. The feature includes analytics aggregation (count, avg, p95, max durations) similar to the existing TUI export functionality.

Changes:

  • Added two export buttons (JSON and Markdown) to the header
  • Implemented data export with filtering support and analytics aggregation
  • Added timestamp-based filename generation for exported files

Reviewed changes

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

File Description
web/static/style.css Added CSS for export button group layout
web/static/index.html Added JSON and Markdown export buttons in header control group
web/static/app.js Implemented export functionality including data building, JSON/Markdown rendering, analytics calculation, and file download

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 737 to 738
if (data.filter) {
exportLine += ` (filter: ${data.filter})`;
Copy link

Copilot AI Feb 21, 2026

Choose a reason for hiding this comment

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

The filter text is directly interpolated into the markdown output without escaping. If the filter contains markdown special characters (like #, *, [, ], etc.), it could potentially break the markdown rendering. Consider escaping or sanitizing the filter text before including it in the markdown output, similar to how query text is escaped with escPipe for table cells.

Copilot uses AI. Check for mistakes.
Comment on lines 777 to 778
a.click();
URL.revokeObjectURL(url);
Copy link

Copilot AI Feb 21, 2026

Choose a reason for hiding this comment

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

The anchor element is not appended to the document before triggering the click, and URL.revokeObjectURL is called immediately after click. The anchor element should be appended to document.body before calling click() to ensure the download works reliably across browsers. Additionally, URL.revokeObjectURL should be delayed (e.g., using setTimeout) to ensure the browser has time to start the download before the URL is revoked, otherwise the download may fail in some browsers.

Suggested change
a.click();
URL.revokeObjectURL(url);
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
setTimeout(() => {
URL.revokeObjectURL(url);
}, 0);

Copilot uses AI. Check for mistakes.
Comment on lines 749 to 752
const args = q.args.length > 0
? '[' + q.args.map(a => "'" + a + "'").join(', ') + ']'
: '';
md += `| ${i + 1} | ${q.time} | ${q.op} | ${fmtDurExport(q.duration_ms)} | ${escPipe(q.query)} | ${args} | ${escPipe(q.error)} |\n`;
Copy link

Copilot AI Feb 21, 2026

Choose a reason for hiding this comment

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

The args values in markdown export are not properly escaped. When building the args string, the values are wrapped in single quotes but special characters like single quotes, pipes, and backslashes in the argument values themselves are not escaped. This could break markdown table formatting or potentially lead to injection issues. Consider escaping special characters (especially pipe characters which break markdown tables, and quotes) in argument values before including them in the markdown output.

Copilot uses AI. Check for mistakes.
@mickamy mickamy merged commit 84c29fb into main Feb 21, 2026
7 checks passed
@mickamy mickamy deleted the feature/export-in-web branch February 21, 2026 07:30
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.

1 participant