Skip to content

Commit 7e2966e

Browse files
author
razvan
committed
fix: cumulative Processed counter in index_status + register JS parser
- index_status.Processed was being overwritten with session-only doneFiles, causing incremental re-indexes to reset the counter (e.g. 232 → 1) - Now captures baseProcessed before each language run and accumulates: Processed = baseProcessed + doneFiles - Full re-index (recreate=true or totalFiles >= diskTotal) resets base to 0 - Register JavaScript parser in daemon imports
1 parent 31aa1f3 commit 7e2966e

3 files changed

Lines changed: 31 additions & 3 deletions

File tree

cmd/rag-code-mcp/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717
)
1818

1919
var (
20-
Version = "2.1.66"
20+
Version = "2.1.67"
2121
Commit = "none"
2222
Date = "24.10.2025"
2323
)

internal/daemon/run.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
_ "github.com/doITmagic/rag-code-mcp/pkg/parser/docs"
2525
_ "github.com/doITmagic/rag-code-mcp/pkg/parser/go"
2626
_ "github.com/doITmagic/rag-code-mcp/pkg/parser/html"
27+
_ "github.com/doITmagic/rag-code-mcp/pkg/parser/javascript"
2728
_ "github.com/doITmagic/rag-code-mcp/pkg/parser/php"
2829
_ "github.com/doITmagic/rag-code-mcp/pkg/parser/python"
2930
"github.com/doITmagic/rag-code-mcp/pkg/storage"

internal/service/engine/engine.go

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -952,6 +952,22 @@ func (e *Engine) IndexWorkspace(ctx context.Context, path string, recreate bool)
952952
diskTotal := fileCounts[lang]
953953
collection := wctx.CollectionName(lang)
954954
logger.Instance.Info("[IDX] ws=%s lang=%s ▶ starting (on_disk=%d)", wsName, lang, diskTotal)
955+
956+
// Capture the already-processed count before this run starts.
957+
// For incremental runs (only changed files), we accumulate on top of
958+
// whatever was already indexed in Qdrant. For a full re-index
959+
// (recreate=true, or all files changed), we reset to 0.
960+
// baseProcessed is captured once per language, before the Progress
961+
// callback fires, so it's safe to close over it.
962+
baseProcessed := s.Languages[lang].Processed
963+
if recreate {
964+
baseProcessed = 0
965+
}
966+
// firstTick is used to detect on the first Progress callback whether
967+
// this is a full re-index (totalFiles >= diskTotal) so we can reset
968+
// baseProcessed to 0 and avoid double-counting.
969+
firstTick := true
970+
955971
err := e.indexer.IndexWorkspace(ctx, wctx.Root, collection, indexer.Options{
956972
Language: lang,
957973
WorkspaceName: wsName,
@@ -962,10 +978,21 @@ func (e *Engine) IndexWorkspace(ctx context.Context, path string, recreate bool)
962978
if doneFiles%10 != 0 && doneFiles != totalFiles {
963979
return
964980
}
981+
// On the first tick, decide if this is a full re-index.
982+
// If totalFiles covers all on-disk files, reset base to 0
983+
// so we don't double-count the existing Processed value.
984+
if firstTick {
985+
firstTick = false
986+
if diskTotal > 0 && totalFiles >= diskTotal {
987+
baseProcessed = 0
988+
}
989+
}
965990
ls := s.Languages[lang]
966991
ls.OnDisk = diskTotal // real total files on disk
967-
ls.Changed = totalFiles // files that needed re-indexing
968-
ls.Processed = doneFiles
992+
ls.Changed = totalFiles // files that needed re-indexing this run
993+
// Cumulative total: for incremental runs add to the existing
994+
// DB count; for full re-indexes (base=0) start from scratch.
995+
ls.Processed = baseProcessed + doneFiles
969996
s.Languages[lang] = ls
970997
indexer.SaveIndexStatus(wctx.Root, s)
971998
},

0 commit comments

Comments
 (0)