mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-10-01 20:42:22 +02:00
fix(ui): complete exact approval continuation
This commit is contained in:
@@ -37,7 +37,7 @@ def _patch_common(monkeypatch):
|
||||
monkeypatch.setattr(al, "estimate_tokens", lambda *a, **k: 10, raising=False)
|
||||
|
||||
async def _fake_exec(block, *a, **k):
|
||||
return ("bash", {"output": "ok", "exit_code": 0})
|
||||
return (block.tool_type, {"output": "ok", "exit_code": 0})
|
||||
monkeypatch.setattr(al, "execute_tool_block", _fake_exec, raising=False)
|
||||
|
||||
|
||||
@@ -58,8 +58,14 @@ def _run_loop(monkeypatch, round_text, max_rounds=2):
|
||||
|
||||
def test_emits_rounds_exhausted_when_cap_hit_mid_task(monkeypatch):
|
||||
_patch_common(monkeypatch)
|
||||
# Every round returns a tool block -> never "done" -> loop exhausts the cap.
|
||||
events = _run_loop(monkeypatch, "```bash\necho hi\n```", max_rounds=2)
|
||||
# Use a system-owned interaction result so this remains a loop-control test:
|
||||
# Bash output is workspace-derived and now correctly pauses for exact user
|
||||
# approval before a later Bash call.
|
||||
events = _run_loop(
|
||||
monkeypatch,
|
||||
'```update_plan\n{"plan":"- [ ] keep going"}\n```',
|
||||
max_rounds=2,
|
||||
)
|
||||
assert any(e.get("type") == "rounds_exhausted" for e in events), events
|
||||
|
||||
|
||||
@@ -84,7 +90,11 @@ def test_emits_intent_nudge_exhausted_when_cap_is_exhausted(monkeypatch):
|
||||
def test_emits_loop_breaker_triggered_when_loop_breaker_trips(monkeypatch):
|
||||
_patch_common(monkeypatch)
|
||||
|
||||
events = _run_loop(monkeypatch, "```bash\necho hi\n```", max_rounds=6)
|
||||
events = _run_loop(
|
||||
monkeypatch,
|
||||
'```update_plan\n{"plan":"- [ ] keep going"}\n```',
|
||||
max_rounds=6,
|
||||
)
|
||||
|
||||
guard = next((e for e in events if e.get("type") == "loop_breaker_triggered"), None)
|
||||
assert guard is not None, events
|
||||
|
||||
@@ -854,6 +854,7 @@ def test_frontend_tool_approval_uses_opaque_id_and_fixed_decisions():
|
||||
root = Path(__file__).parents[1]
|
||||
chat = (root / "static/js/chat.js").read_text()
|
||||
renderer = (root / "static/js/chatRenderer.js").read_text()
|
||||
index = (root / "static/index.html").read_text()
|
||||
|
||||
assert "fd.append('tool_approval_id'" in chat
|
||||
assert "fd.append('tool_approval_decision'" in chat
|
||||
@@ -861,6 +862,12 @@ def test_frontend_tool_approval_uses_opaque_id_and_fixed_decisions():
|
||||
assert "aq.kind === 'tool_approval'" in renderer
|
||||
assert "aq.action.content" in renderer
|
||||
assert "decision: String((opt && opt.value)" in renderer
|
||||
assert "if (isStreaming || _sendInFlight)" in chat
|
||||
assert "_submitToolApprovalWhenIdle" in chat
|
||||
assert "input.dispatchEvent(new Event('input'" in chat
|
||||
assert "const firstRound = (toolsByRound[0] || []).length ? 0 : 1" in renderer
|
||||
assert index.count("app.js?v=20260815toolapproval2") == 2
|
||||
assert "app.js?v=20260808startupshell1" not in index
|
||||
|
||||
|
||||
def test_frontend_raw_fences_do_not_call_document_mutators():
|
||||
|
||||
@@ -23,7 +23,7 @@ _IMPORT_REWRITES = {
|
||||
"import uiModule, { autoResize, styledPrompt } from './ui.js';": (
|
||||
"import uiModule, { autoResize, styledPrompt } from './ui.mjs';"
|
||||
),
|
||||
"import chatRenderer from './chatRenderer.js?v=20260722ctxheader1';": (
|
||||
"import chatRenderer from './chatRenderer.js?v=20260815toolapproval2';": (
|
||||
"import chatRenderer from './chatRenderer.mjs';"
|
||||
),
|
||||
"import { providerLogo } from './providers.js';": (
|
||||
|
||||
Reference in New Issue
Block a user