Skip to content
This repository was archived by the owner on Aug 6, 2026. It is now read-only.

feat(loops): Customize timezone for loop schedules - #3725

Merged
charlesvien merged 6 commits into
mainfrom
posthog-code/loop-system-timezone
Jul 23, 2026
Merged

charlesvien merged 6 commits into
mainfrom
posthog-code/loop-system-timezone

Conversation

@MattPua

@MattPua MattPua commented Jul 22, 2026 •

Copy link
Copy Markdown
Member

Problem

Why: Loop schedules default to UTC and provide little context about when they will run, making configured times surprising outside UTC.

Users want to be able to set loops scheduled in their timezone

Changes

Before:

CleanShot 2026-07-22 at 17 27 43@2x CleanShot 2026-07-22 at 17 27 53@2x

After:
CleanShot 2026-07-22 at 17 27 00@2x
CleanShot 2026-07-22 at 17 27 09@2x
CleanShot 2026-07-22 at 17 27 15@2x
CleanShot 2026-07-22 at 17 27 21@2x
CleanShot 2026-07-22 at 17 27 29@2x

  • Default new loop schedules and templates to the detected system timezone
  • Add a timezone picker consistent with the rest of the trigger form
  • Show the next run while creating a schedule and in loop details
  • Add reusable timezone timestamp, conversion popover, and recurrence utilities
  • Add copy feedback and Storybook coverage for timezone displays

How did you test this?

  • pnpm --filter @posthog/ui typecheck
  • pnpm --filter @posthog/ui exec vitest run src/features/loops/loopDisplay.test.ts src/features/loops/loopCron.test.ts src/features/loops/loopFormTypes.test.ts src/primitives/timezone.test.ts src/primitives/TimezoneConversionTooltip.test.tsx
  • Storybook production build
  • git diff --check

Automatic notifications

  • Publish to changelog?
  • Alert Sales and Marketing teams?

Created with PostHog Code

@trunk-io

trunk-io Bot commented Jul 22, 2026 •

Copy link
Copy Markdown

😎 This pull request was merged.

@github-actions

github-actions Bot commented Jul 22, 2026 •

Copy link
Copy Markdown

React Doctor found no issues in the changed files. 🎉

Reviewed by React Doctor for commit 9436f41.

@posthog

posthog Bot commented Jul 22, 2026 •

Copy link
Copy Markdown
Contributor

👋 Visual changes detected for this PR.

Review and approve in PostHog Visual Review

If these changes are unexpected, they may be caused by a flaky test or a broken snapshot on master. Don't approve — rerun the job or wait for a fix.

@MattPua
MattPua requested a review from charlesvien July 22, 2026 21:29
@MattPua MattPua changed the title Use system timezone for loop schedules feat: Customize timezone for loop schedules Jul 22, 2026
@MattPua
MattPua marked this pull request as ready for review July 22, 2026 21:30
@MattPua MattPua changed the title feat: Customize timezone for loop schedules feat(loops): Customize timezone for loop schedules Jul 22, 2026
@MattPua
MattPua requested a review from a team July 22, 2026 21:30
@greptile-apps

greptile-apps Bot commented Jul 22, 2026 •

Copy link
Copy Markdown
Contributor

Comments Outside Diff (1)

  1. packages/ui/src/features/loops/components/LoopTriggerEditor.tsx, line 302 (link)

    P1 Frequency Toggle Loses Timezone

    Switching a recurring trigger to Once replaces its config with only run_at, discarding the selected timezone. If the user switches back to recurring, the editor falls back to systemTimezone() and saves that value, so a schedule configured for Europe/London can silently become America/Toronto and run at a different instant.

    Prompt To Fix With AI
    This is a comment left during a code review.
    Path: packages/ui/src/features/loops/components/LoopTriggerEditor.tsx
    Line: 302
    
    Comment:
    **Frequency Toggle Loses Timezone**
    
    Switching a recurring trigger to Once replaces its config with only `run_at`, discarding the selected timezone. If the user switches back to recurring, the editor falls back to `systemTimezone()` and saves that value, so a schedule configured for `Europe/London` can silently become `America/Toronto` and run at a different instant.
    
    How can I resolve this? If you propose a fix, please make it concise.
Prompt To Fix All With AI
Fix the following 3 code review issues. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 3
packages/ui/src/features/loops/components/LoopTriggerEditor.tsx:302
**Frequency Toggle Loses Timezone**

Switching a recurring trigger to Once replaces its config with only `run_at`, discarding the selected timezone. If the user switches back to recurring, the editor falls back to `systemTimezone()` and saves that value, so a schedule configured for `Europe/London` can silently become `America/Toronto` and run at a different instant.

### Issue 2 of 3
packages/ui/src/features/loops/components/LoopTriggerEditor.tsx:264
**Missing Timezone Changes Meaning**

An existing recurring trigger with no stored timezone is interpreted as UTC by `nextScheduleRun`, but the editor now presents it as the device timezone. Editing any recurrence field then persists that device timezone, silently changing when the existing loop runs; missing timezones should remain UTC while only new triggers default to `systemTimezone()`.

### Issue 3 of 3
packages/ui/src/primitives/timezone.ts:80-83
**Fallback Removes Most Timezones**

When `Intl.supportedValuesOf` is unavailable, this fallback leaves the picker with only the device timezone and UTC. In a supported host runtime without that optional API, users cannot select any other valid IANA timezone, so the new scheduling feature is unusable for schedules targeting another region.

Reviews (1): Last reviewed commit: "fix: prevent timezone popover reopening" | Re-trigger Greptile

Comment thread packages/ui/src/features/loops/components/LoopTriggerEditor.tsx Outdated
Comment thread packages/ui/src/primitives/timezone.ts
MattPua and others added 6 commits July 22, 2026 21:35
Generated-By: PostHog Code
Task-Id: 907cb786-f6a5-4eb7-bab0-44ec58b70afa
Generated-By: PostHog Code
Task-Id: 231e46d4-90e5-4be2-af47-958398fcbf9c
6 updated
Run: 0f67cae8-b6b4-4e64-8ae8-381a25901372

Co-authored-by: MattPua <3376526+MattPua@users.noreply.github.com>
Generated-By: PostHog Code
Task-Id: 231e46d4-90e5-4be2-af47-958398fcbf9c
Generated-By: PostHog Code
Task-Id: a88a845a-e243-436a-a41d-edc0a65170fa
@charlesvien
charlesvien force-pushed the posthog-code/loop-system-timezone branch from d5ad812 to 9436f41 Compare July 23, 2026 04:40
@charlesvien
charlesvien merged commit 636a8d6 into main Jul 23, 2026
32 checks passed
@charlesvien
charlesvien deleted the posthog-code/loop-system-timezone branch July 23, 2026 04:51
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants