Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions apps/executeJS/src/features/execute-code/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,21 @@ export const useExecutionStore = create<ExecutionState>()(
partialize: (state) => ({
result: state.result,
}),
onRehydrateStorage: () => (state, error) => {
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.

return;
}

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.
// 앱 재시작 시 실행 중이었던 상태를 초기화
state.setExecuting(false);
}
},
}
)
);
26 changes: 25 additions & 1 deletion apps/executeJS/src/pages/playground/playground-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,32 @@ import { OutputPanel } from '@/widgets/output-panel';
import { useExecutionStore } from '@/features/execute-code';
import { PlayIcon, StopIcon } from '@radix-ui/react-icons';

const getInitialCode = (): string => {
try {
const executionStorage = localStorage.getItem(
'executejs-execution-storage'
Comment on lines +8 to +11
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 (executionStorage) {
const parsed = JSON.parse(executionStorage);
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.

return code;
}
}
} catch (error) {
console.error('error from executionStorage:', error);
}

return 'console.log("Hello, ExecuteJS!");';
};

export const PlaygroundPage: React.FC = () => {
const [code, setCode] = useState('console.log("Hello, ExecuteJS!");');
// FIXME: tab이 여러개 생기거나 global store로 상태가 이동되면 수정되어야함
const [code, setCode] = useState(getInitialCode);
const {
result: executionResult,
isExecuting,
Expand Down