Skip to content

adding files and folders as well as right-click with firebase integration#200

Open
meher0704 wants to merge 12 commits into
cpinitiative:mainfrom
meher0704:main
Open

adding files and folders as well as right-click with firebase integration#200
meher0704 wants to merge 12 commits into
cpinitiative:mainfrom
meher0704:main

Conversation

@meher0704
Copy link
Copy Markdown

@meher0704 meher0704 commented Jun 10, 2025

the files and folder look like
Screenshot 2025-06-09 at 5 34 49 PM
and the file structure looks like
Screenshot 2025-06-09 at 5 35 16 PM


Open with Devin

@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 10, 2025

@MeherKhurana is attempting to deploy a commit to the CP Initiative Team on Vercel.

A member of the Team first needs to authorize it.

@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 10, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
ide-svelte ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 13, 2025 6:02pm

Copy link
Copy Markdown
Member

@thecodingwizard thecodingwizard left a comment

Choose a reason for hiding this comment

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

nice! some initial notes:

  • it would be great if we could keep the IDE project as simple as possible, even if that means removing features. we don't have a large engineering team, and maintaining a large codebase is challenging. Specifically, do you think file tags are useful / what was the motivation behind adding them?
  • The IDE is supposed to be mobile-friendly. Not sure how context menus will interact with that; maybe a button to open a dropdown would be better?
    CleanShot 2025-06-09 at 18 26 14@2x
  • Permanently deleting files seems scary (and our backend server doesn't support this anyway), what if we just renamed "hide / unhide" to "delete / restore" and have a "recently deleted" page?
  • When creating a new file, you also need to specify things like "visibility" / "compiler options" / etc, so I'm not sure if the "right click to make a new file" thing really makes sense -- would it be better to just have the "new file" button make a new file in the current active folder or something?
  • Do you think it makes more sense to have the "back" button inside the file explorer or outside?
    CleanShot 2025-06-09 at 18 32 14@2x

@meher0704
Copy link
Copy Markdown
Author

meher0704 commented Jun 10, 2025

Code Organization & File Management Updates
Why This Matters
The current layout is difficult to navigate — everything is packed into a single file, making it hard to locate or modify specific sections. To improve maintainability and the overall user experience, restructuring is necessary.

Current Issues
Screenshot for Reference:

Screenshot showing current file management clutter Screenshot showing current file management clutter
The interface feels cluttered and overwhelming
  • Difficult to find specific logic or UI components
  • File creation feels unintuitive
  • No safe way to delete files temporarily

Planned Improvements

  • i will split each ui update into a file and combine them in dashboard so that there is less code to look at
  1. Folders
  • Inspired by the Finder and Files apps on Apple devices
  • Allows grouping and collapsing for better structure
  • Improves clarity and reduces visual noise
  1. Recently Deleted
  • Adds a temporary storage area for deleted files
  • Prevents accidental permanent deletion
  • Enables users to clean up the UI without losing data
  1. Improved File Creation Flow
  • Replace or remove the current right-click creation method
  • Introduce a dedicated creation page or modal
  • Makes file addition more predictable and user-friendly
  1. Navigation Enhancements
  • Add a consistent back button outside the explorer
  • Improve page and component transitions
  • Ensure logical and smooth navigation
  • planning to add a search feature as a lot of files are created

Collaboration Features

  • Shared Workspaces - Team folders or shared projects
  • Activity Feed - See what teammates are working on
  • Comments/Notes - Add notes to projects
  • Version History - See previous versions of projects

Mobile Experience

  • An upcoming update will significantly improve mobile responsiveness.
  • Current limitations on small screens include layout issues and touch-unfriendly elements.
  • The new design will prioritize usability and reduce clutter for mobile users.
  • planning to take some inspiration from apple files on iphone as that is the best design I have seen

@thecodingwizard
Copy link
Copy Markdown
Member

I think I agree that we should have some form of a file explorer. To clarify my question above, I was wondering while file tags in particular are needed.

Introduce a dedicated creation page or modal

We already have a dedicated creation page: https://ide.usaco.guide/new

I have a slight preference against a model.

Improve page and component transitions

Personally I think what you have now is fine, but up to you (as long as it doesn't make the code too complicated)

planning to add a search feature as a lot of files are created

If we are going to do this, can we do this in a separate PR?

Collaboration Features

Maybe let's talk before you implement these -- in particular, I want to make sure these features are actually needed & won't over-complicate the IDE.


thanks again for working on this!

Comment thread src/lib/types.ts
* Stored in /users/{uid}/files/{fileID} in Firebase.
*/
export type UserFile = {
type: string;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What is "type"?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

it determines if the user is storing is a file or a folder

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

got it. what do you think about storing them separately: /users/{uid}/files/{fileID} and /users/{uid}/folders/{folderID}? or even /users/{uid}/files/folders/{folderID} if you prefer.

That way we can type them differently. In particular, some fields of files are not relevant for folders, like "language."

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

well storing separately will make the code significantly more complicated;
i would suggest

export type File = {
kind: "file";
id: string;
name: string;
language?: string;
// File-specific fields
};

export type Folder = {
kind: "folder";
id: string;
name: string;
// Folder-specific fields
};

export type UserItem = File | Folder;

using a discriminated union

so that it doesn't become as complex and still is one file

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

sure, I'm ok with that!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@meher0704 does this still need to be updated?

Comment thread src/routes/(index)/components/Dashboard.svelte Outdated
@meher0704
Copy link
Copy Markdown
Author

For the collaboration i will work on it in a separate pr and for now in this pr

  1. Add a button for add folder at the top
  2. Change the format for mobile devices
  3. Remove size and tags
  4. Add the actions (in the ss) which will have all of these features
  5. Remove the pfp loading and put a default person
  6. Fix the file name saving issue
  7. Add the recently deleted and restore feature
  8. Add the programming language
  9. Move the back button if needed i think that it is good currently
  10. Work on the selecting files and entering files;
    image

@thecodingwizard
Copy link
Copy Markdown
Member

thecodingwizard commented Jun 10, 2025

Sounds good, please double check with me before you implement the collaboration features -- in particular, I'm not yet convinced we need them:

Shared Workspaces - Team folders or shared projects

We already have shared files, I'm not really sure if shared folders are that important? I also think it's pretty tricky to give folders permissions; then you have to worry about how file permissions and folder permissions interact with each other. Maybe there are more impactful things to do first like #201 ?

Activity Feed - See what teammates are working on

Similar sentiment to above -- I'm not sure if the effort of implementing this is worth the benefits

Comments/Notes - Add notes to projects

We have a "scribble" pane already that seems to do this?

Version History - See previous versions of projects

This seems useful. Note that vscode has a "timeline" feature that we could maybe try to build off of, or maybe we can modify our IDE YJS server to track version history, I'm not really sure.

@meher0704
Copy link
Copy Markdown
Author

ok i will finish this then work on #201

@meher0704
Copy link
Copy Markdown
Author

image
is this good for phones

@thecodingwizard
Copy link
Copy Markdown
Member

thecodingwizard commented Jun 11, 2025

Seems fine, though personally I might prefer a three-dot dropdown menu on the right with options to rename or delete -- that feels less cluttered than having icons for deleting / renaming each file, since most users won't be looking to do that action.

Also, I'm not sure if the "1 item selected" thing is necessary (even though it's super cool!). In particular, when someone clicks a file on mobile, they probably want to open that file for editing, not select it. Bulk file renaming doesn't really make sense and bulk file deleting probably isn't that important.

Maybe we can look at the google drive app for inspiration?

@meher0704
Copy link
Copy Markdown
Author

meher0704 commented Jun 11, 2025

i fixed it by just making the tap better so its rrly easy to open on both mobile and desktop; i tried both and determine that this was significantly easier to use; it simplifies the layout

@meher0704
Copy link
Copy Markdown
Author

i think this is done. should i add anything?

Copy link
Copy Markdown
Member

@thecodingwizard thecodingwizard left a comment

Choose a reason for hiding this comment

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

Incredible! Some small nits below; feel free to disagree with these suggestions :)

  • No need for x-axis padding in the file manager -- it should be flush with "Real-time Collaborative Online IDE"
    CleanShot 2025-06-12 at 14 22 38@2x

  • I think it's strange to have two things that can scroll, the file manager and the website as a whole. Maybe the file manager can just be as tall as needed?

  • Rather than having Py / C++ / etc next to date modified, maybe we can change the icon on the left hand side to either be Python, C++, Java, or a folder?

  • When the three dots dropdown opens, I don't think it's necessary to blur the rest of the page. It feels a bit excessive to me.

  • The New Folder & Recently Deleted icons can probably be de-emphasized (maybe they can be styled similarly to the "Back" button?)

  • I think the right click for context menu is cool, but since there's already a New Folder button, I feel like i'd rather not have the right click for context menu so there's less code we have to maintain.

  • At some screen sizes, the wrapping is a little strange
    CleanShot 2025-06-12 at 14 26 34@2x

  • The "no files or folders" screen should probably be centered in the panel, currently it looks like there's more padding at the bottom than at the top

Overall incredible work!

@meher0704
Copy link
Copy Markdown
Author

meher0704 commented Jun 13, 2025

pushed those updates; as you add files the file manager will extend; there is only one scroll

@thecodingwizard
Copy link
Copy Markdown
Member

For consistency can we use https://www.melt-ui.com/docs/builders/dropdown-menu to handle the three dots dropdown menu instead of capturing the x / y position ourselves? We use Melt UI for the navbar file dropdown menu already.

Also, looks like there's some old code related to the context menu that can probably be removed?

@meher0704
Copy link
Copy Markdown
Author

pushed those updates and removed unused code

@meher0704
Copy link
Copy Markdown
Author

should i add anything else ?

@meher0704 meher0704 closed this Jun 15, 2025
@thecodingwizard
Copy link
Copy Markdown
Member

wait why close?

@meher0704 meher0704 reopened this Jun 15, 2025
@meher0704
Copy link
Copy Markdown
Author

meher0704 commented Jun 15, 2025

i acc closed mb
accidentally pressed close with comment lol

@meher0704
Copy link
Copy Markdown
Author

im not sure about the python logo its kind of grainy; should i replace it

@thecodingwizard
Copy link
Copy Markdown
Member

hmm maybe if there's another one you think is better. will defer to you :)

@meher0704
Copy link
Copy Markdown
Author

i think it is done now ? i finished debugging and didn't find any issues

@xyzqm
Copy link
Copy Markdown
Member

xyzqm commented Jul 26, 2025

@thecodingwizard is this good to merge?

Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 3 potential issues.

View issues and 5 additional flags in Devin Review.

Open in Devin Review

Comment on lines +182 to +188
const handleDropAction = async (draggedItem: FileItem, targetFolder: FileItem) => {
if (targetFolder.type === 'folder' && draggedItem.id !== targetFolder.id) {
await update(ref(database, `users/${firebaseUser.uid}/files/${draggedItem.id}`), {
parentFolder: targetFolder.id
});
}
};
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔴 Drag-and-drop allows creating circular folder references

When dragging a folder into another folder, handleDropAction only checks that the dragged item is not the same as the target folder (draggedItem.id !== targetFolder.id), but does not check if the target folder is a descendant of the dragged folder.

Click to expand

Mechanism

In Dashboard.svelte:182-188, the handleDropAction function allows moving any folder into any other folder:

const handleDropAction = async (draggedItem: FileItem, targetFolder: FileItem) => {
    if (targetFolder.type === 'folder' && draggedItem.id !== targetFolder.id) {
        await update(ref(database, `users/${firebaseUser.uid}/files/${draggedItem.id}`), {
            parentFolder: targetFolder.id
        });
    }
};

Impact

If a user drags folder A into folder B (which is inside folder A), this creates a circular reference. The goBack function at line 196-205 relies on finding the parent folder, and filesToShow at line 86-92 filters by parentFolder. A circular reference would make both folders and all their contents inaccessible through normal navigation.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Comment on lines +118 to +124
const moveToTrash = async (item: FileItem) => {
await update(ref(database, `users/${firebaseUser.uid}/files/${item.id}`), {
isDeleted: true,
deletedAt: Date.now()
});
open.set(false);
};
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔴 Moving folder to trash orphans all files inside the folder

When a folder is moved to trash, files inside the folder are not recursively marked as deleted, causing them to become inaccessible.

Click to expand

Mechanism

The moveToTrash function at Dashboard.svelte:118-124 only marks the single item as deleted:

const moveToTrash = async (item: FileItem) => {
    await update(ref(database, `users/${firebaseUser.uid}/files/${item.id}`), {
        isDeleted: true,
        deletedAt: Date.now()
    });
};

The filesToShow derived at line 86-92 filters files by:

  • file.parentFolder === currentFolder && !file.isDeleted for normal view
  • file.isDeleted for recently deleted view

Actual vs Expected

  • Actual: When folder X is deleted, files inside X are NOT marked as deleted. They won't appear in "Recently Deleted" (because isDeleted is false), and they won't appear in normal view (because their parentFolder points to a deleted folder).
  • Expected: Child files should either be recursively marked as deleted, or the view logic should account for files whose parent folders are deleted.

Impact

Files inside deleted folders become permanently orphaned and inaccessible to the user.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Comment on lines +126 to +132
const restoreItem = async (item: FileItem) => {
await update(ref(database, `users/${firebaseUser.uid}/files/${item.id}`), {
isDeleted: false,
deletedAt: null
});
open.set(false);
};
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔴 Restoring file may leave it orphaned if parent folder is still deleted

When restoring a file from trash, the code doesn't verify that the file's parentFolder still exists or isn't itself deleted.

Click to expand

Mechanism

The restoreItem function at Dashboard.svelte:126-132 simply sets isDeleted: false:

const restoreItem = async (item: FileItem) => {
    await update(ref(database, `users/${firebaseUser.uid}/files/${item.id}`), {
        isDeleted: false,
        deletedAt: null
    });
};

If a file was in a folder that was also deleted, restoring the file keeps its original parentFolder reference. But since filesToShow (line 91) filters by file.parentFolder === currentFolder && !file.isDeleted, the restored file won't appear anywhere if its parent folder is still in trash.

Impact

Restored files may remain inaccessible if their parent folder hasn't been restored first, leading to user confusion and apparent data loss.

Recommendation: When restoring a file, check if its parentFolder is deleted. If so, either restore the parent folder chain, or reset parentFolder to null to place the file in the root directory.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

@ArjunGitDev
Copy link
Copy Markdown

is there a link for this

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.

5 participants