This locks down how the existing chat window grows into one shared system that supports the main window plus 3 additional slide-out windows without forking the UI into four separate implementations.
Every chat slot owns its own target/session state. That means selected agent, session key, draft text, attachments, unread count, and streaming metadata all live per window instead of in page-global singletons.
const chatWindows = {
primary: {
slotId: 'primary',
selectedAgentKey: 'main',
sessionKey: 'agent:main:main',
draft: '',
attachments: [],
pendingRunId: null,
unread: 0,
layoutMode: 'docked-right'
},
'secondary-1': null,
'secondary-2': null,
'secondary-3': null
};
All windows must come from one reusable chat component/template. The current single-instance code needs to be migrated so each window renders from the same logic with a slot-scoped state object.
createChatWindow(slotId, containerEl) renderChatWindow(slotState) bindChatWindowEvents(slotState, elements) loadChatHistory(slotState) connectChatStream(slotState) sendChatMessage(slotState) resetChatSession(slotState) destroyChatWindow(slotId)
data-chat-slot on each window root.Do not create four separate websocket stacks. Use one shared gateway connection and route events to the correct window by slotId and sessionKey.
Buttons map to fixed secondary slots and act as toggles.