From 8b2473ad75fa7f48f8c36fb419106f1c1bb5c0f3 Mon Sep 17 00:00:00 2001 From: David de Hilster Date: Fri, 18 Sep 2026 14:39:04 -0700 Subject: [PATCH] Try page: the knowledge base says what each file holds, on mouse-over #25 gave a description per file -- the comment at the top of the .dict or .kbb, read by kbDescription() as the extension reads it -- and filled it on the editor page. The try page draws its own list and was left passing paths and sizes only, so after a rebuild it would have had the shorter kb/user/-less names but no descriptions. It now fills them from each file's text, which it already holds, and keeps the sizes. Seven of the ten .dict and .kbb files shipped have a comment to show; vocab.dict in Dates and Times and both ambigs files in Ambiguity have none, and show none. Co-Authored-By: Claude Opus 5 (1M context) --- studio/src/try/main.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/studio/src/try/main.ts b/studio/src/try/main.ts index 7651100..45db179 100644 --- a/studio/src/try/main.ts +++ b/studio/src/try/main.ts @@ -14,7 +14,7 @@ import "@visualtext/analyzer-views/style.css"; import "@visualtext/analyzer-views"; import type { NlpCode, NlpKnowledgeBase, NlpLog, NlpOutput, NlpSequence, NlpTrees, NlpValues, OpenDetail } from "@visualtext/analyzer-views"; -import { ruleMatches } from "@visualtext/analyzer-views/rules"; +import { kbDescription, ruleMatches, shownInKnowledgeBase } from "@visualtext/analyzer-views/rules"; import { fetchTree, outputFiles, runAnalyzer, serverHealth, type RunResult } from "../run/api"; import { inputTexts } from "./inputs"; @@ -158,8 +158,13 @@ async function openAnalyzer(entry: TryEntry): Promise { const encoder = new TextEncoder(); els.sequence.files = paths; els.sequence.sequence = state.files.get("spec/analyzer.seq") ?? ""; - // Bytes, not characters: a dictionary of accented words is longer than its length. - els.kb.files = paths.map((path) => ({ path, bytes: encoder.encode(state.files.get(path) ?? "").length })); + // Each file's opening comment is its mouse-over, as in the extension; kbDescription() + // reads only the top of it. Bytes, not characters: a dictionary of accented words is + // longer than its length. + els.kb.files = paths.filter(shownInKnowledgeBase).map((path) => { + const text = state.files.get(path) ?? ""; + return { path, bytes: encoder.encode(text).length, description: kbDescription(text) }; + }); els.shows.textContent = entry.shows; // Say which copy of the analyzer this is: a release tag when it came from the