-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Store initial checkpoint #946
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
Merged
Merged
Changes from all commits
Commits
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
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 |
|---|---|---|
| @@ -1,17 +1,19 @@ | ||
| import { useState, useEffect, useCallback } from "react" | ||
| import { CheckIcon, Cross2Icon } from "@radix-ui/react-icons" | ||
|
|
||
| import { vscode } from "../../../utils/vscode" | ||
|
|
||
| import { Button, Popover, PopoverContent, PopoverTrigger } from "@/components/ui" | ||
|
|
||
| import { vscode } from "../../../utils/vscode" | ||
| import { Checkpoint } from "./schema" | ||
|
|
||
| type CheckpointMenuProps = { | ||
| ts: number | ||
| commitHash: string | ||
| checkpoint?: Checkpoint | ||
| currentCheckpointHash?: string | ||
| } | ||
|
|
||
| export const CheckpointMenu = ({ ts, commitHash, currentCheckpointHash }: CheckpointMenuProps) => { | ||
| export const CheckpointMenu = ({ ts, commitHash, checkpoint, currentCheckpointHash }: CheckpointMenuProps) => { | ||
| const [portalContainer, setPortalContainer] = useState<HTMLElement>() | ||
| const [isOpen, setIsOpen] = useState(false) | ||
| const [isConfirming, setIsConfirming] = useState(false) | ||
|
|
@@ -43,9 +45,11 @@ export const CheckpointMenu = ({ ts, commitHash, currentCheckpointHash }: Checkp | |
|
|
||
| return ( | ||
| <div className="flex flex-row gap-1"> | ||
| <Button variant="ghost" size="icon" onClick={onCheckpointDiff} title="View Diff"> | ||
| <span className="codicon codicon-diff-single" /> | ||
| </Button> | ||
| {!checkpoint?.isFirst && ( | ||
|
Collaborator
Author
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. I don't think we want to expose the "diff" action for the initial checkpoint, but LMK if you feel differently.
Collaborator
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. Agree |
||
| <Button variant="ghost" size="icon" onClick={onCheckpointDiff} title="View Diff"> | ||
| <span className="codicon codicon-diff-single" /> | ||
| </Button> | ||
| )} | ||
| <Popover | ||
| open={isOpen} | ||
| onOpenChange={(open) => { | ||
|
|
||
21 changes: 18 additions & 3 deletions
21
webview-ui/src/components/chat/checkpoints/CheckpointSaved.tsx
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 |
|---|---|---|
| @@ -1,22 +1,37 @@ | ||
| import { useMemo } from "react" | ||
|
|
||
| import { CheckpointMenu } from "./CheckpointMenu" | ||
| import { checkpointSchema } from "./schema" | ||
|
|
||
| type CheckpointSavedProps = { | ||
| ts: number | ||
| commitHash: string | ||
| checkpoint?: Record<string, unknown> | ||
| currentCheckpointHash?: string | ||
| } | ||
|
|
||
| export const CheckpointSaved = (props: CheckpointSavedProps) => { | ||
| export const CheckpointSaved = ({ checkpoint, ...props }: CheckpointSavedProps) => { | ||
| const isCurrent = props.currentCheckpointHash === props.commitHash | ||
|
|
||
| const metadata = useMemo(() => { | ||
| if (!checkpoint) { | ||
| return undefined | ||
| } | ||
|
|
||
| const result = checkpointSchema.safeParse(checkpoint) | ||
| return result.success ? result.data : undefined | ||
| }, [checkpoint]) | ||
|
|
||
| const isFirst = !!metadata?.isFirst | ||
|
|
||
| return ( | ||
| <div className="flex items-center justify-between"> | ||
| <div className="flex gap-2"> | ||
| <span className="codicon codicon-git-commit text-blue-400" /> | ||
| <span className="font-bold">Checkpoint</span> | ||
| <span className="font-bold">{isFirst ? "Initial Checkpoint" : "Checkpoint"}</span> | ||
| {isCurrent && <span className="text-muted text-sm">Current</span>} | ||
| </div> | ||
| <CheckpointMenu {...props} /> | ||
| <CheckpointMenu {...props} checkpoint={metadata} /> | ||
| </div> | ||
| ) | ||
| } |
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 |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| import { z } from "zod" | ||
|
|
||
| export const checkpointSchema = z.object({ | ||
| isFirst: z.boolean(), | ||
| from: z.string(), | ||
| to: z.string(), | ||
| }) | ||
|
|
||
| export type Checkpoint = z.infer<typeof checkpointSchema> |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Taken from cline/cline@c29816c.