Skip to content

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

Closed
CasualDeveloper wants to merge 1 commit into
anomalyco:devfrom
CasualDeveloper:feat/tui-message-limit
Closed

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

Conversation

@CasualDeveloper

@CasualDeveloperCasualDeveloper commented Dec 24, 2025

Copy link
Copy Markdown
Contributor

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 session_list_limit config in tui.json 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. Pinned session-switching entries are preserved within the cap when room exists, and remaining picker entries stay aligned with updated-time recency.

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 300000 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

CopilotAI review requested due to automatic review settings December 24, 2025 23:46

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

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
FileDescription
packages/sdk/openapi.jsonAdds message_limit field to the schema with integer constraints (1-10,000) and description
packages/sdk/js/src/v2/gen/types.gen.tsGenerated TypeScript types for the new message_limit config option
packages/sdk/js/src/gen/types.gen.tsGenerated TypeScript types with incorrect default value in documentation
packages/opencode/src/config/config.tsAdds Zod schema validation for message_limit with proper constraints
packages/opencode/src/cli/cmd/tui/context/sync.tsxUpdates 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 threadpackages/sdk/js/src/gen/types.gen.ts Outdated
@CasualDeveloper

Copy link
Copy Markdown
ContributorAuthor

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

@CasualDeveloper

Copy link
Copy Markdown
ContributorAuthor

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

CasualDeveloper commented Dec 25, 2025

Copy link
Copy Markdown
ContributorAuthor

I have a working implementation ready - typechecks pass.

@ariane-emory

ariane-emory commented Dec 25, 2025

Copy link
Copy Markdown
Contributor

@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
ContributorAuthor

@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
CasualDeveloperforce-pushed the feat/tui-message-limit branch 2 times, most recently from ef4a090 to 4a4438cCompareDecember 25, 2025 03:46
@CasualDeveloper

Copy link
Copy Markdown
ContributorAuthor

Re-committed with valid GPG signature. PR ready.

@CasualDeveloper
CasualDeveloperforce-pushed the feat/tui-message-limit branch 3 times, most recently from 4596a07 to da1e0bcCompareDecember 26, 2025 06:51
@CasualDeveloperCasualDeveloper changed the title feat(tui): add configurable message_limit for session history[#4918] feat(tui): add configurable message_limit for session historyDec 26, 2025
@CasualDeveloperCasualDeveloper changed the title [#4918] feat(tui): add configurable message_limit for session history[#4918][#6137] feat(tui): add configurable message_limit for session historyDec 26, 2025
@CasualDeveloperCasualDeveloper changed the title [#4918][#6137] feat(tui): add configurable message_limit for session history[#6137] feat(tui): add configurable message_limit for session historyDec 26, 2025
@CasualDeveloperCasualDeveloper changed the title [#6137] feat(tui): add configurable message_limit for session history[6137] feat(tui): add configurable message_limit for session historyDec 26, 2025
@CasualDeveloperCasualDeveloper changed the title [6137] feat(tui): add configurable message_limit for session history[#6137] feat(tui): add configurable message_limit for session historyDec 26, 2025
@CasualDeveloperCasualDeveloper changed the title [#6137] feat(tui): add configurable message_limit for session historyfeat(tui): add configurable message_limit for session history (#6137)Dec 26, 2025
@CasualDeveloper
CasualDeveloperforce-pushed the feat/tui-message-limit branch 5 times, most recently from 872e100 to 1e84d56CompareDecember 30, 2025 19:06
@CasualDeveloper

Copy link
Copy Markdown
ContributorAuthor

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

@CasualDeveloper
CasualDeveloperforce-pushed the feat/tui-message-limit branch 2 times, most recently from 325c7f5 to 8fc7ac0CompareJanuary 23, 2026 19:20
@CasualDeveloper
CasualDeveloperforce-pushed the feat/tui-message-limit branch 7 times, most recently from c0282dc to a566be1CompareJanuary 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 has priority inside capped lists; pinned session-switching entries are preserved when space remains, and remaining slots follow the picker's updated-time recency order.
@CasualDeveloper

Copy link
Copy Markdown
ContributorAuthor

Closing this PR in its current form.

After re-reviewing the original goal and the newer session-dialog work in #31132, I no longer think this implementation is the right layer for the problem. This PR applies session_list_limit as a render-time slice over sync.data.session, but that shared sync list is already backend-limited and mixed root/child session data. So the setting cannot reliably make more root sessions visible.

The better immediate fix is #31132: make the session dialog load root sessions directly and safely, without changing shared sync state.

If a configurable picker size is still needed later, it should be implemented as a page size / query limit for the dialog-local root-session browse request, not as a client-side slice of synced sessions.

Superseded by #31132.

Sign up for freeto 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

@CasualDeveloper@ariane-emory@benitogonzalezh