Skip to content
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

feat: implement multi-file code editor - WF-100 #724

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from

Conversation

madeindjs
Copy link
Collaborator

@madeindjs madeindjs commented Jan 8, 2025

Implement the feature to allow the user to create, update and delete any source file of the application.

The logic flow is:

  1. Python backend returns the sourceFiles in the Init request. It's an object representing the tree structure like
    {"type": "directory", "children": {"README.md": {"type": "file", "content": "This app w", "complete": false}}}
  2. the frontend stores this and creates a copy of this as sourceFilesDraft
  3. different action in the editor will trigger new sockets events I implemented: createSourceFile, deleteSourceFile or renameSourceFile

The main challenge was the synchronization between sourceFiles and sourceFilesDraft. This main logic stands in the composable useSourceFilesDraft.

Quick demo

Screen.Recording.2025-01-14.at.15.30.27.mov

@madeindjs madeindjs self-assigned this Jan 8, 2025
@madeindjs madeindjs force-pushed the WF-100 branch 4 times, most recently from e615feb to 628a16e Compare January 14, 2025 10:35
@madeindjs madeindjs marked this pull request as ready for review January 14, 2025 15:17
@madeindjs madeindjs marked this pull request as draft January 15, 2025 14:51
@madeindjs madeindjs marked this pull request as ready for review January 16, 2025 08:21
@FabienArcellier
Copy link
Collaborator

I would advocate having a context menu to delete an item. With the current pattern, I can't remove a folder when I inadvertently create one : https://developer.mozilla.org/en-US/docs/Web/API/Element/contextmenu_event

image

@FabienArcellier
Copy link
Collaborator

I would advocate to bind CTRL+S when the user is inside the editor. It currently open the browser windows : https://codepen.io/ThatSoftwareDude/pen/poVQowE

@FabienArcellier
Copy link
Collaborator

FabienArcellier commented Jan 17, 2025

We lost ability to save a file when an error is raised changing the python code.

image

image

@FabienArcellier
Copy link
Collaborator

I rename and file in .wf directory. It has wrong behavior.

image

src/writer/app_runner.py Outdated Show resolved Hide resolved
src/writer/app_runner.py Outdated Show resolved Hide resolved
src/writer/app_runner.py Outdated Show resolved Hide resolved
@madeindjs
Copy link
Collaborator Author

madeindjs commented Jan 22, 2025

I would advocate having a context menu to delete an item. With the current pattern, I can't remove a folder when I inadvertently create one : https://developer.mozilla.org/en-US/docs/Web/API/Element/contextmenu_event

@FabienArcellier , what do you think about simply avoiding rendering empty folder?

So, if you create a file a/b/c.txt, it creates the folder a/b/, and when you remove c.txt, we don't display the folder in the UI.

The edge case is, when the user tries to create a file matching an empty folder path. In this situation, we can simply delete the empty folder before creating the file.

implemented in b30a952

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.

2 participants