Skip to content

feat(sessions): add archive/unarchive for sessions#674

Open
grandmaster451 wants to merge 1 commit into
MoonshotAI:mainfrom
grandmaster451:feat/session-archive
Open

feat(sessions): add archive/unarchive for sessions#674
grandmaster451 wants to merge 1 commit into
MoonshotAI:mainfrom
grandmaster451:feat/session-archive

Conversation

@grandmaster451

Copy link
Copy Markdown

Adds session archiving so users can hide inactive sessions from the default session picker without deleting them.

Changes

  • Add archive/unarchive slash command in the TUI.
  • Add kimi session archive <id> and kimi session unarchive <id> CLI subcommands.
  • Extend the session store, core RPC, and SDK to persist and surface the archived flag.
  • Filter archived sessions from the default picker and show an archived badge when viewing all sessions.
  • Add unit tests for the slash command, CLI subcommand, and picker filtering.

Testing

  • pnpm vitest run apps/kimi-code/test/tui/commands/session.test.ts
  • pnpm vitest run apps/kimi-code/test/cli/session.test.ts
  • pnpm vitest run apps/kimi-code/test/tui/utils/session-picker-rows.test.ts
  • pnpm vitest run apps/kimi-code/test/tui/components/dialogs/session-picker.test.ts
  • pnpm run typecheck in packages/agent-core, packages/node-sdk, and apps/kimi-code

@changeset-bot

changeset-bot Bot commented Jun 11, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 1e72bfc

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

This PR includes changesets to release 5 packages
Name Type
@moonshot-ai/agent-core Minor
@moonshot-ai/kimi-code-sdk Minor
@moonshot-ai/kimi-code Minor
@moonshot-ai/acp-adapter Patch
@moonshot-ai/migration-legacy 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

@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: 70215e9f45

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

sessionId: entry.sessionId,
sessionDir: entry.sessionDir,
workDir: entry.workDir,
archived: entry.archived === true,

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 archived flag when loading the session index

Although this parses archived from each JSONL entry, readSessionIndex() drops it when it stores the sanitized entry in the returned Map (the result.set(...) object only keeps sessionId, sessionDir, and workDir). Because SessionStore.listAll() filters on entry.archived before reading state.json, an archived session still appears in listSessions() calls that are not scoped to a workDir, even with includeArchived omitted.

Useful? React with 👍 / 👎.

Comment on lines +410 to +415
async archiveSession({ sessionId }: ArchiveSessionPayload): Promise<SessionSummary> {
return this.sessionStore.archive(sessionId);
}

async unarchiveSession({ sessionId }: UnarchiveSessionPayload): Promise<SessionSummary> {
return this.sessionStore.unarchive(sessionId);

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 Update active session metadata when archiving

When the archived session is currently open, these RPC methods write state.json through SessionStore but leave the active Session object's in-memory metadata unchanged. If the user archives/unarchives the current TUI session and then sends another prompt (or otherwise triggers SessionAPIImpl.updatePromptMetadata() / writeMetadata()), that later write spreads the stale in-memory metadata and can remove or restore the old archived value, so the archive state does not persist reliably for active sessions.

Useful? React with 👍 / 👎.

Adds session archiving so users can hide inactive sessions from the
default session picker without deleting them.

- Add `archive`/`unarchive` slash command in the TUI.
- Add `kimi session archive <id>` and `kimi session unarchive <id>` CLI
  subcommands.
- Extend the session store, core RPC, and SDK to persist and surface the
  archived flag.
- Filter archived sessions from the default picker and show an archived badge
  when viewing all sessions.
- Add unit tests for the slash command, CLI subcommand, and picker filtering.
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