Skip to content

feat: Add Clear All Conversations for llama-server web-ui #12924

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

Closed
wants to merge 2 commits into from

Conversation

characharm
Copy link
Contributor

Motivation:
I often use the llama-server web UI directly for basic chats, as I prefer to avoid launching heavier services like OpenWebUI in Docker just for simple interactions. A key missing piece for me was the ability to easily clear the chat history without having to clear browser data, which felt cumbersome.

  • Adding a "Clear All Conversations" button to the sidebar.
  • Implementing the logic to remove all conversation and message data from IndexedDB when the button is clicked (after user confirmation).

characharm and others added 2 commits April 13, 2025 00:23
Adds a "Clear All Conversations" button to the Sidebar component.

Key changes:
- Sidebar: Adds UI button, confirmation dialog, and uses context
  to check for active generation before allowing deletion. Navigates
  to '/' on success. Updates useEffect dependency.
- Storage: Implements `clearAllConversations` method using Dexie
  transaction. Modifies event system (CallbackConversationChanged, etc.)
  to handle `string | null` for signalling "clear all" events.
  Fixes `offConversationChanged` listener removal.
- AppContext: Updates event listener (`handleConversationChange`) to
  accept `string | null` and refresh state correctly on `null`.
  Fixes `exhaustive-deps` warning.
Conversations are saved to browser's IndexedDB
</div>
{/* Clear All Button - Added */}
{conversations.length > 0 && ( // Only show if there are conversations to clear
<button
Copy link
Collaborator

Choose a reason for hiding this comment

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

From UX perspective, this button should be hidden in one of the sections under "Settings". It's strange to expose such a dangerous button on the main UI (even when it requires confirmation)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What are your thoughts on replacing the button with a less intrusive text link in the sidebar footer, next to the IndexedDB notice? Something like this:

 <div className="text-center text-xs opacity-40 mt-auto mx-4 pb-2">
            Conversations are saved to browser's IndexedDB&nbsp;
            <span
              onClick={handleClearAll}
              className="text-error underline cursor-pointer hover:opacity-70"
            >
              clear
            </span>
          </div>

image

Comment on lines +53 to +61
if (currConv?.id) {
// Check if there *was* a selected conversation
const stillExists = await StorageUtils.getOneConversation(currConv.id);
if (!stillExists) {
// If the current conv was deleted/cleared, update the local state for highlighting
setCurrConv(null);
// Navigation happens via handleClearAll or if user manually deletes and stays on the page
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think many changes in this PR are redundant. You can simply window.location.reload() upon clear the database, and everything will be in sync

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right, the page is light and window.location.reload() would be quick. However, I generally try to avoid full page reloads as a principle, considering that the update system is already built into the app – using the StorageUtils.onConversationChanged events and React state (useState/useEffect). I made small tweaks (from my point of view :) ) to that system so it could also handle clearing everything.

@characharm characharm closed this Apr 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants