Skip to content

Commit b7f5f1b

Browse files
committed
fix(home): keep the composer on the live search query, not a mount-time snapshot
1 parent 1c03b3a commit b7f5f1b

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

  • apps/sim/app/workspace/[workspaceId]/home

‎apps/sim/app/workspace/[workspaceId]/home/home.tsx‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -185,11 +185,15 @@ export function Home({ chatId, userName, userId }: HomeProps) {
185185
},
186186
[setSearchQueryParam, setSearchFilters]
187187
)
188-
/** A link that carries a query opens in Search mode with the query in the box. */
189-
const [initialSearchQuery] = useState(searchQuery)
188+
/**
189+
* A URL that carries a query opens in Search mode with the query in the box,
190+
* whether it arrived by link or by navigating back to it; the composer
191+
* follows the live query the same way (below), so the box and the results
192+
* never show two different queries.
193+
*/
190194
useEffect(() => {
191-
if (initialSearchQuery) useMothershipModeStore.getState().setMode('search')
192-
}, [initialSearchQuery])
195+
if (searchQuery) useMothershipModeStore.getState().setMode('search')
196+
}, [searchQuery])
193197
const composerMode = useMothershipModeStore((state) => state.mode)
194198
/** The bases an Ask turn is grounded in; read through a ref so a list refresh never rebuilds the submit handler. */
195199
const { data: knowledgeBases = EMPTY_KNOWLEDGE_BASES } = useKnowledgeBasesQuery(workspaceId)
@@ -758,7 +762,7 @@ export function Home({ chatId, userName, userId }: HomeProps) {
758762
>
759763
<UserInput
760764
ref={initialViewUserInputRef}
761-
defaultValue={initialPrompt || initialSearchQuery}
765+
defaultValue={initialPrompt || searchQuery}
762766
draftScopeKey={draftScopeKey}
763767
onSubmit={handleSubmit}
764768
canSearch

0 commit comments

Comments
 (0)