BugFix
release-tag / release-image (push) Successful in 2m24s

This commit is contained in:
2026-08-05 11:58:25 +02:00
parent 31d3efb8a2
commit b3bd3d5ffd
25 changed files with 679 additions and 719 deletions
-5
View File
@@ -36,7 +36,6 @@ func (s *Server) Handler() http.Handler {
mux.HandleFunc("GET /api/analysis", s.handleAnalysis)
mux.HandleFunc("GET /api/runtime-settings", s.handleGetRuntimeSettings)
mux.HandleFunc("PUT /api/runtime-settings", s.handleSetRuntimeSettings)
mux.HandleFunc("GET /api/categories", s.handleCategories)
mux.HandleFunc("GET /api/sources", s.handleSources)
mux.HandleFunc("GET /api/research/status", s.handleResearchStatus)
mux.HandleFunc("POST /api/research/test", s.handleResearchTest)
@@ -93,10 +92,6 @@ func (s *Server) handleSetRuntimeSettings(w http.ResponseWriter, r *http.Request
writeJSON(w, http.StatusOK, s.Engine.RuntimeSettingsView())
}
func (s *Server) handleCategories(w http.ResponseWriter, r *http.Request) {
writeJSON(w, http.StatusOK, map[string]any{"categories": s.Engine.Categories()})
}
func (s *Server) handleSources(w http.ResponseWriter, r *http.Request) {
writeJSON(w, http.StatusOK, map[string]any{"sources": s.Engine.Sources()})
}
+15 -25
View File
@@ -16,7 +16,7 @@ import (
"github.com/local/glpi-neural-brain/internal/research"
)
func TestRuntimeSettingsAndCategoriesAPI(t *testing.T) {
func TestRuntimeSettingsAndSourcesAPI(t *testing.T) {
data := t.TempDir()
g, err := graph.Open(data)
if err != nil {
@@ -34,10 +34,11 @@ func TestRuntimeSettingsAndCategoriesAPI(t *testing.T) {
LearningEnabled: true,
ThinkingEnabled: true,
DefaultView: "neural",
GLPIKBSource: "Configured GLPI Source",
}, g, broker)
h := (&Server{Engine: eng, Graph: g, Broker: broker}).Handler()
body := `{"learning_enabled":false,"thinking_enabled":false,"learning_categories":["GLPI"],"display_categories":["Ollama"],"thinking_categories":["GLPI"],"learning_sources":["GLPI Knowledge Base"],"display_sources":["internal-kb"],"thinking_sources":["GLPI Knowledge Base"],"view_mode":"constellation","max_display_nodes":1500,"low_power_mode":true}`
body := `{"learning_enabled":false,"thinking_enabled":false,"learning_sources":["GLPI Knowledge Base"],"display_sources":["internal-kb"],"thinking_sources":["GLPI Knowledge Base"],"view_mode":"constellation","max_display_nodes":1500,"low_power_mode":true}`
req := httptest.NewRequest(http.MethodPut, "/api/runtime-settings", strings.NewReader(body))
req.Header.Set("Content-Type", "application/json")
res := httptest.NewRecorder()
@@ -53,27 +54,6 @@ func TestRuntimeSettingsAndCategoriesAPI(t *testing.T) {
t.Fatalf("unexpected settings: %+v", settings)
}
res = httptest.NewRecorder()
h.ServeHTTP(res, httptest.NewRequest(http.MethodGet, "/api/categories", nil))
if res.Code != http.StatusOK {
t.Fatalf("GET categories returned %d", res.Code)
}
var categories struct {
Categories []engine.CategoryInfo `json:"categories"`
}
if err := json.NewDecoder(res.Body).Decode(&categories); err != nil {
t.Fatal(err)
}
foundUncategorized := false
for _, category := range categories.Categories {
if category.Name == "__uncategorized__" && category.Count == 1 {
foundUncategorized = true
}
}
if !foundUncategorized {
t.Fatalf("uncategorized virtual category missing: %+v", categories.Categories)
}
res = httptest.NewRecorder()
h.ServeHTTP(res, httptest.NewRequest(http.MethodGet, "/api/sources", nil))
if res.Code != http.StatusOK {
@@ -85,8 +65,18 @@ func TestRuntimeSettingsAndCategoriesAPI(t *testing.T) {
if err := json.NewDecoder(res.Body).Decode(&sources); err != nil {
t.Fatal(err)
}
if len(sources.Sources) < 2 {
t.Fatalf("source options missing: %+v", sources.Sources)
foundConfiguredGLPI := false
foundInternal := false
for _, source := range sources.Sources {
if source.Name == "Configured GLPI Source" && source.Count == 0 {
foundConfiguredGLPI = true
}
if source.Name == "internal-kb" && source.Count == 1 {
foundInternal = true
}
}
if !foundConfiguredGLPI || !foundInternal {
t.Fatalf("exact source options or configured GLPI source missing: %+v", sources.Sources)
}
res = httptest.NewRecorder()
+3 -3
View File
@@ -31,7 +31,7 @@ html,body{margin:0;width:100%;height:100%;overflow:hidden;background:radial-grad
.dock .think-action{display:flex;align-items:center;gap:7px;border-color:rgba(255,180,82,.22);background:rgba(255,180,82,.07);color:var(--amber)}.dock .think-action small{font-size:8px;letter-spacing:.11em;opacity:.68}.dock .think-action:hover{background:rgba(255,180,82,.14);box-shadow:0 0 22px rgba(255,180,82,.08)}.dock .think-action.running{border-color:rgba(255,180,82,.48);background:rgba(255,180,82,.13);box-shadow:0 0 24px rgba(255,180,82,.11)}.dock .think-action:disabled{cursor:wait;opacity:.72}
.metrics span[title]{cursor:help}.dock #toggleLOD.active{color:var(--green);border-color:rgba(93,255,189,.22);background:rgba(93,255,189,.065)}
/* Laufzeitsteuerung, Kategorie-Filter und Honeycomb-Ansicht */
/* Laufzeitsteuerung, source-Filter und Visualisierungen */
.dock{max-width:calc(100vw - 390px);overflow-x:auto;scrollbar-width:none}.dock::-webkit-scrollbar{display:none}.dock-separator{width:1px;min-width:1px;background:var(--line);margin:5px 2px}.dock button:disabled{opacity:.32;cursor:not-allowed}.dock #toggleLearning.active{color:var(--blue);border-color:rgba(75,123,255,.25);background:rgba(75,123,255,.08)}.dock #toggleThinking.active{color:var(--amber);border-color:rgba(255,180,82,.25);background:rgba(255,180,82,.08)}.dock #viewHoneycomb.active,.dock #viewNeural.active{color:var(--green);border-color:rgba(93,255,189,.24);background:rgba(93,255,189,.07)}.dock #openSettings{color:#a7bdcc}
body.honeycomb-view .legend{opacity:.58}body.honeycomb-view .mode-status small:after{content:" · Honeycomb"}
.settings-backdrop{position:fixed;inset:0;z-index:20;background:rgba(0,3,9,.55);backdrop-filter:blur(3px)}
@@ -41,7 +41,7 @@ body.honeycomb-view .legend{opacity:.58}body.honeycomb-view .mode-status small:a
.switch-row{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:9px 10px;margin:7px 0;border:1px solid rgba(133,200,255,.1);border-radius:12px;background:rgba(255,255,255,.022);cursor:pointer}.switch-row b{display:block;font-size:11px}.switch-row small{display:block;margin-top:3px;color:#718b9e;font-size:9px;line-height:1.35}.switch-row input{appearance:none;width:38px;height:21px;border-radius:999px;background:rgba(119,146,168,.25);position:relative;cursor:pointer;flex:0 0 auto;outline:1px solid rgba(255,255,255,.06)}.switch-row input:after{content:"";position:absolute;width:15px;height:15px;left:3px;top:3px;border-radius:50%;background:#8196a7;transition:transform .2s,background .2s,box-shadow .2s}.switch-row input:checked{background:rgba(82,231,255,.19)}.switch-row input:checked:after{transform:translateX(17px);background:var(--cyan);box-shadow:0 0 10px rgba(82,231,255,.7)}
.view-selector{display:grid;grid-template-columns:repeat(3,1fr);gap:6px;margin-top:10px}.view-selector button{border:1px solid rgba(133,200,255,.12);background:rgba(255,255,255,.025);color:#738da1;border-radius:10px;padding:9px;font-size:10px;font-weight:700;letter-spacing:.1em;cursor:pointer}.view-selector button.active{color:var(--green);border-color:rgba(93,255,189,.24);background:rgba(93,255,189,.07)}
.category-settings{flex:1;min-height:0;overflow:auto;padding-right:5px}.filter-search{display:block;margin-bottom:12px}.filter-search span{display:block;font-size:9px;color:#6d879a;margin-bottom:5px}.filter-search input{width:100%;border:1px solid rgba(133,200,255,.14);background:rgba(2,8,17,.6);color:var(--text);border-radius:10px;padding:9px 10px;outline:0}.filter-search input:focus{border-color:rgba(82,231,255,.38);box-shadow:0 0 0 3px rgba(82,231,255,.06)}
.filter-block{margin:12px 0 16px}.filter-heading{display:flex;align-items:center;justify-content:space-between;margin-bottom:7px}.filter-heading b{display:block;font-size:10px;color:#c8d9e4}.filter-heading small{display:block;margin-top:2px;color:#607b90;font-size:9px}.filter-heading button{border:1px solid rgba(82,231,255,.13);background:rgba(82,231,255,.04);color:#87a8bc;border-radius:8px;padding:5px 8px;font-size:8px;letter-spacing:.08em;cursor:pointer}.category-list{display:flex;flex-wrap:wrap;gap:5px;max-height:128px;overflow:auto;padding:1px}.category-option{position:relative}.category-option input{position:absolute;opacity:0;pointer-events:none}.category-option span{display:block;border:1px solid rgba(133,200,255,.12);background:rgba(255,255,255,.022);color:#7893a6;border-radius:999px;padding:5px 8px;font-size:9px;cursor:pointer;white-space:nowrap}.category-option input:checked+span{color:#dffaff;border-color:rgba(82,231,255,.32);background:rgba(82,231,255,.11);box-shadow:0 0 12px rgba(82,231,255,.05)}.category-option em{font-style:normal;opacity:.58;margin-left:4px}
.filter-block{margin:12px 0 16px}.filter-heading{display:flex;align-items:center;justify-content:space-between;margin-bottom:7px}.filter-heading b{display:block;font-size:10px;color:#c8d9e4}.filter-heading small{display:block;margin-top:2px;color:#607b90;font-size:9px}.filter-heading button{border:1px solid rgba(82,231,255,.13);background:rgba(82,231,255,.04);color:#87a8bc;border-radius:8px;padding:5px 8px;font-size:8px;letter-spacing:.08em;cursor:pointer}.source-list{display:flex;flex-wrap:wrap;gap:5px;max-height:128px;overflow:auto;padding:1px}.source-option{position:relative}.source-option input{position:absolute;opacity:0;pointer-events:none}.source-option span{display:block;border:1px solid rgba(133,200,255,.12);background:rgba(255,255,255,.022);color:#7893a6;border-radius:999px;padding:5px 8px;font-size:9px;cursor:pointer;white-space:nowrap}.source-option input:checked+span{color:#dffaff;border-color:rgba(82,231,255,.32);background:rgba(82,231,255,.11);box-shadow:0 0 12px rgba(82,231,255,.05)}.source-option em{font-style:normal;opacity:.58;margin-left:4px}
.settings-footer{display:flex;align-items:center;justify-content:space-between;gap:12px;padding-top:13px}.settings-footer span{font-size:9px;color:#7f9aac;line-height:1.35}.settings-footer button{border:1px solid rgba(82,231,255,.3);background:rgba(82,231,255,.1);color:var(--cyan);border-radius:11px;padding:10px 13px;font-size:9px;font-weight:800;letter-spacing:.13em;cursor:pointer}.settings-footer button:disabled{opacity:.5;cursor:wait}
@media(max-width:1100px){.dock{max-width:calc(100vw - 40px)}.settings-panel{right:10px;top:10px;bottom:10px}}
@media(max-width:780px){.settings-panel{left:10px;width:auto}.dock{max-width:calc(100vw - 20px)}.dock-separator{display:none}}
@@ -65,4 +65,4 @@ body.low-power .glass{backdrop-filter:blur(12px)}
.eco-switch input:checked{background:rgba(255,180,82,.2)}
.eco-switch input:checked:after{background:var(--amber);box-shadow:0 0 10px rgba(255,180,82,.72)}
@media(max-width:620px){.view-selector{grid-template-columns:1fr}.metrics span[title]{display:none}}
.filter-scope-summary{margin:2px 0 10px;line-height:1.45}.category-option.disabled{opacity:.38}.category-option.disabled span{cursor:not-allowed;border-style:dashed}.category-option span small{display:block;margin-top:2px;font-size:7px;letter-spacing:.04em;color:#8a6f79}.filter-scope-summary.warn{color:#ffb37f}.filter-scope-summary.ok{color:#7898aa}
.filter-scope-summary{margin:2px 0 10px;line-height:1.45}.source-option.disabled{opacity:.38}.source-option.disabled span{cursor:not-allowed;border-style:dashed}.source-option span small{display:block;margin-top:2px;font-size:7px;letter-spacing:.04em;color:#8a6f79}.filter-scope-summary.warn{color:#ffb37f}.filter-scope-summary.ok{color:#7898aa}
+98 -152
View File
@@ -51,15 +51,15 @@
lodOpenUntil: new Map(), lodHotUntil: new Map(), lodDirty: true, lodLastBuild: 0, lodNextExpiry: 0, lodZoomBand: 2,
renderNodes: [], renderEdges: [], renderIdleEdges: [], renderNodeById: new Map(), renderEdgeById: new Map(), visibleForNode: new Map(),
edgeRenderMap: new Map(), renderActive: new Map(), renderEdgeActive: new Map(), renderStats: {nodes: 0, edges: 0, hiddenNodes: 0, hiddenEdges: 0},
fullSnapshot: null, fullNodeById: new Map(), runtimeSettings: {learning_enabled: true, thinking_enabled: true, learning_categories: [], display_categories: [], thinking_categories: [], learning_sources: [], display_sources: [], thinking_sources: [], effective_learning: {categories: [], sources: [], matches_none: false}, effective_display: {categories: [], sources: [], matches_none: false}, effective_thinking: {categories: [], sources: [], matches_none: false}, admin_learning: {categories: [], sources: []}, admin_display: {categories: [], sources: []}, admin_thinking: {categories: [], sources: []}, view_mode: 'neural', max_display_nodes: 0, low_power_mode: false},
availableCategories: [], availableSources: [], viewMode: 'neural', honeycombNodes: [], honeycombSpacing: 0, honeySlotByID: new Map(), honeyPointPool: [], honeyFreeSlots: [],
fullSnapshot: null, fullNodeById: new Map(), runtimeSettings: {source_filter_version: 1, learning_enabled: true, thinking_enabled: true, learning_sources: [], display_sources: [], thinking_sources: [], glpi_kb_source: '', view_mode: 'neural', max_display_nodes: 0, low_power_mode: false},
availableSources: [], viewMode: 'neural', honeycombNodes: [], honeycombSpacing: 0, honeySlotByID: new Map(), honeyPointPool: [], honeyFreeSlots: [],
constellationNodes: [], constellationLinks: [], settingsOpen: false, settingsDraft: null,
forcedDisplayUntil: new Map(), nextDisplayLimitExpiry: 0, graphVersion: null, displaySignature: '', displayLimitStats: {limit: 0, eligible: 0, shown: 0},
researchAnimations: new Map(), researchSequence: 0,
lowPowerMode: false, performanceProfile: PERFORMANCE_CONFIG.normal, lastPaint: 0, fpsWindowStarted: performance.now(), fpsFrames: 0, fps: 0,
backgroundCanvas: document.createElement('canvas'), backgroundKey: '', cameraFrame: null, projectedSortAt: 0,
retiringRenderNodes: [], retiringRenderEdges: [], retiringRenderNodeById: new Map(), viewGhostNodes: [],
topologyNodeIDs: new Set(), topologyEdgeIDs: new Set(), graphLoadPromise: null, graphLoadQueued: false, graphLoadTimer: 0
topologyNodeIDs: new Set(), topologyEdgeIDs: new Set(), graphLoadPromise: null, graphLoadQueued: false, graphLoadTimer: 0, sourceOptionsTimer: 0
};
function currentPerformanceProfile() {
@@ -141,46 +141,30 @@
return data;
}
function normalizedFilterValues(values) {
return [...new Set((values || []).map(value => String(value).trim().toLowerCase()).filter(Boolean))];
function normalizedSourceValues(values) {
return [...new Set((values || []).map(value => String(value).trim()).filter(Boolean))];
}
// Source filtering intentionally uses only the explicit metadata.source value
// copied from a KB file (or assigned to learned web evidence). No origin,
// category, URI or display-label fallback is used.
function nodeSource(node) {
const explicit = node?.metadata?.source;
if (explicit !== undefined && explicit !== null) {
const value = String(explicit).trim();
if (value && value.toLowerCase() !== '<nil>' && value.toLowerCase() !== 'null') return value;
}
if (node?.kind === 'source' && String(node.label || '').trim()) return String(node.label).trim();
if (node?.kind === 'external') {
for (const raw of [node.uri, node.external_id]) {
try {
const host = new URL(String(raw || '')).hostname.trim().toLowerCase();
if (host) return host;
} catch {}
}
}
return String(node?.origin || '').trim();
if (explicit === undefined || explicit === null) return '';
const value = String(explicit).trim();
if (!value || value.toLowerCase() === '<nil>' || value.toLowerCase() === 'null') return '';
return value;
}
function filterDimensionMatches(values, filters, emptyToken) {
const wanted = new Set(normalizedFilterValues(filters));
if (!wanted.size || wanted.has('*')) return true;
const clean = (values || []).map(value => String(value).trim().toLowerCase()).filter(Boolean);
if (!clean.length) return wanted.has(emptyToken);
return clean.some(value => wanted.has(value));
function sourceFilterMatches(node, sources) {
const wanted = normalizedSourceValues(sources);
if (!wanted.length) return true;
const source = nodeSource(node);
return wanted.some(value => source === value);
}
function nodeFilterMatches(node, filter) {
if (filter?.matches_none) return false;
return filterDimensionMatches(node.categories || [], filter?.categories || [], '__uncategorized__') &&
filterDimensionMatches(nodeSource(node) ? [nodeSource(node)] : [], filter?.sources || [], '__unsourced__');
}
function effectiveRuntimeFilter(key, settings = state.runtimeSettings) {
const effective = settings?.[`effective_${key}`];
if (effective) return effective;
return {categories: settings?.[`${key}_categories`] || [], sources: settings?.[`${key}_sources`] || [], matches_none: false};
function runtimeSources(key, settings = state.runtimeSettings) {
return normalizedSourceValues(settings?.[`${key}_sources`] || []);
}
function activeForcedDisplayIDs(now = Date.now()) {
@@ -265,19 +249,18 @@
}
function filteredSnapshot(snapshot) {
const filter = effectiveRuntimeFilter('display');
const restricted = Boolean(filter?.matches_none || (filter?.categories || []).length || (filter?.sources || []).length);
const sources = runtimeSources('display');
let filtered = snapshot;
if (restricted) {
if (sources.length) {
const visible = new Set();
const noteKinds = new Set(['knowledge', 'ai-think', 'external']);
const taxonomyKinds = new Set(['category', 'source', 'concept']);
const nodeMap = new Map(snapshot.nodes.map(node => [node.id, node]));
for (const node of snapshot.nodes) {
if (noteKinds.has(node.kind) && nodeFilterMatches(node, filter)) visible.add(node.id);
if (noteKinds.has(node.kind) && sourceFilterMatches(node, sources)) visible.add(node.id);
}
// Add only the taxonomy directly attached to an already matching note.
// Never pull another knowledge/external note through a semantic edge.
// Taxonomy is visual context only. Another knowledge-bearing node is
// never pulled through an edge when its exact source does not match.
for (const edge of snapshot.edges) {
const source = nodeMap.get(edge.source);
const target = nodeMap.get(edge.target);
@@ -294,8 +277,7 @@
}
function displaySignatureFor(settings = state.runtimeSettings) {
const filter = effectiveRuntimeFilter('display', settings);
return {categories: filter.categories || [], sources: filter.sources || [], matchesNone: Boolean(filter.matches_none), limit: Number(settings.max_display_nodes || 0)};
return {sources: runtimeSources('display', settings), limit: Number(settings.max_display_nodes || 0)};
}
function currentDisplaySignature() {
@@ -303,16 +285,28 @@
return JSON.stringify({...displaySignatureFor(), forced});
}
async function loadSourceOptions() {
const payload = await api('/api/sources');
state.availableSources = payload.sources || [];
renderSourceFilters($('sourceSearch')?.value || '');
return state.availableSources;
}
function scheduleSourceOptionsLoad(delay = 260) {
clearTimeout(state.sourceOptionsTimer);
state.sourceOptionsTimer = setTimeout(() => {
state.sourceOptionsTimer = 0;
loadSourceOptions().catch(() => {});
}, delay);
}
async function loadRuntimeConfiguration() {
try {
const [settings, categories, sources] = await Promise.all([api('/api/runtime-settings'), api('/api/categories'), api('/api/sources')]);
const [settings] = await Promise.all([api('/api/runtime-settings'), loadSourceOptions()]);
state.runtimeSettings = {...state.runtimeSettings, ...settings};
state.availableCategories = categories.categories || [];
state.availableSources = sources.sources || [];
state.viewMode = ['neural', 'honeycomb', 'constellation'].includes(state.runtimeSettings.view_mode) ? state.runtimeSettings.view_mode : 'neural';
applyPerformanceMode(Boolean(state.runtimeSettings.low_power_mode), true);
syncRuntimeControls();
renderCategoryFilters();
renderSourceFilters();
renderFilterScopeSummary();
} catch {
@@ -347,7 +341,7 @@
if (!hint) return;
const limit = Math.max(0, Math.trunc(Number(value) || 0));
if (!limit) {
hint.textContent = 'Unbegrenzt · Kategorie-Filter und LOD bestimmen die Renderlast.';
hint.textContent = 'Unbegrenzt · Quellenfilter und LOD bestimmen die Renderlast.';
return;
}
const stats = state.displayLimitStats || {};
@@ -355,113 +349,72 @@
hint.textContent = `Maximal ${limit.toLocaleString('de-DE')} Nodes · aktuell ${Math.min(limit, eligible).toLocaleString('de-DE')} von ${eligible.toLocaleString('de-DE')} auswählbar.`;
}
function categoryLabel(name) {
return name === '__uncategorized__' ? 'Ohne Kategorie' : name;
}
function sourceLabel(name) {
return name === '__unsourced__' ? 'Ohne Quelle' : name;
return String(name || '');
}
function filterSet(key, dimension) {
const source = state.settingsDraft || state.runtimeSettings;
return new Set((source[`${key}_${dimension}`] || []).map(value => String(value).toLowerCase()));
}
function adminAllows(key, dimension, value) {
const admin = state.runtimeSettings?.[`admin_${key}`] || {};
const restricted = Boolean(admin[`${dimension}_restricted`]);
if (!restricted) return true;
const allowed = new Set(normalizedFilterValues(admin[dimension] || []));
return allowed.has(String(value).trim().toLowerCase());
}
function renderFilterOptions({dimension, search = '', options, targets, labeler, dataAttribute}) {
const query = String(search || '').trim().toLowerCase();
for (const [key, target] of Object.entries(targets)) {
if (!target) continue;
const selected = filterSet(key, dimension);
target.innerHTML = '';
const visibleOptions = options.filter(option => !query || labeler(option.name).toLowerCase().includes(query));
for (const option of visibleOptions) {
const allowed = adminAllows(key, dimension, option.name);
const label = document.createElement('label');
label.className = `category-option${allowed ? '' : ' disabled'}`;
const checked = selected.has(String(option.name).toLowerCase());
const disabled = allowed ? '' : ' disabled';
const notice = allowed ? '' : '<small>durch ENV ausgeschlossen</small>';
label.innerHTML = `<input type="checkbox" ${dataAttribute}="${key}" value="${escapeHTML(option.name)}" ${checked ? 'checked' : ''}${disabled}><span>${escapeHTML(labeler(option.name))}<em>${Number(option.count || 0).toLocaleString('de-DE')}</em>${notice}</span>`;
target.appendChild(label);
}
if (!visibleOptions.length) target.innerHTML = `<span class="empty-filter">Keine passende ${dimension === 'categories' ? 'Kategorie' : 'Quelle'}</span>`;
}
}
function renderCategoryFilters(search = '') {
renderFilterOptions({
dimension: 'categories', search, options: state.availableCategories,
targets: {learning: $('learningCategoryList'), display: $('displayCategoryList'), thinking: $('thinkingCategoryList')},
labeler: categoryLabel, dataAttribute: 'data-category-filter'
});
function sourceSet(key) {
const settings = state.settingsDraft || state.runtimeSettings;
return new Set(normalizedSourceValues(settings[`${key}_sources`] || []));
}
function renderSourceFilters(search = '') {
renderFilterOptions({
dimension: 'sources', search, options: state.availableSources,
targets: {learning: $('learningSourceList'), display: $('displaySourceList'), thinking: $('thinkingSourceList')},
labeler: sourceLabel, dataAttribute: 'data-source-filter'
});
}
function intersectClientValues(adminValues, runtimeValues, restrictedFlag) {
const runtime = normalizedFilterValues(runtimeValues);
if (!restrictedFlag) return {values: runtime, restricted: runtime.length > 0, none: false};
const admin = normalizedFilterValues(adminValues);
if (!runtime.length) return {values: admin, restricted: true, none: false};
const allowed = new Set(admin);
const values = runtime.filter(value => allowed.has(value));
return {values, restricted: true, none: values.length === 0};
}
function previewEffectiveFilter(key) {
const query = String(search || '').trim().toLowerCase();
const settings = state.settingsDraft || state.runtimeSettings;
const admin = state.runtimeSettings?.[`admin_${key}`] || {};
const categories = intersectClientValues(admin.categories || [], settings?.[`${key}_categories`] || [], Boolean(admin.categories_restricted));
const sources = intersectClientValues(admin.sources || [], settings?.[`${key}_sources`] || [], Boolean(admin.sources_restricted));
return {categories: categories.values, sources: sources.values, matches_none: categories.none || sources.none};
const optionMap = new Map((state.availableSources || []).map(option => [String(option.name), {...option}]));
const configuredGLPI = String(state.runtimeSettings.glpi_kb_source || '').trim();
if (configuredGLPI && !optionMap.has(configuredGLPI)) optionMap.set(configuredGLPI, {name: configuredGLPI, count: 0});
for (const key of ['learning', 'display', 'thinking']) {
for (const source of runtimeSources(key, settings)) {
if (!optionMap.has(source)) optionMap.set(source, {name: source, count: 0});
}
}
const options = [...optionMap.values()].filter(option => !query || sourceLabel(option.name).toLowerCase().includes(query));
const targets = {learning: $('learningSourceList'), display: $('displaySourceList'), thinking: $('thinkingSourceList')};
for (const [key, target] of Object.entries(targets)) {
if (!target) continue;
const selected = sourceSet(key);
target.innerHTML = '';
for (const option of options) {
const label = document.createElement('label');
label.className = 'source-option';
const checked = selected.has(String(option.name));
const configured = option.name === state.runtimeSettings.glpi_kb_source && Number(option.count || 0) === 0 ? '<small>GLPI_KB_SOURCE</small>' : '';
label.innerHTML = `<input type="checkbox" data-source-filter="${key}" value="${escapeHTML(option.name)}" ${checked ? 'checked' : ''}><span>${escapeHTML(sourceLabel(option.name))}<em>${Number(option.count || 0).toLocaleString('de-DE')}</em>${configured}</span>`;
target.appendChild(label);
}
if (!options.length) target.innerHTML = '<span class="empty-filter">Keine passende source gefunden</span>';
}
}
function compactFilterValues(values, labeler) {
if (!values?.length) return 'alle';
const labels = values.slice(0, 3).map(labeler);
function compactSourceValues(values) {
if (!values?.length) return 'alle source-Werte';
const labels = values.slice(0, 3).map(sourceLabel);
return labels.join(', ') + (values.length > 3 ? ` +${values.length - 3}` : '');
}
function renderFilterScopeSummary() {
const target = $('filterScopeSummary');
if (!target) return;
const parts = [];
let hasEmpty = false;
for (const [key, label] of [['learning', 'Lernen'], ['display', 'Anzeige'], ['thinking', 'Thinking']]) {
const effective = previewEffectiveFilter(key);
hasEmpty ||= effective.matches_none;
parts.push(`${label}: ${effective.matches_none ? 'keine Übereinstimmung' : `${compactFilterValues(effective.categories, categoryLabel)} · ${compactFilterValues(effective.sources, sourceLabel)}`}`);
}
target.textContent = `Wirksam (ENV ∩ WebUI) — ${parts.join(' | ')}`;
target.classList.toggle('warn', hasEmpty);
target.classList.toggle('ok', !hasEmpty);
const settings = state.settingsDraft || state.runtimeSettings;
const parts = [
`Lernen: ${compactSourceValues(runtimeSources('learning', settings))}`,
`Anzeige: ${compactSourceValues(runtimeSources('display', settings))}`,
`Thinking: ${compactSourceValues(runtimeSources('thinking', settings))}`
];
target.textContent = `Exakter KB-source-Treffer — ${parts.join(' | ')}`;
target.classList.remove('warn');
target.classList.add('ok');
}
async function persistRuntimeSettings(settings = state.runtimeSettings) {
const normalized = {
source_filter_version: 1,
learning_enabled: Boolean(settings.learning_enabled),
thinking_enabled: Boolean(settings.thinking_enabled),
learning_categories: [...(settings.learning_categories || [])],
display_categories: [...(settings.display_categories || [])],
thinking_categories: [...(settings.thinking_categories || [])],
learning_sources: [...(settings.learning_sources || [])],
display_sources: [...(settings.display_sources || [])],
thinking_sources: [...(settings.thinking_sources || [])],
learning_sources: normalizedSourceValues(settings.learning_sources),
display_sources: normalizedSourceValues(settings.display_sources),
thinking_sources: normalizedSourceValues(settings.thinking_sources),
view_mode: ['neural', 'honeycomb', 'constellation'].includes(settings.view_mode) ? settings.view_mode : 'neural',
max_display_nodes: Math.max(0, Math.min(500000, Math.trunc(Number(settings.max_display_nodes) || 0))),
low_power_mode: Boolean(settings.low_power_mode)
@@ -488,7 +441,6 @@
$('settingsPanel')?.classList.remove('hidden');
$('settingsBackdrop')?.classList.remove('hidden');
syncRuntimeControls();
renderCategoryFilters($('categorySearch')?.value || '');
renderSourceFilters($('sourceSearch')?.value || '');
renderFilterScopeSummary();
}
@@ -2760,7 +2712,10 @@
}
}
addLog(evt);
if (evt.type === 'graph.updated') scheduleGraphLoad(180);
if (evt.type === 'graph.updated') {
scheduleGraphLoad(180);
scheduleSourceOptionsLoad(320);
}
if (evt.type?.startsWith('think.') || evt.type?.startsWith('article.') || evt.type?.startsWith('research.')) loadStatus();
}
@@ -2999,7 +2954,6 @@
$('openSettings').addEventListener('click', openSettingsPanel);
$('closeSettings').addEventListener('click', closeSettingsPanel);
$('settingsBackdrop').addEventListener('click', closeSettingsPanel);
$('categorySearch').addEventListener('input', e => renderCategoryFilters(e.currentTarget.value));
$('sourceSearch').addEventListener('input', e => renderSourceFilters(e.currentTarget.value));
$('settingsLearning').addEventListener('change', e => { if (state.settingsDraft) state.settingsDraft.learning_enabled = e.currentTarget.checked; });
$('settingsThinking').addEventListener('change', e => { if (state.settingsDraft) state.settingsDraft.thinking_enabled = e.currentTarget.checked; });
@@ -3019,23 +2973,15 @@
$('settingsViewHoneycomb').addEventListener('click', () => selectSettingsView('honeycomb'));
$('settingsViewConstellation').addEventListener('click', () => selectSettingsView('constellation'));
$('settingsPanel').addEventListener('change', e => {
const input = e.target.closest('[data-category-filter], [data-source-filter]');
if (!input || !state.settingsDraft || input.disabled) return;
const dimension = input.dataset.categoryFilter !== undefined ? 'categories' : 'sources';
const key = input.dataset.categoryFilter ?? input.dataset.sourceFilter;
const property = `${key}_${dimension}`;
const selected = new Map((state.settingsDraft[property] || []).map(value => [String(value).toLowerCase(), value]));
const normalized = String(input.value).toLowerCase();
if (input.checked) selected.set(normalized, input.value); else selected.delete(normalized);
state.settingsDraft[property] = [...selected.values()];
const input = e.target.closest('[data-source-filter]');
if (!input || !state.settingsDraft) return;
const key = input.dataset.sourceFilter;
const property = `${key}_sources`;
const selected = new Set(normalizedSourceValues(state.settingsDraft[property] || []));
if (input.checked) selected.add(input.value); else selected.delete(input.value);
state.settingsDraft[property] = [...selected];
renderFilterScopeSummary();
});
document.querySelectorAll('[data-clear-filter]').forEach(button => button.addEventListener('click', () => {
if (!state.settingsDraft) return;
state.settingsDraft[`${button.dataset.clearFilter}_categories`] = [];
renderCategoryFilters($('categorySearch').value);
renderFilterScopeSummary();
}));
document.querySelectorAll('[data-clear-source-filter]').forEach(button => button.addEventListener('click', () => {
if (!state.settingsDraft) return;
state.settingsDraft[`${button.dataset.clearSourceFilter}_sources`] = [];
+12 -30
View File
@@ -60,7 +60,7 @@
<button id="toggleLOD" class="active" title="Hierarchische dynamische Verdichtung">LOD</button>
<button id="toggleEco" title="Optimierter Renderpfad für schwächere Systeme">ECO</button>
<button id="resetView">Zentrieren</button>
<button id="openSettings" title="Kategorie-Filter und Laufzeitsteuerung">FILTER</button>
<button id="openSettings" title="Exakte KB-source-Filter und Laufzeitsteuerung">FILTER</button>
<button id="enrichNow" class="think-action" title="Einen autonomen AI-THINK-Zyklus sofort starten"><span>AI-THINK</span><small>STARTEN</small></button>
</nav>
@@ -75,7 +75,7 @@
<div id="settingsBackdrop" class="settings-backdrop hidden"></div>
<aside id="settingsPanel" class="settings-panel glass hidden" aria-label="Brain-Einstellungen">
<div class="settings-header">
<div><strong>BRAIN CONTROL</strong><small>Laufzeitmodi und Kategorie-Filter</small></div>
<div><strong>BRAIN CONTROL</strong><small>Laufzeitmodi und exakte KB-source-Filter</small></div>
<button id="closeSettings" title="Schließen">×</button>
</div>
@@ -114,7 +114,7 @@
<button type="button" data-node-limit="25000">25.000</button>
<button type="button" data-node-limit="0">Unbegrenzt</button>
</div>
<p id="displayLimitHint" class="setting-hint">Unbegrenzt · Kategorie-Filter und LOD bestimmen die Renderlast.</p>
<p id="displayLimitHint" class="setting-hint">Unbegrenzt · Quellenfilter und LOD bestimmen die Renderlast.</p>
</section>
<section class="settings-section research-settings">
@@ -130,40 +130,22 @@
</div>
</section>
<section class="settings-section category-settings">
<div class="settings-section-title"><h2>Kategorie-Filter</h2><span>Leer = alle erlaubten Kategorien</span></div>
<p id="filterScopeSummary" class="setting-hint filter-scope-summary">Environment-Grenzen werden geladen …</p>
<label class="filter-search"><span>Kategorien durchsuchen</span><input id="categorySearch" type="search" placeholder="z. B. GLPI, Netzwerk, Ollama"></label>
<div class="filter-block">
<div class="filter-heading"><div><b>Lernen</b><small>Nur diese Kategorien werden neu eingebettet.</small></div><button type="button" data-clear-filter="learning">Alle</button></div>
<div id="learningCategoryList" class="category-list"></div>
</div>
<div class="filter-block">
<div class="filter-heading"><div><b>Anzeige</b><small>Nur passende Notes und deren Taxonomie werden gerendert.</small></div><button type="button" data-clear-filter="display">Alle</button></div>
<div id="displayCategoryList" class="category-list"></div>
</div>
<div class="filter-block">
<div class="filter-heading"><div><b>Thinking</b><small>Nur diese Kategorien werden für neue AI-Edges geprüft.</small></div><button type="button" data-clear-filter="thinking">Alle</button></div>
<div id="thinkingCategoryList" class="category-list"></div>
</div>
</section>
<section class="settings-section source-settings">
<div class="settings-section-title"><h2>Quellen-Filter</h2><span>Quelle und Kategorie gelten gemeinsam</span></div>
<label class="filter-search"><span>Quellen durchsuchen</span><input id="sourceSearch" type="search" placeholder="z. B. GLPI Knowledge Base, internal-kb, docs.example.org"></label>
<div class="settings-section-title"><h2>KB-source-Filter</h2><span>exakter Treffer auf dem source-Feld</span></div>
<p id="filterScopeSummary" class="setting-hint filter-scope-summary">Quellen werden geladen …</p>
<label class="filter-search"><span>source-Werte durchsuchen</span><input id="sourceSearch" type="search" placeholder="z. B. internal-category oder GLPI Knowledge Base"></label>
<div class="filter-block">
<div class="filter-heading"><div><b>Lernen</b><small>Nur Wissen aus diesen Quellen wird neu eingebettet und bei Abfragen verwendet.</small></div><button type="button" data-clear-source-filter="learning">Alle</button></div>
<div id="learningSourceList" class="category-list"></div>
<div class="filter-heading"><div><b>Lernen</b><small>Nur KB-Dokumente mit exakt diesem source-Wert werden eingebettet und bei Abfragen verwendet.</small></div><button type="button" data-clear-source-filter="learning">Alle</button></div>
<div id="learningSourceList" class="source-list"></div>
</div>
<div class="filter-block">
<div class="filter-heading"><div><b>Anzeige</b><small>Nur passende Quellen werden gerendert; Taxonomie bleibt sichtbar.</small></div><button type="button" data-clear-source-filter="display">Alle</button></div>
<div id="displaySourceList" class="category-list"></div>
<div class="filter-heading"><div><b>Anzeige</b><small>Nur Dokumente mit exakt passendem source-Wert werden gerendert; direkte Taxonomie bleibt sichtbar.</small></div><button type="button" data-clear-source-filter="display">Alle</button></div>
<div id="displaySourceList" class="source-list"></div>
</div>
<div class="filter-block">
<div class="filter-heading"><div><b>Thinking</b><small>Nur diese Quellen dürfen neue Relationen und Artikel speisen.</small></div><button type="button" data-clear-source-filter="thinking">Alle</button></div>
<div id="thinkingSourceList" class="category-list"></div>
<div class="filter-heading"><div><b>Thinking</b><small>Nur Dokumente und Webbelege mit exakt passendem source-Wert speisen neue Relationen und Artikel.</small></div><button type="button" data-clear-source-filter="thinking">Alle</button></div>
<div id="thinkingSourceList" class="source-list"></div>
</div>
</section>