feat(web): collapse loaded sessions back to the first page#1322
Conversation
The workspace session list's load-more control was one-way: once expanded, the only way to hide the extra sessions was to collapse the whole group. Add a Show less / Show all toggle so an expanded list can be collapsed back to its first page and re-expanded without losing the loaded data. Restyle the control as a session-row-shaped pill whose label aligns with the session titles, per design-system section 07, and mirror the behavior in the mobile switcher.
🦋 Changeset detectedLatest commit: 2867814 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
commit: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 479515e933
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| page.items.length > 0 ? page.items[page.items.length - 1]!.id : undefined; | ||
| // First-page size = how many were loaded on first paint. Used by the | ||
| // sidebar's in-group "show less" control as the collapse target. | ||
| counts[workspaceId] = page.items.length; |
There was a problem hiding this comment.
Preserve first-page capacity for sparse workspaces
When the initial fetch returns fewer than a full page, this stores that smaller number (including 0) as the permanent collapsed limit. Later, startSessionAndSendPrompt adds newly created sessions with upsertSessionFront but does not increase this count, while both desktop and mobile render collapsed groups with sessions.slice(0, initialCount). For a workspace that was empty on load, creating the first session makes initialCount stay 0, so the active session row is hidden and only a “Show all (1)” control appears; with 1–4 initial sessions, each new session also hides an older row even though the group has never paged.
Useful? React with 👍 / 👎.
The collapse target was seeded with the exact number of sessions loaded on first paint, which is 0 for an empty workspace and below a full page for a sparse one. Newly created sessions are prepended without bumping that count, so a workspace that was empty on load would hide its first new session behind a Show all control, and a sparse one would hide an older row on each new session even when it had never paged. Floor the collapse target at one full page so the first-page capacity is preserved.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ca66049925
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| const visibleSessions = computed(() => | ||
| props.isExpanded(props.group.workspace.id) | ||
| ? props.group.sessions | ||
| : props.group.sessions.slice(0, props.group.initialCount), |
There was a problem hiding this comment.
Keep selected sessions visible after draining history
With this slice, a workspace that starts unexpanded only renders the initial page even after other code adds/selects an older session. For example, Cmd/Ctrl-K calls loadAllSessions() and SearchSessionsDialog can select a result beyond group.initialCount (URL deep links append similarly via fetchSessionIntoList); selectSession marks it active, but the sidebar row is absent until the user manually clicks Show all. Please auto-expand the selected workspace or include the active session in the collapsed view so selection/search doesn't navigate to a hidden row.
Useful? React with 👍 / 👎.
A collapsed workspace only rendered its first page, so an older session selected from outside the pagination flow — Cmd/Ctrl-K search (loadAllSessions) or a URL deep link (fetchSessionIntoList) — was marked active but had no visible row in the sidebar until the user manually clicked Show all. Include the active session in the collapsed view (appended in newest-first order) on both the desktop sidebar and the mobile switcher, so selection and search never navigate to a hidden row.
|
Codex Review: Didn't find any major issues. What shall we delve into next? Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
Related Issue
No related issue — see Problem below.
Problem
The workspace session list in the web sidebar had two issues:
What changed
hasMoreare untouched, so re-expanding never refetches.font-ui,radius-md, 26px row, sunken hover,:focus-visiblering) with an empty lead slot so its label aligns exactly with the session titles. Update design-system section 07 to match.apps/kimi-web/design/sidebar-show-more-demo.html) used to review the control.Checklist
gen-changesetsskill.gen-docsskill, or this PR needs no doc update. (No CLI doc change needed; this is a web-internal UX improvement.)