Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(desktop): 直接在侧栏打开并继续追问

DavidShend4337a11e01b
diff --git a/apps/desktop/src/renderer/features/cc-agent/CCAgentSessionView.tsx b/apps/desktop/src/renderer/features/cc-agent/CCAgentSessionView.tsx
index 6ca3b7afd3..0748b1f5b9 100644
--- a/apps/desktop/src/renderer/features/cc-agent/CCAgentSessionView.tsx
+++ b/apps/desktop/src/renderer/features/cc-agent/CCAgentSessionView.tsx
@@ -44,7 +44,6 @@ import {
import { CINDY_MAKE_ENABLED, isCindyMakeSource } from '@cindy/maker-shared/cindy-make-feature';
import { CindyMakeSessionGate } from './CindyMakeSessionGate';
import { SessionRouteOriginGate } from './SessionRouteOriginGate';
-import { sideChatTaskRoute } from '@/features/right-sidebar/plugins/side-chat/state';
import { dbToMakerAgentKind, normalizeDbAgentKind } from '../../../shared/agentKindConversion';
import { useTranslation } from 'react-i18next';
import { buildSessionDeepLink } from '@/lib/deepLink';
@@ -2876,7 +2875,7 @@ function CCAgentSessionContent({
toast.info(t('chat.sideChat.mainTaskOnly'));
return;
}
- void openSideChatTab(sessionId, { prompt: payload.args, onOpen: (id, deviceId) => navigate(sideChatTaskRoute(id, deviceId)) });
+ void openSideChatTab(sessionId, { prompt: payload.args });
return;
}
if (payload.command === 'cmd') {
@@ -3569,7 +3568,6 @@ function CCAgentSessionContent({
const accepted = await openSideChatTab(sessionId, {
prompt: args,
attachments: files,
- onOpen: (id, deviceId) => navigate(sideChatTaskRoute(id, deviceId)),
});
return { handled: true, accepted, message };
}
@@ -5266,7 +5264,7 @@ function CCAgentSessionContent({
activeVoiceCallId={activeVoiceCallId}
historyVisibleAfter={session?.source === 'side-chat' ? new Date(session.createdAt).getTime() : undefined}
onAskInSideChat={!readOnly && canNavigateSession && sessionId && session?.source !== 'side-chat' && session?.source !== 'bot'
- ? (quote) => openSideChatTab(sessionId, { quote, onOpen: (id, deviceId) => navigate(sideChatTaskRoute(id, deviceId)) }) : undefined}
+ ? (quote) => openSideChatTab(sessionId, { quote }) : undefined}
cindyMakeSessionId={session?.source === 'cindy-make' ? sessionId : undefined}
cindyMakeCompletionInComposer={session?.source === 'cindy-make' && (remoteMakeCards.supported || (!remoteDeviceId && !readOnly && typeof window.electronAPI.cindyMakeTest === 'function'))}
historyLoaded={historyLoaded}
diff --git a/apps/desktop/src/renderer/features/right-sidebar/__tests__/AddTabDropdown.test.tsx b/apps/desktop/src/renderer/features/right-sidebar/__tests__/AddTabDropdown.test.tsx
index 60de69c7c1..19c2b16a68 100644
--- a/apps/desktop/src/renderer/features/right-sidebar/__tests__/AddTabDropdown.test.tsx
+++ b/apps/desktop/src/renderer/features/right-sidebar/__tests__/AddTabDropdown.test.tsx
@@ -193,7 +193,7 @@ it.each([undefined, { groupId: 'left' as const }, { onOptimisticAdd: vi.fn() }])
const onSelect = vi.fn();
render(<Entries sessionId="task-1" onSelect={onSelect} sideChatPlacement={placement} />);
await act(async () => fireEvent.click(screen.getByText('chat.sideChat.new')));
- expect(m.openSideChat).toHaveBeenCalledExactlyOnceWith('task-1', { placement, onOpen: expect.any(Function) });
+ expect(m.openSideChat).toHaveBeenCalledExactlyOnceWith('task-1', { placement });
expect(onSelect).not.toHaveBeenCalled();
});
diff --git a/apps/desktop/src/renderer/features/right-sidebar/lib/__tests__/openSideChatTab.test.ts b/apps/desktop/src/renderer/features/right-sidebar/lib/__tests__/openSideChatTab.test.ts
index d1d3be9f36..de0e5c1795 100644
--- a/apps/desktop/src/renderer/features/right-sidebar/lib/__tests__/openSideChatTab.test.ts
+++ b/apps/desktop/src/renderer/features/right-sidebar/lib/__tests__/openSideChatTab.test.ts
@@ -68,15 +68,13 @@ describe('side chat task entry', () => {
mocks.status.mockResolvedValue(undefined);
});
- // Full-page navigation must happen after the branch entry and draft exist, so
- // returning to the parent can resume the same task instead of creating another.
- it('opens the full task page after preserving the branch entry and draft', async () => {
- const open = vi.fn();
- expect(await openSideChatTab('parent', { prompt: 'follow-up', onOpen: open })).toBe(true);
- expect(open).toHaveBeenCalledExactlyOnceWith('child', null);
- expect(mocks.save.mock.invocationCallOrder[0]).toBeLessThan(open.mock.invocationCallOrder[0]);
+ // The draft must exist before the embedded editor appears; opening a follow-up
+ // keeps the main task visible instead of navigating away (2026-10-25 regression).
+ it('opens the parent sidebar after preserving the branch entry and draft', async () => {
+ expect(await openSideChatTab('parent', { prompt: 'follow-up' })).toBe(true);
+ expect(mocks.save.mock.invocationCallOrder[0]).toBeLessThan(mocks.add.mock.invocationCallOrder[0]);
expect(mocks.tabs).toContainEqual(expect.objectContaining({ state: { sessionId: 'child', deviceId: null } }));
- expect(mocks.reveal).toHaveBeenCalledExactlyOnceWith('close', { sessionId: 'child', animate: false });
+ expect(mocks.reveal).toHaveBeenCalledExactlyOnceWith('open', { sessionId: 'parent', userInitiated: true });
});
it('pins the remote child before exposing its quote and editor', async () => {
@@ -89,19 +87,15 @@ describe('side chat task entry', () => {
expect(mocks.pin.mock.invocationCallOrder[0]).toBeLessThan(mocks.add.mock.invocationCallOrder[0]);
});
- // Unit, #6529: full-page navigation cannot rely on a hidden child's list push.
- // A create result must supply the complete remote metadata before navigation.
- // The owning host must also cross the navigation boundary: an in-memory pin
- // and asynchronous disk cache both disappear in the cold-renderer case.
- it('caches remote metadata before navigating to the full task page', async () => {
+ // Unit, #6529: hidden children do not arrive in ordinary task lists. The create
+ // result must supply metadata before the embedded editor can read/send remotely.
+ it('caches remote metadata before opening the embedded task', async () => {
mocks.device = 'execution-host';
const child = { id: 'child', source: 'side-chat', model: 'test-model', workingDir: '/work' };
mocks.create.mockResolvedValue(child);
- const open = vi.fn();
- expect(await openSideChatTab('parent', { onOpen: open })).toBe(true);
- expect(open).toHaveBeenCalledExactlyOnceWith('child', 'execution-host');
+ expect(await openSideChatTab('parent')).toBe(true);
expect(mocks.cache).toHaveBeenCalledWith('execution-host', 'Host', [child]);
- expect(mocks.cache.mock.invocationCallOrder[0]).toBeLessThan(open.mock.invocationCallOrder[0]);
+ expect(mocks.cache.mock.invocationCallOrder[0]).toBeLessThan(mocks.add.mock.invocationCallOrder[0]);
});
// Unit, #6529: /side used to clear the composer while dropping its files.
diff --git a/apps/desktop/src/renderer/features/right-sidebar/lib/openSideChatTab.ts b/apps/desktop/src/renderer/features/right-sidebar/lib/openSideChatTab.ts
index 667a27ca1d..1224026b18 100644
--- a/apps/desktop/src/renderer/features/right-sidebar/lib/openSideChatTab.ts
+++ b/apps/desktop/src/renderer/features/right-sidebar/lib/openSideChatTab.ts
@@ -132,7 +132,7 @@ export function watchSideChatTabs(sessionId: string): () => void {
/** Open an independent follow-up on the parent's execution host. */
export async function openSideChatTab(
sessionId: string,
- options: { prompt?: string; attachments?: AttachedFile[]; quote?: string; placement?: SideChatTabPlacement; onOpen?: (sessionId: string, deviceId: string | null) => void } = {},
+ options: { prompt?: string; attachments?: AttachedFile[]; quote?: string; placement?: SideChatTabPlacement } = {},
): Promise<boolean> {
try {
if ((await window.electronAPI.rightSidebarWindow?.getState())?.detached) {
@@ -169,12 +169,6 @@ export async function openSideChatTab(
clearDraft(child.id);
throw error;
}
- // Keep the parent's tabs as resumable entries; the child uses the full task route.
- if (options.onOpen) {
- requestRightSidebarVisibility('close', { sessionId: child.id, animate: false });
- options.onOpen(child.id, deviceId);
- return true;
- }
// Menus in other groups or popout windows already own their visible host.
if (!options.placement?.onOptimisticAdd && (!options.placement?.groupId || options.placement.groupId === 'right')) {
requestRightSidebarVisibility('open', { sessionId, userInitiated: true });
diff --git a/apps/desktop/src/renderer/features/right-sidebar/lib/useTabCreationMenu.ts b/apps/desktop/src/renderer/features/right-sidebar/lib/useTabCreationMenu.ts
index 2df14d399c..7c7e8d1a86 100644
--- a/apps/desktop/src/renderer/features/right-sidebar/lib/useTabCreationMenu.ts
+++ b/apps/desktop/src/renderer/features/right-sidebar/lib/useTabCreationMenu.ts
@@ -1,5 +1,3 @@
-import { UNSAFE_NavigationContext } from 'react-router-dom';
-import { isSidebarWindow } from '@/lib/sidebarWindow';
import { useContext, useRef, useState, useSyncExternalStore } from 'react';
import { Puzzle } from 'lucide-react';
import { MAIN_VIEW_ICONS } from '@/cindy-brain/mainViewIcons';
@@ -78,8 +76,6 @@ export function useTabCreationMenu({
const session = remoteSessions.find(row => row.id === sessionId) ?? localSession;
const [openingSessionId, setOpeningSessionId] = useState<string | null>(null);
const pending = useRef<string | null>(null);
- // Detached sidebar hosts have no Router and must hand content back to the main window.
- const router = useContext(UNSAFE_NavigationContext);
const items = listTabKindMenuMetas().filter(item => {
if (item.kind.startsWith('ghost:')) return false;
if (item.kind === 'subagents' && !subagentsAvailable) return false;
@@ -115,8 +111,6 @@ export function useTabCreationMenu({
setOpeningSessionId(sessionId);
const opening = openSideChatTab(sessionId, {
placement: sideChatPlacement,
- onOpen: !isSidebarWindow() && router
- ? (id) => router.navigator.push(`${router.basename.replace(/\/$/, '')}/cc-agent/${id}`) : undefined,
});
void opening.finally(() => {
if (pending.current === sessionId) pending.current = null;
diff --git a/apps/desktop/src/renderer/features/right-sidebar/plugins/side-chat/SideChatTabBody.test.tsx b/apps/desktop/src/renderer/features/right-sidebar/plugins/side-chat/SideChatTabBody.test.tsx
index a1d42f8829..b0e608f44b 100644
--- a/apps/desktop/src/renderer/features/right-sidebar/plugins/side-chat/SideChatTabBody.test.tsx
+++ b/apps/desktop/src/renderer/features/right-sidebar/plugins/side-chat/SideChatTabBody.test.tsx
@@ -3,7 +3,7 @@ import { act, cleanup, fireEvent, render, screen } from '@testing-library/react'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import type { TabKindHostContext } from '../../types';
-const mocks = vi.hoisted(() => ({ navigate: vi.fn(), invoke: vi.fn(), subscribe: vi.fn(), pin: vi.fn(), confirm: vi.fn(), status: vi.fn(), merge: vi.fn(), cache: vi.fn(), detached: false, t: (key: string) => key }));
+const mocks = vi.hoisted(() => ({ navigate: vi.fn(), invoke: vi.fn(), subscribe: vi.fn(), pin: vi.fn(), confirm: vi.fn(), status: vi.fn(), merge: vi.fn(), cache: vi.fn(), closeTab: vi.fn(), detached: false, t: (key: string) => key }));
vi.mock('react-router-dom', () => ({ useNavigate: () => mocks.navigate }));
// Match the stable translation callback; changing it on every render restarts the metadata read.
vi.mock('react-i18next', () => ({ useTranslation: () => ({ t: mocks.t }) }));
@@ -16,13 +16,16 @@ vi.mock('@/lib/composerDraftStore', () => ({ discardDraft: vi.fn() }));
vi.mock('@/lib/sessionService', () => ({ setStatus: mocks.status }));
vi.mock('@/lib/sidebarWindow', () => ({ isSidebarWindow: () => mocks.detached }));
vi.mock('@/lib/toast', () => ({ toast: { error: vi.fn() } }));
-vi.mock('@/contexts/dataOwnerGeneration', () => ({ getDataOwnerGeneration: () => 1, isDataOwnerGenerationCurrent: () => true }));
+vi.mock('@/contexts/dataOwnerGeneration', () => ({ getDataOwnerGeneration: () => 1, isDataOwnerGenerationCurrent: () => true, isDataOwnerPushCurrent: () => true }));
vi.mock('@/lib/remoteDataOwnerPushFence', () => ({ isDeviceLinkRemotePushCurrent: () => true }));
vi.mock('../../lib/mergeSidebarWindowBack', () => ({ mergeSidebarWindowBack: mocks.merge }));
+vi.mock('../../store', () => ({ closeTab: mocks.closeTab }));
import { SideChatTabBody } from './SideChatTabBody';
-// Unit: a hidden remote child has no list row. Its host metadata must be read before the
-// full-page entry is enabled. Closing must honor cancellation; the panel has no second editor.
+// Unit regression (2026-10-25): opening a side-chat tab used to show only a navigation
+// button. Mount the production panel with one local/remote child and verify it exposes
+// the shared editor in place. The previous tests explicitly required a second navigation.
+// Remote metadata/patch ordering, visibility and deletion must still gate that editor.
describe('side chat panel lifecycle', () => {
let close: (() => Promise<boolean>) | null;
const ctx = { sessionId: 'parent', tabId: 'tab', setCloseInterceptor: (fn: () => Promise<boolean>) => { close = fn; return () => { close = null; }; } } as unknown as TabKindHostContext;
@@ -30,12 +33,16 @@ describe('side chat panel lifecycle', () => {
vi.clearAllMocks(); close = null; mocks.detached = false;
mocks.confirm.mockResolvedValue(false); mocks.status.mockResolvedValue(undefined);
mocks.subscribe.mockReturnValue(() => {});
+ mocks.closeTab.mockResolvedValue(undefined);
mocks.invoke.mockResolvedValue({ id: 'child', parentSessionId: 'parent', source: 'side-chat', model: 'old-model' });
- Object.defineProperty(window, 'electronAPI', { configurable: true, value: { deviceLink: { invoke: mocks.invoke, onRemotePush: mocks.subscribe } } });
+ Object.defineProperty(window, 'electronAPI', { configurable: true, value: {
+ deviceLink: { invoke: mocks.invoke, onRemotePush: mocks.subscribe },
+ localDb: { sessionsPush: { onPatched: mocks.subscribe } },
+ } });
});
afterEach(cleanup);
- it('opens a full task page only after its remote branch metadata is available', async () => {
+ it('opens the embedded editor after reading its remote branch, preserving newer patches', async () => {
let resolve!: (value: unknown) => void;
mocks.invoke.mockReturnValueOnce(new Promise(done => { resolve = done; }));
render(<SideChatTabBody state={{ sessionId: 'child', deviceId: 'host' }} ctx={ctx} active />);
@@ -45,16 +52,41 @@ describe('side chat panel lifecycle', () => {
mocks.subscribe.mock.calls[0][0]({ deviceId: 'host', channel: 'local-db:sessions:patched', payload: { sessionId: 'child', patch: { model: 'new-model' } } });
resolve({ id: 'child', parentSessionId: 'parent', source: 'side-chat', model: 'old-model' });
});
- expect(screen.queryByTestId('editor')).toBeNull();
- fireEvent.click(screen.getByRole('button', { name: 'chat.sideChat.openPage' }));
- // Unit #6529: reopening a hidden branch must preserve its host in the URL,
- // even if the renderer restarts before the asynchronous mirror cache writes.
- expect(mocks.navigate).toHaveBeenCalledWith('/cc-agent/child?device=host');
+ const editor = JSON.parse(screen.getByTestId('editor').textContent!);
+ expect(editor).toMatchObject({
+ sessionIdProp: 'child', navigationMode: 'sidebar-embedded', sidebarTargetSessionId: 'parent',
+ sessionSnapshotProp: { id: 'child', model: 'new-model', deviceLinkDeviceId: 'host' },
+ viewVisible: true, chatRealtime: true,
+ });
+ expect(screen.queryByRole('button', { name: 'chat.sideChat.openPage' })).toBeNull();
+ expect(mocks.navigate).not.toHaveBeenCalled();
expect(mocks.cache).toHaveBeenCalledWith('host', 'Host', [expect.objectContaining({ id: 'child', model: 'new-model' })]);
- expect(mocks.cache.mock.invocationCallOrder[0]).toBeLessThan(mocks.navigate.mock.invocationCallOrder[0]);
expect(mocks.pin).toHaveBeenCalledWith('host', 'child');
});
+ it('keeps the local editor mounted but suspends visible work when its tab or shell is hidden', () => {
+ const { rerender } = render(<SideChatTabBody state={{ sessionId: 'child', deviceId: null }} ctx={ctx} active />);
+ const editor = screen.getByTestId('editor');
+ expect(JSON.parse(editor.textContent!)).toMatchObject({ sessionIdProp: 'child', viewVisible: true, chatRealtime: true });
+ rerender(<SideChatTabBody state={{ sessionId: 'child', deviceId: null }} ctx={ctx} active={false} />);
+ expect(screen.getByTestId('editor')).toBe(editor);
+ expect(JSON.parse(editor.textContent!)).toMatchObject({ viewVisible: false, chatRealtime: false, disableAutofocus: true });
+ rerender(<SideChatTabBody state={{ sessionId: 'child', deviceId: null }} ctx={ctx} active shellVisible={false} />);
+ expect(screen.getByTestId('editor')).toBe(editor);
+ expect(JSON.parse(editor.textContent!)).toMatchObject({ viewVisible: false, chatRealtime: false });
+ expect(mocks.invoke).not.toHaveBeenCalled();
+ expect(mocks.navigate).not.toHaveBeenCalled();
+ });
+
+ it('opens the editor after retrying a failed metadata read', async () => {
+ mocks.invoke.mockRejectedValueOnce(new Error('offline'));
+ await act(async () => { render(<SideChatTabBody state={{ sessionId: 'child', deviceId: 'host' }} ctx={ctx} active />); });
+ expect(screen.queryByTestId('editor')).toBeNull();
+ await act(async () => { fireEvent.click(screen.getByRole('button', { name: 'commonUi.retry' })); });
+ expect(screen.getByTestId('editor')).toBeTruthy();
+ expect(mocks.navigate).not.toHaveBeenCalled();
+ });
+
it('cancels without deleting, and a failed remote deletion keeps the panel open', async () => {
await act(async () => { render(<SideChatTabBody state={{ sessionId: 'child', deviceId: 'host' }} ctx={ctx} active />); });
await expect(close!()).resolves.toBe(false);
diff --git a/apps/desktop/src/renderer/features/right-sidebar/plugins/side-chat/SideChatTabBody.tsx b/apps/desktop/src/renderer/features/right-sidebar/plugins/side-chat/SideChatTabBody.tsx
index 6ab107720f..7397b58030 100644
--- a/apps/desktop/src/renderer/features/right-sidebar/plugins/side-chat/SideChatTabBody.tsx
+++ b/apps/desktop/src/renderer/features/right-sidebar/plugins/side-chat/SideChatTabBody.tsx
@@ -1,8 +1,9 @@
import { useCallback, useEffect, useState } from 'react';
import { Button } from '@/components/ui/button';
import { useTranslation } from 'react-i18next';
-import { useNavigate } from 'react-router-dom';
+import { CCAgentSessionView } from '@/features/cc-agent/CCAgentSessionView';
import { remoteProjectsStore } from '@/features/device-link/remoteProjectsStore';
+import { useDocumentVisible, useWindowVisible } from '@/hooks/useWindowVisible';
import { useConfirmDialog } from '@/components/ui/confirm-dialog-provider';
import { makerChatStore } from '@/lib/makerChatStore';
import { discardDraft } from '@/lib/composerDraftStore';
@@ -15,9 +16,8 @@ import { isDeviceLinkRemotePushCurrent } from '@/lib/remoteDataOwnerPushFence';
import { SidebarHostSessionProvider } from '../../lib/sidebarHostSession';
import { mergeSidebarWindowBack } from '../../lib/mergeSidebarWindowBack';
import { closeTab } from '../../store';
-import { requestRightSidebarVisibility } from '../../lib/sidebarCommands';
import type { TabKindBodyProps } from '../../types';
-import { sideChatTaskRoute, type SideChatState } from './state';
+import type { SideChatState } from './state';
export function SideChatTabBody({ state, ctx, active, shellVisible = true }: TabKindBodyProps<SideChatState>) {
const { t } = useTranslation();
@@ -39,10 +39,13 @@ export function SideChatTabBody({ state, ctx, active, shellVisible = true }: Tab
return <AttachedSideChat state={state} ctx={ctx} active={active} shellVisible={shellVisible} />;
}
-function AttachedSideChat({ state, ctx, active }: TabKindBodyProps<SideChatState>) {
+function AttachedSideChat({ state, ctx, active, shellVisible = true }: TabKindBodyProps<SideChatState>) {
const { t } = useTranslation();
const { confirm } = useConfirmDialog();
- const navigate = useNavigate();
+ const windowVisible = useWindowVisible(Boolean(active && shellVisible));
+ const documentVisible = useDocumentVisible(Boolean(active && shellVisible));
+ const viewVisible = Boolean(active && shellVisible && windowVisible);
+ const chatRealtime = Boolean(active && shellVisible && documentVisible);
const childId = state.sessionId;
const [remoteSession, setRemoteSession] = useState<Session | null>(null);
const [loadFailed, setLoadFailed] = useState(false);
@@ -102,6 +105,10 @@ function AttachedSideChat({ state, ctx, active }: TabKindBodyProps<SideChatState
}
const snapshot: Session = { ...value, ...bufferedPatch, id: childId, source: 'side-chat', deviceLinkDeviceId: deviceId };
if (snapshot.status === 'deleted') { dismiss(); return; }
+ // The shared editor also reads metadata from the remote task store. Restore
+ // hidden branches there before mounting it, without changing the main route.
+ remoteProjectsStore.mergeDeviceSessions(deviceId,
+ remoteProjectsStore.getDeviceName(deviceId) ?? '', [snapshot]);
setRemoteSession(snapshot);
};
void read().catch(() => { if (valid() && !unavailable) setLoadFailed(true); });
@@ -133,18 +140,18 @@ function AttachedSideChat({ state, ctx, active }: TabKindBodyProps<SideChatState
{state.deviceId && (loadFailed || remoteSession?.id !== childId) ? <div className="flex h-full flex-col items-center justify-center gap-3 p-6 text-center">
<p className="text-sm leading-5 text-muted-foreground">{t(loadFailed ? 'chat.sideChat.failed' : 'chat.sideChat.opening')}</p>
{loadFailed && <Button onClick={() => setRetry(value => value + 1)}>{t('commonUi.retry')}</Button>}
- </div> : childId && (!state.deviceId || registeredChild === childId) && <div className="flex h-full items-center justify-center px-6">
- <Button variant="secondary" onClick={() => {
- if (state.deviceId && remoteSession?.id === childId) {
- remoteProjectsStore.mergeDeviceSessions(state.deviceId,
- remoteProjectsStore.getDeviceName(state.deviceId) ?? '', [remoteSession]);
- }
- requestRightSidebarVisibility('close', { sessionId: childId, animate: false });
- navigate(sideChatTaskRoute(childId, state.deviceId));
- }}>
- {t('chat.sideChat.openPage')}
- </Button>
- </div>}
+ </div> : childId && (!state.deviceId || registeredChild === childId) && <CCAgentSessionView
+ key={childId}
+ sessionIdProp={childId}
+ sessionSnapshotProp={remoteSession}
+ compact
+ compactToolbar
+ viewVisible={viewVisible}
+ chatRealtime={chatRealtime}
+ disableAutofocus={!viewVisible}
+ navigationMode="sidebar-embedded"
+ sidebarTargetSessionId={ctx.sessionId}
+ />}
</div>
</div>
</SidebarHostSessionProvider>;
diff --git a/apps/desktop/src/renderer/features/right-sidebar/plugins/side-chat/__tests__/SideChatTabBody.test.tsx b/apps/desktop/src/renderer/features/right-sidebar/plugins/side-chat/__tests__/SideChatTabBody.test.tsx
index b6a057379e..f36cdeda58 100644
--- a/apps/desktop/src/renderer/features/right-sidebar/plugins/side-chat/__tests__/SideChatTabBody.test.tsx
+++ b/apps/desktop/src/renderer/features/right-sidebar/plugins/side-chat/__tests__/SideChatTabBody.test.tsx
@@ -17,7 +17,7 @@ vi.mock('react-i18next', () => ({ useTranslation: () => ({ t: m.t }) }));
vi.mock('@/components/ui/button', () => ({ Button: ({ children, onClick }: any) => <button onClick={onClick}>{children}</button> }));
vi.mock('@/components/ui/confirm-dialog-provider', () => ({ useConfirmDialog: () => ({ confirm: m.confirm }) }));
vi.mock('@/features/cc-agent/CCAgentSessionView', () => ({ CCAgentSessionView: () => <textarea aria-label="Side chat composer" /> }));
-vi.mock('@/features/device-link/remoteProjectsStore', () => ({ remoteProjectsStore: { pinSessionOrigin: vi.fn() } }));
+vi.mock('@/features/device-link/remoteProjectsStore', () => ({ remoteProjectsStore: { pinSessionOrigin: vi.fn(), mergeDeviceSessions: vi.fn(), getDeviceName: () => 'Host' } }));
vi.mock('@/hooks/useWindowVisible', () => ({ useWindowVisible: () => true, useDocumentVisible: () => true }));
vi.mock('@/lib/sidebarWindow', () => ({ isSidebarWindow: () => false }));
vi.mock('@/lib/makerChatStore', () => ({ makerChatStore: { closeSessionQuery: vi.fn(), purgeSession: vi.fn() } }));
@@ -54,25 +54,25 @@ beforeEach(() => {
});
afterEach(() => { cleanup(); m.local.clear(); m.remote.clear(); });
-// Unit regression: deleting on another controller must remove the dead full-page entry.
+// Unit regression: deleting on another controller must immediately remove the side-chat composer.
// Existing opener tests exercise tab creation only, not the mounted editor.
// Minimal inputs: a deleted host snapshot or a deletion push while GET is in flight.
it.each([null, 'host'])('removes a deleted branch without another confirmation (%s)', async deviceId => {
mount(deviceId);
await act(async () => {});
- expect(screen.queryByRole('button', { name: 'chat.sideChat.openPage' })).not.toBeNull();
+ expect(screen.queryByRole('textbox', { name: 'Side chat composer' })).not.toBeNull();
await act(async () => deleted(deviceId));
- expect(screen.queryByRole('button', { name: 'chat.sideChat.openPage' })).toBeNull();
+ expect(screen.queryByRole('textbox', { name: 'Side chat composer' })).toBeNull();
expect(m.close).toHaveBeenCalledWith('parent', 'tab', { skipBeforeClose: true });
expect(m.confirm).not.toHaveBeenCalled();
expect(m.setStatus).not.toHaveBeenCalled();
});
-it.each([null, { ...child, status: 'deleted' }])('does not offer a full-page entry for an unavailable remote snapshot', async value => {
+it.each([null, { ...child, status: 'deleted' }])('does not mount a composer for an unavailable remote snapshot', async value => {
m.get.mockResolvedValue(value);
mount('host');
await act(async () => {});
- expect(screen.queryByRole('button', { name: 'chat.sideChat.openPage' })).toBeNull();
+ expect(screen.queryByRole('textbox', { name: 'Side chat composer' })).toBeNull();
expect(m.close).toHaveBeenCalledWith('parent', 'tab', { skipBeforeClose: true });
});
@@ -82,7 +82,7 @@ it('does not revive a deleted branch when an older active snapshot completes', a
mount('host');
await act(async () => deleted('host'));
await act(async () => finish(child));
- expect(screen.queryByRole('button', { name: 'chat.sideChat.openPage' })).toBeNull();
+ expect(screen.queryByRole('textbox', { name: 'Side chat composer' })).toBeNull();
expect(m.close).toHaveBeenCalledTimes(1);
});