Skip to content

Conversation

@ohah
Copy link
Owner

@ohah ohah commented Oct 30, 2025

ㅁㄴㅇㄹ

Copilot AI review requested due to automatic review settings October 30, 2025 12:28
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements code persistence functionality by restoring the last executed code from localStorage when the playground page is loaded. It also adds hydration error handling for the Zustand store.

  • Added getInitialCode() function to retrieve previously executed code from localStorage
  • Implemented onRehydrateStorage callback to handle hydration errors and reset execution state on app restart
  • Updated initial state of code editor to use persisted code instead of default "Hello, ExecuteJS!" message

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
apps/executeJS/src/pages/playground/playground-page.tsx Added getInitialCode() function to restore code from localStorage and updated useState initialization to use it
apps/executeJS/src/features/execute-code/model.ts Added onRehydrateStorage callback to handle hydration errors and reset execution state on app restart

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +8 to +11
const getInitialCode = (): string => {
try {
const executionStorage = localStorage.getItem(
'executejs-execution-storage'
Copy link

Copilot AI Oct 30, 2025

Choose a reason for hiding this comment

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

The storage key 'executejs-execution-storage' is duplicated between this file and model.ts. Consider extracting it to a shared constant to maintain consistency and avoid potential mismatches.

Suggested change
const getInitialCode = (): string => {
try {
const executionStorage = localStorage.getItem(
'executejs-execution-storage'
const EXECUTION_STORAGE_KEY = 'executejs-execution-storage';
const getInitialCode = (): string => {
try {
const executionStorage = localStorage.getItem(
EXECUTION_STORAGE_KEY

Copilot uses AI. Check for mistakes.
if (error) {
console.error('hydration failed:', error);
// persist 실패 시 localStorage 정리
localStorage.removeItem('executejs-execution-storage');
Copy link

Copilot AI Oct 30, 2025

Choose a reason for hiding this comment

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

The storage key 'executejs-execution-storage' is hardcoded here but already defined at line 65. Reference the existing 'name' property from the persist configuration or extract to a constant to avoid duplication.

Copilot uses AI. Check for mistakes.
const code = parsed?.state?.result?.code;

if (code) {
console.log('result from executionStorage:', code);
Copy link

Copilot AI Oct 30, 2025

Choose a reason for hiding this comment

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

Console.log statements should be removed from production code or replaced with a proper logging mechanism. Consider removing this debug log or using a conditional logger.

Suggested change
console.log('result from executionStorage:', code);

Copilot uses AI. Check for mistakes.
}

if (state) {
console.log('hydration success');
Copy link

Copilot AI Oct 30, 2025

Choose a reason for hiding this comment

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

Console.log statements should be removed from production code or replaced with a proper logging mechanism. Consider removing this debug log or using a conditional logger.

Suggested change
console.log('hydration success');

Copilot uses AI. Check for mistakes.
@ohah ohah closed this Oct 30, 2025
@ohah ohah reopened this Oct 30, 2025
@ohah ohah closed this Oct 30, 2025
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.

3 participants