fix(gateway): keep engine threads out of chat sidebar (#2751)

* fix(gateway): keep engine threads out of chat sidebar

* fix: address review findings (iteration 1)

* fix: address review findings (iteration 2)
This commit is contained in:
firat.sertgoz
2026-04-20 21:38:41 +03:00
committed by GitHub
parent e35099de23
commit 904e378677
5 changed files with 180 additions and 95 deletions

View File

@@ -79,6 +79,7 @@ let logEventSource = null;
let currentTab = 'chat';
let currentThreadId = null;
let currentThreadIsReadOnly = false;
const threadChannelHints = new Map();
let assistantThreadId = null;
let hasMore = false;
let oldestTimestamp = null;

View File

@@ -40,6 +40,10 @@ function loadHistory(before) {
apiFetch(historyUrl).then((data) => {
const container = document.getElementById('chat-messages');
if (!isPaginating && currentThreadId && data.channel) {
threadChannelHints.set(currentThreadId, data.channel);
}
if (!isPaginating) {
// Fresh load: clear and render
container.innerHTML = '';
@@ -117,6 +121,16 @@ function loadHistory(before) {
} else if (lastTurn && !lastTurn.response && lastTurn.state === 'Processing') {
showActivityThinking(ActivityEntry.t('activity.processing', 'Processing...'));
}
const hintedChannel = currentThreadId
? (data.channel || threadChannelHints.get(currentThreadId) || 'gateway')
: 'gateway';
currentThreadIsReadOnly = isReadOnlyChannel(hintedChannel);
if (currentThreadIsReadOnly) {
disableChatInputReadOnly();
} else {
enableChatInput();
}
if (data.pending_gate) {
handleGateRequired({
...data.pending_gate,
@@ -467,7 +481,10 @@ function loadThreads() {
const currentThread = currentThreadId === assistantThreadId
? data.assistant_thread
: threads.find(t => t.id === currentThreadId);
const ch = currentThread ? currentThread.channel : 'gateway';
const hintedChannel = currentThread
? currentThread.channel
: threadChannelHints.get(currentThreadId);
const ch = hintedChannel || 'gateway';
currentThreadIsReadOnly = isReadOnlyChannel(ch);
if (currentThreadIsReadOnly) {
disableChatInputReadOnly();