Skip to content

An open-source, faster Devin alternative

TypeScript

schedules: right-align the tz offset as muted +X/-X

Igor Zalutskia1de8453afaf
diff --git a/web/src/components/agent-schedules.tsx b/web/src/components/agent-schedules.tsx
index ad60f8e5..07b6a4aa 100644
--- a/web/src/components/agent-schedules.tsx
+++ b/web/src/components/agent-schedules.tsx
@@ -74,34 +74,30 @@ const COMMON_TZS = [
'Asia/Dubai', 'Asia/Kolkata', 'Asia/Singapore', 'Asia/Shanghai', 'Asia/Tokyo', 'Australia/Sydney',
]
const prettyTz = (z: string) => z.replace(/_/g, ' ')
-// Current UTC offset for a zone — e.g. "UTC-5", "UTC+5:30", "UTC+0" (DST-dependent: the offset in effect now).
+// Current offset as a bare "+5:30" / "-4" / "+0" (DST-dependent: the offset in effect now).
function tzOffset(z: string): string {
try {
const name =
new Intl.DateTimeFormat('en-US', { timeZone: z, timeZoneName: 'shortOffset' })
.formatToParts(new Date())
.find((p) => p.type === 'timeZoneName')?.value ?? ''
- return name.replace('GMT', 'UTC').replace(/^UTC$/, 'UTC+0')
+ return name.replace(/^(?:GMT|UTC)/, '') || '+0'
} catch {
return ''
}
}
-function tzLabel(z: string): string {
- if (z === 'UTC') return 'UTC'
- const off = tzOffset(z)
- return off ? `${prettyTz(z)} (${off})` : prettyTz(z)
-}
-function tzOptions(current: string): ({ value: string; label: string } | { separator: true })[] {
- const items: ({ value: string; label: string } | { separator: true })[] = []
+function tzOptions(current: string): ({ value: string; label: string; hint?: string } | { separator: true })[] {
+ const items: ({ value: string; label: string; hint?: string } | { separator: true })[] = []
const seen = new Set<string>()
const push = (z: string, label?: string) => {
if (z && !seen.has(z)) {
seen.add(z)
- items.push({ value: z, label: label ?? tzLabel(z) })
+ // The offset rides in `hint` (muted, right-aligned); UTC needs none.
+ items.push({ value: z, label: label ?? prettyTz(z), hint: z === 'UTC' ? undefined : tzOffset(z) })
}
}
push('UTC')
- if (LOCAL_TZ && LOCAL_TZ !== 'UTC') push(LOCAL_TZ, `${tzLabel(LOCAL_TZ)} · your timezone`)
+ if (LOCAL_TZ && LOCAL_TZ !== 'UTC') push(LOCAL_TZ, `${prettyTz(LOCAL_TZ)} · your timezone`)
if (current && current !== 'UTC') push(current) // keep an already-set uncommon zone selectable
items.push({ separator: true })
for (const z of COMMON_TZS) push(z)
diff --git a/web/src/components/form.tsx b/web/src/components/form.tsx
index c2a1702d..85994560 100644
--- a/web/src/components/form.tsx
+++ b/web/src/components/form.tsx
@@ -23,8 +23,9 @@ export function Select({
value: string
onValueChange: (value: string) => void
// A `{ separator: true }` entry renders a divider between groups (e.g. models
- // grouped by provider) rather than a selectable item.
- options: ({ value: string; label: string } | { separator: true })[]
+ // grouped by provider) rather than a selectable item. An optional `hint` renders
+ // right-aligned + muted (e.g. a timezone's UTC offset).
+ options: ({ value: string; label: string; hint?: string } | { separator: true })[]
id?: string
placeholder?: string
disabled?: boolean
@@ -71,6 +72,11 @@ export function Select({
className="focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center rounded-md py-1 pr-8 pl-2 text-sm outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50"
>
<SelectPrimitive.ItemText>{o.label}</SelectPrimitive.ItemText>
+ {o.hint ? (
+ <span className="text-muted-foreground ml-auto pl-4 text-xs tabular-nums">
+ {o.hint}
+ </span>
+ ) : null}
<span className="absolute right-2 flex items-center">
<SelectPrimitive.ItemIndicator>
<Check className="size-4" />