Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

🐛 fix(desktop-overlay): hide model picker and stabilize panel enter (#14484)

Innei0a32fbc737f8
diff --git a/apps/desktop/src/overlay/ChatPanel.test.tsx b/apps/desktop/src/overlay/ChatPanel.test.tsx
index 4cbf997c031..fdc8745d527 100644
--- a/apps/desktop/src/overlay/ChatPanel.test.tsx
+++ b/apps/desktop/src/overlay/ChatPanel.test.tsx
@@ -1,8 +1,23 @@
-import { describe, expect, it } from 'vitest';
+import { describe, expect, it, vi } from 'vitest';
+import { resolveOverlayModelSelectionPayload, shouldShowOverlayModelSelector } from './ChatPanel';
import { resolvePanelPlacement } from './panelPlacement';
-describe('resolvePanelPlacement', () => {
+vi.mock('./chatPanel.css.ts', () => new Proxy({}, { get: (_, key) => String(key) }));
+
+vi.mock('./cn', () => ({
+ cn: (...classes: Array<string | false | null | undefined>) => classes.filter(Boolean).join(' '),
+}));
+
+vi.mock('./Avatar', () => ({
+ default: () => null,
+}));
+
+vi.mock('@lobehub/icons', () => ({
+ ModelIcon: () => null,
+}));
+
+describe('ChatPanel', () => {
it('keeps the last selection placement while a reselection is in progress', () => {
expect(
resolvePanelPlacement({
@@ -30,4 +45,43 @@ describe('resolvePanelPlacement', () => {
width: 420,
});
});
+
+ it('hides the model selector and omits model payload for heterogeneous agents', () => {
+ const heterogeneousAgent = {
+ heterogeneousType: 'codex',
+ id: 'agent-codex',
+ title: 'Codex Agent',
+ };
+
+ expect(shouldShowOverlayModelSelector(heterogeneousAgent)).toBe(false);
+ expect(
+ resolveOverlayModelSelectionPayload({
+ agent: heterogeneousAgent,
+ model: { id: 'gpt-4.1', provider: 'openai' },
+ modelId: 'gpt-4.1',
+ }),
+ ).toEqual({
+ modelId: undefined,
+ provider: undefined,
+ });
+ });
+
+ it('keeps the model selector and payload for regular agents', () => {
+ const regularAgent = {
+ id: 'agent-regular',
+ title: 'Regular Agent',
+ };
+
+ expect(shouldShowOverlayModelSelector(regularAgent)).toBe(true);
+ expect(
+ resolveOverlayModelSelectionPayload({
+ agent: regularAgent,
+ model: { id: 'gpt-4.1', provider: 'openai' },
+ modelId: 'gpt-4.1',
+ }),
+ ).toEqual({
+ modelId: 'gpt-4.1',
+ provider: 'openai',
+ });
+ });
});
diff --git a/apps/desktop/src/overlay/ChatPanel.tsx b/apps/desktop/src/overlay/ChatPanel.tsx
index 4d1eac434ee..d2775f8ed8e 100644
--- a/apps/desktop/src/overlay/ChatPanel.tsx
+++ b/apps/desktop/src/overlay/ChatPanel.tsx
@@ -57,6 +57,25 @@ export interface ChatPanelProps {
viewportWidth: number;
}
+export const shouldShowOverlayModelSelector = (agent?: ScreenCaptureAgentOption) =>
+ !agent?.heterogeneousType;
+
+export const resolveOverlayModelSelectionPayload = ({
+ agent,
+ model,
+ modelId,
+}: {
+ agent?: ScreenCaptureAgentOption;
+ model?: ScreenCaptureModelOption;
+ modelId?: string;
+}) => {
+ if (!shouldShowOverlayModelSelector(agent)) {
+ return { modelId: undefined, provider: undefined };
+ }
+
+ return { modelId, provider: model?.provider };
+};
+
const formatBytes = (rect: Rect): string =>
`${Math.round(rect.width)} × ${Math.round(rect.height)} · ${OVERLAY_COPY.selectionFormatLabel}`;
@@ -140,6 +159,7 @@ const ChatPanel = memo<ChatPanelProps>(
() => models?.find((item) => item.id === modelId),
[models, modelId],
);
+ const showModelSelector = shouldShowOverlayModelSelector(currentAgent);
useEffect(() => {
if (!initialAgentId) return;
@@ -276,14 +296,29 @@ const ChatPanel = memo<ChatPanelProps>(
const submit = useCallback(() => {
if (selections.length === 0 || !prompt.trim() || !allUploadsReady) return;
+ const modelSelection = resolveOverlayModelSelectionPayload({
+ agent: currentAgent,
+ model: currentModel,
+ modelId,
+ });
+
onSubmit({
agentId,
captureIds: selections.map((item) => item.captureId),
- modelId,
+ modelId: modelSelection.modelId,
prompt: prompt.trim(),
- provider: currentModel?.provider,
+ provider: modelSelection.provider,
});
- }, [selections, prompt, agentId, modelId, currentModel, onSubmit, allUploadsReady]);
+ }, [
+ selections,
+ prompt,
+ agentId,
+ currentAgent,
+ modelId,
+ currentModel,
+ onSubmit,
+ allUploadsReady,
+ ]);
const handleKeyDown = useCallback(
(e: ReactKeyboardEvent<HTMLTextAreaElement>) => {
@@ -464,38 +499,40 @@ const ChatPanel = memo<ChatPanelProps>(
</select>
</label>
- <label
- aria-label={OVERLAY_COPY.modelSelectLabel}
- className={cn(styles.selectChip, !hasModels && styles.selectChipDisabled)}
- >
- {currentModel ? (
- <span className={styles.modelIconBox}>
- <ModelIcon model={currentModel.id} size={16} />
- </span>
- ) : (
- <span className={styles.modelIconBoxFallback} />
- )}
- <span className={styles.chipLabel}>
- {currentModel?.displayName ??
- currentModel?.id ??
- OVERLAY_COPY.modelSelectPlaceholder}
- </span>
- <ChevronDownIcon className={styles.chevron} size={12} strokeWidth={2} />
- <select
+ {showModelSelector && (
+ <label
aria-label={OVERLAY_COPY.modelSelectLabel}
- className={styles.nativeSelect}
- disabled={!hasModels}
- value={modelId ?? ''}
- onChange={handleModelChange}
+ className={cn(styles.selectChip, !hasModels && styles.selectChipDisabled)}
>
- {!hasModels && <option value="">{OVERLAY_COPY.modelSelectPlaceholder}</option>}
- {models?.map((item) => (
- <option key={item.id} value={item.id}>
- {item.displayName ?? item.id}
- </option>
- ))}
- </select>
- </label>
+ {currentModel ? (
+ <span className={styles.modelIconBox}>
+ <ModelIcon model={currentModel.id} size={16} />
+ </span>
+ ) : (
+ <span className={styles.modelIconBoxFallback} />
+ )}
+ <span className={styles.chipLabel}>
+ {currentModel?.displayName ??
+ currentModel?.id ??
+ OVERLAY_COPY.modelSelectPlaceholder}
+ </span>
+ <ChevronDownIcon className={styles.chevron} size={12} strokeWidth={2} />
+ <select
+ aria-label={OVERLAY_COPY.modelSelectLabel}
+ className={styles.nativeSelect}
+ disabled={!hasModels}
+ value={modelId ?? ''}
+ onChange={handleModelChange}
+ >
+ {!hasModels && <option value="">{OVERLAY_COPY.modelSelectPlaceholder}</option>}
+ {models?.map((item) => (
+ <option key={item.id} value={item.id}>
+ {item.displayName ?? item.id}
+ </option>
+ ))}
+ </select>
+ </label>
+ )}
</div>
<div className={styles.actionBarRight}>
diff --git a/apps/desktop/src/overlay/chatPanel.css.ts b/apps/desktop/src/overlay/chatPanel.css.ts
index 9a4047fb93f..4d03363048e 100644
--- a/apps/desktop/src/overlay/chatPanel.css.ts
+++ b/apps/desktop/src/overlay/chatPanel.css.ts
@@ -484,8 +484,8 @@ export const connectorHidden = style({
});
const fadeIn = keyframes({
- from: { opacity: 0, transform: 'translate(-50%, 8px)' },
- to: { opacity: 1, transform: 'translate(-50%, 0)' },
+ from: { opacity: 0, transform: 'translateY(8px)' },
+ to: { opacity: 1, transform: 'translateY(0)' },
});
const spin = keyframes({
diff --git a/packages/electron-client-ipc/src/types/screenCapture.ts b/packages/electron-client-ipc/src/types/screenCapture.ts
index 52e1215cebf..13ebdd5ed01 100644
--- a/packages/electron-client-ipc/src/types/screenCapture.ts
+++ b/packages/electron-client-ipc/src/types/screenCapture.ts
@@ -14,6 +14,7 @@ export interface ScreenCaptureWindowInfo {
export interface ScreenCaptureAgentOption {
avatar?: string | null;
backgroundColor?: string | null;
+ heterogeneousType?: string | null;
id: string;
title: string;
}
diff --git a/src/features/Electron/ScreenCapture/overlaySnapshot.test.ts b/src/features/Electron/ScreenCapture/overlaySnapshot.test.ts
index 792300ec04a..1f5c63d4a3f 100644
--- a/src/features/Electron/ScreenCapture/overlaySnapshot.test.ts
+++ b/src/features/Electron/ScreenCapture/overlaySnapshot.test.ts
@@ -75,4 +75,20 @@ describe('overlaySnapshot', () => {
},
]);
});
+
+ it('preserves heterogeneousType for overlay agent options', () => {
+ const agentOptions = resolveOverlayAgentOptions({
+ agents: [{ avatar: 'A', heterogeneousType: 'codex', id: 'agent-1', title: 'Agent 1' }],
+ });
+
+ expect(agentOptions).toEqual([
+ {
+ avatar: 'A',
+ backgroundColor: undefined,
+ heterogeneousType: 'codex',
+ id: 'agent-1',
+ title: 'Agent 1',
+ },
+ ]);
+ });
});
diff --git a/src/features/Electron/ScreenCapture/overlaySnapshot.ts b/src/features/Electron/ScreenCapture/overlaySnapshot.ts
index da5f428e53e..34ec3718c1f 100644
--- a/src/features/Electron/ScreenCapture/overlaySnapshot.ts
+++ b/src/features/Electron/ScreenCapture/overlaySnapshot.ts
@@ -7,6 +7,7 @@ const UNTITLED_AGENT_TITLE = 'Untitled Agent';
interface OverlayAgentSource {
avatar?: unknown;
backgroundColor?: string | null;
+ heterogeneousType?: string | null;
id: string;
title?: string | null;
}
@@ -32,11 +33,13 @@ interface ResolveOverlayDefaultAgentIdParams {
const toOverlayAgentOption = ({
avatar,
backgroundColor,
+ heterogeneousType,
id,
title,
}: OverlayAgentSource): ScreenCaptureAgentOption => ({
avatar: typeof avatar === 'string' ? avatar : DEFAULT_AVATAR,
backgroundColor: backgroundColor ?? undefined,
+ heterogeneousType,
id,
title: title?.trim() || UNTITLED_AGENT_TITLE,
});