Skip to content

feat: add git-based workspace backup#131

Draft
dev01lay2 wants to merge 13 commits intodevelopfrom
feat/git-workspace-backup
Draft

feat: add git-based workspace backup#131
dev01lay2 wants to merge 13 commits intodevelopfrom
feat/git-workspace-backup

Conversation

@dev01lay2
Copy link
Copy Markdown
Collaborator

@dev01lay2 dev01lay2 commented Mar 17, 2026

Summary

Based on OpenClaw docs: Git backup (recommended, private), optimizes ClawPal's backup of managed OpenClaw instances in two ways:

  1. Fix: existing copy-based backup now includes workspace (was missing entirely on remote, partially on local)
  2. Feature: adds git-based workspace backup as the docs-recommended approach

Context

ClawPal manages OpenClaw instances (local or remote via SSH). The backup feature protects instance data before upgrades. The workspace (~/.openclaw/workspace) contains the agent's memory and personality files (AGENTS.md, SOUL.md, USER.md, memory/, skills/) — the most important data to back up.

Before this PR:

  • Remote backup: only copied openclaw.json + agents/ + memory/ (wrong path) — workspace not backed up
  • Local backup: copied ~/.openclaw/ recursively — workspace included only if at default path
  • No git integration

Changes

1. Fix copy-based backup to include workspace

remote_backup_before_upgrade: reads workspace path from remote openclaw.json (agents.defaults.workspace), copies it to backup/workspace/

remote_restore_from_backup: restores workspace from backup, resolving target path from config

backup_before_upgrade (local): also copies workspace when configured outside ~/.openclaw/ (custom path), skips .git dir

restore_from_backup (local): restores workspace to custom path if backed up separately

2. Git-based workspace backup (new feature)

Core layer (clawpal-core/src/backup.rs):

  • WorkspaceGitStatus struct — repo state tracking (branch, remote URL, uncommitted count, ahead/behind, last commit)
  • Shell command builders for git probe, commit+push, init+.gitignore
  • WORKSPACE_GITIGNORE matching docs recommendation
  • 7 new unit tests

Tauri commands (src-tauri/src/commands/backup.rs):

  • workspace_git_status / remote_workspace_git_status — probe git state on managed instance
  • workspace_git_backup / remote_workspace_git_backup — commit + push
  • workspace_git_init / remote_workspace_git_init — init repo + .gitignore

Both local and remote paths follow the same dispatch pattern as existing backup commands.

Frontend (WorkspaceGitBackup.tsx):

  • Status card: branch, remote URL, uncommitted changes (amber ⚠) / clean (green ✓)
  • "Sync Now" button — git add + commit + push
  • "Initialize Git" for non-git workspaces
  • Integrated into BackupsPanel above copy-based backups
  • i18n (en + zh)

Testing

  • cargo test -p clawpal-core --lib backup — 18/18 pass (7 new + 11 existing)
  • npx tsc --noEmit — zero TypeScript errors

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 17, 2026

📊 Test Coverage Report

Metric Base (develop) PR (feat/git-workspace-backup) Delta
Lines 74.65% (6303/8443) 75.00% (6424/8565) 🟢 +0.35%
Functions 69.35% (724/1044) 69.67% (735/1055) 🟢 +0.32%
Regions 76.00% (10363/13635) 76.26% (10525/13801) 🟢 +0.26%

Coverage measured by cargo llvm-cov (clawpal-core + clawpal-cli).

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 17, 2026

📦 PR Build Artifacts

Platform Download Size
Windows-x64 📥 clawpal-Windows-x64 27.4 MB
Linux-x64 📥 clawpal-Linux-x64 105.8 MB
macOS-ARM64 📥 clawpal-macOS-ARM64 13.2 MB
macOS-x64 📥 clawpal-macOS-x64 14.0 MB

🔨 Built from 9eb231d · View workflow run
⚠️ Unsigned development builds — for testing only

@dev01lay2 dev01lay2 force-pushed the feat/git-workspace-backup branch 2 times, most recently from e5d12bf to de632dd Compare March 18, 2026 09:43
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 18, 2026

📏 Metrics Gate Report

Status: ✅ All gates passed

Commit Size ❌

Metric Value Limit Status
Commits checked 13
All within limit 12/13 ≤ 500 lines
Largest commit 1016 lines ≤ 500

Bundle Size ✅

Metric Value Limit Status
JS bundle (raw) 1080 KB
JS bundle (gzip) 330 KB ≤ 350 KB
JS initial load (gzip) 174 KB ≤ 180 KB

Perf Metrics E2E ✅

Metric Value Limit Status
Tests 10 passed, 0 failed 0 failures
RSS (test process) 3.1 MB ≤ 20 MB
VMS (test process) 270.1 MB ℹ️
Command P50 latency 34 µs ≤ 1000 µs
Command P95 latency 43 µs ≤ 5000 µs
Command max latency 51 µs ≤ 50000 µs

Command Perf (local) ✅

Metric Value Status
Tests 4 passed, 0 failed
Commands measured 5 ℹ️
RSS (test process) 4.4 MB ℹ️
Local command timings
Command P50 (µs) P95 (µs) Max (µs)
local_openclaw_config_exists 2 10 10
list_ssh_hosts 3 12 12
get_app_preferences 14 42 42
read_app_log 78 119 119
read_error_log 6 14 14

Command Perf (remote SSH) ✅

Metric Value Status
SSH transport OK
Command failures 12/15 runs ℹ️ Docker (no gateway)
Remote command timings (via Docker SSH)
Command Median Max
openclaw_status 2103 ms 2128 ms
cat__root_.openclaw_openclaw.json 248 ms 274 ms
openclaw_gateway 2288 ms 2303 ms
openclaw_cron 2143 ms 2170 ms
openclaw_agent 2278 ms 2393 ms

Home Page Render Probes (real IPC) ✅

Probe Value Limit Status
status 48 ms ≤ 500 ms
version 122 ms ≤ 500 ms
agents 7 ms ≤ 500 ms
models 7 ms ≤ 500 ms
settled 132 ms ≤ 500 ms

Code Readability

File Lines Target Status
commands/mod.rs 11853 ≤ 300 ⚠️
commands/doctor_assistant.rs 5637 ≤ 3000 ⚠️
commands/rescue.rs 3402 ≤ 2000 ⚠️
cli_runner.rs 3266 ≤ 1200 ⚠️
commands/profiles.rs 1891 ≤ 1500 ⚠️
commands/sessions.rs 1807 ≤ 1100 ⚠️
commands/discovery.rs 1641 ≤ 1000 ⚠️
commands/credentials.rs 1629 ≤ 1000 ⚠️
openclaw_doc_resolver.rs 1362 ≤ 800 ⚠️
commands/ssh.rs 1216 ≤ 700 ⚠️
commands/doctor.rs 1193 ≤ 700 ⚠️
recipe_adapter_tests.rs 1100 ≤ 700 ⚠️
commands/backup.rs 1076 ≤ 600 ⚠️
agent_identity.rs 937 ≤ 600 ⚠️
ssh.rs 904 ≤ 500 ⚠️
pages/StartPage.tsx 898 ≤ 500 ⚠️
pages/Settings.tsx 897 ≤ 500 ⚠️
recipe_library.rs 884 ≤ 500 ⚠️
pages/Cook.tsx 881 ≤ 500 ⚠️
pages/Recipes.tsx 875 ≤ 500 ⚠️
pages/Home.tsx 867 ≤ 500 ⚠️
lib/types.ts 864 ≤ 500 ⚠️
recipe_library_tests.rs 861 ≤ 500 ⚠️
install/commands.rs 839 ≤ 500 ⚠️
lib/use-api.ts 790 ≤ 500 ⚠️
recipe_adapter.rs 757 ≤ 500 ⚠️
pages/RecipeStudio.tsx 680 ≤ 500 ⚠️
components/SessionAnalysisPanel.tsx 666 ≤ 500 ⚠️
commands/model.rs 645 ≤ 500 ⚠️
bridge_client.rs 645 ≤ 500 ⚠️
recipe_action_catalog.rs 631 ≤ 500 ⚠️
lib/actions.ts 622 ≤ 500 ⚠️
components/InstallHub.tsx 619 ≤ 500 ⚠️
App.tsx 617 ≤ 500 ⚠️
recipe_workspace.rs 613 ≤ 500 ⚠️
agent_fallback.rs 609 ≤ 500 ⚠️
recipe.rs 596 ≤ 500 ⚠️
commands/config.rs 549 ≤ 500 ⚠️
recipe_runtime/systemd.rs 537 ≤ 500 ⚠️
commands/discord.rs 535 ≤ 500 ⚠️
lib/api.ts 534 ≤ 500 ⚠️
commands/overview.rs 533 ≤ 500 ⚠️
install/runners/docker.rs 525 ≤ 500 ⚠️
commands/types.rs 520 ≤ 500 ⚠️
commands/instance.rs 501 ≤ 500 ⚠️
markdown_document.rs 497 ≤ 500
pages/Doctor.tsx 479 ≤ 500
pages/Channels.tsx 477 ≤ 500
node_client.rs 452 ≤ 500
commands/discover_local.rs 441 ≤ 500
lib/__tests__/guidance.test.ts 439 ≤ 500
recipe_executor.rs 437 ≤ 500
components/__tests__/DoctorRecoveryOverview.test.tsx 429 ≤ 500
pages/Cron.tsx 428 ≤ 500
recipe_executor_tests.rs 422 ≤ 500
hooks/useInstanceDataStore.ts 421 ≤ 500
lib.rs 416 ≤ 500
bug_report/queue.rs 409 ≤ 500
lib/api-read-cache.ts 405 ≤ 500
commands/channels.rs 405 ≤ 500
components/__tests__/InstanceCard.test.tsx 400 ≤ 500
components/DoctorRecoveryOverview.tsx 383 ≤ 500
pages/Orchestrator.tsx 372 ≤ 500
recipe_tests.rs 360 ≤ 500
lib/use-cached-query.ts 353 ≤ 500
hooks/useSshConnection.ts 352 ≤ 500
components/DoctorTempProviderDialog.tsx 349 ≤ 500
commands/precheck.rs 346 ≤ 500
bug_report/collector.rs 335 ≤ 500
components/InstanceCard.tsx 334 ≤ 500
hooks/useWorkspaceTabs.ts 331 ≤ 500
lib/doctor-report-i18n.ts 328 ≤ 500
components/ParamForm.tsx 324 ≤ 500
pages/__tests__/cook-plan-context.test.ts 319 ≤ 500
pages/__tests__/overview-loading.test.ts 318 ≤ 500
hooks/useChannelCache.ts 317 ≤ 500
components/__tests__/SshFormWidget.test.tsx 312 ≤ 500
doctor.rs 303 ≤ 500
recipe_planner_tests.rs 302 ≤ 500
Files > 500 lines 45 trend ↓ ⚠️
Files over target 45 0 ⚠️

📊 Metrics defined in docs/architecture/metrics.md

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 19, 2026

📸 UI Screenshots

Commit: 4360d6879bcb640928dcc1f8b334b2f0177a887b | Screenshots: Download artifact

Light Mode — Core Pages

Start Page Home Channels
start home channels
Recipes Cron Doctor
recipes cron doctor
Context History Chat Panel
context history chat
Settings (4 scroll positions)
Main Appearance Advanced Bottom
s1 s2 s3 s4
Start Page Sections
Overview Profiles Settings
sp1 sp2 sp3

Dark Mode

Start Home Channels Doctor
d1 d2 d3 d4
Dark mode — more pages
Recipes Cron Settings
d5 d6 d7

Responsive + Dialogs

Home 1024×680 Chat 1024×680 Create Agent
r1 r2 d1

🔧 Harness: Docker + Xvfb + tauri-driver + Selenium | 28 screenshots, 13 flows

@Keith-CY Keith-CY marked this pull request as draft March 19, 2026 17:58
@dev01lay2 dev01lay2 force-pushed the feat/git-workspace-backup branch 2 times, most recently from 1eac681 to 4015995 Compare March 19, 2026 19:54
@dev01lay2 dev01lay2 force-pushed the feat/git-workspace-backup branch from 22a4558 to 3f4376d Compare March 23, 2026 07:13
cjs added 7 commits March 23, 2026 09:43
- Use gh CLI to get release body (avoids shell escaping issues)
- Use jq for proper JSON construction
- Skip .sig and latest.json files
- Use HTTP/1.1 for large file upload stability
- Detect user timezone to determine if likely in China
- CN users fetch release assets from GitLab (lay2dev/clawpal)
- Other users fetch from GitHub as before
- Falls back to secondary source if primary fails
- Add canonical, Open Graph, Twitter Card meta tags
- Add SoftwareApplication JSON-LD schema
- Add robots.txt with AI crawler permissions
- Add llms.txt for AI search engines
- Add sitemap.xml
- Improve meta description for better CTR
cjs and others added 5 commits March 23, 2026 09:43
- Redirect clawpal.zhixian.io to clawpal.xyz (301)
- Redirect clawpal.pages.dev to clawpal.xyz (301)
- Fixes GSC 'Google 选择的规范网页与用户指定的不同' issue
- 1200x630 hero section screenshot
- Fixes broken social preview cards
Adds workspace-aware backup/restore and git-based workspace backup:
- Copy-based backup/restore now includes workspace directory
- Workspace path resolved from OpenClaw config (custom or default)
- New git backup commands: workspace_git_status, workspace_git_backup, workspace_git_init
- Remote variants for all git backup commands via SSH
- WorkspaceGitBackup UI component with status, backup, and init actions
- clawpal-core: git status probe, backup, and init shell command builders

Rebased on origin/develop (timed_async!/timed_sync! macro wrapping,
read_openclaw_config(&OpenClawPaths) signature).
@dev01lay2 dev01lay2 force-pushed the feat/git-workspace-backup branch from 3f4376d to 249dbc1 Compare March 23, 2026 09:45
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 23, 2026

Recipe GUI E2E Perf

Artifacts: perf report

Recipe Page Load (ms) Form Fill (ms) Execution (ms) Verification (ms) Total (ms)
dedicated-agent ⚠️ Skipped: Discord not configured in E2E environment
channel-persona-pack ⚠️ Skipped: Discord not configured in E2E environment
agent-persona-pack ⚠️ Skipped: Discord not configured in E2E environment

Harness: Docker + Xvfb + tauri-driver + Selenium

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant