Let one gate decide every AI surface, so switching AI off actually removes all of it
The Tools card adopted the AI scripts on the host check alone, and api/ai.php only tested AI_ENABLED in front of ask, so a disabled subsystem still had rows to run and an endpoint that answered.
This commit is contained in:
@@ -268,6 +268,19 @@ function vv_is_ai_host(): bool {
|
||||
return vv_detect_host() === 'host1';
|
||||
}
|
||||
|
||||
// Whether the UI may offer anything AI at all: the right host, with the master switch on. Every
|
||||
// AI surface asks this one question — the AI tab, the assistant dock on the Scheduler, and the
|
||||
// two AI rows on the Tools card — so AI off means AI gone, not gone from most places.
|
||||
//
|
||||
// It lives here rather than in include/ai.php because the pages that need it do not all load
|
||||
// that file; the Scheduler loads only config.php, and a gate that silently answers false where
|
||||
// its definition is missing is worse than no gate. Reads AI_ENABLED directly for the same
|
||||
// reason. Fail-closed on anything but the literal "true", matching the conf's own contract.
|
||||
function vv_ai_ui_on(): bool {
|
||||
return vv_is_ai_host()
|
||||
&& strtolower(trim(vv_conf_vars()['AI_ENABLED'] ?? 'false')) === 'true';
|
||||
}
|
||||
|
||||
function vv_read_conf_raw(string $filename): string {
|
||||
$path = CONF_DIR . '/' . $filename;
|
||||
return file_exists($path) ? file_get_contents($path) : '';
|
||||
|
||||
Reference in New Issue
Block a user