Repository navigation
CommonCardの列車種別カッコ縮小表示で全角カッコにも対応する - #5951
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughCommonCard のタイトル解析が、ASCII と全角の括弧を共通の正規表現で扱うように更新され、接尾辞抽出・トークン分割・レンダリング時の括弧検出が一貫します。 Changes括弧タイプ統一処理
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/components/CommonCard.tsx (1)
360-360: ⚡ Quick win正規表現を共通化して将来の乖離を防いでください。
Line 360 と Line 473 で同義のパターンを重複定義しているため、片方だけ変更されるメンテナンス事故が起きやすいです。定数化して共有するのが安全です。
差分案
+const PAREN_GROUP_REGEX = /([((][^))]*[))])/; +const PAREN_WRAPPED_REGEX = /^[((][^))]*[))]$/; + const { titlePrefix, titleParts, titleSuffix } = useMemo(() => { let main = titleOrLineName; let prefix: string | null = null; let suffix: string | null = null; @@ return { titlePrefix: prefix, - titleParts: main.split(/([((][^))]*[))])/), + titleParts: main.split(PAREN_GROUP_REGEX), titleSuffix: suffix, }; }, [titleOrLineName, shrinkBoundAffix]); @@ - {titleParts.map((part, index) => - /^[((][^))]*[))]$/.test(part) ? ( + {titleParts.map((part, index) => + PAREN_WRAPPED_REGEX.test(part) ? ( <Typography key={`${index}-${part}`} style={styles.titleParens}>Also applies to: 473-473
🤖 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/CommonCard.tsx` at line 360, Extract the duplicated regex /([((][^))]*[))])/ into a single exported/const identifier (e.g. PARENTHESIS_SPLIT_REGEX) in the same module (src/components/CommonCard.tsx) and replace both occurrences (used in titleParts: main.split(...) at the titleParts computation and the duplicate use at line 473) with main.split(PARENTHESIS_SPLIT_REGEX) so both places reference the same constant and avoid future divergence.
🤖 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.
Nitpick comments:
In `@src/components/CommonCard.tsx`:
- Line 360: Extract the duplicated regex /([((][^))]*[))])/ into a single
exported/const identifier (e.g. PARENTHESIS_SPLIT_REGEX) in the same module
(src/components/CommonCard.tsx) and replace both occurrences (used in
titleParts: main.split(...) at the titleParts computation and the duplicate use
at line 473) with main.split(PARENTHESIS_SPLIT_REGEX) so both places reference
the same constant and avoid future divergence.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: f13664b6-4d14-477d-a01c-6e8c6ef1bedf
📒 Files selected for processing (1)
src/components/CommonCard.tsx
概要
CommonCardの列車種別タイトル分割ロジックで、半角カッコ()のみが縮小表示対象となっており、全角カッコ()を含むデータが来た場合にカッコ内も本文と同じフォントサイズで描画されてしまう潜在的な問題を修正しました。直前のPR #5950 でSelectBoundSettingListModal側を同様に修正したため、表示処理を揃えるためのフォローアップです。変更の種類
変更内容
src/components/CommonCard.tsxのカッコ分割正規表現/(\([^)]*\))/を/([((][^))]*[))])/に変更し、全角・半角どちらのカッコでも縮小フォント側に振り分けられるようにした。/^\(.*\)$/も同じ文字クラスを使う/^[((][^))]*[))]$/に変更。shrinkBoundAffixの「カッコ内の方面を分離対象から除外する」ガードmatch[1].endsWith(')')に、全角閉じカッコ)の判定も追加。これにより急行(○○方面)方面のような全角カッコを含む稀なケースでも「方面」が二重に分離されない。PAREN_GROUP_REGEX/PAREN_WRAPPED_REGEX定数に抽出し、split 側と test 側で乖離しないようにした(CodeRabbit のレビュー指摘対応)。列車種別名や路線名はGraphQL API経由で取得する動的データのため、コードベース内では実値を確認できません。CodeRabbit の予防的指摘に沿って、API側がどちらのカッコを使っていても安全な側に揃えています。
テスト
npm run lintが通ることnpm testが通ることnpm run typecheckが通ること関連Issue
スクリーンショット(任意)
Summary by CodeRabbit