Skip to content

Conversation

@Sg312
Copy link
Contributor

@Sg312 Sg312 commented Nov 12, 2025

Summary

Fix template details page

Type of Change

  • Bug fix

Testing

Manual

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link

vercel bot commented Nov 12, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
docs Skipped Skipped Nov 12, 2025 6:42pm

@Sg312 Sg312 merged commit cb39e69 into staging Nov 12, 2025
9 checks passed
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Nov 12, 2025

Greptile Overview

Greptile Summary

This PR refactors the template details page from server-side rendering (SSR) to client-side rendering (CSR). The main changes include:

  • page.tsx: Removed all server-side data fetching logic and converted to a simple wrapper component
  • template.tsx: Converted from receiving props to fetching data client-side using useEffect and fetch calls
  • templates.tsx: Updated to use Input from @/components/emcn instead of @/components/ui/input (follows custom instructions)
  • Data structure enhancements: Added support for creator profiles, markdown descriptions, social links, and credential requirements

Critical Issue Found:
The component attempts to fetch user session from /api/auth/get-session endpoint which does not exist in the codebase. This will cause the session fetch to fail silently, preventing authenticated features from working properly (starring, "Use Template" without redirect, owner checks).

Confidence Score: 1/5

  • This PR introduces a critical bug that breaks authentication-dependent features
  • The non-existent /api/auth/get-session endpoint will cause all authenticated features to fail. Users won't be able to star templates properly, owner checks will fail, and the "Use Template" flow will always redirect to login even for authenticated users. This is a regression from the working server-side implementation.
  • Pay critical attention to apps/sim/app/workspace/[workspaceId]/templates/[id]/template.tsx - the session fetch needs to be fixed before merging

Important Files Changed

File Analysis

Filename Score Overview
apps/sim/app/workspace/[workspaceId]/templates/[id]/page.tsx 5/5 Converted from server component with data fetching to simple wrapper that delegates to client component
apps/sim/app/workspace/[workspaceId]/templates/[id]/template.tsx 1/5 Converted from receiving props to client-side data fetching, but calls non-existent /api/auth/get-session endpoint which will fail

Sequence Diagram

sequenceDiagram
    participant User
    participant Browser
    participant Page as page.tsx (Server)
    participant Template as template.tsx (Client)
    participant API as /api/templates/[id]
    participant AuthAPI as /api/auth/get-session
    
    User->>Browser: Navigate to template detail page
    Browser->>Page: Request page
    Page->>Template: Render TemplateDetails component
    Template->>Browser: Show loading state
    
    par Fetch template and session in parallel
        Template->>API: GET /api/templates/{id}
        API-->>Template: Return template data
    and
        Template->>AuthAPI: GET /api/auth/get-session
        AuthAPI--xTemplate: 404 - Endpoint does not exist ❌
    end
    
    Template->>Browser: Display template (without user session)
    
    alt User clicks "Use Template"
        Template->>Template: Check if currentUserId exists
        Note over Template: currentUserId will be null due to failed auth fetch
        Template->>Browser: Redirect to login
    end
Loading

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.

4 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile


const fetchCurrentUser = async () => {
try {
const response = await fetch('/api/auth/get-session')
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: /api/auth/get-session endpoint does not exist in the codebase. Use getSession() from @/lib/auth instead (server-side only), or access session data from a different client-side pattern.

For client-side components, session should either be:

  1. Passed as a prop from a server component
  2. Accessed via a proper session provider/context
  3. Or the component should remain server-side
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/sim/app/workspace/[workspaceId]/templates/[id]/template.tsx
Line: 164:164

Comment:
**logic:** `/api/auth/get-session` endpoint does not exist in the codebase. Use `getSession()` from `@/lib/auth` instead (server-side only), or access session data from a different client-side pattern.

For client-side components, session should either be:
1. Passed as a prop from a server component
2. Accessed via a proper session provider/context
3. Or the component should remain server-side

How can I resolve this? If you propose a fix, please make it concise.

@waleedlatif1 waleedlatif1 deleted the fix/templates-details-page branch November 18, 2025 01:27
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