Skip to content

feat(server): support restoring and listing archived sessions#1073

Open
sailist wants to merge 3 commits into
MoonshotAI:mainfrom
sailist:feat/restore-archived-sessions
Open

feat(server): support restoring and listing archived sessions#1073
sailist wants to merge 3 commits into
MoonshotAI:mainfrom
sailist:feat/restore-archived-sessions

Conversation

@sailist

@sailist sailist commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

Related Issue

No linked issue; the problem is described below.

Problem

Archived sessions could be included in session listings, but server clients had no API to restore an archived session or to query only archived sessions. That blocks the web archive/resume flow, where the UI needs to bring an archived session back before resuming it.

What changed

Restore archived sessions through the server API

Problem: Clients could see archived sessions but could not restore them through the server.

What was done:

  • Added a :restore session action that clears the archived flag from the persisted session state.
  • Returned the restored session so callers can immediately continue the resume flow.
  • Added server e2e coverage for restoring archived sessions and for missing-session restore errors.

List only archived sessions

Problem: The existing list API could include archived sessions, but it could not filter to archived sessions only.

What was done:

  • Added an archived_only list query parameter.
  • Kept it mutually exclusive with include_archive to avoid ambiguous list semantics.
  • Added e2e coverage for archived-only listing and the mutual-exclusion validation.

Validation

  • pnpm --filter @moonshot-ai/server typecheck
  • pnpm --filter @moonshot-ai/server exec vitest run test/sessions.e2e.test.ts

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.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

- add a `:restore` session action that clears the archived flag in state.json and returns the restored session
- add an `archived_only` list query param, mutually exclusive with `include_archive`, that post-filters to archived sessions
- keep the implementation in the server layer as a temporary measure until agent-core exposes restore natively
@changeset-bot

changeset-bot Bot commented Jun 24, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 1e24920

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 Minor

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 Jun 24, 2026

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

commit: 1e24920

@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: 1d31b4283d

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

Comment thread packages/server/src/routes/sessions.ts Outdated
Comment on lines +317 to +318
items: page.items.filter((session) => session.archived === true),
has_more: page.has_more,

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 Filter archived sessions before paginating

When archived sessions are sparse, this post-filter can make /sessions?archived_only=true&page_size=1 return items: [] with has_more: true if the newest session is live and an older one is archived. Since pagination uses returned session ids as before_id/after_id, the client has no cursor to advance past that empty filtered page, so older archived sessions become unreachable; the archived-only predicate needs to be applied before pagination or the route needs an unfiltered cursor.

Useful? React with 👍 / 👎.

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