Skip to content

Commit 575223d

Browse files
committed
revert(search): return Ask Sim to prefill, storing raw prose
Auto-send still loses the message on cross-route navigation — use-chat's cleanup abort fires during Home's mount-settling effect cycle. Prefill restored, but via LandingPromptStorage directly so free-form queries are never mentionified into @ chips.
1 parent 54aa354 commit 575223d

2 files changed

Lines changed: 10 additions & 14 deletions

File tree

apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/search-modal/search-modal.test.tsx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import { act } from 'react'
55
import { createRoot, type Root } from 'react-dom/client'
66
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
7-
import { MothershipHandoffStorage } from '@/lib/core/utils/browser-storage'
7+
import { LandingPromptStorage } from '@/lib/core/utils/browser-storage'
88
import {
99
MOTHERSHIP_SEND_MESSAGE_EVENT,
1010
type MothershipSendMessageDetail,
@@ -163,10 +163,7 @@ describe('SearchModal', () => {
163163

164164
expect(onOpenChange).toHaveBeenCalledWith(false)
165165
expect(mockPush).toHaveBeenCalledWith('/workspace/workspace-1/home')
166-
expect(MothershipHandoffStorage.consume('workspace-1')).toEqual({
167-
message: 'plan our Slack launch week',
168-
contexts: [],
169-
})
166+
expect(LandingPromptStorage.consume()).toBe('plan our Slack launch week')
170167
})
171168

172169
it('returns to search results when Tab is pressed again in ask mode', async () => {
@@ -298,7 +295,7 @@ describe('SearchModal', () => {
298295

299296
expect(receivedMessages).toEqual(['summarize this workspace'])
300297
expect(mockPush).not.toHaveBeenCalled()
301-
expect(MothershipHandoffStorage.consume('workspace-1')).toBeNull()
298+
expect(LandingPromptStorage.consume()).toBeNull()
302299
} finally {
303300
window.removeEventListener(MOTHERSHIP_SEND_MESSAGE_EVENT, handleMessage)
304301
}
@@ -694,7 +691,7 @@ describe('SearchModal', () => {
694691

695692
it('keeps the palette open when the query handoff cannot be persisted', async () => {
696693
const onOpenChange = vi.fn()
697-
const storeSpy = vi.spyOn(MothershipHandoffStorage, 'store').mockReturnValue(false)
694+
const storeSpy = vi.spyOn(LandingPromptStorage, 'store').mockReturnValue(false)
698695

699696
try {
700697
await act(async () => {

apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/search-modal/search-modal.tsx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ import { usePostHog } from 'posthog-js/react'
4141
import { createPortal } from 'react-dom'
4242
import { supportsAtomicBrowserPanelOcclusion } from '@/lib/browser-agent/transport'
4343
import { isChatEnabled } from '@/lib/core/config/env-flags'
44-
import { MothershipHandoffStorage } from '@/lib/core/utils/browser-storage'
44+
import { LandingPromptStorage } from '@/lib/core/utils/browser-storage'
4545
import { sendMothershipMessage } from '@/lib/mothership/events'
4646
import { captureEvent } from '@/lib/posthog/client'
4747
import { toSearchToken } from '@/lib/search/tokens'
@@ -844,12 +844,11 @@ function SearchModalContent({
844844
const sentToMountedHome = window.location.pathname === homeHref && sendMothershipMessage(query)
845845

846846
if (!sentToMountedHome) {
847-
/* One-shot auto-send handoff: Home's mount consumer sends it on arrival,
848-
so both routes deliver the raw query identically. use-chat's queued
849-
send dispatch now survives the mount-settling effect cycle that used
850-
to silently abort programmatic sends (the old reason this was a
851-
prefill). */
852-
if (!MothershipHandoffStorage.store({ message: query }, workspaceId)) {
847+
/* Prefill, not auto-send: sends started during Home's mount-settling
848+
window are still silently aborted by use-chat's cleanup effect, so a
849+
MothershipHandoffStorage handoff would vanish (verified live). Stored
850+
raw — user prose is never mentionified into @ chips. */
851+
if (!LandingPromptStorage.store(query)) {
853852
logger.warn('Failed to persist command palette query for a new chat', {
854853
workspaceId,
855854
})

0 commit comments

Comments
 (0)