Skip to content

Commit 1342a1e

Browse files
committed
fix: ensure checkpoints appear in chat even with invalid metadata
- Modified CheckpointSaved component to show fallback display when checkpoint metadata is missing or invalid - Added console warnings to help debug checkpoint metadata issues - Prevents checkpoints from being completely hidden due to schema validation failures - Fixes issue #5899 where users reported not seeing checkpoints despite having them enabled The component now: - Shows a fallback checkpoint display with default metadata when validation fails - Logs warnings to console for debugging purposes - Displays "metadata unavailable" indicator when using fallback data - Ensures CheckpointMenu still functions with fallback metadata
1 parent a6e16e8 commit 1342a1e

File tree

1 file changed

+29
-6
lines changed

1 file changed

+29
-6
lines changed

webview-ui/src/components/chat/checkpoints/CheckpointSaved.tsx

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,32 +17,55 @@ export const CheckpointSaved = ({ checkpoint, ...props }: CheckpointSavedProps)
1717

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

2324
const result = checkpointSchema.safeParse(checkpoint)
2425

2526
if (!result.success) {
27+
console.warn("[CheckpointSaved] Invalid checkpoint metadata", {
28+
checkpoint,
29+
errors: result.error.errors,
30+
ts: props.ts,
31+
commitHash: props.commitHash
32+
})
2633
return undefined
2734
}
2835

2936
return result.data
30-
}, [checkpoint])
37+
}, [checkpoint, props.ts, props.commitHash])
3138

32-
if (!metadata) {
33-
return null
34-
}
39+
// Always show the checkpoint, even if metadata is invalid
40+
// This ensures users can see that checkpoints are being created
41+
const fallbackMetadata = useMemo(() => {
42+
if (metadata) {
43+
return metadata
44+
}
45+
46+
// Create fallback metadata when the original is invalid
47+
return {
48+
isFirst: false, // Default to regular checkpoint
49+
from: "", // Empty string as fallback
50+
to: props.commitHash, // Use the commit hash we have
51+
}
52+
}, [metadata, props.commitHash])
3553

3654
return (
3755
<div className="flex items-center justify-between">
3856
<div className="flex gap-2">
3957
<span className="codicon codicon-git-commit text-blue-400" />
4058
<span className="font-bold">
41-
{metadata.isFirst ? t("chat:checkpoint.initial") : t("chat:checkpoint.regular")}
59+
{fallbackMetadata.isFirst ? t("chat:checkpoint.initial") : t("chat:checkpoint.regular")}
4260
</span>
4361
{isCurrent && <span className="text-muted text-sm">{t("chat:checkpoint.current")}</span>}
62+
{!metadata && (
63+
<span className="text-muted text-xs italic">
64+
{t("chat:checkpoint.metadataUnavailable", "metadata unavailable")}
65+
</span>
66+
)}
4467
</div>
45-
<CheckpointMenu {...props} checkpoint={metadata} />
68+
<CheckpointMenu {...props} checkpoint={fallbackMetadata} />
4669
</div>
4770
)
4871
}

0 commit comments

Comments
 (0)