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

Folders for conversation categorization, improving navigation and manageability. #296

Closed
wants to merge 28 commits into from

Conversation

joriskalz
Copy link
Contributor

This pull request introduces a new feature as requested in #162 that enhances the organization of conversations within our chat interface. By integrating a folder-based structure, users can now categorize and manage their conversations more efficiently, addressing the previous issue of having a single, overwhelming list of chats.

Key Features:

  • Folders for conversation categorization, improving navigation and manageability.
  • Default 'General' folder for uncategorized conversations.
  • Ability to create, rename, and delete folders with user-friendly UI interactions.
  • Conversations are displayed only for the selected folder, reducing DOM size and potential browser lag.
  • Utilization of Zustand for state management, ensuring a smooth and reactive user experience.

Technical Details:

  • ChatNavigationFolders.tsx component handles the folder UI, including folder creation, selection, and conversation listing within each folder.
  • store-folders.ts introduces Zustand store for folder state management, with actions for CRUD operations on folders.
  • Integration with existing chat components to ensure seamless functionality and minimal disruption to current features.

Please note that this is an initial ugly version and there are still rough edges present. The current UI does not fully match the sleekness of the mockups. I am seeking feedback on the functionality and would appreciate any suggestions for UI improvements to enhance the visual appeal and user experience.

Screenshot:
Bildschirmfoto 2023-12-22 um 16 44 37

Copy link

vercel bot commented Dec 22, 2023

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

Name Status Preview Updated (UTC)
big-agi ✅ Ready (Inspect) Visit Preview Dec 26, 2023 11:59pm

@enricoros
Copy link
Owner

Hi @joriskalz - I'm testing it now - let me know when you're out of Draft and want to merge it. I'll do careful merging and a cosmetic pass (as I always do :). In the meantime: this is REALLY impressive - large in scope and the code (esp. hooks) are good.

A couple of questions:

  • common/state/FolderStore: I am leaning towards the folder structure being a "chat" application state. I haven't yet figured out whether the conversations themselves shall be global state or contained within the /app/chat folder. Very soon I want to scale horizontally big-AGI and add more Apps (Call is already an example, but imagine a Knowledge base, more tools, etc.).
  • (hook) useConversationsByFolder: this will be very expensive as it's triggered (and updates the React component) every time anything happens in any conversation. Suggest to reduce the selected state and use the shallow comparison
  • when chats are deleted, do they disappear in the folder structure as well?
  • I'll soon start to improve the layout (AppLayout / AppChat) to have a left-side chats pane (collapsible) instead of the menu (it's the test-drawer branch); this should give you more space on both Desktop and Mobile and the changes will be more visible

For other notes, I'll wait until you have reviewed, tightened up, and submitted :)

…ersations based on selected folder filter.

# Aider chat conversation:

USER: in ChatDrawerItems.tsx in the menu item props.onConversationsDeleteAll is called to delete all conversations. It finally calls wipeAllConversations. However with the new Folder filter (const conversations = useConversationsByFolder(selectedFolderId)) it shows the exact number (Delete {totalConversations >= 2 ? `all ${totalConversations} chats` : 'chat'}), but in the delete function it does not take care about the selected filter. Please change it to only delete the one based on the selectedFolderId.

ASSISTANT: To make this change, we need to modify `src/apps/chat/components/applayout/ChatDrawerItems.tsx` and `src/common/state/store-chats.ts`.

Here are the steps:

1. In `src/apps/chat/components/applayout/ChatDrawerItems.tsx`, we need to pass `selectedFolderId` to `onConversationsDeleteAll`.
2. In `src/common/state/store-chats.ts`, we need to modify `wipeAllConversations` to delete only the conversations in the selected folder.

Here are the *SEARCH/REPLACE* blocks:

src/apps/chat/components/applayout/ChatDrawerItems.tsx
```python
<<<<<<< SEARCH
    <MenuItem disabled={!hasChats} onClick={props.onConversationsDeleteAll}>
=======
    <MenuItem disabled={!hasChats} onClick={() => props.onConversationsDeleteAll(selectedFolderId)}>
>>>>>>> REPLACE
```

src/common/state/store-chats.ts
```python
<<<<<<< SEARCH
  wipeAllConversations: (personaId: SystemPurposeId | undefined): DConversationId => {
    const { conversations } = _get();

    // abort any pending requests on all conversations
    conversations.forEach(conversation => conversation.abortController?.abort());

    const conversation = createDConversation(personaId);

    _set({
      conversations: [conversation],
    });

    return conversation.id;
  },
=======
  wipeAllConversations: (personaId: SystemPurposeId | undefined, folderId: string | null): DConversationId => {
    let { conversations } = _get();

    // If a folder is selected, only delete conversations in that folder
    if (folderId) {
      const folderConversations = useFolderStore.getState().folders.find(folder => folder.id === folderId)?.conversationIds || [];
      conversations = conversations.filter(conversation => folderConversations.includes(conversation.id));
    }

    // abort any pending requests on all conversations
    conversations.forEach(conversation => conversation.abortController?.abort());

    const conversation = createDConversation(personaId);

    _set({
      conversations: folderId ? conversations : [conversation],
    });

    return conversation.id;
  },
>>>>>>> REPLACE
```

Please confirm these changes.
@joriskalz
Copy link
Contributor Author

joriskalz commented Dec 26, 2023

Hi @enricoros, thank you very much for your feedback. Here's an updated version with a more streamlined UI:

Screenshot:
Bildschirmfoto 2023-12-26 um 21 39 08

Video:
https://github.com/enricoros/big-AGI/assets/1590910/0359c298-9cbe-46fe-a2f8-73d8b7915d11

Regarding your questions, please find my responses inline:

  • common/state/FolderStore: I am leaning towards the folder structure being a "chat" application state. I haven't yet figured out whether the conversations themselves shall be global state or contained within the /app/chat folder. Very soon I want to scale horizontally big-AGI and add more Apps (Call is already an example, but imagine a Knowledge base, more tools, etc.).

I haven't formed an opinion yet, but yes, this should be carefully considered.

  • (hook) useConversationsByFolder: this will be very expensive as it's triggered (and updates the React component) every time anything happens in any conversation. Suggest to reduce the selected state and use the shallow comparison

If I'm observing this correctly, this function only executes during interaction with the Drawer. But yes, there's room for further optimization.

  • when chats are deleted, do they disappear in the folder structure as well?

Now they should.

  • I'll soon start to improve the layout (AppLayout / AppChat) to have a left-side chats pane (collapsible) instead of the menu (it's the test-drawer branch); this should give you more space on both Desktop and Mobile and the changes will be more visible

I really like this idea, and I think the new UX might fit in even better.

I also have some further issues for which I don't have good solutions yet:

  • In the AppBar, the directory icon isn't displayed when selected. I don't understand why AppBarDropdown.tsx isn't showing the FolderIcon.
  • "New Folder" still doesn't use an Inline Dialog.
  • Performance optimization is still necessary, and the code needs further cleaning and organizing.
  • The conversation filter dialog is not working, when typing it focus is lost and it jumps to the first conversation item.

I am eagerly looking forward to your thoughts, and feedback. Thank you very much for considering this pull request!

@joriskalz joriskalz marked this pull request as ready for review December 26, 2023 20:41
@enricoros
Copy link
Owner

enricoros commented Dec 26, 2023

Thanks @joriskalz - I'm very excited to work on merging this.

There are elements of beauty and much brilliance in this design. I'm a fan of how you implemented drag & drop. The default colors also look sweet.

One element I'll challenge you to think about is: how do we make the "dropdown" with the folder usable on mobile, where the screen space is so limited?

This is what I'm working on at this exact moment (branch feature-newi):
image

I'm ensuring you have a fully stable surface to list the chats on (the Popup Menu has limitations). See the red outlined elements in this mockup. On both desktop and mobile, we'll have full control over that plane, which also leads the way to renaming chats, auto-naming chats, etc.

I would love to have this done by the end of the day. I really need the surface & structure to add other root apps (call, draw, knowledge base, etc).

To your specific questions:

In the AppBar, the directory icon isn't displayed when selected. I don't understand why AppBarDropdown.tsx isn't showing the FolderIcon.

I will take a look at this when merging.

"New Folder" still doesn't use an Inline Dialog.

No problem, let's work on this once we have the full surface at our disposal. The likely solution is to have something like {isAddingFolder && <GoodModal> ...} with a text input inside. you can probably just show an <Input ../> element where the user will enter the name, and a button to confirm the insertion.

Performance optimization is still necessary, and the code needs further cleaning and organizing.

For sure, and please leave some of that to me as well; I recently learned to react hooks quite well and enjoy optimizing.

The conversation filter dialog is not working, when typing it focus is lost and it jumps to the first conversation item.

This is probably solved automatically by the new layouting I'm working on 👍

If you want, you can continue on this until I finish the feature-newi branch, after which I'll look at the merge.

@joriskalz
Copy link
Contributor Author

One element I'll challenge you to think about is: how do we make the "dropdown" with the folder usable on mobile, where the screen space is so limited?

Thanks @enricoros for your helpful feedback! I've been thinking over your challenge regarding the "dropdown" and its mobile usability.

Transforming it into a more compact dropdown might be a practical start.In addition, I propose leveraging the concept of adaptive design, rather than just responsive design. This approach allows us to tailor the user experience specifically for mobile users, rather than merely resizing desktop features.

Drawing from my own experiences with ChatGPT on mobile, I've noticed a distinct shift in interaction style. On mobile, I tend to lean towards voice mode and prefer concise dialogues. This got me thinking – could we perhaps streamline the mobile experience to focus more on immediate, dialogue-based interactions? By doing so, we could reduce the reliance on features like folders or extensive dialogue histories, which are more desktop-centric.

Imagine a scenario where users swiftly access key functions via voice commands or simple gestures. This makes the app more conversational and intuitive, enhancing the mobile experience for on-the-go users.

I would love to explore these ideas further. What are your thoughts on this adaptive approach?

@enricoros
Copy link
Owner

enricoros commented Dec 27, 2023

Yes! Absolutely yes to that. I want and need that on mobile. And quickly on the Folders on mobile, we need to find a way, maybe not on the App bar with drop downs. Maybe within the folders/chats pane.

Also a question on the folder structure. Usually people go for a tree, so conversations are "children" of folders, but you prefer having folders as labels on top, and conversations at the bottom?

Now on the next-cool part, the mobile UX that up mentioned.

Have you used voice calls on big-AGI on mobile? They're rough around the edges, but they're my preferred ways to use the app for hours or when driving/commuting.

Mobile UX is key, and on of the pillars of big-AGI is to reduce friction/streamline UX.

Every click we save is a win.

In some tickets here there are references to an Operator or Commander. That's not defined yet, but will be the entity you interact with when using the mobile UX.

On mobile, a dedicated "drawer" will open on the bottom if you cold-start the app, and will listen to your commands:

  • what was my last chat?
  • connect me to the legal advisor (creates a persona on the fly if missing)
  • why is the sky blue?
  • how many chats and personas do I have?

We can implement this with function calling. What do you think?

enricoros added a commit that referenced this pull request Dec 28, 2023
 - Optima Layout: new Context based pluggable layout system
   - Now children have context functions, for better behaviors
   - Removed `store-applayout`
   - using withLayout on top-level Pages
 - ScrollToBottom: grounds-up subsystem for smooth scrolling with snap-to-bottom
 - Panes subsystem: use react-resizeable-panels together with our Panes subsystem
   - New: Split window chats, Drag to close windows, Button to split
   - using: https://github.com/bvaughn/react-resizable-panels
 - Cosmetic: Colors: update Light and Dark themes
 - Bootstrap Logic provider: will enable Mobile use cases
 - Removed NoSSR (the backend provided natually acts as the same)
 - Next load progress: loading indicator for slower pages (>300ms)
 - withLayout() system

Additional benefits include: no-pluggable-flashing, pane-ready,
fixed X-scrolling on Firefox, and more.

Closes #308, #304, #255, #59.
Progress on #305, #201, #296, #233, #208, #203.
@enricoros
Copy link
Owner

Sorry for the late, I just dropped the first part of the New UI system.
d775d47

Biggest changes are: new layout system "Optima", new Scroll-to-bottom system (fully home-grown), new React Panes library.

This is a video for you:

New.UI.Subsystems.-.2023-12-28.032151.mp4

This took a while because my wish to add an icon messed the layout, which messed the layout system, which messed the Panes system (overflow), which required the in-order rendering of messages, which required a new scroll-to-bottom system.

Tomorrow I should be able to land the Left Panel (on Desktop), and Drawer (on Mobile) where the folders & chats will live.

@enricoros
Copy link
Owner

enricoros commented Dec 30, 2023

Hi @joriskalz, just giving you a quick update - the UI is pretty banged'up right now, but it should be done very soon, this is the current status.

At least you begin to see the panel that will be dedicated to the chats.

image

@joriskalz
Copy link
Contributor Author

Hi @enricoros, thanks for the heads up! Exciting to see the progress, even with the UI still in its final stages. The dedicated chat panel sounds like a game changer for desktop users, making things much smoother without constantly toggling the drawer.

Can’t wait to see the finished product in action. Unfortunately, I won’t be able to dive into it or give feedback for the next few days. Keep up the great work!

@enricoros
Copy link
Owner

Hi @joriskalz - enjoy your Happy New Year!
For the last moment of 2023, Big-AGI has landed the new UI :)

Could you port your code to main when you get a chance? Take your time and enjoy the new year!!

@joriskalz
Copy link
Contributor Author

joriskalz commented Jan 1, 2024

Hi @enricoros, Happy New Year to you as well! 🎉 I hope you've had a fantastic start to 2024. The new UI looks incredible—kudos to you for the great work on Big-AGI's landing!

I wanted to let you know that I've taken your suggestion into account and merged it with main in the latest version. created a new pull request to port the code with further optimizations. You can find the new PR here: #321 This should align well with the new UI changes. Looking forward to your thoughts on the updates!

@joriskalz joriskalz closed this Jan 1, 2024
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