Skip to content

The agent that grows with you

test(gateway,desktop): a compression busy refusal logs at debug, and only a busy refusal gets the wait text (currently failing)

yoniebans7c3212a906b9
diff --git a/apps/desktop/src/app/session/hooks/use-prompt-actions/slash-session-commands.test.tsx b/apps/desktop/src/app/session/hooks/use-prompt-actions/slash-session-commands.test.tsx
index 4ab63895a18..ecf2e674d0a 100644
--- a/apps/desktop/src/app/session/hooks/use-prompt-actions/slash-session-commands.test.tsx
+++ b/apps/desktop/src/app/session/hooks/use-prompt-actions/slash-session-commands.test.tsx
@@ -283,6 +283,29 @@ describe('/undo and /retry while a compression holds the session', () => {
expect(callsOf(requestGateway, 'prompt.submit')).toEqual([])
})
}
+
+ it('keeps the wait text for a busy refusal only, not another refusal naming the same field', async () => {
+ const other = new JsonRpcGatewayError('invalid_params', {
+ code: 4001,
+ data: { field: 'compression', reason: 'invalid_params' }
+ })
+
+ const requestGateway = gateway(method => {
+ if (method === 'session.resume') {
+ return SNAPSHOT
+ }
+
+ if (method === 'session.rewind') {
+ throw other
+ }
+ })
+
+ const handle = await mount(requestGateway)
+ await handle.submitText('/undo')
+
+ expect(renderedText(handle)).toContain('error: invalid_params')
+ expect(renderedText(handle)).not.toContain('a /compress is running')
+ })
})
describe('/steer', () => {
diff --git a/tests/gateway/test_session_busy_compression_refusal.py b/tests/gateway/test_session_busy_compression_refusal.py
index 49ab60fd821..063626cdb18 100644
--- a/tests/gateway/test_session_busy_compression_refusal.py
+++ b/tests/gateway/test_session_busy_compression_refusal.py
@@ -19,7 +19,7 @@ async def _rewind(db, owner, ref, target):
@pytest.mark.asyncio
-async def test_rewind_under_a_held_compression_lock_names_the_lock(tmp_path, monkeypatch):
+async def test_rewind_under_a_held_compression_lock_names_the_lock(tmp_path, monkeypatch, caplog):
async def handle(event):
return 'ok'
store, db, authority, owner, ref = _owner(tmp_path, monkeypatch, handle)
@@ -28,9 +28,14 @@ async def test_rewind_under_a_held_compression_lock_names_the_lock(tmp_path, mon
target = transcript_target(authority, ref)
db.append_message(target, 'user', 'keep')
assert db.try_acquire_compression_lock(target, 'another-writer')
- reply = await _rewind(db, owner, ref, target)
+ import logging
+ with caplog.at_level(logging.DEBUG, logger='gateway.session_controls'):
+ reply = await _rewind(db, owner, ref, target)
assert reply['error']['message'] == 'session_busy', reply
assert reply['error']['data'] == {'reason': 'session_busy', 'field': 'compression'}
+ # A retrying client (Desktop's edit retries busy for 6 s) must not flood the log.
+ refusals = [r for r in caplog.records if 'session.mutate refused' in r.getMessage()]
+ assert refusals and all(r.levelno == logging.DEBUG for r in refusals), refusals
assert [m['content'] for m in db.get_messages(target)] == ['keep']
finally:
await owner.close()