Skip to content

Comments

feat: Clear file changes state when the task path changes and display…#862

Merged
arnestrickmann merged 3 commits intogeneralaction:mainfrom
prath47:fix-777
Feb 17, 2026
Merged

feat: Clear file changes state when the task path changes and display…#862
arnestrickmann merged 3 commits intogeneralaction:mainfrom
prath47:fix-777

Conversation

@prath47
Copy link
Contributor

@prath47 prath47 commented Feb 14, 2026

Fix: #777

This PR includes changes as per:

  1. Added Clear stale state after change in taskpath
  2. used isLoading variable from useFileChanges to show loader on changes tab

Check Performed

  1. Lint
  2. Format
  3. Build
  4. Manually verified the working of the changes done;

@vercel
Copy link

vercel bot commented Feb 14, 2026

@prath47 is attempting to deploy a commit to the General Action Team on Vercel.

A member of the Team first needs to authorize it.

@greptile-apps
Copy link

greptile-apps bot commented Feb 14, 2026

Greptile Overview

Greptile Summary

Fixed stale file changes displaying when switching between tasks by immediately clearing the file changes state when taskPath changes, and added a loading spinner to provide visual feedback during the data fetch.

  • Cleared stale fileChanges state immediately in useFileChanges hook when taskPath changes
  • Exposed isLoading from the hook and used it to display a centered spinner in FileChangesPanel when loading with no file changes yet
  • Improved UX by preventing brief flash of stale data from the previous task

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The changes are focused, well-tested by the author, and follow React best practices for state management. The immediate state clearing prevents a common UI bug (stale data flash), and the loading indicator improves UX. No side effects, security issues, or edge cases identified.
  • No files require special attention

Important Files Changed

Filename Overview
src/renderer/hooks/useFileChanges.ts Added immediate state clearing when taskPath changes to prevent showing stale file changes from the previous task
src/renderer/components/FileChangesPanel.tsx Destructured isLoading from useFileChanges hook and added loading spinner display when loading with no file changes

Flowchart

flowchart TD
    A[Task Path Changes] --> B[useEffect triggered in useFileChanges]
    B --> C[setFileChanges clears array]
    B --> D[taskPathRef.current = taskPath]
    B --> E[hasLoadedRef.current = false]
    
    C --> F[Component re-renders]
    D --> G[Second useEffect triggered]
    E --> G
    
    G --> H{taskPath && shouldPoll?}
    H -->|Yes| I[fetchFileChanges with isInitialLoad=true]
    H -->|No| J[clearIdleHandle and return]
    
    I --> K[setIsLoading true]
    I --> L[Call getCachedGitStatus]
    
    L --> M{Request successful?}
    M -->|Yes| N[setFileChanges with new data]
    M -->|No| O[setFileChanges with empty array]
    
    N --> P[setIsLoading false]
    O --> P
    
    F --> Q{isLoading && fileChanges.length === 0?}
    Q -->|Yes| R[Show Spinner]
    Q -->|No| S[Show file changes list]
    
    P --> T[Component updates with new state]
Loading

Last reviewed commit: 6c0d183

@prath47
Copy link
Contributor Author

prath47 commented Feb 15, 2026

@arnestrickmann Please help here

@arnestrickmann
Copy link
Contributor

Hi @prath47, thanks for opening this PR and for catching this issue!

One thing:
When testing locally I wasnt able to see the spinner.

Can you add a screen recording showing the spinner on task switch? Also, please add setIsLoading(true) in the same effect as the setFileChanges([]) clear — without it there's a blank frame before the spinner kicks in:

useEffect(() => {
setFileChanges([]);
setIsLoading(true);
taskPathRef.current = taskPath;
hasLoadedRef.current = false;
}, [taskPath]);

When this is fixed, happy to merge this

@prath47
Copy link
Contributor Author

prath47 commented Feb 17, 2026

@arnestrickmann I think

    if (taskPath) {
      setIsLoading(true);
    }

this would suit better than just adding setIsLoading(true);
it's safer to wrap it in a check for taskPath to ensure we don't get stuck in a loading state if taskPath is undefined (e.g., when no project is open).

@arnestrickmann
Copy link
Contributor

Sounds good

@arnestrickmann
Copy link
Contributor

thanks! @prath47

@arnestrickmann
Copy link
Contributor

tested, lgtm!

@arnestrickmann arnestrickmann merged commit 89b462c into generalaction:main Feb 17, 2026
1 of 2 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.

Changes view can show state from a different chat/task

2 participants