Skip to content

feat(web): collapse loaded sessions back to the first page#1322

Merged
wbxl2000 merged 3 commits into
mainfrom
feat/web-sidebar-collapse
Jul 2, 2026
Merged

feat(web): collapse loaded sessions back to the first page#1322
wbxl2000 merged 3 commits into
mainfrom
feat/web-sidebar-collapse

Conversation

@wbxl2000

@wbxl2000 wbxl2000 commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

Related Issue

No related issue — see Problem below.

Problem

The workspace session list in the web sidebar had two issues:

  1. Its "load more" control was one-way: once you loaded more sessions and reached the end, the button disappeared and the only way to hide the extra sessions was to collapse the entire workspace group (which hides the first page too).
  2. The control did not conform to design-system section 07: it used the mono font, had no rounded pill, recolored the text on hover, had no focus ring, and its label sat 8px to the right of the session titles.

What changed

  • Add a Show less / Show all toggle to each workspace group. After loading past the first page, the list can be collapsed back to the first page and re-expanded. This is a pure view-layer trim — loaded data, the paging cursor, and hasMore are untouched, so re-expanding never refetches.
  • Record each workspace's first-page size on initial load and use it as the collapse target.
  • Restyle the load-more / show-less control as a session-row-shaped pill (font-ui, radius-md, 26px row, sunken hover, :focus-visible ring) with an empty lead slot so its label aligns exactly with the session titles. Update design-system section 07 to match.
  • Mirror the same expand/collapse behavior in the mobile switcher.
  • Add a high-fidelity design demo (apps/kimi-web/design/sidebar-show-more-demo.html) used to review the control.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • I have added tests that prove my feature works. (The web package has no component-test infrastructure — only pure-logic tests — so this view-layer change is covered by typecheck / build / check-style and manual verification.)
  • Ran gen-changesets skill.
  • Ran gen-docs skill, or this PR needs no doc update. (No CLI doc change needed; this is a web-internal UX improvement.)

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

changeset-bot Bot commented Jul 2, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 2867814

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/kimi-code Patch

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

@pkg-pr-new

pkg-pr-new Bot commented Jul 2, 2026

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@2867814
npx https://pkg.pr.new/@moonshot-ai/kimi-code@2867814

commit: 2867814

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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.
@wbxl2000

wbxl2000 commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator Author

@codex

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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.
@wbxl2000

wbxl2000 commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator Author

@codex

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: 2867814b2e

ℹ️ 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".

@wbxl2000 wbxl2000 merged commit 5441ad1 into main Jul 2, 2026
9 checks passed
@wbxl2000 wbxl2000 deleted the feat/web-sidebar-collapse branch July 2, 2026 13:51
@github-actions github-actions Bot mentioned this pull request Jul 2, 2026
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.

1 participant