Repository navigation
refactor: 하이라이트 타입을 HighlightStyle enum으로 전환 - #104
Conversation
stringly-typed highlightType("yellow"/"underline" 등)을 HighlightStyle enum으로
대체해 JS·VM·Repo 3중 중복과 오타 위험 제거. 영속화(DatabaseKit)는 String을
유지하고 Repository 경계에서 rawValue로만 변환. JS 브릿지 문자열 계약을
검증하는 HighlightStyleTests 추가.
There was a problem hiding this comment.
Code Review
This pull request replaces raw String types for highlight styles with a structured HighlightStyle enum across the detail feature module, updating repositories, models, view models, and views accordingly, and adds corresponding unit tests. The review feedback points out that the String to HighlightStyle conversion is currently being handled in ArticleDetailView rather than being encapsulated within the WebView seam (ArticleWebView) as intended, and suggests refactoring the web view's callback signatures to accept HighlightStyle directly.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| onSaveHighlight: { color in viewModel.saveHighlight(style: HighlightStyle(rawValue: color) ?? .yellow) }, | ||
| onHighlightTypeChanged: { text, newType in viewModel.changeHighlightStyle(text: text, to: HighlightStyle(rawValue: newType) ?? .yellow) }, |
There was a problem hiding this comment.
PR 설명에 'JS 콜백 String→enum 변환은 WebView seam에서만 수행'이라고 명시되어 있으나, 현재 ArticleDetailView에서 HighlightStyle(rawValue:)를 통해 직접 변환을 수행하고 있습니다.\n\nArticleWebView가 이미 DetailDomain을 임포트하고 있으므로, ArticleWebView 내부의 콜백 클로저 타입을 String 대신 HighlightStyle로 변경하는 것이 좋습니다.\n\n추가 가이드:\n이 제안을 적용하려면 ArticleWebView.swift 파일에서 onSaveHighlight와 onHighlightTypeChanged 클로저의 타입을 String 대신 HighlightStyle을 받도록 변경해야 합니다.\n\nswift\n// ArticleWebView.swift\nvar onSaveHighlight: ((HighlightStyle) -> Void)?\nvar onHighlightTypeChanged: ((String, HighlightStyle) -> Void)?\n\n\n그리고 ArticleWebView.Coordinator에서 JS 메시지를 수신하여 처리할 때 HighlightStyle(rawValue:) 변환을 수행하도록 수정하면, 뷰 레이어(ArticleDetailView)에 문자열 타입이 노출되지 않고 설계 의도대로 WebView seam 내부에서만 변환이 완결됩니다.
| onSaveHighlight: { color in viewModel.saveHighlight(style: HighlightStyle(rawValue: color) ?? .yellow) }, | |
| onHighlightTypeChanged: { text, newType in viewModel.changeHighlightStyle(text: text, to: HighlightStyle(rawValue: newType) ?? .yellow) }, | |
| onSaveHighlight: { style in viewModel.saveHighlight(style: style) }, | |
| onHighlightTypeChanged: { text, style in viewModel.changeHighlightStyle(text: text, to: style) }, |
배경
Article Highlight 영역의 색/밑줄 타입이 stringly-typed(
"yellow"/"underline"등)로 JS·ViewModel·Repository 3중 중복돼 오타에 취약했음. Article Highlight 리팩토링 설계의 0단계(가장 저위험).변경
HighlightStyleenum 신설 (DetailDomain,StringrawValue)DetailHighlight.highlightType: String→style: HighlightStyleaddHighlight(type:)→(style:),changeHighlightType→changeHighlightStyleDatabaseKit)는String유지 — 변환은 Repository 경계에서rawValue/init?(rawValue:)로만HighlightListViewswitch를 enum exhaustive로 (default 제거)테스트
HighlightStyleTests: JS 브릿지 문자열 계약(rawValue), rawValue 라운드트립, unknown→nilDetailTests/Mock/Sample 갱신검증
Detail스킴 빌드 통과 (BUILD SUCCEEDED)비고
Detail모듈 분리(Brand/Reader)는 별도 후속 과제로 식별됨