π€― 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.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
π fix(desktop): restore Codex reply regeneration (#20271)
Nekoeb7a330fbf0d
diff --git a/src/features/Conversation/store/slices/generation/action.test.ts b/src/features/Conversation/store/slices/generation/action.test.tsindex eb4a53a7701..68e8522d66a 100644--- a/src/features/Conversation/store/slices/generation/action.test.ts+++ b/src/features/Conversation/store/slices/generation/action.test.ts@@ -1725,13 +1725,14 @@ describe('Generation Actions', () => {// upcoming lifecycle refactor cannot silently change them. They assert what// the code does NOW β including behavior that looks buggy (called out inline).// ===========================================================================- describe('regenerate hetero branch characterization (lifecycle refactor regression net)', () => {+ /** @example Both local CLI providers preserve attachments and topic configuration on retry. */+ describe.each(['claude-code', 'codex'] as const)('regenerate %s branch', (providerType) => {// The hetero regenerate path lives behind `runtimeType === 'hetero'`. We// force that decision (it normally requires desktop + a local CLI provider)// by stubbing `selectRuntimeType`, and supply a `heterogeneousProvider` via// the agent config selector so the `runtimeType === 'hetero' && provider`// guard passes.- const heterogeneousProvider = { type: 'claude-code' } as any;+ const heterogeneousProvider = { type: providerType };const setupHeteroChatStore = async (overrides: Record<string, any> = {}) => {const mockRefreshMessages = vi.fn().mockResolvedValue(undefined);@@ -1823,7 +1824,7 @@ describe('Generation Actions', () => {expect.objectContaining({parentId: 'msg-1',role: 'assistant',- provider: 'claude-code',+ provider: providerType,}),);@@ -1849,10 +1850,11 @@ describe('Generation Actions', () => {});it('regenerates with the topic-pinned heterogeneous model', async () => {+ const pinnedModel = providerType === 'codex' ? 'gpt-5.4' : 'opus';await setupHeteroChatStore({topicDataMap: {test: {- items: [{ id: 'topic-1', model: 'opus', provider: 'claude-code' }],+ items: [{ id: 'topic-1', model: pinnedModel, provider: providerType }],},},});@@ -1873,7 +1875,7 @@ describe('Generation Actions', () => {expect(executeHeterogeneousAgentSpy).toHaveBeenCalledWith(expect.any(Function),expect.objectContaining({- heterogeneousProvider: expect.objectContaining({ model: 'opus', type: 'claude-code' }),+ heterogeneousProvider: expect.objectContaining({ model: pinnedModel, type: providerType }),}),);});diff --git a/src/routes/(main)/agent/features/Conversation/useActionsBarConfig.test.ts b/src/routes/(main)/agent/features/Conversation/useActionsBarConfig.test.tsnew file mode 100644index 00000000000..8293afca3c6--- /dev/null+++ b/src/routes/(main)/agent/features/Conversation/useActionsBarConfig.test.ts@@ -0,0 +1,83 @@+import { cleanup, renderHook } from '@testing-library/react';+import { act } from 'react';+import { afterEach, beforeEach, describe, expect, it } from 'vitest';++import { useAgentStore } from '@/store/agent';++import { useActionsBarConfig } from './useActionsBarConfig';++const initialState = useAgentStore.getState();++/** @example A completed Codex reply exposes the existing regenerate action. */+describe('useActionsBarConfig', () => {+ beforeEach(() => {+ useAgentStore.setState({+ activeAgentId: 'codex-agent',+ agentMap: {+ 'codex-agent': { agencyConfig: { heterogeneousProvider: { type: 'codex' } } },+ },+ });+ });++ afterEach(() => {+ cleanup();+ useAgentStore.setState(initialState, true);+ });++ // ROOT CAUSE:+ //+ // Completed Codex replies used the fixed HETERO_ASSISTANT slots, which only+ // exposed copy/select/delete even though regenerateAssistantMessage already+ // dispatched to the heterogeneous runtime. Both assistant shapes must expose+ // regenerate; tool-using turns render as assistantGroup.+ /** @example Both a text reply and a tool-using reply can be regenerated. */+ it('exposes regenerate for Codex assistant messages and groups', () => {+ const { result } = renderHook(() => useActionsBarConfig());++ /** @example A text reply offers regenerate in its quick actions. */+ expect(result.current.assistant?.bar).toContain('regenerate');+ /** @example Its overflow menu also offers regenerate. */+ expect(result.current.assistant?.menu).toContain('regenerate');+ /** @example Tool-using reply groups have the same lifecycle actions. */+ expect(result.current.assistantGroup).toEqual(result.current.assistant);+ });++ /** @example Restoring the user prompt remains available after enabling reply regeneration. */+ it('preserves the Codex user message actions', () => {+ const { result } = renderHook(() => useActionsBarConfig());++ /** @example The user menu still supports restoring the original prompt. */+ expect(result.current.user?.menu).toContain('restoreToInput');+ /** @example The user quick action remains copy. */+ expect(result.current.user?.bar).toEqual(['copy']);+ });++ /** @example Switching from Codex to Claude Code removes the Codex-only action. */+ it('updates the slots when the heterogeneous provider changes', () => {+ const { result } = renderHook(() => useActionsBarConfig());++ act(() => {+ useAgentStore.setState({+ agentMap: {+ 'codex-agent': { agencyConfig: { heterogeneousProvider: { type: 'claude-code' } } },+ },+ });+ });++ /** @example Claude Code keeps its current quick actions. */+ expect(result.current.assistant?.bar).toEqual(['copy']);+ /** @example Claude Code keeps its current overflow menu. */+ expect(result.current.assistant?.menu).toEqual([+ 'copy', 'divider', 'select', 'divider', 'del',+ ]);+ });++ /** @example A native agent keeps the default actions provided by the message components. */+ it('uses the native defaults for agents without a heterogeneous provider', () => {+ useAgentStore.setState({ agentMap: { 'codex-agent': {} } });+ const { result } = renderHook(() => useActionsBarConfig());++ /** @example No overrides replace the native default action slots. */+ expect(result.current).toEqual({});+ });+});diff --git a/src/routes/(main)/agent/features/Conversation/useActionsBarConfig.ts b/src/routes/(main)/agent/features/Conversation/useActionsBarConfig.tsindex 1fdbe3ebfb9..012c2b1a7a3 100644--- a/src/routes/(main)/agent/features/Conversation/useActionsBarConfig.ts+++ b/src/routes/(main)/agent/features/Conversation/useActionsBarConfig.ts@@ -9,7 +9,9 @@ import { agentSelectors } from '@/store/agent/selectors';/*** Hetero-agent (Claude Code / Codex) sessions keep the menu minimal β copy +* delete β because the external runtime owns the assistant message lifecycle- * (edit / regenerate / branching / translate / share don't apply).+ * (edit / branching / translate / share don't apply).+ * Regenerate was previously excluded too; Codex now uses the existing+ * heterogeneous rerun path, which preserves the user prompt and attachments.* `select` remains available because forwarding / batch deletion is handled by* the local conversation UI and does not depend on the external runtime.*@@ -28,18 +30,38 @@ const HETERO_ASSISTANT: { bar: MessageActionSlot[]; menu: MessageActionSlot[] }menu: ['copy', 'divider', 'select', 'divider', 'del'],};+/** Codex replies can reuse the existing heterogeneous regeneration path. */+const CODEX_ASSISTANT: typeof HETERO_ASSISTANT = {+ bar: ['copy', 'regenerate'],+ menu: ['regenerate', ...HETERO_ASSISTANT.menu],+};++/**+ * Selects message actions supported by the current agent runtime.+ *+ * Use when:+ * - Configuring the main conversation's message action bars.+ *+ * Expects:+ * - The active agent's configuration is available in the agent store.+ *+ * Returns:+ * - Runtime-specific overrides, or native message defaults via an empty object.+ */export const useActionsBarConfig = (): ActionsBarConfig => {const isHeteroAgent = useAgentStore(agentSelectors.isCurrentAgentHeterogeneous);+ const providerType = useAgentStore(agentSelectors.currentAgentHeterogeneousProviderType);+return useMemo<ActionsBarConfig>(() => {if (isHeteroAgent) {return {- assistant: HETERO_ASSISTANT,- assistantGroup: HETERO_ASSISTANT,+ assistant: providerType === 'codex' ? CODEX_ASSISTANT : HETERO_ASSISTANT,+ assistantGroup: providerType === 'codex' ? CODEX_ASSISTANT : HETERO_ASSISTANT,user: HETERO_USER,};}return {};- }, [isHeteroAgent]);+ }, [isHeteroAgent, providerType]);};