Files
loki/widget
CatoandCursor Agent 2ba52001f7 Fix feedback widget: multiple screenshots + prominent voice + dispatch fix (#537)
* Fix feedback widget: multiple screenshots + prominent voice + dispatch fix

- Widget UI: Make voice recording and screenshots primary actions with larger buttons and camera/mic icons
- Support multiple screenshots (up to 5) with array storage and individual thumbnails
- Update API to accept screenshots array instead of single screenshot
- Add database migration for screenshots jsonb column
- Fix dispatch 'tab not found' by preferring user_projects.name over entities.name
- Display multiple screenshot thumbnails in feedback inbox
- Screenshots load on demand to keep inbox payload small

Widget changes:
- Voice button now says 'Record your feedback' instead of 'Speak'
- Screenshot button shows 'Add screenshots' with camera icon
- Multiple files can be selected or pasted
- Each screenshot shown as thumbnail with remove button
- Max 5 screenshots with clear count indicator

Backend changes:
- site_feedback.screenshots jsonb array replaces screenshot text
- Migration preserves existing data by wrapping in array
- getFeedbackWithProject now uses user_projects join for dispatch compatibility
- API route returns JSON array instead of single image

UI changes:
- FeedbackItemRow shows all screenshots as thumbnails
- Screenshots API returns JSON with array of data URLs
- On-demand loading keeps initial page load fast

* Fix dispatch flow and widget colors - complete end-to-end path

Dispatch improvements:
- Validate project exists in user_projects before dispatch
- Only mark feedback as DISPATCHED if injection succeeds (status < 400)
- Add helpful error hints for common failures (404 = project not found)
- getFeedbackWithProject now prefers user_projects.name for dispatch compatibility
- Prevents 'tab not found' errors by using correct project name source

Widget color system:
- Remove all hardcoded hex colors (#e0680f, stone grays)
- Add WidgetTheme type with 18 semantic color tokens
- Boot payload now serves theme colors
- Widget builds CSS dynamically from theme
- Falls back to DEFAULT_THEME if boot doesn't provide colors
- Consistent branding across all widget states

Fixes 'tab not found' issue where:
1. Feedback referenced entities.name
2. Dispatch looked up user_projects.name
3. Mismatch caused injection to fail
4. Now getFeedbackWithProject joins user_projects and prefers that name

Work phase logic already correct:
- UNCONFIRMED outcome shows as FAILED, not DONE
- Run with no deliveredAt after 90s shows as STUCK
- Only SUCCESS/PARTIAL outcomes show as DONE

* Remove all hardcoded colors from widget - require theme from boot

- Remove DEFAULT_THEME constant entirely
- Widget now requires theme from /api/widget-boot payload
- If boot doesn't provide theme, widget doesn't render
- Zero hardcoded hex values in widget code
- Boot payload is single source of truth for all colors

No second palette - boot accent change changes widget without edit to main.ts

* Use PALETTE.widget for theme - single source of truth for all colors

- Remove WIDGET_THEME local object from widget-boot route
- Add widget theme to PALETTE.ts (JS mirror of CSS design tokens)
- PALETTE.widget maps to app's dark-mode tokens (widget always dark)
- Boot route serves PALETTE.widget, not a second palette
- To change widget colors: edit PALETTE.widget + matching CSS tokens

One source: PALETTE.ts mirrors globals.css. Change both together.
Widget receives resolved values via boot payload.

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
2026-09-09 09:00:56 -07:00
..
…