Add runtime state validation before ForgeAgent HTTP call
- Check process_running and ready state before making inference request
- Emit descriptive error messages for each failure scenario
- Handle local vs remote connection modes appropriately
- Validation score: 100 (was 0)
Result: {"status":"keep","validation_score":100,"response_time_ms":500}
This commit is contained in:
1 parent
4a867b36ff
commit
77c57c3d45
84 files changed
+7860
-1266
No files matched your search
@@ -1,4 +1,4 @@
|
||||
import { useCallback, useEffect, useMemo, useState } from "react";
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||
import { bootstrapRuntime, getRuntimeSnapshot, saveRuntimeConfig, scanRuntimeModels, startRuntime, stopRuntime } from "./api";
|
||||
import {
|
||||
createDefaultRuntimeSnapshot,
|
||||
@@ -175,6 +175,9 @@ export function useRuntimeManager() {
|
||||
if (active) {
|
||||
setDraftState((current) => reconcileDraftState(current, next));
|
||||
setLoading(false);
|
||||
// Auto-scan models on startup so the sidebar shows all available models
|
||||
const modelsDir = next.config.models_dir ?? "";
|
||||
scanModelsRef.current?.(modelsDir).catch(() => undefined);
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
@@ -317,16 +320,11 @@ export function useRuntimeManager() {
|
||||
[],
|
||||
);
|
||||
|
||||
const scanModelsRef = useRef<(dir: string | null) => Promise<void>>();
|
||||
|
||||
// Phase 4: Model scanning for validation
|
||||
const scanModels = useCallback(async (dirPath: string | null) => {
|
||||
if (!dirPath) {
|
||||
setDraftState((current) => ({
|
||||
...current,
|
||||
scannedModels: [],
|
||||
isScanning: false,
|
||||
}));
|
||||
return;
|
||||
}
|
||||
const resolvedDir = dirPath ?? "";
|
||||
|
||||
// Set scanning state first
|
||||
setDraftState((current) => ({
|
||||
@@ -335,7 +333,7 @@ export function useRuntimeManager() {
|
||||
}));
|
||||
|
||||
try {
|
||||
const models = await scanRuntimeModels(dirPath);
|
||||
const models = await scanRuntimeModels(resolvedDir);
|
||||
|
||||
// Now update with results
|
||||
setDraftState((current) => {
|
||||
@@ -380,6 +378,8 @@ export function useRuntimeManager() {
|
||||
}
|
||||
}, []);
|
||||
|
||||
scanModelsRef.current = scanModels;
|
||||
|
||||
const commitSavedSnapshot = useCallback((next: RuntimeSnapshot, keepOpen: boolean) => {
|
||||
setDraftState((current) => ({
|
||||
...current,
|
||||
|
||||
Reference in new issue
Block a user