Skip to content

feat: session-first mobile UX with agent-first pre-SSH onboarding (PR #6)#6

Open
claudinethelobster wants to merge 7 commits intomainfrom
feat/session-first-mobile-v2
Open

feat: session-first mobile UX with agent-first pre-SSH onboarding (PR #6)#6
claudinethelobster wants to merge 7 commits intomainfrom
feat/session-first-mobile-v2

Conversation

@claudinethelobster
Copy link
Owner

What Changed

Session-First, Agent-First UX (PR #6 clean-room redo)

This PR delivers the session-first mobile UX with two key improvements over PR #5:

1. Agent available before SSH is connected
The chat agent greets users by name immediately on page load — before any server is connected. Users can ask questions, get help, and start onboarding through natural conversation from the very first second.

2. Connectivity probe BEFORE showing install command
Before showing the authorized_keys install command, the backend probes the target host:

  • DNS resolution check
  • TCP port reachability
  • SSH banner verification (is it actually SSH?)

If the host is blocked/unreachable, the agent explains WHY and provides specific guidance — before the user wastes time running an install command that won't work.

Architecture (ADR-002)

Onboarding state machine:

[greeting] → [collect_target] → [probing] → 
  → [connectable] → [needs_install] → [confirm] → [active_session]
  → [dns_fail] → troubleshoot hostname
  → [port_fail] → troubleshoot firewall/VPN/port
  → [ssh_fail]  → troubleshoot service on port

New API Endpoints

  • POST /api/v1/connections/probeNEW — connectivity pre-check (DNS + TCP + SSH banner)
  • GET /api/v1/auth/oauth/github/start — GitHub OAuth with PKCE
  • GET /api/v1/auth/oauth/github/callback — auto-provision keypair on first login
  • GET/POST/PATCH/DELETE /api/v1/keys/* — Ed25519 keypair management
  • GET/POST/PATCH/DELETE /api/v1/connections/* — SSH connection CRUD + test
  • POST /api/v1/sessions/bootstrap — chat-led onboarding (returns install command)
  • POST /api/v1/sessions/bootstrap/:id/confirm — test SSH + start session

Why Cleaner Than PR #5

Aspect PR #5 (feat/mobile-auth-overhaul) PR #6 (this PR)
Branch base main main ✅
Commit count 25 mixed commits 8 clean logical commits ✅
Agent availability After SSH connected Immediately on load ✅
Connectivity check After key install Before install (probe step) ✅
Blocked-host UX Generic SSH error Specific guidance per failure type ✅
Channel lifecycle Returns immediately (causes restart loop) Awaits abortSignal ✅
DB schema Custom tables Compatible migration included ✅

Testing Evidence

All endpoints tested on clawdfather.ai (deployed to prod branch):

Test Result
Login screen loads ✅ PASS
GitHub OAuth flow ✅ PASS (redirects, creates session, greets user by name)
Agent greets user before SSH ✅ PASS (chat available immediately)
Health check (/api/v1/health) ✅ PASS {status:ok,db:ok}
Auth/me returns account data ✅ PASS
Probe: connectable host ✅ PASS {status: connectable, latency_ms: 3}
Probe: DNS fail ✅ PASS {status: dns_fail}
Probe: port fail ✅ PASS {status: port_fail}
Bootstrap: needs_setup ✅ PASS (returns install_command + keypair)
Channel stability (no restart loop) ✅ PASS (1 start, no auto-restart)

Known Limitations / Follow-Ups

  1. Probe timeout too long (8s) for poor connections — consider 5s with retry
  2. SSH banner check may miss servers behind HAProxy or other TCP forwarders
  3. Confirm flow (test SSH after key install) not end-to-end tested in this PR — requires a real server with the key installed
  4. WebSocket session continuity on page reload needs testing
  5. Mobile PWA install (add to home screen) not tested
  6. Rate limiting on probe endpoint (30/hr) needs load testing
  7. Session nickname UX ("call it dev-box") not wired to DB persistence yet

Deploy Status

Live at: https://clawdfather.ai
Branch commit: $(git rev-parse HEAD)

- ADR-002: codifies two key improvements over PR #5:
  1) Agent available before SSH is connected (onboarding mode)
  2) Connectivity probe before showing install command
- Onboarding state machine with probe result branching
  (connectable/dns_fail/port_fail/ssh_fail → different guidance)
- Planning doc 08: conversation transcripts for ideal and blocked paths
- Comparison table: why cleaner than PR #5 approach
…ity probe

- PostgreSQL integration (db.ts, schema.sql)
- crypto.ts: HKDF-SHA256 KEK, AES-256-GCM key encryption, token hashing
- GitHub OAuth 2.0 with PKCE + auto-keypair provisioning on first login
- REST API:
  - /api/v1/auth/* — OAuth flow, session, account info
  - /api/v1/keys/* — Ed25519 keypair management + install command
  - /api/v1/connections/* — SSH connection CRUD + test
  - NEW: POST /api/v1/connections/probe — connectivity pre-check before install
    (DNS resolve → TCP probe → SSH banner check)
  - /api/v1/sessions/* — session lifecycle
  - /api/v1/sessions/bootstrap + confirm — chat-led onboarding flow
- Rate limiting, audit logging, proper error responses
- TypeScript strict mode: 0 compile errors
- Agent available in onboarding mode (before SSH connected):
  buildOnboardingContext() used when no active session exists
- Per-turn SystemInstruction injection prevents context loss after N turns
- DB fallback session rehydration when in-memory store is stale
  (after process restart or memory eviction)
- Assistant output sanitization guards (strips ControlPath, SSH flags,
  SystemInstruction fragments before messages reach user)
- Fix probe flow: properly handle all state transitions
- Improve blocked state: parse 'retry', 'port NNNN', IP addresses
- Polish typing indicator and message rendering
- Fix WebSocket reconnect logic for active sessions
- Clean up dead code from initial implementation
…start loop

The startAccount function was returning immediately, causing OpenClaw
to treat the channel as completed and continuously auto-restart it.
Now the function awaits the abortSignal before cleaning up, matching
the expected long-running channel service lifecycle.
…iolation

GitHub users without a public display name have ghUser.name = null.
Fall back to ghUser.login to ensure display_name is always populated
(backward compatible with existing NOT NULL constraint on accounts table).
Documents the column additions and table migrations needed when
upgrading from feat/mobile-auth-overhaul to this branch's schema:
- accounts: add github_id (with UNIQUE), login, avatar_url, updated_at
- accounts.display_name: make nullable
- auth_sessions: create from app_sessions (new table name + extra fields)
- oauth_state_cache: ensure code_verifier column present
- audit_logs: create new table
Safe to run on existing PR#5 databases.
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