Skip to content

feat: WSL2 support (016)#26

Open
grobomo wants to merge 11 commits intomainfrom
016-T004-wsl-support
Open

feat: WSL2 support (016)#26
grobomo wants to merge 11 commits intomainfrom
016-T004-wsl-support

Conversation

@grobomo
Copy link
Copy Markdown
Owner

@grobomo grobomo commented Apr 28, 2026

Summary

  • Auto-detect WSL2 via /proc/version containing "microsoft"
  • New tab launch via wt.exe interop → wsl.exe -d <distro> -- bash -lc 'cd ... && claude'
  • Auto-select claude (native) or claude.exe (Windows interop) based on availability
  • WSL process names (relay, sessionleader, init-systemd) recognized in shell PID detection
  • pgrep and safety checks use substring match for claude/claude.exe compat
  • get_wt_settings_path() resolves Windows Terminal settings from WSL via cmd.exe
  • openclaw-checkin.py: TRACKER_PATH configurable via OPENCLAW_TRACKER_PATH env var
  • stop-message.txt: all paths use env vars instead of hardcoded paths

Verified

  • 110/110 unit tests pass (14 new WSL-specific tests)
  • WSL dry-run: platform detected, wt.exe command generated, claude.exe selected, shell PID found via relay process
  • Audit: all 18 Windows-specific code patterns are inside IS_WIN guards

Test plan

  • python scripts/test.py — 110 pass, 0 fail
  • Dry-run in WSL2 Ubuntu — correct command generated, shell PID detected
  • Live launch in WSL2 (manual — opens real terminal tab)

grobomo added 11 commits April 27, 2026 12:18
Fixes the broken Claude Code → OpenClaw feedback loop.

The monitor (manage-claude-code.py / claude-tab-monitor cron) reads
tracker.json, but openclaw-checkin.py never wrote to it — the two sides
were completely disconnected.

Changes:
- Add TRACKER_PATH constant pointing to tracker.json in WSL workspace
- Add _update_tracker(status, detail, project): finds matching active
  tab by project_name (basename of CLAUDE_PROJECT_DIR), updates
  last_checkin, appends to checkins[], marks completed on done.
  Atomic write via .tmp rename. try/except guards never break the flow.
- Call _update_tracker() from main() before send_to_openclaw() so
  tracker is always updated even when the API times out.
The two sides of the checkin system were completely disconnected:
- openclaw-checkin.py wrote to comms log + OpenClaw API (which always timed out)
- manage-claude-code.py / monitor cron only read tracker.json
- Result: 32 checkins in comms log, zero in tracker.json

Fix:
1. Add _update_tracker() to openclaw-checkin.py
   - Reads tracker.json, finds matching active tab by project_name
   - Appends to checkins[], updates last_checkin
   - If status=done: marks tab completed with completed_at + summary
   - Atomic write (tmp -> os.replace), wrapped in try/except (best-effort)
   - Called BEFORE OpenClaw API POST so tracker is always updated

2. Add --fire-and-forget to argparse (hidden, no-op)
   - openclaw-checkin.js was passing this flag causing argparse errors

3. Add docs/FEEDBACK-LOOP.md
   - Full architecture, ASCII diagram, component table, bug description, test instructions

Also synced /mnt/c/Users/joelg/.claude/scripts/openclaw-checkin.py to match.
- Detect WSL via /proc/version containing 'microsoft'
- Add WSL branch to build_launch_cmd() using wt.exe interop
- WSL tabs open via wt.exe new-tab + wsl.exe -d <distro>
- get_wt_settings_path() resolves WT settings via cmd.exe in WSL
- _get_wsl_distro() reads WSL_DISTRO_NAME env var
- Make TRACKER_PATH in openclaw-checkin.py configurable via env var
- Make stop-message.txt paths portable (env vars instead of hardcoded)
- Add 14 new tests (110 total, all passing)
…in stop-message.txt), T004 (WSL detection + wt.exe launch) done, 110/110 tests pass
- Add _get_wsl_claude_cmd() — prefers native 'claude', falls back to 'claude.exe'
- Add WSL process names to terminal_hosts (relay, sessionleader, init-systemd)
- Use substring match for pgrep (catches both claude and claude.exe)
- Use 'claude' substring match in Unix safety check (same reason)
- Verified via dry-run in WSL: shell PID detected, command uses claude.exe
- Add relay, sessionleader, init-systemd to Unix terminal_hosts
- Add _get_wsl_claude_cmd() for claude vs claude.exe detection
- pgrep uses substring match for claude/claude.exe compat
- Audit: 18 Windows patterns all gated behind IS_WIN
- WSL dry-run verified: detection, cmd gen, shell PID, claude.exe
Mock platform flags to test all branches on any OS:
- Mac: osascript, Terminal.app, quote escaping (6 tests)
- Linux gnome-terminal: --tab, title, quote escaping (6 tests)
- Linux fallback: bash -c background, & suffix (3 tests)
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