Skip to content

The agent that grows with you

fix(acp): project config options on outside changes; document prompt.cancel

unsupportedpastels8aee8df0ecda
diff --git a/acp_adapter/gateway_server.py b/acp_adapter/gateway_server.py
index 1bfef1c9d20..40c70beeec6 100644
--- a/acp_adapter/gateway_server.py
+++ b/acp_adapter/gateway_server.py
@@ -117,6 +117,8 @@ class GatewayACPAgent(GatewayReplyMixin, acp.Agent):
self._titles = {}
# Session -> the mode (edit approval policy) the editor was last shown (``current_mode_update``).
self._modes = {}
+ # Session -> the mode / model / effort the editor's ``configOptions`` last showed (``config_option_update``).
+ self._configs = {}
# Session -> the owner's latest usage dict (``session.usage`` / ``session.stats``).
self._usage = {}
self._background = set()
@@ -1074,13 +1076,33 @@ class GatewayACPAgent(GatewayReplyMixin, acp.Agent):
from acp_adapter.modes import EDIT_APPROVAL_POLICY_TO_MODE
mode = EDIT_APPROVAL_POLICY_TO_MODE.get(payload.get("edit_approval_policy"))
# A session's first (its attach's snapshot) seeds silently: the attach's reply shows it.
- if mode is None or self._modes.setdefault(sid, mode) == mode:
+ if mode is not None and self._modes.setdefault(sid, mode) != mode:
+ self._modes[sid] = mode
+ if self._conn:
+ from acp.schema import CurrentModeUpdate # ``acp`` does not re-export ``update_current_mode``
+ await self._conn.session_update(session_id=editor_id, update=CurrentModeUpdate(
+ session_update="current_mode_update", current_mode_id=mode))
+ await self._project_config(sid, editor_id, payload)
+
+ async def _project_config(self, sid, editor_id, payload):
+ """Zed draws its pickers only from ``configOptions`` once an agent sends them (it then ignores
+ ``current_mode_update``), so a mode, model or effort change from another surface or a typed
+ ``/model`` / ``/reasoning`` resends the full list. A partial ``session.info`` keeps what it omits."""
+ from acp_adapter.gateway_session_meta import config_options, current_mode, model_state
+ fields = ("model", "provider", "reasoning_effort")
+ if not any(key in payload for key in (*fields, "edit_approval_policy")):
return
- self._modes[sid] = mode
- if self._conn:
- from acp.schema import CurrentModeUpdate # ``acp`` does not re-export ``update_current_mode``
- await self._conn.session_update(session_id=editor_id, update=CurrentModeUpdate(
- session_update="current_mode_update", current_mode_id=mode))
+ seen = self._configs.get(sid)
+ shown = {**(seen or {}), **{key: payload[key] for key in fields if key in payload},
+ "mode": self._modes.get(sid) or current_mode(payload)}
+ self._configs[sid] = shown
+ # Seeded silently like the mode: the attach's reply carries the options.
+ if seen is None or seen == shown or not self._conn:
+ return
+ from acp.schema import ConfigOptionUpdate
+ models = await asyncio.to_thread(model_state, shown)
+ await self._conn.session_update(session_id=editor_id, update=ConfigOptionUpdate(
+ session_update="config_option_update", config_options=config_options(models, shown, shown["mode"])))
async def _project_usage(self, sid, editor_id, stats):
"""The owner's usage dict: kept for the turn's ``PromptResponse.usage``, shown as ``usage_update``."""
diff --git a/acp_adapter/gateway_session_meta.py b/acp_adapter/gateway_session_meta.py
index b559900f4be..b24dd89fb29 100644
--- a/acp_adapter/gateway_session_meta.py
+++ b/acp_adapter/gateway_session_meta.py
@@ -89,9 +89,12 @@ def config_options(models: SessionModelState | None, info: dict, mode_id: str) -
if models is not None:
options.append(select("model", "Model", "model", models.current_model_id,
[(m.model_id, m.name) for m in models.available_models]))
- effort = info.get("reasoning_effort")
- options.append(select(REASONING_CONFIG_ID, "Reasoning effort", "thought_level",
- effort if effort in reasoning_choices() else "default", [(v, v) for v in reasoning_choices()]))
+ # ``session.info`` reports the level in force, never ``default`` (a reset session reads the profile's), so
+ # ``default`` is offered only while no level is set: a pick never shows as another value than the one chosen.
+ levels = reasoning_choices()[1:]
+ effort = info.get("reasoning_effort") if info.get("reasoning_effort") in levels else "default"
+ options.append(select(REASONING_CONFIG_ID, "Reasoning effort", "thought_level", effort,
+ [(v, v) for v in (levels if effort in levels else ("default", *levels))]))
return options
diff --git a/apps/shared/src/gateway-contract.generated.ts b/apps/shared/src/gateway-contract.generated.ts
index 00a14a5d44b..6e777117819 100644
--- a/apps/shared/src/gateway-contract.generated.ts
+++ b/apps/shared/src/gateway-contract.generated.ts
@@ -6822,7 +6822,7 @@ export interface CanonicalRpcMethods {
/** Native-owner only: admit the dispatcher's current claim on a kanban task. */
'kanban.run': { params: KanbanRunParams; result: KanbanRunResult }
'profiles.list': { params: CanonicalProfilesParams; result: CanonicalProfilesResult }
- /** Retire a still-queued admission; a started one is unaffected. */
+ /** Retire a queued admission; a started one is interrupted in the same call. */
'prompt.cancel': { params: PromptCancelParams; result: AdmissionStatus }
/** Current receipt of one admission the caller submitted (or controls). */
'prompt.receipt': { params: PromptReceiptParams; result: PromptReceiptResult }
diff --git a/apps/shared/src/gateway-contract.openrpc.json b/apps/shared/src/gateway-contract.openrpc.json
index 0b113e1ab38..6b23ca77f24 100644
--- a/apps/shared/src/gateway-contract.openrpc.json
+++ b/apps/shared/src/gateway-contract.openrpc.json
@@ -47866,7 +47866,7 @@
},
{
"name": "prompt.cancel",
- "summary": "Retire a still-queued admission; a started one is unaffected.",
+ "summary": "Retire a queued admission; a started one is interrupted in the same call.",
"params": [
{
"name": "params",
diff --git a/tests/acp_adapter/test_gateway_config_options.py b/tests/acp_adapter/test_gateway_config_options.py
index 38b372c28d4..4108834893f 100644
--- a/tests/acp_adapter/test_gateway_config_options.py
+++ b/tests/acp_adapter/test_gateway_config_options.py
@@ -29,3 +29,17 @@ async def test_effort_pick_applies_through_the_reasoning_mutation_and_returns_th
assert mutations == [('reasoning', {'effort': 'high'})]
pickers = {option.category: option.current_value for option in reply.config_options}
assert pickers == {'mode': 'ask', 'model': 'openrouter:fixture', 'thought_level': 'high'}
+
+
+def test_the_effort_picker_offers_default_only_while_no_level_is_set():
+ from acp_adapter.gateway_session_meta import config_options
+ from acp_adapter.modes import DEFAULT_MODE
+
+ def effort(level):
+ option = config_options(None, {'reasoning_effort': level}, DEFAULT_MODE)[-1]
+ return option.current_value, [choice.value for choice in option.options]
+ # ``default`` (a reset) reads back as the profile's level: offering it would make the pick jump.
+ current, values = effort('medium')
+ assert current == 'medium' and 'default' not in values
+ current, values = effort('')
+ assert current == 'default' and values[0] == 'default'
diff --git a/tests/acp_adapter/test_gateway_config_projection.py b/tests/acp_adapter/test_gateway_config_projection.py
new file mode 100644
index 00000000000..7d6096149da
--- /dev/null
+++ b/tests/acp_adapter/test_gateway_config_projection.py
@@ -0,0 +1,22 @@
+"""Zed reads its pickers only from ``configOptions`` once an agent sends them, so another surface's mode
+or effort change must reach it as ``config_option_update``, not ``current_mode_update`` alone."""
+from unittest.mock import AsyncMock
+
+import pytest
+
+from acp_adapter.gateway_server import GatewayACPAgent
+
+
+async def test_another_surfaces_mode_and_effort_change_resend_the_config_options(monkeypatch):
+ monkeypatch.setattr('acp_adapter.gateway_session_meta.model_state', lambda info: None)
+ agent = GatewayACPAgent()
+ agent._conn = AsyncMock()
+ info = {'edit_approval_policy': 'ask', 'model': 'fixture', 'reasoning_effort': 'medium'}
+ await agent._project_mode('s', 's', info) # the attach's snapshot: its reply shows it
+ await agent._project_mode('s', 's', {**info, 'edit_approval_policy': 'session'})
+ await agent._project_mode('s', 's', {'reasoning_effort': 'high'}) # a partial session.info
+ shown = [{option.category: option.current_value for option in call.kwargs['update'].config_options}
+ for call in agent._conn.session_update.await_args_list
+ if call.kwargs['update'].session_update == 'config_option_update']
+ assert shown == [{'mode': 'session', 'thought_level': 'medium'}, {'mode': 'session', 'thought_level': 'high'}]
diff --git a/tui_gateway/contracts/canonical.py b/tui_gateway/contracts/canonical.py
index 9fde53d7bab..393cf24bb4b 100644
--- a/tui_gateway/contracts/canonical.py
+++ b/tui_gateway/contracts/canonical.py
@@ -62,7 +62,7 @@ class PromptCancelParams(Params):
canonical_method("prompt.cancel", params=PromptCancelParams, result=AdmissionStatus,
- doc="Retire a still-queued admission; a started one is unaffected.")
+ doc="Retire a queued admission; a started one is interrupted in the same call.")
class PromptResolveUnknownParams(Params):
diff --git a/website/docs/user-guide/tui.md b/website/docs/user-guide/tui.md
index dacedcbb8e0..b95d4cdb583 100644
--- a/website/docs/user-guide/tui.md
+++ b/website/docs/user-guide/tui.md
@@ -112,7 +112,7 @@ On macOS, `F7` means the physical F7 function key. MacBook keyboards may use tha
- **`/terminal-setup`** installs local VS Code / Cursor / Windsurf terminal bindings for better `Cmd+Enter` and undo/redo parity on macOS.
- **Slash autocompletion** opens as a floating panel with descriptions, not an inline dropdown.
- **Typing while the agent is busy** (`display.busy_input_mode: queue`, the TUI default) submits the message to the gateway immediately. The gateway's durable session queue orders it behind the running turn, so it survives a gateway crash or restart and shows up as `[queued] …` in the `queued (N)` panel of every client attached to the session — the Desktop app sees the same list. Your message's transcript bubble appears when its turn actually starts. `steer` and `interrupt` still act on the live turn as before.
-- **`Ctrl+X`** opens the live session switcher. When a queued message is highlighted (sent while the agent was still running), it still deletes that queued message instead — for a gateway-queued row this cancels it on the gateway (`prompt.cancel`), so it disappears for every viewer; picking and re-sending an edited row cancels the original and submits the edit as a new input. **`Esc`** cancels editing and unhighlights without deleting.
+- **`Ctrl+X`** opens the live session switcher. When a queued message is highlighted (sent while the agent was still running), it still deletes that queued message instead — for a gateway-queued row this cancels it on the gateway (`prompt.cancel`), so it disappears for every viewer; picking and re-sending an edited row cancels the original and submits the edit as a new input (if the original has already started by then, it is stopped and the edit runs after it). **`Esc`** cancels editing and unhighlights without deleting.
- **`Ctrl+G` / `Ctrl+X Ctrl+E`** — open the current input buffer in `$EDITOR` for multi-line / long-prompt composition; save-and-exit sends the contents back as the prompt.
## Slash commands