TODO: Adopt AFDATA Language and Timezone Conventions
This plan applies after AFDATA defines:
*_bcp47for BCP-47 language tag fields.timezone_utc_offsetfor fixed UTC timezone offsets.nullor missing config fields as the documented auto/default form for strict-format fields.
Target Config Shape
Replace the current ui.language and top-level timezone config with a
workspace-level section:
{
"workspace": {
"language_bcp47": null,
"timezone_utc_offset": "+08:00"
}
}
Do not preserve old afmail config compatibility unless explicitly requested.
Config Model
- Add
WorkspaceSectiontoMailConfigwith:language_bcp47: Option<String>timezone_utc_offset: Option<String>
- Remove
UiSection,UiLanguage, and top-leveltimezone. - Validate
language_bcp47asnullor a BCP-47-like language tag. - Validate
timezone_utc_offsetasnull,UTC, or fixed UTC offset. - Normalize lenient timezone inputs only when writing config, not in raw persisted data.
- Add resolver helpers:
resolved_language_bcp47()returns explicit config value or detected/default language.resolved_timezone_offset()returns aFixedOffsetfrom config or current detected offset.
- Prefer pinning
timezone_utc_offsetat init/setup because it affects UID and message-id date stability.
Behavior Changes
- Use
workspace.language_bcp47as the default language for human-readable workspace text. - Template rendering should try the configured language first, then fallback to supported built-ins, ending at
en-US. - Keep template fallback internal; do not overwrite the configured language intent just because a template is missing.
- Update
AGENTS.mdtemplates and theagent-first-mailskill so agent-generated reason text, case names, archive names, summaries, and notes default toworkspace.language_bcp47. - Put mailbox-specific exceptions in the user-editable
AGENTS.mdsection, not in new config fields. - Replace direct host-local date paths with config-based fixed offset handling.
- Ensure case/archive UID dates, message-id date components, rendered message times, and fallback dates all use the resolved
workspace.timezone_utc_offset. - Expose
workspace.language_bcp47andworkspace.timezone_utc_offsetthroughafmail config get/set. - Remove
ui.languageand top-leveltimezonefrom config access.
Init and Setup
- Change
afmail initto:- Write
workspace.language_bcp47: null. - Detect and write the current fixed
workspace.timezone_utc_offset, for example+08:00. - Return structured output with detected language/timezone and next-step hints.
- Write
- Add or plan
afmail setupto:- Let a human or agent confirm language and timezone.
- Normalize timezone input before writing.
- Keep IMAP/SMTP guided setup separate if the scope gets too large.
- Document that:
nullmeans auto/default only where documented.timezone_utc_offsetis fixed offset only, not an IANA timezone.language_bcp47follows the AFDATA*_bcp47convention.
Tests
- Config:
- Default config contains
workspace.language_bcp47: null. - Default/init config pins
workspace.timezone_utc_offset. - Valid language tags pass; obvious invalid values fail if validation is strict.
UTC,+08:00, and-05:00pass and normalize consistently.- Top-level
timezoneandui.languageare rejected when compatibility is not required.
- Default config contains
- Rendering:
- Exact template language is used when available.
- Unsupported language falls back to a built-in template language without changing configured
language_bcp47.
- Agent/workspace templates:
- Generated
AGENTS.mdmentionsworkspace.language_bcp47as the default language for agent-written reason/name/summary/notes.
- Generated
- Time:
- UID dates and rendered local times use
workspace.timezone_utc_offset, not host local timezone. - Null timezone resolves predictably in status/doctor, with a warning if not pinned.
- UID dates and rendered local times use
- CLI docs/help:
- Generated help/docs mention the new config keys.
- Generated help/docs no longer mention
ui.language.
Assumptions
- AFDATA has already documented
*_bcp47,timezone_utc_offset, and null-as-auto config semantics. - No backward compatibility is required for existing afmail config files.
timezone_utc_offsetremains fixed-offset only; IANA timezone support is out of scope.- Fine-grained language controls for reason/case/archive/render are intentionally deferred; one workspace language is the default policy.