Skip to content

Commit 648bf45

Browse files
authored
fix(mothership): default chat effort back to high (#8659)
* fix(mothership): default chat effort back to high * test(mothership): pin that a send carries effort only when the user picked one The default flip reaches a chat only if admission never records the default as a pick. The composer already sends effort only for a real pick; this pins it for new and existing chats.
1 parent 777b3e9 commit 648bf45

5 files changed

Lines changed: 45 additions & 7 deletions

File tree

‎apps/sim/app/workspace/[workspaceId]/home/hooks/use-chat.dom.test.tsx‎

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ import { useChat } from '@/app/workspace/[workspaceId]/home/hooks/use-chat'
8585
import { type MothershipChatHistory, mothershipChatKeys } from '@/hooks/queries/mothership-chats'
8686
import { handleMothershipChatStatusEvent } from '@/hooks/use-mothership-chat-events'
8787
import { useExecutionStore } from '@/stores/execution/store'
88+
import { useMothershipEffortStore } from '@/stores/mothership-effort/store'
8889
import { useMothershipQueueStore } from '@/stores/mothership-queue/store'
8990

9091
authClientMockFns.mockUseSession.mockImplementation(() => ({
@@ -105,7 +106,7 @@ interface NetworkState {
105106
* - `deduped` — the 409 the server returns for an already-claimed send
106107
*/
107108
postBehavior: 'hang' | 'accept' | 'deduped' | 'tool' | 'task'
108-
postBodies: Array<{ message: string; userMessageId?: string; chatId?: string }>
109+
postBodies: Array<{ message: string; userMessageId?: string; chatId?: string; effort?: string }>
109110
pendingAdmissions: Map<string, () => void>
110111
abortSettlements: boolean[]
111112
abortBodies: CopilotChatAbortBody[]
@@ -692,6 +693,36 @@ describe('useChat remount send recovery', () => {
692693
}
693694
)
694695

696+
it.each([
697+
{ surface: 'a new chat', newChatPick: null, storedPick: null, sends: undefined },
698+
{ surface: 'a new chat', newChatPick: 'medium', storedPick: null, sends: 'medium' },
699+
{ surface: 'an existing chat', newChatPick: null, storedPick: null, sends: undefined },
700+
{ surface: 'an existing chat', newChatPick: null, storedPick: 'medium', sends: 'medium' },
701+
] as const)(
702+
'sends effort $sends from $surface only when the user picked one',
703+
async ({ surface, newChatPick, storedPick, sends }) => {
704+
state.postBehavior = 'accept'
705+
useMothershipEffortStore.getState().reset()
706+
if (newChatPick) useMothershipEffortStore.getState().setNewChatEffort(newChatPick)
707+
const { getResult } =
708+
surface === 'a new chat'
709+
? renderUseChat('ws-1', 'agent')
710+
: renderUseChatInChat('chat-effort', {
711+
id: 'chat-effort',
712+
title: 'Effort',
713+
messages: [],
714+
activeStreamId: null,
715+
resources: [],
716+
effort: storedPick,
717+
})
718+
await act(async () => {
719+
await getResult().sendMessage('Plan the launch')
720+
})
721+
expect(state.postBodies).toHaveLength(1)
722+
expect(state.postBodies[0].effort).toBe(sends)
723+
}
724+
)
725+
695726
it('identifies a Stop while an existing-chat query is still cancelling', async () => {
696727
const { getResult } = renderUseChatInChat('chat-a')
697728
let releaseCancellation!: () => void

‎apps/sim/executor/handlers/mothership/mothership-handler.test.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,6 +1095,13 @@ describe('MothershipBlockHandler', () => {
10951095
})
10961096
})
10971097

1098+
it('runs a block with no effort set at high', async () => {
1099+
fetchMock.mockResolvedValue(new Response(JSON.stringify({ content: 'done' })))
1100+
await handler.execute(context, block, { prompt: 'hello' })
1101+
const body = JSON.parse(String(fetchMock.mock.calls[0]?.[1]?.body))
1102+
expect(body.effort).toBe('high')
1103+
})
1104+
10981105
it.each([true, false])('uses deployment agent-event opt-in: %s', async (agentEvents) => {
10991106
context.stream = true
11001107
context.selectedOutputs = [`${block.id}_content`]

‎apps/sim/lib/mothership/chat/application/set-effort.integration.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ describe('a chat keeps the effort its owner picked', () => {
7878
await setChatEffort.execute({ principal: owner, input: { chatId: picked, effort: 'low' } })
7979

8080
expect(await loadEffort(untouched)).toBeNull()
81-
expect(await nextTurnEffort(untouched)).toBe('medium')
81+
expect(await nextTurnEffort(untouched)).toBe('high')
8282
expect(await nextTurnEffort(picked)).toBe('low')
8383
const [row] = await db
8484
.select({ config: copilotChats.config })
@@ -96,7 +96,7 @@ describe('a chat keeps the effort its owner picked', () => {
9696
it('reads a stored value outside the effort range as no pick', async () => {
9797
const chatId = await createChat({ effort: 'turbo' })
9898
expect(await loadEffort(chatId)).toBeNull()
99-
expect(await nextTurnEffort(chatId)).toBe('medium')
99+
expect(await nextTurnEffort(chatId)).toBe('high')
100100
})
101101

102102
it("refuses to change another user's chat in a shared workspace", async () => {

‎apps/sim/lib/mothership/chat/post.test.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -814,7 +814,7 @@ describe('handleUnifiedChatPost', () => {
814814
['xhigh', 'xhigh'],
815815
['max', 'xhigh'],
816816
['low', 'low'],
817-
['none', 'medium'],
817+
['none', 'high'],
818818
])(
819819
'enforces the default model and effort range on submitted %s effort',
820820
async (effort, expected) => {
@@ -841,8 +841,8 @@ describe('handleUnifiedChatPost', () => {
841841
)
842842

843843
it.each([
844-
{ stored: null, sent: undefined, runs: 'medium' },
845-
{ stored: 'high', sent: undefined, runs: 'high' },
844+
{ stored: null, sent: undefined, runs: 'high' },
845+
{ stored: 'medium', sent: undefined, runs: 'medium' },
846846
{ stored: 'low', sent: undefined, runs: 'low' },
847847
{ stored: 'high', sent: 'low', runs: 'low' },
848848
{ stored: 'high', sent: 'max', runs: 'xhigh' },

‎apps/sim/lib/mothership/model-options.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export const MOTHERSHIP_MODEL_OPTIONS = [
1818
] satisfies Array<{ value: ModelSelection['model']; label: string }>
1919

2020
/** The effort a chat or Sim Chat block runs at until the user picks one. */
21-
export const DEFAULT_MOTHERSHIP_EFFORT: MothershipEffort = 'medium'
21+
export const DEFAULT_MOTHERSHIP_EFFORT: MothershipEffort = 'high'
2222

2323
const SIMPLE_EFFORT_VALUES: ReadonlySet<MothershipEffort> = new Set([
2424
'low',

0 commit comments

Comments
 (0)