Skip to content

Installer: temperature-unit default ignores detected timezone, defaults to Fahrenheit worldwide #1456

Description

@henrique-franze

Bug

On a fresh install, the temperature-unit prompt defaults to Fahrenheit regardless of the timezone the installer just detected/confirmed one step earlier — so most non-US installs end up with Fahrenheit in the statusline weather display unless the user explicitly types C.

Where

LifeOS/install/LIFEOS/LIFEOS_INSTALL/engine/actions.ts:

// line ~1443 — timezone is detected and confirmed here
const detectedTz = state.detection?.timezone || Intl.DateTimeFormat().resolvedOptions().timeZone;
const tz = await getInput("timezone", `Detected timezone: ${detectedTz}...`, "text", detectedTz, ...);
state.collected.timezone = tz.trim() || detectedTz;

// line ~1454-1460 — temperature unit prompt, right after
const defaultTempUnit = state.collected.temperatureUnit || "fahrenheit";   // <-- always "fahrenheit" on a fresh install
const tempUnit = await getInput(
  "temperature-unit",
  `Temperature unit? Type F for Fahrenheit or C for Celsius. (Default: ${defaultTempUnit === "celsius" ? "C" : "F"})`,
  "text",
  defaultTempUnit === "celsius" ? "C" : "F",
  ...
);
const trimmedUnit = tempUnit.trim().toLowerCase();
state.collected.temperatureUnit = (trimmedUnit === "c" || trimmedUnit === "celsius") ? "celsius" : "fahrenheit";

state.collected.timezone is already populated one step above, but defaultTempUnit never looks at it — it only carries over a unit from a prior install (actions.ts:1212, settings.preferences?.temperatureUnit). On a truly fresh install there's nothing to carry over, so every install pre-fills F regardless of locale, and anyone who accepts the default (pressing Enter, or a non-interactive/web install flow) ends up with Fahrenheit.

This then flows unchanged into config-gen.ts:55 (temperatureUnit: config.temperatureUnit || "fahrenheit") and gets written to settings.json, which LIFEOS_StatusLine.sh reads for the weather display.

Suggested fix

Derive the pre-filled default from the timezone already collected, instead of hardcoding "fahrenheit". Something like:

// A short list is enough — Fahrenheit-for-weather is really only the US
// (plus a couple of small outliers) once you exclude it.
const FAHRENHEIT_TIMEZONES = new Set([
  "America/New_York", "America/Chicago", "America/Denver", "America/Los_Angeles",
  "America/Anchorage", "America/Adak", "Pacific/Honolulu",
  "America/Nassau",      // Bahamas
  "America/Belize",
  "America/Cayman",
  "Pacific/Palau",
  "Asia/Yangon",         // Myanmar
  "Africa/Monrovia",     // Liberia
]);

const defaultTempUnit =
  state.collected.temperatureUnit ||
  (FAHRENHEIT_TIMEZONES.has(state.collected.timezone) ? "fahrenheit" : "celsius");

The explicit F/C prompt should stay (so anyone can override it) — this only changes what the default is when the user just accepts it. The timezone list above isn't exhaustive of every IANA alias; happy to help fill it out if useful, but even a partial list beats a global Fahrenheit default for a project whose users are worldwide.

Repro

Fresh install, non-US timezone, accept the temperature-unit prompt's default (or install non-interactively) → settings.json ends up with preferences.temperatureUnit: "fahrenheit" → statusline weather shows °F.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions