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
77 changes: 59 additions & 18 deletions apps/web/src/components/monaco-editor/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,21 @@ import 'monaco-editor/esm/vs/editor/contrib/stickyScroll/browser/stickyScrollCon
import { getLanguageByFilename } from '@/components/file-manager/utils'
import { installMinimapSurface, syncMinimapSurface } from './minimap-theme'

const MINIMAP_MIN_CONTAINER_WIDTH = 560

const props = withDefaults(defineProps<{
modelValue: string
language?: string
readonly?: boolean
filename?: string
active?: boolean
options?: Monaco.editor.IStandaloneEditorConstructionOptions
}>(), {
language: undefined,
readonly: false,
filename: undefined,
active: true,
options: undefined,
})

const emit = defineEmits<{
Expand All @@ -35,11 +39,30 @@ const editorFontSize = computed(() => settings.codeFontSizePx)
// Keep Monaco's built-in platform default font unless the user explicitly
// customizes the code font; `undefined` resets to the editor default.
const editorFontFamily = computed(() => settings.codeFontFamily ? settings.codeFontStack : undefined)
const isNarrowContainer = ref(false)
let heightObserver: MutationObserver | null = null
let resizeObserver: ResizeObserver | null = null
let themeFrame = 0
let themeDirtyWhileInactive = false
let mounted = false

function resolveMinimapOption(): Monaco.editor.IEditorMinimapOptions {
const callerMinimap = props.options?.minimap
if (callerMinimap?.enabled !== undefined) return callerMinimap
return { ...callerMinimap, enabled: !isNarrowContainer.value }
}

function buildRuntimeOptions(): Monaco.editor.IStandaloneEditorConstructionOptions {
return {
...props.options,
readOnly: props.readonly,
fontSize: editorFontSize.value,
fontFamily: editorFontFamily.value,
lineHeight: Math.round(editorFontSize.value * 1.7),
minimap: resolveMinimapOption(),
}
}

function resolveLanguage(): string {
if (props.language) return props.language
if (props.filename) return getLanguageByFilename(props.filename)
Expand Down Expand Up @@ -133,20 +156,13 @@ const {
} = useMonaco({
theme: resolveThemeName(),
themes: [settings.shikiThemeDark, settings.shikiThemeLight],
readOnly: props.readonly,
automaticLayout: true,
autoScrollInitial: false,
autoScrollOnUpdate: false,
minimap: { enabled: true },
// Pin the current heading / scope trail at the top while scrolling. Uses the
// document-symbol model, so it works for code out of the box and for Markdown via
// the heading provider registered in onBeforeCreate.
stickyScroll: { enabled: true },
onBeforeCreate: (monaco) => {
registerMarkdownHeadingSymbols(monaco as unknown as typeof Monaco)
installMinimapSurface(monaco as unknown as typeof Monaco, settings.resolvedColorMode, settings.colorScheme)
return []
},
scrollBeyondLastLine: true,
scrollbar: {
vertical: 'auto',
Expand All @@ -155,13 +171,6 @@ const {
horizontalScrollbarSize: 12,
useShadows: true,
},
fontSize: editorFontSize.value,
fontFamily: editorFontFamily.value,
// Monaco's computed default line box (~1.35×font) packs lines tight, and CJK
// glyphs (no descender, full em) read bottom-heavy inside it. A roomier
// explicit lineHeight (1.7×, matching our relaxed prose rhythm) spreads the
// air evenly above/below and makes consecutive lines distinguishable.
lineHeight: Math.round(editorFontSize.value * 1.7),
// Mono at 400 reads thin next to the ~420 Latin body; one step up keeps code
// legible without approaching bold-token territory (700).
fontWeight: '500',
Expand All @@ -170,6 +179,21 @@ const {
tabSize: 2,
wordWrap: 'on',
padding: { top: 8, bottom: 8 },
...props.options,
readOnly: props.readonly,
minimap: resolveMinimapOption(),
fontSize: editorFontSize.value,
fontFamily: editorFontFamily.value,
// Monaco's computed default line box (~1.35×font) packs lines tight, and CJK
// glyphs (no descender, full em) read bottom-heavy inside it. A roomier
// explicit lineHeight (1.7×, matching our relaxed prose rhythm) spreads the
// air evenly above/below and makes consecutive lines distinguishable.
lineHeight: Math.round(editorFontSize.value * 1.7),
onBeforeCreate: (monaco) => {
registerMarkdownHeadingSymbols(monaco as unknown as typeof Monaco)
installMinimapSurface(monaco as unknown as typeof Monaco, settings.resolvedColorMode, settings.colorScheme)
return []
},
})

function scheduleThemeSync() {
Expand Down Expand Up @@ -203,6 +227,20 @@ onMounted(async () => {
mounted = true
if (!editorRef.value) return

const initialWidth = editorRef.value.clientWidth
if (initialWidth > 0) {
isNarrowContainer.value = initialWidth < MINIMAP_MIN_CONTAINER_WIDTH
}
if (typeof ResizeObserver !== 'undefined') {
resizeObserver = new ResizeObserver((entries) => {
const width = entries[0]?.contentRect.width ?? editorRef.value?.clientWidth ?? 0
if (width > 0) {
isNarrowContainer.value = width < MINIMAP_MIN_CONTAINER_WIDTH
}
})
resizeObserver.observe(editorRef.value)
}

await createEditor(editorRef.value, props.modelValue, resolveLanguage())
if (!mounted || !editorRef.value) return

Expand All @@ -218,10 +256,7 @@ onMounted(async () => {
// Creation is asynchronous and the model-value watcher skips updates while
// there is no editor yet, so a value that changed meanwhile is applied here.
if (editor.getValue() !== props.modelValue) updateCode(props.modelValue, resolveLanguage())
editor.updateOptions({
fontSize: editorFontSize.value,
fontFamily: editorFontFamily.value,
})
editor.updateOptions(buildRuntimeOptions())
editor.setPosition({ lineNumber: 1, column: 1 })
editor.revealLine(1)
editor.onDidChangeModelContent(() => {
Expand All @@ -239,6 +274,8 @@ onBeforeUnmount(() => {
}
heightObserver?.disconnect()
heightObserver = null
resizeObserver?.disconnect()
resizeObserver = null
cleanupEditor()
})

Expand Down Expand Up @@ -273,6 +310,10 @@ watch(editorFontFamily, (fontFamily) => {
getEditorView()?.updateOptions({ fontFamily })
})

watch([() => props.options, isNarrowContainer], () => {
getEditorView()?.updateOptions(buildRuntimeOptions())
}, { deep: true })

watch([() => props.language, () => props.filename], () => {
setLanguage(resolveLanguage())
})
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/provider-icon/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
:height="numericSize"
:style="cssSize ? { width: cssSize, height: cssSize } : undefined"
alt=""
class="[color-scheme:light] dark:[color-scheme:dark]"
:class="['[color-scheme:light] dark:[color-scheme:dark]', monochrome && 'dark:invert']"
v-bind="$attrs"
@error="onImageError"
>
Expand Down
4 changes: 3 additions & 1 deletion apps/web/src/components/sidebar/panel-supermarket.vue
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@
v-else-if="appDependencyIconUrl(app)"
:src="appDependencyIconUrl(app)"
alt=""
class="size-5 object-contain"
:class="['size-5 object-contain', shouldInvertDarkIcon(appDependencyIconUrl(app)) && 'dark:invert']"
@load="handleDarkIconLoad($event)"
>
<SkillIcon v-else />
</div>
Expand Down Expand Up @@ -228,6 +229,7 @@ import { getBotsByBotIdApps, getSupermarketRegistriesByRegistryIdAppsByAppId, ty
import { appDisplayDescription, appDisplayName, appKey, botAppsQueryKey } from '@/composables/api/useApps'
import { useWorkspaceDependencyText } from '@/composables/useWorkspaceDependencyText'
import { resolveApiErrorMessage } from '@/utils/api-error'
import { handleDarkIconLoad, shouldInvertDarkIcon } from '@/utils/dark-icon-contrast'
import SkillIcon from '@/pages/supermarket/components/skill-icon.vue'
import InstallAppDialog from '@/pages/supermarket/components/install-app-dialog.vue'
import SidebarPanelHeader from './panel-header.vue'
Expand Down
3 changes: 2 additions & 1 deletion apps/web/src/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -972,7 +972,7 @@
"tagline": "Open-source multi-agent platform",
"description": "Multiple AI agents, each with its own computer and long-term memory.",
"updatesSection": "Updates",
"currentVersion": "Version v{version}",
"currentVersion": "Version {version}",
"checkHint": "Check GitHub for the latest release.",
"desktopCheckHint": "Check for a newer Desktop app version.",
"checkForUpdates": "Check for updates",
Expand Down Expand Up @@ -4094,6 +4094,7 @@
"repository": "Repository",
"revision": "Revision",
"installPreview": "Installing will",
"installPreviewSkill": "add {count} Skill to this bot | add {count} Skills to this bot",
"installPreviewDependency": "install into the workspace if missing",
"installPreviewPrerequisite": "required by {by}, installed first if missing",
"installPreviewConnector": "authorize during installation",
Expand Down
19 changes: 10 additions & 9 deletions apps/web/src/i18n/locales/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@
"acp_runtime_owner_missing": "この外部Agent Sessionには実行所有者がありません。新しいSessionを開始してください。",
"acp_runtime_start_failed": "外部Agent runtimeの起動に失敗しました。",
"agent": {
"chat_model_not_configured": "チャットモデルが選択されていません。Bot 設定 →「一般的な」でデフォルトのチャットモデルを設定してから、もう一度お試しください。",
"chat_model_not_configured": "チャットモデルが選択されていません。Bot 設定 →「一般」でデフォルトのチャットモデルを設定してから、もう一度お試しください。",
"provider_auth_failed": "モデルプロバイダーが認証情報を拒否しました。プロバイダーの API キーを確認してください。",
"provider_overloaded": "モデルプロバイダーは現在利用できないか、過負荷の状態です。しばらくしてからもう一度お試しください。",
"provider_permission_denied": "モデルプロバイダーがこのモデルまたはリソースへのアクセスを拒否しました。プロバイダーのアカウントがこのモデルを利用できるか確認してください。",
Expand Down Expand Up @@ -972,7 +972,7 @@
"tagline": "オープンソースのマルチエージェント プラットフォーム",
"description": "複数の AI エージェントが、それぞれ専用のコンピューターと長期記憶を持ちます。",
"updatesSection": "アップデート",
"currentVersion": "バージョン v{version}",
"currentVersion": "バージョン {version}",
"checkHint": "最新リリースについては GitHub を確認してください。",
"desktopCheckHint": "新しい Desktop バージョンを確認します。",
"checkForUpdates": "アップデートをチェックする",
Expand Down Expand Up @@ -1486,7 +1486,7 @@
"reasoningOff": "オフ",
"reasoningMinimal": "最小限",
"reasoningLow": "低い",
"reasoningMedium": "中くらい",
"reasoningMedium": "中",
"reasoningHigh": "高い",
"reasoningXHigh": "X-高い",
"reasoningMax": "マックス",
Expand Down Expand Up @@ -2746,10 +2746,10 @@
"configTitle": "構成",
"modelLabel": "Model",
"modelNone": "Modelが選択されていません",
"memoryLabel": "Memory",
"memoryLabel": "メモリ",
"memoryCount": "{count} Memoryのインデックス付け",
"memoryNone": "オフ",
"memoryTitle": "Memory",
"memoryTitle": "メモリ",
"memoryNoStats": "Memoryの統計はまだ取得できません。",
"usageTitle": "使用状況・過去30日間",
"usageTotal": "合計",
Expand All @@ -2771,7 +2771,7 @@
"advanced": "詳細設定",
"overviewSubtitle": "このBotがどこに存在し、どのように設定されているか。",
"overview": "概要",
"general": "一般的な",
"general": "一般",
"desktop": "Desktop",
"toolApproval": "Toolの承認",
"hooks": "Hooks",
Expand Down Expand Up @@ -3269,7 +3269,7 @@
"title": "リソース制限",
"subtitle": "セットCPUこのBot WorkspaceのMemory、ストレージの制限。空または 0 は無制限を意味します。",
"cpuLabel": "CPUコア",
"memoryLabel": "Memory (GiB)",
"memoryLabel": "メモリ (GiB)",
"storageLabel": "ストレージ (GiB)",
"cpuHint": "対応するコンテナおよび VM ランタイムでは、ハード上限として適用されます。",
"memoryHint": "対応するコンテナおよび VM ランタイムでは、ハード上限として適用されます。",
Expand Down Expand Up @@ -3360,7 +3360,7 @@
"searchProviderPlaceholder": "ウェブ検索を選択",
"fetchProvider": "ウェブフェッチ",
"fetchProviderPlaceholder": "Web フェッチを選択します",
"memory": "Memory",
"memory": "メモリ",
"memoryDescription": "Built-in Memoryで、会話をまたいで事実や好みを記憶します。",
"memoryMarkdownFiles": "マークダウンファイル",
"memoryGraphEdges": "グラフリンク",
Expand Down Expand Up @@ -4066,7 +4066,7 @@
"viewDetails": "詳細を見る",
"appInstallTitle": "App をインストール",
"loadError": "スーパーマーケットからの読み込みに失敗しました",
"submit": "送信",
"submit": "掲載申請",
"information": "情報",
"category": "カテゴリ",
"registry": "Registry",
Expand Down Expand Up @@ -4094,6 +4094,7 @@
"repository": "リポジトリ",
"revision": "リビジョン",
"installPreview": "インストールすると",
"installPreviewSkill": "スキルを {count} 件追加します",
"installPreviewDependency": "未インストールならワークスペースにインストールします",
"installPreviewPrerequisite": "{by} に必要です。未インストールなら先にインストールします",
"installPreviewConnector": "インストール中に認証",
Expand Down
5 changes: 3 additions & 2 deletions apps/web/src/i18n/locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -972,7 +972,7 @@
"tagline": "开源多智能体平台",
"description": "多个 AI Agent,各自拥有独立的电脑与长期记忆",
"updatesSection": "更新",
"currentVersion": "当前版本 v{version}",
"currentVersion": "当前版本 {version}",
"checkHint": "前往 GitHub 检查最新版本",
"desktopCheckHint": "检查是否有新的 Desktop 版本",
"checkForUpdates": "检查更新",
Expand Down Expand Up @@ -4042,7 +4042,7 @@
"colOutputTokens": "输出"
},
"supermarket": {
"title": "市场",
"title": "应用市场",
"searchPlaceholder": "搜索应用…",
"skillsSection": "Skills",
"noResults": "未找到结果",
Expand Down Expand Up @@ -4094,6 +4094,7 @@
"repository": "仓库",
"revision": "版本修订",
"installPreview": "安装将会",
"installPreviewSkill": "添加 {count} 个 Skill",
"installPreviewDependency": "缺失时安装到工作区",
"installPreviewPrerequisite": "{by} 需要,缺失时先安装",
"installPreviewConnector": "安装时授权",
Expand Down
3 changes: 2 additions & 1 deletion apps/web/src/pages/about/components/about-identity-card.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
size="sm"
class="font-medium"
>
{{ $t('settings.versionTag', { version }) }}
{{ isSemverVersion(version) ? $t('settings.versionTag', { version: normalizeVersion(version) }) : version }}
</Badge>
</div>
<p class="mt-0.5 text-[13px] leading-[18px] tracking-[-0.08px] font-[360] text-muted-foreground">
Expand Down Expand Up @@ -64,6 +64,7 @@
import type { Component } from 'vue'
import { BookOpen, Github, MessageSquare } from 'lucide-vue-next'
import { Badge, Button, SurfaceCard } from '@felinic/ui'
import { isSemverVersion, normalizeVersion } from '@/utils/version'

defineProps<{
/** Running version without the leading "v"; the badge is hidden when empty. */
Expand Down
18 changes: 10 additions & 8 deletions apps/web/src/pages/about/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
<DialogHeader>
<DialogTitle>{{ $t('about.updatesSection') }}</DialogTitle>
<DialogDescription>
{{ $t('about.currentVersion', { version: displayVersion || '—' }) }}
{{ $t('about.currentVersion', { version: formatVersionLabel(displayVersion) || '—' }) }}
</DialogDescription>
</DialogHeader>
<DialogBody>
Expand Down Expand Up @@ -253,6 +253,7 @@ import {
import { useDesktopUpdates } from '@/composables/useDesktopUpdates'
import { SettingsRow, SettingsSection } from '@felinic/ui'
import { resolveApiErrorMessage } from '@/utils/api-error'
import { formatVersionLabel, normalizeVersion } from '@/utils/version'
import { useCapabilitiesStore } from '@/store/capabilities'
import { useSettingsStore } from '@/store/settings'
import { useUpdateStore } from '@/store/update'
Expand Down Expand Up @@ -287,9 +288,9 @@ const actionPending = ref(false)

const capabilitiesStore = useCapabilitiesStore()
const { serverVersion, commitHash } = storeToRefs(capabilitiesStore)
const normalizedServerVersion = computed(() => (serverVersion.value ?? '').replace(/^v/i, ''))
const normalizedServerVersion = computed(() => normalizeVersion(serverVersion.value))
const displayVersion = computed(() => (
desktopUpdate.value?.currentVersion.replace(/^v/i, '')
normalizeVersion(desktopUpdate.value?.currentVersion)
|| normalizedServerVersion.value
))

Expand All @@ -306,18 +307,18 @@ const codeBlockTheme = computed(() => ({
const updateLabel = computed(() => {
if (desktopUpdates.value) {
const state = desktopUpdate.value
if (!state) return t('about.currentVersion', { version: displayVersion.value || '—' })
if (!state) return t('about.currentVersion', { version: formatVersionLabel(displayVersion.value) || '—' })
if (state.status === 'up-to-date') return t('about.upToDate')
if (state.status === 'installing') return t('about.applyingUpdate')
if (state.status === 'downloaded') return t('about.readyToRestart')
if (state.status === 'downloading') return t('about.updatingVersion', { version: state.latestVersion || '—' })
if (state.status === 'error') return t('about.desktopUpdateFailed')
if (state.status === 'unavailable') return t('about.desktopUpdatesUnavailable')
return t('about.currentVersion', { version: state.currentVersion })
return t('about.currentVersion', { version: formatVersionLabel(state.currentVersion) || '—' })
}
if (update.hasUpdate) return t('about.newVersionTitle', { version: update.latestVersion })
if (update.checked) return t('about.upToDate')
return t('about.currentVersion', { version: normalizedServerVersion.value || '—' })
return t('about.currentVersion', { version: formatVersionLabel(normalizedServerVersion.value) || '—' })
})
const updateDesc = computed(() => {
if (desktopUpdates.value) {
Expand All @@ -336,8 +337,9 @@ const updateDesc = computed(() => {
}
if (update.hasUpdate) return t('about.newVersionDesc')
if (update.checked) {
return normalizedServerVersion.value
? t('about.currentVersion', { version: normalizedServerVersion.value })
const version = formatVersionLabel(normalizedServerVersion.value)
return version
? t('about.currentVersion', { version })
: ''
}
return t('about.checkHint')
Expand Down
Loading
Loading