Skip to content

feat: IDE layout#62

Merged
sergioramos merged 26 commits into
mainfrom
1-vscode-layout
Jun 2, 2023
Merged

feat: IDE layout#62
sergioramos merged 26 commits into
mainfrom
1-vscode-layout

Conversation

@cguedes

@cguedes cguedes commented May 30, 2023

Copy link
Copy Markdown
Collaborator

This PR closes #1, and closes #44, by adding the following features:

  • Side panels for file browsing, references browsing and AI interactions (on the right)
  • Central panel for document edit and view with tabs and side-panel (support for two: LEFT and RIGHT)
  • New dependency with visual studio icons (and others if we need them)

Implementation details

  • App state - using Jotai

    • openFilesAtom - The main (read-write) state for the open files (overall and per pane)
    • leftPaneAtom - Read-only atom with the left pane files (and active file)
    • rightPaneAtom - Read-only atom with the right pane files (and active file)
    • write-only atoms (actions)
      • openFileInPaneAtom - that will open a file in a given tab
      • activateFileInPaneAtom - that will activate a file open in a tab (selected in the explorer or in the tabs)
      • closeFileInPaneAtom - that will close a file in a tab
      • splitFileToPaneAtom - that will move a file between two tabs (UI via explorer -> open files)
  • react-icons library with vs code icons

  • Updated terminology: view -> panel

    • The main UI components used by the App
    • ExplorerPanel - contains the open files and project tree
    • ReferencesPanel - contains the uploaded references
    • AIPanel - contains the AI interactions
    • CenterPanel - contains the split view (LEFT, RIGHT) with two tabled areas with file-rendered-view components
  • View components (used by the CenterPanel - component that renders in the central area with open files

    • EmptyView - view (splash screen) for when no file is selected
    • TextView - generic view that displays text content (used for .xml and .json files)
    • PdfViewer - PDF presenter (for .pdf files)
    • TipTapView - the TipTap editor (used for any other file not listed above)
  • Reusable UI components (/components)

    • GOAL: Split UI from the business logic and start a component library (related to [Discussion] Component libraries #3)
    • PanelSection - This is a panel section with a title and a collapsible, and scrollable, content
    • PanelWrapper - This is a side panel with multiple PanelSection components, and a title
    • TabPane - This is a x-scrollable list of tabs with an x (close) icon/action. Used for the open files tab.
    • PrimarySideBar - Not actually reusable (maybe will be used for the right side also) but a UI component

IDE Panels

  • Left

    • Explorer

      • "Open Files" section
      • "Project files" section
      • both sections render a tree of files/folders
    • References

  • Right

    • AI
      • "Selection" section - existing code for selected text and interaction with the sidecar
image
Empty Center Center Tabs
image image

@cguedes cguedes requested a review from sehyod May 30, 2023 14:39
@hammer

hammer commented May 31, 2023

Copy link
Copy Markdown
Contributor

This looks very cool! It doesn't have to be in this PR, but it would be nice to make the left and right sidebars collapsible. I also think it could be useful to have the writing and reading tabs all part of the same component rather than having them separated right now, though I could be convinced otherwise. Overall though I think this is looking good!

Another small nit: the toolbar in the TipTap component does not behave well when the window size is small. Below you can see the strikethrough symbol exceeding the shaded area. We don't need to nail all of these small issues while getting the high-level layout solved, but just wanted to mention it now so that we get to it at some point.

Screenshot 2023-05-31 at 10 03 18 AM

Comment thread src/atoms/openFilesState.ts Outdated
Comment thread src/atoms/openFilesState.ts Outdated
Comment thread src/atoms/openFilesState.ts Outdated
Comment thread src/panels/ExplorerPanel.tsx Outdated
@cguedes cguedes marked this pull request as ready for review June 1, 2023 13:38
@cguedes

cguedes commented Jun 1, 2023

Copy link
Copy Markdown
Collaborator Author

Another small nit: the toolbar in the TipTap component does not behave well when the window size is small. Below you can see the strikethrough symbol exceeding the shaded area. We don't need to nail all of these small issues while getting the high-level layout solved, but just wanted to mention it now so that we get to it at some point.

@hammer fixed this and improved (I think 😅) the UX of this component.

image
image

@cguedes

cguedes commented Jun 1, 2023

Copy link
Copy Markdown
Collaborator Author

This looks very cool! It doesn't have to be in this PR, but it would be nice to make the left and right sidebars collapsible. I also think it could be useful to have the writing and reading tabs all part of the same component rather than having them separated right now, though I could be convinced otherwise. Overall though I think this is looking good!

Created a ticket for this feature #68

sehyod
sehyod previously approved these changes Jun 1, 2023
@cguedes cguedes requested a review from danvk June 1, 2023 13:46

@danvk danvk left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Left a bunch of comments. I really like the VS Code look!

I think there are a few high level things that we should hash out:

  • We should pick a system for doing async calls in React before our application gets too big. React has <Suspense> built in but there are also many other tools out there like react-query. Basically, calling an async function in a useEffect is extremely error-prone and something that should be avoided.
  • The way we're using Jotai in this PR feels like it's mostly acting as a wrapper around how you'd do everything with Redux. I think we'll get more value from Jotai if we have several atoms rather than just one big one.

Comment thread src/atoms/openFilesState.ts Outdated
Comment thread src/atoms/openFilesState.ts Outdated
Comment thread src/atoms/openFilesState.ts Outdated
Comment thread src/atoms/openFilesState.ts Outdated
return {
...state,
panes: {
...state.panes,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

There is a Jotai Immer integration which could cut down on all this object spreading: https://jotai.org/docs/integrations/immer

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Will try that integration. Was trying to keep the code as clean of external dependencies as possible. But I understand that this type of code is harder to maintain and read.

Comment thread src/panels/ExplorerPanel.tsx Outdated
Comment thread src/panels/ExplorerPanel.tsx Outdated
Comment thread src/Components/PanelSection.tsx Outdated
Comment thread src/Components/TabPane.tsx
Comment thread src/PdfViewer/index.tsx
@danvk

danvk commented Jun 1, 2023

Copy link
Copy Markdown
Collaborator

Oh, and a UI nit I'm noticing while developing locally: I'm getting a ton of empty scrollbars that I don't see in your screenshot:
image

@danvk

danvk commented Jun 1, 2023

Copy link
Copy Markdown
Collaborator

Here's what it might look like to roll our own hook to safely wrap Promises (there's a little bit of diff noise due to the capital/lowercase C thing): 35aab1b

  • Pros: Forces you to model loading, error and success states as mutually exclusive options and handle all of them. Handles set-after-unmount errors for you.
  • Cons: Sometimes you don't want to think about loading/error states. Forces wrapping of async functions in React.useCallback.

@hammer

hammer commented Jun 2, 2023

Copy link
Copy Markdown
Contributor

The way we're using Jotai in this PR feels like it's mostly acting as a wrapper around how you'd do everything with Redux.

if Redux patterns are more comfortable to the team perhaps we should use Zustand?

@cguedes

cguedes commented Jun 2, 2023

Copy link
Copy Markdown
Collaborator Author

Oh, and a UI nit I'm noticing while developing locally: I'm getting a ton of empty scrollbars that I don't see in your screenshot:

@danvk were are you testing? I'm in OSX with safari (Tauri's browser).

@cguedes

cguedes commented Jun 2, 2023

Copy link
Copy Markdown
Collaborator Author

if Redux patterns are more comfortable to the team perhaps we should use Zustand?

We would keep Jotai for this PR so that we can merge and move forward with the project.
But I think that worth spending some time investigating (in a new PR) how Zustand would work in our project as we have more state.

@cguedes

cguedes commented Jun 2, 2023

Copy link
Copy Markdown
Collaborator Author

@sehyod can you review this again.

@cguedes cguedes requested a review from sehyod June 2, 2023 13:31
@cguedes

cguedes commented Jun 2, 2023

Copy link
Copy Markdown
Collaborator Author

Oh, and a UI nit I'm noticing while developing locally: I'm getting a ton of empty scrollbars that I don't see in your screenshot: image

I was able to reproduce that by configuring the system to always display scrollbars.

image

Now it loos like this:

No scroll Scroll
image image

sehyod
sehyod previously approved these changes Jun 2, 2023
Comment thread src/Components/FileTree.tsx
Comment thread src/filesystem.tsx Outdated
@sergioramos sergioramos merged commit 5729640 into main Jun 2, 2023
@sergioramos sergioramos deleted the 1-vscode-layout branch June 2, 2023 15:05
@cguedes cguedes mentioned this pull request Jun 2, 2023
sergioramos pushed a commit that referenced this pull request Jun 2, 2023
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.

[Discussion] Icons library Design high-level layout of writing, references, and AI interactions components

5 participants