Skip to content

Commit ea25699

Browse files
committed
fix(ui): clear patch actions after approval or rejection
1 parent daf04d2 commit ea25699

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

codetide/agents/tide/ui/app.py

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,12 @@ async def on_inspect_context(action :cl.Action):
268268
@cl.action_callback("approve_patch")
269269
async def on_approve_patch(action :cl.Action):
270270
agent_tide_ui: AgentTideUi = cl.user_session.get("AgentTideUi")
271+
271272
await action.remove()
273+
latest_action_message :cl.Message = cl.user_session.get("latest_patch_msg")
274+
if latest_action_message.id == action.payload.get("action_id"):
275+
latest_action_message.actions = []
276+
272277
if action.payload.get("lgtm"):
273278
agent_tide_ui.agent_tide.approve()
274279

@@ -278,6 +283,10 @@ async def on_reject_patch(action :cl.Action):
278283
chat_history = cl.user_session.get("chat_history")
279284

280285
await action.remove()
286+
latest_action_message :cl.Message = cl.user_session.get("latest_patch_msg")
287+
if latest_action_message.id == action.payload.get("action_id"):
288+
latest_action_message.actions = []
289+
281290
response = await cl.AskUserMessage(
282291
content="""Please provide specific feedback explaining why the patch was rejected. Include what's wrong, which parts are problematic, and what needs to change. Avoid vague responses like "doesn't work" - instead be specific like "missing error handling for FileNotFoundError" or "function should return boolean, not None." Your detailed feedback helps generate a better solution.""",
283292
timeout=3600
@@ -404,20 +413,25 @@ async def agent_loop(message: Optional[cl.Message]=None, codeIdentifiers: Option
404413
await agent_tide_ui.add_to_history(msg.content)
405414

406415
if agent_tide_ui.agent_tide._has_patch:
407-
choice = await cl.AskActionMessage(
416+
action_msg = cl.AskActionMessage(
408417
content="AgentTide is asking you to review the Patch before applying it.",
409-
actions=[
410-
cl.Action(name="approve_patch", payload={"lgtm": True}, label="✔️ Approve"),
411-
cl.Action(name="reject_patch", payload={"lgtm": False}, label="❌ Reject"),
412-
],
418+
actions=[],
413419
timeout=3600
414-
).send()
420+
)
421+
action_msg.actions = [
422+
cl.Action(name="approve_patch", payload={"lgtm": True, "msg_id": action_msg.id}, label="✔️ Approve"),
423+
cl.Action(name="reject_patch", payload={"lgtm": False, "msg_id": action_msg.id}, label="❌ Reject")
424+
]
425+
cl.user_session.set("latest_patch_msg", action_msg)
426+
choice = await action_msg.send()
415427

416428
if choice:
417429
lgtm = choice.get("payload", []).get("lgtm")
418430
if lgtm:
431+
action_msg.actions = []
419432
agent_tide_ui.agent_tide.approve()
420433
else:
434+
action_msg.actions = []
421435
response = await cl.AskUserMessage(
422436
content="""Please provide specific feedback explaining why the patch was rejected. Include what's wrong, which parts are problematic, and what needs to change. Avoid vague responses like "doesn't work" - instead be specific like "missing error handling for FileNotFoundError" or "function should return boolean, not None." Your detailed feedback helps generate a better solution.""",
423437
timeout=3600

0 commit comments

Comments
 (0)