Beautiful, AI-native markdown IDE and LLM wiki
TypeScript 2nd-brainagent-skillsclaudecodexcompany-braindocsknowledge-knowledge-baseknowledge-managementllmllm-wikillm-wiki-karpathymarkdownmarkdown-editormdmdxnotespkmsecond-brainskills
Reveal ACP threads after lazy Agents mount (#6742)
Nick Gomez180b125d5a72
diff --git a/.changeset/reveal-agent-thread-after-lazy-host.md b/.changeset/reveal-agent-thread-after-lazy-host.mdnew file mode 100644index 000000000..fdb5d298f--- /dev/null+++ b/.changeset/reveal-agent-thread-after-lazy-host.md@@ -0,0 +1,5 @@+---+"@inkeep/open-knowledge-app": patch+---++Agent conversations now open the Agents panel even when the panel finishes loading after the conversation starts.diff --git a/packages/app/src/components/SessionsHost.agents.dom.test.tsx b/packages/app/src/components/SessionsHost.agents.dom.test.tsxindex 7db7c465a..87e5c2708 100644--- a/packages/app/src/components/SessionsHost.agents.dom.test.tsx+++ b/packages/app/src/components/SessionsHost.agents.dom.test.tsx@@ -1792,6 +1792,42 @@ describe('SessionsHost — agents panel (web / no bridge)', () => {expect(onVisibleChange).not.toHaveBeenCalled();});+ test('a live thread injected before host mount reveals a hidden dock after an empty roster', async () => {+ const onVisibleChange = vi.fn((_v: boolean) => {});+ setInitialRosterIds(new Set());+ setOpenThreads([makeThread({ threadId: 'injected-1', title: 'Injected' })]);++ render(<Harness initialVisible={false} onVisibleChange={onVisibleChange} />);+ await screen.findByRole('tab', { name: /Injected/ });++ await waitFor(() => expect(onVisibleChange).toHaveBeenCalledWith(true));+ });++ test('a live thread injected before the roster arrives reveals a hidden dock once the roster omits it', async () => {+ const onVisibleChange = vi.fn((_v: boolean) => {});+ setOpenThreads([makeThread({ threadId: 'injected-1', title: 'Injected' })]);++ render(<Harness initialVisible={false} onVisibleChange={onVisibleChange} />);+ await screen.findByRole('tab', { name: /Injected/ });+ expect(onVisibleChange).not.toHaveBeenCalled();++ act(() => setInitialRosterIds(new Set()));++ expect(onVisibleChange).toHaveBeenCalledWith(true);+ });++ test('a live thread present before the roster arrives stays hidden once the roster restores it', async () => {+ const onVisibleChange = vi.fn((_v: boolean) => {});+ setOpenThreads([makeThread({ threadId: 'injected-1', title: 'Injected' })]);++ render(<Harness initialVisible={false} onVisibleChange={onVisibleChange} />);+ await screen.findByRole('tab', { name: /Injected/ });++ act(() => setInitialRosterIds(new Set(['injected-1'])));++ expect(onVisibleChange).not.toHaveBeenCalled();+ });+test('revealing the dock focuses the active session', async () => {const control = makeControl();setOpenThreads([makeThread({ threadId: 't1', title: 'Pre-existing' })]);diff --git a/packages/app/src/components/SessionsHost.tsx b/packages/app/src/components/SessionsHost.tsxindex 3b8e59b2e..f55858cd9 100644--- a/packages/app/src/components/SessionsHost.tsx+++ b/packages/app/src/components/SessionsHost.tsx@@ -1364,13 +1364,22 @@ export function SessionsHost({const liveThreadIds = openThreadTabs.filter((info) => info.archived !== true).map((info) => info.threadId);- const prevLiveThreadIdsRef = useRef<readonly string[]>(liveThreadIds);+ const prevLiveThreadIdsRef = useRef<readonly string[]>(+ initialRosterThreadIds === null ? liveThreadIds : [...initialRosterThreadIds],+ );+ const initialRosterWasUnknownRef = useRef(initialRosterThreadIds === null);useEffect(() => {if (!hostThreads) return;if (!agentsVisibilityRestoreSettled) return;const previous = prevLiveThreadIdsRef.current;prevLiveThreadIdsRef.current = liveThreadIds;- const added = liveThreadIds.filter((id) => !previous.includes(id));+ const rosterWasUnknown = initialRosterWasUnknownRef.current;+ const rosterIsKnown = initialRosterThreadIds !== null;+ initialRosterWasUnknownRef.current = !rosterIsKnown;+ const added =+ rosterWasUnknown && rosterIsKnown+ ? liveThreadIds.filter((id) => !initialRosterThreadIds.has(id))+ : liveThreadIds.filter((id) => !previous.includes(id));if (added.length === 0) return;const seededLaunch = seededThreadLaunchRef.current;const seededThreadId = added.find((id) => {