7 Commits

Author SHA1 Message Date
Sahaj Jain d21c8e3d40 fix: keep AI chat image payloads under the serverless body limit
Uploaded images were inlined as full-resolution base64 in the message
metadata, and the entire chat history is posted on every turn. Two 4MB
uploads exceeded the 4.5MB request body cap, so the platform rejected the
request before the route ran (FUNCTION_PAYLOAD_TOO_LARGE).

- Downscale and re-encode raster uploads client-side (1536px longest edge,
  WebP with a JPEG fallback, ~300KB target). UI screenshots land around
  12KB with imperceptible color drift, so token extraction is unaffected.
- Trim images from the oldest messages when the serialized request body
  would still exceed the budget, rather than failing the request outright.
- Raise MAX_IMAGE_FILES from 2 to 5 now that the payload allows it, and
  wrap the multi-image message preview row so the thumbnails stay legible.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-17 20:50:38 +05:30
Sahaj Jain 5882f60c32 Enhance ai chat (#218)
* update package locks to avoid conflict

* Refactor AI Generation with AI SDK v5 (#210)

* refactor(wip): Whole Chat implementation

* fix: Deps

* chore: Update types and create tool to handle theme generation

* chore: Add hook and component to handle feedback text

* chore: Check for themeStyles in asssiatant metadata

* feat: Improve messages styles and feedback

* chore: Update react-hook-form deps

* chore: Improve Messages display

* chore: Show a banner when theme is generating

* chore: Optimize the Messages syncing

* feat: Add debug button to MessageActions in dev mode

* chore: messages

* chore: Improve System prompt + tools + utils

* fix: correctly display User messages with only images

* feat: Handle errors in UI and adapt to AI sdk

* feat: Use tool output instead of custom data parts

* chore: System prompt and schema context

* chore: Gemini 2.5 pro as the default model

* refactor: Change name to Chat Context and apply generated theme automatically

* chore: Update ai packages to latest version

* feat: Stop ongoing request before starting a new chat

* feat: Refactor logic for Scroll start/end sentinels

* feat: Improve UI streaming with AI Elements and Stream Text utils

* chore: Generate theme types and logic

* feat: Allow customize the speed of streaming text

* refactor: Theme generation utils

* fix: Avoid duplicated Mention references

* styles: Improve Chat error banner

* feat: Enhance Prompt core implementation

* feat: Implement enhance prompt in components

* chore: Add TODOS comments

* chore: Remove Openai provider

* chore: Update AI adk packages

* fix: Free request constant

---------

Co-authored-by: Sahaj Jain <82111591+jnsahaj@users.noreply.github.com>

* update lockfile

* fix import

* fix types

* chore: Trigger theme generation before transitioning to editor page

* refactor: Move AI sdk specific code into Lib and update imports

* chore: Provide model ID to record usage util

* refactor: Multi model provider convention

* fix types

* refactor: Use Zustand persist middleware versioning

* feat: Improve prompts and context

* feat: Optimize streaming JSONContent into text area

* chore: Improve Theme Generation prompt

* feat: Improve prompt

* feat: Add subscription checks for enhancing prompt and Posthog tracking

---------

Co-authored-by: Luis Llanes <137589205+llanesluis@users.noreply.github.com>
Co-authored-by: Luis Llanes <luisllaboj@gmail.com>
2025-10-01 16:31:10 +05:30
Sahaj Jain 8c107dd53e Feature/dynamic fonts (#197)
* chore: allow overriding ControlSection classNames

* feat: Support Google Fonts API and load fonts dynamically

* feat: Enforce System Prompt to use Google Fonts API if needed

* styles: Improve GoogleFontPicker styles

* feat: Pull Fonts from fileSystem instead of hitting the Google Fonts API every time

* feat: Improve System Prompt to reference Google Fonts

* refactor: Use Next.js Cache instead of manually fetching and reading from the filesystem

* feat: Only enable Font picker fetch when it's open

* chore: Remove JSON for Google Fonts catalogue

* feat: Scroll to selected font if it's already fetched and add clean search button

* chore: update imports

* fix: dashboard preview

---------

Co-authored-by: Luis Llanes <luisllaboj@gmail.com>
2025-07-27 23:40:36 +05:30
Luis Llanes 7bb0ff213c Fix SVG issue when processed by the API and minor styles fixes (#171)
* fix: border radius and overflow in ImagePreview component

* fix: Proper support for SVGs and UI feedback when errors occur

* SVG files are treated and displayed as Images in the UI
* SVG files are processed as Markup Text to send to the API
* Remove support for GIFs

* chore: improve system prompt to handle SVGs properly

* styles: Add border radius to uploaded image preview when loading
2025-07-18 19:43:43 +05:30
Luis Llanes 562c793e79 fix: keep mentions references in Message Edit form (#167) 2025-07-18 00:19:51 +05:30
Sahaj Jain 4c41596712 AI theme generation just got 10x better (#165)
* feat: Add polar for tweakcn-plus checkout

* migrate to polar nextjs for more control

* chore: save closable chat suggestions state as a preference in local storage

* chore: improve color contrast in user UI message

* feat: add pro features components

* chore: update TextArea styles

* feat: adjust theme generation types, functions and API to support adding an image

* feat: AI components now support and display images

* feat: add support for multiple images

* feat: add support for multiple images to components

* feat: support image only prompts and clean up API code

* chore: save closable chat suggestions state as a preference in local storage

* chore: improve color contrast in user UI message

* feat: add pro features components

* chore: update TextArea styles

* feat: adjust theme generation types, functions and API to support adding an image

* feat: AI components now support and display images

* feat: add support for multiple images

* feat: add support for multiple images to components

* feat: support image only prompts and clean up API code

* add checkout link support

* add ai-usage schema and actions

* feat: dashboard: add AI usage stats with bar chart

* feat: enforce subscription limits and improved error handling for AI theme generation

* feat: Integrate alert-banner with actual usage

* fix: pricing navigation

* feat: Checkout link generation

* feat: add quick action to create a theme from an image in ai page

* feat: add drag and drop for images

* chore: move Image Upload constant vars and update imports

* feat: improve feedback while theme is being generated

* feat: Add pricing page UI

* refactor: Dashboard migration to Settings page

* feat: improve pricing page

* feat: add auth check in checkout and refactor implementation for consistency and typesafety

* refactor: adjust code and API to follow new types and useQuery hook typesafety

* refactor: alert banner displays correctly and uses the new subscription hook

* feat: improve UI feedback for Pro users

* feat: upload images by pasting (cmd/crtl + v)

* feat: add Go Pro dialog, and global store (no implemented in app yet)

* chore(WIP): scaffold of Pro subscription modal show logic

* feat: Add openProModal logic to handleGenerateTheme in chat-interface

* chore: save closable chat suggestions state as a preference in local storage

* chore: improve color contrast in user UI message

* feat: add pro features components

* chore: update TextArea styles

* feat: adjust theme generation types, functions and API to support adding an image

* feat: AI components now support and display images

* feat: add support for multiple images

* feat: add support for multiple images to components

* feat: support image only prompts and clean up API code

* add ai-usage schema and actions

* feat: dashboard: add AI usage stats with bar chart

* feat: enforce subscription limits and improved error handling for AI theme generation

* feat: Integrate alert-banner with actual usage

* fix: pricing navigation

* feat: Checkout link generation

* feat: add quick action to create a theme from an image in ai page

* feat: add drag and drop for images

* chore: move Image Upload constant vars and update imports

* feat: improve feedback while theme is being generated

* feat: Add pricing page UI

* refactor: Dashboard migration to Settings page

* feat: improve pricing page

* feat: add auth check in checkout and refactor implementation for consistency and typesafety

* refactor: adjust code and API to follow new types and useQuery hook typesafety

* refactor: alert banner displays correctly and uses the new subscription hook

* feat: improve UI feedback for Pro users

* feat: upload images by pasting (cmd/crtl + v)

* feat: add Go Pro dialog, and global store (no implemented in app yet)

* chore(WIP): scaffold of Pro subscription modal show logic

* feat: Add openProModal logic to handleGenerateTheme in chat-interface

* refactor: follow naming convention

* chore: refactor components and layout/pages for consistency

* fix: enforce auth checks or redirect in /settings routes

* chore: update Go Pro dialog

* refactor: create reusable theme toggle component

* feat: add Get Pro dialog to header

* chore: rename GoPro dialog to GetPro and update imports

* feat: add AI generation section to Home page and adjust Get Pro dialog

* chore: save closable chat suggestions state as a preference in local storage

* chore: improve color contrast in user UI message

* feat: add pro features components

* chore: update TextArea styles

* feat: adjust theme generation types, functions and API to support adding an image

* feat: AI components now support and display images

* feat: add support for multiple images

* feat: add support for multiple images to components

* feat: support image only prompts and clean up API code

* add ai-usage schema and actions

* feat: dashboard: add AI usage stats with bar chart

* feat: enforce subscription limits and improved error handling for AI theme generation

* feat: Integrate alert-banner with actual usage

* fix: pricing navigation

* feat: Checkout link generation

* feat: add quick action to create a theme from an image in ai page

* feat: add drag and drop for images

* chore: move Image Upload constant vars and update imports

* feat: improve feedback while theme is being generated

* feat: Add pricing page UI

* refactor: Dashboard migration to Settings page

* feat: improve pricing page

* feat: add auth check in checkout and refactor implementation for consistency and typesafety

* refactor: adjust code and API to follow new types and useQuery hook typesafety

* refactor: alert banner displays correctly and uses the new subscription hook

* feat: improve UI feedback for Pro users

* feat: upload images by pasting (cmd/crtl + v)

* feat: add Go Pro dialog, and global store (no implemented in app yet)

* chore(WIP): scaffold of Pro subscription modal show logic

* feat: Add openProModal logic to handleGenerateTheme in chat-interface

* refactor: follow naming convention

* chore: refactor components and layout/pages for consistency

* fix: enforce auth checks or redirect in /settings routes

* chore: update Go Pro dialog

* refactor: create reusable theme toggle component

* feat: add Get Pro dialog to header

* chore: rename GoPro dialog to GetPro and update imports

* feat: add AI generation section to Home page and adjust Get Pro dialog

* feat: Add customer portal

* feat: add chat input draft persistence (not images)

* styles: improve styles for ai generation and alert banner defaults

* feat: Send whole chat context to AI

* fix: silly typo lol

* feat: support images persistence and sync

* feat: edit message (text, mentions and images)

* fix: add eslint-disable for exhaustive-deps warnings

* chore: fix build error & improve text and styles in suggested prompts

* refactor: handle session and subscription checks and handle post login actions

* migrate to turbopack

* refactor: use reducer builder pattern to sync ai-draft-store with image-uploader

* fix: ai-usage computation: account for abort

* feat: Theme limit handling for pro tier

* refactor: remove duplicate code from ai-chat-form and chat-input

* feat: Add faq to pricing page

* fix: /dashboard navigations -> /settings

* feat: update ui for success page

* feat: Migrate ai chat and draft message store to idb-keyval

* feat: move subscription details in-house

* generate migration

* fix: build err

* styles: improve Message UI

* fix: allow scroll in GoPro dialog chat preview

* feat: improve AI usage feedback when theme generation when success or failure

* feat: Message UI enhancement when assistant message is error feedback

* feat: add latest features in /ai page and refactor Core Theme Generation logic hooks

* styles: improve styles and layout for consistency

* styles: improve styles in settings pages for consistency

* cancelled theme doesn't cost requests

* update next to latest (for turbopack compat)

* fail build if polar webhook secret is not set

* update polar sdk and nextjs plugin

* feat: Create customer before creating checkout for them

* chore: save closable chat suggestions state as a preference in local storage

* chore: improve color contrast in user UI message

* feat: add pro features components

* chore: update TextArea styles

* feat: adjust theme generation types, functions and API to support adding an image

* feat: AI components now support and display images

* feat: add support for multiple images

* feat: add support for multiple images to components

* feat: support image only prompts and clean up API code

* add ai-usage schema and actions

* feat: dashboard: add AI usage stats with bar chart

* feat: enforce subscription limits and improved error handling for AI theme generation

* feat: Integrate alert-banner with actual usage

* fix: pricing navigation

* feat: Checkout link generation

* feat: add quick action to create a theme from an image in ai page

* feat: add drag and drop for images

* chore: move Image Upload constant vars and update imports

* feat: improve feedback while theme is being generated

* feat: Add pricing page UI

* refactor: Dashboard migration to Settings page

* feat: improve pricing page

* feat: add auth check in checkout and refactor implementation for consistency and typesafety

* refactor: adjust code and API to follow new types and useQuery hook typesafety

* refactor: alert banner displays correctly and uses the new subscription hook

* feat: improve UI feedback for Pro users

* feat: upload images by pasting (cmd/crtl + v)

* feat: add Go Pro dialog, and global store (no implemented in app yet)

* chore(WIP): scaffold of Pro subscription modal show logic

* feat: Add openProModal logic to handleGenerateTheme in chat-interface

* refactor: follow naming convention

* chore: refactor components and layout/pages for consistency

* fix: enforce auth checks or redirect in /settings routes

* chore: update Go Pro dialog

* refactor: create reusable theme toggle component

* feat: add Get Pro dialog to header

* chore: rename GoPro dialog to GetPro and update imports

* feat: add AI generation section to Home page and adjust Get Pro dialog

* feat: Add customer portal

* feat: add chat input draft persistence (not images)

* styles: improve styles for ai generation and alert banner defaults

* feat: Send whole chat context to AI

* fix: silly typo lol

* feat: support images persistence and sync

* feat: edit message (text, mentions and images)

* fix: add eslint-disable for exhaustive-deps warnings

* chore: fix build error & improve text and styles in suggested prompts

* refactor: handle session and subscription checks and handle post login actions

* migrate to turbopack

* refactor: use reducer builder pattern to sync ai-draft-store with image-uploader

* fix: ai-usage computation: account for abort

* feat: Theme limit handling for pro tier

* refactor: remove duplicate code from ai-chat-form and chat-input

* feat: Add faq to pricing page

* fix: /dashboard navigations -> /settings

* feat: update ui for success page

* feat: Migrate ai chat and draft message store to idb-keyval

* feat: move subscription details in-house

* generate migration

* fix: build err

* styles: improve Message UI

* fix: allow scroll in GoPro dialog chat preview

* feat: improve AI usage feedback when theme generation when success or failure

* feat: Message UI enhancement when assistant message is error feedback

* feat: add latest features in /ai page and refactor Core Theme Generation logic hooks

* styles: improve styles and layout for consistency

* styles: improve styles in settings pages for consistency

* cancelled theme doesn't cost requests

* update next to latest (for turbopack compat)

* fail build if polar webhook secret is not set

* update polar sdk and nextjs plugin

* feat: Create customer before creating checkout for them

---------

Co-authored-by: Luis Llanes <luisllaboj@gmail.com>
2025-07-17 00:00:07 +05:30
Luis Llanes 5a251cd912 Improve AI features and project structure (#131)
* refactor: Rename and break components into smaller components

* refactor: move ai utils to own folder and update imports

* feat: improve the AI context for theme generation

* fix: line breaks on CustomTextArea when shift + enter and when pasting a multiline prompt

* feat: improve 'create' example prompts for more consistent results
2025-06-29 23:26:42 +05:30