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

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.
@changeset-bot

changeset-bot Bot commented Jun 11, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 70215e9

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a 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 👍 / 👎.

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