feat(code-review): add revert all local changes button#3352
Conversation
Adds a button next to Refresh in the review toolbar to discard every uncommitted change at once, reusing the existing CleanWorkingTreeSaga (stashes a backup first) via a new git.discardAllChanges mutation. Generated-By: PostHog Code Task-Id: 9a3a79b8-890b-43e0-b567-938fc2cc46c4
|
Merging to
After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here |
|
React Doctor found no issues in the changed files. 🎉 Reviewed by React Doctor for commit |
|
| .mutation(({ input }) => | ||
| gitService().discardAllChanges(input.directoryPath), |
There was a problem hiding this comment.
The new mutation takes input.directoryPath from the client and sends it straight into the clean-working-tree saga. A caller that can reach this API can point it at any local Git repository the workspace-server process can access, which runs reset/restore/clean there without first checking that the path is a registered workspace owned by the caller.
Rule Used: When implementing new features, ensure that owners... (source)
Learned From
PostHog/posthog#31236
| const result = await discardAllChanges.mutateAsync({ | ||
| directoryPath: repoPath, | ||
| }); |
There was a problem hiding this comment.
If discardAllChanges.mutateAsync rejects after the user confirms, this async click handler lets the error escape without showing any failure message. The local diff can stay unchanged while the user gets no clear indication that the revert did not happen.
Rule Used: Always wrap asynchronous calls that may fail, such... (source)
Learned From
PostHog/posthog#32098
Problem
Reviewing local changes only lets you refresh the diff or discard files one at a time. No quick way to blow away all uncommitted changes at once.
Changes
CleanShot.2026-07-10.at.12.29.53.mp4
git.discardAllChangestRPC mutation on workspace-server, reusing the existingCleanWorkingTreeSaga(stashes a backup before reset/clean)useDiscardAllChangeshook with a confirm dialog before revertingHow did you test this?
pnpm typecheckon@posthog/ui,@posthog/git,@posthog/workspace-server(ran via pre-commit hook)qa-swarmreview (paul-reviewer, xp-reviewer, security-audit) — no correctness or security findings; addressed the one convergent nit (confirm dialog now mentions untracked-file deletion and the backup stash)Automatic notifications
Created with PostHog Code