Skip to content

CommonCardの列車種別カッコ縮小表示で全角カッコにも対応する - #5951

Merged
TinyKitten merged 2 commits into
devfrom
claude/fix-parens-fullwidth-common-card
May 11, 2026
Merged

TinyKitten merged 2 commits into
devfrom
claude/fix-parens-fullwidth-common-card

Conversation

@TinyKitten

@TinyKitten TinyKitten commented May 11, 2026 •

Copy link
Copy Markdown
Member

概要

CommonCard の列車種別タイトル分割ロジックで、半角カッコ () のみが縮小表示対象となっており、全角カッコ () を含むデータが来た場合にカッコ内も本文と同じフォントサイズで描画されてしまう潜在的な問題を修正しました。直前のPR #5950 で SelectBoundSettingListModal 側を同様に修正したため、表示処理を揃えるためのフォローアップです。

変更の種類

  • バグ修正
  • 新機能
  • リファクタリング
  • ドキュメント
  • CI/CD
  • その他

変更内容

  • src/components/CommonCard.tsx のカッコ分割正規表現 /(\([^)]*\))/ を /([((][^))]*[))])/ に変更し、全角・半角どちらのカッコでも縮小フォント側に振り分けられるようにした。
  • 縮小判定用テスト /^\(.*\)$/ も同じ文字クラスを使う /^[((][^))]*[))]$/ に変更。
  • shrinkBoundAffix の「カッコ内の方面を分離対象から除外する」ガード match[1].endsWith(')') に、全角閉じカッコ ) の判定も追加。これにより 急行(○○方面)方面 のような全角カッコを含む稀なケースでも「方面」が二重に分離されない。
  • 上記2つの正規表現をモジュールスコープの 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

  • バグ修正
    • タイトルの括弧処理を改善しました。半角・全角の両方の括弧を一貫して扱い、小括弧付き表記の表示スタイル(括弧非表示オプション含む)が正しく適用されます。
    • 「方面」などのサフィックス分割を不要な分割を避ける形で調整しました。

Review Change Stack

@TinyKitten TinyKitten self-assigned this May 11, 2026
@github-actions github-actions Bot added the react label May 11, 2026
@coderabbitai

coderabbitai Bot commented May 11, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b92c5816-d47f-44ec-aae2-ba64ca6402ec

📥 Commits

Reviewing files that changed from the base of the PR and between ebf8b14 and 4ab5dea.

📒 Files selected for processing (1)
  • src/components/CommonCard.tsx

📝 Walkthrough

Walkthrough

CommonCard のタイトル解析が、ASCII と全角の括弧を共通の正規表現で扱うように更新され、接尾辞抽出・トークン分割・レンダリング時の括弧検出が一貫します。

Changes

括弧タイプ統一処理

Layer / File(s) Summary
共有正規表現定義
src/components/CommonCard.tsx
ASCII と全角括弧を検出・グループ化する正規表現定数を導入しました。
日本語接尾辞抽出パターン
src/components/CommonCard.tsx
「方面」接尾辞抽出で、捕捉したベースが半角)または全角)で終わる場合は分割しないよう条件を調整しました。
タイトルトークン分割
src/components/CommonCard.tsx
タイトル分割を親括弧グループ正規表現に切り替え、(...) と (...) の両方で分割するようにしました。
レンダリング時の括弧検出
src/components/CommonCard.tsx
レンダリング時の「括弧で囲まれたトークン」判定を半角・全角両対応に拡張し、hideParens のスライス処理が一貫するようにしました。

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

ウサギが跳ねて、括弧をそろえ、
半角も全角もニコニコで、
タイトルがすっきり整い、
小さな括弧も堂々と並び、
今日もコードはふわりと舞う。

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed PRのタイトルは、変更の主要な目的(CommonCardのカッコ縮小表示で全角カッコに対応)を正確かつ簡潔に説明しており、実装内容と一致しています。
Description check ✅ Passed PR説明はテンプレートのすべての主要セクション(概要、変更の種類、変更内容、テスト)を完全に記入しており、詳細な技術情報と実施内容が適切に記載されています。
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 claude/fix-parens-fullwidth-common-card

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 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

📥 Commits

Reviewing files that changed from the base of the PR and between 18f1f53 and ebf8b14.

📒 Files selected for processing (1)
  • src/components/CommonCard.tsx

@TinyKitten
TinyKitten merged commit fe83fcf into dev May 11, 2026
5 checks passed
@TinyKitten
TinyKitten deleted the claude/fix-parens-fullwidth-common-card branch May 11, 2026 14:21
@TinyKitten TinyKitten mentioned this pull request May 11, 2026
4 of 9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants