TidGi-Desktop/src/services/git/index.ts
lin onetwo 7edb132d32
Fix/watch fs and ai commit (#674)
* fix: missing return

* feat: showApiKey

* feat: undo commit

* feat: amend commit

* fix: file name quoted in git log

* fix: wikiWorkspaceDefaultValues

* fix: no ai commit message sometimes

* Persist only non-default preferences to storage

Added a utility to store only preferences that differ from defaults, reducing storage size and improving config readability. Updated the setPreferences method to use this utility before saving preferences.

* fix: External Attachment Handling in fs plugin instead of ext-attachment-plugin to handle direct tag update case which won't trigger  th-saving-tiddler hook

* feat: api for plugin to create base64 file

* Show all untracked files and recreate Git history window

Updated git status commands to use '-uall' for displaying all untracked files, not just directories. Modified windowService.open calls for Git history to include the { recreate: true } option, ensuring the window is refreshed when opened from various menus.

* fix: handling of external attachments with _canonical_uri

Ensure tiddlers with _canonical_uri are always saved as .tid files, not as binary files, by forcing the .tid extension in FileSystemAdaptor. Update tests to verify this behavior. Also, skip loading files from the external attachments folder in loadWikiTiddlersWithSubWikis to prevent them from being loaded as separate tiddlers.

* Refactor external attachment utilities to module exports

Refactored externalAttachmentUtilities to use ES module exports instead of attaching functions to $tw.utils. Updated imports and mocks accordingly, removed related type definitions from ExtendedUtilities, and cleaned up obsolete meta file.

* disable enableFileSystemWatch to prevent bug for innocent users

* fix: test that requires enableFileSystemWatch use new step set to true

* Fix extension filter usage and sync workspace state after save

Refactored variable naming for extension filters in FileSystemAdaptor to improve clarity and fixed their usage in generateTiddlerFileInfo calls. Removed an unused import in routingUtilities.type.ts. Added a useEffect in useForm to sync workspace state with originalWorkspace after save, ensuring the save button disappears as expected.

* fix: review

* lint

* feat: unify AI commit entry points and add availability check  - Unified all AI commit message generation to use syncService.syncWikiIfNeeded() for consistent business logic handling - Added externalAPI.isAIAvailable() method to check if AI provider and model are properly configured - Updated gitService.isAIGenerateBackupTitleEnabled() to use the new availability check - Removed redundant logging code since generateFromAI() automatically logs to database when externalAPIDebug is enabled - Simplified menu item creation logic in menuItems.ts - Ensured AI menu options only appear when both API credentials and free model are configured - Updated documentation to reflect the unified architecture

* Improve AI commit message diff filtering and API checks

Renamed the AI commit message entry points doc for clarity. Enhanced the AI availability check to better handle provider API key requirements, including support for providers that do not require keys. Improved plugin diff filtering to retain small config file diffs while omitting large plugin file contents, optimizing AI token usage.

* Update wiki

* Refactor and enhance Tidgi mini window initialization and sync

Refactors Tidgi mini window startup to use a new initializeTidgiMiniWindow method, improving workspace selection logic and view management. Adds concurrency locks to prevent race conditions during open/close operations. Enhances workspace sync/fixed mode handling, view cleanup, and error logging. Updates interfaces and utilities to support new behaviors and improves robustness of tray icon creation and view realignment.

* Refactor file system sync to use $tw.syncer.syncFromServer()

Introduces FileSystemWatcher to monitor file changes and collect updates for the syncer, replacing direct wiki updates in WatchFileSystemAdaptor. Updates documentation to describe the new syncer-driven architecture, echo prevention, and event handling. WatchFileSystemAdaptor now delegates file change detection and lazy loading to FileSystemWatcher, improving batch change handling and eliminating echo loops.

* Improve logging and cleanup in file system watcher and git ops

Added detailed logging to WatchFileSystemAdaptor and FileSystemWatcher for better traceability during initialization and test stabilization. Introduced a constant for the temporary git index prefix in gitOperations. Removed the unused comparison.ts utility for tiddler comparison. Enhanced comments and logging for AI commit message generation context.

* Improve GitLog i18n test and config refresh logic

Updated gitLog.feature to use only Chinese selectors for actions, revert, and discard buttons, improving i18n test reliability. In FileSystemWatcher, re-fetch workspace config before checking enableFileSystemWatch to ensure latest settings are respected. In useGitLogData, prevent file-change events from overriding commit/undo events to maintain correct auto-selection behavior.

* Improve Git log selection and test stability

Refines auto-selection logic in the Git log window to better handle uncommitted changes, commits, reverts, and undos. Updates the feature test to explicitly verify selection and UI state after each operation, improving reliability. Removes unnecessary config re-fetch in FileSystemWatcher and enhances logging for more accurate DOM update detection.

* Implement workspace config sync via tidgi.config.json

Adds support for syncing workspace configuration to tidgi.config.json in the wiki folder, enabling settings persistence and migration across devices. Introduces new documentation, feature tests, and supporting utilities for config file reading, writing, migration, and validation. Updates step definitions and test helpers to support config sync scenarios, and refactors database config utilities for modularity.

* Improve workspace config handling and sync logic

Enhances workspace lookup in step definitions to check both settings.json and tidgi.config.json, ensuring properties are found even if moved. Updates tidgiConfig write logic to remove the config file if all values are default. Refactors workspace save logic to always write syncable config to tidgi.config.json for all wiki workspaces before removing those fields from settings.json, preventing config loss.

* Update .gitignore

* Update wiki.ts

* Add delay before waiting for git log render after revert

- Add 1 second wait after clearing git-log-data-rendered markers following revert
- This gives UI time to start refreshing before we check for the new marker
- Fixes CI timing issue where revert operation needs more time to trigger UI refresh

* Update test log markers for git log refresh events

Replaces '[test-id-git-log-data-rendered]' with '[test-id-git-log-refreshed]' in gitLog.feature to better reflect UI refresh events after commit and revert actions. Adds a debug log marker '[test-id-git-revert-complete]' in revertCommit for improved test synchronization.

* Fix git revert refresh timing - remove intermediate step and rely on git-log-refreshed

* Add detailed logging to handleRevert for CI debugging

* Fix git log refresh by adding manual triggerRefresh fallback

- Add triggerRefresh function to useGitLogData hook for manual refresh
- Call triggerRefresh in handleCommitSuccess, handleRevertSuccess, and handleUndoSuccess
- This fixes cross-process IPC observable subscription issues where gitStateChange$
  notifications from main process may not reach renderer process reliably
- Add detailed logging to handleRevert for CI debugging

* Update index.tsx
2026-01-10 23:57:59 +08:00

463 lines
20 KiB
TypeScript

import { createWorkerProxy } from '@services/libs/workerAdapter';
import { dialog, net } from 'electron';
import { getRemoteName, getRemoteUrl, GitStep, ModifiedFileList, stepsAboutChange } from 'git-sync-js';
import { inject, injectable } from 'inversify';
import { BehaviorSubject, Observer } from 'rxjs';
import { Worker } from 'worker_threads';
// @ts-expect-error - Vite worker import with ?nodeWorker query
import GitWorkerFactory from './gitWorker?nodeWorker';
import { LOCAL_GIT_DIRECTORY } from '@/constants/appPaths';
import { WikiChannel } from '@/constants/channels';
import type { IAuthenticationService, ServiceBranchTypes } from '@services/auth/interface';
import { container } from '@services/container';
import type { IExternalAPIService } from '@services/externalAPI/interface';
import { i18n } from '@services/libs/i18n';
import { logger } from '@services/libs/log';
import type { INativeService } from '@services/native/interface';
import type { IPreferenceService } from '@services/preferences/interface';
import serviceIdentifier from '@services/serviceIdentifier';
import type { IViewService } from '@services/view/interface';
import type { IWikiService } from '@services/wiki/interface';
import type { IWindowService } from '@services/windows/interface';
import { WindowNames } from '@services/windows/WindowProperties';
import { isWikiWorkspace, type IWorkspace } from '@services/workspaces/interface';
import * as gitOperations from './gitOperations';
import type { GitWorker } from './gitWorker';
import type { ICommitAndSyncConfigs, IForcePullConfigs, IGitLogMessage, IGitService, IGitStateChange, IGitUserInfos } from './interface';
import { registerMenu } from './registerMenu';
import { getErrorMessageI18NDict, translateMessage } from './translateMessage';
@injectable()
export class Git implements IGitService {
private gitWorker?: GitWorker;
private nativeWorker?: Worker;
public gitStateChange$ = new BehaviorSubject<IGitStateChange | undefined>(undefined);
constructor(
@inject(serviceIdentifier.Preference) private readonly preferenceService: IPreferenceService,
@inject(serviceIdentifier.Authentication) private readonly authService: IAuthenticationService,
@inject(serviceIdentifier.NativeService) private readonly nativeService: INativeService,
@inject(serviceIdentifier.Window) private readonly windowService: IWindowService,
) {}
private notifyGitStateChange(wikiFolderLocation: string, type: IGitStateChange['type']): void {
this.gitStateChange$.next({
timestamp: Date.now(),
wikiFolderLocation,
type,
});
}
/**
* Public method to notify file system changes
* Called by watch-fs plugin when files are modified
*/
public notifyFileChange(wikiFolderLocation: string, options?: { onlyWhenGitLogOpened?: boolean }): void {
const { onlyWhenGitLogOpened = true } = options ?? {};
// If we should only notify when git log is open, check if the window exists
if (onlyWhenGitLogOpened) {
const gitLogWindow = this.windowService.get(WindowNames.gitHistory);
// If no git log window is open, skip notification
if (!gitLogWindow) {
return;
}
}
this.notifyGitStateChange(wikiFolderLocation, 'file-change');
}
public async initialize(): Promise<void> {
await this.initWorker();
// Register menu items after initialization
void registerMenu();
}
private async initWorker(): Promise<void> {
process.env.LOCAL_GIT_DIRECTORY = LOCAL_GIT_DIRECTORY;
logger.debug(`Initializing gitWorker`, {
function: 'Git.initWorker',
LOCAL_GIT_DIRECTORY,
});
try {
// Use Vite's ?nodeWorker import instead of dynamic Worker path
const worker = (GitWorkerFactory as () => Worker)();
this.nativeWorker = worker;
this.gitWorker = createWorkerProxy<GitWorker>(worker);
logger.debug('gitWorker initialized successfully', { function: 'Git.initWorker' });
} catch (error) {
logger.error('Failed to initialize gitWorker', {
function: 'Git.initWorker',
error,
});
throw error;
}
}
public async getModifiedFileList(wikiFolderPath: string): Promise<ModifiedFileList[]> {
const list = await this.gitWorker?.getModifiedFileList(wikiFolderPath);
return list ?? [];
}
public async getWorkspacesRemote(wikiFolderPath?: string): Promise<string | undefined> {
if (!wikiFolderPath) return;
const branch = (await this.authService.get('git-branch' as ServiceBranchTypes)) ?? 'main';
const defaultRemoteName = (await getRemoteName(wikiFolderPath, branch)) ?? 'origin';
const remoteUrl = await getRemoteUrl(wikiFolderPath, defaultRemoteName);
return remoteUrl;
}
/**
* Update in-wiki settings for git. Only needed if the wiki is config to synced.
* @param {string} remoteUrl
*/
private async updateGitInfoTiddler(workspace: IWorkspace, remoteUrl?: string, branch?: string): Promise<void> {
// at least 'http://', but in some case it might be shorter, like 'a.b'
if (remoteUrl === undefined || remoteUrl.length < 3) return;
if (branch === undefined) return;
const viewService = container.get<IViewService>(serviceIdentifier.View);
const browserView = viewService.getView(workspace.id, WindowNames.main);
if (browserView === undefined) {
logger.error(`no browserView in updateGitInfoTiddler for ID ${workspace.id}`);
return;
}
// "/tiddly-gittly/TidGi-Desktop/issues/370"
const { pathname } = new URL(remoteUrl);
// [ "", "tiddly-gittly", "TidGi-Desktop", "issues", "370" ]
const [, userName, repoName] = pathname.split('/');
/**
* similar to "linonetwo/wiki", string after "https://com/"
*/
const githubRepoName = `${userName}/${repoName}`;
const wikiService = container.get<IWikiService>(serviceIdentifier.Wiki);
if (await wikiService.wikiOperationInServer(WikiChannel.getTiddlerText, workspace.id, ['$:/GitHub/Repo']) !== githubRepoName) {
await wikiService.wikiOperationInBrowser(WikiChannel.addTiddler, workspace.id, ['$:/GitHub/Repo', githubRepoName]);
}
if (await wikiService.wikiOperationInServer(WikiChannel.getTiddlerText, workspace.id, ['$:/GitHub/Branch']) !== branch) {
await wikiService.wikiOperationInBrowser(WikiChannel.addTiddler, workspace.id, ['$:/GitHub/Branch', branch]);
}
}
private popGitErrorNotificationToUser(step: GitStep, message: string): void {
if (step === GitStep.GitPushFailed && message.includes('403')) {
const windowService = container.get<IWindowService>(serviceIdentifier.Window);
const mainWindow = windowService.get(WindowNames.main);
if (mainWindow !== undefined) {
void dialog.showMessageBox(mainWindow, {
title: i18n.t('Log.GitTokenMissing'),
message: `${i18n.t('Log.GitTokenExpireOrWrong')} (${message})`,
buttons: ['OK'],
cancelId: 0,
defaultId: 0,
});
}
}
}
/**
* Handle common error dialog and message dialog
*/
private readonly getWorkerMessageObserver = (wikiFolderPath: string, resolve: () => void, reject: (error: Error) => void, workspaceID?: string): Observer<IGitLogMessage> => ({
next: (messageObject) => {
if (messageObject.level === 'error') {
const errorMessage = (messageObject.error).message;
// if workspace exists, show notification in workspace, else use dialog instead
if (workspaceID === undefined) {
this.createFailedDialog(errorMessage, wikiFolderPath);
} else {
this.createFailedNotification(errorMessage, workspaceID);
}
// Reject the promise on error to prevent service restart
reject(messageObject.error);
return;
}
const { message, meta, level } = messageObject;
if (typeof meta === 'object' && meta !== null && 'step' in meta) {
this.popGitErrorNotificationToUser((meta as { step: GitStep }).step, message);
}
logger.log(level, translateMessage(message), meta);
},
error: (error) => {
// this normally won't happen. And will become unhandled error. Because Observable error can't be catch, don't know why.
reject(error as Error);
},
complete: () => {
resolve();
},
});
private createFailedNotification(message: string, workspaceID: string) {
const wikiService = container.get<IWikiService>(serviceIdentifier.Wiki);
void wikiService.wikiOperationInBrowser(WikiChannel.generalNotification, workspaceID, [`${i18n.t('Log.SynchronizationFailed')} ${message}`]);
}
private createFailedDialog(message: string, wikiFolderPath: string): void {
const windowService = container.get<IWindowService>(serviceIdentifier.Window);
const mainWindow = windowService.get(WindowNames.main);
if (mainWindow !== undefined) {
void dialog
.showMessageBox(mainWindow, {
title: i18n.t('Log.SynchronizationFailed'),
message,
buttons: ['OK', 'Github Desktop'],
cancelId: 0,
defaultId: 1,
})
.then(async ({ response }) => {
if (response === 1) {
await this.nativeService.openInGitGuiApp(wikiFolderPath);
}
})
.catch((error: unknown) => {
logger.error('createFailedDialog failed', { error });
});
}
}
public async initWikiGit(wikiFolderPath: string, isSyncedWiki?: boolean, isMainWiki?: boolean, remoteUrl?: string, userInfo?: IGitUserInfos): Promise<void> {
const syncImmediately = !!isSyncedWiki && !!isMainWiki;
await new Promise<void>((resolve, reject) => {
this.gitWorker
?.initWikiGit(wikiFolderPath, getErrorMessageI18NDict(), syncImmediately && net.isOnline(), remoteUrl, userInfo)
.subscribe(this.getWorkerMessageObserver(wikiFolderPath, resolve, reject));
});
// Log for e2e test detection - indicates initial git setup and commits are complete
logger.debug(`[test-id-git-init-complete]`, { wikiFolderPath });
}
public async commitAndSync(workspace: IWorkspace, configs: ICommitAndSyncConfigs): Promise<boolean> {
// For commit-only operations (local workspace), we don't need network
// Only check network for sync operations
if (!configs.commitOnly && !net.isOnline()) {
// If not online and trying to sync, will not have any change
return false;
}
if (!isWikiWorkspace(workspace)) {
return false;
}
const workspaceIDToShowNotification = workspace.isSubWiki ? workspace.mainWikiID! : workspace.id;
try {
try {
await this.updateGitInfoTiddler(workspace, configs.remoteUrl, configs.userInfo?.branch);
} catch (error: unknown) {
logger.error('updateGitInfoTiddler failed when commitAndSync', { error });
}
// Generate AI commit message if not provided and settings allow
let finalConfigs = configs;
if (!configs.commitMessage) {
logger.debug('No commit message provided, attempting to generate AI commit message');
const { generateAICommitMessage } = await import('./aiCommitMessage');
// Determine source of the call for debugging
const source = configs.commitOnly ? 'backup' : 'sync';
const aiCommitMessage = await generateAICommitMessage(workspace.wikiFolderLocation, source);
if (aiCommitMessage) {
finalConfigs = { ...configs, commitMessage: aiCommitMessage };
logger.debug('Using AI-generated commit message', { commitMessage: aiCommitMessage, source });
} else {
// If AI generation fails or times out, use default message
logger.debug('AI commit message generation returned undefined, using default message', { source });
finalConfigs = { ...configs, commitMessage: i18n.t('LOG.CommitBackupMessage') };
}
} else {
logger.debug('Commit message already provided, skipping AI generation', { commitMessage: configs.commitMessage });
}
const observable = this.gitWorker?.commitAndSyncWiki(workspace, finalConfigs, getErrorMessageI18NDict());
const hasChanges = await this.getHasChangeHandler(observable, workspace.wikiFolderLocation, workspaceIDToShowNotification);
// Notify git state change
const changeType = configs.commitOnly ? 'commit' : 'sync';
this.notifyGitStateChange(workspace.wikiFolderLocation, changeType);
// Log for e2e test detection
logger.debug(`[test-id-git-${changeType}-complete]`, { wikiFolderLocation: workspace.wikiFolderLocation });
return hasChanges;
} catch (error: unknown) {
const error_ = error as Error;
this.createFailedNotification(error_.message, workspaceIDToShowNotification);
// Return false on sync failure - no successful changes were made
return false;
}
}
public async forcePull(workspace: IWorkspace, configs: IForcePullConfigs): Promise<boolean> {
if (!net.isOnline()) {
return false;
}
if (!isWikiWorkspace(workspace)) {
return false;
}
const workspaceIDToShowNotification = workspace.isSubWiki ? workspace.mainWikiID! : workspace.id;
const observable = this.gitWorker?.forcePullWiki(workspace, configs, getErrorMessageI18NDict());
const hasChanges = await this.getHasChangeHandler(observable, workspace.wikiFolderLocation, workspaceIDToShowNotification);
// Notify git state change
this.notifyGitStateChange(workspace.wikiFolderLocation, 'pull');
return hasChanges;
}
/**
* Handle methods that checks if there is any change. Return a promise that resolves to a "hasChanges" boolean, resolve on the observable completes.
* @param observable return by `this.gitWorker`'s methods.
* @returns the `hasChanges` result.
*/
private async getHasChangeHandler(
observable: ReturnType<GitWorker['commitAndSyncWiki']> | undefined,
wikiFolderPath: string,
workspaceID?: string,
) {
// return the `hasChanges` result.
return await new Promise<boolean>((resolve, reject) => {
if (!observable) {
resolve(false);
return;
}
let hasChanges = false;
observable.subscribe({
next: (messageObject: IGitLogMessage) => {
// Log the message
if (messageObject.level === 'error') {
const errorMessage = (messageObject.error).message;
// if workspace exists, show notification in workspace, else use dialog instead
if (workspaceID === undefined) {
this.createFailedDialog(errorMessage, wikiFolderPath);
} else {
this.createFailedNotification(errorMessage, workspaceID);
}
// Reject the promise on error to prevent service restart
reject(messageObject.error);
return;
}
const { message, meta, level } = messageObject;
if (typeof meta === 'object' && meta !== null && 'step' in meta) {
this.popGitErrorNotificationToUser((meta as { step: GitStep }).step, message);
// Check if this step indicates changes
if (stepsAboutChange.includes((meta as { step: GitStep }).step)) {
hasChanges = true;
}
}
logger.log(level, translateMessage(message), meta);
},
error: (error) => {
// this normally won't happen. And will become unhandled error. Because Observable error can't be catch, don't know why.
reject(error as Error);
},
complete: () => {
resolve(hasChanges);
},
});
});
}
public async clone(remoteUrl: string, repoFolderPath: string, userInfo: IGitUserInfos): Promise<void> {
if (!net.isOnline()) {
return;
}
await new Promise<void>((resolve, reject) => {
this.gitWorker?.cloneWiki(repoFolderPath, remoteUrl, userInfo, getErrorMessageI18NDict()).subscribe(this.getWorkerMessageObserver(repoFolderPath, resolve, reject));
});
}
public async syncOrForcePull(workspace: IWorkspace, configs: IForcePullConfigs & ICommitAndSyncConfigs): Promise<boolean> {
if (!isWikiWorkspace(workspace)) {
return false;
}
// if local is in readonly mode, any things that write to local (by accident) should be completely overwrite by remote.
if (workspace.readOnlyMode) {
return await this.forcePull(workspace, configs);
} else {
return await this.commitAndSync(workspace, configs);
}
}
/**
* Generic type-safe proxy method for git operations
* Uses conditional types and mapped types to ensure complete type safety
*/
public async callGitOp<K extends keyof typeof gitOperations>(
method: K,
...arguments_: Parameters<typeof gitOperations[K]>
): Promise<Awaited<ReturnType<typeof gitOperations[K]>>> {
const operation = gitOperations[method];
if (typeof operation !== 'function') {
throw new Error(`gitOperations.${method} is not a function`);
}
// Type assertion through unknown is necessary here because TypeScript cannot verify
// that the union type of all gitOperations functions matches the generic K constraint
return await (operation as unknown as (...arguments__: Parameters<typeof gitOperations[K]>) => ReturnType<typeof gitOperations[K]>)(...arguments_);
}
public async checkoutCommit(wikiFolderPath: string, commitHash: string): Promise<void> {
await this.callGitOp('checkoutCommit', wikiFolderPath, commitHash);
// Notify git state change
this.notifyGitStateChange(wikiFolderPath, 'checkout');
// Log for e2e test detection
logger.debug(`[test-id-git-checkout-complete]`, { wikiFolderPath, commitHash });
}
public async revertCommit(wikiFolderPath: string, commitHash: string, commitMessage?: string): Promise<void> {
try {
await this.callGitOp('revertCommit', wikiFolderPath, commitHash, commitMessage);
// Notify git state change BEFORE logging test marker
// This ensures the notification is sent before tests start waiting for UI refresh
this.notifyGitStateChange(wikiFolderPath, 'revert');
// Log for e2e test detection - only log after notification is sent
logger.debug(`[test-id-git-revert-complete]`, { wikiFolderPath, commitHash });
} catch (error) {
logger.error('revertCommit failed', { error, wikiFolderPath, commitHash, commitMessage });
throw error;
}
}
public async amendCommitMessage(wikiFolderPath: string, newMessage: string): Promise<void> {
try {
await this.callGitOp('amendCommitMessage', wikiFolderPath, newMessage);
// Notify git state change (commit list and hashes may change)
this.notifyGitStateChange(wikiFolderPath, 'commit');
} catch (error) {
logger.error('amendCommitMessage failed', { error, wikiFolderPath, newMessage });
throw error;
}
}
public async undoCommit(wikiFolderPath: string, commitHash: string): Promise<void> {
try {
await this.callGitOp('undoCommit', wikiFolderPath, commitHash);
// Notify git state change
this.notifyGitStateChange(wikiFolderPath, 'undo');
} catch (error) {
logger.error('undoCommit failed', { error, wikiFolderPath, commitHash });
throw error;
}
}
public async discardFileChanges(wikiFolderPath: string, filePath: string): Promise<void> {
await this.callGitOp('discardFileChanges', wikiFolderPath, filePath);
// Notify git state change
this.notifyGitStateChange(wikiFolderPath, 'discard');
}
public async addToGitignore(wikiFolderPath: string, pattern: string): Promise<void> {
await this.callGitOp('addToGitignore', wikiFolderPath, pattern);
// Notify git state change to refresh git log
this.notifyGitStateChange(wikiFolderPath, 'file-change');
}
public async isAIGenerateBackupTitleEnabled(): Promise<boolean> {
try {
const preferences = this.preferenceService.getPreferences();
if (!preferences.aiGenerateBackupTitle) {
return false;
}
const externalAPIService = container.get<IExternalAPIService>(serviceIdentifier.ExternalAPI);
return await externalAPIService.isAIAvailable();
} catch {
return false;
}
}
}