-
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
Enhance Diff View #7841
Changes from 1 commit
e4361d4
43c7ffb
d75daf1
82bb2e5
1a71b68
588fae7
7d5a21c
1e119d6
d881c8c
e27c044
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -270,10 +270,10 @@ export async function checkpointRestore( | |
| } | ||
|
|
||
| export type CheckpointDiffOptions = { | ||
| ts: number | ||
| ts?: number | ||
| previousCommitHash?: string | ||
| commitHash: string | ||
| mode: "full" | "checkpoint" | ||
| mode: "from-init" | "checkpoint" | "to-current" | "full" | ||
| } | ||
|
|
||
| export async function checkpointDiff(task: Task, { ts, previousCommitHash, commitHash, mode }: CheckpointDiffOptions) { | ||
|
|
@@ -285,21 +285,43 @@ 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 | ||
|
|
||
| const checkpoints = task.clineMessages.filter(({ say }) => say === "checkpoint_saved").map(({ text }) => text!) | ||
|
|
||
NaccOll marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 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 (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 | ||
| } | ||
| 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 +330,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({ | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.