Skip to content

Commit 8333731

Browse files
Sg312Vikhyath Mondreti
authored andcommitted
Default Plan chats to independently saved Opus 5.5 Medium preferences
1 parent 3af24cd commit 8333731

12 files changed

Lines changed: 742 additions & 22 deletions

File tree

‎apps/sim/app/o/[organizationId]/home/components/composer/composer.test.tsx‎

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
1515
import { createRoot, type Root } from 'react-dom/client'
1616
import { afterEach, beforeEach, expect, it, vi } from 'vitest'
1717
import type { useSpeechToText } from '@/hooks/use-speech-to-text'
18-
import { useMothershipEffortStore } from '@/stores/mothership-effort/store'
18+
import {
19+
useMothershipEffortStore,
20+
useMothershipPlanEffortStore,
21+
} from '@/stores/mothership-effort/store'
1922

2023
const mocks = vi.hoisted(() => ({
2124
plan: false,
@@ -103,6 +106,7 @@ let queryClient: QueryClient
103106
beforeEach(() => {
104107
mocks.advanced = false
105108
useMothershipEffortStore.getState().reset()
109+
useMothershipPlanEffortStore.getState().reset()
106110
mocks.plan = false
107111
vi.clearAllMocks()
108112
mocks.workspaces = [
@@ -191,7 +195,7 @@ afterEach(async () => {
191195
async function render(
192196
isInitialView: boolean,
193197
initialValue = 'Summarize',
194-
requestMode: 'agent' | 'assistant' = 'assistant',
198+
requestMode: 'agent' | 'assistant' | 'plan' = 'assistant',
195199
controls: Pick<
196200
ComponentProps<typeof Composer>,
197201
'isSending' | 'showModeSelector' | 'onModeChange' | 'restoredContexts' | 'onSendQueuedHead'
@@ -476,3 +480,22 @@ it.each([
476480
expect(input.value).toBe('')
477481
}
478482
)
483+
484+
it('renders and restores separate Plan and Build model preferences when changing modes', async () => {
485+
mocks.plan = true
486+
mocks.advanced = true
487+
await render(false, '', 'plan')
488+
expect(container.textContent).toContain('Opus 5.5')
489+
expect(container.textContent).toContain('Medium')
490+
await act(async () => {
491+
useMothershipPlanEffortStore.getState().setModel('gpt-6-astra')
492+
useMothershipPlanEffortStore.getState().setEffort('xhigh')
493+
})
494+
expect(container.textContent).toContain('GPT-6 Astra')
495+
expect(container.textContent).toContain('Extra High')
496+
await render(false, '', 'agent')
497+
expect(container.textContent).toContain('GPT-6 Astra')
498+
expect(container.textContent).not.toContain('Extra High')
499+
await render(false, '', 'plan')
500+
expect(container.textContent).toContain('Extra High')
501+
})

‎apps/sim/app/o/[organizationId]/home/components/composer/composer.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,7 @@ export function Composer({
313313
/>
314314
) : (
315315
<InputToolbar
316+
plan={requestMode === 'plan'}
316317
leadingControls={leadingControls}
317318
voiceControl={voiceControl}
318319
submitControl={submitControl}

‎apps/sim/app/workspace/[workspaceId]/home/components/user-input/components/input-toolbar.tsx‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { ModelSelector } from '@/app/workspace/[workspaceId]/home/components/use
77
interface InputToolbarProps {
88
leadingControls: ReactNode
99
showModelSelector?: boolean
10+
plan?: boolean
1011
selectionControl?: ReactNode
1112
voiceControl?: ReactNode
1213
beforeSubmitControl?: ReactNode
@@ -22,6 +23,7 @@ interface InputToolbarProps {
2223
export function InputToolbar({
2324
leadingControls,
2425
showModelSelector = true,
26+
plan = false,
2527
selectionControl,
2628
voiceControl,
2729
beforeSubmitControl,
@@ -69,7 +71,7 @@ export function InputToolbar({
6971
<>
7072
{(selectionControl || showModelSelector || voiceControl) && (
7173
<div className='flex items-center gap-[inherit]'>
72-
{selectionControl ?? (showModelSelector && <ModelSelector />)}
74+
{selectionControl ?? (showModelSelector && <ModelSelector plan={plan} />)}
7375
{voiceControl}
7476
</div>
7577
)}

‎apps/sim/app/workspace/[workspaceId]/home/components/user-input/components/model-selector.tsx‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,15 @@ import {
2323
useMothershipChatHistory,
2424
useSetMothershipChatEffort,
2525
} from '@/hooks/queries/mothership-chats'
26-
import { useMothershipEffortStore } from '@/stores/mothership-effort/store'
26+
import { useMothershipEffortStore, useMothershipPlanEffortStore } from '@/stores/mothership-effort/store'
2727

2828
/** Model, reasoning effort, and Fast mode for Build chat composers. */
29-
export function ModelSelector() {
29+
export function ModelSelector({ plan = false }: { plan?: boolean }) {
30+
const usePreferenceStore = plan ? useMothershipPlanEffortStore : useMothershipEffortStore
3031
const advanced = useFeatureFlag('mothership-model-selector')
31-
const selection = useMothershipEffortStore((state) => state.modelSelection)
32-
const setModel = useMothershipEffortStore((state) => state.setModel)
33-
const setFastMode = useMothershipEffortStore((state) => state.setFastMode)
32+
const selection = usePreferenceStore((state) => state.modelSelection)
33+
const setModel = usePreferenceStore((state) => state.setModel)
34+
const setFastMode = usePreferenceStore((state) => state.setFastMode)
3435
const { chatId } = useChatSurface()
3536
const { data: chatHistory } = useMothershipChatHistory(chatId)
3637
const chatPick = useMothershipEffortStore((state) =>
@@ -42,7 +43,8 @@ export function ModelSelector() {
4243
const effortChoice = chatId ? (chatPick ?? chatHistory?.effort) : newChatEffort
4344
const { effort, modelSelection } = resolveMothershipModelSettings(
4445
{ effort: effortChoice ?? undefined, modelSelection: selection },
45-
advanced
46+
advanced,
47+
plan
4648
)
4749
const options = modelSelection ? MOTHERSHIP_EFFORT_OPTIONS : MOTHERSHIP_SIMPLE_EFFORT_OPTIONS
4850
const setEffort = (choice: MothershipEffort) => {

‎apps/sim/app/workspace/[workspaceId]/home/components/user-input/user-input.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,7 @@ const UserInputImpl = forwardRef<UserInputHandle, UserInputProps>(function UserI
598598
/>
599599

600600
<InputToolbar
601+
plan={requestMode === 'plan'}
601602
leadingControls={
602603
<>
603604
<Tooltip.Root>

‎apps/sim/app/workspace/[workspaceId]/home/hooks/use-chat.ts‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ import { getWorkflowListQueryOptions } from '@/hooks/queries/utils/workflow-list
136136
import { workflowKeys } from '@/hooks/queries/workflows'
137137
import { snapAllSmoothText } from '@/hooks/use-smooth-text'
138138
import { useChatPanelStore } from '@/stores/chat-panel/store'
139-
import { useMothershipEffortStore } from '@/stores/mothership-effort/store'
139+
import { useMothershipEffortStore, useMothershipPlanEffortStore } from '@/stores/mothership-effort/store'
140140
import {
141141
liveQueueKey,
142142
liveQueuePosition,
@@ -3940,8 +3940,12 @@ export function useChat(
39403940
...(options?.requestMode !== 'assistant'
39413941
? {
39423942
modelSelection: resolveMothershipModelSettings(
3943-
useMothershipEffortStore.getState(),
3944-
modelSelectorEnabled
3943+
(options?.requestMode === 'plan'
3944+
? useMothershipPlanEffortStore
3945+
: useMothershipEffortStore
3946+
).getState(),
3947+
modelSelectorEnabled,
3948+
options?.requestMode === 'plan'
39453949
).modelSelection,
39463950
...(effortChoice ? { effort: effortChoice } : {}),
39473951
}

0 commit comments

Comments
 (0)