Skip to content

The agent that grows with you

test(acp): the editor's own mode pick projected before session.mutate answers

Teknium435b61400ad5
diff --git a/tests/acp_adapter/test_gateway_session_commands.py b/tests/acp_adapter/test_gateway_session_commands.py
index f6d1bea9f63..63ccf20a104 100644
--- a/tests/acp_adapter/test_gateway_session_commands.py
+++ b/tests/acp_adapter/test_gateway_session_commands.py
@@ -139,6 +139,26 @@ async def test_modes_and_the_config_option_set_the_owners_edit_policy():
+async def test_the_editors_own_pick_projected_before_the_mutation_answers_is_harmless():
+ """The owner publishes ``session.info`` inside the commit, before ``session.mutate`` answers, so the
+ pump may project the editor's own pick first: at most one ``current_mode_update`` of the picked
+ mode, and the pump keeps running."""
+ async def rpc(method, **params):
+ if method == 'session.resume':
+ return {'revision': 3, 'execution_generation': 7}
+ await agent._project({'session_id': 's', 'type': 'session.info',
+ 'payload': {'edit_approval_policy': params['payload']['policy']}})
+ return {'session_id': 's', 'operation': 'edit_policy', 'revision': 4}
+
+ agent = _agent(rpc)
+ agent._modes['s'] = 'default'
+ await agent.set_session_mode('dont_ask', 's')
+ shown = [call.kwargs['update'] for call in agent._conn.session_update.await_args_list]
+ assert [(u.session_update, u.current_mode_id) for u in shown] == [('current_mode_update', 'dont_ask')], shown
+ assert agent._modes['s'] == 'dont_ask' and agent._failure is None
+
+
@pytest.mark.asyncio
@pytest.mark.parametrize('pick', [lambda a: a.set_session_mode('dont_ask', 's'),
lambda a: a.set_config_option('edit_approval_policy', 's', 'session')])