Skip to content

feat(tui): add session_list_limit for session picker#6138

Open
CasualDeveloper wants to merge 1 commit intoanomalyco:devfrom
CasualDeveloper:feat/tui-message-limit
Open

feat(tui): add session_list_limit for session picker#6138
CasualDeveloper wants to merge 1 commit intoanomalyco:devfrom
CasualDeveloper:feat/tui-message-limit

Conversation

@CasualDeveloper
Copy link
Copy Markdown
Contributor

@CasualDeveloper CasualDeveloper commented Dec 24, 2025

Issue for this PR

Closes #20754

Related to #6137, #8535, and #4918.

Type of change

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

What does this PR do?

Adds optional tui.session_list_limit config for the TUI session picker. The picker uses a default cap of 150 root sessions when not searching, while search keeps the existing server-limited request path.

The current session stays visible when capped, and picker ordering stays aligned with the existing day-bucket and created-time sort.

This is intentionally scoped to the picker render list, not broader session loading or pagination.

How did you verify your code works?

  • From packages/opencode: bun run test test/cli/tui/session-list.test.ts
  • From packages/opencode: bun test --timeout 120000 test/cli/tui/session-list.test.ts test/config/tui.test.ts --max-concurrency=1
  • From repo root: bun turbo typecheck

Screenshots / recordings

N/A. This is a TUI config and picker behavior change with no visual layout change.

Notes

AI Assistance: OpenCode + openai/gpt-5.5; Review: Human operator reviewed.

Checklist

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

Copilot AI review requested due to automatic review settings December 24, 2025 23:46
Copy link
Copy Markdown
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.

Comment thread packages/sdk/js/src/gen/types.gen.ts Outdated
@CasualDeveloper
Copy link
Copy Markdown
Contributor Author

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

@CasualDeveloper
Copy link
Copy Markdown
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
Copy Markdown
Contributor Author

CasualDeveloper commented Dec 25, 2025

I have a working implementation ready - typechecks pass.

@ariane-emory
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor Author

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

@CasualDeveloper CasualDeveloper force-pushed the feat/tui-message-limit branch 6 times, most recently from 325c7f5 to 8fc7ac0 Compare January 23, 2026 19:20
@CasualDeveloper CasualDeveloper force-pushed the feat/tui-message-limit branch 7 times, most recently from c0282dc to a566be1 Compare January 30, 2026 03:44
Adds an optional `session_list_limit` setting to `tui.json` (default 150) that caps how many root sessions the picker renders when not searching.

Search still requests the existing server-limited result set and renders an empty pending state instead of falling back to the full synced list.

The active session remains visible in capped lists by reserving space for it and reinserting it with the same day-bucket/created-time ordering used by the picker.
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.

[QUESTION] Configurable session picker limit (#6138)

4 participants