fix(web): allow directory collapse during session search - #1797
techotaku39 wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Findings
-
[Major] Selected-session auto-expansion can overwrite the pre-filter collapse state — the new filtered-state lookup at
web/src/components/SessionList.tsx:1400is bypassed by the existing unconditional persistent-map write atweb/src/components/SessionList.tsx:1751. Collapse the currently selected group, search so that selected session disappears, then clear search: the effect resets its guard while filtered and writesfalseintocollapseOverrideswhen the group returns, reopening it instead of restoring the collapsed state.Suggested fix:
if (!group) { if (!isFiltering) autoExpandedSelectedSessionKeyRef.current = null return } const setOverrides = isFiltering ? setFilterCollapseOverrides : setCollapseOverrides setOverrides(prev => expandSelectedSessionCollapseOverrides(prev, group))
Questions
- None.
Summary
Review mode: initial
One major correctness issue found in pre-filter state restoration. The added test uses selectedSessionId={null}, so it does not cover the normal selected-session interaction that triggers the issue.
Testing
- Not run (automation):
bunis unavailable in this runner. Static review of the full diff and surrounding session-group effects completed.
HAPI Bot
| const isGroupCollapsed = (group: SessionGroup): boolean => { | ||
| if (isFiltering) return false | ||
| const override = collapseOverrides.get(group.key) | ||
| const override = isFiltering |
There was a problem hiding this comment.
[MAJOR] Selected-session auto-expansion bypasses the temporary filter state
isGroupCollapsed now reads filterCollapseOverrides during filtering, but the selected-session effect still calls setCollapseOverrides unconditionally at web/src/components/SessionList.tsx:1751. Reproduction: collapse the group containing the selected session, enter a query that removes that session/group, then clear the query. While filtered, the effect clears autoExpandedSelectedSessionKeyRef; when the group returns, it writes false to the persistent map and reopens the group, so the promised pre-filter collapsed state is lost. The new test avoids this path by rendering with selectedSessionId={null} at web/src/components/SessionList.directory-action.test.tsx:795.
Suggested fix:
if (!group) {
if (!isFiltering) autoExpandedSelectedSessionKeyRef.current = null
return
}
const setOverrides = isFiltering ? setFilterCollapseOverrides : setCollapseOverrides
setOverrides(prev => expandSelectedSessionCollapseOverrides(prev, group))Also add a regression test with a selected session that is excluded and then restored by clearing the query.
There was a problem hiding this comment.
Findings
- None.
Questions
- None.
Summary
Review mode: follow-up after new commits
No issues found in the latest full diff at ≥80% confidence. The prior selected-session state-restoration issue is addressed by keeping filtered auto-expansion in temporary state and preserving the guard while the selected session is filtered out (web/src/components/SessionList.tsx:1743, web/src/components/SessionList.tsx:1753); the added regression covers clearing that filter (web/src/components/SessionList.directory-action.test.tsx:825). Residual risk: runtime behavior was not independently exercised in this runner.
Testing
- Not run (automation):
bunis unavailable in this runner. Static review of the full latest diff, prior review context, and surrounding collapse/filter effects completed.
HAPI Bot
Summary
Problem / Motivation
When session search was active, directory groups were always forced open. The directory header remained clickable, but clicking it had no visible effect because the filtering state overrode the user's collapse choice. Selected-session auto-expansion could also rewrite the persistent collapse state after a filtered session group returned.
Validation
Final HEAD validation:
bun run --cwd web test -- src/components/SessionList.directory-action.test.tsx src/components/SessionList.test.ts src/components/SessionList.machine-filter.test.ts— 89 passedbun typecheck— passedbun run build— passedpwsh -NoProfile -File .\scripts\Invoke-HapiTaskPlaywright.ps1 -Name investigate-session-search-folder-collapse -Suite Root terminal-wrap-fidelity.spec.ts— 2 passedBaseline full-suite runs before the follow-up review fix:
bun run test— 28 unrelated Windows/CLI baseline failures; 2584 of 2612 tests passedbun run test:web— 77 unrelated CRLF fixture serialization failures; 2871 of 2948 tests passedRelated Issues
Refs #1068
AI Disclosure
OpenAI Codex (GPT-5.6)