Skip to content

feat: export chart data as CSV#740

Open
nehaaprasaad wants to merge 1 commit intogetnao:mainfrom
nehaaprasaad:feat/exp-chrt-dat-csv
Open

feat: export chart data as CSV#740
nehaaprasaad wants to merge 1 commit intogetnao:mainfrom
nehaaprasaad:feat/exp-chrt-dat-csv

Conversation

@nehaaprasaad
Copy link
Copy Markdown
Contributor

What

  • Add CSV export for charts (chat + story embeds).

Why

  • Users need the rows behind a chart without redoing the answer as a table.

How

  • Shared CSV helpers in @nao/shared/csv, small export button; chat uses the same filtered rows as the chart (incl. date range when shown).

Closes : #718

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 7, 2026

🚀 Preview Deployment

URL https://pr-740-09ccca1.preview.getnao.io
Commit 09ccca1

⚠️ No LLM API keys configured - you'll see the API key setup flow when trying to chat.


Preview will be automatically removed when this PR is closed.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 6 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="apps/shared/src/csv.ts">

<violation number="1" location="apps/shared/src/csv.ts:4">
P2: `escapeCsvCell` regex omits carriage return (`\r`) from characters that trigger CSV field quoting, which can break row boundaries per CSV spec</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread apps/shared/src/csv.ts
export function escapeCsvCell(value: unknown): string {
const str = value === null || value === undefined ? '' : String(value);
const sanitized = /^[=+\-@]/.test(str.trimStart()) ? `'${str}` : str;
return /[,"\n]/.test(sanitized) ? `"${sanitized.replace(/"/g, '""')}"` : sanitized;
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.

P2: escapeCsvCell regex omits carriage return (\r) from characters that trigger CSV field quoting, which can break row boundaries per CSV spec

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/shared/src/csv.ts, line 4:

<comment>`escapeCsvCell` regex omits carriage return (`\r`) from characters that trigger CSV field quoting, which can break row boundaries per CSV spec</comment>

<file context>
@@ -0,0 +1,45 @@
+export function escapeCsvCell(value: unknown): string {
+	const str = value === null || value === undefined ? '' : String(value);
+	const sanitized = /^[=+\-@]/.test(str.trimStart()) ? `'${str}` : str;
+	return /[,"\n]/.test(sanitized) ? `"${sanitized.replace(/"/g, '""')}"` : sanitized;
+}
+
</file context>
Suggested change
return /[,"\n]/.test(sanitized) ? `"${sanitized.replace(/"/g, '""')}"` : sanitized;
return /[,"\r\n]/.test(sanitized) ? `"${sanitized.replace(/"/g, '""')}"` : sanitized;

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.

[feature] Export chart data as CSV (and unify table/chart objects?)

1 participant