fix(web): sync runtime-facing chat and settings follow-ups - #1200
fix(web): sync runtime-facing chat and settings follow-ups#1200franknobox wants to merge 76 commits into
Conversation
Add proposed design documentation for the LoongClaw Web Console in both English and Chinese (web/DESIGN.md and web/DESIGN.zh-CN.md). Documents define goals, positioning, architecture (local-first frontend/backend split), conversation model, API surface, install/distribution modes, security defaults, commands, implementation phases, open questions, and acceptance criteria (last updated 2026-03-17).
Remove the old English web/DESIGN.md; relocate and update the Chinese DESIGN file to web/docs/DESIGN.zh-CN.md (rename and replace `webchat` keys/usages with `web` and adjust command names). Add new Chinese documentation files: web/docs/API.zh-CN.md (local HTTP API draft) and web/docs/STACK.zh-CN.md (web/ layout and tech-stack guidance). Overall: consolidate web documentation under web/docs and introduce API and STACK proposals in zh-CN.
Introduce a local Web Console API and integrate it into the daemon CLI. Adds a new axum-based web_cli with HTTP endpoints for health, meta, dashboard, chat sessions, history, turn submission, and CORS handling; exposes a WebCommand (serve) and wires it into the main daemon command runner. Expand app memory/sqlite APIs to support listing and clearing recent conversation sessions: add ConversationSessionSummary type, list_recent_sessions_direct and clear_session_direct helpers, and expose them from memory/mod.rs. Make DEFAULT_TOKEN_TTL_S and bootstrap_kernel_context public to allow web API usage of kernel bootstrap. Add web/ frontend skeleton (assets, i18n, pages, TS config, package files) and update docs (API and DESIGN zh-CN) to describe the Web Phase 1 API and design. Update crates/daemon/Cargo.toml to include axum workspace dependency and export the new web_cli module.
Introduce a visual and structural overhaul for the dashboard and related UI: add decorative background ornaments/axes in RootLayout, update NavBar branding to a compact wordmark (LOONGCLAW web), and restructure the Chat composer (wrapped textarea, floating submit button with accessible sr-only label). Rewrite DashboardPage: new summary card layout, runtime/provider/memory/install/tools cards, two-column main/side layout, provider list and settings panel rework, and additional i18n keys for both en and zh-CN. Large CSS updates: custom scrollbars, background ornament/axis styles, many layout/component style refinements (panels, pills, dashboard grids, buttons, composer, responsive adjustments), and unify theming by adding new color variables and adjusting theme/panel/background gradients. These changes improve visual clarity, accessibility, and theming consistency while preparing the UI for future controlled write paths and runtime interactions.
Add PowerShell scripts scripts/web/start-dev.ps1 and scripts/web/stop-dev.ps1 to launch and stop the local web API (loongclaw) and Vite preview as hidden background processes. Both scripts manage processes by port, write runtime logs to %USERPROFILE%\.loongclaw\logs (web-api.log, web-api.err.log, web-preview.log, web-preview.err.log), and start the preview on port 4173 and the API on 4317 by default. Update web/docs/DESIGN.zh-CN.md and web/docs/STACK.zh-CN.md to document the runtime file/log location and recommend these scripts to avoid polluting the repository working tree and Git status with runtime artifacts.
# Conflicts: # crates/app/src/context.rs
Replace the old "preview" dev workflow with a "dev" workflow and adjust related logging/ports: rename PreviewHost/Port and preview logs to DevHost/DevPort and web-dev.log in start-dev.ps1, start vite in dev mode (remove prebuilt dist step), and update readiness checks and output messages. Update Chinese docs (API, DESIGN, STACK) to reflect current implementation progress, priorities, and the change to using vite dev; bump last-updated dates. UI changes: make Panel accept className and hideHeader, update ChatPage to use the new panel options and add a connection status dot. CSS overhaul: refine chat/panel layout and spacing, add scoped panel-chat-main rules, shared regions/comments, scrollbar styling, and tweak input background color in themes.css. These changes align the dev workflow to live dev (vite dev), improve chat UI flexibility and visuals, and bring docs up to date with current implementation status.
Introduce native provider streaming support and local web API streaming endpoints.
Key changes:
- Pass an optional AcpTurnEventSink through ConversationRuntime/provider request paths to emit incremental events.
- Implement execute_openai_streaming_turn_request to request provider-native SSE streams, decode OpenAI-style events, reconstruct assistant text and function/tool calls, and forward deltas to the event sink. Falls back to existing buffered path when needed.
- request_dispatch_runtime will prefer the native streaming path for OpenAI-compatible transports and fall back to the previous execute_model_request flow on errors or unsupported providers.
- Web daemon: add local API token auth (env / file), token resolution/generation, protected /api routes, an NDJSON streaming endpoint for turn events (/chat/sessions/{id}/turns/{turn_id}/stream), per-turn stream state, WebTurnEventSink to forward provider deltas to clients, and several dashboard/connectivity/config endpoints used by the UI.
- Update many call sites and tests to propagate the new optional event_sink parameter (using None where not applicable).
- Minor housekeeping: add temporary web log ignores to .gitignore and add required dependencies in daemon Cargo.toml.
These changes enable low-latency incremental assistant updates from compatible providers and a streaming web API for the frontend to consume them.
Add a memory window metric to the ChatPage inspector panel: introduce memoryWindow state, reset it when sessions change, and display localized label/value/pending/hint UI. Fetch the slidingWindow from dashboardApi.loadConfig() on auth/config changes and handle 401 via markUnauthorized. Add corresponding i18n entries for en and zh-CN.
Introduce a temporary Web-only "tool assist" feature to nudge discovery-first tool flows without changing user-visible messages or shared CLI behavior. Backend: add optional tool_assist_hint to ChatTurnRequest and thread it through run_chat_turn_stream to append a one-shot marker into the turn CLI system prompt when present. Frontend: add a persistent composer toggle, simple intent detection heuristics, and hint builder; pass toolAssistHint in createTurn when enabled. Also add i18n entries for the toggle (en/zh), small zh copy fixes, and basic CSS for the new toggle. This is intentionally lightweight and reversible (hint remains optional so rollback is a one-line removal).
Introduce a minimal web onboarding flow: server endpoints and frontend integration. Server: crates/daemon/src/web_cli.rs - Add onboarding payloads and request types. - Implement /api/onboard/status, POST /api/onboard/provider and POST /api/onboard/validate. - Add provider validation and probing utilities (header building, model selection, lightweight validation paths) and status-building logic. - Persist minimal provider edits to local config and merge public/protected API routers. Frontend and UX: - Add OnboardingStatusPanel component and onboarding API client (web/src/features/onboarding/api/index.ts). - Show onboarding panel in RootLayout when onboarding is blocking (useWebConnection integration). - Update WebSessionContext and related assets to surface onboarding state. - Add i18n keys for chat/common/dashboard locales. Docs: Update Chinese docs (API, DESIGN, STACK) to document new onboarding endpoints, behavior and update timestamps. Misc: minor CSS and dashboard/config payload additions to surface prompt/personality fields. This implements a lightweight controlled write+validate path for onboarding provider configuration and a read-only status endpoint for guiding first-run UX.
Refactor: move onboarding-related types, handlers and helper functions out of crates/daemon/src/web_cli.rs into a new module crates/daemon/src/web_cli/onboarding.rs and update route registrations to call onboarding::onboard_status, onboarding::onboard_provider and onboarding::onboard_validate. Frontend: add web/src/styles/dashboard.css and import it from web/src/styles/index.css while removing the inlined dashboard styles from index.css. This cleans up the web CLI file and separates dashboard styles for better organization.
Introduce automatic local pairing and onboarding preferences support. - Web API: add POST /onboard/pairing/auto and /onboard/pairing/clear to set/clear an HttpOnly pairing cookie (restricted to trusted loopback origins) so the token is not returned in plaintext to the page. Add POST /onboard/preferences to persist lightweight onboarding prefs (personality, memory_profile, prompt_addendum). - Server: support extracting pairing token from Cookie header, build/clear pairing cookie helpers, allow Origin-based local CORS with Access-Control-Allow-Credentials and Vary: Origin, and add a WebApiError::forbidden helper. - Onboarding: extend status payload with personality, memory_profile, prompt_addendum and wire preference write + auto-pairing/clear handlers; persist preferences into config when written. - Docs & frontend: update Chinese API / DESIGN / STACK docs and touch frontend locales, onboarding UI, session/context and API client assets and styles to reflect the new endpoints and onboarding flows. These changes enable a safer local auto-pairing UX, allow origin-restricted CORS for local dev, and surface light user preferences in onboarding.
Enhance auth-related UX by injecting tokenPath and tokenEnv into localized invalid-token messages. Update ChatPage and DashboardPage to obtain and pass tokenPath/tokenEnv from useWebConnection and to use them when constructing error strings (including updating toFriendlyChatError signature). Adjust OnboardingStatusPanel to show a new auto-pairing hint inside the token entry form. Add corresponding i18n strings in English and Chinese for the banner/body and the auto-pairing notice.
Relax provider validation to treat credential_status of "request_rejected" as an acceptable outcome alongside "validated"; the endpoint must still be reachable. This allows first-run onboarding to proceed when a provider rejects a provider-specific probe shape (which still proves the endpoint and credentials are wired up). Also clarifies the onboarding validation comment to explain the intent.
Back-end: add a new POST /onboard/provider/apply route that validates a candidate provider config and only writes it to disk when validation passes. Refactor onboarding write logic into helpers (load_or_default_web_config, apply_provider_request_to_config, route_matches_existing_provider_route) and make onboard_provider stop writing directly (delegating apply+validate to the new endpoint). Front-end: add onboardingApi.applyProvider and update Dashboard to call it. Dashboard now shows a pending/success/error modal when applying provider settings, handles validation failures with appropriate messages, and updates onboarding state using a new acceptValidatedOnboardingStatus handler. WebSessionContext: persist onboarding validation keys via sessionStorage through a helper, expose acceptValidatedOnboardingStatus, and adjust auto-pairing / token pairing checks. Other UI changes: make the root layout keep Chat and Dashboard mounted (hidden) to preserve state, wire Enter (without Shift/composition) to submit the chat composer, and tweak onboarding provider form behavior to clear inherited route when switching kinds. Add dashboard modal styles in CSS. Script: remove user-level ARK_API_KEY passthrough from start-dev.ps1. These changes implement a safer apply/validate workflow for provider configuration and improve UX around applying settings and preserving UI state.
Add scripts/scripts/web/start-dev.sh and stop-dev.sh to manage the web development environment. start-dev.sh prepares log/run dirs, kills processes on configured ports, verifies the loongclaw daemon and Vite binaries, launches the API and Vite dev server (nohup), writes PID files, and waits for readiness endpoints. stop-dev.sh stops processes by PID files and by port (4317/4173) and cleans up PID files. Scripts use sensible defaults and locations (~/.loongclaw/{logs,run}) and provide guidance if build/install steps are missing.
Back-end: include ToolRuntimeConfig in dashboard API and pass it to build_tool_items so tool summaries reflect runtime readiness. Update build_tool_items to show runtime-aware details for browser_companion, add web_search and file_tools items. Front-end: add workspace-stage class to workspace panes; reorganize DashboardPage to separate runtime and local config into stacked sections with headings; wire in new localized labels. Update i18n (en / zh-CN) to include new labels and tool names. Session handling: persist an onboarding acknowledgment key in sessionStorage, expose acknowledgedOnboardingKey in WebSessionContext, and update helpers to persist/clear acknowledgment and use it in onboarding status. Styling: tweak dashboard grid columns and provider min-width, add styles for stacked sections and workspace-stage.
Introduce a read-only Debug Console for the Dashboard: add server-side runtime debug state, recording of turn/tool events (started/finished/delta/failed/completed), and an API endpoint GET /api/dashboard/debug-console. Implement log tailing and ANSI-stripping utilities, limit and trim recent debug blocks, and wire debug recordings into onboarding and turn/tool event flows. Update chat history to use a visible-message-limited loader (ignoring internal assistant records so they don't consume UI message quota). Add frontend locale strings and docs describing the debug console, plus related UI/style changes.
Enable serving a same-origin static web UI from the daemon and add session-based auth. Introduces a --static-root option and static asset resolver + fallback (serve_web_static), enforces same-origin write origins, and adds session/pairing cookie builders and token extraction in a new auth module. Refactors debug console logic into its own module and adds a DebugConsolePanel React component. Updates API meta/onboarding payloads and frontend WebSessionContext, translations, and chat/onboarding UI to handle the new auth mode. Also adds start/stop scripts and temporary web dev logs.
Reorganize web helper scripts by moving start/stop scripts into scripts/web and update their internal path resolution. The PowerShell and shell start scripts now compute repo and web roots relative to the script location so they work after the move. .gitignore updated to ignore any .tmp-web-*.log files. Add placeholder web/README.md and web/INSTALL.md.
Expand web documentation (INSTALL, README, API, DESIGN, STACK) with installation steps, dev/same-origin runtimes, API surface details, onboarding states, engineering review notes and recommended next steps; add scripts and stack/version notes for local devs. Improve web/src/lib/api/client.ts by extending ApiRequestError with method and url, adding payload error extractors and describeApiFailure, and hardening apiFetch to catch network failures and produce clearer, actionable error messages (404/unreachable/contextual request target). These changes improve local onboarding, diagnostics and runtime error reporting for front-end developers.
Keep chat/dashboard UI state alive and modernize API usage across the app. - RootLayout: add keep-alive caching for /chat and /dashboard outlets, wrap outlet in Suspense and preserve route elements to avoid losing state when switching sections. - Router: lazy-load Chat and Dashboard pages and mount RootLayout as the workspace root. - Chat page: add per-session view caching, persist selected session in sessionStorage, auto-scroll improvements, per-session stream/event handling, optimistic UI fixes and various stream/session state refactors. - WebSessionContext: switch to onboardingApi helpers, add AbortController handling, centralize offline onboarding status construction and avoid noisy errors for aborted requests. - API surfaces: refactor chat/dashboard/onboarding APIs to use new client primitives (apiGetData, apiPostData, apiOpenStream, request option/timeout handling, buildApiUrl), introduce default timeouts and better stream parsing/error messages. - Onboarding/Dashboard UI: extract provider & preferences form helpers (providerConfig.ts), wire DashboardPage and OnboardingStatusPanel to use the new form utilities and unified save/validation/error handling. These changes improve UX by preserving workspace state, make API calls more robust (timeouts/abort support), and consolidate onboarding/provider configuration logic into reusable utilities.
Add three new subcommands under `loongclaw web`: - `web install --source <path>` — copies a built frontend dist directory to ~/.loongclaw/web/dist and writes an install.json manifest (installed_at, source_path, install_dir) - `web status` — reads the manifest and reports install state, including an asset integrity check for dist/index.html - `web remove [--force]` — removes dist/ and install.json; requires --force to confirm `web serve` now auto-detects ~/.loongclaw/web/dist when --static-root is not supplied, enabling same-origin-static mode without an explicit flag after installation. Also fix pre-existing clippy warnings (collapsible-if, wildcard match, indexing-may-panic, clamp-like pattern) that were blocking `-D warnings` in CI. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…aces - add the new Abilities page skeleton and wire it into navigation and keep-alive routing - rename the visible Dashboard surface to Status while keeping dashboard code paths intact - refine chat session/tool state presentation, including recent tool retention across session switches - tighten chat header/layout details and restore the intended code block background treatment - improve status-side tool summaries and refresh related Web docs to match the current structure
…followups-20260405 feat(web): add abilities shell and refine chat/status surfaces
- add the new Abilities page shell with left-side section navigation - add initial Personalization, Channels, and Skills panels - add daemon-side abilities endpoints and wire them into the Web API - refine abilities page layout and styling to use a simpler line-based UI - align visible dashboard tool metadata text with the updated formatting - keep visible Dashboard naming as Status while leaving internal dashboard paths unchanged - fix post-merge daemon compile issues in web abilities/channel read-model handling
…n UX - add initial abilities personalization read/write flow and keep channels/skills in dedicated sections - add abilities-specific select controls, layout refinements, and documentation notes - refine chat sessions with local rename overrides, friendlier activity timestamps, and generating state hints - update web docs to reflect the current abilities surface and chat session behavior
# Conflicts: # crates/app/src/memory/mod.rs
- split locale resources into app, abilities, chat, and dashboard namespaces\n- expand abilities with mascot controls plus refined channels and skills layouts\n- keep the experimental chat mascot hidden by default behind an abilities toggle\n- refine runtime page copy, tool metadata, and debug terminal presentation\n- suppress low-value debug noise and document follow-up channels/skills notes
…e-followups-20260406 feat(web): expand abilities workspace and polish runtime surfaces
- remove the duplicate futures-util workspace dependency from crates/daemon/Cargo.toml\n- add the missing WhatsappServe logging match arm so the daemon CLI builds again\n- unblock rebuilding loongclaw so the web subcommand is available on Linux and Windows
…-fix-20260407 fix(cli): restore web subcommand buildability
- add the missing unix-only fs import in doctor_security_cli\n- restore the gateway control runtime and token file mode constants\n- unblock cargo build --bin loongclaw on Linux after the recent merge
…-fix-20260407 fix(unix): restore daemon build after dev merge
…-20260411 fix (web) : provider setup flow and sync runtime-facing docs
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (3)
📒 Files selected for processing (128)
📝 WalkthroughWalkthroughThis pull request introduces a comprehensive Web Console feature for LoongClaw, adding a local web UI served by the daemon with chat, dashboard, abilities, and onboarding interfaces. It threads an optional event sink through the conversation/provider request pipeline, expands provider catalog metadata APIs, adds session management to the memory layer, and includes complete frontend implementation with localization and supporting startup scripts. Changes
Sequence Diagram(s)sequenceDiagram
participant Client as Web Client
participant Server as Daemon (Web API)
participant Runtime as Kernel Runtime
participant Provider as LLM Provider
Client->>Server: POST /api/chat/turn (input, sessionId)
activate Server
Server->>Server: Load config, init runtime
Server->>Server: Create ACP EventSink
Server->>Runtime: Create ConversationTurnCoordinator
Server->>Runtime: request_turn_with_event_sink(eventSink)
activate Runtime
Runtime->>Provider: request_turn_in_view(eventSink)
activate Provider
Provider->>Provider: Build request body
Provider->>Provider: execute_openai_streaming_turn_request
note over Provider: Emits events via eventSink<br/>(turn.started, message.delta, tool.started, etc.)
Provider-->>Runtime: ProviderTurn
deactivate Provider
Runtime-->>Server: ProviderTurn
deactivate Runtime
Server->>Server: Transform turn to NDJSON events
note over Server: turn.started, message.delta chunks,<br/>turn.completed or turn.failed
Server-->>Client: Response stream (application/x-ndjson)
deactivate Server
Client->>Client: Parse NDJSON, update UI<br/>(stream phase, assistant message, tools)
note over Client: Keep-alive on disconnect,<br/>reconcile on unexpected close
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
|
Summary
This PR wraps up the recent Web follow-ups after syncing
devintoweb, with a focus on chat runtime state, provider/settings flow, and runtime-facing form behavior.Included
Chat runtime alignment
turn.phasesupport to the Web chat stream modelProvider and settings flow
Memory and preferences
memory.sliding_windowin onboarding and dashboard settings~/.loong/homeUI and copy polish
Notes
web/docs/note.mdValidation
npm.cmd run buildinweb/cargo check -p loongclawSummary by CodeRabbit
New Features
Chores