Skip to content

feat(client): deleting a file in code editor leaves the file structu… #1159

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 4 commits into from
May 30, 2025

Conversation

AJMADHAB
Copy link
Contributor

Description

Deleting a file in Code editor should leave the file structure open.

Changes Made

1.Modified FileExplorer.tsx
2.Modified FileExplorerPanel.tsx

How to Test

  1. Go to Apps -> open any App -> click edit -> delete any file you want
  2. Expected outcomes:
    The file structure will remain open after deleting a file.

Notes

…e open
@AJMADHAB AJMADHAB self-assigned this May 16, 2025
@AJMADHAB AJMADHAB requested a review from a team as a code owner May 16, 2025 06:20
@AJMADHAB AJMADHAB linked an issue May 16, 2025 that may be closed by this pull request
Copy link

@CodiumAI-Agent /describe

@CodiumAI-Agent
Copy link

Title

feat(client): deleting a file in code editor leaves the file structu…


User description

Description

Deleting a file in Code editor should leave the file structure open.

Changes Made

1.Modified FileExplorer.tsx
2.Modified FileExplorerPanel.tsx

How to Test

  1. Go to Apps -> open any App -> click edit -> delete any file you want
  2. Expected outcomes:
    The file structure will remain open after deleting a file.

Notes


PR Type

Enhancement


Description

  • Add controlled expansion props for FileExplorer

  • Remove internal expanded state hook

  • Handle toggle events in parent panel

  • Maintain expandedPaths in FileExplorerPanel


Changes walkthrough 📝

Relevant files
Enhancement
FileExplorer.tsx
Externalize FileExplorer expansion state                                 

packages/client/src/components/common/File/FileExplorer.tsx

  • Introduce expandedPaths and onToggleExpand props
  • Remove internal expanded state management
  • Bind expandedPaths to TreeView expanded prop
  • Call onToggleExpand on node toggle event
  • +14/-9   
    FileExplorerPanel.tsx
    Manage file tree expansion in panel                                           

    packages/client/src/components/workspace/panels/FileExplorerPanel.tsx

  • Add expandedPaths state hook in panel
  • Implement handleToggleExpand toggle function
  • Pass expandedPaths and onToggleExpand to FileExplorer
  • +10/-1   

    Need help?
  • Type /help how to ... in the comments thread for any questions about PR-Agent usage.
  • Check out the documentation for more information.
  • Copy link

    @CodiumAI-Agent /review

    @CodiumAI-Agent
    Copy link

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Prop Type Mismatch

    The expanded prop passed to FileExplorerItem receives the entire expandedPaths array instead of a boolean indicating whether the item is expanded. This could lead to unexpected rendering or runtime errors.

    <FileExplorerItem
        key={n.path}
        type={type}
        space={space}
        name={n.name}
        path={n.path}
        isDirectory={n.type === 'directory'}
        lastModified={n.lastModified}
        expanded={expandedPaths}
    Toggle Logic

    The logic inside onNodeToggle only identifies a single toggled node and may not handle simultaneous expansion or collapse of multiple nodes correctly. Ensure multi-node toggles behave as expected.

    onNodeToggle={(e, nodeIds) => {
        const lastToggled =
            nodeIds.find((id) => !expandedPaths.includes(id)) ||
            expandedPaths.find((id) => !nodeIds.includes(id));
        if (lastToggled) {
            onToggleExpand(lastToggled);
        }
    }}

    Copy link

    @CodiumAI-Agent /improve

    @CodiumAI-Agent
    Copy link

    PR Code Suggestions ✨

    CategorySuggestion                                                                                                                                    Impact
    General
    Remove unused commented code

    Remove the commented-out local state since expansion is now fully controlled by
    props. This cleans up dead code and prevents confusion.

    packages/client/src/components/common/File/FileExplorer.tsx [78]

    -//const [expanded, setExpanded] = React.useState<string[]>([]);
     
    +
    Suggestion importance[1-10]: 3

    __

    Why: Removing the commented-out expanded state is a minor cleanup that improves readability and removes dead code.

    Low

    AJMADHAB and others added 2 commits May 16, 2025 12:27

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    @johbaxter johbaxter merged commit f3bb88f into dev May 30, 2025
    3 checks passed
    @johbaxter johbaxter deleted the 893-deleting-a-file branch May 30, 2025 16:40
    Copy link

    @CodiumAI-Agent /update_changelog

    @CodiumAI-Agent
    Copy link

    Changelog updates: 🔄

    2025-05-30 *

    Changed

    • Keep file tree expanded after deleting a file in the code editor

    to commit the new content to the CHANGELOG.md file, please type:
    '/update_changelog --pr_update_changelog.push_changelog_changes=true'

    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.

    Deleting a file in Code editor should leave the file structure open
    5 participants