chore: refine Next.js configuration and improve error handling
- Simplified the Next.js webpack configuration to apply raw-loader for markdown files universally. - Updated build script in package.json to ensure webpack is used during the build process. - Enhanced error logging across various hooks to provide clearer messages when exceptions occur, improving debugging capabilities.
This commit is contained in:
1 parent
655d9c1b45
commit
55749c07e3
12 files changed
+43
-36
No files matched your search
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"version": "0.1.0",
|
||||||
|
"generatedAt": "2025-11-28T03:22:48.992Z",
|
||||||
|
"releases": []
|
||||||
|
}
|
||||||
@@ -87,23 +87,18 @@ export function useAppUpdater(): AppUpdaterState {
|
|||||||
const update = await checkForUpdate();
|
const update = await checkForUpdate();
|
||||||
|
|
||||||
if (update?.available) {
|
if (update?.available) {
|
||||||
// Escutar progresso do download
|
|
||||||
const unlisten = await update.on('download-progress', (progress: any) => {
|
|
||||||
setDownloadProgress(progress.progress || 0);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Baixar e instalar atualização
|
// Baixar e instalar atualização
|
||||||
|
// O progresso pode ser monitorado via eventos do Tauri se necessário
|
||||||
await update.downloadAndInstall();
|
await update.downloadAndInstall();
|
||||||
|
|
||||||
unlisten();
|
// Após downloadAndInstall(), o app será reiniciado automaticamente
|
||||||
|
// Não é necessário chamar installAndRestart() que não existe na API
|
||||||
// Reiniciar aplicativo após instalação
|
|
||||||
await update.installAndRestart();
|
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Failed to install update:', err);
|
console.error('Failed to install update:', err);
|
||||||
setError(err instanceof Error ? err.message : 'Erro ao instalar atualização');
|
setError(err instanceof Error ? err.message : 'Erro ao instalar atualização');
|
||||||
setIsDownloading(false);
|
setIsDownloading(false);
|
||||||
|
setDownloadProgress(0);
|
||||||
}
|
}
|
||||||
}, [updateAvailable]);
|
}, [updateAvailable]);
|
||||||
|
|
||||||
|
|||||||
@@ -392,7 +392,7 @@ export function useChatStorage() {
|
|||||||
const keywords = Array.isArray(msg.metadata.keywords)
|
const keywords = Array.isArray(msg.metadata.keywords)
|
||||||
? msg.metadata.keywords
|
? msg.metadata.keywords
|
||||||
: [];
|
: [];
|
||||||
memoryContext.push(...keywords.filter(k => typeof k === 'string'));
|
memoryContext.push(...keywords.filter((k: unknown) => typeof k === 'string'));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const uniqueMemoryContext = Array.from(new Set(memoryContext));
|
const uniqueMemoryContext = Array.from(new Set(memoryContext));
|
||||||
@@ -457,7 +457,7 @@ export function useChatStorage() {
|
|||||||
const keywords = Array.isArray(msg.metadata.keywords)
|
const keywords = Array.isArray(msg.metadata.keywords)
|
||||||
? msg.metadata.keywords
|
? msg.metadata.keywords
|
||||||
: [];
|
: [];
|
||||||
memoryContext.push(...keywords.filter(k => typeof k === 'string'));
|
memoryContext.push(...keywords.filter((k: unknown) => typeof k === 'string'));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// Deduplicate
|
// Deduplicate
|
||||||
|
|||||||
@@ -195,7 +195,7 @@ export function useDeepResearch() {
|
|||||||
setState(s => ({ ...s, context }));
|
setState(s => ({ ...s, context }));
|
||||||
return context;
|
return context;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
log.warn('Contextual analysis failed, continuing without context:', error);
|
log.warn(`Contextual analysis failed, continuing without context: ${error instanceof Error ? error.message : String(error)}`);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
@@ -219,7 +219,7 @@ export function useDeepResearch() {
|
|||||||
setState(s => ({ ...s, enrichedQueries: enriched }));
|
setState(s => ({ ...s, enrichedQueries: enriched }));
|
||||||
return enriched;
|
return enriched;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
log.warn('Query enrichment failed, continuing without enrichment:', error);
|
log.warn(`Query enrichment failed, continuing without enrichment: ${error instanceof Error ? error.message : String(error)}`);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|||||||
@@ -53,6 +53,8 @@ export function useOllamaDownload() {
|
|||||||
downloadError: null,
|
downloadError: null,
|
||||||
filePath: null,
|
filePath: null,
|
||||||
isInstalled: false,
|
isInstalled: false,
|
||||||
|
isChecking: false,
|
||||||
|
checkStatus: '',
|
||||||
});
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -66,6 +68,8 @@ export function useOllamaDownload() {
|
|||||||
downloadError: null,
|
downloadError: null,
|
||||||
filePath: existingPath,
|
filePath: existingPath,
|
||||||
isInstalled: false,
|
isInstalled: false,
|
||||||
|
isChecking: false,
|
||||||
|
checkStatus: '',
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -79,6 +83,8 @@ export function useOllamaDownload() {
|
|||||||
downloadError: null,
|
downloadError: null,
|
||||||
filePath,
|
filePath,
|
||||||
isInstalled: false,
|
isInstalled: false,
|
||||||
|
isChecking: false,
|
||||||
|
checkStatus: '',
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setState({
|
setState({
|
||||||
@@ -88,6 +94,8 @@ export function useOllamaDownload() {
|
|||||||
downloadError: error instanceof Error ? error.message : 'Erro desconhecido durante download',
|
downloadError: error instanceof Error ? error.message : 'Erro desconhecido durante download',
|
||||||
filePath: null,
|
filePath: null,
|
||||||
isInstalled: false,
|
isInstalled: false,
|
||||||
|
isChecking: false,
|
||||||
|
checkStatus: '',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ export async function extractKeyFacts(
|
|||||||
entities: f.entities || [],
|
entities: f.entities || [],
|
||||||
}));
|
}));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
chatLog.warn(`[ContextUnifier] Erro ao extrair fatos de ${entry.title}:`, error);
|
chatLog.warn(`[ContextUnifier] Erro ao extrair fatos de ${entry.title}: ${error instanceof Error ? error.message : String(error)}`);
|
||||||
// Fallback: criar fato básico do título
|
// Fallback: criar fato básico do título
|
||||||
return [{
|
return [{
|
||||||
fact: entry.title,
|
fact: entry.title,
|
||||||
@@ -273,7 +273,7 @@ export async function unifyContext(
|
|||||||
|
|
||||||
// Criar texto unificado
|
// Criar texto unificado
|
||||||
const unifiedSections: string[] = [];
|
const unifiedSections: string[] = [];
|
||||||
const sourceMap = new Map<string, { title: string; url: string; factsCount: number }>();
|
const sourceMap = new Map<string, { id: string; title: string; url: string; factsCount: number }>();
|
||||||
|
|
||||||
// Agrupar por fonte
|
// Agrupar por fonte
|
||||||
for (const entry of entries) {
|
for (const entry of entries) {
|
||||||
@@ -281,6 +281,7 @@ export async function unifyContext(
|
|||||||
|
|
||||||
if (entryFacts.length > 0) {
|
if (entryFacts.length > 0) {
|
||||||
sourceMap.set(entry.id, {
|
sourceMap.set(entry.id, {
|
||||||
|
id: entry.id,
|
||||||
title: entry.title,
|
title: entry.title,
|
||||||
url: entry.sourceUrl,
|
url: entry.sourceUrl,
|
||||||
factsCount: entryFacts.length,
|
factsCount: entryFacts.length,
|
||||||
|
|||||||
@@ -206,11 +206,11 @@ export async function analyzeQueryContext(
|
|||||||
complexity: analysis.complexity || 'moderate',
|
complexity: analysis.complexity || 'moderate',
|
||||||
};
|
};
|
||||||
|
|
||||||
chatLog.success(`[ContextualAnalysis] Contexto extraído: ${context.intent}, ${context.entities.length} entidades, ${context.topics.length} tópicos`);
|
chatLog.info(`[ContextualAnalysis] Contexto extraído: ${context.intent}, ${context.entities.length} entidades, ${context.topics.length} tópicos`);
|
||||||
|
|
||||||
return context;
|
return context;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
chatLog.error(`[ContextualAnalysis] Erro ao analisar contexto:`, error);
|
chatLog.error(`[ContextualAnalysis] Erro ao analisar contexto: ${error instanceof Error ? error.message : String(error)}`);
|
||||||
|
|
||||||
// Fallback: análise básica usando heurísticas
|
// Fallback: análise básica usando heurísticas
|
||||||
return createFallbackContext(query);
|
return createFallbackContext(query);
|
||||||
|
|||||||
@@ -24,12 +24,13 @@ export interface CondensationOptions {
|
|||||||
context?: QueryContext; // Contexto analisado para ranqueamento semântico
|
context?: QueryContext; // Contexto analisado para ranqueamento semântico
|
||||||
}
|
}
|
||||||
|
|
||||||
const DEFAULT_OPTIONS: Required<CondensationOptions> = {
|
const DEFAULT_OPTIONS: Omit<Required<CondensationOptions>, 'context'> & { context?: QueryContext } = {
|
||||||
maxTokens: 12000,
|
maxTokens: 12000,
|
||||||
minRelevanceScore: 0.1,
|
minRelevanceScore: 0.1,
|
||||||
autoSummarize: true,
|
autoSummarize: true,
|
||||||
summarizeThreshold: 5000,
|
summarizeThreshold: 5000,
|
||||||
fallbackToSummarization: true,
|
fallbackToSummarization: true,
|
||||||
|
context: undefined,
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -108,7 +109,6 @@ export function condenseKnowledgeBase(
|
|||||||
entries.forEach((entry, entryIndex) => {
|
entries.forEach((entry, entryIndex) => {
|
||||||
const processed = processContent(entry.content, query, {
|
const processed = processContent(entry.content, query, {
|
||||||
summarizeThreshold: opts.summarizeThreshold,
|
summarizeThreshold: opts.summarizeThreshold,
|
||||||
autoSummarize: opts.autoSummarize,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Atribuir sourceIndex e metadados aos chunks
|
// Atribuir sourceIndex e metadados aos chunks
|
||||||
|
|||||||
@@ -176,7 +176,7 @@ export async function enrichQueries(
|
|||||||
result.expanded.length +
|
result.expanded.length +
|
||||||
result.contextual.length;
|
result.contextual.length;
|
||||||
|
|
||||||
chatLog.success(
|
chatLog.info(
|
||||||
`[QueryEnricher] ${totalQueries} queries geradas: ` +
|
`[QueryEnricher] ${totalQueries} queries geradas: ` +
|
||||||
`${result.literal.length} literal, ${result.semantic.length} semântica, ` +
|
`${result.literal.length} literal, ${result.semantic.length} semântica, ` +
|
||||||
`${result.related.length} relacionadas, ${result.expanded.length} expandidas, ` +
|
`${result.related.length} relacionadas, ${result.expanded.length} expandidas, ` +
|
||||||
@@ -185,7 +185,7 @@ export async function enrichQueries(
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
chatLog.error(`[QueryEnricher] Erro ao enriquecer queries:`, error);
|
chatLog.error(`[QueryEnricher] Erro ao enriquecer queries: ${error instanceof Error ? error.message : String(error)}`);
|
||||||
|
|
||||||
// Fallback: usar apenas query original
|
// Fallback: usar apenas query original
|
||||||
return createFallbackEnrichment(originalQuery, context);
|
return createFallbackEnrichment(originalQuery, context);
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ Query expandida:`;
|
|||||||
chatLog.info(`Query expanded: "${originalQuery}" → "${expanded}"`);
|
chatLog.info(`Query expanded: "${originalQuery}" → "${expanded}"`);
|
||||||
return expanded;
|
return expanded;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
chatLog.warn('Error expanding query, using original:', error);
|
chatLog.warn(`Error expanding query, using original: ${error instanceof Error ? error.message : String(error)}`);
|
||||||
return originalQuery;
|
return originalQuery;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -352,7 +352,7 @@ export async function executeProgressiveSearch(
|
|||||||
const results = await searchFn(finalQuery, finalConfig.maxResultsPerRound, round);
|
const results = await searchFn(finalQuery, finalConfig.maxResultsPerRound, round);
|
||||||
return { query: finalQuery, results };
|
return { query: finalQuery, results };
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
chatLog.warn(`[Round ${round}] Query "${finalQuery}" failed:`, error);
|
chatLog.warn(`[Round ${round}] Query "${finalQuery}" failed: ${error instanceof Error ? error.message : String(error)}`);
|
||||||
return { query: finalQuery, results: [] };
|
return { query: finalQuery, results: [] };
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
+10
-12
@@ -5,19 +5,17 @@ const nextConfig: NextConfig = {
|
|||||||
images: {
|
images: {
|
||||||
unoptimized: true,
|
unoptimized: true,
|
||||||
},
|
},
|
||||||
webpack: (config, { isServer }) => {
|
webpack: (config) => {
|
||||||
// Adiciona suporte para raw-loader apenas no cliente
|
// Adiciona suporte para raw-loader para arquivos .md
|
||||||
if (!isServer) {
|
config.module.rules.push({
|
||||||
config.module.rules.push({
|
test: /\.md$/,
|
||||||
test: /\.md$/,
|
use: {
|
||||||
use: {
|
loader: 'raw-loader',
|
||||||
loader: 'raw-loader',
|
options: {
|
||||||
options: {
|
esModule: false,
|
||||||
esModule: false,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
});
|
},
|
||||||
}
|
});
|
||||||
return config;
|
return config;
|
||||||
},
|
},
|
||||||
// Configuração Turbopack: objeto vazio silencia o erro
|
// Configuração Turbopack: objeto vazio silencia o erro
|
||||||
|
|||||||
+1
-1
@@ -4,7 +4,7 @@
|
|||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "next dev --webpack",
|
"dev": "next dev --webpack",
|
||||||
"build": "next build",
|
"build": "next build --webpack",
|
||||||
"start": "next start",
|
"start": "next start",
|
||||||
"lint": "eslint",
|
"lint": "eslint",
|
||||||
"generate-changelog": "node scripts/generate-changelog.js",
|
"generate-changelog": "node scripts/generate-changelog.js",
|
||||||
|
|||||||
Reference in new issue
Block a user