MoonshotAI / MoonshotAI/kimi-cli
web: support busy session metadata edits safely
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 11.4k
- Forks
- 1.3k
- Avg merge
- 9h 47m
- Merged PRs (30d)
- 2
Description
Summary
The web UI currently blocks session metadata edits while a session worker is busy. We initially tried to allow state-only edits such as rename, archive / unarchive, and title generation during busy sessions, but review found that the current state.json read-modify-write paths can lose concurrent updates.
This issue now tracks the larger fix: supporting busy-session metadata edits safely, without rolling back worker-owned or web-owned state.
Current behavior
When a session is busy, web endpoints that use get_editable_session reject metadata edits with:
Session is busy. Please wait for it to complete before modifying.
That remains the safer behavior until session-state writes have proper synchronization or field-level merge semantics.
Desired behavior
Allow state-only metadata edits while a session worker is running, including:
- rename session
- archive / unarchive session
- generate session title
Delete / fork / upload may still stay blocked, because those operations have stronger conflicts with a running worker.
Risks to solve first
PATCH /api/sessions/{session_id}currently performs an unlocked load / mutate / save of the full session state, so it can overwrite worker-owned fields saved concurrently.POST /api/sessions/{session_id}/generate-titlealso writes state after an async LLM call and needs protection against concurrent worker saves.- Not all worker writes go through the same merge path; for example, first-turn auto-title has used its own load / save cycle.
Possible approaches
- Add a field-level state patch helper for externally mutable metadata fields.
- Add file locking or CAS around session-state writes.
- Route all worker and web state writes through one merge-aware API.
- Add regression tests covering busy rename / archive / generate-title concurrent with worker saves.
Related work
PR #2102 keeps the busy-session guard in place, but fixes a smaller title race where a late AI-generated title could overwrite a title finalized by another request.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating get_editable_session, the PATCH session endpoint, and the generate-title endpoint, then trace their state load and save paths alongside worker writes. The issue suggests field-level patches, locking or CAS, and a shared merge-aware API; done means busy rename, archive, and title generation cannot overwrite concurrent worker-owned state, with regression tests covering those races.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend-api-design, cli
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100