Skip to content

fix: sidebar updates for /undo and compacting#5765

Open
flatsponge wants to merge 1 commit intoanomalyco:devfrom
flatsponge:dev
Open

fix: sidebar updates for /undo and compacting#5765
flatsponge wants to merge 1 commit intoanomalyco:devfrom
flatsponge:dev

Conversation

@flatsponge
Copy link
Copy Markdown

@flatsponge flatsponge commented Dec 18, 2025

Closes
#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

@Nindaleth
Copy link
Copy Markdown
Contributor

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

@flatsponge
Copy link
Copy Markdown
Author

flatsponge commented Dec 30, 2025

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

@Nindaleth
Copy link
Copy Markdown
Contributor

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.

@flatsponge
Copy link
Copy Markdown
Author

flatsponge commented Jan 8, 2026

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.

@Nindaleth
Copy link
Copy Markdown
Contributor

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 🙁

@github-actions
Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@flatsponge flatsponge reopened this Feb 18, 2026
@flatsponge
Copy link
Copy Markdown
Author

flatsponge commented Feb 18, 2026

opencodefix.mp4

I reverted and implemented a more stable fix + added a test file to verify the changes.
I hope this time it works for you too! :) Let me know if there are further concerns!

@Nindaleth
Copy link
Copy Markdown
Contributor

I just did a quick test and both the "Context" and "Modified Files" in the sidebar now update properly across undos, redos and compactions. The speed of the actions is the same as in dev branch.

Thank you for the improvement 👍

@flatsponge
Copy link
Copy Markdown
Author

I just did a quick test and both the "Context" and "Modified Files" in the sidebar now update properly across undos, redos and compactions. The speed of the actions is the same as in dev branch.

Thank you for the improvement 👍
Thank you for bearing with me and for the quick review! :)

@github-actions github-actions bot mentioned this pull request Feb 26, 2026
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants