Skip to content

Commit bb74206

Browse files
committed
remove check new files necessary
1 parent 46eba97 commit bb74206

File tree

3 files changed

+0
-171
lines changed

3 files changed

+0
-171
lines changed

backend/src/__tests__/request-files-prompt.test.ts

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ import {
88
it,
99
} from 'bun:test'
1010

11-
// Import the entire module to spy on its exports
12-
import * as checkNewFilesNecessaryModule from '../find-files/check-new-files-necessary'
1311
import * as OriginalRequestFilesPromptModule from '../find-files/request-files-prompt'
1412
import * as geminiWithFallbacksModule from '../llm-apis/gemini-with-fallbacks'
1513

@@ -18,17 +16,6 @@ import type { CodebuffMessage } from '@codebuff/common/types/message'
1816
import type { ProjectFileContext } from '@codebuff/common/util/file'
1917
import type { Mock } from 'bun:test'
2018

21-
// Restore module-level mocks using bunMockFn for the mock implementations
22-
bunMockFn.module('../find-files/check-new-files-necessary', () => ({
23-
checkNewFilesNecessary: bunMockFn(() =>
24-
Promise.resolve({
25-
newFilesNecessary: true,
26-
response: 'YES',
27-
duration: 100,
28-
}),
29-
),
30-
}))
31-
3219
bunMockFn.module('../llm-apis/gemini-with-fallbacks', () => ({
3320
promptFlashWithFallbacks: bunMockFn(() =>
3421
Promise.resolve('file1.ts\nfile2.ts'),
@@ -121,18 +108,6 @@ describe('requestRelevantFiles', () => {
121108
'getCustomFilePickerConfigForOrg',
122109
).mockResolvedValue(null)
123110

124-
// Reset behavior and clear call history for module mocks
125-
const checkNewFilesNecessaryMock =
126-
checkNewFilesNecessaryModule.checkNewFilesNecessary as Mock<
127-
typeof checkNewFilesNecessaryModule.checkNewFilesNecessary
128-
>
129-
checkNewFilesNecessaryMock.mockResolvedValue({
130-
newFilesNecessary: true,
131-
response: 'YES',
132-
duration: 100,
133-
})
134-
checkNewFilesNecessaryMock.mockClear()
135-
136111
const promptFlashWithFallbacksMock =
137112
geminiWithFallbacksModule.promptFlashWithFallbacks as Mock<
138113
typeof geminiWithFallbacksModule.promptFlashWithFallbacks
@@ -265,35 +240,4 @@ describe('requestRelevantFiles', () => {
265240
)
266241
expect(getCustomFilePickerConfigForOrgSpy).toHaveBeenCalled()
267242
})
268-
269-
it('should return null if checkNewFilesNecessary returns false', async () => {
270-
// Override the module mock for this specific test case
271-
;(
272-
checkNewFilesNecessaryModule.checkNewFilesNecessary as Mock<
273-
typeof checkNewFilesNecessaryModule.checkNewFilesNecessary
274-
>
275-
).mockResolvedValue({
276-
newFilesNecessary: false,
277-
response: 'NO',
278-
duration: 50,
279-
})
280-
281-
const result = await OriginalRequestFilesPromptModule.requestRelevantFiles(
282-
{ messages: mockMessages, system: mockSystem },
283-
mockFileContext,
284-
mockAssistantPrompt,
285-
mockAgentStepId,
286-
mockClientSessionId,
287-
mockFingerprintId,
288-
mockUserInputId,
289-
mockUserId,
290-
mockRepoId,
291-
)
292-
293-
expect(result).toBeNull()
294-
expect(
295-
geminiWithFallbacksModule.promptFlashWithFallbacks,
296-
).not.toHaveBeenCalled()
297-
expect(getCustomFilePickerConfigForOrgSpy).toHaveBeenCalled()
298-
})
299243
})

backend/src/find-files/check-new-files-necessary.ts

Lines changed: 0 additions & 76 deletions
This file was deleted.

backend/src/find-files/request-files-prompt.ts

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import { getAllFilePaths } from '@codebuff/common/project-file-tree'
1212
import { and, eq } from 'drizzle-orm'
1313
import { range, shuffle, uniq } from 'lodash'
1414

15-
import { checkNewFilesNecessary } from './check-new-files-necessary'
1615
import { CustomFilePickerConfigSchema } from './custom-file-picker-config'
1716
import { promptFlashWithFallbacks } from '../llm-apis/gemini-with-fallbacks'
1817
import { promptAiSdk } from '../llm-apis/vercel-ai-sdk/ai-sdk'
@@ -160,41 +159,6 @@ export async function requestRelevantFiles(
160159
: JSON.stringify(lastMessage.content)
161160
: ''
162161

163-
const newFilesNecessaryPromise = assistantPrompt
164-
? Promise.resolve({ newFilesNecessary: true, response: 'N/A', duration: 0 })
165-
: checkNewFilesNecessary(
166-
messagesExcludingLastIfByUser,
167-
system,
168-
clientSessionId,
169-
fingerprintId,
170-
userInputId,
171-
userPrompt,
172-
userId,
173-
).catch((error) => {
174-
logger.error({ error }, 'Error checking new files necessary')
175-
return { newFilesNecessary: true, response: 'N/A', duration: 0 }
176-
})
177-
178-
// Await newFilesNecessaryPromise first
179-
const newFilesNecessaryResult = await newFilesNecessaryPromise
180-
const {
181-
newFilesNecessary,
182-
response: newFilesNecessaryResponse,
183-
duration: newFilesNecessaryDuration,
184-
} = newFilesNecessaryResult
185-
186-
if (!newFilesNecessary) {
187-
logger.info(
188-
{
189-
newFilesNecessary,
190-
response: newFilesNecessaryResponse,
191-
duration: newFilesNecessaryDuration,
192-
},
193-
'requestRelevantFiles: No new files necessary, keeping current files',
194-
)
195-
return null // Early return if no new files are necessary
196-
}
197-
198162
// Only proceed to get key files if new files are necessary
199163
const keyPrompt = generateKeyRequestFilesPrompt(
200164
userPrompt,
@@ -242,9 +206,6 @@ export async function requestRelevantFiles(
242206
logger.info(
243207
{
244208
files,
245-
newFilesNecessary,
246-
newFilesNecessaryResponse,
247-
newFilesNecessaryDuration,
248209
customFilePickerConfig: customFilePickerConfig,
249210
modelName: customFilePickerConfig?.modelName,
250211
orgId,

0 commit comments

Comments
 (0)