Skip to content

#123 fix: 코드 에디터 버그 해결#124

Merged
suminb99 merged 1 commit into
developfrom
feat/123-fix-code-editor-bug
May 14, 2026
Merged

#123 fix: 코드 에디터 버그 해결#124
suminb99 merged 1 commit into
developfrom
feat/123-fix-code-editor-bug

Conversation

@suminb99

Copy link
Copy Markdown
Contributor

⚙️ Related ISSUE Number

Related #123



📄 Work Description

문제 변경 시 currentCodeId 초기화



📷 Screenshot



💬 To Reviewers



🔗 Reference

@suminb99 suminb99 self-assigned this May 14, 2026
@suminb99 suminb99 linked an issue May 14, 2026 that may be closed by this pull request
6 tasks
@vercel

vercel Bot commented May 14, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
snow-code-client Ready Ready Preview, Comment May 14, 2026 4:43am

@coderabbitai

coderabbitai Bot commented May 14, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Summary by CodeRabbit

릴리스 노트

  • Bug Fixes
    • 과제 제출 페이지에서 다른 과제로 전환할 때 에디터 상태가 올바르게 업데이트되도록 개선

개요

AssignmentSubmitPage에서 useEffect 훅을 추가하여 할당(assignment)이 변경될 때마다 현재 코드 ID를 초기값으로 리셋합니다. 이는 다른 할당으로 전환할 때 편집기 상태의 불일치를 해결합니다.

변경사항

할당 변경 시 편집기 상태 동기화

레이어 / 파일 요약
할당 변경 감시 효과
src/pages/submit-assignment/AssignmentSubmitPage.tsx
useEffect 훅을 import에 추가하고, assignmentId가 변경될 때 currentCodeIdinitialCodeId로 업데이트하는 의존성 효과를 구현합니다. 이는 할당 간 네비게이션 시 편집기 상태의 stale 문제를 해결합니다.

예상 코드 리뷰 난이도

🎯 1 (Trivial) | ⏱️ ~3분

연관 이슈

추천 레이블

🛠️ refactor

추천 리뷰어

  • JiiminHa
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed PR 제목이 실제 변경사항인 currentCodeId 초기화와 관련이 있으며, 코드 에디터 버그 수정이라는 주요 목적을 명확히 전달합니다.
Description check ✅ Passed PR 설명에서 '문제 변경 시 currentCodeId 초기화'라고 명시하여 변경사항과 관련된 내용을 포함하고 있습니다.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/123-fix-code-editor-bug

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/pages/submit-assignment/AssignmentSubmitPage.tsx`:
- Around line 35-37: The effect in AssignmentSubmitPage (useEffect that calls
setCurrentCodeId(initialCodeId)) is missing initialCodeId in its dependency
array so changes to initialCodeId (from location.state) won't update
currentCodeId; update the dependency array to include initialCodeId (in addition
to assignmentId) so the effect re-runs when either assignmentId or initialCodeId
changes, ensuring setCurrentCodeId(initialCodeId) stays synchronized with the
incoming state.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 4a5de0d6-b9b0-415f-b3fe-7730d1a5ac9b

📥 Commits

Reviewing files that changed from the base of the PR and between 66f491c and dd04ec8.

📒 Files selected for processing (1)
  • src/pages/submit-assignment/AssignmentSubmitPage.tsx

Comment on lines +35 to +37
useEffect(() => {
setCurrentCodeId(initialCodeId);
}, [assignmentId]);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

cat -n src/pages/submit-assignment/AssignmentSubmitPage.tsx | head -60

Repository: 2025-snowCode/snowCode-Client

Length of output: 2842


useEffect 의존성 누락으로 initialCodeId 변경이 반영되지 않을 수 있어요.

initialCodeIdlocation.state에서 추출되어 렌더링마다 새로 평가되는데, effect 내부에서 사용 중인 initialCodeId가 의존성 배열에 없습니다. 같은 assignmentId에서 다른 codeId를 가진 state로 이동할 때 currentCodeId가 동기화되지 않을 수 있습니다.

✅ 제안 수정
  useEffect(() => {
    setCurrentCodeId(initialCodeId);
- }, [assignmentId]);
+ }, [assignmentId, initialCodeId]);

React 공식 문서의 useEffect 의존성 배열 가이드에서 "effect가 사용하는 모든 반응형 값(props, state, 파생 값)을 의존성에 포함"해야 한다는 규칙을 참고해 주세요.

🧰 Tools
🪛 GitHub Check: build-and-deploy

[warning] 37-37:
React Hook useEffect has a missing dependency: 'initialCodeId'. Either include it or remove the dependency array

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/pages/submit-assignment/AssignmentSubmitPage.tsx` around lines 35 - 37,
The effect in AssignmentSubmitPage (useEffect that calls
setCurrentCodeId(initialCodeId)) is missing initialCodeId in its dependency
array so changes to initialCodeId (from location.state) won't update
currentCodeId; update the dependency array to include initialCodeId (in addition
to assignmentId) so the effect re-runs when either assignmentId or initialCodeId
changes, ensuring setCurrentCodeId(initialCodeId) stays synchronized with the
incoming state.

@suminb99 suminb99 merged commit 4b29593 into develop May 14, 2026
4 checks passed
@suminb99 suminb99 mentioned this pull request May 14, 2026
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.

fix: 코드에디터 버그 해결

1 participant