fix: respect for task-only contexts
Adjusted poll()’s context reconciliation so we respect task-only contexts. Now we mark both chat and task stores when the active context belongs to tasks(tasksStore.contains(context)), and we only fall back to the first chat when the context is absent from both chats and tasks. Prevents the previous behavior where selecting a task immediately went back to the first chat because the context wasn’t found in the chats list.
Alessandro committed
Nov 4, 2025 at 11:49 UTC
90ffc78799fd36fe3e200dbf7b2f28a302adb774
1 file changed
+7
-5
webui/index.js
+7
-5
@@ -337,10 +337,14 @@ export async function poll() {
337
// Update selection in both stores
338
chatsStore.setSelected(context);
339
340
- // Check if this context exists in the chats list
341
- const contextExists = chatsStore.contains(context);
340
+ const contextInChats = chatsStore.contains(context);
341
+ const contextInTasks = tasksStore.contains(context);
342
343
- if (!contextExists) {
343
+ if (contextInTasks) {
344
+ tasksStore.setSelected(context);
345
+ }
346
+
347
+ if (!contextInChats && !contextInTasks) {
348
if (chatsStore.contexts.length > 0) {
349
// If it doesn't exist in the list but other contexts do, fall back to the first
350
const firstChatId = chatsStore.firstId();
@@ -352,8 +356,6 @@ export async function poll() {
356
// No contexts remain – clear state so the welcome screen can surface
357
deselectChat();
358
}
355
- } else {
356
- tasksStore.setSelected(context);
359
}
360
} else {
361
const welcomeStore =