Skip to content

Commit 299acf9

Browse files
committed
fix(organization): keep a custom date range when Home restores Search results
organizationHomeParsers already reads from/to, but OrganizationHomeContent passed only source and updated to searchFiltersFromParams, so a Home URL with updated=custom restored an unbounded search. Pass from/to through, matching the workspace results view, and add them to the effect deps.
1 parent deaa7a2 commit 299acf9

2 files changed

Lines changed: 22 additions & 5 deletions

File tree

‎apps/sim/app/o/[organizationId]/home/organization-home.test.tsx‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -892,6 +892,23 @@ it('restores an explicitly selected search panel on empty Home without reusing t
892892
expect(mocks.send).not.toHaveBeenCalled()
893893
})
894894

895+
it('restores a custom date range with the search panel', async () => {
896+
mocks.activeResource = 'search:organization:organization-a'
897+
await act(async () =>
898+
renderHome(<OrganizationHome />, '?q=Orion&updated=custom&from=2026-09-01&to=2026-09-03')
899+
)
900+
expect(mocks.addResource).toHaveBeenCalledWith(
901+
expect.objectContaining({
902+
search: expect.objectContaining({
903+
filters: {
904+
modifiedAfter: new Date(2026, 8, 1).toISOString(),
905+
modifiedBefore: new Date(2026, 8, 4, 0, 0, 0, -1).toISOString(),
906+
},
907+
}),
908+
})
909+
)
910+
})
911+
895912
it('does not reopen closed search results merely because a query remains in the URL', async () => {
896913
await act(async () => renderHome(<OrganizationHome />, '?searchLevel=adaptive&q=Orion'))
897914
expect(mocks.addResource).not.toHaveBeenCalled()

‎apps/sim/app/o/[organizationId]/home/organization-home.tsx‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,8 @@ function OrganizationHomeContent({
8484
const rememberedMode = useOrganizationChatModeStore(
8585
(state) => state.modes[`${userId}:${organization.id}`]
8686
)
87-
const [{ q, source, updated, searchLevel: urlSearchLevel }, setSearchParams] = useQueryStates(
88-
organizationHomeParsers,
89-
organizationSearchUrlKeys
90-
)
87+
const [{ q, source, updated, from, to, searchLevel: urlSearchLevel }, setSearchParams] =
88+
useQueryStates(organizationHomeParsers, organizationSearchUrlKeys)
9189
const rememberMode = useOrganizationChatModeStore((state) => state.setMode)
9290
const [selectedMode, setSelectedMode] = useState<ChatRequestMode | null>(null)
9391
const planEnabled = useFeatureFlag('mothership-plan-mode')
@@ -143,7 +141,7 @@ function OrganizationHomeContent({
143141
const resource = createSearchResource({
144142
scope: { kind: 'organization', organizationId: organization.id },
145143
query: q.trim(),
146-
filters: searchFiltersFromParams({ source, updated }, Date.now()),
144+
filters: searchFiltersFromParams({ source, updated, from, to }, Date.now()),
147145
})
148146
if (
149147
controller.activeResourceParam !== resource.id ||
@@ -156,6 +154,8 @@ function OrganizationHomeContent({
156154
q,
157155
source,
158156
updated,
157+
from,
158+
to,
159159
organization.id,
160160
controller.activeResourceParam,
161161
chat.resources,

0 commit comments

Comments
 (0)