Skip to content

fix windows directory adding etc#43

Merged
SuperComboGamer merged 2 commits intoremoving-electron-features-build-apifrom
fs/ui
Dec 12, 2025
Merged

fix windows directory adding etc#43
SuperComboGamer merged 2 commits intoremoving-electron-features-build-apifrom
fs/ui

Conversation

@SuperComboGamer
Copy link
Collaborator

No description provided.

- Introduced a new FileBrowserProvider to manage file browsing state and functionality.
- Added FileBrowserDialog component for user interface to navigate and select directories.
- Updated Home component to utilize the file browser context and provide global access.
- Enhanced HttpApiClient to use the new file browser for directory and file selection.
- Implemented server-side route for browsing directories, including drive detection on Windows.
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @SuperComboGamer, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the user experience for selecting directories and files by replacing the rudimentary prompt-based input with a fully interactive file browser dialog. This change involves both frontend and backend development, including new React components, a dedicated context for managing the browser's state, and a server-side API endpoint capable of listing file system contents and handling platform-specific features like Windows drives. The overall impact is a more intuitive and robust method for users to specify file paths within the application.

Highlights

  • Interactive File Browser: Introduced a new, interactive file browser dialog component, replacing the previous basic prompt-based input for directory and file selection.
  • File Browser Context: Implemented a React context (FileBrowserProvider) to manage the state and functionality of the file browser, allowing components to easily open and receive selections from it.
  • Backend API for File System Browsing: Added a new POST endpoint /api/fs/browse to the server, which handles listing directories, navigating to parent directories, and detecting available drives on Windows systems.
  • Integration with HttpApiClient: Updated the HttpApiClient to use the new interactive file browser for openDirectory and openFile operations, enhancing the user experience for path selection.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new file browser dialog to replace the native prompt for selecting directories, which is a significant improvement for user experience. The implementation is well-structured, using a new React context, a dialog component, and a backend endpoint. However, I've identified a critical security vulnerability in the new backend endpoint that allows for path traversal, which must be addressed. I've also included a recommendation to improve React hooks usage for better code maintainability.

Comment on lines +51 to +87
const browseDirectory = async (dirPath?: string) => {
setLoading(true);
setError("");

try {
// Get server URL from environment or default
const serverUrl = process.env.NEXT_PUBLIC_SERVER_URL || "http://localhost:3008";

const response = await fetch(`${serverUrl}/api/fs/browse`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ dirPath }),
});

const result: BrowseResult = await response.json();

if (result.success) {
setCurrentPath(result.currentPath);
setParentPath(result.parentPath);
setDirectories(result.directories);
setDrives(result.drives || []);
} else {
setError(result.error || "Failed to browse directory");
}
} catch (err) {
setError(err instanceof Error ? err.message : "Failed to load directories");
} finally {
setLoading(false);
}
};

// Load home directory on mount
useEffect(() => {
if (open && !currentPath) {
browseDirectory();
}
}, [open]);
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The browseDirectory function is redefined on every render, and the useEffect hook at line 83 has an incomplete dependency array. This violates React hooks rules and can lead to subtle bugs or stale closures if the component is refactored in the future.

To adhere to best practices, you should wrap browseDirectory in useCallback to memoize it, and provide a complete dependency array to the useEffect hook.

  const browseDirectory = useCallback(async (dirPath?: string) => {
    setLoading(true);
    setError("");

    try {
      // Get server URL from environment or default
      const serverUrl = process.env.NEXT_PUBLIC_SERVER_URL || "http://localhost:3008";

      const response = await fetch(`${serverUrl}/api/fs/browse`, {
        method: "POST",
        headers: { "Content-Type": "application/json" },
        body: JSON.stringify({ dirPath }),
      });

      const result: BrowseResult = await response.json();

      if (result.success) {
        setCurrentPath(result.currentPath);
        setParentPath(result.parentPath);
        setDirectories(result.directories);
        setDrives(result.drives || []);
      } else {
        setError(result.error || "Failed to browse directory");
      }
    } catch (err) {
      setError(err instanceof Error ? err.message : "Failed to load directories");
    } finally {
      setLoading(false);
    }
  }, []);

  // Load home directory on mount
  useEffect(() => {
    if (open && !currentPath) {
      browseDirectory();
    }
  }, [open, currentPath, browseDirectory]);

@SuperComboGamer SuperComboGamer merged commit 5873e88 into removing-electron-features-build-api Dec 12, 2025
@SuperComboGamer SuperComboGamer deleted the fs/ui branch December 12, 2025 22:40
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.

3 participants