Session History Enhanced
简介
Session History Enhanced
原始描述
Session history system for OpenClaw — persistent, browsable, resumable chat sessions with SQLite index, archive/restore, migration, paginated UI, and chat dr...
通过你的 Agent 添加
安装目录:session-history/(目录名取自 SKILL.md 的 frontmatter name,不是 URL 里的 slug)。
点「快速安装」复制一段指令贴给你的 Agent:它会先下载到 /tmp、把文件清单和校验值给你看,你确认之后才解压安装。不会一步装完、也不改系统其它位置。
或者手动安装
包是「根级 SKILL.md + 作者附带的文件」,解压到上面的 <slug>/ 目录即可;
目录名不用换,也不要把包直接解压到 skills 根目录。
技能申请的权限由作者决定:装之前先看清单里有没有脚本、它会读写什么。
技能正文
name: session-history
description: "Session history system for OpenClaw — persistent, browsable, resumable chat sessions with SQLite index, archive/restore, migration, paginated UI, and chat dropdown integration. Use when: (1) adding session archival/indexing to OpenClaw, (2) implementing session browsing/search in the dashboard, (3) adding session resume/rename/delete, (4) fixing session RPC handlers, (5) adding pagination to session lists, or (6) integrating recent sessions into the chat dropdown."
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
~/.openclaw/agents/{agentId}/sessions/
├── sessions.json # routing table (unchanged)
├── history.db # SQLite index (auto-created)
├── {activeSessionId}.jsonl # active transcript
└── archive/
└── {sessionId}.jsonl # archived transcripts
On /new or session reset: old transcript moves to archive/, metadata is indexed in SQLite.
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)
| File | Reference | Purpose |
|---|---|---|
src/config/sessions/history-db.ts |
references/backend-history-db.ts.txt | SQLite CRUD operations |
src/config/sessions/history-migration.ts |
references/backend-history-migration.ts.txt | One-time migration + initHistoryDbWithMigration |
src/gateway/session-archive.ts |
references/backend-session-archive.ts.txt | Archive/restore logic |
Backend (modified files)
File
Reference
Purpose
src/gateway/protocol/schema/sessions.ts
references/backend-protocol-schemas.ts.txt
TypeBox schemas for 4 new RPCs
src/gateway/server-methods/sessions.ts
references/backend-rpc-handlers.ts.txt
RPC handler implementations
Frontend (modified files)
File
Reference
Purpose
ui/src/ui/controllers/sessions.ts
references/frontend-controllers-sessions.ts.txt
Full controller with archived session CRUD + pagination
ui/src/ui/views/sessions.ts
references/frontend-views-sessions.ts.txt
Full view with Session History section + pagination
ui/src/ui/app-view-state.ts
references/frontend-state-changes.txt
State additions + app.ts + app-render.ts + app-chat.ts + app-settings.ts wiring
Installation
| File | Reference | Purpose |
|---|---|---|
src/gateway/protocol/schema/sessions.ts |
references/backend-protocol-schemas.ts.txt | TypeBox schemas for 4 new RPCs |
src/gateway/server-methods/sessions.ts |
references/backend-rpc-handlers.ts.txt | RPC handler implementations |
| File | Reference | Purpose |
|---|---|---|
ui/src/ui/controllers/sessions.ts |
references/frontend-controllers-sessions.ts.txt | Full controller with archived session CRUD + pagination |
ui/src/ui/views/sessions.ts |
references/frontend-views-sessions.ts.txt | Full view with Session History section + pagination |
ui/src/ui/app-view-state.ts |
references/frontend-state-changes.txt | State additions + app.ts + app-render.ts + app-chat.ts + app-settings.ts wiring |
Installation
See references/INSTALL.md for step-by-step instructions.
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. Every call must include these.
- Client-side pagination for live sessions: Slice the already-loaded array — live sessions are always few enough to fit in memory
- Auto-migration:
initHistoryDbWithMigration runs migration on first access if not already completed
- Chat dropdown integration: Recent archived sessions appear in
<optgroup>, with "View All Sessions" navigation link
Common Pitfalls
- RPC handler signature: Must use
({ params, respond }) destructuring, not (request, respond)
- assertValidParams: Takes 4 args:
(params, validator, "method.name", respond)
- Sessions directory: Use
resolveSessionTranscriptsDirForAgent(agentId) — NOT resolveGatewaySessionStoreTarget(config)
- Pagination on every load: All
loadArchivedSessions calls must pass limit and offset — initial, refresh, search, resume, rename, delete reloads
- Page reset: Changing page size or search query must reset page to 1
limit/offset to sessions.archived RPC. Every call must include these.initHistoryDbWithMigration runs migration on first access if not already completed<optgroup>, with "View All Sessions" navigation link- RPC handler signature: Must use
({ params, respond })destructuring, not(request, respond) - assertValidParams: Takes 4 args:
(params, validator, "method.name", respond) - Sessions directory: Use
resolveSessionTranscriptsDirForAgent(agentId)— NOTresolveGatewaySessionStoreTarget(config) - Pagination on every load: All
loadArchivedSessionscalls must passlimitandoffset— initial, refresh, search, resume, rename, delete reloads - Page reset: Changing page size or search query must reset page to 1
正文来自原始发布页, 版权归作者所有,许可未标注。 权利人认为有不妥,可申请下架。