Skip to content

⚡ Bolt: Optimize ERD column name resolution - #850

Open
seonghobae wants to merge 3 commits into
mainfrom
bolt-optimize-handle-resolution-4116336364886781330
Open

⚡ Bolt: Optimize ERD column name resolution#850
seonghobae wants to merge 3 commits into
mainfrom
bolt-optimize-handle-resolution-4116336364886781330

Conversation

@seonghobae

@seonghobae seonghobae commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

💡 What
Introduced an O(1) parseColumnNameFromHandle utility to directly parse and decode column names embedded in React Flow edge handle IDs (which are hex-encoded strings like c-0069-0064). Updated export.ts, dbml.ts, exportDataDictionary.ts, and mermaid.ts to decode edge handles locally in O(1) rather than performing O(E*C) lookups (where it iterates over all columns of a node just to map a handle back to a string).

🎯 Why
Graph exporters previously relied on iterative .find() lookups and sourceColumnHandleId/targetColumnHandleId encoding steps in loops across all edges and columns. This created O(E*C) bottlenecks. Direct decoding removes unnecessary iteration and allocations. In dbml.ts, the previous simple replace('src-', '') fallback leaked hex-encoded handles into DBML schemas. The new decoder correctly renders the original schema column strings.

📊 Impact
Reduces export lookup complexity from O(E * C) to O(E), improving performance when generating DBML, Mermaid, and Dictionary exports on large diagrams. Directly generating original table column names in DBML correctly avoids emitting unparsed c-... handles for explicitly drawn UI links.

🔬 Measurement
All vitest suites pass (frontend/src/erd/__tests__/dbml.test.ts, coverageEdges.test.ts, etc). Time complexity of column mapping inside fkColumnsForEdge is now static.


PR created automatically by Jules for task 4116336364886781330 started by @seonghobae

Summary by CodeRabbit

  • 개선 사항

    • ERD의 DBML 및 Mermaid 내보내기가 인코딩된 컬럼 핸들을 안정적으로 해석합니다.
    • 컬럼 정보가 일부 누락되거나 불완전한 경우에도 가능한 관계를 유지해 내보내기가 정상적으로 동작합니다.
    • 유효하지 않은 핸들은 자동으로 제외하고 기존 대체 처리 방식을 적용합니다.
  • 버그 수정

    • 특수문자, 유니코드, 빈 값 및 이전 형식의 핸들 처리 오류를 개선했습니다.
  • 테스트

    • 비동기 프로젝트·스냅샷 목록과 검색 결과가 완전히 표시된 후 검증하도록 테스트를 보강했습니다.

Exact-head remediation

Head 6ccaa690699ac0a336d6c51f6b38b3601897021c closes every current review finding: malformed hexadecimal handles now fail closed, DBML has canonical encoded-handle regression coverage, DDL column membership is pre-indexed for O(N*C + E), and unused imports are removed. Test-first evidence: malformed partial-hex cases failed before the parser boundary and passed after full-segment validation. Focused: 49 passed; full frontend: 27 files / 209 tests passed; typecheck and production build passed.

- Add `parseColumnNameFromHandle` for O(1) decoding
- Update exports (DBML, DDL, Dictionary, Mermaid) to avoid O(N) column matching loops
- Fix DBML decoding fallback logic
@google-labs-jules

Copy link
Copy Markdown

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@seonghobae, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 44 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: af9295c7-ddc9-4fb3-b775-ec17bcbdfd06

📥 Commits

Reviewing files that changed from the base of the PR and between 10b21ad and 6ccaa69.

📒 Files selected for processing (5)
  • CHANGELOG.md
  • frontend/src/erd/__tests__/dbml.test.ts
  • frontend/src/erd/export.ts
  • frontend/src/erd/handleUtils.test.ts
  • frontend/src/erd/handleUtils.ts
📝 Walkthrough

Walkthrough

엣지 핸들에서 원본 컬럼명을 파싱하는 함수를 추가했습니다. DBML, Mermaid, 데이터 사전 내보내기는 파싱된 컬럼명을 사용합니다. 관련 테스트는 비동기 렌더링 완료를 기다리도록 수정했습니다.

Changes

ERD 핸들 기반 컬럼 처리

Layer / File(s) Summary
핸들 파싱 계약 및 회귀 테스트
frontend/src/erd/handleUtils.ts, frontend/src/erd/handleUtils.test.ts
parseColumnNameFromHandle이 인코딩된 핸들, 접두사, 레거시 값, 빈 값, 잘못된 입력을 처리합니다. 각 동작을 테스트에 추가했습니다.
ERD 내보내기 경로 적용
frontend/src/erd/dbml.ts, frontend/src/erd/export.ts, frontend/src/erd/exportDataDictionary.ts, frontend/src/erd/mermaid.ts, .jules/bolt.md
DBML, Mermaid, 데이터 사전 내보내기가 파싱된 컬럼명을 사용합니다. 실제 노드 컬럼 검증과 외래 키 컬럼 추적을 컬럼명 기준으로 변경했습니다.
비동기 렌더링 테스트 보강
frontend/src/App.coverage.test.tsx
검색 결과와 다이어그램 목록의 렌더링이 완료된 후 검증하도록 waitFor 처리를 추가했습니다.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed ERD 컬럼명 해석 최적화라는 주요 변경 사항을 간결하고 명확하게 설명합니다.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch bolt-optimize-handle-resolution-4116336364886781330

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.

Comment thread frontend/src/erd/export.ts Fixed

@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: 3

🤖 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 `@frontend/src/erd/dbml.ts`:
- Around line 93-99: In the relationship tests for the DBML generator, add a
focused case using encoded handles src-c-0075-0073-0065-0072-005f-0069-0064 and
tgt-c-0069-0064, and assert the generated output is Ref: posts.user_id >
users.id. Keep the existing legacy-handle coverage unchanged so this test
specifically verifies encoded handles are decoded into DBML column names.

In `@frontend/src/erd/export.ts`:
- Around line 70-78: Update exportDDL and fkColumnsForEdge so each node’s
column_name values are collected into Map/Set structures once at export start,
then replace the per-edge source/target .some membership checks with O(1)
lookups while preserving null handling for missing columns.

In `@frontend/src/erd/handleUtils.ts`:
- Around line 41-43: Validate every segment in the handle decoder before calling
parseInt or String.fromCodePoint, rejecting any segment that is not a complete
hexadecimal string and returning null. In frontend/src/erd/handleUtils.ts lines
41-43, update the decoding logic accordingly; in
frontend/src/erd/handleUtils.test.ts lines 39-72, add focused regression cases
confirming malformed handles such as partial or invalid hex segments return null
rather than a column name.
🪄 Autofix

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: 4d547b85-1d00-4469-93a3-8ef606c76aa5

📥 Commits

Reviewing files that changed from the base of the PR and between 72afe6d and 10b21ad.

📒 Files selected for processing (8)
  • .jules/bolt.md
  • frontend/src/App.coverage.test.tsx
  • frontend/src/erd/dbml.ts
  • frontend/src/erd/export.ts
  • frontend/src/erd/exportDataDictionary.ts
  • frontend/src/erd/handleUtils.test.ts
  • frontend/src/erd/handleUtils.ts
  • frontend/src/erd/mermaid.ts

Comment thread frontend/src/erd/dbml.ts
Comment thread frontend/src/erd/export.ts
Comment thread frontend/src/erd/handleUtils.ts Outdated
seonghobae and others added 2 commits August 10, 2026 15:15
- Add `parseColumnNameFromHandle` for O(1) decoding
- Update exports (DBML, DDL, Dictionary, Mermaid) to avoid O(N) column matching loops
- Fix DBML decoding fallback logic

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

Please review exact head 6ccaa690699ac0a336d6c51f6b38b3601897021c. All prior actionable threads are addressed. Evidence: focused 49 passed; full frontend 27 files / 209 tests passed; typecheck and production build passed.

@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown

@seonghobae I will review pull request #850 at commit 6ccaa690699ac0a336d6c51f6b38b3601897021c. I will use the supplied verification results as context.

⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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