Skip to content

feat: add /export-session command to export session with full system prompt - #18010

Merged
steipete merged 6 commits into
openclaw:mainfrom
boris721:feature/export-session
Feb 16, 2026
Merged

steipete merged 6 commits into
openclaw:mainfrom
boris721:feature/export-session

Conversation

@boris721

@boris721 boris721 commented Feb 16, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds /export-session (alias /export) command that exports the current session to a standalone HTML file including the complete system prompt.

Motivation

Currently there is no easy way to inspect or share a session with its full context (system prompt, tools, conversation). The pi-mono CLI has /share which uploads to a gist, but:

  • Not everyone wants to upload sessions externally
  • OpenClaw users often run headless/remote where browser opening is not practical

This command generates a local HTML file making it easy to:

  • Debug/inspect the full system prompt
  • Share sessions offline
  • Archive conversations with full context

Usage

/export-session           # Export to workspace (default)
/export-session ~/backup  # Export to custom path
/export                   # Alias

Output:

✅ Session exported!

📄 File: openclaw-session-3c5dbbc0-2026-02-16T12-30-00.html
📊 Entries: 42
🧠 System prompt: 40,344 chars
🔧 Tools: 47

Implementation

  • Self-contained templates: HTML/CSS/JS templates are bundled in src/auto-reply/reply/export-html/ (~250KB) — no runtime dependency on pi-coding-agent internal files
  • Uses pi-mono dark theme colors for consistent styling
  • Builds full system prompt via existing buildAgentSystemPrompt()
  • Uses resolveUserPath() for proper path handling
  • Registered as both native command and text alias

Files Changed

  • src/auto-reply/reply/commands-export-session.ts - New handler (~280 lines)
  • src/auto-reply/reply/export-html/ - Bundled HTML templates
  • src/auto-reply/commands-registry.data.ts - Command registration
  • src/auto-reply/reply/commands-core.ts - Handler wiring
  • src/auto-reply/reply/commands-info.ts - Export
  • scripts/copy-export-html-templates.ts - Build script
  • package.json - Add copy script to build

Testing

Tested locally via Signal. The exported HTML renders correctly with:

  • Full conversation history
  • Complete system prompt (viewable in sidebar)
  • Tool definitions
  • Proper dark theme styling

Happy to address any feedback! 🦞

Export current session to HTML file with full system prompt included.
Uses pi-coding-agent templates for consistent rendering.

Features:
- Exports session entries + full system prompt + tools
- Saves to workspace by default, or custom path
- Optional --open flag to open in browser
- Reuses pi-mono export-html templates

Usage:
  /export-session           # Export to workspace
  /export-session ~/export  # Export to custom path
  /export-session --open    # Export and open in browser
…odules

- Copy templates from pi-coding-agent into src/auto-reply/reply/export-html/
- Add build script to copy templates to dist/
- Remove fragile node_modules path traversal
- Templates are now self-contained (~250KB total)
@openclaw-barnacle openclaw-barnacle Bot added scripts Repository scripts size: XL and removed size: M labels Feb 16, 2026

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

6 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

Comment thread package.json Outdated
"long": "^5.3.2",
"markdown-it": "^14.1.1",
"node-edge-tts": "^1.2.10",
"openclaw": "link:../../Library/pnpm/global/5/node_modules/openclaw",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

local dev dependency accidentally committed

this link: dependency points to a specific machine path and will break CI/CD and other developers' environments

Suggested change
"openclaw": "link:../../Library/pnpm/global/5/node_modules/openclaw",
Prompt To Fix With AI
This is a comment left during a code review.
Path: package.json
Line: 167:167

Comment:
local dev dependency accidentally committed

this `link:` dependency points to a specific machine path and will break CI/CD and other developers' environments

```suggestion
```

How can I resolve this? If you propose a fix, please make it concise.

@greptile-apps

greptile-apps Bot commented Feb 16, 2026

Copy link
Copy Markdown
Contributor
Additional Comments (1)

src/auto-reply/reply/commands-export-session.ts
use resolveUserPath from src/utils.ts instead of manual tilde expansion with process.env.HOME

the codebase has a standard utility (resolveUserPath) that properly handles tilde expansion with fallbacks and edge cases. see line 295 in src/utils.ts

    ? resolveUserPath(args.outputPath)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/auto-reply/reply/commands-export-session.ts
Line: 322:322

Comment:
use `resolveUserPath` from `src/utils.ts` instead of manual tilde expansion with `process.env.HOME`

the codebase has a standard utility (`resolveUserPath`) that properly handles tilde expansion with fallbacks and edge cases. see line 295 in `src/utils.ts`

```suggestion
    ? resolveUserPath(args.outputPath)
```

<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>

How can I resolve this? If you propose a fix, please make it concise.

@boris721

Copy link
Copy Markdown
Contributor Author

Thanks for the review! Both issues have been addressed:

  1. ✅ Package.json link dependency - Removed in commit b3ac287
  2. ✅ resolveUserPath - Now using the standard utility in commit 6b39002

The templates are now fully bundled in src/auto-reply/reply/export-html/ instead of reading from node_modules at runtime.

@steipete
steipete merged commit f82a3d3 into openclaw:main Feb 16, 2026
3 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Thanks again for the work here, and sorry for the churn.

We accidentally merged a batch of PRs and need to temporarily roll this back for now.

Revert details:

  • merged commit SHA: f82a3d3e2bb47f1cac5eff036380a52df1420d20
  • revert commit SHA: 4fa35d3fd9f6a263f7586f18fbcc9f9b92b30744

We can't repope right now, but we will revisit this later and bring this back properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scripts Repository scripts size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants