feat(web): hide empty sessions from the session list - #1166
Conversation
Add an optional exclude_empty parameter to the session list API; the web client passes it so unused "New Session" entries are hidden by default, with pagination and has_more computed on the filtered set.
🦋 Changeset detectedLatest commit: e4d0171 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: 95b7d7cee0
ℹ️ 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_size: z.coerce.number().int().min(1).max(100).optional(), | ||
| status: sessionStatusSchema.optional(), | ||
| include_archive: booleanQueryParam, | ||
| exclude_empty: booleanQueryParam, |
There was a problem hiding this comment.
Keep the protocol query schema in sync
This adds exclude_empty only to the server-local route schema, but packages/protocol/src/rest/session.ts still defines listSessionsQuerySchema/ListSessionsQuery with only status and include_archive. Any client or validation path that imports the protocol schema will silently strip the new flag and the generated TypeScript type will not expose it, so the newly documented API parameter is unusable through the shared protocol package; add the same boolean field and tests there as part of this change.
Useful? React with 👍 / 👎.
| .listSessions({ | ||
| workspaceId: w.id, | ||
| pageSize: SESSIONS_INITIAL_PAGE_SIZE, | ||
| excludeEmpty: true, |
There was a problem hiding this comment.
Filter live-created empty sessions too
Passing excludeEmpty here only affects REST-loaded pages; while the web app is already connected, a different client can create a session and the global event.session.created path still prepends that empty session into rawState.sessions via reduceAppEvent, and the sidebar grouping does not re-filter by lastPrompt. In that multi-client scenario an unused “New Session” row immediately reappears until refresh, so the live event path needs the same empty-session policy or a follow-up fetch once session.meta.updated supplies a prompt.
Useful? React with 👍 / 👎.
Keep the shared protocol schema in sync with the server route so clients using the protocol type see the new parameter.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d73002e18f
ℹ️ 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".
| z.object({ | ||
| status: sessionStatusSchema.optional(), | ||
| include_archive: booleanQueryParam, | ||
| exclude_empty: booleanQueryParam, |
There was a problem hiding this comment.
Avoid advertising exclude_empty on child lists
Adding this flag to listSessionsQuerySchema also changes listSessionChildrenQuerySchema because it aliases the same schema, but the /sessions/{id}/children route still parses only before/after/page_size/status and SessionService.listChildren never applies excludeEmpty. Clients generated from the protocol will think GET /children?exclude_empty=true is supported while the server still includes empty child sessions; split the schemas or pass/filter the option for child lists.
Useful? React with 👍 / 👎.
| @@ -0,0 +1,5 @@ | |||
| --- | |||
| "@moonshot-ai/kimi-code": patch | |||
There was a problem hiding this comment.
Do not mark a removed slash command as patch
Line 5 says the web /sessions slash command is removed, but this changeset bumps @moonshot-ai/kimi-code as patch. The repo-level AGENTS.md classifies renamed or removed commands/arguments as major criteria requiring explicit confirmation before writing a major changeset; releasing this as a patch mislabels a breaking UI command removal. Please restore the command or handle the changeset as a confirmed breaking change.
Useful? React with 👍 / 👎.
listSessionChildrenQuerySchema aliased the main list schema, so it inherited exclude_empty even though the /sessions/{id}/children route does not filter by it. Split it so generated clients are not misled.
|
Codex Review: Didn't find any major issues. 🎉 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 web session list shows empty "New Session" placeholders — sessions that were created but never received a message. They clutter the sidebar and carry no useful content. Separately, the
/sessionsslash command opened a session-browser popup that duplicates what the sidebar already shows.What changed
exclude_emptyquery parameter toGET /api/v1/sessions. When set, the service drops sessions that have nolast_prompt(i.e. never used) before cursor pagination, so every returned page is filled with non-empty sessions andhas_morereflects the filtered set. Default is off, so existing clients are unaffected.exclude_empty: true, so unused "New Session" entries are hidden from the sidebar by default. The earlier client-side filter was removed in favor of the server-side one./sessionsslash command and its session-browser popup; the sidebar already covers session browsing.Added a
SessionService.listtest coveringexcludeEmptytogether with pagination and cursors. Typecheck passes foragent-core,server, andkimi-web; the swagger and api-surface tests pass without snapshot changes.Checklist
gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.