forked from cline/cline
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Enhance Diff View #7841
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Enhance Diff View #7841
Changes from 9 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
e4361d4
feat: enhance checkpoint diff functionality with new modes and UI upd…
NaccOll 43c7ffb
feat: add detailed mode descriptions for checkpointDiff options and u…
NaccOll d75daf1
fix: add validation for checkpointDiff mode to ensure first checkpoin…
NaccOll 82bb2e5
feat: remove full diff view button
NaccOll 1a71b68
Merge branch 'main' of https://github.com/RooCodeInc/Roo-Code into fe…
NaccOll 588fae7
feat: change more diff button to drop-down menu
NaccOll 7d5a21c
Merge branch 'main' of https://github.com/RooCodeInc/Roo-Code into fe…
NaccOll 1e119d6
fix: popover show error when CheckpointMenu has multiple popover
NaccOll d881c8c
fix: update icon in CheckpointMenu for better clarity
NaccOll e27c044
Update webview-ui/src/components/chat/checkpoints/CheckpointMenu.tsx
NaccOll File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -270,10 +270,16 @@ export async function checkpointRestore( | |
| } | ||
|
|
||
| export type CheckpointDiffOptions = { | ||
| ts: number | ||
| ts?: number | ||
| previousCommitHash?: string | ||
| commitHash: string | ||
| mode: "full" | "checkpoint" | ||
| /** | ||
| * from-init: Compare from the first checkpoint to the selected checkpoint. | ||
| * checkpoint: Compare the selected checkpoint to the next checkpoint. | ||
| * to-current: Compare the selected checkpoint to the current workspace. | ||
| * full: Compare from the first checkpoint to the current workspace. | ||
| */ | ||
| mode: "from-init" | "checkpoint" | "to-current" | "full" | ||
| } | ||
|
|
||
| export async function checkpointDiff(task: Task, { ts, previousCommitHash, commitHash, mode }: CheckpointDiffOptions) { | ||
|
|
@@ -285,21 +291,48 @@ export async function checkpointDiff(task: Task, { ts, previousCommitHash, commi | |
|
|
||
| TelemetryService.instance.captureCheckpointDiffed(task.taskId) | ||
|
|
||
| let prevHash = commitHash | ||
| let nextHash: string | undefined = undefined | ||
| let fromHash: string | undefined | ||
| let toHash: string | undefined | ||
| let title: string | ||
|
|
||
| if (mode !== "full") { | ||
| const checkpoints = task.clineMessages.filter(({ say }) => say === "checkpoint_saved").map(({ text }) => text!) | ||
| const idx = checkpoints.indexOf(commitHash) | ||
| if (idx !== -1 && idx < checkpoints.length - 1) { | ||
| nextHash = checkpoints[idx + 1] | ||
| } else { | ||
| nextHash = undefined | ||
| } | ||
| const checkpoints = task.clineMessages.filter(({ say }) => say === "checkpoint_saved").map(({ text }) => text!) | ||
|
|
||
NaccOll marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if (["from-init", "full"].includes(mode) && checkpoints.length < 1) { | ||
| vscode.window.showInformationMessage("No first checkpoint to compare.") | ||
| return | ||
| } | ||
|
|
||
| const idx = checkpoints.indexOf(commitHash) | ||
| switch (mode) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider extracting this switch logic into a separate function for better testability and readability. Something like: This would make the logic easier to unit test independently. |
||
| case "checkpoint": | ||
| fromHash = commitHash | ||
| toHash = idx !== -1 && idx < checkpoints.length - 1 ? checkpoints[idx + 1] : undefined | ||
| title = "Changes compare with next checkpoint" | ||
| break | ||
| case "from-init": | ||
| fromHash = checkpoints[0] | ||
| toHash = commitHash | ||
| title = "Changes since first checkpoint" | ||
| break | ||
| case "to-current": | ||
| fromHash = commitHash | ||
| toHash = undefined | ||
| title = "Changes to current workspace" | ||
| break | ||
| case "full": | ||
| fromHash = checkpoints[0] | ||
| toHash = undefined | ||
| title = "Changes since first checkpoint" | ||
| break | ||
| } | ||
|
|
||
| if (!fromHash) { | ||
| vscode.window.showInformationMessage("No previous checkpoint to compare.") | ||
| return | ||
| } | ||
|
|
||
| try { | ||
| const changes = await service.getDiff({ from: prevHash, to: nextHash }) | ||
| const changes = await service.getDiff({ from: fromHash, to: toHash }) | ||
|
|
||
| if (!changes?.length) { | ||
| vscode.window.showInformationMessage("No changes found.") | ||
|
|
@@ -308,7 +341,7 @@ export async function checkpointDiff(task: Task, { ts, previousCommitHash, commi | |
|
|
||
| await vscode.commands.executeCommand( | ||
| "vscode.changes", | ||
| mode === "full" ? "Changes since task started" : "Changes compare with next checkpoint", | ||
| title, | ||
| changes.map((change) => [ | ||
| vscode.Uri.file(change.paths.absolute), | ||
| vscode.Uri.parse(`${DIFF_VIEW_URI_SCHEME}:${change.paths.relative}`).with({ | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.