Skip to content

fix(tui): request root sessions in switch session dialog#23276

Open
jiwangyihao wants to merge 1 commit intoanomalyco:devfrom
jiwangyihao:fix/switch-session-root-filter
Open

fix(tui): request root sessions in switch session dialog#23276
jiwangyihao wants to merge 1 commit intoanomalyco:devfrom
jiwangyihao:fix/switch-session-root-filter

Conversation

@jiwangyihao
Copy link
Copy Markdown

@jiwangyihao jiwangyihao commented Apr 18, 2026

Issue for this PR

Closes #16270

Related: #13877

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Switch Session was asking for a mixed session list and then filtering root sessions in the dialog. In projects with many recent child sessions, that meant root sessions could get pushed out of the first page even though opencode session list still showed them.

This change keeps the fix scoped to the dialog path instead of making the shared bootstrap session store roots-only, because other TUI flows still use the shared session store for parent / child session navigation.

It updates the dialog to request root sessions directly for both the default list and search results, and it refetches that root-session list after delete / workspace recovery so the dialog stays current.

How did you verify your code works?

I reproduced the bug against a local OpenCode database where the missing session was rank 4 among root sessions but rank 152 among all sessions because 148 newer child sessions came first.

I then verified the dialog's previous query shape (session.list({ start, limit: 100 }) followed by client-side parentID === undefined filtering) could exclude that root session, while the patched query shape (session.list({ start, roots: true, limit: 100 })) keeps it in the returned default list.

I also verified that search now requests roots: true, so recent child sessions cannot crowd root sessions out of search results, and that the delete / workspace recovery flows refetch the same root-session resource afterward.

Screenshots / recordings

N/A. This changes the session query used by the TUI dialog rather than the rendered UI itself.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Only fetching the latest mixed session list lets recent child sessions crowd root sessions out of Switch Session. Querying root sessions directly keeps recent root sessions visible and makes dialog refetches stay in sync after delete or workspace recovery.
@github-actions
Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions github-actions bot added needs:issue needs:compliance This means the issue will auto-close after 2 hours. labels Apr 18, 2026
@github-actions
Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

I found one potentially related PR from the recent results:

feat(tui): add session migration dialog (#23250)
#23250

This PR is recent (nearby PR number) and also involves TUI session-related functionality. While it's about session migration rather than the switch session dialog specifically, it may be related work in the same area.

Otherwise, the search results show various TUI and session-related PRs but none appear to be direct duplicates of fixing the switch session dialog's root session filtering behavior. The closest match was #14267 about preserving input drafts when switching sessions, but that's a different concern.

Would you like me to do additional searches with different keywords to be thorough?

@github-actions github-actions bot removed needs:issue needs:compliance This means the issue will auto-close after 2 hours. labels Apr 18, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

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.

/sessions TUI only shows recent sessions, ignores historical ones

1 participant