fix: sidebar updates for /undo and compacting
Adresses: #5760 #4548
two very similar issues, so i batch fixed them. let me know if I should split it instead.
Issue: compacting would not update the sidebar immediately after successful compaction and /undo does also not update Modified Files.
Cause: Issue 1: The /compact command triggers session.compacted event but session.compacted was NOT handled in sync.tsx so the sidebar never updated
Issue 2: /undo Command does not emit a session.diff event. Only session.updated is published via Session.update causing the sidebar's Modified Files to never get updated.
Fix: Issue 1: Add handler for session.compacted
Issue 2: After /revert emit a session.diff event with an empty diff array to clear the Modified Files list in the sidebar
The compaction seems to work nicely, cool!
The /undo needs more work:
- between /undo and /redo, the sidebar's context is unchanged (I guess the recalc depends on actually sending a user request first, so this is maybe not an issue)
- on two successive edits to the same file, the first /undo completely erases the sidebar's changes to the file - but the 1st edit is still active and should be shown
i updated it so now the current diff is gotten via Session.diff(input.sessionID)
so now: After /undo with two edits to the same file, the first edit's changes will now be visible in the Modified Files list After /redo, the full diff is recalculated now
hopefully this works as expected.
The compaction seems to work nicely, cool!
The /undo needs more work:
- between /undo and /redo, the sidebar's context is unchanged (I guess the recalc depends on actually sending a user request first, so this is maybe not an issue)
- on two successive edits to the same file, the first /undo completely erases the sidebar's changes to the file - but the 1st edit is still active and should be shown
Thanks for iterating on this!
For some reason the 2nd approach doesn't work for me either, now the /undo commands don't have any effect on the Modified files at all. I send a user request, get 2 tool calls + assistant response, then another user request followed by 1 tool call + assistant response.
The main view's "message(s) reverted" conversation bubbles properly show the "reverse" line changes (-2 for the first /undo, -4 for the second /undo), but perhaps that information is taken from elsewhere.
Sorry for the delay in getting back to you. I was on holiday vacation. I am reusing the sidebar’s session_diff logic instead of duplicating it, and it should be working correctly now. Thanks for the patience!
ps: for afa9319 github auto corrected the commit message but the actual message should just be "refactor for /undo" should i change it or is it fine like how it is?
Thanks for the patience!
Thanks for iterating on this!
For some reason the 2nd approach doesn't work for me either, now the /undo commands don't have any effect on the Modified files at all. I send a user request, get 2 tool calls + assistant response, then another user request followed by 1 tool call + assistant response.
The main view's "message(s) reverted" conversation bubbles properly show the "reverse" line changes (-2 for the first /undo, -4 for the second /undo), but perhaps that information is taken from elsewhere.
I'm not sure if I'm doing something wrong but for some reason this still doesn't work in my builds when testing /undo and /redo :slightly_frowning_face: