Skip to content

fix: Agent Folder state not cleared when creating a new project#1485

Merged
4pmtong merged 4 commits into
eigent-ai:mainfrom
dev-miro26:fix/agent-folder-state-not-reset-on-new-project
Mar 13, 2026
Merged

fix: Agent Folder state not cleared when creating a new project#1485
4pmtong merged 4 commits into
eigent-ai:mainfrom
dev-miro26:fix/agent-folder-state-not-reset-on-new-project

Conversation

@dev-miro26

@dev-miro26 dev-miro26 commented Mar 12, 2026

Copy link
Copy Markdown
Contributor

Related Issue

Closes #1481

Description

When a user finishes a task and clicks the "+" button to create a new project, the Agent Folder panel on the right side still displays the previous task's file (e.g., file name header still shows, clicking it opens the old file) even though the "Files" section appears empty.

Root cause: The Folder component maintains local React state (selectedFile, fileTree, fileGroups, expandedFolders) that was never cleared when activeTaskId changed. The new project correctly sets selectedFile: null in the chatStore, but the component's local state persisted the previous task's values.

Fix:

  1. Expanded the existing activeTaskId change useEffect to reset all local state (selectedFile, fileTree, fileGroups, expandedFolders), not just the hasFetchedRemote ref.
  2. Added an else clause in the selectedFile sync useEffect to clear the local selectedFile when the new task has no selected file in the store.

Testing Evidence (REQUIRED)

eigent-issue1481.mp4
  • I have included human-verified testing evidence in this PR.
  • This PR includes frontend/UI changes, and I attached screenshot(s) or screen recording(s).
  • No frontend/UI changes in this PR.

What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Contribution Guidelines Acknowledgement

@dev-miro26

Copy link
Copy Markdown
Contributor Author

Hi @4pmtong
Could you please review this PR?

@4pmtong

4pmtong commented Mar 12, 2026

Copy link
Copy Markdown
Collaborator

Thanks @dev-miro26 for contribution!

@dev-miro26

Copy link
Copy Markdown
Contributor Author

Thanks @dev-miro26 for contribution!

Thank you!
Could you please merge this PR?

@dev-miro26

Copy link
Copy Markdown
Contributor Author

Hi, @4pmtong
Could you merge my first PR?

@4pmtong 4pmtong merged commit b86ccd0 into eigent-ai:main Mar 13, 2026
7 checks passed
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.

[BUG] Previous Task Results Persist in Agent Folder When Creating a New Project

3 participants