Refactor Tidgi mini window initialization logic

Tidgi mini window creation now only creates the window; view creation is deferred to initializeAllWorkspaceView. Updated related comments and logging for clarity. Also fixed formatting in French translations and improved documentation for error handling during release.
This commit is contained in:
lin onetwo 2026-01-21 23:16:48 +08:00
parent fbb75a2404
commit c8212dca9b
5 changed files with 14 additions and 51 deletions

View file

@ -13,5 +13,6 @@ Solution: kill background **esbuild** process
```powershell
Get-Process | Where-Object { $_.ProcessName -match "esbuild|electron" } | Stop-Process -Force
Remove-Item "$env:TEMP\si-*" -Recurse -Force -ErrorAction SilentlyContinue
Start-Sleep -Seconds 2
```
Also check if there are open explorer folder opened, close may help.

View file

@ -294,7 +294,9 @@
"ImageNotAvailable": "Image non disponible",
"InfiniteScroll": "chargement en défilement",
"LoadingFull": "Chargement en cours...",
"LoadingMore": "Charger plus...", "LoadingWorkspace": "Chargement de l'espace de travail...", "Message": "soumettre les informations",
"LoadingMore": "Charger plus...",
"LoadingWorkspace": "Chargement de l'espace de travail...",
"Message": "soumettre les informations",
"MessageSearch": "soumettre les informations",
"NewImage": "Nouvelle image (ajoutée lors de cette soumission)",
"NoCommits": "Aucun enregistrement soumis",

View file

@ -148,12 +148,13 @@ const commonInit = async (): Promise<void> => {
await wikiGitWorkspaceService.initialize();
// Create default page workspaces before initializing all workspace views
await workspaceService.initializeDefaultPageWorkspaces();
// Initialize tidgi mini window if enabled (must be done BEFORE initializeAllWorkspaceView)
// because initializeAllWorkspaceView will try to create views for tidgi mini window
// This only creates the window, views will be created by initializeAllWorkspaceView
await windowService.initializeTidgiMiniWindow();
// perform wiki startup and git sync for each workspace
// This will also create views for tidgi mini window (in addViewForAllBrowserViews)
await workspaceViewService.initializeAllWorkspaceView();
logger.info('[test-id-ALL_WORKSPACE_VIEW_INITIALIZED] All workspace views initialized');

View file

@ -86,8 +86,7 @@ export const ErrorMessageRenderer: React.FC<MessageRendererProps> = ({ message }
};
// Check if this is a provider-related error that could be fixed in settings
const isSettingsFixableError =
['MissingConfigError', 'MissingProviderError', 'AuthenticationError', 'MissingAPIKeyError', 'MissingBaseURLError'].includes(errorName) ||
const isSettingsFixableError = ['MissingConfigError', 'MissingProviderError', 'AuthenticationError', 'MissingAPIKeyError', 'MissingBaseURLError'].includes(errorName) ||
['NO_DEFAULT_MODEL', 'PROVIDER_NOT_FOUND', 'AUTHENTICATION_FAILED', 'MISSING_API_KEY', 'MISSING_BASE_URL'].includes(errorCode);
return (

View file

@ -501,7 +501,7 @@ export class Window implements IWindowService {
/**
* Initialize tidgi mini window on app startup.
* Creates window, determines target workspace based on preferences, and sets up view.
* Only creates the window, views will be created later by initializeAllWorkspaceView.
*/
public async initializeTidgiMiniWindow(): Promise<void> {
const tidgiMiniWindowEnabled = await this.preferenceService.get('tidgiMiniWindow');
@ -510,50 +510,10 @@ export class Window implements IWindowService {
return;
}
// Create the window but don't show it yet
// Only create the window but don't create views yet
// Views will be created by initializeAllWorkspaceView -> addViewForAllBrowserViews
await this.openTidgiMiniWindow(true, false);
// Determine which workspace to show based on preferences (sync vs fixed)
const { shouldSync, targetWorkspaceId } = await getTidgiMiniWindowTargetWorkspace();
if (!targetWorkspaceId) {
logger.info('No target workspace for tidgi mini window (sync disabled and no fixed workspace selected)', { function: 'initializeTidgiMiniWindow' });
return;
}
const workspaceService = container.get<IWorkspaceService>(serviceIdentifier.Workspace);
const targetWorkspace = await workspaceService.get(targetWorkspaceId);
if (!targetWorkspace || targetWorkspace.pageType) {
// Skip page workspaces (like Agent) - they don't have browser views
logger.debug('Target workspace is a page type or not found, skipping view creation', {
function: 'initializeTidgiMiniWindow',
targetWorkspaceId,
isPageType: targetWorkspace?.pageType,
});
return;
}
// Create view for the target workspace
const viewService = container.get<IViewService>(serviceIdentifier.View);
const existingView = viewService.getView(targetWorkspace.id, WindowNames.tidgiMiniWindow);
if (!existingView) {
logger.info('Creating tidgi mini window view for target workspace', {
function: 'initializeTidgiMiniWindow',
workspaceId: targetWorkspace.id,
shouldSync,
});
await viewService.addView(targetWorkspace, WindowNames.tidgiMiniWindow);
}
// Realign to ensure view is properly positioned
logger.info('Realigning workspace view for tidgi mini window after initialization', {
function: 'initializeTidgiMiniWindow',
workspaceId: targetWorkspace.id,
shouldSync,
});
await container.get<IWorkspaceViewService>(serviceIdentifier.WorkspaceView).realignActiveWorkspace(targetWorkspace.id);
logger.debug('TidGi mini window created, views will be initialized by initializeAllWorkspaceView', { function: 'initializeTidgiMiniWindow' });
}
public async updateWindowProperties(windowName: WindowNames, properties: { alwaysOnTop?: boolean }): Promise<void> {