Skip to content

Commit 41e7c9e

Browse files
committed
fix: reconcile staging search and file contracts after rebase
1 parent 183d432 commit 41e7c9e

20 files changed

Lines changed: 90 additions & 41 deletions

File tree

‎apps/sim/app/api/copilot/tools/execute/route.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { getErrorMessage } from '@sim/utils/errors'
33
import { type NextRequest, NextResponse } from 'next/server'
44
import { copilotToolExecuteInternalBodySchema } from '@/lib/api/contracts/copilot'
55
import { validationErrorResponse } from '@/lib/api/server'
6+
import { withRouteHandler } from '@/lib/core/utils/with-route-handler'
67
import { toolResultForModel } from '@/lib/mothership/chat/sim-key-redaction'
78
import { prepareCopilotEnvironmentContext } from '@/lib/mothership/environment-context'
89
import { MothershipStreamV1ToolOutcome } from '@/lib/mothership/generated/mothership-stream-v1'
@@ -20,7 +21,6 @@ import type { ToolCallResult } from '@/lib/mothership/request/types'
2021
import { ensureHandlersRegistered, toolRequiresApprovalLane } from '@/lib/mothership/tool-executor'
2122
import { executeTool } from '@/lib/mothership/tool-executor/executor'
2223
import { TOOL_EFFECT_PHASE } from '@/lib/mothership/tool-executor/types'
23-
import { withRouteHandler } from '@/lib/core/utils/with-route-handler'
2424
import type { ResolvedSecretTraceRegistry } from '@/executor/utils/resolved-secret-trace-registry'
2525

2626
const logger = createLogger('CopilotToolExecuteInternalAPI')

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import { useEffect, useRef, useState } from 'react'
44
import { Chip, ChipDropdown, ComposerActionButton, cn, Tooltip, toast } from '@sim/emcn'
55
import { ArrowUp, Paperclip, Plus, Search, Slash, StopFilled } from '@sim/emcn/icons'
6+
import { escapeRegExp } from '@sim/utils/string'
67
import { useQueries } from '@tanstack/react-query'
78
import {
89
ASSISTANT_IMAGE_ACCEPT_ATTRIBUTE,
@@ -25,10 +26,7 @@ import {
2526
import { organizationSkillOptions } from '@/app/workspace/[workspaceId]/home/components/user-input/components/skills-menu-dropdown/organization-skill-options'
2627
import type { ChatRequestMode } from '@/app/workspace/[workspaceId]/home/types'
2728
import type { useFileAttachments } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/user-input/hooks/use-file-attachments'
28-
import {
29-
escapeRegex,
30-
SKILL_CHIP_TRIGGER,
31-
} from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/user-input/utils'
29+
import { SKILL_CHIP_TRIGGER } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/user-input/utils'
3230
import { getSkillsQueryOptions } from '@/hooks/queries/skills'
3331
import { useWorkspacesQuery } from '@/hooks/queries/workspace'
3432
import { useAnimatedPlaceholder } from '@/hooks/use-animated-placeholder'
@@ -131,7 +129,7 @@ export function Composer({
131129
for (const context of restoredContexts) {
132130
if (context.kind !== 'skill') continue
133131
restoredText = restoredText.replace(
134-
new RegExp(`(^|\\s)/${escapeRegex(context.label)}(?=\\s|$)`, 'g'),
132+
new RegExp(`(^|\\s)/${escapeRegExp(context.label)}(?=\\s|$)`, 'g'),
135133
`$1${SKILL_CHIP_TRIGGER}${context.label}`
136134
)
137135
}

‎apps/sim/app/o/[organizationId]/search/search-results-view.test.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ describe('results-only search layout', () => {
145145
const filters = mocks.search.mock.calls.at(-1)![2]
146146
expect(filters.source).toBe('slack')
147147
expect(mocks.searchChange).toHaveBeenLastCalledWith({ scope, query: 'Orion', filters })
148-
expect(mocks.search).toHaveBeenLastCalledWith(scope, 'Orion', filters, undefined)
148+
expect(mocks.search).toHaveBeenLastCalledWith(scope, 'Orion', filters, 20)
149149
})
150150
it('summarizes the selected document through Home without duplicating search state', async () => {
151151
await render('?q=Orion')

‎apps/sim/app/o/[organizationId]/search/search.test.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ async function editDraft(value: string) {
163163
function expectVisibleQuery(query: string) {
164164
expect(searchInput().value).toBe(query)
165165
expect(container.querySelector('a[data-source-link]')?.textContent).toBe(`${query} launch plan`)
166-
expect(mocks.search).toHaveBeenLastCalledWith(scope, query, {}, undefined)
166+
expect(mocks.search).toHaveBeenLastCalledWith(scope, query, {}, 20)
167167
expect(document.activeElement).toBe(searchInput())
168168
}
169169

‎apps/sim/app/workspace/[workspaceId]/home/components/knowledge-search-results/knowledge-search-results.tsx‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,13 +187,16 @@ function SearchResults({
187187
scope,
188188
awaitingRange ? '' : query,
189189
searchFilters,
190-
topK ?? (expanded
191-
? WORKSPACE_KNOWLEDGE_SEARCH_LIMITS.expanded
192-
: WORKSPACE_KNOWLEDGE_SEARCH_LIMITS.initial)
190+
topK ??
191+
(expanded
192+
? WORKSPACE_KNOWLEDGE_SEARCH_LIMITS.expanded
193+
: WORKSPACE_KNOWLEDGE_SEARCH_LIMITS.initial)
193194
)
194195
/** A full first page may collapse to few cards, yet more documents may still match. */
195196
const mayHaveMore =
196-
topK === undefined && !expanded && (search?.results.length ?? 0) >= WORKSPACE_KNOWLEDGE_SEARCH_LIMITS.initial
197+
topK === undefined &&
198+
!expanded &&
199+
(search?.results.length ?? 0) >= WORKSPACE_KNOWLEDGE_SEARCH_LIMITS.initial
197200
const { data: overview } = useSearchSourceOverview(scope)
198201
const indexing = (overview?.providers ?? [])
199202
.filter((provider) => provider.isSyncing)

‎apps/sim/app/workspace/[workspaceId]/home/components/mothership-view/components/resource-content/resource-content.tsx‎

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
'use client'
22

33
import { lazy, memo, Suspense, useCallback, useEffect, useMemo, useRef, useState } from 'react'
4-
import { OverflowText, PlayOutline, Skeleton, TabStripAction, Tooltip, toast } from '@sim/emcn'
4+
import {
5+
Button,
6+
OverflowText,
7+
PlayOutline,
8+
Skeleton,
9+
TabStripAction,
10+
Tooltip,
11+
toast,
12+
} from '@sim/emcn'
513
import {
614
Download,
715
FileX,
@@ -640,16 +648,16 @@ function EmbeddedFileActions({
640648
return (
641649
<>
642650
{file && !isUpload && (
643-
<Tooltip.Root>
644-
<Tooltip.Trigger asChild>
645-
<TabStripAction variant='subtle' onClick={handleOpenInFiles} aria-label='Open in files'>
646-
<SquareArrowUpRight className={RESOURCE_TAB_ICON_CLASS} />
647-
</TabStripAction>
648-
</Tooltip.Trigger>
649-
<Tooltip.Content side='bottom'>
650-
<p>Open in files</p>
651-
</Tooltip.Content>
652-
</Tooltip.Root>
651+
<Tooltip.Root>
652+
<Tooltip.Trigger asChild>
653+
<TabStripAction variant='subtle' onClick={handleOpenInFiles} aria-label='Open in files'>
654+
<SquareArrowUpRight className={RESOURCE_TAB_ICON_CLASS} />
655+
</TabStripAction>
656+
</Tooltip.Trigger>
657+
<Tooltip.Content side='bottom'>
658+
<p>Open in files</p>
659+
</Tooltip.Content>
660+
</Tooltip.Root>
653661
)}
654662
<Tooltip.Root>
655663
<Tooltip.Trigger asChild>

‎apps/sim/app/workspace/[workspaceId]/home/components/user-input/hooks/use-skill-auto-mention.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useCallback, useMemo, useRef } from 'react'
22
import { escapeRegExp } from '@sim/utils/string'
3-
import { SKILL_CHIP_TRIGGER } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/user-input/utils'
43
import { isBuiltinSkillId } from '@/lib/workflows/skills/builtin-skills'
4+
import { SKILL_CHIP_TRIGGER } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/user-input/utils'
55
import type { McpServer } from '@/hooks/queries/mcp'
66
import type { SkillDefinition } from '@/hooks/queries/skills'
77
import type { ChatContext } from '@/stores/panel'

‎apps/sim/app/workspace/[workspaceId]/home/search-params.ts‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,21 @@ function endOfLocalDay(day: Date): Date {
6161

6262
/** Resolve the shared source/recency controls once for a particular search. */
6363
export function searchFiltersFromParams(
64-
params: { source: string | null; updated: (typeof UPDATED_WINDOWS)[number]['id']; from?: Date | null; to?: Date | null },
64+
params: {
65+
source: string | null
66+
updated: (typeof UPDATED_WINDOWS)[number]['id']
67+
from?: Date | null
68+
to?: Date | null
69+
},
6570
searchedAt: number
6671
): WorkspaceSearchFilters {
6772
const days = UPDATED_WINDOWS.find((entry) => entry.id === params.updated)?.days
6873
return {
6974
...(params.updated === 'custom' && params.from && params.to
70-
? { modifiedAfter: startOfLocalDay(params.from).toISOString(), modifiedBefore: endOfLocalDay(params.to).toISOString() }
75+
? {
76+
modifiedAfter: startOfLocalDay(params.from).toISOString(),
77+
modifiedBefore: endOfLocalDay(params.to).toISOString(),
78+
}
7179
: {}),
7280
...(params.source ? { source: params.source } : {}),
7381
...(days ? { modifiedAfter: new Date(searchedAt - days * 86_400_000).toISOString() } : {}),

‎apps/sim/lib/knowledge/application/search.test.ts‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -886,11 +886,8 @@ describe('knowledge search application use case', () => {
886886
expect(result.results[1]).toMatchObject({ similarity: 0.95, rankScore: 1 / 62 })
887887
})
888888

889-
it('assigns contiguous ranks after unreadable documents are removed', async () => {
890-
mocks.executeSearch.mockResolvedValue([
891-
row({ id: 'hidden', documentId: 'unreadable', rankScore: 0.9, rank: 1 }),
892-
row({ id: 'visible', rankScore: 0.8, rank: 2 }),
893-
])
889+
it('assigns contiguous ranks to the authorized retrieval rows', async () => {
890+
mocks.executeSearch.mockResolvedValue([row({ id: 'visible', rankScore: 0.8, rank: 2 })])
894891

895892
const result = await search()
896893

‎apps/sim/lib/knowledge/search/queries.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ import {
5353
vectorCandidatePoolLimit,
5454
visibleDocumentsQuery,
5555
} from '@/lib/knowledge/search/queries'
56-
import { forgetIndexedVectorSources } from '@/lib/knowledge/search/source-vector-indexes'
5756
import { RRF_K } from '@/lib/knowledge/search/recency'
57+
import { forgetIndexedVectorSources } from '@/lib/knowledge/search/source-vector-indexes'
5858
import type { StructuredFilter } from '@/lib/knowledge/types'
5959

6060
/**

0 commit comments

Comments
 (0)