Skip to content

fix: autosave#27

Merged
macintushar merged 2 commits intomainfrom
fix/auto-save
May 27, 2025
Merged

fix: autosave#27
macintushar merged 2 commits intomainfrom
fix/auto-save

Conversation

@macintushar
Copy link
Copy Markdown
Owner

@macintushar macintushar commented May 26, 2025

Summary by CodeRabbit

  • New Features

    • Added auto-save functionality for scenes, saving progress every 3 seconds.
    • Save button now displays "Saving..." and is disabled while saving is in progress.
  • Improvements

    • Save operations are only triggered when changes are detected, reducing unnecessary saves.
    • Increased the delay before initial save after loading data from 10ms to 1000ms for improved stability.
    • The refresh button icon has been slightly reduced in size.
    • Added fixed height and placeholder to the page title input field.
  • Bug Fixes

    • Improved feedback and reliability of save status in the user interface.
    • Removed toast notification on successful save to streamline user experience.

@vercel
Copy link
Copy Markdown

vercel bot commented May 26, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
draw ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 27, 2025 9:56am

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented May 26, 2025

Walkthrough

The code introduces an auto-save feature to the scene editor. A new isSaving state manages the saving status, disabling the save button and updating its label during saves. The save logic now avoids redundant saves by comparing current and stored elements. Auto-saving occurs every three seconds, and UI feedback is enhanced.

Changes

File(s) Change Summary
src/views/Page.tsx Added isSaving state, auto-save interval (3 seconds), improved save logic to prevent redundant saves, updated button UI and input styling, removed toast on success, reduced refresh icon size, adjusted initial save delay to 1000ms, cleaned unused imports/comments, refactored setSceneData as a useCallback.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant PageComponent
    participant LocalStorage
    participant Server

    User->>PageComponent: Edit scene
    PageComponent->>PageComponent: setSceneData (auto/manual)
    PageComponent->>LocalStorage: Compare elements
    alt Elements changed
        PageComponent->>LocalStorage: Save scene
        PageComponent->>Server: updateScene mutation
        Server-->>PageComponent: Response (onSuccess/onError)
        PageComponent->>PageComponent: Reset isSaving
    else No changes
        PageComponent->>PageComponent: Do nothing
    end
Loading

Poem

A bunny taps the save with care,
Now auto-magic fills the air!
Every three, a gentle hop—
Saving scenes, it doesn’t stop.
A button waits, then says “Saving…”
While code ensures no double-saving.
🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c6efef8 and 3db9940.

📒 Files selected for processing (1)
  • src/views/Page.tsx (6 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/views/Page.tsx
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a2f7b05 and c6efef8.

📒 Files selected for processing (1)
  • src/views/Page.tsx (6 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/views/Page.tsx (3)
src/stores/drawDataStore.ts (1)
  • drawDataStore (52-52)
src/components/ui/button.tsx (1)
  • Button (83-83)
src/components/ui/tooltip.tsx (3)
  • TooltipProvider (28-28)
  • Tooltip (28-28)
  • TooltipTrigger (28-28)
🔇 Additional comments (7)
src/views/Page.tsx (7)

1-1: LGTM! Good addition of useCallback import.

The addition of useCallback import is necessary for the new implementation and follows best practices for React hooks.


29-29: LGTM! Proper state initialization for saving indicator.

The isSaving state is correctly initialized and will provide good user feedback during save operations.


42-50: LGTM! Proper state cleanup in mutation handlers.

The mutation handlers correctly reset the isSaving state on both success and error cases, ensuring the UI returns to the correct state.


93-93: LGTM! Improved timing for scene update.

Increasing the delay from 10ms to 1000ms is a good improvement that allows more time for the API and drawing components to be properly initialized before updating the scene.


98-104: LGTM! Well-implemented auto-save functionality.

The auto-save interval is properly implemented with:

  • 5-second interval for reasonable auto-save frequency
  • Proper cleanup with clearInterval in the effect return
  • Correct dependency array including setSceneData

134-141: LGTM! Excellent user experience improvements.

The save button improvements provide great UX:

  • Disabled state during saving prevents multiple concurrent saves
  • Dynamic text ("Saving..." vs "Save") gives clear feedback
  • Proper integration with the isSaving state

147-150: LGTM! Consistent UI sizing.

The size standardization to "sm" and icon size adjustment create a more consistent interface.

@macintushar macintushar merged commit 095b71a into main May 27, 2025
5 checks passed
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