Code index: progress lost on failure, shared stop cancels other callers, any settings change starts a duplicate embedding run

Cerrado
#170 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
48/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
typescript
Área
backend, desktop

Línea de trabajo

Start with src/main/search/code_index.ts at runUpdate and update(), then inspect the cache invalidation listener in src/main/index.ts:124. Trace batching, shared callers’ abort signals and settings changes, and run the code-index tests or probes if available. Done means partial progress survives failures, one caller cannot cancel others, and unrelated settings changes do not trigger duplicate indexing.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

bug performance priority: medium severity: medium

Found in the 2026-10-07 code review and confirmed with probes.

Problems

  1. Nothing is saved until the end. runUpdate (src/main/search/code_index.ts:204-261) embeds every batch before committing anything. A failure in the last batch (rate limit, a stopped search_code) throws away every embedding already paid for. Probe: 70 files with the second batch failing → fileCount 0.
  2. One caller's stop cancels everyone. update() (:102-111) shares one run, but the run uses only the first caller's signal and progress callback. If the first caller stops, the second fails with aborted. A later caller's stop does nothing.
  3. Any settings change clears the cache. settings.on('change', () => codeIndexes.clear()) (src/main/index.ts:124) runs on every change, including theme, model and approval mode. A running update stays on the old instance. The next search_code/index:status creates a second instance from the stale file and starts a second full embedding run of the same project. Both write the same file, and the last one to finish wins. The status bar shows "not indexing" while the first run continues.

Fix

  • Commit each file's chunks after each batch, and call writeJson every N batches and in finally.
  • Give the shared run its own AbortController, aborted only when every waiting caller has aborted. Each caller races its own signal against the shared promise.
  • Clear the cache only when the OpenRouter key or endpoint changes.
Lenguaje dominante
TypeScript
Estrellas
2
Forks
2
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.