> ## Documentation Index
> Fetch the complete documentation index at: https://docs.myrmagent.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Chat History & Session Management

> Search, organize, export, and manage your conversation history with powerful sidebar tools.

## Overview

MyrmAgent provides a comprehensive chat history management system integrated directly into the sidebar — no separate page needed. Every conversation is organized, searchable, and exportable from one place.

## Full-Text Search (Cmd+K)

Press **⌘+K** (macOS) or **Ctrl+K** (Windows/Linux) anywhere in the app to open the global search dialog.

* **Instant results**: Debounced search queries the backend `/chats/search` API
* **Time range filtering**: Narrow results to Today, This Week, This Month, or This Quarter
* **Snippet highlighting**: Matching text is highlighted in search results
* **Click to jump**: Select a result to navigate directly to the chat and highlight the matching message

## Date-Grouped History

Conversations are automatically grouped into time-based sections:

| Group                | Description                    |
| -------------------- | ------------------------------ |
| **Today**            | Sessions from the current day  |
| **Yesterday**        | Sessions from the previous day |
| **Previous 7 Days**  | Sessions within the past week  |
| **Previous 30 Days** | Sessions within the past month |
| **Older**            | Everything before 30 days      |

Each group can be collapsed/expanded, and the collapsed state persists across sessions via `localStorage`.

## Pinning & Drag-and-Drop Reordering

* **Pin conversations** to the top of the sidebar for quick access
* **Drag-and-drop** pinned items to reorder them using DnD-Kit SortableContext
* Use **keyboard shortcuts** (number keys) to quickly jump to pinned conversations

## Batch Operations

Enter batch mode to select multiple conversations at once:

1. Toggle batch mode from the sidebar header
2. Select/deselect individual chats or use "Select All"
3. **Batch export**: Click "Export" on selected chats, choose a format (Markdown / JSON / HTML), and all conversations are packaged into a ZIP download
4. **Batch delete**: Deleted items go to the **Trash** (soft delete with recovery)

### Batch Export Features

| Feature                     | Description                                                                       |
| --------------------------- | --------------------------------------------------------------------------------- |
| **3-concurrent processing** | Exports 3 chats simultaneously, \~3x faster for large batches                     |
| **Auto retry on failure**   | Failed exports are retried once automatically                                     |
| **Date-based folders**      | ZIP organizes chats by date, e.g. `2026-07-15/Chat Title.md`                      |
| **Real-time progress bar**  | Shows current progress and the chat being processed                               |
| **Cancelable**              | Cancel anytime during export without waiting for completion                       |
| **Fault-tolerant**          | Individual failures don't block the batch; summary reports success/failure counts |

## Export Conversations

Right-click any conversation to export in four formats:

* **Markdown** — Clean `.md` file with message formatting
* **HTML** — Styled HTML page ready to share
* **JSON** — Structured data for programmatic use
* **Copy to clipboard** — Quick paste anywhere

### Diagnostic Information in Exports

Exported files automatically include metadata for debugging and workflow reproduction:

| Info                  | Description                                                                               |
| --------------------- | ----------------------------------------------------------------------------------------- |
| **Agent Identity**    | Name, model, and description of the agent that generated the response                     |
| **Tool Call Details** | Argument summary, execution duration, and success/failure status for each tool invocation |
| **Token Usage**       | Total tokens consumed and cost estimate for the conversation                              |
| **Tool Usage Stats**  | Call count and total duration per tool                                                    |

<Note>
  Sensitive information in tool arguments (API keys, passwords, tokens, etc.) is automatically redacted to `***` for safe sharing.
</Note>

### Print Conversation

The right-click menu also offers a "Print" option to print or save the current conversation as PDF. Uses a hidden iframe to invoke the browser's native print dialog, bypassing popup blockers.

### Share Conversation

Generate a **read-only public link** for any conversation via the right-click menu → "Share":

* **Time-limited**: Links expire after 1–30 days (configurable)
* **Revocable**: One-click revoke invalidates the link immediately
* **Secure**: HMAC-signed URLs, strict CSP headers, no scripts, X-Frame-Options DENY
* **Rich rendering**: Server-side Markdown rendering with syntax-highlighted code blocks, tables, and dark mode support
* **Agent identity**: Shows the agent name and model used in the conversation

In local/desktop mode, a fallback message guides users to export HTML instead (localhost URLs are not externally reachable).

## Project Folders

Organize conversations into named projects with color labels:

* Move conversations between projects via the context menu
* Filter the sidebar to show only a specific project's conversations
* Project assignments persist across sessions

## Trash & Recovery

Accidentally deleted a conversation? The **Session Trash Panel** provides:

* Soft-deleted conversations are kept for recovery
* One-click restore to bring back any deleted session
* Permanent delete when you're sure

## Source Filtering

Filter conversations by their origin channel — Web UI, Telegram, Discord, WeChat, and 35+ other platforms.

## Infinite Scrolling

The sidebar uses `IntersectionObserver`-based infinite scrolling — no pagination buttons. Conversations load automatically as you scroll down.

## Additional Features

| Feature                        | Description                                                                                                                                                         |
| ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Inline rename**              | Click the title to rename any conversation                                                                                                                          |
| **Handoff**                    | Transfer a conversation to another agent or channel via HandoffDialog                                                                                               |
| **Create automation**          | Turn a conversation pattern into a scheduled task with CronJobCreateDialog                                                                                          |
| **Compacted badge**            | Visual indicator when a conversation has been context-compressed                                                                                                    |
| **Real-time status indicator** | Dual-color pulse: emerald for generating, amber for awaiting approval — cross-session awareness without switching                                                   |
| **PWA Install**                | One-click PWA installation from the sidebar                                                                                                                         |
| **Appearance**                 | Settings → Preferences: dark/light theme, 6 brand accent skins, 3 font presets (including accessibility), zero-flash on reload — PWA status bar color stays in sync |
| **Catchup Inbox**              | Aggregated unread messages across all channels                                                                                                                      |
| **Workspace file browser**     | Browse CLI and Web workspace files directly from the sidebar                                                                                                        |

## Message Edit & Resend

Edit any previous message to retry with different wording. MyrmAgent ensures full front-end and back-end consistency when you edit and resend:

1. **Atomic truncation** — Messages after the edited one are removed from the database *before* the new message is sent, so the agent never sees stale context
2. **Version preservation** — Regenerated responses are stored as sibling versions (`is_active` flag); switch between versions using the left/right arrows on any assistant message
3. **Smart Regeneration** — Four preset modes (Try Again, More Concise, More Detailed, More Creative) plus custom instruction. The instruction is injected into the agent's context as `[Regeneration guidance: ...]`, directly steering the new response
4. **Complaint-Up auto-escalation** — When you regenerate *without* a custom instruction (plain retry), the system interprets this as implicit dissatisfaction and automatically upgrades the model tier (SIMPLE→STANDARD→REASONING) for a higher-quality response — no manual model switching needed
5. **Undo last turn** — One click removes the last user + assistant message pair and updates the conversation state
6. **Conversation forking** — Fork from any message to explore an alternative path without losing the original thread. Three entry points: sidebar right-click menu, `/fork` slash command, and mobile action sheet. Use `message_index=-1` to fork from the latest message instantly. When context usage exceeds 75%, a "Fork new topic" button appears in the context usage panel for quick topic branching. If the parent conversation has an active sandbox (git worktree), the forked child automatically resets to the original repository root — preventing file conflicts from multiple conversations sharing the same sandbox workspace

<Tip>
  Unlike many competitors that only truncate locally, MyrmAgent's backend-first approach prevents "ghost messages" from polluting agent context — every edit is a clean slate.
</Tip>

## Mid-Stream Redirect (Busy Input)

When the agent is actively generating a response, pressing Enter sends your correction as a **redirect** — interrupting the current generation immediately without waiting for completion:

| Mode                   | Behavior                                                                                               | When to use                                                             |
| ---------------------- | ------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------- |
| **Redirect** (default) | Interrupts mid-generation, preserves partial output in context, starts fresh turn with your correction | Agent is going in the wrong direction                                   |
| **Steer**              | Waits for current generation/tool to finish, then injects your message for the next turn               | Agent is doing something useful but needs a course correction afterward |
| **Queue**              | Adds your message to a queue, sent automatically after the current task completes                      | You want to line up follow-up work without interrupting                 |

Key benefits of redirect mode:

* **Zero wasted tokens** — Stops generation the moment you realize the direction is wrong (saves 200–1800 tokens per redirect)
* **Context consistency** — Partial AI output is preserved as an AIMessage so the LLM sees the same context you saw
* **Prompt cache friendly** — Preserved partial text maintains the message prefix, improving cache hit rates on the next call
* **Zero learning curve** — Default Enter behavior, no special key combo needed

Change the default mode in **Settings → Agent → Busy Input Mode** (`redirect` / `steer` / `queue`).

## vs Competitor Approaches

Most competitors (e.g., Hermes Agent) use a separate `/history` page that duplicates sidebar functionality. MyrmAgent follows the same pattern as ChatGPT, Claude, and Gemini — **sidebar-integrated history** — while providing 16 additional capabilities that the separate-page approach lacks.

<Tip>
  The sidebar approach keeps your workflow uninterrupted. You never leave your current conversation to search, export, or manage history.
</Tip>
