Skip to content

generalized chat routes and vibe coding #771

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Jul 18, 2025

Conversation

BilalG1
Copy link
Contributor

@BilalG1 BilalG1 commented Jul 16, 2025

https://www.loom.com/share/acaea08979274fc194357a5359f0938a?sid=6b5a2ac0-1f87-4311-8b40-0c2e22cd965d


Important

This PR adds support for email templates, refactors chat handling, and updates UI components for enhanced email and chat functionalities.

  • Behavior:
    • Adds support for rendering emails with either theme_id or template_id in render-email/route.tsx.
    • Introduces ai-chat/[threadId]/route.tsx for handling chat messages with context types email-theme and email-template.
    • Adds PATCH and GET routes for email-templates/[templateId]/route.tsx to update and retrieve email templates.
  • Adapters:
    • Adds emailTemplateAdapter and emailThemeAdapter in adapter-registry.ts for chat context handling.
    • Implements renderEmailWithTemplate in email-themes.tsx for rendering emails with templates.
  • UI Components:
    • Updates page-client.tsx for email templates and themes to use VibeCodeLayout with AssistantChat and CodeEditor.
    • Adds ThemePreview component to handle email preview rendering with error boundaries.
  • Misc:
    • Renames OPENAI_API_KEY to STACK_OPENAI_API_KEY in .env.development.
    • Refactors chat-adapters.ts to handle tool calls and chat message history.

This description was created by Ellipsis for df210b8. You can customize this summary. It will automatically update as commits are pushed.

Copy link

vercel bot commented Jul 16, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
stack-backend ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 17, 2025 9:08pm
stack-dashboard ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 17, 2025 9:08pm
stack-demo ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 17, 2025 9:08pm
stack-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 17, 2025 9:08pm

@BilalG1 BilalG1 changed the base branch from dev to vibe-coding-templates July 16, 2025 19:10
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Greptile Summary

This PR implements a significant refactoring of the email template and theme management system, introducing AI-assisted capabilities through a generalized chat system. The changes include:

  1. Introduction of a new email template editor with live preview and AI assistance
  2. Generalization of chat functionality through an adapter-based architecture
  3. New vibe-coding components for consistent UI/UX across AI-assisted features
  4. Migration from role-based to content-based chat messages
  5. Enhanced email rendering system supporting both themes and templates

The changes represent a shift from specialized chat implementations to a more flexible, adapter-based system that can handle different types of AI-assisted content generation. The code demonstrates good separation of concerns, type safety, and proper error handling.

The database schema changes (removing ThreadMessageRole) and the new configuration system suggest a more dynamic approach to message handling and template management.

Confidence score: 4/5

  1. This PR is relatively safe to merge with proper testing of the new template editor
  2. The score reflects the well-structured changes and proper error handling, but complex UI changes warrant thorough testing
  3. Key files needing attention:
    • apps/backend/src/app/api/latest/internal/ai-chat/[threadId]/route.tsx (AI chat implementation)
    • apps/dashboard/src/components/vibe-coding/assistant-chat.tsx (Core chat UI)
    • apps/backend/prisma/schema.prisma (Message role removal)

36 files reviewed, 11 comments
Edit PR Review Bot Settings | Greptile

Copy link

recurseml bot commented Jul 16, 2025

✨ No issues found! Your code is sparkling clean! ✨

🗒️ View all ignored comments in this repo
  • The constraint 'TokenStoreType extends string' is too restrictive. It should likely be 'TokenStoreType extends string | object' to match the condition check in line 113 where TokenStoreType is checked against {}
  • Return type mismatch - the interface declares useUsers() returning ServerUser[] but the Team interface that this extends declares useUsers() returning TeamUser[]
  • There is a syntax error in the super constructor call due to the ellipsis operator used incorrectly. Objects aren't being merged correctly. This syntax usage can lead to runtime errors when trying to pass the merged object to 'super()'. Verify that the intended alterations to the object occur before or outside of the super() call if needed.
  • Throwing an error when no active span is found is too aggressive. The log function should gracefully fallback to console.log or another logging mechanism when there's no active span, since not all execution contexts will have an active span. This makes the code less resilient and could break functionality in non-traced environments.

📚 Relevant Docs

  • Function sets backendContext with a new configuration but doesn't pass 'defaultProjectKeys'. Since defaultProjectKeys is required in the type definition and cannot be updated (throws error if tried to set), this will cause a type error.
  • The schema is using array syntax for pick() which is incorrect for Yup schemas. The pick() method in Yup expects individual arguments, not an array. Should be changed to: emailConfigSchema.pick('type', 'host', 'port', 'username', 'sender_name', 'sender_email')

📚 Relevant Docs

  • Creating a refresh token with current timestamp as expiration means it expires immediately. Should set a future date for token expiration.
  • The 'tools' object is initialized as an empty object, even though 'tools' is presumably expected to contain tool definitions. This could cause the server capabilities to lack necessary tool configurations, thus potentially impacting functionalities that depend on certain tool setups.

📚 Relevant Docs

  • 'STACK_SECRET_SERVER_KEY' is potentially being included in every request header without checking its existence again here. Although it's checked during initialization, this could lead to security issues as it's exposed in all communications where the header is logged or captured.

📚 Relevant Docs

  • When adding 'use client' directive at the beginning, it doesn't check if file.text already contains the 'use client' directive. This could lead to duplicate 'use client' directives if the file already has one.

📚 Relevant Docs

⚠️ Only 5 files were analyzed due to processing limits.

Need help? Join our Discord for support!
https://discord.gg/qEjHQk64Z9

Base automatically changed from vibe-coding-templates to email-themes-ui-fixes July 17, 2025 20:02
@BilalG1 BilalG1 merged commit fd62a4d into email-themes-ui-fixes Jul 18, 2025
14 of 17 checks passed
@BilalG1 BilalG1 deleted the ai-chat-refactoring branch July 18, 2025 17: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.

2 participants