Skip to content
This repository was archived by the owner on Aug 1, 2025. It is now read-only.

Commit b933f52

Browse files
authored
chore(chat): clean up code on large file detection (#8032)
clean up code on large file detection ## Test plan Green CI <!-- Required. See https://docs-legacy.sourcegraph.com/dev/background-information/testing_principles. -->
1 parent dce7ce6 commit b933f52

File tree

2 files changed

+2
-14
lines changed

2 files changed

+2
-14
lines changed

vscode/src/editor/utils/editor-context.test.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,11 +138,9 @@ describe('filterContextItemFiles', () => {
138138

139139
expect(filtered).toEqual([
140140
{
141-
isTooLarge: true,
142-
isTooLargeReason: 'File exceeds 1MB size limit',
143-
size: 222222,
141+
size: 222222, // Math.floor(1000001 / 4.5)
144142
type: 'file',
145-
uri: largeFile.uri,
143+
uri: largeFile.uri, // Use the same URI reference
146144
},
147145
])
148146
})

vscode/src/editor/utils/editor-context.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -378,10 +378,6 @@ export async function filterContextItemFiles(
378378
if (cf.type !== 'file' || fileStat?.type !== vscode.FileType.File) {
379379
continue
380380
}
381-
382-
// Mark files larger than 1MB as too large but still include them
383-
const isTooLarge = fileStat.size > 1000000
384-
385381
// TODO (bee) consider a better way to estimate the token size of a file
386382
// We cannot get the exact token size without parsing the file, which is expensive.
387383
// Instead, we divide the file size in bytes by 4.5 for non-markdown as a rough estimate of the token size.
@@ -393,12 +389,6 @@ export async function filterContextItemFiles(
393389
// the file content on-demand instead of in bulk. We would then label the file size more accurately with the tokenizer.
394390
cf.size = Math.floor(fileStat.size / (cf.uri.fsPath.endsWith('.md') ? 3.5 : 4.5))
395391

396-
// Mark the file as too large if it exceeds the size limit
397-
if (isTooLarge) {
398-
cf.isTooLarge = true
399-
cf.isTooLargeReason = 'File exceeds 1MB size limit'
400-
}
401-
402392
filtered.push(cf)
403393
}
404394
return filtered

0 commit comments

Comments
 (0)