Skip to content

fix(devices): save default refresh rate as a number - #90

Open
jhuesos wants to merge 1 commit into
usetrmnl:mainfrom
jhuesos:fix/refresh-rate-number
Open

jhuesos wants to merge 1 commit into
usetrmnl:mainfrom
jhuesos:fix/refresh-rate-number

Conversation

@jhuesos

@jhuesos jhuesos commented Oct 16, 2026

Copy link
Copy Markdown

Closes #89.

Problem

The "Default refresh rate" field on the device page is saved as a string ("default_refresh_rate": "600"), because the generic handleInputChange stores e.target.value as is. normalizeRefreshSchedule only accepts a number, so it returns null for the whole schedule:

  • the device page shows the 300 s UI fallback instead of the saved value,
  • /api/display sends the 180 s fallback,
  • time-range overrides are ignored as well.

Time-range rates are not affected because handleNestedInputChange already runs Number.parseInt.

Fix

  • Form (client-page.tsx): parse refresh_schedule.default_refresh_rate with Number.parseInt, like the time-range rates.
  • Reader (lib/device/defaults.ts): normalizeRefreshSchedule accepts numeric strings ("600") for the default and time-range rates, so rows already saved by the old form work again without a migration. Anything else still gives null for the default, and invalid time ranges are dropped as before.

Tests

Adds lib/device/defaults.test.ts for numeric schedules, numeric strings, JSON string columns, invalid defaults and invalid time ranges. The two numeric-string cases fail without the fix.

pnpm lint, pnpm typecheck and pnpm test pass.

🤖 Generated with Claude Code

The device form stored "Default refresh rate" straight from the input,
so it was saved as a string ("600"). normalizeRefreshSchedule only
accepts a number and returned null for the whole schedule, so the UI
showed the 300 s fallback, /api/display sent the 180 s fallback, and
time-range overrides were ignored too.

Parse the field as an integer in the form, like the time-range rates
already are, and let normalizeRefreshSchedule accept numeric strings so
rows saved by the old form work again.

Closes usetrmnl#89

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

Default refresh rate is saved as a string, so the whole refresh schedule is ignored

1 participant