Skip to content

dev-story-history#25

Open
MatsunoHitoshi wants to merge 1 commit into
mainfrom
dev-story-history
Open

dev-story-history#25
MatsunoHitoshi wants to merge 1 commit into
mainfrom
dev-story-history

Conversation

@MatsunoHitoshi
Copy link
Copy Markdown
Owner

feat: implement story history tracking and management

  • 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.

- 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.
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Feb 11, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
graph-viz-with-llm Error Error Feb 11, 2026 4:41am

Request Review

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello @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 Story History Model: Introduced a new StoryHistory model in the Prisma schema to store snapshots of stories before they are updated, along with relations to Story and User models.
  • Automatic Snapshot Creation: Implemented logic within the story saving process to automatically create a snapshot of the current story state and save it as a StoryHistory entry before any modifications are applied.
  • API Endpoints for History: Added new API endpoints (listHistory and getHistoryEntry) to allow fetching a list of story history entries for a workspace and retrieving the details of a specific historical snapshot.
  • User Interface Integration: Integrated a new StoryHistoryModal component into the SnapshotStoryboard to provide users with a dedicated interface to view and browse the historical versions of their stories.

🧠 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
  • prisma/schema.prisma
    • Added StoryHistory model with fields for storyId, snapshotData, description, savedById, and createdAt.
    • Established a one-to-many relationship between Story and StoryHistory.
    • Established a one-to-many relationship between User and StoryHistory.
  • src/app/_components/curators-writing-workspace/artifact/snapshot-storyboard.tsx
    • Imported StoryHistoryModal component.
    • Added isHistoryModalOpen state variable to control the visibility of the history modal.
    • Included a '履歴' (History) button that toggles the StoryHistoryModal.
  • src/app/_components/curators-writing-workspace/artifact/story-history-modal.tsx
    • Created a new React component StoryHistoryModal to display a list of story history entries.
    • Implemented state management for selecting a specific history entry.
    • Utilized api.story.listHistory and api.story.getHistoryEntry to fetch and display historical data.
    • Provided a user interface to browse historical story snapshots, including details like creation date and the user who saved it.
  • src/server/api/routers/story.ts
    • Modified the save procedure to include relationshipsFrom in the existingStory query for comprehensive snapshot data.
    • Added logic within the save procedure to create a StoryHistory entry with snapshotData before updating an existing story.
    • Implemented listHistory protected procedure to retrieve all history entries for a given story, including savedBy user details.
    • Implemented getHistoryEntry protected procedure to fetch a single story history entry by its ID, ensuring proper access control.
Activity
  • The pull request was created with the title 'dev-story-history' and a description outlining the implementation of story history tracking and management.
  • The description detailed the addition of the StoryHistory model, updates to Story and User models, enhancement of story saving logic for snapshots, introduction of API endpoints, and integration of StoryHistoryModal.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

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;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

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=""
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

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"}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant