feat: v2.12.0 - UI/UX Refinement (Model Sync & Premium Tooltips)
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
import * as vscode from 'vscode';
|
||||
import * as fs from 'fs';
|
||||
import { getConfig } from '../config';
|
||||
import { logInfo, logWarn, logError } from '../utils';
|
||||
|
||||
/**
|
||||
* HealthCheckMonitor: Periodically monitors the environment
|
||||
* (Ollama, Disk, API) to ensure the agent stays functional.
|
||||
*/
|
||||
export class HealthCheckMonitor {
|
||||
public static async runAllChecks(): Promise<{ ok: boolean; reports: string[] }> {
|
||||
const reports: string[] = [];
|
||||
const config = getConfig();
|
||||
|
||||
// 1. Ollama Connectivity Check
|
||||
try {
|
||||
const res = await fetch(`${config.ollamaUrl}/api/tags`, { signal: AbortSignal.timeout(3000) });
|
||||
if (res.ok) {
|
||||
logInfo('Health Check: Ollama connectivity OK.');
|
||||
} else {
|
||||
reports.push('⚠️ AI Server (Ollama) is reachable but returned an error.');
|
||||
}
|
||||
} catch {
|
||||
reports.push('❌ AI Server (Ollama) is NOT reachable. Please check if it is running.');
|
||||
}
|
||||
|
||||
// 2. Workspace Validation
|
||||
const workspaceFolders = vscode.workspace.workspaceFolders;
|
||||
if (!workspaceFolders || workspaceFolders.length === 0) {
|
||||
reports.push('⚠️ No workspace folder open. Agent capabilities will be limited.');
|
||||
}
|
||||
|
||||
// 3. Simple Disk/Permissions Check
|
||||
try {
|
||||
const testFile = workspaceFolders ? vscode.Uri.joinPath(workspaceFolders[0].uri, '.g1-health-check') : null;
|
||||
if (testFile) {
|
||||
await vscode.workspace.fs.writeFile(testFile, Buffer.from('ok'));
|
||||
await vscode.workspace.fs.delete(testFile);
|
||||
logInfo('Health Check: Write permissions OK.');
|
||||
}
|
||||
} catch {
|
||||
reports.push('❌ Write permissions denied in the current workspace.');
|
||||
}
|
||||
|
||||
if (reports.length > 0) {
|
||||
logWarn(`Health Check Warnings: ${reports.join(' | ')}`);
|
||||
vscode.window.showWarningMessage(`ConnectAI Health Warning: ${reports[0]}`);
|
||||
}
|
||||
|
||||
return {
|
||||
ok: reports.length === 0,
|
||||
reports
|
||||
};
|
||||
}
|
||||
|
||||
public static startInterval(ms: number = 300000) { // Default 5 mins
|
||||
setInterval(() => this.runAllChecks(), ms);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user