Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions apps/web/src/components/searchable-select-popover/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@
:aria-label="ariaLabel || placeholder"
:class="[selectTriggerClass, 'w-full']"
>
<span class="line-clamp-1">{{ displayLabel || placeholder }}</span>
<span
class="min-w-0 flex-1 truncate text-left"
:class="isUnavailableSelection ? 'text-muted-foreground' : undefined"
>{{ displayLabel || placeholder }}</span>
<ChevronsUpDown class="opacity-50" />
</button>
</slot>
Expand Down Expand Up @@ -134,6 +137,7 @@ import {
MenuScrollArea,
} from '@felinic/ui'
import { computed, nextTick, ref, useId, watch } from 'vue'
import { useI18n } from 'vue-i18n'
import { useVirtualizer } from '@tanstack/vue-virtual'
import { useListboxKeyboard } from '@/composables/useListboxKeyboard'
import { measureVirtualRow } from '@/utils/virtual-row-measure'
Expand Down Expand Up @@ -198,20 +202,29 @@ const props = withDefaults(defineProps<{
alignOffset: menuAlignOffset,
})

const { t } = useI18n()
const selected = defineModel<string>({ default: '' })
const searchTerm = ref('')
const open = ref(false)
const scrollElArea = ref<InstanceType<typeof MenuScrollArea> | null>(null)
const scrollEl = computed(() => scrollElArea.value?.viewportElement ?? null)

const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i

const selectedOption = computed(() =>
props.options.find((option) => option.value === selected.value),
)

const displayLabel = computed(() =>
selectedOption.value?.label ?? selected.value,
const isUnavailableSelection = computed(() =>
Boolean(selected.value && !selectedOption.value && (props.options.length > 0 || UUID_RE.test(selected.value))),
)
Comment on lines +218 to 220

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve valid timezones missing from the option catalog

For accounts using the default UTC timezone, this condition now makes the profile timezone selector display “Unavailable” instead of UTC. TimezoneSelect builds its options from Intl.supportedValuesOf('timeZone') in utils/timezones.ts, which omits UTC and valid aliases such as Etc/UTC even though they are accepted timezone values. The shared selector cannot assume every options array is exhaustive; preserve valid current timezone values in that owner or make unavailable-state handling opt-in for exhaustive catalogs.

Useful? React with 👍 / 👎.


const displayLabel = computed(() => {
if (selectedOption.value) return selectedOption.value.label
if (isUnavailableSelection.value) return t('common.unavailableOption')
return selected.value
})

const filteredOptions = computed(() => {
const keyword = searchTerm.value.trim().toLowerCase()
if (!keyword) {
Expand Down
17 changes: 5 additions & 12 deletions apps/web/src/components/sidebar/bot-switcher.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@
align="start"
side="bottom"
:align-offset="fullWidth ? 0 : -10"
class="w-60"
class="min-w-60"
:style="{ width: 'var(--reka-dropdown-menu-trigger-width)' }"
>
<DropdownMenuLabel class="text-xs font-medium text-muted-foreground">
{{ t('sidebar.bots') }}
Expand Down Expand Up @@ -131,7 +132,7 @@
</div>

<div
v-if="isLoading"
v-if="isLoading && displayBots.length === 0"
class="flex justify-center py-3"
>
<Spinner class="size-3.5" />
Expand Down Expand Up @@ -190,7 +191,7 @@ import { useChatStore } from '@/store/chat-list'
import { useUnreadStore } from '@/store/unread'
import { attentionBadgeVariant, mostUrgentKind } from '@/utils/session-attention'
import AttentionDot from './attention-dot.vue'
import { firstAvatarCharacter } from '@/composables/useAvatarInitials'
import { avatarInitials } from '@/composables/useAvatarInitials'
import { usePinnedBots } from '@/composables/usePinnedBots'
import { usePendingBotsRefresh } from '@/composables/usePendingBotsRefresh'
import { switcherBots } from './bot-switcher-list'
Expand Down Expand Up @@ -241,15 +242,7 @@ const currentLabel = computed(() => {
})

function initialsOf(bot: BotsBot): string {
const name = (bot.display_name || bot.id || '').trim()
const initials = name
.split(/[\s_-]+/)
.filter(Boolean)
.slice(0, 2)
.map(firstAvatarCharacter)
.join('')
.toUpperCase()
return initials || 'B'
return avatarInitials(bot.display_name || bot.id, 'B')
}

const avatarFallback = computed(() => {
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/sidebar/files-pane.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
class="group/pane-header min-h-[1.6875rem] mx-1 pl-[11px] mt-2"
:label="botName || t('bots.files.panelTitle')"
>
<div class="flex items-center gap-0.5 pr-1 opacity-0 transition-opacity duration-150 group-hover/pane-header:opacity-100">
<div class="flex items-center gap-0.5 pr-1 opacity-0 transition-opacity duration-150 group-hover/pane-header:opacity-100 group-focus-within/pane-header:opacity-100 pointer-coarse:opacity-100">
<Button
v-if="canWrite"
variant="ghost"
Expand Down
1 change: 1 addition & 0 deletions apps/web/src/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"active": "Active",
"inactive": "Inactive",
"loadFailed": "Failed to load",
"unavailableOption": "Unavailable",
"saveFailed": "Failed to save",
"networkError": "Network connection failed. Check your connection and try again.",
"createdAt": "Created at",
Expand Down
1 change: 1 addition & 0 deletions apps/web/src/i18n/locales/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"active": "アクティブ",
"inactive": "非アクティブ",
"loadFailed": "読み込みに失敗しました",
"unavailableOption": "利用不可",
"saveFailed": "保存に失敗しました",
"networkError": "ネットワークに接続できません。接続を確認してもう一度お試しください。",
"createdAt": "作成日時",
Expand Down
1 change: 1 addition & 0 deletions apps/web/src/i18n/locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"active": "启用",
"inactive": "未启用",
"loadFailed": "加载失败",
"unavailableOption": "不可用",
"saveFailed": "保存失败",
"networkError": "网络连接失败,请检查网络后重试",
"createdAt": "创建时间",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
</div>
<div class="flex shrink-0 items-center gap-2">
<span
v-if="isFormDirty && !isHydratingCredentials"
v-if="isFormDirty && !isHydratingCredentials && channelItem.meta.type !== 'weixin'"
class="hidden text-xs text-muted-foreground sm:inline"
>
{{ $t('common.unsaved') }}
Expand All @@ -41,6 +41,7 @@
{{ form.disabled ? $t('bots.channels.actionEnable') : $t('bots.channels.actionDisable') }}
</Button>
<Button
v-if="channelItem.meta.type !== 'weixin'"
size="sm"
:disabled="(!isFormDirty && isEditMode) || isBusy || isHydratingCredentials"
:loading="action === 'save'"
Expand Down
22 changes: 17 additions & 5 deletions apps/web/src/pages/bots/components/model-select.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
:class="[selectTriggerClass, 'w-full']"
>
<span
class="line-clamp-1"
class="min-w-0 flex-1 truncate text-left"
:class="isUnavailableSelection ? 'text-muted-foreground' : undefined"
:title="displayLabel || placeholder"
>
{{ displayLabel || placeholder }}
Expand Down Expand Up @@ -90,17 +91,28 @@ watch(selected, () => {

const { t } = useI18n()

const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i

const matchedModel = computed(() =>
props.models.find((m) => (m.id || m.model_id) === selected.value),
)

const isUnavailableSelection = computed(() =>
Boolean(selected.value && !matchedModel.value && (props.models.length > 0 || UUID_RE.test(selected.value))),
)

const modelLabel = computed(() => {
const model = props.models.find((m) => (m.id || m.model_id) === selected.value)
return model?.name || model?.model_id || selected.value
if (matchedModel.value) return matchedModel.value.name || matchedModel.value.model_id || selected.value
if (isUnavailableSelection.value) return t('common.unavailableOption')
return selected.value
})

// The effort moved inside this menu, so the trigger has to carry it — otherwise
// the value is invisible until the menu is reopened. "Off" is not appended: a
// bare model name leaves the provider's reasoning behavior unspecified.
const displayLabel = computed(() => {
if (!props.showReasoning || !modelLabel.value) return modelLabel.value
const model = props.models.find(m => (m.id || m.model_id) === selected.value)
if (isUnavailableSelection.value || !props.showReasoning || !modelLabel.value) return modelLabel.value
const model = matchedModel.value
const effort = props.reasoningOptions !== undefined
? reasoningEffort.value
: displayedEffort(reasoningEffort.value, model?.reasoning)
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/pages/bots/detail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
<!-- Edit Overlay -->
<button
type="button"
class="absolute inset-0 flex items-center justify-center rounded-full bg-black/40 opacity-0 transition-opacity group-hover/avatar:opacity-100"
class="absolute inset-0 flex items-center justify-center rounded-full bg-black/40 opacity-0 transition-opacity group-hover/avatar:opacity-100 focus-visible:opacity-100 pointer-coarse:opacity-100"
:title="$t('common.edit')"
:aria-label="$t('common.edit')"
:disabled="!bot || botLifecyclePending"
Expand Down Expand Up @@ -100,7 +100,7 @@
<button
v-if="bot"
type="button"
class="opacity-0 group-hover/name:opacity-100 p-1 shrink-0"
class="opacity-0 group-hover/name:opacity-100 focus-visible:opacity-100 group-focus-within/name:opacity-100 pointer-coarse:opacity-100 p-1 shrink-0"
:disabled="botLifecyclePending"
@click="handleStartEditBotName"
>
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/pages/bots/new.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
</Avatar>
<button
type="button"
class="absolute inset-0 flex items-center justify-center rounded-full bg-black/40 opacity-0 transition-opacity group-hover/avatar:opacity-100"
class="absolute inset-0 flex items-center justify-center rounded-full bg-black/40 opacity-0 transition-opacity group-hover/avatar:opacity-100 focus-visible:opacity-100 pointer-coarse:opacity-100"
:title="$t('common.edit')"
:aria-label="$t('common.edit')"
@click="avatarDialogOpen = true"
Expand Down
11 changes: 7 additions & 4 deletions apps/web/src/pages/people/index.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<template>
<PageShell :title="t('people.title')">
<PageShell
:title="t('people.title')"
width="lg"
>
<template #actions>
<Button
type="button"
Expand Down Expand Up @@ -63,7 +66,7 @@
:key="user.id"
>
<TableCell>
<div class="flex items-center gap-3">
<div class="flex min-w-0 max-w-64 items-center gap-3">
<Avatar class="size-9 shrink-0">
<AvatarImage
v-if="user.avatar_url"
Expand Down Expand Up @@ -322,7 +325,7 @@ import type {
AccountsUpdateAccountRequest,
} from '@memohai/sdk'

const { t } = useI18n()
const { t, locale } = useI18n()
const userStore = useUserStore()

type MemberRole = 'admin' | 'member'
Expand Down Expand Up @@ -407,7 +410,7 @@ function setUserPending(userID: string, pending: boolean) {
}

function formatMemberDate(value: string | undefined, fallback: string): string {
return formatDateTime(value, { fallback })
return formatDateTime(value, { fallback, locale: locale.value })
}

function resetCreateForm() {
Expand Down
68 changes: 41 additions & 27 deletions apps/web/src/utils/date-time.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,23 @@ interface FormatDateOptions {
locale?: string
}

function parseDate(value: string | null | undefined): Date | null {
if (!value) {
return null
}
const parsed = new Date(value)
return Number.isNaN(parsed.getTime()) ? null : parsed
type DateResolution =
| { kind: 'missing' }
| { kind: 'invalid' }
| { kind: 'valid'; date: Date }

function isGoZeroDate(date: Date): boolean {
// Go serializes zero time.Time{} values as year 0001 (e.g. "0001-01-01T00:00:00Z").
// Treat them as unset so callers render their empty fallback instead of "1/1/1".
return date.getUTCFullYear() <= 1
}

function resolveDate(value: string | Date | null | undefined): DateResolution {
if (!value) return { kind: 'missing' }
const parsed = value instanceof Date ? value : new Date(value)
if (Number.isNaN(parsed.getTime())) return { kind: 'invalid' }
if (isGoZeroDate(parsed)) return { kind: 'missing' }
return { kind: 'valid', date: parsed }
}

/**
Expand All @@ -27,29 +38,30 @@ export function formatDateTime(
value: string | null | undefined,
options: FormatDateOptions = {},
): string {
if (!value) return options.fallback ?? ''
const parsed = parseDate(value)
if (!parsed) return resolveInvalid(value, options)
return parsed.toLocaleString(options.locale)
const resolved = resolveDate(value)
if (resolved.kind === 'missing') return options.fallback ?? ''
if (resolved.kind === 'invalid') return resolveInvalid(value ?? '', options)
return resolved.date.toLocaleString(options.locale)
}

export function formatDate(
value: string | null | undefined,
options: FormatDateOptions = {},
): string {
if (!value) return options.fallback ?? ''
const parsed = parseDate(value)
if (!parsed) return resolveInvalid(value, options)
return parsed.toLocaleDateString(options.locale)
const resolved = resolveDate(value)
if (resolved.kind === 'missing') return options.fallback ?? ''
if (resolved.kind === 'invalid') return resolveInvalid(value ?? '', options)
return resolved.date.toLocaleDateString(options.locale)
}

export function formatDateTimeSeconds(
value: string | null | undefined,
options: FormatDateOptions = {},
): string {
if (!value) return options.fallback ?? ''
const parsed = parseDate(value)
if (!parsed) return resolveInvalid(value, options)
const resolved = resolveDate(value)
if (resolved.kind === 'missing') return options.fallback ?? ''
if (resolved.kind === 'invalid') return resolveInvalid(value ?? '', options)
const parsed = resolved.date

const year = parsed.getFullYear()
const month = String(parsed.getMonth() + 1).padStart(2, '0')
Expand All @@ -70,10 +82,10 @@ export function formatDateTimeShort(
value: string | null | undefined,
options: FormatDateOptions = {},
): string {
if (!value) return options.fallback ?? ''
const parsed = parseDate(value)
if (!parsed) return resolveInvalid(value, options)
return parsed.toLocaleString(options.locale, {
const resolved = resolveDate(value)
if (resolved.kind === 'missing') return options.fallback ?? ''
if (resolved.kind === 'invalid') return resolveInvalid(value ?? '', options)
return resolved.date.toLocaleString(options.locale, {
month: 'short',
day: 'numeric',
hour: 'numeric',
Expand All @@ -97,9 +109,10 @@ export function formatCalendarTime(
value: string | null | undefined,
options: FormatDateOptions & { hour12?: boolean } = {},
): string {
if (!value) return options.fallback ?? ''
const parsed = parseDate(value)
if (!parsed) return resolveInvalid(value, options)
const resolved = resolveDate(value)
if (resolved.kind === 'missing') return options.fallback ?? ''
if (resolved.kind === 'invalid') return resolveInvalid(value ?? '', options)
const parsed = resolved.date

const hour12 = options.hour12 ?? true
const clock: Intl.DateTimeFormatOptions = {
Expand Down Expand Up @@ -139,9 +152,10 @@ export function formatRelativeTime(
value: string | Date | null | undefined,
options: FormatDateOptions = {},
): string {
if (!value) return options.fallback ?? ''
const date = value instanceof Date ? value : parseDate(value)
if (!date) return resolveInvalid(value as string, options)
const resolved = resolveDate(value)
if (resolved.kind === 'missing') return options.fallback ?? ''
if (resolved.kind === 'invalid') return resolveInvalid(String(value ?? ''), options)
const date = resolved.date

const diffMs = date.getTime() - Date.now()
const absDiffSec = Math.abs(diffMs) / 1000
Expand Down
Loading