Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,11 @@ async def _process_chain(self, agent: "Agent", msg: "UserMessage|str", user=True
return response
except Exception as e:
await self.handle_exception("process_chain", e)
finally:
# Push updated running state to ALL connections when agent finishes.
# Without this, non-active tabs don't see running:false until they click.
from helpers.state_monitor_integration import mark_dirty_all
mark_dirty_all(reason="agent.AgentContext._process_chain completed")

@extension.extensible
async def handle_exception(self, location: str, exception: Exception):
Expand Down
9 changes: 8 additions & 1 deletion webui/components/chat/message-queue/message-queue-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,15 @@ const model = {
},

// Combined items for display: confirmed first, then pending at the end
// Deduplicate by id to prevent Alpine "Duplicate key" errors during
// the race between server poll updates and pending item cleanup.
get allItems() {
return [...this.items, ...this.pendingItems];
const seen = new Set();
return [...this.items, ...this.pendingItems].filter((item) => {
if (seen.has(item.id)) return false;
seen.add(item.id);
return true;
});
},

async addToQueue(text, attachments = []) {
Expand Down
2 changes: 1 addition & 1 deletion webui/components/sidebar/chats/chats-list.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ <h3 class="section-header">Chats</h3>

<ul class="config-list chats-config-list no-scrollbar" x-show="$store.chats.contexts.length > 0">
<template x-for="context in $store.chats.contexts" :key="context.id">
<li>
<li :data-chat-id="context.id">
<div :class="{'chat-container': true, 'chat-selected': context.id === $store.chats.selected}"
@click="$store.chats.selectChat(context.id)">
<div class="chat-list-button">
Expand Down
15 changes: 7 additions & 8 deletions webui/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,13 @@ export async function applySnapshot(snapshot, options = {}) {
return { updated: false };
}

// Update chats/tasks list BEFORE context check so background chat
// state changes (running, etc.) are always reflected in the sidebar.
let contexts = snapshot.contexts || [];
chatsStore.applyContexts(contexts);
let tasks = snapshot.tasks || [];
tasksStore.applyTasks(tasks);

if (
snapshot.context != context &&
context !== null
Expand Down Expand Up @@ -370,14 +377,6 @@ export async function applySnapshot(snapshot, options = {}) {
setConnectionStatus(true);
}

// Update chats list using store
let contexts = snapshot.contexts || [];
chatsStore.applyContexts(contexts);

// Update tasks list using store
let tasks = snapshot.tasks || [];
tasksStore.applyTasks(tasks);

// Make sure the active context is properly selected in both lists
if (context) {
// Update selection in both stores
Expand Down