Skip to content

Feature Request: Add conversation/thread delete functionality #1907

Description

@saga197410qq

📋 Feature Request

Add ability to delete conversations/threads


🎯 Problem Description

Currently, there is no way to delete conversations/threads in the IronClaw web interface. Users can create new conversations (via the "+" button) and switch between them, but cannot delete old ones.

Current UI behavior:

  • Clicking a thread item only switches to that conversation
  • No delete button, menu, or icon on thread items
  • No right-click context menu
  • No delete option in settings

🔍 Technical Analysis

Frontend (src/channels/web/static/app.js)

Thread list rendering (line ~2008-2044):

for (const thread of threads) {
  const item = document.createElement('div');
  item.className = 'thread-item' + (isActive ? ' active' : '');
  
  // Only renders: label + timestamp + unread indicator
  // Click only triggers switchThread()
  item.addEventListener('click', () => switchThread(thread.id));
  list.appendChild(item);
}

Missing:

  • No delete button/icon in thread item
  • No delete confirmation dialog
  • No API call to delete endpoint

Backend (src/channels/web/handlers/chat.rs)

Existing handlers:

pub async fn chat_threads_handler(...)      // GET /api/chat/threads
pub async fn chat_new_thread_handler(...)   // POST /api/chat/thread/new
// ❌ No chat_delete_thread_handler

Missing:

  • No DELETE /api/chat/thread/{id} endpoint
  • No delete handler implementation

Server Routes (src/channels/web/handlers/server.rs)

Existing routes:

.route("/api/chat/threads", get(chat_threads_handler))
.route("/api/chat/thread/new", post(chat_new_thread_handler))
// ❌ No delete route

For comparison, other features have delete:

.route("/api/admin/routines/{id}", delete(routines_delete_handler))
.route("/api/admin/skills/{name}", delete(skills_remove_handler))
.route("/api/admin/secrets/{name}", delete(secrets_delete_handler))

💡 Expected Implementation

Frontend Changes

  1. Add delete button/icon on thread items

    • Show on hover or always visible
    • Use trash icon (🗑️) or delete icon
    • Position: right side of thread item
  2. Add confirmation dialog

    function confirmDeleteThread(threadId, threadName) {
      if (confirm(`Delete conversation "${threadName}"? This cannot be undone.`)) {
        apiFetch(`/api/chat/thread/${threadId}`, { method: 'DELETE' })
          .then(() => { loadThreads(); if (activeThreadId === threadId) switchToFirstThread(); });
      }
    }
  3. Update thread list rendering

    • Add delete button to each thread item
    • Add event listener for delete action

Backend Changes

  1. Add delete handler (chat.rs):

    pub async fn chat_delete_thread_handler(
      Path(thread_id): Path<Uuid>,
      user: User,
      db: Data<Database>,
    ) -> Result<Json<()>> {
      // Verify thread belongs to user
      let thread = db.get_thread(thread_id, user.id).await?;
      
      // Delete thread and associated messages
      db.delete_thread(thread_id, user.id).await?;
      
      Ok(Json(()))
    }
  2. Add route (server.rs):

    .route("/api/chat/thread/{id}", delete(chat_delete_thread_handler))
  3. Add database method (database.rs):

    pub async fn delete_thread(&self, thread_id: Uuid, user_id: Uuid) -> Result<()> {
      // Delete thread and cascade delete messages
      sqlx::query("DELETE FROM threads WHERE id = ? AND user_id = ?")
        .bind(thread_id)
        .bind(user_id)
        .execute(&self.pool)
        .await?;
      Ok(())
    }

🎨 UI Design Suggestions

Option 1: Delete button on hover

┌─────────────────────────────────────┐
│ 📋 Project Discussion    2026-04-02 │ [🗑️]
├─────────────────────────────────────┤
│ 💬 Daily Chat          2026-04-01 │ [🗑️]
└─────────────────────────────────────┘

Option 2: Three-dot menu

┌─────────────────────────────────────┐
│ 📋 Project Discussion    2026-04-02 │ [⋮]
├─────────────────────────────────────┤
│ 💬 Daily Chat          2026-04-01 │ [⋮]
└─────────────────────────────────────┘

Option 3: Delete icon always visible

┌─────────────────────────────────────┐
│ 📋 Project Discussion    2026-04-02 │ 🗑️
├─────────────────────────────────────┤
│ 💬 Daily Chat          2026-04-01 │ 🗑️
└─────────────────────────────────────┘

Recommendation: Option 1 (show on hover) for cleaner UI


🔒 Security Considerations

  • Verify thread ownership before delete
  • Only authenticated users can delete their own threads
  • Admin can delete any thread (optional)
  • Add rate limiting to prevent abuse

📝 Use Cases

  1. Clean up old conversations - Remove completed projects or outdated discussions
  2. Privacy - Delete conversations containing sensitive information
  3. Token management - Delete long conversations to free up context space
  4. Organization - Keep conversation list manageable and relevant

🏷️ Labels

  • enhancement
  • good first issue (for frontend changes)
  • backend (for API implementation)

📎 Related

  • N/A (no existing issues found for this feature)

✅ Acceptance Criteria

  • Delete button/icon visible on thread items
  • Confirmation dialog before delete
  • Backend API endpoint implemented
  • Thread and messages deleted from database
  • Thread list refreshed after delete
  • If deleted thread was active, switch to another thread
  • Error handling for permission issues
  • Unit tests for delete handler

Thank you for considering this feature request!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions