[FIX] 필드명 오류 수정 | 뉴스별 파급 경로 그래프가 잘못된 인덱스를 참조해 undefined.marketCap로 터지던 버그 수정 - #29
Conversation
GraphCanvas가 focus 모드(뉴스별 파급 경로)에서도 옛 데모 온톨로지 기반
전역 graphIndex(mocks/graph/data.ts, id가 'sk'/'ss' 같은 문자열)로 노드
메타데이터를 조회하고 있었다. buildFocusScene은 실제 impactGraph.nodes/
edges로 만든 자기만의 index를 이미 갖고 있었는데 그게 GraphCanvas까지
전달되지 않아서, 실 백엔드가 데모와 다른 id 체계를 내려주면 조회가
실패(undefined)하고 sizeOf(undefined)에서 marketCap을 읽다 크래시했다.
Scene2에 index 필드를 추가해 buildFocusScene/buildAllScene이 각자
자기 데이터에 맞는 인덱스(전자는 impactGraph 기반, 후자는
fullGraphIndex)를 함께 실어 보내도록 하고, GraphCanvas는 scene2.index를
쓰도록 변경 — 별도 index prop과 옛 graphIndex export(이제 완전히
미사용)는 제거.
데모 온톨로지와 무관한 임의의 id("TEST_A"/"TEST_B")로 응답을 흉내내서
수정 전엔 크래시, 수정 후엔 정상 렌더링(카드 크기까지 정확)되는 것을
직접 확인했다. 전체 관계망 렌더링/검색/하이라이트, 기존 뉴스 파급 경로
회귀도 재확인.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
📝 WalkthroughWalkthrough그래프 레이아웃의 모듈 전역 ChangesGraphIndex 전달 구조
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
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/components/graph/GraphPanel.tsx`:
- Around line 283-286: Update the cache handling around the scene2.index
assignment so changing the scene-specific index invalidates both prevNodesRef
and prevEdgesRef before cached objects can be reused. Track the previous index
identity and clear both caches whenever the index changes, preserving cache
reuse when the same index remains active.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 1a069fdd-0ed9-4154-a449-95a8385c32b5
📒 Files selected for processing (3)
src/components/graph/GraphPanel.tsxsrc/components/graph/NetworkView.tsxsrc/utils/graph/layout.ts
💤 Files with no reviewable changes (1)
- src/utils/graph/layout.ts
| // 씬마다 자기 데이터에 맞는 인덱스를 실어 보낸다(focus=뉴스별 impactGraph, | ||
| // all=graph.json) — 두 데이터셋의 id 체계가 다르므로 고정된 전역 인덱스를 | ||
| // 쓰면 다른 쪽 모드에서 노드를 못 찾아 undefined.marketCap 등으로 터진다. | ||
| const index = scene2.index |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
씬별 index 변경 시 노드·엣지 캐시를 무효화해야 합니다.
scene2.index를 새로 읽어도 prevNodesRef와 prevEdgesRef는 유지됩니다. 이후 id와 시각 상태가 같으면 이전 객체를 재사용하므로, 뉴스 전환 시 새 인덱스의 노드명·크기·위치 또는 엣지 polarity 색상이 반영되지 않을 수 있습니다. 캐시 항목에 index identity를 포함하거나, 인덱스가 바뀔 때 두 캐시를 초기화하세요.
🤖 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/components/graph/GraphPanel.tsx` around lines 283 - 286, Update the cache
handling around the scene2.index assignment so changing the scene-specific index
invalidates both prevNodesRef and prevEdgesRef before cached objects can be
reused. Track the previous index identity and clear both caches whenever the
index changes, preserving cache reuse when the same index remains active.
👥 작업 배경 및 목적
mocks/graph/data.ts) 기반 전역 인덱스로 노드 메타데이터를 조회하고 있었음. 실 백엔드가 데모와 다른 id 체계로 노드를 내려주면 조회에 실패해Cannot read properties of undefined (reading 'marketCap')로 크래시하는 버그를 수정.🛠️ 주요 변경 사항
src/components/graph/GraphPanel.tsx:Scene2에index: GraphIndex필드 추가.buildFocusScene은 실제impactGraph.nodes/edges로 만든 자기 인덱스를,buildAllScene은fullGraphIndex를 각각 씬에 실어 보내도록 수정.GraphCanvas는 별도indexprop 대신scene2.index를 사용src/components/graph/NetworkView.tsx:GraphCanvas에 더 이상 필요 없는indexprop 제거src/utils/graph/layout.ts: 이제 완전히 미사용이 된 옛 데모 전용graphIndexexport 및 관련 import 제거GraphPanel.tsx의Scene2인터페이스와buildFocusScene/buildAllScene이 각각 어떤 인덱스를 채워 넣는지,GraphCanvas가 prop 대신scene2.index를 쓰도록 바뀐 부분🧪 테스트 결과 (선택)
TEST_A/TEST_B, 티커 999901/999902)로 목 응답을 만들어 렌더링 — 수정 전 크래시 재현, 수정 후 카드 크기(capSize)까지 정확하게 정상 렌더링되는 것 확인tsc --noEmit,pnpm lint클린PRBODY)
👥 작업 배경 및 목적
mocks/graph/data.ts) 기반 전역 인덱스로 노드 메타데이터를 조회하고 있었음. 실 백엔드가 데모와 다른 id 체계로 노드를 내려주면 조회에 실패해Cannot read properties of undefined (reading 'marketCap')로 크래시하는 버그를 수정.🛠️ 주요 변경 사항
src/components/graph/GraphPanel.tsx:Scene2에index: GraphIndex필드 추가.buildFocusScene은 실제impactGraph.nodes/edges로 만든 자기 인덱스를,buildAllScene은fullGraphIndex를 각각 씬에 실어 보내도록 수정.GraphCanvas는 별도indexprop 대신scene2.index를 사용src/components/graph/NetworkView.tsx:GraphCanvas에 더 이상 필요 없는indexprop 제거src/utils/graph/layout.ts: 이제 완전히 미사용이 된 옛 데모 전용graphIndexexport 및 관련 import 제거GraphPanel.tsx의Scene2인터페이스와buildFocusScene/buildAllScene이 각각 어떤 인덱스를 채워 넣는지,GraphCanvas가 prop 대신scene2.index를 쓰도록 바뀐 부분🧪 테스트 결과 (선택)
TEST_A/TEST_B, 티커 999901/999902)로 목 응답을 만들어 렌더링 — 수정 전 크래시 재현, 수정 후 카드 크기(capSize)까지 정확하게 정상 렌더링되는 것 확인tsc --noEmit,pnpm lint클린Summary by CodeRabbit