Skip to content

feat(mobile): scale completion sound speed with task length#3050

Open
Gilbert09 wants to merge 3 commits into
mainfrom
posthog-code/mobile-scale-completion-sound-speed
Open

feat(mobile): scale completion sound speed with task length#3050
Gilbert09 wants to merge 3 commits into
mainfrom
posthog-code/mobile-scale-completion-sound-speed

Conversation

@Gilbert09

Copy link
Copy Markdown
Member

Ports the desktop feature from #3026 to the mobile app (apps/mobile, React Native / Expo).

What this does

When a turn finishes and the completion sound plays, it now plays at a variable playback rate based on how long the task ran: quick tasks ring fast (higher pitch), long tasks drag slow (lower pitch). A new settings toggle, "Scale sound speed with task length", gates the behavior and defaults off.

Changes

  • features/tasks/utils/playbackRate.ts (new) — playbackRateForTaskDuration(durationMs), ported verbatim from desktop. Maps duration to a rate: <=30s → 3x, the 2–4min "normal" band → 1x, >=30min → 1/3x, with smooth log-interpolation across the two ramps.
  • features/tasks/utils/sounds.tsplayCompletionSound takes an optional playbackRate; sets rate and shouldCorrectPitch: false on the expo-av player so pitch shifts with speed (matching desktop). Dropped the now-unused playMeepSound alias.
  • features/preferences/stores/preferencesStore.ts — added the scaleSoundWithTaskLength preference (default false) with a setter, persisted alongside the other completion-sound prefs.
  • features/tasks/stores/taskSessionStore.ts — track promptStartedAt on the session when a prompt starts on this device; at the ping sites, when the setting is enabled and a start time is known, play at playbackRateForTaskDuration(elapsed), otherwise at rate 1.
  • app/settings/index.tsx — added the toggle row, shown only when completion sounds are enabled.

Tests

  • Unit test for playbackRateForTaskDuration mirroring the desktop cases (<=30s → 3, normal band → 1, >=30min → 1/3) plus a monotonicity check.
  • Preference store default / setter / persistence test.
  • Full mobile suite green (378 tests).

Ports the desktop feature from #3026 to the mobile app: the task-completion
sound now plays at a variable rate based on how long the turn ran — quick tasks
ring fast (higher pitch), long tasks drag slow (lower pitch). A new
"Scale sound speed with task length" setting gates the behavior, defaulting off.

- Add `playbackRateForTaskDuration` (verbatim from desktop) mapping duration to
  a playback rate, and thread an optional `playbackRate` through
  `playCompletionSound`, setting `rate`/`shouldCorrectPitch: false` on expo-av.
- Add the `scaleSoundWithTaskLength` preference (persisted, default off).
- Track prompt start time on the session and compute the rate at the ping sites.
- Add the settings toggle, shown only when a completion sound is enabled.

Generated-By: PostHog Code
Task-Id: dc58b11c-b3fc-4275-8102-9bffed29d638
@Gilbert09 Gilbert09 requested a review from a team July 1, 2026 10:46
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

React Doctor found no issues in the changed files. 🎉

Reviewed by React Doctor for commit 4f96025.

@greptile-apps

greptile-apps Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Reviews (1): Last reviewed commit: "feat(mobile): scale completion sound spe..." | Re-trigger Greptile

Comment thread apps/mobile/src/features/tasks/stores/taskSessionStore.test.ts
Gilbert09 added 2 commits July 1, 2026 12:10
…mock

The store imports playbackRateForTaskDuration from ../utils/playbackRate, not
../utils/sounds, so stubbing it in the sounds mock had no effect. The function
is pure and dependency-free, so let the real implementation run rather than add
a redundant mock.

Generated-By: PostHog Code
Task-Id: dc58b11c-b3fc-4275-8102-9bffed29d638
…peed

Generated-By: PostHog Code
Task-Id: 7393b760-09b1-49d1-b90c-695eca0e50fa
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.

2 participants