···66666767 // Check for bundle files in directory
6868 bundleFiles, _ := filepath.Glob(filepath.Join(config.BundleDir, "*.jsonl.zst"))
6969- bundleFiles = filterBundleFiles(bundleFiles) // ← ADD THIS
6969+ bundleFiles = filterBundleFiles(bundleFiles)
7070 hasBundleFiles := len(bundleFiles) > 0
71717272+ // Check if clone/download is in progress (look for .tmp files)
7373+ tmpFiles, _ := filepath.Glob(filepath.Join(config.BundleDir, "*.tmp"))
7474+ cloneInProgress := len(tmpFiles) > 0
7575+7276 needsRebuild := false
73777478 if err != nil {
7579 // Index doesn't exist or is invalid
7680 if hasBundleFiles {
7777- // We have bundles but no index - need to rebuild
7878- config.Logger.Printf("No valid index found, but detected %d bundle files", len(bundleFiles))
7979- needsRebuild = true
8181+ if cloneInProgress {
8282+ config.Logger.Printf("Clone/download in progress, skipping auto-rebuild")
8383+ } else {
8484+ // We have bundles but no index - need to rebuild
8585+ config.Logger.Printf("No valid index found, but detected %d bundle files", len(bundleFiles))
8686+ needsRebuild = true
8787+ }
8088 } else {
8189 // No index and no bundles - create fresh index
8290 config.Logger.Printf("Creating new index at %s", indexPath)
···919992100 // Check if there are bundle files not in the index
93101 if hasBundleFiles && len(bundleFiles) > index.Count() {
9494- config.Logger.Printf("Detected %d bundle files but index only has %d entries - rebuilding",
9595- len(bundleFiles), index.Count())
9696- needsRebuild = true
102102+ if cloneInProgress {
103103+ config.Logger.Printf("Clone/download in progress (%d .tmp files), skipping auto-rebuild", len(tmpFiles))
104104+ } else {
105105+ config.Logger.Printf("Detected %d bundle files but index only has %d entries - rebuilding",
106106+ len(bundleFiles), index.Count())
107107+ needsRebuild = true
108108+ }
97109 }
98110 }
99111···168180 bundles := index.GetBundles()
169181 missingHashes := 0
170182 for i, meta := range bundles {
171171- if meta.ContentHash == "" { // ← Changed from meta.Hash
183183+ if meta.ContentHash == "" {
172184 missingHashes++
173185 }
174174- if i > 0 && meta.Hash == "" { // ← This is now the chain hash
186186+ if i > 0 && meta.Hash == "" {
175187 missingHashes++
176188 }
177189 }