Skip to content

Fix all search investigation issues#31

Open
syuya2036 wants to merge 3 commits intofeature/#9from
claude/fix-search-issues-62eKv
Open

Fix all search investigation issues#31
syuya2036 wants to merge 3 commits intofeature/#9from
claude/fix-search-issues-62eKv

Conversation

@syuya2036
Copy link
Copy Markdown
Collaborator

claude added 3 commits March 7, 2026 13:13
## 致命的バグ (4.1)
- 4.1.1: trigger_search を cx.spawn_in + background_executor で非同期化
- 4.1.2: SearchQuery 構造体を導入し、検索オプション (match_case, match_whole_word, use_regex, search_type) をバックエンドまで伝播
- 4.1.4: SearchResult に match_start/match_end を追加、group_results でも伝播

## パフォーマンス (4.2)
- 4.2.2: search_bar.rs の render 内副作用を on_search_input_changed イベントハンドラに移動
- 4.2.3: Tantivy TopDocs 上限を 50 → 200 に拡大
- 4.2.4: RipgrepBackend を build_parallel() で並列検索に変更
- 4.2.5: search_results_map (HashMap) による O(1) 検索結果参照
- 4.2.6: row.rs / snippets.rs で O(n) の iter().find() を HashMap 参照に置換
- 4.2.7: IndexManager の二重ファイルツリー走査を単一パスに統合

## 設計上の問題 (4.3)
- 4.3.5: open_preview を cx.spawn_in + background_executor で非同期化
- 4.3.6: search_bar の入力変更を on_search_input_changed メソッドに集約
- 4.3.7: process_changes でディレクトリの is_dir() チェックを追加
- 4.3.8: RipgrepBackend で use_regex=false 時に regex::escape() を適用

## 潜在的バグ (4.4)
- 4.4.1: scroll_to_first_match の off-by-one 修正 (1-based → 0-based 変換)
- 4.4.2: results_to_entries の name フィールドを filename に修正
- 4.4.3: Tantivy クエリの特殊文字をエスケープ (sanitize_tantivy_query)
- 4.4.4: is_performing_search が非同期化により意味のある状態を持つように

全56テスト通過、cargo check --features gui もコンパイル成功。

https://claude.ai/code/session_01YMW7CxqQmAti2DsVmWQ2Sx
- ~/.nohrs/nohrs.toml による設定可能化
  - インデックス対象ディレクトリの複数指定
  - 除外パターン (node_modules, .git 等)
  - ファイルサイズ上限の設定
  - デバウンス時間・ページサイズの設定
- デバウンス付きオートサーチ (300ms デフォルト)
  - キー入力ごとに世代番号で前回タイマーをキャンセル
  - Enter キーでデバウンスをバイパスして即座検索
- 検索結果のページネーション
  - 設定可能なページサイズ (デフォルト 200件)
  - 前/次ページボタン付きUI
  - 新規検索時に自動でページリセット
- ローディングインジケーター
  - is_performing_search 中は "Searching..." 表示
  - アクセントカラーでステータス強調

https://claude.ai/code/session_01YMW7CxqQmAti2DsVmWQ2Sx
ブランチ全体の修正・新機能に対する自動テストと
GUI手動確認の手順をまとめたドキュメント。

https://claude.ai/code/session_01YMW7CxqQmAti2DsVmWQ2Sx
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: de9b372245

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

.cloned()
.collect();
let entries = search::results_to_entries(&paged);
self.rebuild_search_results_map(&paged);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Build search result index map from full results

get_search_result indexes into self.search_results (the full grouped result list), but on page changes this map is rebuilt from the paged slice only. On page 2+ the stored indices restart at 0, so lookups return the wrong file's matches/snippets and preview navigation can jump to unrelated results. Rebuild the map against the full result vector (or store path->result directly) to keep indices consistent across pages.

Useful? React with 👍 / 👎.

Comment on lines +508 to +509
(self.search_total_results + self.search_results_per_page - 1)
/ self.search_results_per_page
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Validate results-per-page before dividing

search_results_per_page comes from config and is not validated, so a user value of 0 will cause a division-by-zero panic once any search returns results. This path is reached in normal rendering via search_total_pages, so a malformed config can crash the UI immediately after searching.

Useful? React with 👍 / 👎.

Comment on lines +30 to +34
let watch_dir = if roots.is_empty() {
dirs::home_dir().expect("Home dir not found")
} else {
roots[0].clone()
};
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Watch every configured content root for updates

The indexer now supports multiple content_roots, but the watcher subscribes only to roots[0]. As a result, file changes in any additional configured directory never trigger process_changes, so search results for those directories become stale until a full reindex runs.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants