@@ -2,7 +2,6 @@ import { RunResult } from "sqlite3";
2
2
import { IContinueServerClient } from "../../continueServer/interface.js" ;
3
3
import { Chunk , IndexTag , IndexingProgressUpdate } from "../../index.js" ;
4
4
import { getBasename } from "../../util/index.js" ;
5
- import { getLanguageForFile } from "../../util/treeSitter.js" ;
6
5
import { DatabaseConnection , SqliteDb , tagToString } from "../refreshIndex.js" ;
7
6
import {
8
7
IndexResultType ,
@@ -12,6 +11,7 @@ import {
12
11
type CodebaseIndex ,
13
12
} from "../types.js" ;
14
13
import { chunkDocument , shouldChunk } from "./chunk.js" ;
14
+ import * as path from "path" ;
15
15
16
16
export class ChunkCodebaseIndex implements CodebaseIndex {
17
17
relativeExpectedTime : number = 1 ;
@@ -61,8 +61,11 @@ export class ChunkCodebaseIndex implements CodebaseIndex {
61
61
let accumulatedProgress = 0 ;
62
62
63
63
if ( results . compute . length > 0 ) {
64
+ const folderPath = results . compute [ 0 ] . path ;
65
+ const folderName = path . basename ( path . dirname ( folderPath ) ) ;
66
+
64
67
yield {
65
- desc : `Chunking ${ results . compute . length } ${ this . formatListPlurality ( "file" , results . compute . length ) } ` ,
68
+ desc : `Chunking files in ${ folderName } ` ,
66
69
status : "indexing" ,
67
70
progress : accumulatedProgress ,
68
71
} ;
@@ -171,35 +174,63 @@ export class ChunkCodebaseIndex implements CodebaseIndex {
171
174
}
172
175
173
176
private async computeChunks ( paths : PathAndCacheKey [ ] ) : Promise < Chunk [ ] > {
174
- const chunkLists = await Promise . all ( paths . map ( p => this . packToChunks ( p ) ) ) ;
177
+ const chunkLists = await Promise . all (
178
+ paths . map ( ( p ) => this . packToChunks ( p ) ) ,
179
+ ) ;
175
180
return chunkLists . flat ( ) ;
176
181
}
177
182
178
- private async insertChunks ( db : DatabaseConnection , tagString : string , chunks : Chunk [ ] ) {
183
+ private async insertChunks (
184
+ db : DatabaseConnection ,
185
+ tagString : string ,
186
+ chunks : Chunk [ ] ,
187
+ ) {
179
188
await new Promise < void > ( ( resolve , reject ) => {
180
189
db . db . serialize ( ( ) => {
181
190
db . db . exec ( "BEGIN" , ( err : Error | null ) => {
182
191
if ( err ) {
183
192
reject ( new Error ( "error creating transaction" , { cause : err } ) ) ;
184
193
}
185
194
} ) ;
186
- const chunksSQL = "INSERT INTO chunks (cacheKey, path, idx, startLine, endLine, content) VALUES (?, ?, ?, ?, ?, ?)" ;
187
- chunks . map ( c => {
188
- db . db . run ( chunksSQL , [ c . digest , c . filepath , c . index , c . startLine , c . endLine , c . content ] , ( result : RunResult , err : Error ) => {
189
- if ( err ) {
190
- reject ( new Error ( "error inserting into chunks table" , { cause : err } ) ) ;
191
- }
192
- } ) ;
193
- const chunkTagsSQL = "INSERT INTO chunk_tags (chunkId, tag) VALUES (last_insert_rowid(), ?)" ;
194
- db . db . run ( chunkTagsSQL , [ tagString ] , ( result : RunResult , err : Error ) => {
195
- if ( err ) {
196
- reject ( new Error ( "error inserting into chunk_tags table" , { cause : err } ) ) ;
197
- }
198
- } ) ;
195
+ const chunksSQL =
196
+ "INSERT INTO chunks (cacheKey, path, idx, startLine, endLine, content) VALUES (?, ?, ?, ?, ?, ?)" ;
197
+ chunks . map ( ( c ) => {
198
+ db . db . run (
199
+ chunksSQL ,
200
+ [ c . digest , c . filepath , c . index , c . startLine , c . endLine , c . content ] ,
201
+ ( result : RunResult , err : Error ) => {
202
+ if ( err ) {
203
+ reject (
204
+ new Error ( "error inserting into chunks table" , {
205
+ cause : err ,
206
+ } ) ,
207
+ ) ;
208
+ }
209
+ } ,
210
+ ) ;
211
+ const chunkTagsSQL =
212
+ "INSERT INTO chunk_tags (chunkId, tag) VALUES (last_insert_rowid(), ?)" ;
213
+ db . db . run (
214
+ chunkTagsSQL ,
215
+ [ tagString ] ,
216
+ ( result : RunResult , err : Error ) => {
217
+ if ( err ) {
218
+ reject (
219
+ new Error ( "error inserting into chunk_tags table" , {
220
+ cause : err ,
221
+ } ) ,
222
+ ) ;
223
+ }
224
+ } ,
225
+ ) ;
199
226
} ) ;
200
227
db . db . exec ( "COMMIT" , ( err : Error | null ) => {
201
228
if ( err ) {
202
- reject ( new Error ( "error while committing insert chunks transaction" , { cause : err } ) ) ;
229
+ reject (
230
+ new Error ( "error while committing insert chunks transaction" , {
231
+ cause : err ,
232
+ } ) ,
233
+ ) ;
203
234
} else {
204
235
resolve ( ) ;
205
236
}
0 commit comments