Skip to content

Fix template project creation returning to welcome screen#532

Open
vellanki-santhosh wants to merge 1 commit intoIronclad:mainfrom
vellanki-santhosh:main
Open

Fix template project creation returning to welcome screen#532
vellanki-santhosh wants to merge 1 commit intoIronclad:mainfrom
vellanki-santhosh:main

Conversation

@vellanki-santhosh
Copy link

Problem

When creating a new project from a template (AI Agent Template, MCP AI Agent Template, or Tutorial), clicking 'Create' caused the modal to close and return to the welcome screen instead of opening the template project.

Root Cause

The useNewProjectFromTemplate hook was missing critical state updates that manage the list of opened projects. While it correctly set the project data, it didn't update openedProjectsState and openedProjectsSortedIdsState. This caused the app to think no projects were open (openedProjectIds.length === 0), so it continued displaying the welcome screen.

Solution

Updated useNewProjectFromTemplate.ts to match the behavior of useNewProject by:

  1. Added imports for openedProjectsState, openedProjectsSortedIdsState, and OpenedProjectInfo type
  2. Added useAtomValue for reading current opened project IDs
  3. Added setters for openedProjectsState and openedProjectsSortedIdsState
  4. After creating the project with new ID, now properly updates the opened projects registry
  5. Appends the new project ID to the sorted IDs list

This ensures that when a template is loaded, the app correctly tracks it as an opened project and displays it instead of returning to the welcome screen.

Testing

  • Create a new project from AI Agent Template → template opens correctly
  • Create a new project from MCP AI Agent Template → template opens correctly
  • Create a new project from Tutorial → template opens correctly
  • Create a blank project → still works as before

When creating a project from templates (AI Agent, MCP AI Agent, or tutorials),
clicking 'Create' would close the modal but return to the welcome screen instead
of opening the template project.

Root cause: useNewProjectFromTemplate hook was missing updates to openedProjectsState
and openedProjectsSortedIdsState. While it set the project data correctly, the app
thought no projects were open (openedProjectIds.length === 0), so it continued
displaying the NoProject welcome screen.

Fix: Add the same opened projects state management that useNewProject has:
- Import and use openedProjectsState and openedProjectsSortedIdsState
- Update opened projects registry with the new template project
- Append new project ID to sorted IDs list

This ensures template projects are properly tracked as opened and displayed.
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.

1 participant