fix(sidebar): surface search hits that only match a subagent transcript - #152
Merged
Conversation
processProjectSessions() dropped a project entirely when its only search match lived inside a subagent transcript: the orphan-subagent guard disqualified itself whenever any filter, search included, was active, even though refreshSidebar had already discarded projects with zero matching sessions before this guard runs. Restrict the disqualification to showStarredOnly/showRunningOnly/showTodayOnly, which a subagent can never satisfy, and auto-expand the orphan bucket while a search is active so the surfaced hit isn't hidden behind an extra click.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
A search hit living only inside a subagent transcript used to vanish entirely from the sidebar — the project disappeared from the results, not just the row.
Subagent transcripts are indexed:
read-session-file.jsenumerates them under<folder>/<parent>/subagents/with the idsub:<parent>:<agentId>,session-cache.jspushes them into FTS with no filter, and neitherdb.jsnor the search worker filters them out. So the hit is real and reachessearchMatchIds; it was then dropped at render time.The orphan-subagent guard in
processProjectSessions()disqualified itself whenever any filter was on, an active search included. ButrefreshSidebaralready drops projects with zero matching sessions before that guard runs, so the search exclusion was redundant — and actively harmful here: with the only match being a subagent,filteredis empty, the guard returnsnull, and the render loop skips the project before reaching the orphan bucket.This also corrects a claim in
.ai/contexts/subagent-observability.mdintroduced with #149: that without!anyFilterActivean active search would resurface every project merely owning a subagent. That is false for search, for the reason above. The reasoning only holds for the three real filters.Fix
Restrict the disqualification to
showStarredOnly/showRunningOnly/showTodayOnly— the filters a subagent can never satisfy — and auto-expand the orphan bucket while a search is active, so a surfaced hit is not hidden behind a click. Worktree subgroups reuse the sameprocessProjectSessions, so they are covered by construction.Tests
test/dom-sidebar-search-subagent-hits.test.js, 2 tests. Each of the three halves of the change is discriminated by its own failure:Non-regression cases checked one by one: empty project; top-level sessions excluded by each of the three filters; empty project under an active filter;
_projectMatchedOnly; surviving top-level sessions; worktree subgroups; and the #149 behaviour with no filter active.Full suite: 687 tests, 680 pass, 0 fail, 7 pre-existing skips. ESLint: 265 warnings before and after, 0 errors, none added.