Local code intelligence for developers and AI agents. Connect code, docs and infrastructure in a persistent graph, with CBM Lens, MCP tools, agent integrations and change-aware test selection.
C aiderastclaude-codecode-analysiscode-intelligencecodexcursorcypherdeveloper-toolsgemini-cligraph-visualizationkilocodeknowledge-graphmcpmcp-servermodel-context-protocolopencodesqlitetree-sitterwindsurf
fix(ui): smooth the German chat wording and fit examples to the kind
Bernhard Jackiewicz77639095e28e
diff --git a/graph-ui/src/browser-ai/BrowserChatDock.test.tsx b/graph-ui/src/browser-ai/BrowserChatDock.test.tsxindex c8fc84309..d5d3faebd 100644--- a/graph-ui/src/browser-ai/BrowserChatDock.test.tsx+++ b/graph-ui/src/browser-ai/BrowserChatDock.test.tsx@@ -1589,11 +1589,12 @@ describe('general questions, prompts without a question and configuration filesexpect(runtime.countTokens).not.toHaveBeenCalled();expect(runtime.chat).not.toHaveBeenCalled();expect(answer()).toContain('No question was recognized in "test". You can ask, for example:');- for (const example of ['What does JSONBAgg do?', 'Who calls JSONBAgg?', 'What does JSONBAgg call?']) expect(answer()).toContain(example);+ // JSONBAgg is a class: what it is, who uses it, what it inherits from (W9).+ for (const example of ['What is JSONBAgg?', 'Who uses JSONBAgg?', 'What does JSONBAgg inherit from?']) expect(answer()).toContain(example);expect(buttons()).toEqual(['Ask the model']);await type('hallo'); await click('Send ↑');- expect(answer()).toContain('In "hallo" wurde keine Frage erkannt. Frage zum Beispiel:');- for (const example of ['Was macht JSONBAgg?', 'Wer ruft JSONBAgg auf?']) expect(answer()).toContain(example);+ expect(answer()).toContain('In „hallo“ wurde keine Frage erkannt. Du kannst zum Beispiel fragen:');+ for (const example of ['Was ist JSONBAgg?', 'Wer verwendet JSONBAgg?']) expect(answer()).toContain(example);expect(buttons()).toEqual(['Modell fragen']);expect(runtime.chat).not.toHaveBeenCalled();await act(async () => button('Modell fragen').click());diff --git a/graph-ui/src/browser-ai/BrowserChatDock.tsx b/graph-ui/src/browser-ai/BrowserChatDock.tsxindex 98371ff89..2c89d02e6 100644--- a/graph-ui/src/browser-ai/BrowserChatDock.tsx+++ b/graph-ui/src/browser-ai/BrowserChatDock.tsx@@ -652,7 +652,7 @@ export default function BrowserChatDock({ proactiveSelection, selectionScope = "const known = knownNames({ galaxy, names: galaxy ? galaxyNames(galaxy) : fileSource ? [fileSource.path] : [],texts: [fileSource?.text ?? '', source?.text ?? '', ...currentGraph.filter(() => !galaxy).map(item => item.label), ...extra.map(item => item.label)] });if (!retry && noQuestion(prompt, known)) {- const subject = galaxy ? { kind: 'galaxy' as const, name: galaxy.label } : fileSource?.kind === 'selection' || source ? { kind: 'marked' as const }+ const subject = galaxy ? { kind: 'galaxy' as const, name: galaxy.label, evidence: galaxy } : fileSource?.kind === 'selection' || source ? { kind: 'marked' as const }: { kind: 'other' as const, name: fileSource ? fileSource.path.split('/').pop()! : topic?.label ?? '' };setTurns(previous => [...previous, { id: `local-turn-${crypto.randomUUID()}`, prompt, attachment: source, readerContext: reader, context: extra, topic, replyLanguage: language,...currentGraph[0] ? { listedFrom: currentGraph[0] } : {}, modelId: model.id, request: [], answer: noQuestionAnswer(prompt, language, subject), status: 'complete', answeredFrom: 'hint' }]);diff --git a/graph-ui/src/browser-ai/chat-wording.test.ts b/graph-ui/src/browser-ai/chat-wording.test.tsindex b856bcf45..0242b8454 100644--- a/graph-ui/src/browser-ai/chat-wording.test.ts+++ b/graph-ui/src/browser-ai/chat-wording.test.ts@@ -1,9 +1,12 @@import { describe, expect, it } from 'vitest';+import { selectionEvidenceContext } from '../galaxy/selection-evidence';import { prepareExplanationContext, selectionSummary } from './explanation-context';import { explanationSentence, formatExplanationEvidence, namesNotIn } from './explanation-response';-import { jsonbAggEvidence, jsonbAggRenderLimited } from './galaxy-evidence.fixture';-import { relationshipAnswer } from './relationship-answer';-import { browserChatText, groundedText, topicText } from './strings';+import { readGalaxyEvidence } from './galaxy-evidence';+import { jsonbAggEvidence, jsonbAggRenderLimited, largeFolderScope } from './galaxy-evidence.fixture';+import { generalQuestion, noQuestionAnswer } from './question-intent';+import { relationshipAnswer, relationshipQuestion, relationshipSuggestion } from './relationship-answer';+import { browserChatText, groundedText, relationshipWords, topicText } from './strings';import { sourceTargetOf, symbolSource } from './symbol-source';/* Wording of the chat texts after the third review of the hand test (2026-10-04, W1 to W10). */@@ -218,3 +221,59 @@ describe('German answers in German, with the controls named as the UI shows themexpect(topicText.de.topicBreak('tox.ini')).toBe('Neues Thema: tox.ini. Frühere Nachrichten werden bei diesen Fragen nicht mitgeschickt.');});});++describe('German wording and examples that fit the selection (W9)', () => {+ const jsonb = () => readGalaxyEvidence(jsonbAggEvidence().text)!;++ it('suggests questions to a German prompt without a question in natural German', () => {+ const answer = noQuestionAnswer('test', 'de', { kind: 'galaxy', name: 'JSONBAgg', evidence: jsonb() });+ expect(answer.startsWith('In „test“ wurde keine Frage erkannt. Du kannst zum Beispiel fragen:')).toBe(true);+ expect(answer).not.toContain('Frage zum Beispiel');+ });++ it('offers examples for a class that make sense for a class, and that the chat answers as offered', () => {+ const german = noQuestionAnswer('test', 'de', { kind: 'galaxy', name: 'JSONBAgg', evidence: jsonb() });+ expect(german).toContain('- Was ist JSONBAgg?\n- Wer verwendet JSONBAgg?\n- Wovon erbt JSONBAgg?');+ expect(german).not.toContain('Was ruft JSONBAgg auf?');+ const english = noQuestionAnswer('test', 'en', { kind: 'galaxy', name: 'JSONBAgg', evidence: jsonb() });+ expect(english).toContain('- What is JSONBAgg?\n- Who uses JSONBAgg?\n- What does JSONBAgg inherit from?');+ expect(english).not.toContain('What does JSONBAgg call?');+ expect(generalQuestion('What is JSONBAgg?', ['JSONBAgg'])).toBe('general');+ expect(generalQuestion('Was ist JSONBAgg?', ['JSONBAgg'])).toBe('general');+ expect(relationshipQuestion('Who uses JSONBAgg?')?.sides).toEqual(['incoming']);+ expect(relationshipQuestion('Wer verwendet JSONBAgg?')?.sides).toEqual(['incoming']);+ // A class that inherits nothing gets no question about it.+ const plain = { ...jsonb(), relationships: { ...jsonb().relationships, outgoing: [] } };+ expect(noQuestionAnswer('test', 'en', { kind: 'galaxy', name: 'JSONBAgg', evidence: plain })).not.toContain('inherit');+ });++ it('keeps the call questions for a function and asks what a folder contains', () => {+ const method = { ...jsonb(), roots: [{ ...jsonb().roots[0], kind: 'Method' }] };+ expect(noQuestionAnswer('test', 'en', { kind: 'galaxy', name: 'handle', evidence: method })).toContain('- What does handle do?\n- Who calls handle?\n- What does handle call?');+ const folder = readGalaxyEvidence(selectionEvidenceContext(largeFolderScope()).text)!;+ expect(noQuestionAnswer('hallo', 'de', { kind: 'galaxy', name: 'postgres', evidence: folder })).toContain('- Was enthält postgres?\n- Erklär postgres ausführlich.');+ expect(generalQuestion('Was enthält postgres?', ['postgres'])).toBe('general');+ });++ it('offers the list or the model as a choice, not as an order', () => {+ expect(relationshipSuggestion('jsonbagg aufrufe?', [jsonbAggEvidence()])!.markdown)+ .toContain('_Die Frage wurde nicht sicher erkannt. Du kannst dir die Liste aus dem indizierten Graphen anzeigen lassen oder das Modell fragen._');+ expect(relationshipSuggestion('jsonbagg calls', [jsonbAggEvidence()])!.markdown)+ .toContain('_The question was not recognized for certain. You can show the list from the indexed graph or ask the model._');+ expect(relationshipSuggestion('wer ruft JSONBAg auf', [jsonbAggEvidence()])!.markdown)+ .toContain('_`JSONBAg` entspricht nicht dem Namen der Auswahl (`JSONBAgg`). Du kannst dir die Liste aus dem indizierten Graphen anzeigen lassen oder das Modell fragen._');+ expect(relationshipSuggestion('who calls JSONBAg?', [jsonbAggEvidence()])!.markdown)+ .toContain('_`JSONBAg` does not match the name of the selection (`JSONBAgg`). You can show the list from the indexed graph or ask the model._');+ });++ it('names what defines the selection with the right article and pronoun for every kind', () => {+ expect(relationshipWords.de.definer('File', 1, 'X')).toBe('die Datei, die X definiert');+ expect(relationshipWords.de.definer('Module', 1, 'X')).toBe('das Modul, das X definiert');+ expect(relationshipWords.de.definer('Interface', 1, 'X')).toBe('die Schnittstelle, die X definiert');+ expect(relationshipWords.de.definer('Folder', 1, 'X')).toBe('der Ordner, der X definiert');+ expect(relationshipWords.de.definer('Class', 2, 'X')).toBe('die Klassen, die X definieren');+ expect(relationshipWords.de.definer('Gadget', 1, 'X')).toBe('das Symbol (Gadget), das X definiert');+ expect(relationshipWords.en.definer('Class', 2, 'X')).toBe('the classes that define X');+ expect(relationshipWords.en.definer('Interface', 1, 'X')).toBe('the interface that defines X');+ });+});diff --git a/graph-ui/src/browser-ai/question-intent.ts b/graph-ui/src/browser-ai/question-intent.tsindex f4a05d620..1650f96e1 100644--- a/graph-ui/src/browser-ai/question-intent.ts+++ b/graph-ui/src/browser-ai/question-intent.ts@@ -93,14 +93,25 @@ export function noQuestion(prompt: string, known: (word: string) => boolean): boreturn words.length <= 3 && words.every(word => GREETINGS.has(word));}-/** What the examples of a prompt without a question are about. */-export type ExampleSubject = { kind: 'galaxy' | 'other'; name: string } | { kind: 'marked' };+/** What the examples of a prompt without a question are about; a Galaxy selection with its evidence. */+export type ExampleSubject = { kind: 'galaxy'; name: string; evidence?: GalaxyEvidence } | { kind: 'other'; name: string } | { kind: 'marked' };++/** Kinds asked about as a type, and kinds that hold other symbols. */+const TYPE_KINDS = new Set(['class', 'interface', 'struct', 'trait', 'enum', 'type']);+const CONTAINER_KINDS = new Set(['file', 'folder', 'module', 'package', 'namespace', 'project']);+/** Questions that suit the selected kind: "What does JSONBAgg call?" led a class to "no CALLS edge" (W9). */+function galaxyExamples(text: typeof noQuestionText['en'], name: string, evidence?: GalaxyEvidence): string[] {+ const kind = (evidence && evidence.rootCount <= 1 ? evidence.roots[0]?.kind ?? evidence.selectionKind : evidence?.selectionKind)?.toLowerCase() ?? '';+ if (TYPE_KINDS.has(kind)) return [text.whatIs(name), text.whoUses(name), ...evidence?.relationships.outgoing.some(group => group.type === 'INHERITS') ? [text.whatInherits(name)] : []];+ if (CONTAINER_KINDS.has(kind)) return [text.whatContains(name), text.inDetail(name)];+ return [text.whatDoes(name), text.whoCalls(name), text.whatCalls(name)];+}/** "No question was recognized in "test"." and two or three questions that work for the selection (C6). */export function noQuestionAnswer(typed: string, language: 'en' | 'de', subject: ExampleSubject): string {const text = noQuestionText[language];const examples = subject.kind === 'marked' ? [text.markedDoes, text.markedInDetail]- : subject.kind === 'galaxy' ? [text.whatDoes(subject.name), text.whoCalls(subject.name), text.whatCalls(subject.name)]+ : subject.kind === 'galaxy' ? galaxyExamples(text, subject.name, subject.evidence): [text.whatDoes(subject.name), text.inDetail(subject.name)];const shown = typed.replace(/\s+/g, ' ').replace(/["`]/g, "'").trim().slice(0, 40);return `${text.heading(shown)}\n\n${examples.map(example => `- ${example}`).join('\n')}\n\n_${text.note}_`;diff --git a/graph-ui/src/browser-ai/relationship-answer.test.ts b/graph-ui/src/browser-ai/relationship-answer.test.tsindex 80fb9d427..135a8ad1a 100644--- a/graph-ui/src/browser-ai/relationship-answer.test.ts+++ b/graph-ui/src/browser-ai/relationship-answer.test.ts@@ -314,7 +314,7 @@ describe('caller questions with a misspelled selection or a free word order (K16? expected === 'incoming' ? 'Meintest du: Aufrufer von `JSONBAgg`?' : 'Meintest du: von `JSONBAgg` aufgerufene Symbole?': expected === 'incoming' ? 'Did you mean: callers of `JSONBAgg`?' : 'Did you mean: what `JSONBAgg` calls?');// The uncertain part is the name, and the reply says so.- if (relationshipQuestion(prompt)) expect(suggestion?.markdown).toContain(language === 'de' ? 'ist nicht genau der Name der Auswahl' : 'is not exactly the name of the selection');+ if (relationshipQuestion(prompt)) expect(suggestion?.markdown).toContain(language === 'de' ? 'entspricht nicht dem Namen der Auswahl (`JSONBAgg`)' : 'does not match the name of the selection (`JSONBAgg`)');// The suggested question lists the selection when chosen.expect(relationshipAnswer(suggestion!.question, evidence())?.markdown).toContain(heading(expected, language));});diff --git a/graph-ui/src/browser-ai/relationship-answer.ts b/graph-ui/src/browser-ai/relationship-answer.tsindex 1bf92862a..b8d15a142 100644--- a/graph-ui/src/browser-ai/relationship-answer.ts+++ b/graph-ui/src/browser-ai/relationship-answer.ts@@ -216,7 +216,7 @@ function suggestionFor(sides: readonly Side[], language: 'en' | 'de', evidence:: both ? `Who calls ${name} and what does ${name} call?` : outgoing ? `What does ${name} call?` : `Who calls ${name}?`;const text = relationshipWords[language];const heading = both ? text.didYouMeanBoth(quote(name)) : text.didYouMean(outgoing ? 'outgoing' : 'incoming', quote(name));- return { markdown: `${heading}\n\n_${typedName ? text.uncertainName(quote(typedName)) : text.uncertain}_`, question, context, language };+ return { markdown: `${heading}\n\n_${typedName ? text.uncertainName(quote(typedName), quote(name)) : text.uncertain}_`, question, context, language };}/** A question that sounds like callers or callees of the selection, but not certainly:diff --git a/graph-ui/src/browser-ai/strings.ts b/graph-ui/src/browser-ai/strings.tsindex a2790f299..c4508abb9 100644--- a/graph-ui/src/browser-ai/strings.ts+++ b/graph-ui/src/browser-ai/strings.ts@@ -103,7 +103,10 @@ const englishRelationshipWords = {/** One edge type of a listed answer with the number of its symbols: "TESTS (11)". */typeCount: (type: string, count: number) => `${type} (${en(count)})`,/** What an incoming DEFINES edge from a file, module or class says about the selection. */- definer: (kind: string, count: number, name: string) => count === 1 ? `the ${kind.toLowerCase()} that defines ${name}` : `the ${kind.toLowerCase()}s that define ${name}`,+ definer: (kind: string, count: number, name: string) => {+ const noun = kind.toLowerCase();+ return count === 1 ? `the ${noun} that defines ${name}` : `the ${/(?:s|x|ch|sh)$/.test(noun) ? `${noun}es` : `${noun}s`} that define ${name}`;+ },noCalls: (name: string, side: 'incoming' | 'outgoing') => side === 'incoming'? `No CALLS edge reaches ${name} in this scope.` : `${name} has no outgoing CALLS edge in this scope.`,otherRelationships: (side: 'incoming' | 'outgoing') => `Other ${side} relationships:`,@@ -116,8 +119,9 @@ const englishRelationshipWords = {listedFromGraph: 'Listed from the indexed graph; not generated by the model.',didYouMean: (side: 'incoming' | 'outgoing', name: string) => side === 'incoming' ? `Did you mean: callers of ${name}?` : `Did you mean: what ${name} calls?`,didYouMeanBoth: (name: string) => `Did you mean: callers of ${name} and what it calls?`,- uncertain: 'The question was not recognized for certain. Show the list from the indexed graph, or ask the model instead.',- uncertainName: (typed: string) => `${typed} is not exactly the name of the selection. Show the list from the indexed graph, or ask the model instead.`,+ /** A choice, not an order: the buttons "Show the list" and "Ask the model" follow (W9). */+ uncertain: 'The question was not recognized for certain. You can show the list from the indexed graph or ask the model.',+ uncertainName: (typed: string, name: string) => `${typed} does not match the name of the selection (${name}). You can show the list from the indexed graph or ask the model.`,showList: 'Show the list',/** Offered under a listed answer or a suggestion, which the model did not write. */askModel: 'Ask the model',@@ -173,10 +177,12 @@ export const relationshipWords: { en: RelationshipWords; de: RelationshipWords }: `${name} ruft in diesem Ausschnitt nichts auf und hat keine anderen ausgehenden Beziehungen.`,cutListed: (side: 'incoming' | 'outgoing') => `Der Schnappschuss hat die ${side === 'incoming' ? 'eingehenden' : 'ausgehenden'} Beziehungen ausgelassen.`,typeCount: (type: string, count: number) => `${type} (${de(count)})`,+ /** Article and relative pronoun follow the gender of the kind: "der Ordner, der", "die Schnittstelle, die" (W9). */definer: (kind: string, count: number, name: string) => {- const noun = ({ file: ['die Datei', 'die Dateien'], module: ['das Modul', 'die Module'], class: ['die Klasse', 'die Klassen'] } as Record<string, string[]>)[kind.toLowerCase()]- ?? [`${kind}`, `${kind}`];- return count === 1 ? `${noun[0]}, ${noun[0].startsWith('das') ? 'das' : 'die'} ${name} definiert` : `${noun[1]}, die ${name} definieren`;+ const known = GERMAN_KINDS[kind.toLowerCase()];+ const [noun, plural, gender] = known ?? [`Symbol (${kind})`, `Symbole (${kind})`, 'n'];+ const article = gender === 'f' ? 'die' : gender === 'm' ? 'der' : 'das';+ return count === 1 ? `${article} ${noun}, ${article} ${name} definiert` : `die ${plural}, die ${name} definieren`;},noCalls: (name: string, side: 'incoming' | 'outgoing') => side === 'incoming'? `Keine CALLS-Kante führt in diesem Ausschnitt zu ${name}.` : `${name} hat in diesem Ausschnitt keine ausgehende CALLS-Kante.`,@@ -190,8 +196,8 @@ export const relationshipWords: { en: RelationshipWords; de: RelationshipWords }listedFromGraph: 'Aus dem indizierten Graphen gelistet, nicht vom Modell erzeugt.',didYouMean: (side: 'incoming' | 'outgoing', name: string) => side === 'incoming' ? `Meintest du: Aufrufer von ${name}?` : `Meintest du: von ${name} aufgerufene Symbole?`,didYouMeanBoth: (name: string) => `Meintest du: Aufrufer von ${name} und was ${name} aufruft?`,- uncertain: 'Die Frage wurde nicht sicher erkannt. Zeige die Liste aus dem indizierten Graphen oder frage stattdessen das Modell.',- uncertainName: (typed: string) => `${typed} ist nicht genau der Name der Auswahl. Zeige die Liste aus dem indizierten Graphen oder frage stattdessen das Modell.`,+ uncertain: 'Die Frage wurde nicht sicher erkannt. Du kannst dir die Liste aus dem indizierten Graphen anzeigen lassen oder das Modell fragen.',+ uncertainName: (typed: string, name: string) => `${typed} entspricht nicht dem Namen der Auswahl (${name}). Du kannst dir die Liste aus dem indizierten Graphen anzeigen lassen oder das Modell fragen.`,showList: 'Liste anzeigen',askModel: 'Modell fragen',},@@ -293,16 +299,25 @@ export const noQuestionText = {whoCalls: (name: string) => `Who calls ${name}?`,whatCalls: (name: string) => `What does ${name} call?`,inDetail: (name: string) => `Explain ${name} in detail.`,+ /** For a class: what it is, who uses it and what it inherits from; for a file or folder: what it contains (W9). */+ whatIs: (name: string) => `What is ${name}?`,+ whoUses: (name: string) => `Who uses ${name}?`,+ whatInherits: (name: string) => `What does ${name} inherit from?`,+ whatContains: (name: string) => `What does ${name} contain?`,markedDoes: 'What does the marked code do?',markedInDetail: 'Explain the marked code line by line.',},de: {- heading: (typed: string) => `In "${typed}" wurde keine Frage erkannt. Frage zum Beispiel:`,+ heading: (typed: string) => `In „${typed}“ wurde keine Frage erkannt. Du kannst zum Beispiel fragen:`,note: 'Ohne das Modell beantwortet.',whatDoes: (name: string) => `Was macht ${name}?`,whoCalls: (name: string) => `Wer ruft ${name} auf?`,whatCalls: (name: string) => `Was ruft ${name} auf?`,inDetail: (name: string) => `Erklär ${name} ausführlich.`,+ whatIs: (name: string) => `Was ist ${name}?`,+ whoUses: (name: string) => `Wer verwendet ${name}?`,+ whatInherits: (name: string) => `Wovon erbt ${name}?`,+ whatContains: (name: string) => `Was enthält ${name}?`,markedDoes: 'Was macht der markierte Code?',markedInDetail: 'Erklär den markierten Code Zeile für Zeile.',},diff --git a/graph-ui/tools/handtest-fixes-chat.mjs b/graph-ui/tools/handtest-fixes-chat.mjsindex da5bdfb42..67052140a 100644--- a/graph-ui/tools/handtest-fixes-chat.mjs+++ b/graph-ui/tools/handtest-fixes-chat.mjs@@ -325,8 +325,8 @@ async function k16(page) {const typoModelCalls = (await sentSince(page, typoMark)).length;check('K16', 'A typo in the selected name (up to two letters, any case) is offered for the selection, a free word order with "wo" is listed; none of them reach the model',orders.every((item) => /Aufrufer \(CALLS\) von JSONBAgg im geladenen Graphen/.test(item.answer) && callers.every((name) => item.answer.includes(name)))- && typos.every((item) => item.language === 'de' ? /Meintest du: Aufrufer von JSONBAgg\?/.test(item.answer) && /ist nicht genau der Name der Auswahl/.test(item.answer)- : /Did you mean: callers of JSONBAgg\?/.test(item.answer) && /is not exactly the name of the selection/.test(item.answer))+ && typos.every((item) => item.language === 'de' ? /Meintest du: Aufrufer von JSONBAgg\?/.test(item.answer) && /entspricht nicht dem Namen der Auswahl \(JSONBAgg\)/.test(item.answer)+ : /Did you mean: callers of JSONBAgg\?/.test(item.answer) && /does not match the name of the selection \(JSONBAgg\)/.test(item.answer))&& /callers \(CALLS\) of JSONBAgg in the loaded graph/.test(typoListed) && typoModelCalls === 0,{ orders: orders.map((item) => `${item.question} => ${item.answer.replace(/\s+/g, ' ').slice(0, 140)}`), typos: typos.map((item) => `${item.question} => ${item.answer.replace(/\s+/g, ' ').slice(0, 160)}`),afterShowList: typoListed.replace(/\s+/g, ' ').slice(0, 140), modelCalls: typoModelCalls });