Skip to content

feat(reminder): add timeflow-alarm native module and Expo wiring - #237

Closed
gac0812 wants to merge 4 commits into
1024XEngineer:mainfrom
gac0812:feat/native-timeflow-alarm-module
Closed

feat(reminder): add timeflow-alarm native module and Expo wiring#237
gac0812 wants to merge 4 commits into
1024XEngineer:mainfrom
gac0812:feat/native-timeflow-alarm-module

Conversation

@gac0812

@gac0812 gac0812 commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Summary

  • 新增 frontend/modules/timeflow-alarm Android 原生库(精确闹钟、响铃 UI、停铃、原生事件)
  • 增加 Expo config plugin withTimeflowAlarmreact-native.config.js autolinking
  • 加厚 TimeflowAlarmBridge / NativeAlarmScheduler:三参 schedule、cancelAllstopRingingsubscribeconsumeNativeDispositions
  • 新增 ExpoSystemNotificationexpo-notifications 懒加载),并补 scheduler / 系统通知单测

Merge Order

Scope

  • frontend/modules/timeflow-alarm/**
  • frontend/plugins/withTimeflowAlarm.js
  • frontend/react-native.config.js
  • frontend/app.jsonfrontend/package.jsonfrontend/eslint.config.jsfrontend/.prettierignore
  • frontend/src/infrastructure/notifications/native/TimeflowAlarmBridge.ts
  • frontend/src/infrastructure/notifications/NativeAlarmScheduler.ts
  • frontend/src/infrastructure/notifications/ExpoSystemNotification.ts
  • frontend/src/features/reminder/application/interfaces/AlarmSchedulerPort.ts(可选原生事件方法)
  • frontend/tests/unit/infrastructure/notifications/nativeAlarmScheduler.test.ts
  • frontend/tests/unit/infrastructure/notifications/expoSystemNotification.test.ts

Out of scope

Verification

  • npm run check
  • npm ci

Closes #232

Give Android an actual TimeflowAlarm library and thicken the JS bridge so exact alarms can be scheduled, cancelled, and observed from the app.
@vercel

vercel Bot commented Aug 13, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
timeflow Ready Ready Preview Aug 14, 2026 1:44am

@fennoai fennoai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Found one high-confidence build blocker in the new Android module. TypeScript typecheck, focused Jest tests (18 tests), and ESLint pass; an Android Gradle build was not available in this workspace because no Android SDK/project wrapper is mounted.

compileSdk 35 does not ship MODE_BACKGROUND_ACTIVITY_START_ALLOW_ALWAYS; use the documented integer on API 36+ instead.
@gac0812

gac0812 commented Aug 13, 2026

Copy link
Copy Markdown
Contributor Author

@fennoai /review

@fennoai

fennoai Bot commented Aug 13, 2026

Copy link
Copy Markdown

Review Complete

  • Reviewed the fixed range ac37def20a925c28b9927ed124763ff002c72332...b268e19b776c0184f271379881da10c6c419cae5.
  • Posted one non-blocking PR review finding: overlapping alarms share a singleton AlarmSoundService, which can suppress the second alarm’s fired event and couple dismissal/audio lifecycles.
  • Verification passed: targeted Jest tests (18), TypeScript typecheck, ESLint, and Prettier check.
  • npm ci completed successfully; npm reported an engine warning and 13 existing audit vulnerabilities.

View job run

@fennoai fennoai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Found one correctness issue in the native alarm service. The targeted JS tests and static checks pass.

Last-wins replacement now emits a fired event for each alarm id instead of collapsing concurrent rings into one.
@gac0812

gac0812 commented Aug 14, 2026

Copy link
Copy Markdown
Contributor Author

@fennoai /review

@fennoai

fennoai Bot commented Aug 14, 2026

Copy link
Copy Markdown

Review Complete

  • Reviewed the fixed range ac37def20a925c28b9927ed124763ff002c72332...83ba3b0b01c64b571806611e33ffe75b60053ef1.
  • The new overlap serialization correctly addresses the prior missing fired event, but one residual P1 lifecycle issue remains: the previous RingActivity is not closed when the service switches to a new overlapping alarm, so its controls can dismiss the wrong alarm and stop the new one.
  • Verification passed: targeted Jest tests (18), TypeScript typecheck, ESLint, Prettier check, and git diff --check.

View job run

@fennoai fennoai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The previous overlap-event issue is improved, but one lifecycle correctness issue remains. Targeted tests and static checks pass.

// Singleton service: overlapping alarms are serialized last-wins so each
// schedule still gets its own `fired` event and the previous UI/audio is torn down.
boolean isNewAlarm = notifiedAlarmId == null || !nextAlarmId.equals(notifiedAlarmId);
if (isNewAlarm && notifiedAlarmId != null) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 — The previous RingActivity is not torn down when replacing an overlapping alarm. RingActivity is launched with FLAG_ACTIVITY_MULTIPLE_TASK and keeps its own alarmId/requestCode, while this replacement block only releases the service audio and overlay. If alarm B fires while alarm A’s activity is visible, the visible UI still belongs to A but the service now plays B; pressing confirm/snooze on A calls AlarmNativeBridge.notify* with A’s IDs and AlarmSoundService.stop() stops B as well. RingActivity.finishIfOpen() already exists, so close the current activity before switching the service to the new alarm (or otherwise make the activity/service state atomic).

@gac0812 gac0812 closed this Aug 14, 2026
@gac0812
gac0812 deleted the feat/native-timeflow-alarm-module branch August 14, 2026 06:05
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.

feat(reminder): 接入 timeflow-alarm 原生模块与 Expo 接线

1 participant