OpenAgentsInc / openagents

An open agents platform (wip)
https://openagents.com
GNU Affero General Public License v3.0
159 stars 18 forks source link

Enhancement: Add edit button for list of chats #427

Open dekdynamics opened 1 month ago

dekdynamics commented 1 month ago

Hi Team,

I have a bunch of chats that I'd like to remove from the sidebar, but clicking each one and confirming the delete is pretty annoying and time consuming.

Can you add an edit button at the top of the column that reveals a delete button on each chat, for quick delete, or can you add a "Delete All chats" button in settings?

Thanks!

greptile-apps[bot] commented 1 month ago

To add an edit button for quick delete functionality:

  1. Modify sidebar-thread.blade.php:

    • Add a delete button for each chat item.
      <div class="relative z-[15]">
      <!-- Existing code -->
      <button wire:click="deleteThread({{ $thread->id }})" class="hidden group-hover:block">Delete</button>
      </div>
  2. Modify sidebar-switcher.blade.php:

    • Add an edit button at the top of the sidebar.
      <div x-data="{ editMode: false }">
      <button @click="editMode = !editMode">Edit</button>
      <ul>
         <!-- Existing code -->
         <li x-show="editMode">
             <!-- Include delete button here -->
         </li>
      </ul>
      </div>
  3. Update Chat.php Livewire Component:

    • Add a method to handle thread deletion.
      public function deleteThread($threadId)
      {
      $thread = Thread::find($threadId);
      if ($thread) {
         $thread->delete();
         session()->flash('message', 'Thread deleted successfully.');
      }
      }
  4. Add 'Delete All Chats' Button in Settings:

    • Create a new button in the settings view.
      <button wire:click="deleteAllChats">Delete All Chats</button>
    • Add the corresponding method in the Livewire component.
      public function deleteAllChats()
      {
      Thread::truncate();
      session()->flash('message', 'All chats deleted successfully.');
      }

References

/resources/views/livewire/sidebar-thread.blade.php /resources/views/livewire/sidebar-switcher.blade.php /app/Livewire/Chat.php /app/Livewire/Modals/Chat/Delete.php /resources/views/livewire/modals/chat/delete.blade.php

Ask Greptile