Skip to content

実装: fix(#693): STATUS Hull 表示の水平 overflow を防止する #693

Closed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "none"
goal_ref: "STATUS パネルの Hull 表示が大きな HP 値で枠外にはみ出さず、最大化・半画面のいずれの viewport でも読める状態にする"
change_kind: mixed

Parent Issue

なし(単独改善)

Parent Goal Ref

  • Goal: STATUS パネルの Hull 表示桁溢れを修正する
  • Desired Destination: current/max 形式の Hull 数値が長くなっても .stat-grid dd の枠外に水平 overflow しない

Current Validated Scope

  • src/style.css の .stat-grid dd に overflow 保護を追加(overflow-wrap: break-word または word-break: break-all)
  • src/ui/HudController.ts の Hull 表示値(${state.player.hp}/${state.player.maxHp})に大きな値でも枠内に収まるコンパクト表記またはフォーマット処理を追加

Remaining Parent Gaps

なし(本 Issue で完結)

Outcome

src/style.css に overflow 保護が追加され、かつ HudController.ts の Hull 表示が大きな HP 値でも .stat-grid のセル枠内に収まり、pnpm typecheck && pnpm lint && pnpm test && pnpm build が通っている状態。

Background

2026-06-02 の人間プレイテスト(Observed in: #570 / #543)で、STATUS パネルの HULL フィールドが大きな数値になると枠外にはみ出すことを確認した。

PR #691(Issue #581)は Canvas 上の敵 HP ラベルを対象としており、DOM 側の STATUS > HULL 表示は対象外だったため本 Issue として別途対応する。

現在の実装:

  • HudController.ts:71: hp.textContent = \${state.player.hp}/${state.player.maxHp}`` — フォーマットなしで生値をそのまま表示
  • src/style.css の .stat-grid dd(174-180 行): font-size: 1.35rem; font-weight: 600 のみで overflow 制御なし

In Scope

  • src/style.css の .stat-grid dd に overflow-wrap: anywhere + word-break: normal + min-width: 0 による overflow 保護を追加
  • src/ui/HudController.ts の Hull 表示値フォーマット(CSS のみで解決できる場合は変更不要。formatter を追加する場合は src/utils/ または src/shared/ に配置する)
  • viewport 1280x720、980x720、800x720、375x667 での DOM overflow 検証(e2e または unit test)
  • pnpm typecheck / lint / test / build の通過確認

Out of Scope

Runtime Verification Applicability

decision: immediate
reason: "viewport 依存の layout bug のため、DOM の scrollWidth <= clientWidth を複数 viewport で検証する必要がある。Playwright または DOM テストを使い 99999/99999 と 999999999/999999999 を注入し、各 viewport で水平 overflow がないことを確認する。"

Acceptance Criteria

  • AC1: src/style.css の .stat-grid dd ブロックに overflow-wrap: anywhere と word-break: normal による overflow 保護が追加されている。word-break: break-all を使う場合は PR 本文に overflow-wrap: anywhere では不足する理由を明記すること。
  • AC2a: STATUS > HULL が 99999/99999 および 999999999/999999999 で水平 overflow しない。
  • AC2b: viewport 1280x720、980x720、800x720、375x667 で .stat-grid dd の scrollWidth <= clientWidth を満たす。
  • AC2c: .stat-grid の親 right rail / app shell を横方向に押し広げない。
  • AC3: UI から src/render/** を import しない。数値省略を導入する場合、formatter は src/utils/ または src/shared/ に移して Canvas/UI 双方から共有する。省略表示でも正確な current/max を title または aria-label で保持する。
  • AC4: pnpm typecheck && pnpm lint && pnpm test && pnpm build が通る。

Verification Commands

# AC1
$ rg -n "overflow-wrap|word-break" src/style.css

# AC2a / AC2b / AC2c (immediate runtime verification)
# exit 77 = SKIP (test not yet written), exit 1 = FAIL
# preflight-scope: runtime_only
$ pnpm test -- --grep "hud.*overflow|hull.*overflow|stat-grid.*scrollWidth" || exit 1

# AC3
$ rg -n "from.*render" src/ui/HudController.ts

# AC4
$ pnpm typecheck
$ pnpm lint
$ pnpm test
$ pnpm build

Allowed Paths

  • src/style.css(.stat-grid dd に overflow 保護を追加)
  • src/ui/HudController.ts(必要に応じて Hull 表示値のフォーマットを追加)
  • tests/e2e/**(viewport overflow 検証 e2e テストの追加)
  • src/utils/**(formatter を共有化する場合のみ)
  • src/shared/**(formatter を共有化する場合のみ)

Stop Conditions

  • Allowed Paths 外の変更が必要と判明した場合
  • In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
  • 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
  • 後続 Phase / 別スコープへの波及が判明した場合
  • nested SubAgent delegation が必要になった場合
  • 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合

Required Skills

  • CSS(overflow / word-break / grid layout)
  • TypeScript / DOM API

Scope Delta(任意)

N/A

Activity

  1. squne121 commented on Jun 6, 2026

    @squne121
    OwnerAuthor

    判定: REQUEST_CHANGES

    #693 は 「敵頭上HP」ではなく DOM の STATUS > HULL 表示崩れを直す Issue としては妥当です。#581/#691 は Canvas 側の敵HPラベル、#693 は .stat-grid dd と HudController のプレイヤー Hull 表示なので、分離は正しいです。現行 HudController.ts は hp/maxHp をそのまま textContent に流し込み、現行 CSS の .stat-grid dd には折返し・最小幅・桁溢れ対策がありません。([GitHub]1)

    ただし、Issue の品質ゲートが弱すぎます。このまま実装すると「CSSを少し触ってレビューで見た目OK」に逃げられます。


    致命的な指摘

    1. Runtime Verification: not_applicable は不適切

    これはレイアウト崩れです。つまり 実行時・viewport依存の不具合 です。PRレビュー目視だけでは再発防止になりません。#693 自身も「最大化・半画面表示で溢れないこと」を要求しているため、少なくとも Playwright か DOM レベルで scrollWidth <= clientWidth を検証すべきです。#691 では headless Playwright、viewport、DPR、白ピクセル検査まで証跡化しており、#693 だけ実行時検証なしにする理由が弱いです。([GitHub]1)

    修正案:

    • AC2 を pr_review_only から外す。

    • viewport matrix を必須化する。

      • 例: 1280x720, 980x720, 800x720, 375x667
    • .stat-grid dd と親要素について以下を検証する。

      • dd.scrollWidth <= dd.clientWidth
      • 親 .stat-grid div が右 rail を押し広げない
      • 99999/99999 と 999999999/999999999 の両方で崩れない

    2. CSS指定が雑すぎる: word-break: break-all を同格候補にしてはいけない

    Issue本文は overflow-wrap: break-word や word-break: break-all を例示していますが、これは危険です。word-break はテキストを過剰に分断しやすく、数値表示の可読性を壊します。MDN 上でも overflow-wrap:anywhere は「通常は折れない文字列を必要時に任意位置で折る」用途で、かつ min-content サイズ計算にも効きます。一方 word-break は overflow 時の改行挿入をより強く制御するため、最終手段寄りです。([MDN Web Docs]2)

    推奨 CSS 方針:

    .stat-grid div,
    .stat-grid dd {
      min-width: 0;
      max-width: 100%;
    }
    
    .stat-grid dd {
      overflow-wrap: anywhere;
      word-break: normal;
      line-height: 1.15;
    }

    word-break: break-all は採用するなら「なぜ anywhere では不足か」をPR本文に明記させるべきです。


    3. 数値フォーマットの SSOT が壊れる危険がある

    #581/#691 では formatCombatNumber と敵HPラベル描画が src/render/renderUtils.ts に入り、10000 -> 10k, 999999 -> 999k, 1000000 -> 1M のようなポリシーがテストされています。([GitHub]3)

    一方 #693 は UI 側から src/render/renderUtils.ts を直接 import することを out-of-scope としています。これは妥当です。ADR上も render は Canvas、ui は DOM と分離される構造です。([GitHub]1)

    問題は、#693 がこの状態で HudController.ts に別の独自フォーマッタを作ると、Canvas敵HPとDOM Hullで数値省略ルールが二重化 することです。

    選択肢は2つに絞るべきです。

    • 最小修正: 今回は CSS の折返しだけで直す。Hull は 99999/99999 のまま exact 表示。TSフォーマットは触らない。
    • 高品質修正: formatCombatNumber を src/utils/ または src/shared/ に移し、Canvas と UI の双方から使う。Issue 実装: fix(#693): STATUS Hull 表示の水平 overflow を防止する #693 の allowed paths を src/utils/** と tests まで拡張する。

    敵対的に見ると、現行 Issue のままでは「独自 formatter 追加」か「CSSだけで視覚確認なし」のどちらにも逃げられます。


    4. allowed paths に tests がない

    #693 の allowed paths は src/style.css と src/ui/HudController.ts のみです。これでは regression test を追加できません。([GitHub]1)

    レイアウト崩れ修正なら、少なくとも以下を許可すべきです。

    tests/e2e/**
    tests/**/*.test.ts
    src/utils/**
    src/shared/**
    

    特に formatter を共有化する場合、テストなしは不可です。


    5. fix(#570) はトレースが悪い

    #693 のタイトルは fix(#570) 系ですが、#570 は #543 を閉じた human playtest evidence PR であり、STATUS Hull overflow の修正Issueそのものではありません。#543/#570 は観測元として重要ですが、修正対象は #693 です。([GitHub]4)

    推奨:

    実装: fix(#693): STATUS Hull 表示の水平 overflow を防止する
    

    本文で以下を参照に回すのがよいです。

    Observed in: #570 / #543 human playtest evidence
    Related but separate: #581 / #691 enemy overhead HP label
    

    Issue #693 の修正文案

    ## Acceptance Criteria
    
    - [ ] STATUS > HULL が `99999/99999` および `999999999/999999999` で水平 overflow しない。
    - [ ] viewport `1280x720`, `980x720`, `800x720`, `375x667` で `.stat-grid dd.scrollWidth <= .stat-grid dd.clientWidth` を満たす。
    - [ ] `.stat-grid` の親 right rail / app shell を横方向に押し広げない。
    - [ ] `word-break: break-all` を使わない。使う場合は `overflow-wrap:anywhere` では不足する理由を PR に明記する。
    - [ ] UI から `src/render/**` を import しない。
    - [ ] 数値省略を導入する場合、formatter は `src/utils` または `src/shared` に移して Canvas/UI 双方で共有する。
    - [ ] 省略表示する場合でも、正確な `current/max` は `title` または `aria-label` で保持する。
    - [ ] `pnpm typecheck && pnpm lint && pnpm test && pnpm build` が通る。

    実装方針

    推奨は「まず CSS 最小修正」

    #693 の本質は DOM の桁溢れです。現時点では formatter 共有化まで入れると #581/#691 の領域に踏み込み、変更範囲が広がります。

    まずはこれでよいです。

    .stat-grid div,
    .stat-grid dd {
      min-width: 0;
      max-width: 100%;
    }
    
    .stat-grid dd {
      overflow-wrap: anywhere;
      word-break: normal;
      line-height: 1.15;
    }

    そのうえで 99999/99999 と異常に長い値を Playwright で流し込んで、DOM overflow が出ないことを検証するべきです。


    GitHub に投げるコメント案

    ## Verdict: REQUEST_CHANGES
    
    #693 は STATUS > HULL の DOM 表示崩れを扱う Issue としては妥当ですが、現状の契約では品質ゲートが弱すぎます。
    
    主な問題:
    
    1. `Runtime Verification: not_applicable` は不適切です。
       これは viewport 依存の layout bug なので、PRレビュー目視だけでは再発を防げません。
       `99999/99999` とより長い値を使い、複数 viewport で `scrollWidth <= clientWidth` を確認する AC が必要です。
    
    2. `word-break: break-all` を `overflow-wrap` と同格候補にしないでください。
       数値表示を過剰に分断して可読性を落とします。
       基本方針は `overflow-wrap: anywhere` + `word-break: normal` + `min-width: 0` が妥当です。
    
    3. `HudController` に独自 formatter を作ると、#581/#691 の `formatCombatNumber` と数値表示ポリシーが二重化します。
       今回は CSS のみで exact value を維持するか、formatter を `src/utils` / `src/shared` に移して Canvas/UI 双方から使うかの二択にしてください。
    
    4. allowed paths に tests がないため、regression test を追加できません。
       `tests/e2e/**` または該当 unit test path を許可してください。
    
    5. タイトルの `fix(#570)` は追跡上よくありません。
       #570/#543 は観測元であり、修正対象は #693 です。
       `fix(#693)` に変更し、#570/#543 は observed-in として参照するのがよいです。
    
    このまま実装すると「CSSを少し触ってレビューで見た目OK」に逃げられるため、Issue契約を修正してから着手するべきです。
  2. changed the title [-]実装: fix(#570): STATUS Hull 表示の桁溢れを修正する[/-] [+]実装: fix(#693): STATUS Hull 表示の水平 overflow を防止する[/+] on Jun 6, 2026
  3. squne121 commented on Jun 6, 2026

    @squne121
    OwnerAuthor

    Refinement Loop: Approved

    The issue has been approved and is ready for implementation.

  4. squne121 commented on Jun 6, 2026

    @squne121
    OwnerAuthor

    Contract Review: BLOCKED (2026-06-06T07:22:00Z)

    不足項目

    VC preflight: blocked (compound_command_disallowed)

    AC コマンド category decision
    AC2a/AC2b/AC2c pnpm test -- --grep "hud.*overflow|hull.*overflow|stat-grid.*scrollWidth" || exit 1 compound_command_disallowed blocked

    AC2a/AC2b/AC2c の VC コマンドに \|\| が含まれており、baseline_vc_preflight.py の compound_command_disallowed 制約に抵触します。

    分類: simple_contract_hygiene_fix

    このブロックは # preflight-scope: runtime_only マーカーの付与 で解消できます(VC 意味論変更なし、scope class の明示のみ)。

    該当コマンドは <!-- runtime-verification: true --> の AC2a/AC2b/AC2c に対応するランタイム検証であり、scope_class: runtime_only として分類することが適切です。

    推奨アクション

    Issue body の VC セクションの $ pnpm test -- --grep ... 直前行に以下を追加:

    # preflight-scope: runtime_only
    

    修正後に issue-contract-review 693 を再実行してください。


    generated_by: issue-contract-review

  5. squne121 commented on Jun 6, 2026

    @squne121
    OwnerAuthor

    Contract Snapshot (2026-06-06T07:25:40Z)

    • Outcome: src/style.css に overflow 保護が追加され、HudController.ts の Hull 表示が大きな HP 値でも .stat-grid のセル枠内に収まり、pnpm typecheck && pnpm lint && pnpm test && pnpm build が通っている状態。
    • Acceptance Criteria:
      • AC1: .stat-grid dd に overflow-wrap: anywhere + word-break: normal による overflow 保護追加
      • AC2a: 99999/99999 / 999999999/999999999 で水平 overflow しない(runtime-verification)
      • AC2b: viewport 1280x720/980x720/800x720/375x667 で scrollWidth <= clientWidth(runtime-verification)
      • AC2c: 親 right rail / app shell を横方向に押し広げない(runtime-verification)
      • AC3: UI から src/render/** を import しない
      • AC4: pnpm typecheck && pnpm lint && pnpm test && pnpm build が通る
    • Verification Commands:
      • AC1: rg -n "overflow-wrap|word-break" src/style.css(baseline fail → 実装後 pass)
      • AC2a/AC2b/AC2c: pnpm test -- --grep "hud.*overflow|hull.*overflow|stat-grid.*scrollWidth" (runtime_only, post-implementation)
      • AC3: rg -n "from.*render" src/ui/HudController.ts(baseline fail → 実装後 pass)
      • AC4: pnpm typecheck, pnpm lint, pnpm test, pnpm build(regression gate, 現在 pass)
    • Allowed Paths:
      • src/style.css
      • src/ui/HudController.ts
      • tests/e2e/**
      • src/utils/**(formatter 共有化の場合のみ)
      • src/shared/**(formatter 共有化の場合のみ)
    • Worktree: .claude/worktrees/issue-693-status-hull-overflow
    • Branch: worktree-issue-693-status-hull-overflow
    • VC preflight: baseline fail = 2, 想定外 pass = 0, 実行不可 = 0, regression gate = 4, runtime_only = 1(skipped)

    CONTRACT_REVIEW_RESULT_V1:
      status: go
      generated_at: 2026-06-06T07:25:40Z
      generated_by: issue-contract-review
      issue_url: https://github.com/squne121/loop-protocol/issues/693
      body_sha256: sha256:ac2c53e17e18b6b2dfc5a4aaa546987f9963aa91859ca9807d9fd58ada574e6f
      checks:
        template_compliance: pass
        state_label: ok
        allowed_paths_present: pass
        vc_present: pass
        stop_conditions_complete: pass
        vc_preflight:
          passed: true
          vc_failed_as_expected: 2
          vc_passed_unexpectedly: 0
          vc_unrunnable: 0
          vc_expected_pass: 4
          vc_skipped: 1
          classifications:
            - ac: AC1
              command: "rg -n \"overflow-wrap|word-break\" src/style.css"
              exit_code: 1
              category: expected_baseline_fail
              scope_class: baseline_fail_expected
              confidence: high
              evidence:
                stdout_excerpt: ""
                stderr_excerpt: ""
              decision: go
            - ac: AC2a/AC2b/AC2c
              command: "pnpm test -- --grep \"hud.*overflow|hull.*overflow|stat-grid.*scrollWidth\" || exit 1"
              exit_code: null
              category: preflight_scope_runtime_only
              scope_class: runtime_only
              confidence: high
              evidence:
                stdout_excerpt: ""
                stderr_excerpt: ""
              decision: go
              verification_owner: impl-review-loop
              deferred_reason: "# preflight-scope: runtime_only マーカーにより baseline 実行を skip"
              runtime_verification_required: true
            - ac: AC3
              command: "rg -n \"from.*render\" src/ui/HudController.ts"
              exit_code: 1
              category: expected_baseline_fail
              scope_class: baseline_fail_expected
              confidence: high
              evidence:
                stdout_excerpt: ""
                stderr_excerpt: ""
              decision: go
            - ac: AC4
              command: "pnpm typecheck"
              exit_code: 0
              category: regression_gate
              scope_class: regression_gate
              confidence: low
              evidence:
                stdout_excerpt: ""
                stderr_excerpt: ""
              decision: go
            - ac: AC4
              command: "pnpm lint"
              exit_code: 0
              category: regression_gate
              scope_class: regression_gate
              confidence: low
              evidence:
                stdout_excerpt: ""
                stderr_excerpt: ""
              decision: go
            - ac: AC4
              command: "pnpm test"
              exit_code: 0
              category: regression_gate
              scope_class: regression_gate
              confidence: low
              evidence:
                stdout_excerpt: ""
                stderr_excerpt: ""
              decision: go
            - ac: AC4
              command: "pnpm build"
              exit_code: 0
              category: regression_gate
              scope_class: regression_gate
              confidence: low
              evidence:
                stdout_excerpt: ""
                stderr_excerpt: ""
              decision: go
        ac_verifiability: pass
        product_spec_check:
          applicability: not_applicable
          decision: pass
          triggers:
            docs_product_allowed_paths: false
            tasks_md_mentioned: false
            specify_artifact_mentioned: false
            generated_task_mentioned: false
            product_spec_context_present: false
          blocked_reasons: []
        worktree_branch_collision: clear
      next_action: implement_issue
      blocked_reasons: []
      warnings:
        - "AC2a/AC2b/AC2c は runtime_only VC。impl-review-loop が post-implementation に Playwright / DOM テストで検証すること。"
  6. squne121 commented on Jun 6, 2026

    @squne121
    OwnerAuthor

    implement-issue: 実装完了 (2026-06-06T07:33:47Z)

    • PR: fix(#693): STATUS Hull 表示の水平 overflow を防止する #701
    • Worktree: .claude/worktrees/issue-693-status-hull-overflow
    • Branch: worktree-issue-693-status-hull-overflow
    • 検証: typecheck/lint/test/build 全件 PASS、Playwright e2e AC2a/AC2b/AC2c 8件 PASS(全 viewport × 全 hull 値)
    • 後続: PR レビュー(pr-review-judge)→ マージ → post-merge-cleanup
  7. added 3 commits that reference this issue on Jun 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    phase/implementation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions