Fix writing assist: disable thinking mode, drop stuck-buffer 409

- stream_chat: add think=False parameter passed through to Ollama payload.
  qwen3 models have thinking enabled by default; without this flag the model
  spends minutes generating internal thinking tokens that stream_chat silently
  discards, leaving the frontend spinner blank until the SSE connection times
  out and the widget disappears.

- create_assist_buffer: orphan (overwrite) a still-running buffer instead of
  raising. The old asyncio task holds a direct reference and completes
  harmlessly against the stale buffer. New requests always win.

- assist_route: remove the 409 guard that blocked new requests when a previous
  generation got stuck. create_assist_buffer now handles this transparently.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-05 13:28:59 -05:00
parent 9bf047ec45
commit b11a92f32d
3 changed files with 11 additions and 8 deletions
-5
View File
@@ -288,11 +288,6 @@ async def assist_route():
if not target_section or not instruction:
return jsonify({"error": "target_section and instruction are required"}), 400
# Reject if an assist generation is already running for this user
existing = get_assist_buffer(uid)
if existing and existing.state == GenerationState.RUNNING:
return jsonify({"error": "Assist generation already running"}), 409
model = await get_setting(uid, "default_model", Config.OLLAMA_MODEL) or Config.OLLAMA_MODEL
messages = build_assist_messages(body, target_section, instruction)