diff --git a/packages/backend/src/utils/podman.spec.ts b/packages/backend/src/utils/podman.spec.ts index a47bc4419..66bc9a012 100644 --- a/packages/backend/src/utils/podman.spec.ts +++ b/packages/backend/src/utils/podman.spec.ts @@ -16,7 +16,7 @@ * SPDX-License-Identifier: Apache-2.0 ***********************************************************************/ -import { beforeEach, expect, test, describe, vi } from 'vitest'; +import { beforeEach, expect, test, describe, vi, afterEach } from 'vitest'; import * as podmanDesktopApi from '@podman-desktop/api'; import * as utils from '../utils/podman'; import type { ContainerEngineInfo } from '@podman-desktop/api'; @@ -38,6 +38,7 @@ vi.mock('@podman-desktop/api', () => { return { env: { isWindows: false, + isLinux: false, }, configuration: { getConfiguration: () => config, @@ -330,6 +331,21 @@ describe('checkContainerConnectionStatusAndResources', () => { engineName: 'enginerName', engineType: 'podman', }; + afterEach(() => { + vi.mocked(podmanDesktopApi.env).isLinux = false; + }); + test('return native on Linux', async () => { + vi.mocked(podmanDesktopApi.env).isLinux = true; + vi.spyOn(utils, 'getFirstRunningPodmanConnection').mockReturnValue(undefined); + const result = await utils.checkContainerConnectionStatusAndResources({ + memoryNeeded: 10, + context: 'inference', + }); + expect(result).toStrictEqual({ + status: 'native', + canRedirect: true, + }); + }); test('return noMachineInfo if there is no running podman connection', async () => { vi.spyOn(utils, 'getFirstRunningPodmanConnection').mockReturnValue(undefined); const result = await utils.checkContainerConnectionStatusAndResources({ diff --git a/packages/backend/src/utils/podman.ts b/packages/backend/src/utils/podman.ts index 0ae61d46d..056abfb16 100644 --- a/packages/backend/src/utils/podman.ts +++ b/packages/backend/src/utils/podman.ts @@ -138,6 +138,16 @@ export async function isQEMUMachine(): Promise { export async function checkContainerConnectionStatusAndResources( modelInfo: ModelCheckerInfo, ): Promise { + // starting from podman desktop 1.10 we have the navigate functions + const hasNavigateFunction = !!navigation.navigateToResources; + + if (env.isLinux) { + return { + status: 'native', + canRedirect: hasNavigateFunction, + }; + } + let connection: ProviderContainerConnection | undefined = undefined; try { connection = getFirstRunningPodmanConnection(); @@ -145,9 +155,6 @@ export async function checkContainerConnectionStatusAndResources( console.log(String(e)); } - // starting from podman desktop 1.10 we have the navigate functions - const hasNavigateFunction = !!navigation.navigateToResources; - if (!connection) { return { status: 'no-machine', diff --git a/packages/frontend/src/lib/notification/ContainerConnectionStatusInfo.svelte b/packages/frontend/src/lib/notification/ContainerConnectionStatusInfo.svelte index 654dc3f0d..de95c7397 100644 --- a/packages/frontend/src/lib/notification/ContainerConnectionStatusInfo.svelte +++ b/packages/frontend/src/lib/notification/ContainerConnectionStatusInfo.svelte @@ -16,6 +16,10 @@ let actionName: string | undefined = ''; $: updateTitleDescription(connectionInfo); function updateTitleDescription(connectionInfo: ContainerConnectionInfo) { + if (connectionInfo.status === 'native') { + return; + } + if (connectionInfo.status === 'no-machine') { title = 'No Podman Machine is running'; description = 'Please start a Podman Machine before proceeding further.'; diff --git a/packages/shared/src/models/IContainerConnectionInfo.ts b/packages/shared/src/models/IContainerConnectionInfo.ts index 723214d3b..375673734 100644 --- a/packages/shared/src/models/IContainerConnectionInfo.ts +++ b/packages/shared/src/models/IContainerConnectionInfo.ts @@ -19,7 +19,8 @@ export type ContainerConnectionInfo = | RunningContainerConnection | LowResourcesContainerConnection - | NoContainerConnection; + | NoContainerConnection + | NativeContainerConnection; export type ContainerConnectionInfoStatus = 'running' | 'no-machine' | 'low-resources'; @@ -44,3 +45,8 @@ export interface NoContainerConnection { status: 'no-machine'; canRedirect: boolean; } + +export interface NativeContainerConnection { + status: 'native'; + canRedirect: boolean; +}