fix: image upload via /image slash command not working (#184)#195
Conversation
- Add page-images storage bucket migration with RLS policies - Return structured errors from uploadImage instead of silent null - Show toast notifications on upload failure (type, size, storage errors) - Add regression tests for uploadImage validation and error paths Co-authored-by: Ona <no-reply@ona.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
zacharias-ona
left a comment
There was a problem hiding this comment.
The TypeScript changes (discriminated union return type, toast error feedback) look good — well-typed, correctly used in both code paths, and well-tested.
However, the migration file is empty. This is the primary fix for the root cause (missing storage bucket), so the bug isn't actually resolved without it.
- Empty migration —
supabase/migrations/20260417165531_create_page_images_bucket.sqlcontains no SQL. It needs the bucket creation and RLS policies. See inline comment for details.
I'll fix this now.
The migration file was empty — no SQL to create the storage bucket or RLS policies. Added bucket creation with size/type constraints and policies for authenticated upload, public read, and owner delete. Co-authored-by: Ona <no-reply@ona.com>
|
✅ UI verification passed — design spec compliance confirmed. Static analysis: The only UI file changed ( Visual verification: Playwright screenshots of the editor page (desktop dark + mobile 375px) show no regressions — layout, spacing, typography, dark mode tokens, sidebar behavior, and mobile responsiveness all conform to |
|
✅ Post-merge verification passed. E2E suite: 46/47 passed. The 1 failure ( Ad-hoc smoke tests against
Skipped:
|
Closes #184
What
The
/imageslash command opened a file picker but selecting an image had no effect — the image never appeared in the editor. Two root causes: (1) thepage-imagesSupabase Storage bucket was never created (no migration existed), so every upload failed, and (2)uploadImagesilently returnednullon any failure with no user-visible feedback.How
page-imagesstorage bucket with RLS policies (authenticated users can upload, public read access).uploadImageto return a discriminated union{ url, error }instead ofstring | null, so callers always know why an upload failed.toast.error()notifications in bothopenImagePicker(slash command path) and the drag-and-drop handler so users see actionable error messages on validation failures (wrong type, too large) and storage errors.Testing
uploadImagecovering: unsupported type rejection, file size limit, Supabase upload failure, successful upload with public URL, all accepted MIME types, and boundary size (exactly 5 MB).pnpm lint && pnpm typecheck && pnpm testall pass (213 tests).pnpm test:e2epasses (46/47, 1 pre-existing flaky test in page-icon.spec.ts).