Search results should show reads in expanded reference context #129
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When searching for read IDs in "Read" mode, references containing matching reads now automatically expand to show the filtered results. This improves UX by eliminating the need to manually click each reference group to see which reads matched the search query.
The fix adds auto-expansion logic in rebuildItemsList():
This change is isolated to the display logic and maintains backward compatibility with existing search and expansion behavior.
Changes Made
File: src/views/components/squiggy-reads-core.tsx:745-747
Added auto-expansion logic for references when searching for reads:
// Auto-expand references with matching reads in read search mode
const shouldAutoExpand = searchMode === 'read' && searchText && filteredReads.length > 0;
const isExpanded = shouldAutoExpand || expandedReferences.has(referenceName);
How It Works
Before: When searching for read IDs, the UI would show:
Search: "abc123"
▶ tRNA-Ala-AGC-1 (2 reads) ← Collapsed, user must click to see reads
▶ tRNA-Gly-GCC-1 (1 read) ← Collapsed, user must click to see reads
After: References automatically expand to show matching reads:
Search: "abc123"
▼ tRNA-Ala-AGC-1 (2 reads)
→ abc123_read1
→ abc123_read2
▼ tRNA-Gly-GCC-1 (1 read)
→ xyz_abc123
Behavior
Read search mode + active search → Auto-expands references with matches
No search text → Uses manual expansion state only
Reference search mode → Uses manual expansion state only
Filtered results → Only matching reads are shown (already working)
Testing
The extension compiled successfully with no errors. The change is minimal and isolated to the display logic, so it should be safe.