dev-story-history#25
Conversation
- Added StoryHistory model to track snapshots of stories before updates. - Updated Story model to include a relation to StoryHistory. - Enhanced story saving logic to create a snapshot before overwriting existing stories. - Introduced API endpoints to list and retrieve specific story history entries. - Integrated StoryHistoryModal in the SnapshotStoryboard component for user access to story history.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Summary of ChangesHello @MatsunoHitoshi, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a robust story history tracking system, enabling the application to maintain a record of story versions. This feature ensures that users can review previous states of their stories, enhancing data integrity and providing a valuable rollback mechanism. The changes span database schema, backend API logic, and frontend UI components to deliver a complete solution. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request successfully implements story history tracking and management. The changes are well-structured, encompassing database schema updates, backend API enhancements, and new frontend components. The introduction of the StoryHistory model and the logic for creating snapshots within a transaction are well-executed, ensuring data integrity. The new API endpoints for history management include appropriate access controls. The StoryHistoryModal provides a clean interface for users to view story history. I have a couple of suggestions to improve the new modal component, focusing on safer data handling and accessibility.
|
|
||
| const historyStoryItems = useMemo(() => { | ||
| if (!entry?.snapshotData) return []; | ||
| const data = entry.snapshotData as SnapshotDataLike; |
There was a problem hiding this comment.
The type assertion as SnapshotDataLike is unsafe. The entry.snapshotData is of type Json from Prisma, and its structure is not guaranteed at compile time. If the data format in the database ever deviates from the SnapshotDataLike interface, this could lead to runtime errors.
To make this more robust, I recommend using a validation library like Zod to safely parse snapshotData. This ensures the data conforms to the expected shape before use and allows for graceful error handling.
You can define a schema at the top of your file:
import { z } from "zod";
// ...
const SnapshotDataLikeSchema = z.object({
summaries: z.array(z.object({ communityId: z.string(), title: z.string(), summary: z.string() })).optional(),
narrativeFlow: z.array(z.object({ communityId: z.string(), order: z.number(), transitionText: z.string() })).optional(),
detailedStories: z.record(z.union([z.string(), z.any()])).optional(), // z.any() for JSONContent
});Then, use it to parse the data safely.
const parseResult = SnapshotDataLikeSchema.safeParse(entry.snapshotData);
if (!parseResult.success) {
console.error("Failed to parse snapshotData:", parseResult.error);
return [];
}
const data = parseResult.data;
| {h.savedBy.image && ( | ||
| <img | ||
| src={h.savedBy.image} | ||
| alt="" |
There was a problem hiding this comment.
For accessibility, the img tag for the user avatar should have descriptive alt text. Currently, it's empty. While this is sometimes acceptable for purely decorative images, in this context, the image conveys who saved the history entry. Providing the user's name as alt text would be more informative for users of screen readers.
alt={h.savedBy.name ?? "User avatar"}
feat: implement story history tracking and management