Skip to content

fix(sidebar): surface search hits that only match a subagent transcript - #152

Merged
devsuitup merged 1 commit into
mainfrom
fix/search-subagent-hits
Aug 23, 2026
Merged

fix(sidebar): surface search hits that only match a subagent transcript#152
devsuitup merged 1 commit into
mainfrom
fix/search-subagent-hits

Conversation

@devsuitup

Copy link
Copy Markdown
Owner

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.js enumerates them under <folder>/<parent>/subagents/ with the id sub:<parent>:<agentId>, session-cache.js pushes them into FTS with no filter, and neither db.js nor the search worker filters them out. So the hit is real and reaches searchMatchIds; it was then dropped at render time.

The orphan-subagent guard in processProjectSessions() disqualified itself whenever any filter was on, an active search included. But refreshSidebar already 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, filtered is empty, the guard returns null, and the render loop skips the project before reaching the orphan bucket.

This also corrects a claim in .ai/contexts/subagent-observability.md introduced with #149: that without !anyFilterActive an 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 same processProjectSessions, 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:

drop the search exclusion   → project group must still be rendered when its only match is a subagent
drop the starred exclusion  → a subagent must never keep a project alive under showStarredOnly
drop the auto-expand        → orphan bucket must be expanded during an active search, not hidden behind a click

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.

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.
@devsuitup
devsuitup merged commit 09264cf into main Aug 23, 2026
7 checks passed
@devsuitup
devsuitup deleted the fix/search-subagent-hits branch August 23, 2026 22:10
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.

1 participant