qwen-code/patches
Edenman a623a41ef3
fix(cli): statusline not re-rendering when switching from preset to command type (#4706)
* fix(cli): statusline not re-rendering when switching from preset to command type

When `/statusline [prompt]` triggers the statusline-setup agent to change
the config type from preset to command, the in-memory LoadedSettings is
never updated (the agent edits settings.json on disk via Edit/Write tools),
so useStatusLine continues rendering the stale preset config.

- Add LoadedSettings.reloadScopeFromDisk() to re-read a settings file
  from disk with env-var resolution and rawJson sync
- Add notifyStatusLineReloaded callback that clears the stale preset
  override and bumps statusLineSettingsVersion to trigger re-render
- Wire an onComplete callback in statuslineCommand that reloads user
  settings and notifies the statusline hook after the agent turn completes
- Clear submitPromptOnCompleteRef on cancel/error to prevent stale
  callbacks from leaking to subsequent turns
- Update statusline docs with preset mode reference, worktree JSON field,
  and preset-specific troubleshooting entries

* fix(cli): reload settings on stream idle instead of onComplete

onComplete fires when processGeminiStreamEvents returns, which happens
as soon as tool calls are scheduled — before the statusline-setup agent
has finished writing to settings.json. The fix adds a reload effect in
useStatusLine that triggers when streamingState transitions to Idle
(all tools done, no pending continuations), which is the true end of a
model turn.

The onComplete callback is kept as belt-and-suspenders for non-agentic
slash commands (those that don't invoke tools), but the primary sync
point is now the streamingState → Idle transition.

* docs: add /statusline to commands reference with link to status-line page

* refactor(cli): remove onComplete mechanism, keep only idle-reload path

The onComplete callback fires when processGeminiStreamEvents returns,
which is before the statusline-setup agent finishes writing settings.json.
Remove the entire onComplete + notifyStatusLineReloaded plumbing and rely
solely on the streamingState → Idle reload effect in useStatusLine.

Also optimize the reload effect to compare the serialized statusLine
config before and after reloading from disk, only bumping the re-render
key when the config actually changed — avoids unnecessary doUpdate()
calls on turns that didn't touch statusline settings.

* chore(cli): shorten statusline reload comment

---------

Co-authored-by: 克竟 <dingbingzhi.dbz@alibaba-inc.com>
2026-06-03 14:17:16 +08:00
..
ink+7.0.3.patch fix(cli): statusline not re-rendering when switching from preset to command type (#4706) 2026-06-03 14:17:16 +08:00