Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 29 additions & 6 deletions webview-ui/src/components/chat/checkpoints/CheckpointSaved.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,32 +17,55 @@ export const CheckpointSaved = ({ checkpoint, ...props }: CheckpointSavedProps)

const metadata = useMemo(() => {
if (!checkpoint) {
console.warn("[CheckpointSaved] No checkpoint metadata provided", { ts: props.ts, commitHash: props.commitHash })
return undefined
}

const result = checkpointSchema.safeParse(checkpoint)

if (!result.success) {
console.warn("[CheckpointSaved] Invalid checkpoint metadata", {
checkpoint,
errors: result.error.errors,
ts: props.ts,
commitHash: props.commitHash
})
return undefined
}

return result.data
}, [checkpoint])
}, [checkpoint, props.ts, props.commitHash])

if (!metadata) {
return null
}
// Always show the checkpoint, even if metadata is invalid
// This ensures users can see that checkpoints are being created
const fallbackMetadata = useMemo(() => {
if (metadata) {
return metadata
}

// Create fallback metadata when the original is invalid
return {
isFirst: false, // Default to regular checkpoint
from: "", // Empty string as fallback
to: props.commitHash, // Use the commit hash we have
}
}, [metadata, props.commitHash])

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">
{metadata.isFirst ? t("chat:checkpoint.initial") : t("chat:checkpoint.regular")}
{fallbackMetadata.isFirst ? t("chat:checkpoint.initial") : t("chat:checkpoint.regular")}
</span>
{isCurrent && <span className="text-muted text-sm">{t("chat:checkpoint.current")}</span>}
{!metadata && (
<span className="text-muted text-xs italic">
{t("chat:checkpoint.metadataUnavailable", "metadata unavailable")}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid providing an inline English fallback string in the translation call. Remove the second argument from t('chat:checkpoint.metadataUnavailable') and manage defaults via the translation JSON files.

Suggested change
{t("chat:checkpoint.metadataUnavailable", "metadata unavailable")}
{t("chat:checkpoint.metadataUnavailable")}

This comment was generated because it violated a code review rule: irule_C0ez7Rji6ANcGkkX.

</span>
)}
</div>
<CheckpointMenu {...props} checkpoint={metadata} />
<CheckpointMenu {...props} checkpoint={fallbackMetadata} />
</div>
)
}