Skip to content

webui: Initialize root directory on file lister mount #1780

@junhaoliao

Description

@junhaoliao

Request

Note

This feature builds on top of the file listing UI added in #1292

Currently, the PathsSelectFormItem component does not automatically load the root directory's children when the component mounts. Users must manually click on the root "/" node to see its contents. This adds an unnecessary extra step to the user workflow.

Why it's important:

  • Most, if not all, users would not want to compress everything from the "/" directory - Reduces clicks needed to start browsing the file tree
  • Improves initial user experience by showing available top-level directories immediately
  • Makes the interface feel more responsive and ready-to-use
  • Aligns with common file browser UX patterns where the initial view shows the root contents

Possible implementation

Add a useEffect hook that runs on component mount to load the root directory:

useEffect(() => {
    const initializeTree = async () => {
        setIsLoading(true);
        try {
            await loadPath(ROOT);
        } catch (e) {
            console.error("Failed to load root directory:", e);
            message.error(e instanceof Error ?
                e.message :
                "Failed to load root directory");
        } finally {
            setIsLoading(false);
        }
    };

    initializeTree();
}, [loadPath]);

Considerations

  • May slightly increase initial load time if root directory is large, for whatever reason
  • Should show loading state during initialization
  • Error handling should be graceful to not block the entire component

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions