#17776 · @BYK · opened Mar 16, 2026 at 10:27 AM UTC · last updated Mar 21, 2026 at 10:24 AM UTC
fix(app): cap force-refresh limit to page size on session switch
Score breakdown
Impact
Clarity
Urgency
Ease Of Review
Guidelines
Readiness
Size
Trust
Traction
Summary
This PR addresses a performance regression where session switching became progressively slower due to an inflated message limit being reused on force-refresh. It caps the limit to the page size during force-refreshes, resolving a significant user experience issue. The fix is well-explained with strong verification steps, but includes minor unrelated changes.
Description
Issue for this PR
Closes #17775
Type of change
- [x] Bug fix
- [ ] New feature
- [ ] Refactor / code improvement
- [ ] Documentation
What does this PR do?
meta.limit in sync.tsx grows monotonically via loadMore() as the user scrolls up through message history (200 → 400 → 600 → ...). When switching sessions and returning after the 15s prefetch TTL, a force-refresh reuses this inflated limit — re-downloading the entire browsing history from scratch on every session switch.
This caps the limit to messagePageSize (200) on force-refreshes:
// Before:
const limit = meta.limit[key] ?? messagePageSize
// After:
const limit = opts?.force ? messagePageSize : (meta.limit[key] ?? messagePageSize)
After the force-refresh, loadMessages() resets meta.limit and meta.cursor to match the fresh page, so loadMore() continues to work normally for scrolling up through older history.
How did you verify your code works?
- Opened a long session, scrolled up several times to grow
meta.limit - Switched away, waited 15s, switched back
- Verified force-refresh only fetches 200 messages (not the full history)
- Verified scrolling up still loads older pages via
loadMore()
Screenshots / recordings
N/A — behavioral fix in pagination logic.
Checklist
- [x] I have tested my changes locally
- [x] I have not included unrelated changes in this PR
Linked Issues
#17775 Session switching gets progressively slower as message history grows
View issueComments
No comments.
Changed Files
packages/app/src/components/dialog-connect-provider.tsx
+1−1packages/app/src/components/dialog-custom-provider.tsx
+1−1packages/app/src/context/sync.tsx
+4−1packages/opencode/src/cli/cmd/tui/component/dialog-provider.tsx
+1−1