Skip to content

refactor(sdk/ui): code quality, structure, and type fixes - #20

Merged
cescox merged 2 commits into
mainfrom
refactor/sdk-ui-quality
Apr 23, 2026
Merged

cescox merged 2 commits into
mainfrom
refactor/sdk-ui-quality

Conversation

@cescox

@cescox cescox commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Structure: move public types (errors.ts, types.ts) out of internal/, rename hooks to kebab-case (use-action.ts, use-credits.ts)
  • API fixes: fix ActionButton.onResult to use ActionResult type, add error field to useCredits, remove redundant subscribeUrl from hook result, drop dead CanupErrorType export
  • Code quality: robust error handling in api-client, async/await jwt-cache, stable ActionButton callbacks via useRef, deduplicate error normalization via toCanupError
  • Tests: merge split vitest imports, use shared renderWithCanva, fix relative import paths
  • Docs: remove nonexistent CLI commands and CanupErrorType from README

Test plan

  • All 80 UI tests pass (pnpm vitest run src/ui/)
  • TypeScript compiles clean (pnpm tsc --noEmit)
  • ESLint + Prettier pass (pre-commit hooks)
  • Build succeeds (pnpm build)

Made with Cursor

cescox added 2 commits April 23, 2026 15:00
- Rename hooks to kebab-case (useAction→use-action, useCredits→use-credits)
- Move errors.ts and types.ts out of internal/ (they're public API)
- Move ApiResponse envelope type into api-client.ts (truly internal)
- Fix ActionButton.onResult type to use ActionResult (was hiding credits)
- Add error field to UseCreditsResult for parity with useAction
- Remove redundant subscribeUrl from UseCreditsResult (use data.subscribeUrl)
- Remove dead CanupErrorType export
- Robust error handling in api-client (wrap fetch + JSON parse)
- Rewrite jwt-cache with async/await and safe JWT parsing
- Stable ActionButton callbacks via useRef + useCallback
- CreditCounter extends Rows props, forwards spacing/align
- Deduplicate error normalization via toCanupError
- Merge split vitest imports, use shared renderWithCanva
- Fix README: remove nonexistent CLI commands and CanupErrorType

Made-with: Cursor
Silences TS2686 UMD global warning in editor.

Made-with: Cursor
@github-actions

Copy link
Copy Markdown

size-limit report 📦

Path Size
UI entry (full import) 16.27 KB (+1.21% 🔺)

@github-actions

Copy link
Copy Markdown

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 99.52% (🎯 95%) 1257 / 1263
🔵 Statements 99.54% (🎯 95%) 1304 / 1310
🔵 Functions 99.54% (🎯 95%) 219 / 220
🔵 Branches 95.84% (🎯 85%) 553 / 577
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
src/ui/errors.ts 100% 75% 100% 100%
src/ui/components/ActionButton.tsx 100% 100% 100% 100%
src/ui/components/CreditCounter.tsx 100% 96.42% 100% 100%
src/ui/internal/api-client.ts 87.5% 80% 100% 86.66% 28, 35-37
src/ui/internal/jwt-cache.ts 94.44% 100% 100% 94.44% 19
src/ui/internal/query.ts 100% 100% 100% 100%
src/ui/internal/i18n/use-intl.ts 90% 83.33% 100% 88.88% 19
Generated in workflow #26 for commit bae1348 by the Vitest Coverage Report Action

@cescox
cescox merged commit 6f4eeba into main Apr 23, 2026
9 checks passed
@cescox
cescox deleted the refactor/sdk-ui-quality branch April 23, 2026 20:08
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