feat(yolo-mode): add YOLO support to web interface#1767
feat(yolo-mode): add YOLO support to web interface#1767lucaspdude wants to merge 33 commits intoMoonshotAI:mainfrom
Conversation
Add ability to view and toggle YOLO mode from the web UI:
- Add GET/POST /api/sessions/{id}/yolo endpoints
- Add useYoloMode hook for state management
- Add YOLO mode toggle in global config controls
- Add YoloStatus and UpdateYoloRequest models
- Update wire protocol with set_yolo_mode JSON-RPC method
- Update StatusUpdate to include yolo_mode field
Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com> Signed-off-by: Lucas Pacheco <lucaspdude@gmail.com>
Integrate useYoloMode hook into useSessionStream to fetch the initial YOLO mode state from the server API. This ensures the UI correctly reflects the default_yolo config setting when a session connects, instead of defaulting to false and waiting for a StatusUpdate event. Changes: - Import useYoloMode hook in useSessionStream.ts - Add yoloStatus fetching and sync to yoloMode state via useEffect
fix(web): initialize YOLO mode from server config on session connect
The separate useEffect that synced sessionIdRef.current was updating the ref BEFORE the load effect could compare them. This caused the guard condition to always be true after first mount, skipping refresh() on session switches and displaying stale YOLO data. Remove the ref-sync effect so the load effect can properly compare old vs new sessionId before deciding to fetch.
…nto feat/yolo-mode-web
…ditions Add AbortController to cancel in-flight fetch requests when sessionId changes. This prevents stale YOLO status from overwriting the correct state after a session switch. Changes: - Add abortControllerRef to track the current fetch - Pass signal to fetch call in refresh callback - Check for AbortError in catch block and skip state updates - Add cleanup function in useEffect to abort on session change/unmount
Add previousSessionIdRef to track the last connected session ID. Modify resetState to accept preserveYoloMode parameter. On reconnect to the same session, preserve YOLO mode state to avoid showing the toggle as OFF while approvals are still auto-approved. Changes: - Add previousSessionIdRef to track session changes - Update resetState signature to accept preserveYoloMode - Check if reconnecting to same session in connect() and preserve yoloMode
Only save session state to disk when the worker is NOT alive. When the worker IS alive, skip the disk save and let the worker handle persistence via its notify_change callback. This prevents the REST handler's save from overwriting concurrent worker changes to session state (title, plan mode, todos, etc.). Changes: - Move save_session_state inside else branch - Only save directly when session_process is None or not alive - When worker is alive, rely on set_yolo_mode -> worker persistence
…dates Add hasReceivedLiveYoloUpdateRef to track if we've received a live yolo_mode update from WebSocket. Only apply yoloStatus from HTTP fetch if no live update has been received yet. This prevents stale HTTP responses from overwriting newer real-time state when the user toggles YOLO quickly or another client toggles it. Changes: - Add hasReceivedLiveYoloUpdateRef to track live WebSocket updates - Guard yoloStatus sync useEffect to only apply before live updates - Set flag when StatusUpdate.yolo_mode is received from WebSocket - Reset flag in resetState when switching sessions
Add ability to view and toggle YOLO mode from the web UI:
- Add GET/POST /api/sessions/{id}/yolo endpoints
- Add useYoloMode hook for state management
- Add YOLO mode toggle in global config controls
- Add YoloStatus and UpdateYoloRequest models
- Update wire protocol with set_yolo_mode JSON-RPC method
- Update StatusUpdate to include yolo_mode field
Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com> Signed-off-by: Lucas Pacheco <lucaspdude@gmail.com>
Integrate useYoloMode hook into useSessionStream to fetch the initial YOLO mode state from the server API. This ensures the UI correctly reflects the default_yolo config setting when a session connects, instead of defaulting to false and waiting for a StatusUpdate event. Changes: - Import useYoloMode hook in useSessionStream.ts - Add yoloStatus fetching and sync to yoloMode state via useEffect
The separate useEffect that synced sessionIdRef.current was updating the ref BEFORE the load effect could compare them. This caused the guard condition to always be true after first mount, skipping refresh() on session switches and displaying stale YOLO data. Remove the ref-sync effect so the load effect can properly compare old vs new sessionId before deciding to fetch.
…ditions Add AbortController to cancel in-flight fetch requests when sessionId changes. This prevents stale YOLO status from overwriting the correct state after a session switch. Changes: - Add abortControllerRef to track the current fetch - Pass signal to fetch call in refresh callback - Check for AbortError in catch block and skip state updates - Add cleanup function in useEffect to abort on session change/unmount
# Conflicts: # CHANGELOG.md # docs/en/release-notes/changelog.md # docs/zh/release-notes/changelog.md # src/kimi_cli/web/api/sessions.py # web/src/hooks/useSessionStream.ts
The useEffect that syncs initial YOLO mode state from the REST API had an empty body due to a merge conflict resolution error. Add the missing setYoloMode(yoloStatus.enabled) call so the toggle correctly reflects the server state on initial page load and session switch.
When POST /api/sessions/{id}/yolo runs against a stopped session,
append a StatusUpdate(yolo_mode=...) record to wire.jsonl in addition
to saving session_state.json. This ensures replay emits the correct
YOLO state on reconnect, preventing the toggle from showing stale
values until the next live update.
Add comprehensive tests for the YOLO mode REST API:
- GET /api/sessions/{id}/yolo endpoint tests
- POST /api/sessions/{id}/yolo endpoint tests
- Tests for stopped sessions (saves to disk and wire.jsonl)
- Tests for running sessions (notifies worker via set_yolo_mode)
- Wire replay tests to verify StatusUpdate records are persisted
- StatusUpdate serialization tests with yolo_mode field
Capture the sessionId at the start of the refresh request and verify it hasn't changed before applying the fetch result. This prevents stale YOLO data from the previous session from being applied to the newly selected session when a session switch happens during the fetch.
|
@RealKai42 You are a manteiner. Can you review this Pull Request please? |
# Conflicts: # src/kimi_cli/utils/pyinstaller.py # tests/utils/test_pyinstaller_utils.py
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4a0d00b726
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| const nextYoloMode = event.payload.yolo_mode; | ||
| if (typeof nextYoloMode === "boolean") { | ||
| hasReceivedLiveYoloUpdateRef.current = true; | ||
| setYoloMode(nextYoloMode); |
There was a problem hiding this comment.
Emit yolo_mode updates for non-RPC YOLO toggles
Fresh evidence in this commit: the web state only changes on StatusUpdate.yolo_mode here, but /yolo in src/kimi_cli/soul/slash.py still calls approval.set_yolo(...) without publishing a StatusUpdate(yolo_mode=...) event. In the web UI, running /yolo (or any other mutation path that skips this status event) leaves the toggle and safety indicator stale, so users can see YOLO as OFF while approvals are actually auto-approved until another YOLO status event happens.
Useful? React with 👍 / 👎.
|
This was a terrible experience, trying to make a pull request with a neat feature i would like on kimi and having to deal with gpt and devin endlesly. |
Related Issue
N/A - This is a follow-up feature to extend YOLO mode support to the Web UI.
Description
Add YOLO (auto-approve) mode support to the Web UI, allowing users to toggle automatic approval of
operations directly from the web interface.
Backend Changes
GET /api/sessions/{id}/yoloandPOST /api/sessions/{id}/yoloendpoints inweb/a pi/sessions.pyYoloStatusandUpdateYoloRequestPydantic models inweb/models.pyset_yolo_modeJSON-RPC method and includeyolo_modeinStatusUpdatemessages
session_state.pyand propagate throughKimiSoulweb/runner/process.py)Frontend Changes
useYoloModehook for state management and server synchronizationglobal-config-controls.tsx)Documentation
Tests
Checklist
md) document.
make gen-changelogto update the changelog.make gen-docsto update the user documentation.