Skip to content

Fix install/build/tests, patch the workbook parser, settle failed runs, chart numeric sheets - #1

Open
rxslice wants to merge 1 commit into
mainfrom
fix/audit-deck
Open

rxslice wants to merge 1 commit into
mainfrom
fix/audit-deck

Conversation

@rxslice

@rxslice rxslice commented Nov 14, 2026

Copy link
Copy Markdown
Owner

Fixes audit findings DECK-1 to DECK-4.

DECK-1: fresh clone now installs, builds, type-checks, lints and tests

  • npm is the package manager: bun.lockb is removed and package-lock.json regenerated, so npm ci succeeds. Test tools (vitest, jsdom, Testing Library) moved to devDependencies, and the missing @testing-library/jest-dom was added.
  • use-toast.ts is renamed to .tsx, since it contains JSX.
  • vitest.config.ts now uses @vitejs/plugin-react-swc, the plugin the manifest actually installs.
  • useToast called hooks conditionally (a rules-of-hooks error). The hooks now run unconditionally, and toast() no longer throws before a provider mounts.
  • src/integrations/supabase/types.ts described a different project's tables (qr_codes, webhooks, …). user_projects is added, which removes all 16 type errors in dataService.ts.
  • Two existing tests were broken (they assigned event.target, and they expected a progress bar without a selected file). Both are fixed.
  • Lint: 0 errors. The remaining warnings are no-explicit-any and fast-refresh notices; no-explicit-any is set to warn.
  • CI added: npm ci, type check, lint, tests, build.

DECK-2: workbook parser

  • xlsx 0.18.5 is replaced by SheetJS 0.20.3 from cdn.sheetjs.com, outside both the prototype-pollution and ReDoS advisory ranges. SheetJS no longer publishes to npm.
  • New limits: 20 MB per file (down from 100 MB, because parsing runs in the tab), 50 sheets, and 1,000,000 cells per sheet. The cell limit is read from the sheet's declared !ref before the sheet is expanded, so a small file that declares a huge range is rejected. The UI copy now says 20 MB.

DECK-3: failed or cancelled runs no longer stay busy

  • A new END_PROCESSING transition runs in finally on every exit path. Failures and cancellations clear isProcessing without marking the session completed.
  • Cancellation during parsing or extraction now returns CANCELLED rather than a validation or extraction error.
  • Only the newest run settles shared state; starting a new run aborts the older one.

DECK-4: numeric sheets become charts

  • The chart check (isChartable: a header row, 2+ data rows, and a numeric value column) now runs before the table fallback. Text-only sheets remain tables. The policy is documented in the code and the README.
  • The Math.random() "processing time" stat is removed; it now returns null until real durations are recorded.

Database: supabase/migrations/…_user_projects.sql defines the table the app expects, with owner-only RLS policies. I could not see the deployed database, so compare before applying.

Verification

  • 18 unit tests pass. The new ones fail on the old code: routing (numeric sheet → chart), 4 terminal-state cases, and the parser's version and cell-limit checks.
  • dev/check-upload-download.cjs (Playwright, with Supabase auth stubbed) uploads a 3-quarter workbook and downloads the deck. The .pptx opens as a valid zip with 5 slides and 3 charts, and there are no page errors.
  • A fresh npm ci passes type check, lint, tests and build.

Still open (separate PR): npm audit drops from 32 entries to 19. The 7 runtime ones need major upgrades: react-router 7, zod 4, and image-size ≥ 2.0.3, which pptxgenjs 4.0.1 pins to 1.x. The rest are dev tooling: vitest 4 for the critical tinypool entry, and esbuild through vite. No licence is added.


Generated by Claude Code

…d runs; route numeric sheets to charts

- DECK-1: npm is the package manager (bun.lockb removed, lockfile regenerated,
  test tools moved to devDependencies); use-toast is .tsx; vitest uses the
  SWC plugin; broken tests repaired; Supabase types gain user_projects;
  conditional hooks in useToast fixed; lint has 0 errors; CI added
- DECK-2: SheetJS 0.20.3 from the SheetJS CDN (outside both advisory ranges);
  20 MB file cap, 50 sheets, 1M declared cells per sheet checked before expansion
- DECK-3: every exit path ends with END_PROCESSING; cancellation reports
  CANCELLED instead of a validation error; only the newest run settles state
- DECK-4: chart eligibility is checked before the table fallback
- Remove Math.random processing-time stat; add user_projects migration with RLS
- Tests: 18 unit tests, browser check for upload to a valid PPTX download

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011GFY8v4QeVYzawpSLcJCzz
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