Skip to content

Conversation

@CasualDeveloper
Copy link
Contributor

@CasualDeveloper CasualDeveloper commented Dec 24, 2025

Problem

The session picker loads all sessions by default, which can become slow with hundreds or thousands of sessions.

Solution

  • Add tui.session_list_limit config (default 150)
  • Apply the limit only when not searching (search still uses server-side limit 30)
  • Keep the current session visible even when capped (tie-safe ordering)
  • Add a TUI tip for discoverability
  • Regenerate SDK OpenAPI/types

Notes

Copilot AI review requested due to automatic review settings December 24, 2025 23:46
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a configurable message_limit option to control the number of messages loaded per session in the TUI. The default value remains 100, but users can now configure it up to 10,000 messages through the config file.

  • Add message_limit configuration field to TUI schema with validation constraints (1-10,000)
  • Update implementation to use the configured value with fallback to 100
  • Generate corresponding TypeScript type definitions

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/sdk/openapi.json Adds message_limit field to the schema with integer constraints (1-10,000) and description
packages/sdk/js/src/v2/gen/types.gen.ts Generated TypeScript types for the new message_limit config option
packages/sdk/js/src/gen/types.gen.ts Generated TypeScript types with incorrect default value in documentation
packages/opencode/src/config/config.ts Adds Zod schema validation for message_limit with proper constraints
packages/opencode/src/cli/cmd/tui/context/sync.tsx Updates message loading to use configured limit with fallback to 100

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@CasualDeveloper
Copy link
Contributor Author

Fixed the inconsistent default value in the SDK types (was 500, now correctly 100). Thanks Copilot!

@CasualDeveloper
Copy link
Contributor Author

Fixed second hardcoded 100 in the message.updated event handler at line 191. Without this, new messages arriving during active sessions would trim the array back to 100, defeating the configurable limit.

@CasualDeveloper
Copy link
Contributor Author

CasualDeveloper commented Dec 25, 2025

I have a working implementation ready - typechecks pass.

@ariane-emory
Copy link
Contributor

ariane-emory commented Dec 25, 2025

@CasualDeveloper I also want to see this feature. I've had a half-finished PR in my pocket for a while that addresses this (and also makes the length of session_list similarly configurable) I haven't found the time to finish it and yours looks like it may be cleaner than mine.

I cordially invite you to steal anything you think might be useful from my unfinished PR: ariane-emory#43

The team may (or may not) conclude that this also resolves my original Issue on the topic, #4918.

@CasualDeveloper
Copy link
Contributor Author

@ariane-emory Thanks for linking your PR! I've incorporated session_list_limit from your work. Kept the implementation simpler (no "none" option, proper types instead of as any casts). Added a reference to #4918 in the PR description.

@CasualDeveloper CasualDeveloper force-pushed the feat/tui-message-limit branch 2 times, most recently from ef4a090 to 4a4438c Compare December 25, 2025 03:46
@CasualDeveloper
Copy link
Contributor Author

Re-committed with valid GPG signature. PR ready.

@CasualDeveloper CasualDeveloper force-pushed the feat/tui-message-limit branch 3 times, most recently from 4596a07 to da1e0bc Compare December 26, 2025 06:51
@CasualDeveloper CasualDeveloper changed the title feat(tui): add configurable message_limit for session history [#4918] feat(tui): add configurable message_limit for session history Dec 26, 2025
@CasualDeveloper CasualDeveloper changed the title [#4918] feat(tui): add configurable message_limit for session history [#4918][#6137] feat(tui): add configurable message_limit for session history Dec 26, 2025
@CasualDeveloper CasualDeveloper changed the title [#4918][#6137] feat(tui): add configurable message_limit for session history [#6137] feat(tui): add configurable message_limit for session history Dec 26, 2025
@CasualDeveloper CasualDeveloper changed the title [#6137] feat(tui): add configurable message_limit for session history [6137] feat(tui): add configurable message_limit for session history Dec 26, 2025
@CasualDeveloper CasualDeveloper changed the title [6137] feat(tui): add configurable message_limit for session history [#6137] feat(tui): add configurable message_limit for session history Dec 26, 2025
@CasualDeveloper CasualDeveloper changed the title [#6137] feat(tui): add configurable message_limit for session history feat(tui): add configurable message_limit for session history (#6137) Dec 26, 2025
@CasualDeveloper CasualDeveloper force-pushed the feat/tui-message-limit branch 5 times, most recently from 872e100 to 1e84d56 Compare December 30, 2025 19:06
@CasualDeveloper
Copy link
Contributor Author

Will continue rebasing on top of release tags as they're set.

@CasualDeveloper
Copy link
Contributor Author

Revised: session_list_limit only

I've rebased and revised this PR to remove message_limit entirely. With cursor-based pagination merged (#8535), message_limit is now redundant and was causing conflicts in sync.tsx.

What's left

  • session_list_limit config option (1-10000, default 150)
  • Limits sessions displayed in the picker when not searching
  • Search continues to use server-side limit of 30

Files changed

  • config.ts: Added session_list_limit to TUI schema
  • dialog-session-list.tsx: Added .slice() logic
  • SDK types and openapi.json regenerated

No sync.tsx changes — conflicts eliminated.

cc @ariane-emory — kept your session_list_limit contribution, just without message_limit.

@ariane-emory
Copy link
Contributor

ariane-emory commented Jan 17, 2026

@CasualDeveloper Might be prudent to revise the top/initial message and the title to accurately reflect the new state/scope of the PR? I was pretty confused when I came to look at the code and didn't see the setting named in the title.

@CasualDeveloper CasualDeveloper changed the title feat(tui): add configurable message_limit for session history (#6137) feat(tui): add session_list_limit for session picker Jan 17, 2026
@github-actions
Copy link
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.

@CasualDeveloper
Copy link
Contributor Author

CasualDeveloper commented Jan 17, 2026

Updated the PR title/body to reflect the new scope (session_list_limit only). Thanks for the nudge, @ariane-emory!

@CasualDeveloper CasualDeveloper changed the title feat(tui): add session_list_limit for session picker feat(tui): add session_list_limit for session picker (#6137) Jan 17, 2026
@CasualDeveloper CasualDeveloper force-pushed the feat/tui-message-limit branch 8 times, most recently from 769134b to 325c7f5 Compare January 23, 2026 19:02
Introduce the optional tui.session_list_limit setting for limiting
the session picker when not searching.
Apply session_list_limit to the picker and ensure the active
session remains visible when the list is capped.
Surface the new session_list_limit setting in the TUI tips
so users can discover the session picker cap.
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.

Cannot scroll to beginning of long conversations (message limit hardcoded to 100) (#6138)

3 participants