← 返回
数据分析 中文

Session History Enhanced

Session history system for OpenClaw — persistent, browsable, resumable chat sessions with SQLite index, archive/restore, migration, paginated UI, and chat dr...
OpenClaw 的会话历史系统——持久化、可浏览、可恢复的聊天会话,配备 SQLite 索引,支持归档/恢复、迁移、分页 UI,以及聊天...
maverick-software
数据分析 clawhub v1.0.1 1 版本 100000 Key: 无需
★ 0
Stars
📥 783
下载
💾 12
安装
1
版本
#latest

概述

Session History

Transforms OpenClaw's single-slot session model into a multi-session history system with SQLite indexing, archive/restore, and full dashboard UI.

Architecture

~/.openclaw/agents/{agentId}/sessions/
├── sessions.json           # routing table (unchanged)
├── history.db              # SQLite index (auto-created)
├── {activeSessionId}.jsonl # active transcript
└── archive/
    └── {sessionId}.jsonl   # archived transcripts

Lifecycle:

  • On /new or session reset → old transcript moves to archive/, metadata indexed in SQLite
  • On archive (from UI) → session deactivated, transcript archived, indexed, removed from store
  • On resume → transcript moves back from archive/, SQLite status flips to active
  • Migration auto-runs on first access: indexes all orphaned .jsonl files

File Map

Backend (new files)

FileReferencePurpose
--------------------------
src/config/sessions/history-db.tsreferences/backend-history-db.ts.txtSQLite CRUD operations
src/config/sessions/history-migration.tsreferences/backend-history-migration.ts.txtOne-time migration + initHistoryDbWithMigration
src/gateway/session-archive.tsreferences/backend-session-archive.ts.txtArchive/restore logic

Backend (modified files)

FileReferencePurpose
--------------------------
src/gateway/protocol/schema/sessions.tsreferences/backend-protocol-schemas.ts.txtTypeBox schemas for new RPCs
src/gateway/server-methods/sessions.tsreferences/backend-rpc-handlers.ts.txt5 RPC handler implementations

Frontend (modified files)

FileReferencePurpose
--------------------------
ui/src/ui/controllers/sessions.tsreferences/frontend-controllers-sessions.ts.txtFull controller with archived session CRUD + pagination
ui/src/ui/views/sessions.tsreferences/frontend-views-sessions.ts.txtFull view with Session History section, Archive button, pagination
ui/src/ui/app-view-state.tsreferences/frontend-state-changes.txtState + app.ts + app-render.ts + app-chat.ts + app-settings.ts + app-render.helpers.ts wiring

Installation

See references/INSTALL.md for step-by-step instructions.

RPC Endpoints

MethodParamsPurpose
-------------------------
sessions.archivekeyArchive active session — deactivates, moves transcript, indexes in SQLite, removes from store
sessions.archivedagentId?, limit?, offset?, search?, status?List archived sessions with pagination and search
sessions.resumesessionId, agentId?Restore archived session to active
sessions.renamesessionId, displayName, agentId?Update session display name
sessions.deleteArchivedsessionId, agentId?, deleteTranscript?Delete archived session + optional transcript

UI Features

Sessions Page

  • Active Sessions grid — with Archive button (hidden for Main Session), History, Delete
  • Session History section — archived sessions with search, Resume/Rename/Delete buttons
  • Pagination — both sections have 10/20/25 page-size dropdown + Prev/Next

Chat Dropdown

  • Filters out cron/subagent/openai sessions (only user-facing sessions shown)
  • "Recent Sessions" with 10 most recent archived sessions
  • "📋 View All Sessions" link navigates to Sessions tab
  • Selecting an archived session auto-resumes it

Key Design Decisions

  • SQLite over JSON: Supports search, pagination, and indexing without loading everything into memory
  • Server-side pagination for archives: Pass limit/offset to sessions.archived RPC
  • Client-side pagination for live sessions: Slice the already-loaded array
  • sessionId-based dropdown values: Archived sessions all share the same sessionKey (agent:main:main), so the dropdown uses __archived__:{sessionId} as the option value
  • sessions.archive reuses sessions.delete param schema: Both need just { key }

Common Pitfalls

  1. RPC handler signature: Must use ({ params, respond }) destructuring, not (request, respond)
  2. assertValidParams: Takes 4 args: (params, validator, "method.name", respond)
  3. Sessions directory: Use resolveSessionTranscriptsDirForAgent(agentId) — NOT resolveGatewaySessionStoreTarget(config)
  4. Pagination on every load: All loadArchivedSessions calls must pass limit and offset
  5. Page reset: Changing page size or search query must reset page to 1
  6. Archived session dropdown filtering: Filter by sessionId, not sessionKey (all archived sessions share the same sessionKey)

版本历史

共 1 个版本

  • v1.0.1 当前
    2026-03-30 01:56 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

data-analysis

Excel / XLSX

ivangdavila
创建、检查和编辑 Microsoft Excel 工作簿及 XLSX 文件,支持可靠的公式、日期、类型、格式、重算及模板保留功能。
★ 368 📥 140,461
content-creation

Copywriting Pro

maverick-software
为任何形式撰写有说服力、高转化率的文案——广告、着陆页、邮件、销售页、标题、产品描述、CTA和社交帖子。App...
★ 2 📥 4,942
data-analysis

Data Analysis

ivangdavila
{"answer":"数据分析与可视化。查询数据库、生成报告、自动化电子表格,将原始数据转化为清晰可行的见解。适用于:(1) 您……"}
★ 198 📥 65,120