feat(server): support restoring and listing archived sessions#1073
feat(server): support restoring and listing archived sessions#1073sailist wants to merge 3 commits into
Conversation
- 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 detectedLatest commit: 1e24920 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: 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".
| items: page.items.filter((session) => session.archived === true), | ||
| has_more: page.has_more, |
There was a problem hiding this comment.
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 👍 / 👎.
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:
:restoresession action that clears the archived flag from the persisted session state.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:
archived_onlylist query parameter.include_archiveto avoid ambiguous list semantics.Validation
pnpm --filter @moonshot-ai/server typecheckpnpm --filter @moonshot-ai/server exec vitest run test/sessions.e2e.test.tsChecklist
gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.