Skip to content

[feat]Newバッジ表示機能追加#257

Merged
taminororo merged 3 commits intodevelopfrom
feat/danimaru/245-add-New-badge
Apr 20, 2026
Merged

[feat]Newバッジ表示機能追加#257
taminororo merged 3 commits intodevelopfrom
feat/danimaru/245-add-New-badge

Conversation

@danimaru1025
Copy link
Copy Markdown
Contributor

@danimaru1025 danimaru1025 commented Mar 19, 2026

未読シフトへの「New!」バッジ表示の実装

resolve #245

概要

ユーザーが「どのシフトカードが新規追加または更新されたか」を直感的に把握できるように、カード単位でNewバッジを表示する機能の追加。
判定対象は本人のカード情報(タスク名、開始時刻、終了時刻、集合場所)のみ。

画面スクリーンショット等

localhost_45029_layout(iPhone 12 Pro)

テスト項目
・初回表示でNewが付く
・カード開封でNewが消える
・変更なし更新でNewが増えない
・対象項目変更時のみNewが付く
・タブ切替後も既読状態が維持される

確認方法

  1. ターミナルで以下を入力
docker compose up -d
cd mobile
fvm flutter run -d web-server --web-port=45029
  1. ブラウザでhttp://localhost:45029/layouthttp://localhost:3000/shifts を開く
  2. http://localhost:3000/shiftsの方で、左の一覧にある「タスク」を開いて、タスクの編集を行う。
  3. http://localhost:45029/layout でF5 or 「更新」 or 日付変更などのボタンを押す と編集したタスクにnewバッジがつく

カードの内容が変わるたびに古いキーの削除が行われていることの確認方法

  1. 上の方法でタスクを変更する。
  2. http://localhost:45029/layout でf12からコンソールを開いて、上部のフィルタに Cleaned と入力
  3. Cleaned X stale opened keys for day Y が出ていることを確認

備考

Summary by CodeRabbit

  • New Features

    • Shift cards now display a "New" badge to highlight recently added shifts; badge clears when you open a card.
  • Performance Improvements

    • Optimized day navigation to eliminate unnecessary shift card reloads.
    • Fixed issue where delayed background operations could overwrite current shift data.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a “New” badge to shift cards so users can quickly identify newly added/updated shifts, and persists “opened/read” state locally via Hive.

Changes:

  • Extend ShiftCard to optionally render a New badge and notify when a card is opened (ExpansionTile expanded).
  • Add persistent storage (openedCardKeysBox) for opened card keys.
  • Implement New-detection and opened-key filtering in MyShiftPage, and wire New state into ShiftCard.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
mobile/lib/widgets/shift_card.dart Adds isNew + onOpened and displays NewBadge next to the task name; triggers callback on expand.
mobile/lib/utils/permanent_store.dart Opens a new Hive box to persist opened-card keys.
mobile/lib/pages/my_shift_page.dart Tracks new/opened card keys, loads persisted opened keys, detects new/updated cards on fetch, and clears/persists state on open.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread mobile/lib/pages/my_shift_page.dart
Comment thread mobile/lib/pages/my_shift_page.dart Outdated
Comment thread mobile/lib/pages/my_shift_page.dart Outdated
Comment thread mobile/lib/pages/my_shift_page.dart Outdated
Comment thread mobile/lib/pages/my_shift_page.dart
@danimaru1025 danimaru1025 requested a review from Copilot March 19, 2026 05:39
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

未読(新規追加/更新)シフトカードをユーザーが判別できるように、「New」バッジ表示と既読管理(永続化)をモバイル側に追加するPRです。

Changes:

  • ShiftCard に New バッジ表示(isNew)と開封時コールバック(onOpened)を追加
  • MyShiftPage で New 判定(キャッシュ差分)・開封済み管理・Hive 永続化を実装
  • Hive に開封済みカードキー保存用の Box を追加

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
mobile/lib/widgets/shift_card.dart タスク名横に New バッジを表示し、ExpansionTile 展開時に既読化コールバックを発火
mobile/lib/utils/permanent_store.dart 開封済みカードキー保存用の Hive Box を追加して初期化
mobile/lib/pages/my_shift_page.dart New キー検出/保持、開封済み管理、Hive 永続化、非同期ロード競合回避を追加

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread mobile/lib/widgets/shift_card.dart
Comment thread mobile/lib/pages/my_shift_page.dart
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 15, 2026

📝 Walkthrough

Walkthrough

The changes implement a persistent "New" card badge system for shift cards. The system loads previously-opened card keys from Hive storage during initialization, determines which cards are new by comparing fetched card content, passes an isNew flag and callback to the ShiftCard widget, and records opened cards to persistent storage to prevent re-displaying them across app sessions.

Changes

Cohort / File(s) Summary
New Card Tracking & Persistence Logic
mobile/lib/pages/my_shift_page.dart
Implements request cancellation via _latestLoadRequestId, adds _handleTabChange early-return for unchanged days, loads opened-card keys from Hive during initialization, computes per-day _newCardKeysByDay by comparing fetched vs. cached card content (task name, normalized times, place), filters already-opened keys, and persists per-day New-key sets. Updated ShiftCard rendering to pass isNew flag and onOpened callback. Removes opened keys that no longer exist in latest data.
Persistent Storage Infrastructure
mobile/lib/utils/permanent_store.dart
Added new Hive Box global openedCardKeysBox and extended initHive() to open the 'openedCardKeys' box.
ShiftCard Widget Enhancement
mobile/lib/widgets/shift_card.dart
Added two public parameters: isNew (boolean, default false) and onOpened (optional callback). Changed task name display from standalone Text to Row with conditional NewBadge rendering. Extended ExpansionTile with onExpansionChanged to invoke onOpened when tile expands if card is marked new.

Sequence Diagram

sequenceDiagram
    participant App as App Init
    participant Store as Permanent Store<br/>(Hive)
    participant Page as MyShiftPage
    participant API as API/Cache
    participant UI as ShiftCard Widget

    App->>Store: initHive() opens 'openedCardKeys' box
    
    Page->>Store: Load opened card keys from Hive
    Store-->>Page: Return user-scoped opened keys
    
    Page->>API: Fetch latest shift card data
    API-->>Page: Return fetched cards
    
    Page->>Page: Compute _newCardKeysByDay<br/>by comparing fetched vs. cached<br/>content (task, time, place)
    
    Page->>Page: Filter out already-opened keys<br/>from new card sets
    
    Page->>UI: Render cards with isNew flag<br/>and onOpened callback
    
    UI-->>Page: Display card with badge<br/>if isNew == true
    
    Note over UI,Page: User opens card
    UI->>Page: Invoke onOpened callback
    
    Page->>Page: Remove key from<br/>in-memory _newCardKeysByDay
    
    Page->>Store: Persist updated New-key sets<br/>to Hive per day
    Store-->>Page: Keys saved
    
    Page->>UI: Re-render without badge
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

🐰 Hop, hop! A new feature hops into view—
Badges of "New" on shifts fresh and true!
Hive stores our memory, cards tracked with care,
Unread ones sparkle, then fade in the air! ✨

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The implementation deviates significantly from issue #245 requirements: uses persistent Hive storage instead of mock-only, tracks opened cards per-user rather than per-card, and includes backend state management not specified in the original requirements. Review whether persistent state management with Hive and per-user tracking aligns with the original UI/mock prototype goal in issue #245, or clarify if requirements were updated.
Out of Scope Changes check ⚠️ Warning Changes include persistent Hive storage with openedCardKeysBox and per-user card tracking, which extends beyond the mock UI implementation described in issue #245. Clarify if persistent state management and backend-ready architecture were planned extensions, or revert to the mock-only prototype approach specified in issue #245.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: adding a 'New' badge display feature for shift cards, which aligns with the changeset.
Description check ✅ Passed The description follows the repository template, includes resolved issue (#245), clear overview, screenshots, and detailed test items and verification steps.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/danimaru/245-add-New-badge

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

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@mobile/lib/pages/my_shift_page.dart`:
- Around line 396-417: The current key generation in _cardKeyFromShiftCardData
and its use in _buildCardMap collapses multiple distinct ShiftCardData entries
that share day/taskName/startTime/endTime/place; change the key to include a
stable per-card unique identifier from the API (e.g., card.id or card.uniqueId)
if available, otherwise augment the generated key deterministically by appending
an occurrence suffix (e.g., incrementing counter or index for duplicates) when
building the map in _buildCardMap so each card produces a unique map key and
preserves per-card isNew/badge state.
- Around line 264-279: The cache key for shift cards is not namespaced by user
and causes cross-account diffs; include the current user id when loading,
diffing, and writing the cache. Specifically, update calls that use the
'${dayID}_${weatherID}' key (including where you call _loadPersistedNewKeys,
_detectNewOrUpdatedCardKeys inputs if they rely on the cache key, and the final
shiftCardBox.put call) to use a namespaced key like
'${_userID}_${dayID}_${weatherID}' (or equivalent _userID prefix) so both the
baseline load and the put use the same per-user key.
🪄 Autofix (Beta)

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: defaults

Review profile: CHILL

Plan: Pro

Run ID: add656ae-03e6-4707-b812-ffe1d50e045b

📥 Commits

Reviewing files that changed from the base of the PR and between 6859368 and 26c8781.

📒 Files selected for processing (3)
  • mobile/lib/pages/my_shift_page.dart
  • mobile/lib/utils/permanent_store.dart
  • mobile/lib/widgets/shift_card.dart

Comment thread mobile/lib/pages/my_shift_page.dart
Comment thread mobile/lib/pages/my_shift_page.dart
Copy link
Copy Markdown
Collaborator

@taminororo taminororo left a comment

Choose a reason for hiding this comment

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

LGTMです

@taminororo taminororo merged commit e313cf0 into develop Apr 20, 2026
1 check passed
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.

[UI/Mock] 未読シフトへの「New!」バッジ表示の実装

3 participants