Skip to content
Draft
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
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<template>
<div
ref="rootEl"
class="relative overflow-hidden h-full w-full bg-neutral-900"
class="relative h-full w-full overflow-hidden bg-neutral-900"
>
<div class="p-terminal rounded-none h-full w-full p-2">
<div ref="terminalEl" class="h-full terminal-host" />
<div class="p-terminal h-full w-full rounded-none p-2">
<div ref="terminalEl" class="terminal-host h-full" />
</div>
<Button
v-tooltip.left="{
Expand All @@ -26,6 +26,7 @@
</template>

<script setup lang="ts">
import { isDesktop } from '@frontend/platform/distribution/types'
import { useElementHover, useEventListener } from '@vueuse/core'
import type { IDisposable } from '@xterm/xterm'
import Button from 'primevue/button'
Expand All @@ -34,7 +35,7 @@ import { computed, onMounted, onUnmounted, ref } from 'vue'
import { useI18n } from 'vue-i18n'

import { useTerminal } from '@/composables/bottomPanelTabs/useTerminal'
import { electronAPI, isElectron } from '@/utils/envUtil'
import { electronAPI } from '@/utils/envUtil'
import { cn } from '@/utils/tailwindUtil'

const { t } = useI18n()
Expand Down Expand Up @@ -84,7 +85,7 @@ const showContextMenu = (event: MouseEvent) => {
electronAPI()?.showContextMenu({ type: 'text' })
}

if (isElectron()) {
if (isDesktop) {
useEventListener(terminalEl, 'contextmenu', showContextMenu)
}

Expand Down
4 changes: 2 additions & 2 deletions apps/desktop-ui/src/router.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { isDesktop } from '@frontend/platform/distribution/types'
import {
createRouter,
createWebHashHistory,
createWebHistory
} from 'vue-router'

import { isElectron } from '@/utils/envUtil'
import LayoutDefault from '@/views/layouts/LayoutDefault.vue'

const isFileProtocol = window.location.protocol === 'file:'
const basePath = isElectron() ? '/' : window.location.pathname
const basePath = isDesktop ? '/' : window.location.pathname

const router = createRouter({
history: isFileProtocol ? createWebHashHistory() : createWebHistory(basePath),
Expand Down
14 changes: 1 addition & 13 deletions apps/desktop-ui/src/utils/envUtil.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1 @@
import type { ElectronAPI } from '@comfyorg/comfyui-electron-types'

export function isElectron() {
return 'electronAPI' in window && window.electronAPI !== undefined
}

export function electronAPI() {
return (window as any).electronAPI as ElectronAPI
}

export function isNativeWindow() {
return isElectron() && !!window.navigator.windowControlsOverlay?.visible
}
export { electronAPI, isNativeWindow } from '@frontend/utils/envUtil'
15 changes: 8 additions & 7 deletions apps/desktop-ui/src/views/templates/BaseViewTemplate.vue
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
<template>
<div
class="font-sans w-screen h-screen flex flex-col"
class="flex h-screen w-screen flex-col font-sans"
:class="[
dark
? 'text-neutral-300 bg-neutral-900 dark-theme'
: 'text-neutral-900 bg-neutral-300'
? 'dark-theme bg-neutral-900 text-neutral-300'
: 'bg-neutral-300 text-neutral-900'
]"
>
<!-- Virtual top menu for native window (drag handle) -->
<div
v-show="isNativeWindow()"
ref="topMenuRef"
class="app-drag w-full h-(--comfy-topbar-height)"
class="app-drag h-(--comfy-topbar-height) w-full"
/>
<div class="grow w-full flex items-center justify-center overflow-auto">
<div class="flex w-full grow items-center justify-center overflow-auto">
<slot />
</div>
</div>
</template>

<script setup lang="ts">
import { isDesktop } from '@frontend/platform/distribution/types'
import { nextTick, onMounted, ref } from 'vue'

import { electronAPI, isElectron, isNativeWindow } from '../../utils/envUtil'
import { electronAPI, isNativeWindow } from '../../utils/envUtil'

const { dark = false } = defineProps<{
dark?: boolean
Expand All @@ -40,7 +41,7 @@ const lightTheme = {

const topMenuRef = ref<HTMLDivElement | null>(null)
onMounted(async () => {
if (isElectron()) {
if (isDesktop) {
await nextTick()

electronAPI().changeTheme({
Expand Down
1 change: 1 addition & 0 deletions apps/desktop-ui/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"baseUrl": ".",
"paths": {
"@/*": ["src/*"],
"@frontend/*": ["../../src/*"],
"@frontend-locales/*": ["../../src/locales/*"]
}
},
Expand Down
1 change: 1 addition & 0 deletions apps/desktop-ui/vite.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export default defineConfig(() => {
resolve: {
alias: {
'@': path.resolve(projectRoot, 'src'),
'@frontend': path.resolve(projectRoot, '../../src'),
'@frontend-locales': path.resolve(projectRoot, '../../src/locales')
}
},
Expand Down
5 changes: 3 additions & 2 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ import { computed, onMounted } from 'vue'

import GlobalDialog from '@/components/dialog/GlobalDialog.vue'
import config from '@/config'
import { isDesktop } from '@/platform/distribution/types'
import { useWorkspaceStore } from '@/stores/workspaceStore'
import { useConflictDetection } from '@/workbench/extensions/manager/composables/useConflictDetection'

import { electronAPI, isElectron } from './utils/envUtil'
import { electronAPI } from './utils/envUtil'

const workspaceStore = useWorkspaceStore()
const conflictDetection = useConflictDetection()
Expand All @@ -45,7 +46,7 @@ onMounted(() => {
// @ts-expect-error fixme ts strict error
window['__COMFYUI_FRONTEND_VERSION__'] = config.app_version

if (isElectron()) {
if (isDesktop) {
document.addEventListener('contextmenu', showContextMenu)
}

Expand Down
5 changes: 3 additions & 2 deletions src/components/bottomPanel/tabs/terminal/BaseTerminal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
class="relative h-full w-full overflow-hidden bg-neutral-900"
>
<div class="p-terminal h-full w-full rounded-none p-2">
<div ref="terminalEl" class="terminal-host h-full" />

Check failure on line 7 in src/components/bottomPanel/tabs/terminal/BaseTerminal.vue

View workflow job for this annotation

GitHub Actions / test

tests-ui/tests/components/bottomPanel/tabs/terminal/BaseTerminal.test.ts

Error: [vitest] There was an error when mocking a module. If you are using "vi.mock" factory, make sure there are no top level variables inside, since this call is hoisted to top of the file. Read more: https://vitest.dev/api/vi.html#vi-mock ❯ src/components/bottomPanel/tabs/terminal/BaseTerminal.vue:7:31 Caused by: Caused by: ReferenceError: Cannot access 'distributionMock' before initialization ❯ tests-ui/tests/components/bottomPanel/tabs/terminal/BaseTerminal.test.ts:60:48 ❯ src/components/bottomPanel/tabs/terminal/BaseTerminal.vue:7:31
</div>
<Button
v-tooltip.left="{
Expand Down Expand Up @@ -34,7 +34,8 @@
import { useI18n } from 'vue-i18n'

import { useTerminal } from '@/composables/bottomPanelTabs/useTerminal'
import { electronAPI, isElectron } from '@/utils/envUtil'
import { isDesktop } from '@/platform/distribution/types'
import { electronAPI } from '@/utils/envUtil'
import { cn } from '@/utils/tailwindUtil'

const { t } = useI18n()
Expand Down Expand Up @@ -84,7 +85,7 @@
electronAPI()?.showContextMenu({ type: 'text' })
}

if (isElectron()) {
if (isDesktop) {
useEventListener(terminalEl, 'contextmenu', showContextMenu)
}

Expand Down
4 changes: 2 additions & 2 deletions src/components/dialog/content/MissingModelsWarning.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</div>
<ListBox :options="missingModels" class="comfy-missing-models">
<template #option="{ option }">
<Suspense v-if="isElectron()">
<Suspense v-if="isDesktop">
<ElectronFileDownload
:url="option.url"
:label="option.label"
Expand All @@ -39,8 +39,8 @@ import { useI18n } from 'vue-i18n'
import ElectronFileDownload from '@/components/common/ElectronFileDownload.vue'
import FileDownload from '@/components/common/FileDownload.vue'
import NoResultsPlaceholder from '@/components/common/NoResultsPlaceholder.vue'
import { isDesktop } from '@/platform/distribution/types'
import { useSettingStore } from '@/platform/settings/settingStore'
import { isElectron } from '@/utils/envUtil'

// TODO: Read this from server internal API rather than hardcoding here
// as some installations may wish to use custom sources
Expand Down
16 changes: 8 additions & 8 deletions src/components/helpcenter/HelpCenterMenuContent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,12 @@ import type { CSSProperties, Component } from 'vue'
import { useI18n } from 'vue-i18n'

import PuzzleIcon from '@/components/icons/PuzzleIcon.vue'
import { isCloud } from '@/platform/distribution/types'
import { isCloud, isDesktop } from '@/platform/distribution/types'
import { useSettingStore } from '@/platform/settings/settingStore'
import type { ReleaseNote } from '@/platform/updates/common/releaseService'
import { useReleaseStore } from '@/platform/updates/common/releaseStore'
import { useCommandStore } from '@/stores/commandStore'
import { electronAPI, isElectron } from '@/utils/envUtil'
import { electronAPI } from '@/utils/envUtil'
import { formatVersionAnchor } from '@/utils/formatUtil'
import { useConflictAcknowledgment } from '@/workbench/extensions/manager/composables/useConflictAcknowledgment'
import { useManagerState } from '@/workbench/extensions/manager/composables/useManagerState'
Expand Down Expand Up @@ -216,7 +216,7 @@ const moreItems = computed<MenuItem[]>(() => {
key: 'desktop-guide',
type: 'item',
label: t('helpCenter.desktopUserGuide'),
visible: isElectron(),
visible: isDesktop,
action: () => {
const docsUrl =
electronAPI().getPlatform() === 'darwin'
Expand All @@ -230,7 +230,7 @@ const moreItems = computed<MenuItem[]>(() => {
key: 'dev-tools',
type: 'item',
label: t('helpCenter.openDevTools'),
visible: isElectron(),
visible: isDesktop,
action: () => {
openDevTools()
emit('close')
Expand All @@ -239,13 +239,13 @@ const moreItems = computed<MenuItem[]>(() => {
{
key: 'divider-1',
type: 'divider',
visible: isElectron()
visible: isDesktop
},
{
key: 'reinstall',
type: 'item',
label: t('helpCenter.reinstall'),
visible: isElectron(),
visible: isDesktop,
action: () => {
onReinstall()
emit('close')
Expand Down Expand Up @@ -484,13 +484,13 @@ const onSubmenuLeave = (): void => {
}

const openDevTools = (): void => {
if (isElectron()) {
if (isDesktop) {
electronAPI().openDevTools()
}
}

const onReinstall = (): void => {
if (isElectron()) {
if (isDesktop) {
void electronAPI().reinstall()
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/sidebar/tabs/ModelLibrarySidebarTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
/>
</template>
<template #body>
<ElectronDownloadItems v-if="isElectron()" />
<ElectronDownloadItems v-if="isDesktop" />

<TreeExplorer
v-model:expanded-keys="expandedKeys"
Expand All @@ -54,13 +54,13 @@ import SidebarTabTemplate from '@/components/sidebar/tabs/SidebarTabTemplate.vue
import ElectronDownloadItems from '@/components/sidebar/tabs/modelLibrary/ElectronDownloadItems.vue'
import ModelTreeLeaf from '@/components/sidebar/tabs/modelLibrary/ModelTreeLeaf.vue'
import { useTreeExpansion } from '@/composables/useTreeExpansion'
import { isDesktop } from '@/platform/distribution/types'
import { useSettingStore } from '@/platform/settings/settingStore'
import { useLitegraphService } from '@/services/litegraphService'
import type { ComfyModelDef, ModelFolder } from '@/stores/modelStore'
import { ResourceState, useModelStore } from '@/stores/modelStore'
import { useModelToNodeStore } from '@/stores/modelToNodeStore'
import type { TreeExplorerNode, TreeNode } from '@/types/treeExplorerTypes'
import { isElectron } from '@/utils/envUtil'
import { buildTree } from '@/utils/treeUtil'

const modelStore = useModelStore()
Expand Down
4 changes: 1 addition & 3 deletions src/components/topbar/WorkflowTabs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ import { useI18n } from 'vue-i18n'

import WorkflowTab from '@/components/topbar/WorkflowTab.vue'
import { useOverflowObserver } from '@/composables/element/useOverflowObserver'
import { isDesktop } from '@/platform/distribution/types'
import { useWorkflowService } from '@/platform/workflow/core/services/workflowService'
import type { ComfyWorkflow } from '@/platform/workflow/management/stores/workflowStore'
import {
Expand All @@ -87,7 +88,6 @@ import {
} from '@/platform/workflow/management/stores/workflowStore'
import { useCommandStore } from '@/stores/commandStore'
import { useWorkspaceStore } from '@/stores/workspaceStore'
import { isElectron } from '@/utils/envUtil'
import { whileMouseDown } from '@/utils/mouseDownUtil'

import WorkflowOverflowMenu from './WorkflowOverflowMenu.vue'
Expand All @@ -114,8 +114,6 @@ const showOverflowArrows = ref(false)
const leftArrowEnabled = ref(false)
const rightArrowEnabled = ref(false)

const isDesktop = isElectron()

const workflowToOption = (workflow: ComfyWorkflow): WorkflowOption => ({
value: workflow.path,
workflow
Expand Down
4 changes: 2 additions & 2 deletions src/composables/sidebarTabs/useModelLibrarySidebarTab.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { markRaw } from 'vue'

import ModelLibrarySidebarTab from '@/components/sidebar/tabs/ModelLibrarySidebarTab.vue'
import { isDesktop } from '@/platform/distribution/types'
import { useElectronDownloadStore } from '@/stores/electronDownloadStore'
import type { SidebarTabExtension } from '@/types/extensionTypes'
import { isElectron } from '@/utils/envUtil'

export const useModelLibrarySidebarTab = (): SidebarTabExtension => {
return {
Expand All @@ -15,7 +15,7 @@ export const useModelLibrarySidebarTab = (): SidebarTabExtension => {
component: markRaw(ModelLibrarySidebarTab),
type: 'vue',
iconBadge: () => {
if (isElectron()) {
if (isDesktop) {
const electronDownloadStore = useElectronDownloadStore()
if (electronDownloadStore.inProgressDownloads.length > 0) {
return electronDownloadStore.inProgressDownloads.length.toString()
Expand Down
5 changes: 3 additions & 2 deletions src/extensions/core/electronAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ import log from 'loglevel'

import { PYTHON_MIRROR } from '@/constants/uvMirrors'
import { t } from '@/i18n'
import { isDesktop } from '@/platform/distribution/types'
import { useToastStore } from '@/platform/updates/common/toastStore'
import { useWorkflowStore } from '@/platform/workflow/management/stores/workflowStore'
import { app } from '@/scripts/app'
import { useDialogService } from '@/services/dialogService'
import { checkMirrorReachable } from '@/utils/electronMirrorCheck'
import { electronAPI as getElectronAPI, isElectron } from '@/utils/envUtil'
import { electronAPI as getElectronAPI } from '@/utils/envUtil'

// Desktop documentation URLs
const DESKTOP_DOCS = {
Expand All @@ -16,7 +17,7 @@ const DESKTOP_DOCS = {
} as const

;(async () => {
if (!isElectron()) return
if (!isDesktop) return

const electronAPI = getElectronAPI()
const desktopAppVersion = await electronAPI.getElectronVersion()
Expand Down
6 changes: 3 additions & 3 deletions src/platform/settings/composables/useSettingUI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import type { Component } from 'vue'
import { useI18n } from 'vue-i18n'

import { useCurrentUser } from '@/composables/auth/useCurrentUser'
import { isDesktop } from '@/platform/distribution/types'
import type { SettingTreeNode } from '@/platform/settings/settingStore'
import { useSettingStore } from '@/platform/settings/settingStore'
import type { SettingParams } from '@/platform/settings/types'
import { isElectron } from '@/utils/envUtil'
import { normalizeI18nKey } from '@/utils/formatUtil'
import { buildTree } from '@/utils/treeUtil'

Expand Down Expand Up @@ -129,7 +129,7 @@ export function useSettingUI(
userPanel,
keybindingPanel,
extensionPanel,
...(isElectron() ? [serverConfigPanel] : [])
...(isDesktop ? [serverConfigPanel] : [])
].filter((panel) => panel.component)
)

Expand Down Expand Up @@ -178,7 +178,7 @@ export function useSettingUI(
keybindingPanel.node,
extensionPanel.node,
aboutPanel.node,
...(isElectron() ? [serverConfigPanel.node] : [])
...(isDesktop ? [serverConfigPanel.node] : [])
].map(translateCategory)
}
])
Expand Down
Loading
Loading