Skip to content

[Bug]: Control UI Crashes When Session Conversation History Is Too Large #45687

@Hengdiwu

Description

@Hengdiwu

Bug type

Regression (worked before, now fails)

Summary

## Bug: Control UI Crashes When Session Conversation History Is Too Large

### Environment
- **OpenClaw Version**: 2026.3.12
- **Node Version**: v24.14.0
- **OS**: Darwin 25.2.0 (arm64) - macOS
- **Browser**: Chrome / Safari
- **Deployment Mode**: local (localhost)

### Problem Description
The Control UI (Web Chat interface) fails to load properly when a session has many conversation, UI Crashes。 Manifests as page freeze, unresponsive, or crash.

### Steps to Reproduce
1. Start OpenClaw Gateway: `openclaw gateway start`
2. Have a multi-turn conversation via any channel (Feishu/Telegram/Webchat)
3. After 50-200 messages accumulate, refresh the Control UI in browser (usually http://localhost:18789)
4. Observe page loading behavior

### Test Data

**Session File Sizes:**
| Session ID | File Size | Lines | Status |
|------------|-----------|-------|--------|
| 07f595c0-... | 591 KB | 201 | obsolete |
| 1a61747b-... | 247 KB | 149 | main session |
| b07973c7-... | 185 KB | 72 | current active |

**sessions.json Contents:**
- Contains complete metadata for 2 sessions
- Each session stores full `systemPromptReport` (~30KB each)
- `systemPromptReport.tools.schemaChars`: 27,115 characters
- `systemPromptReport.systemPrompt.chars`: 31,666 characters

**sessions Directory Total Size:**
- Before cleanup: ~3.2MB
- After cleanup: ~500KB

### Root Cause Analysis

1. **No Pagination**
   - UI loads and renders all sessions at once
   - Missing `limit` / `offset` pagination support

2. **Redundant Data in sessions.json**
   - Each session stores complete `systemPromptReport`
   - Contains 37 tools' complete schema (27KB)
   - Unnecessary for UI list display

3. **No Virtual Scrolling**
   - When session count > 10, too many DOM nodes
   - No virtual scrolling or windowing implementation

### Expected Fix

**Option A: Reduce Loaded Data**
- Remove `systemPromptReport` field from sessions.json
- Or create lightweight session list API

**Option B: Add Pagination**
- UI adds pagination, load 10-20 sessions at a time
- Gateway supports `?page=1&limit=20` parameter

**Option C: Virtual Scrolling**
- Use react-virtual / vue-virtual-scroller
- Only render visible DOM nodes

### Temporary Workaround

Manually delete obsolete session files:
```bash
rm /Users/hd/.openclaw/agents/main/sessions/*.jsonl
# Keep sessions.json and active session

Affected Code Paths

  • UI Static Assets: /usr/local/lib/node_modules/openclaw/dist/control-ui/
  • Session Storage: /Users/hd/.openclaw/agents/main/sessions/
  • Gateway API:推测在 src/gateway/routes/sessions.ts

Impact

  • All Control UI users affected
  • Reproducible when session > 50 messages
  • Severely degraded user experience

Priority

High - Functional bug affecting core use case


Ready to submit to GitHub Issues. Want me to post it?

### Steps to reproduce

1. Start OpenClaw Gateway: `openclaw gateway start`
2. Have a multi-turn conversation via any channel (Feishu/Telegram/Webchat)
3. After 50-200 messages accumulate, refresh the Control UI in browser (http://localhost:18789)
4. Observe page loading behavior

### Expected behavior

- Control UI should load within 2-3 seconds
- User should be able to see session list and select any session
- Page should remain responsive during normal usage

### Actual behavior

- Page becomes unresponsive during load
- Browser tab may crash or show "Page Unresponsive" dialog
- After crash, user cannot interact with the UI until restart
- Sometimes the tab needs to be force-closed

### OpenClaw version

2026.3.12

### Operating system

maxOS Tahoe 26.3.1

### Install method

_No response_

### Model

minimax

### Provider / routing chain

Webchat (Control UI)

### Config file / key location

_No response_

### Additional provider/model setup details

_No response_

### Logs, screenshots, and evidence

```shell

Impact and severity

No response

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingregressionBehavior that previously worked and now fails

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions