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

クローズ
#170 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
48/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
typescript
領域
backend, desktop

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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.
主要言語
TypeScript
スター
2
フォーク
2
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。