Skip to content

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.

Merge third round: chat wording, counts with units, render limit sentence, dropped sentence reason, token note, unknown names, German answers, Architecture card

Bernhard Jackiewicz234e0f23298f
diff --cc graph-ui/src/browser-ai/BrowserChatDock.ask-model.test.tsx
index 6dd383256,000000000..10ea55d0b
mode 100644,000000..100644
--- a/graph-ui/src/browser-ai/BrowserChatDock.ask-model.test.tsx
+++ b/graph-ui/src/browser-ai/BrowserChatDock.ask-model.test.tsx
@@@ -1,85 -1,0 +1,85 @@@
+// @vitest-environment jsdom
+import { describe, expect, it } from 'vitest';
+import { JSONB_AGG_CALLERS, jsonbAggEvidence } from './galaxy-evidence.fixture';
+import { dockHarness, readerOf } from './chat-dock.fixture';
+
+const dock = dockHarness();
+const PRE_COMMIT = 'repos:\n - repo: https://github.com/PyCQA/isort\n rev: 5.13.2\n hooks:\n - id: isort\n';
+
+/** "Ask the model" under an answer the chat gave itself put the model's text in its place: the
+ * 11 listed callers became one sentence naming one of them, and nothing said who wrote it (B1). */
+describe('the model answer to a listed, grounded or file answer is a turn of its own (B1)', () => {
+ it('keeps the listed callers and adds the model answer below them, marked as generated', async () => {
+ const { props, runtime } = dock.setup();
+ runtime.chat.mockResolvedValueOnce('The call to JSONBAgg is made by the test_jsonb_agg method.');
+ await dock.render({ ...props, proactiveSelection: jsonbAggEvidence() }); await dock.load();
+ await dock.ask('Who calls JSONBAgg?');
+ await dock.click('Ask the model', dock.last());
+ expect(runtime.chat).toHaveBeenCalledOnce();
+ const [listed, asked] = dock.turns();
+ expect(dock.turns()).toHaveLength(2);
+ for (const name of JSONB_AGG_CALLERS) expect(dock.answerOf(listed)).toContain(name);
+ expect(dock.answerOf(listed)).toContain('not generated by the model');
+ expect(asked.querySelector('.cbm-chat-question')?.textContent).toContain('Who calls JSONBAgg?');
+ expect(asked.querySelector('.cbm-chat-asked-model')?.textContent).toBe('Asked the local model');
+ expect(dock.answerOf(asked)).toBe('The call to JSONBAgg is made by the test_jsonb_agg method.');
+ expect(dock.notesOf(asked)).toContain('Generated by the local model; it can be wrong.');
+ // Only the last turn offers a button: asking again repeats the model's answer in place.
+ expect(dock.buttonsOf(listed)).toEqual([]);
+ expect(dock.buttonsOf(asked)).toEqual(['Ask again']);
+ await dock.click('Ask again', asked);
+ expect(runtime.chat).toHaveBeenCalledTimes(2);
+ expect(runtime.chat.mock.calls[1][0]).toEqual(runtime.chat.mock.calls[0][0]);
+ expect(dock.turns()).toHaveLength(2);
+ });
+
+ it('keeps German facts and adds the model answer with a German note', async () => {
+ const { props, runtime } = dock.setup();
+ runtime.chat.mockResolvedValueOnce('`JSONBAgg` setzt `function` auf "JSONB_AGG".').mockResolvedValueOnce('Diese Klasse ist eine Aggregation.');
+ await dock.render({ ...props, proactiveSelection: jsonbAggEvidence() }); await dock.load();
+ await dock.ask('was macht diese klasse? sehr kurze antwort');
+ const facts = dock.answerOf(dock.last());
- expect(facts).toContain('Ausgewählt: JSONBAgg (Class)');
++ expect(facts).toContain('Ausgewählt: JSONBAgg (Klasse)');
+ await dock.click('Modell fragen', dock.last());
+ const [grounded, asked] = dock.turns();
+ expect(dock.turns()).toHaveLength(2);
+ expect(dock.answerOf(grounded)).toBe(facts);
+ expect(asked.querySelector('.cbm-chat-asked-model')?.textContent).toBe('An das lokale Modell gestellt');
+ expect(dock.answerOf(asked)).toBe('Diese Klasse ist eine Aggregation.');
+ expect(dock.notesOf(asked)).toContain('Vom lokalen Modell erzeugt; kann falsch sein.');
+ expect(dock.buttonsOf(asked)).toEqual(['Erneut fragen']);
+ });
+
+ it('keeps a file outline and adds the model answer below it', async () => {
+ const { props, runtime } = dock.setup();
+ runtime.chat.mockResolvedValueOnce('This file configures pre-commit hooks.');
+ await dock.render({ ...props, selectionScope: 'django-demo:explore', readerContext: readerOf(PRE_COMMIT, '.pre-commit-config.yaml') }); await dock.load();
+ await dock.ask('What does this file do?');
+ const outline = dock.answerOf(dock.last());
+ expect(outline).toContain('repos (list of 1):');
+ await dock.click('Ask the model', dock.last());
+ expect(dock.turns()).toHaveLength(2);
+ expect(dock.answerOf(dock.turns()[0])).toBe(outline);
+ expect(dock.answerOf(dock.last())).toBe('This file configures pre-commit hooks.');
+ // The model is asked about the file, and the outline is not handed to it as an earlier answer.
+ const request = runtime.chat.mock.calls[0][0];
+ expect(request[0].content).toContain('--- BEGIN EXACT SOURCE TEXT ---\nrepos:');
+ expect(request.filter(message => message.role === 'assistant')).toHaveLength(0);
+ // A follow-up carries both: the outline and the model's answer.
+ await dock.ask('Which hook runs isort?');
+ expect(dock.questionsIn(runtime.chat.mock.calls[1][0])).toEqual(['What does this file do?', 'What does this file do?', 'Which hook runs isort?']);
+ });
+
+ it('marks every free model answer as generated, in the language of the question', async () => {
+ const { props, runtime } = dock.setup();
+ runtime.chat.mockResolvedValueOnce('It adds two values.').mockResolvedValueOnce('Es addiert zwei Werte.');
+ await dock.render({ ...props, readerContext: readerOf('export const sum = (a: number, b: number) => a + b;', 'src/sum.ts') }); await dock.load();
+ await dock.ask('Which values does it add, and where is it used?');
+ expect(dock.notesOf(dock.last())).toContain('Generated by the local model; it can be wrong.');
+ expect(dock.buttonsOf(dock.last())).toEqual(['Ask again']);
+ expect(dock.last().querySelector('.cbm-chat-asked-model')).toBeNull();
+ await dock.ask('Welche Werte addiert es, und wo wird es benutzt?');
+ expect(dock.notesOf(dock.last())).toContain('Vom lokalen Modell erzeugt; kann falsch sein.');
+ expect(dock.buttonsOf(dock.last())).toEqual(['Erneut fragen']);
+ });
+});
diff --cc graph-ui/src/browser-ai/BrowserChatDock.code-facts.test.tsx
index 6640ee775,000000000..8625ba9d0
mode 100644,000000..100644
--- a/graph-ui/src/browser-ai/BrowserChatDock.code-facts.test.tsx
+++ b/graph-ui/src/browser-ai/BrowserChatDock.code-facts.test.tsx
@@@ -1,62 -1,0 +1,63 @@@
+// @vitest-environment jsdom
+import { act } from 'react';
+import { afterEach, describe, expect, it, vi } from 'vitest';
+import { jsonbAggEvidence } from './galaxy-evidence.fixture';
+import { dockHarness } from './chat-dock.fixture';
+
+const dock = dockHarness();
+
+/** "was macht diese klasse? sehr kurze antwort" on JSONBAgg got only counts: the model's sentence
+ * claimed "Arrays" and was dropped, and nothing said what the class declares (B2). */
+describe('a general question about a selected symbol says what its code declares (B2)', () => {
+ afterEach(() => vi.useRealTimers());
+
+ it('lists the class line and its assignments under "Im Quelltext:" even when the sentence is dropped', async () => {
+ const { props, runtime } = dock.setup();
+ runtime.chat.mockResolvedValueOnce('JSONBAgg ist eine Aggregation, die Werte in einen JSON-Array umwandelt.');
+ await dock.render({ ...props, proactiveSelection: jsonbAggEvidence() }); await dock.load();
+ await dock.ask('was macht diese klasse? sehr kurze antwort');
+ expect(runtime.chat).toHaveBeenCalledOnce();
+ const answer = dock.answerOf(dock.last());
- expect(answer).toContain('Ausgewählt: JSONBAgg (Class)');
++ expect(answer).toContain('Ausgewählt: JSONBAgg (Klasse)');
+ expect(answer).toContain('Im Quelltext:');
+ for (const line of ['class JSONBAgg(OrderableAggMixin, Aggregate):', 'function = "JSONB_AGG"', 'template = "%(function)s(%(distinct)s%(expressions)s %(order_by)s)"',
+ 'allow_distinct = True', 'output_field = JSONField()']) expect(dock.last().querySelector('.cbm-chat-answer-text pre')?.textContent).toContain(line);
+ expect(answer).not.toContain('JSON-Array');
+ expect(answer).toContain('wurde weggelassen');
+ // The facts come first, then the code, then who wrote what.
+ expect(answer.indexOf('Ausgewählt:')).toBeLessThan(answer.indexOf('Im Quelltext:'));
+ expect(answer.indexOf('Im Quelltext:')).toBeLessThan(answer.indexOf('wurde weggelassen'));
+ });
+
+ it('says it in English for an English question, with the checked sentence after the code', async () => {
+ const { props, runtime } = dock.setup();
+ runtime.chat.mockResolvedValueOnce('`JSONBAgg` sets `function` to "JSONB_AGG" and allows distinct values.');
+ await dock.render({ ...props, proactiveSelection: jsonbAggEvidence() }); await dock.load();
+ await dock.ask('What does this do?');
+ const answer = dock.answerOf(dock.last());
+ expect(answer).toContain('In the source:');
+ expect(answer).toContain('class JSONBAgg(OrderableAggMixin, Aggregate):');
+ expect(answer.indexOf('In the source:')).toBeLessThan(answer.indexOf('JSONBAgg sets function to "JSONB_AGG"'));
+ });
+
+ it('shows no code without source: the listed facts stay the answer', async () => {
+ const { props, runtime } = dock.setup();
+ await dock.render({ ...props, proactiveSelection: jsonbAggEvidence(), readSource: vi.fn(async () => { throw new Error('offline'); }) }); await dock.load();
+ await dock.ask('What does this do?');
+ expect(runtime.chat).not.toHaveBeenCalled();
+ expect(dock.answerOf(dock.last())).not.toContain('In the source:');
+ });
+
+ it('adds the same lines to the automatic explanation card', async () => {
+ vi.useFakeTimers(); const { props, runtime } = dock.setup();
+ runtime.chat.mockResolvedValueOnce('JSONBAgg turns rows into arrays.');
+ await dock.render({ ...props, proactive: true, proactiveSelection: jsonbAggEvidence() }); await dock.load();
+ await act(async () => { await vi.advanceTimersByTimeAsync(650); });
+ const card = dock.card()!.textContent ?? '';
- expect(card).toContain('Incoming relationships: 23 from 12 symbols');
++ expect(card).toContain('Incoming: 23 relationships from 12 symbols');
+ expect(card).toContain('In the source:');
+ expect(card).toContain('output_field = JSONField()');
- expect(card).not.toContain('arrays');
++ // The dropped sentence stays out; only the note names its claim (W5).
++ expect(card).not.toContain('turns rows into arrays');
+ });
+});
diff --cc graph-ui/src/browser-ai/BrowserChatDock.code-questions.test.tsx
index 71de0da8f,000000000..cdb2ac45d
mode 100644,000000..100644
--- a/graph-ui/src/browser-ai/BrowserChatDock.code-questions.test.tsx
+++ b/graph-ui/src/browser-ai/BrowserChatDock.code-questions.test.tsx
@@@ -1,60 -1,0 +1,61 @@@
+// @vitest-environment jsdom
+import { describe, expect, it } from 'vitest';
+import { dockHarness, readerOf } from './chat-dock.fixture';
+
+const dock = dockHarness();
+const GENERAL = '"""Aggregate functions for PostgreSQL."""\nfrom django.db.models import Aggregate\n\n\n'
+ + 'class ArrayAgg(OrderableAggMixin, Aggregate):\n function = "ARRAY_AGG"\n allow_distinct = True\n\n\n'
+ + 'class JSONBAgg(OrderableAggMixin, Aggregate):\n function = "JSONB_AGG"\n allow_distinct = True\n output_field = JSONField()\n';
+const PATH = 'django/contrib/postgres/aggregates/general.py';
+const JSONB_AGG = 'class JSONBAgg(OrderableAggMixin, Aggregate):\n function = "JSONB_AGG"\n allow_distinct = True\n output_field = JSONField()';
+
+/** Short general questions about an open code file or marked code got the free model answer
+ * the reader had called garbled, while a Galaxy selection got listed facts and one checked
+ * sentence (B3). */
+describe('short general questions about an open code file or marked code (B3)', () => {
+ it('answers "was macht diese datei?" with facts read from the file and one checked model text, in German', async () => {
+ const { props, runtime } = dock.setup();
+ runtime.chat.mockResolvedValueOnce('Die Datei definiert die Aggregate `ArrayAgg` und `JSONBAgg`.');
+ await dock.render({ ...props, selectionScope: 'django-demo:explore', readerContext: readerOf(GENERAL, PATH) }); await dock.load();
+ await dock.ask('was macht diese datei?');
+ expect(runtime.chat).toHaveBeenCalledOnce();
+ const [request, , options] = runtime.chat.mock.calls[0];
+ expect(options).toMatchObject({ generationProfile: 'automatic-explanation' });
+ expect(request.at(-1)!.content).toContain('Answer in German.');
+ expect(request.at(-1)!.content).toContain('class JSONBAgg(OrderableAggMixin, Aggregate):');
+ const answer = dock.answerOf(dock.last());
+ expect(answer).toContain('general.py: Python-Quelltext, 13 Zeilen.');
+ expect(answer).toContain('Docstring des Moduls: "Aggregate functions for PostgreSQL."');
+ expect(answer).toContain('Definitionen auf oberster Ebene (2): class ArrayAgg, class JSONBAgg.');
+ expect(answer).toContain('Die Datei definiert die Aggregate ArrayAgg und JSONBAgg.');
+ expect(answer).toContain('Fakten aus der Datei gelesen; der Text danach ist vom Modell erzeugt.');
+ expect(dock.buttonsOf(dock.last())).toEqual(['Modell fragen']);
+ });
+
+ it('answers a question about marked code that is one class with its lines and the code facts, in English', async () => {
+ const { props, runtime } = dock.setup();
+ runtime.chat.mockResolvedValueOnce('It declares the JSONB_AGG aggregate with `json_helper`.');
+ await dock.render({ ...props, selectionScope: 'django-demo:explore', readerContext: readerOf(JSONB_AGG, PATH, 'selection', { start: 11, end: 14 }) }); await dock.load();
+ await dock.ask('explain this');
+ expect(runtime.chat).toHaveBeenCalledOnce();
+ const answer = dock.answerOf(dock.last());
+ expect(answer).toContain('Marked lines 11-14 of general.py (Python source file).');
+ expect(answer).toContain('In the source:');
+ expect(dock.last().querySelector('.cbm-chat-answer-text pre')?.textContent).toContain('output_field = JSONField()');
+ // The model named something the code does not have: its text is left out.
- expect(answer).not.toContain('json_helper');
- expect(answer).toContain("Read from the file. The model's text named something the file does not show and was left out.");
++ expect(answer).not.toContain('It declares the JSONB_AGG aggregate');
++ // The note names what the left out text named (W5).
++ expect(answer).toContain("Read from the file. The model's text named something the file does not show (here: json_helper) and was left out.");
+ });
+
+ it('still sends questions that are not general to the model as before', async () => {
+ const { props, runtime } = dock.setup();
+ await dock.render({ ...props, selectionScope: 'django-demo:explore', readerContext: readerOf(GENERAL, PATH) }); await dock.load();
+ await dock.ask('Which class sets allow_distinct and why?');
+ expect(runtime.chat).toHaveBeenCalledOnce();
+ expect(runtime.chat.mock.calls[0][2]?.generationProfile).toBeUndefined();
+ expect(dock.notesOf(dock.last())).toContain('Generated by the local model; it can be wrong.');
+ await dock.ask('Erklär diese Datei Zeile für Zeile');
+ expect(runtime.chat.mock.calls[1][2]?.generationProfile).toBeUndefined();
+ });
+});
diff --cc graph-ui/src/browser-ai/BrowserChatDock.probes.test.tsx
index 1ee747d50,000000000..3df0097db
mode 100644,000000..100644
--- a/graph-ui/src/browser-ai/BrowserChatDock.probes.test.tsx
+++ b/graph-ui/src/browser-ai/BrowserChatDock.probes.test.tsx
@@@ -1,34 -1,0 +1,34 @@@
+// @vitest-environment jsdom
+import { describe, expect, it } from 'vitest';
+import { jsonbAggEvidence } from './galaxy-evidence.fixture';
+import { dockHarness, readerOf } from './chat-dock.fixture';
+
+const dock = dockHarness();
+const TESTS = 'from django.test import TestCase\n\n\nclass AggregateTests(TestCase):\n def test_values_list(self):\n # test that the list is ok\n self.assertEqual(1, 1)\n';
+
+/** A prompt that asks nothing gets example questions, also when the open file contains its word (B5). */
+describe('prompts without a question about an open file (B5)', () => {
+ it('answers "test" locally although the open file contains "test", and offers no model on that hint', async () => {
+ const { props, runtime } = dock.setup();
+ await dock.render({ ...props, selectionScope: 'django-demo:explore', readerContext: readerOf(TESTS, 'tests/postgres_tests/test_aggregates.py') }); await dock.load();
+ for (const prompt of ['test', 'hallo', 'ok']) {
+ await dock.ask(prompt);
+ expect(dock.answerOf(dock.last())).toMatch(/No question was recognized|wurde keine Frage erkannt/);
+ expect(dock.buttonsOf(dock.last())).toEqual([]);
+ }
+ expect(runtime.countTokens).not.toHaveBeenCalled();
+ expect(runtime.chat).not.toHaveBeenCalled();
+ // A real name of the file is a question.
+ await dock.ask('AggregateTests');
+ expect(runtime.chat).toHaveBeenCalledOnce();
+ });
+
+ it('offers no model under the hint for a Galaxy selection either', async () => {
+ const { props, runtime } = dock.setup();
+ await dock.render({ ...props, proactiveSelection: jsonbAggEvidence() }); await dock.load();
+ await dock.ask('test');
- expect(dock.answerOf(dock.last())).toContain('What does JSONBAgg do?');
++ expect(dock.answerOf(dock.last())).toContain('What is JSONBAgg?');
+ expect(dock.buttonsOf(dock.last())).toEqual([]);
+ expect(runtime.chat).not.toHaveBeenCalled();
+ });
+});
diff --cc graph-ui/src/browser-ai/BrowserChatDock.test.tsx
index c30f84f91,0182b070a..e0d475f41
--- a/graph-ui/src/browser-ai/BrowserChatDock.test.tsx
+++ b/graph-ui/src/browser-ai/BrowserChatDock.test.tsx
@@@ -1052,12 -1051,10 +1052,12 @@@ describe('graph answers and answer limi
const request = runtime.chat.mock.calls[0][0];
expect(request.map(message => message.role)).toEqual(['system', 'user']);
expect(request[1].content).toContain('Who calls JSONBAgg?');
- expect(request[1].content).toContain('Incoming relationships: 23 from 12 symbols.');
+ expect(request[1].content).toContain('Incoming: 23 relationships from 12 symbols.');
- expect(container.querySelectorAll('.cbm-chat-turn')).toHaveLength(1);
- expect(container.querySelector('.cbm-chat-answer-text')?.textContent).toBe('Adds the two values.');
- expect(button('Retry')).toBeDefined();
+ // The listed answer stays; the model's answer is a turn of its own below it (B1).
+ expect(container.querySelectorAll('.cbm-chat-turn')).toHaveLength(2);
+ expect(container.querySelector('.cbm-chat-answer-text')?.textContent).toContain('not generated by the model');
+ expect([...container.querySelectorAll('.cbm-chat-answer-text')].at(-1)?.textContent).toBe('Adds the two values.');
+ expect(button('Ask again')).toBeDefined();
});
// 40 callers with long names in their own files: the snapshot names 24, a default prompt fewer.
@@@ -1112,11 -1109,13 +1112,13 @@@
options?.onComplete?.({ stopReason: 'length' }); return 'A long answer that';
});
await render({ ...props, attachment: selection }); await click('Download & load');
- await type('Explain this part'); await click('Send ↑');
+ await type('How is this part computed?'); await click('Send ↑');
const note = container.querySelector<HTMLDetailsElement>('.cbm-chat-turn details.cbm-chat-limit-note');
- expect(note?.textContent).toContain('The output limit is at the maximum of 512 tokens for this model.');
+ expect(note?.textContent).toContain('The output limit is at its maximum of 512 tokens.');
expect([...note?.querySelectorAll('button') ?? []].map(item => item.textContent)).not.toContain('Change the output limit');
- expect(note?.textContent).toContain('Qwen3 0.6B · 579 MB download');
+ // Every larger model stops at 512 output tokens as well, so none is offered for a longer answer.
+ expect(note?.textContent).toContain('Larger models have the same limit.');
+ expect(note?.textContent).not.toContain('Qwen3 0.6B · 579 MB download');
});
it('says why an automatic explanation stops early and that a question may answer longer (K1)', async () => {
@@@ -1590,14 -1589,17 +1592,15 @@@ describe('general questions, prompts wi
expect(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']);
+ // The model only echoed such a prompt, so the hint offers no model (B5).
+ expect(buttons()).toEqual([]);
await type('hallo'); await click('Send ↑');
- expect(answer()).toContain('In "hallo" wurde keine Frage erkannt.');
- 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(buttons()).toEqual([]);
expect(runtime.chat).not.toHaveBeenCalled();
- await act(async () => button('Modell fragen').click());
- expect(runtime.chat).toHaveBeenCalledOnce();
- expect(runtime.chat.mock.calls[0][0].at(-1)!.content).toContain('User question:\nhallo');
// A follow-up does not carry the hint as an answer.
await render({ ...props, readerContext: reader('repos:\n - repo: x\n', 'file', '.pre-commit-config.yaml') });
await type('?'); await click('Send ↑');
diff --cc graph-ui/src/browser-ai/BrowserChatDock.topics.test.tsx
index 894b26595,000000000..7104d573a
mode 100644,000000..100644
--- a/graph-ui/src/browser-ai/BrowserChatDock.topics.test.tsx
+++ b/graph-ui/src/browser-ai/BrowserChatDock.topics.test.tsx
@@@ -1,75 -1,0 +1,75 @@@
+// @vitest-environment jsdom
+import { describe, expect, it } from 'vitest';
+import { jsonbAggEvidence } from './galaxy-evidence.fixture';
+import { dockHarness, readerOf } from './chat-dock.fixture';
+
+const dock = dockHarness();
+const WORKFLOW = 'name: New contributor message\n\non:\n pull_request_target:\n types: [opened]\n';
+const PATH = '.github/workflows/new_contributor_pr.yml';
+
+/** Back on the same file the divider said "New topic", its earlier turns were not sent, and
+ * "Und was noch?" got "Ja, und noch." (B4). */
+describe('coming back to a topic and follow-ups without context (B4)', () => {
+ it('says "Back to" and sends the earlier turns of that topic again, never those of another one', async () => {
+ const { props, runtime } = dock.setup();
+ runtime.chat.mockResolvedValueOnce('It uses actions/first-interaction@v1.').mockResolvedValueOnce('JSONBAgg is an aggregate.');
+ await dock.render({ ...props, selectionScope: 'django-demo:explore', readerContext: readerOf(WORKFLOW, PATH) }); await dock.load();
+ await dock.ask('welche Aktion nutzt dieses File?');
+ await dock.render({ ...props, selectionScope: 'django-demo:galaxy', proactiveSelection: jsonbAggEvidence() });
+ await dock.ask('Explain JSONBAgg line by line.');
+ await dock.render({ ...props, selectionScope: 'django-demo:explore', readerContext: readerOf(WORKFLOW, PATH) });
+ await dock.ask('Und was noch?');
+ const request = runtime.chat.mock.calls.at(-1)![0];
+ expect(dock.questionsIn(request)).toEqual(['welche Aktion nutzt dieses File?', 'Und was noch?']);
+ expect(request.filter(message => message.role === 'assistant').map(message => message.content)).toEqual(['It uses actions/first-interaction@v1.']);
+ expect(request.map(message => message.content).join('\n')).not.toContain('JSONBAgg');
+ expect(dock.dividers()).toEqual(['New topic: JSONBAgg. Earlier messages are not sent with these questions.',
+ `Zurück zu: ${PATH}. Die früheren Nachrichten dazu werden wieder mitgeschickt.`]);
+ });
+
+ it('says "Back to" in English for an English question', async () => {
+ const { props } = dock.setup();
+ await dock.render({ ...props, selectionScope: 'django-demo:explore', readerContext: readerOf(WORKFLOW, PATH) }); await dock.load();
+ await dock.ask('Which action does it use?');
+ await dock.render({ ...props, selectionScope: 'django-demo:galaxy', proactiveSelection: jsonbAggEvidence() });
+ await dock.ask('Who calls JSONBAgg?');
+ await dock.render({ ...props, selectionScope: 'django-demo:explore', readerContext: readerOf(WORKFLOW, PATH) });
+ await dock.ask('Which trigger starts it?');
+ expect(dock.dividers().at(-1)).toBe(`Back to: ${PATH}. Earlier messages about it are sent again.`);
+ });
+
+ it('answers a follow-up right after a topic change locally and asks for the full question', async () => {
+ const { props, runtime } = dock.setup();
+ await dock.render({ ...props, selectionScope: 'django-demo:explore', readerContext: readerOf(WORKFLOW, PATH) }); await dock.load();
+ await dock.ask('welche Aktion nutzt dieses File?');
+ await dock.render({ ...props, selectionScope: 'django-demo:galaxy', proactiveSelection: jsonbAggEvidence() });
+ const calls = runtime.chat.mock.calls.length;
+ await dock.ask('und was noch?');
+ expect(runtime.chat.mock.calls.length).toBe(calls);
+ const answer = dock.answerOf(dock.last());
- expect(answer).toContain('"und was noch?" bezieht sich auf frühere Nachrichten. Die betrafen ein anderes Thema und werden mit Fragen zu JSONBAgg nicht mitgeschickt.');
++ expect(answer).toContain('„und was noch?“ bezieht sich auf frühere Nachrichten. Die betrafen ein anderes Thema und werden mit Fragen zu JSONBAgg nicht mitgeschickt.');
+ expect(answer).toContain('Stell die Frage bitte vollständig, zum Beispiel:');
- for (const example of ['Was macht JSONBAgg?', 'Wer ruft JSONBAgg auf?']) expect(answer).toContain(example);
++ for (const example of ['Was ist JSONBAgg?', 'Wer verwendet JSONBAgg?']) expect(answer).toContain(example);
+ expect(answer).toContain('Ohne das Modell beantwortet.');
+ expect(dock.buttonsOf(dock.last())).toEqual([]);
+ await dock.ask('more');
+ expect(dock.answerOf(dock.last())).toContain('"more" refers to earlier messages. Those were about another topic and are not sent with questions about JSONBAgg.');
+ expect(runtime.chat.mock.calls.length).toBe(calls);
+ // The hints are not earlier turns: a real question afterwards goes to the model without them.
+ await dock.ask('Explain JSONBAgg line by line.');
+ expect(dock.questionsIn(runtime.chat.mock.calls.at(-1)![0])).toEqual(['Explain JSONBAgg line by line.']);
+ });
+
+ // Without another topic before it, a follow-up may refer to the explanation card and goes to
+ // the model as before ("uses original source for follow-ups" in BrowserChatDock.test.tsx).
+ it('reads "mehr" as German', async () => {
+ const { props, runtime } = dock.setup();
+ await dock.render({ ...props, selectionScope: 'django-demo:galaxy', proactiveSelection: jsonbAggEvidence() }); await dock.load();
+ await dock.ask('Who calls JSONBAgg?');
+ await dock.render({ ...props, selectionScope: 'django-demo:explore', readerContext: readerOf(WORKFLOW, PATH) });
+ await dock.ask('mehr');
+ expect(runtime.chat).not.toHaveBeenCalled();
- expect(dock.answerOf(dock.last())).toContain(`"mehr" bezieht sich auf frühere Nachrichten. Die betrafen ein anderes Thema und werden mit Fragen zu ${PATH} nicht mitgeschickt.`);
++ expect(dock.answerOf(dock.last())).toContain(`„mehr“ bezieht sich auf frühere Nachrichten. Die betrafen ein anderes Thema und werden mit Fragen zu ${PATH} nicht mitgeschickt.`);
+ expect(dock.answerOf(dock.last())).toContain('Was macht new_contributor_pr.yml?');
+ });
+});
diff --cc graph-ui/src/browser-ai/BrowserChatDock.tsx
index dd9da493c,b5d77ad9e..69ee0a5b2
--- a/graph-ui/src/browser-ai/BrowserChatDock.tsx
+++ b/graph-ui/src/browser-ai/BrowserChatDock.tsx
@@@ -3,15 -3,14 +3,15 @@@ import type { BrowserAiProgress } from
import { createBrowserChatRuntime, type BrowserChatRuntime } from './browser-ai-runtime';
import { BROWSER_MODELS, getBrowserModel, isBrowserModelCached, removeBrowserModelCache, type BrowserModel } from './model-policy';
import { keepAgent, loadProgress, offerAgent, peekAgent, takeAgent, type AgentHandover, type LoadProgress } from './agent-handover';
-import { buildChatMessages, selectionLocation, snapshotAttachment, snapshotReaderContext, trimChatHistory, type BrowserChatAttachment, type BrowserChatContext, type BrowserChatReaderContext, type BrowserChatSource, type BrowserChatTurn } from './chat-model';
+import { buildChatMessages, selectionLocation, sentInHistory, snapshotAttachment, snapshotReaderContext, trimChatHistory, type BrowserChatAttachment, type BrowserChatContext, type BrowserChatReaderContext, type BrowserChatSource, type BrowserChatTurn } from './chat-model';
import { explanationInput, EXPLANATION_DELAY_MS, type ExplanationInput } from './proactive-selection';
import { prepareExplanationContext, selectionSummary, type PreparedExplanationContext } from './explanation-context';
- import { AUTO_INPUT_TOKENS, AUTO_OUTPUT_TOKENS, citedInterpretation, explanationMode, explanationSentence, namesNotIn, parseExplanationResponse, explanationMessages, formatExplanationEvidence } from './explanation-response';
+ import { AUTO_INPUT_TOKENS, AUTO_OUTPUT_TOKENS, citedInterpretation, explanationMode, explanationSentence, namesNotIn, parseExplanationResponse, explanationMessages, formatExplanationEvidence, type DroppedReason } from './explanation-response';
import { carriedSource, selectionSubject, SYMBOL_SOURCE_LINES, sourceTargetOf, symbolSource, type SymbolSourceReader } from './symbol-source';
+import { codeFacts, codeFactsMarkdown, codeSourceFacts } from './code-facts';
import { relationshipAnswer, relationshipSuggestion } from './relationship-answer';
import { clampTokenLimits, tokenLimitBounds, tokenLimitsFor, useAgentPreferences, type TokenLimits } from './agent-preferences';
- import { browserChatText, chatRound3Text, groundedText, relationshipWords } from './strings';
-import { browserChatText, evidenceNote, groundedText, relationshipWords, topicText } from './strings';
++import { browserChatText, chatRound3Text, evidenceNote, groundedText, relationshipWords, topicText } from './strings';
import { isGpuRuntimeFailure, BrowserRuntimeFatalError } from './runtime-fault';
import ChatMarkdown from './ChatMarkdown';
import AgentSettingsDialog from './AgentSettingsDialog';
@@@ -78,19 -70,17 +78,21 @@@ const sizeLabel = (bytes: number): stri
/** Symbol sources read for explanations and questions, newest last. */
const SOURCE_CACHE_SIZE = 32;
-/** The listed facts first, then the model's sentence if it stood the check, then who wrote what (K7).
- * The facts come from the indexed graph, or for an open workflow from the file itself (K12). The
- * answer to a general question says it in the language of that question (C5). */
-function groundedExplanation(summary: readonly string[], sentence: string | undefined, dropped: boolean | DroppedReason, from: 'graph' | 'file' = 'graph', language: 'en' | 'de' = 'en'): string {
- const words = groundedText[language];
- // The note names what the left out sentence claimed or named, where the check says it (W5).
+/** The listed facts first, then the lines read from the selected code, then the model's sentence
+ * if it stood the check, then who wrote what (K7). The facts come from the indexed graph, or for
+ * an open workflow from the file itself (K12). The answer to a general question says it in the
+ * language of that question (C5). `code` says what the code declares when the sentence is
- * dropped, as it was for JSONBAgg every time (B2). */
- function groundedExplanation(summary: readonly string[], sentence: string | undefined, dropped: boolean, from: 'graph' | 'file' = 'graph', language: 'en' | 'de' = 'en', code?: string): string {
++ * dropped, as it was for JSONBAgg every time (B2). The note names what the left out sentence
++ * claimed or named, where the check says it (W5). */
++function groundedExplanation(summary: readonly string[], sentence: string | undefined, dropped: boolean | DroppedReason, from: 'graph' | 'file' = 'graph', language: 'en' | 'de' = 'en', code?: string): string {
+ const words = from === 'file' ? chatRound3Text[language].fileNotes : groundedText[language];
- const note = sentence ? words.factsAndSentence : dropped ? words.sentenceDropped : words.factsOnly;
+ const reason = typeof dropped === 'object' ? dropped : undefined;
- const note = from === 'file' ? sentence ? browserChatText.fileFactsAndSentence : dropped ? browserChatText.fileSentenceDropped(reason) : browserChatText.fileFactsOnly
- : sentence ? words.factsAndSentence : dropped ? words.sentenceDropped(reason) : words.factsOnly;
- return [summary.map(line => `- ${line}`).join('\n'), ...sentence ? [sentence] : [], `_${note}_`].join('\n\n');
++ const note = sentence ? words.factsAndSentence : dropped ? words.sentenceDropped(reason) : words.factsOnly;
+ return [summary.map(line => `- ${line}`).join('\n'), ...code ? [code] : [], ...sentence ? [sentence] : [], `_${note}_`].join('\n\n');
}
+/** The same while the model writes its sentence. */
+const writingExplanation = (summary: readonly string[], note: string, code?: string): string =>
+ summary.length ? [summary.map(line => `- ${line}`).join('\n'), ...code ? [code] : [], `_${note}_`].join('\n\n') : '';
function Attachment({ attachment, label }: { attachment: BrowserChatAttachment; label?: string }): JSX.Element {
return <details className="cbm-chat-attachment">
@@@ -454,7 -447,7 +462,7 @@@ export default function BrowserChatDock
// One sentence beside the facts (two for reader code), and none that names what the evidence lacks.
const checked = result.status === 'generated' ? explanationSentence(result.markdown, packet, request.map(message => message.content).join('\n')) : {};
if (summary.length || (result.status === 'generated' && checked.dropped)) {
- const markdown = summary.length ? groundedExplanation(summary, checked.sentence, checked.dropped !== undefined, from, 'en', code) : `_${browserChatText.explanationDropped}_`;
- const markdown = summary.length ? groundedExplanation(summary, checked.sentence, checked.reason ?? checked.dropped !== undefined, from) : `_${browserChatText.explanationDropped(checked.reason)}_`;
++ const markdown = summary.length ? groundedExplanation(summary, checked.sentence, checked.reason ?? checked.dropped !== undefined, from, 'en', code) : `_${browserChatText.explanationDropped(checked.reason)}_`;
const complete: Explanation = { key: snapshot.key, label: snapshot.label, answer: markdown, status: 'complete', mode: 'interpretation', packet, grounded: summary.length > 0,
...shortened && checked.sentence ? { shortened, limit: { inputTokens: autoInput, outputTokens: autoOutput } } : {}, ...snapshot.evidence ? { evidence: snapshot.evidence } : {} };
remember(complete); setExplanation(complete);
@@@ -658,16 -651,11 +666,16 @@@
// A prompt that asks nothing ("test", "hallo") gets questions it could ask, not an echo of the model (C6).
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)] });
- const subject: ExampleSubject = galaxy ? { kind: 'galaxy', name: galaxy.label } : fileSource?.kind === 'selection' || source ? { kind: 'marked' }
- if (!retry && noQuestion(prompt, known)) {
- 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 ?? '' };
++ const subject: ExampleSubject = galaxy ? { kind: 'galaxy', name: galaxy.label, evidence: galaxy } : fileSource?.kind === 'selection' || source ? { kind: 'marked' }
+ : { kind: 'other', name: fileSource ? fileSource.path.split('/').pop()! : topic?.label ?? '' };
+ // "und was noch?" right after a change of topic would reach the model without context:
+ // this topic has no earlier turn, and those of other topics are not sent (B4).
+ const hint = !retry && noQuestion(prompt, known) ? noQuestionAnswer(prompt, language, subject)
+ : !retry && topic && contextFreeFollowUp(prompt) && !topicHistory(turns, topic).some(sentInHistory) && turns.some(item => item.topic && item.topic.key !== topic.key)
+ ? followUpAnswer(prompt, language, subject, topic.label) : undefined;
+ if (hint) {
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' }]);
+ ...currentGraph[0] ? { listedFrom: currentGraph[0] } : {}, modelId: model.id, request: [], answer: hint, status: 'complete', answeredFrom: 'hint' }]);
consume();
return;
}
@@@ -783,7 -757,7 +791,7 @@@
// One sentence beside the facts, checked like the sentence of the explanation card.
const result = parseExplanationResponse(output, packet!);
const checked = !stopRequested.current && result.status === 'generated' ? explanationSentence(result.markdown, packet!, request.map(message => message.content).join('\n')) : {};
- const answer = groundedExplanation(grounded.summary, checked.sentence, checked.dropped !== undefined, grounded.from, language, code);
- const answer = groundedExplanation(grounded.summary, checked.sentence, checked.reason ?? checked.dropped !== undefined, 'graph', language);
++ const answer = groundedExplanation(grounded.summary, checked.sentence, checked.reason ?? checked.dropped !== undefined, grounded.from, language, code);
setTurns(previous => previous.map(item => item.id === id ? { ...item, answer, status: stopRequested.current ? 'stopped' : 'complete' } : item));
return;
}
@@@ -907,17 -880,13 +915,17 @@@
: manualRequest.current ? 'This selection will be explained after your answer.' : 'Preparing explanation…'}</p>}
</section>}
{turns.length === 0 && !(proactive && automatic && selected) && <div className="cbm-chat-empty"><span aria-hidden="true">⌁</span><h3>Ask about the code.</h3><p>{readerContext ? 'The current file is included automatically. Mark code to focus your next message on that exact selection.' : 'Ask a question, or add source and graph context to your next message.'}</p></div>}
- {turns.map((turn, index) => { const replyWords = relationshipWords[turn.replyLanguage === 'de' ? 'de' : 'en']; return <article className="cbm-chat-turn" key={turn.id}>
- {turn.topic && index > 0 && turn.topic.key !== turns.slice(0, index).reverse().find(item => item.topic)?.topic?.key
- && <p className="cbm-chat-topic-break">{topicText[turn.replyLanguage ?? questionLanguage(turn.prompt)].topicBreak(turn.topic.label)}</p>}
- <div className="cbm-chat-question"><span className="cbm-chat-speaker">You</span><ChatMarkdown text={turn.prompt} /></div>
+ {turns.map((turn, index) => { const replyWords = relationshipWords[turn.replyLanguage === 'de' ? 'de' : 'en'];
+ // The model's own answers carry their note in the language of the question (B1).
+ const ownWords = chatRound3Text[turn.replyLanguage ?? questionLanguage(turn.prompt)];
+ const divider = topicDivider(turns, index);
+ return <article className="cbm-chat-turn" key={turn.id}>
- {turn.topic && divider && <p className="cbm-chat-topic-break">{divider === 'back' ? ownWords.backTo(turn.topic.label) : browserChatText.topicBreak(turn.topic.label)}</p>}
++ {turn.topic && divider && <p className="cbm-chat-topic-break">{divider === 'back' ? ownWords.backTo(turn.topic.label) : topicText[turn.replyLanguage ?? questionLanguage(turn.prompt)].topicBreak(turn.topic.label)}</p>}
+ <div className="cbm-chat-question"><span className="cbm-chat-speaker">You</span><ChatMarkdown text={turn.prompt} />
+ {turn.askedModel && <small className="cbm-chat-asked-model">{ownWords.askedModel}</small>}</div>
<div className="cbm-chat-answer"><SourceDisclosure>
{turn.evidence || turn.attachment || turn.readerContext?.source || turn.context?.length ? <>
- {turn.evidence ? <PacketSource packet={turn.evidence} /> : <>
+ {turn.evidence ? <PacketSource packet={turn.evidence} language={turn.replyLanguage ?? questionLanguage(turn.prompt)} /> : <>
{turn.attachment && <Attachment attachment={turn.attachment} />}
{turn.readerContext?.source && <><Attachment attachment={turn.readerContext.source} label={turn.readerContext.source.kind === 'selection' ? 'Selection snapshot' : 'File snapshot'} />{turn.readerContext.source.partial && <p className="cbm-chat-evidence-note">{turn.readerContext.source.partial}</p>}</>}
</>}
diff --cc graph-ui/src/browser-ai/question-intent.ts
index 8ce098f3f,1650f96e1..cade78c50
--- a/graph-ui/src/browser-ai/question-intent.ts
+++ b/graph-ui/src/browser-ai/question-intent.ts
@@@ -93,30 -93,28 +93,41 @@@ export function noQuestion(prompt: stri
return 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 {
+/** Two or three questions that work for the selection, as a Markdown list. */
+function examples(language: 'en' | 'de', subject: ExampleSubject): string {
const text = noQuestionText[language];
- const examples = subject.kind === 'marked' ? [text.markedDoes, text.markedInDetail]
+ const items = 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}_`;
+ return items.map(example => `- ${example}`).join('\n');
+}
+const shownPrompt = (typed: string) => typed.replace(/\s+/g, ' ').replace(/["`]/g, "'").trim().slice(0, 40);
+
+/** "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];
+ return `${text.heading(shownPrompt(typed))}\n\n${examples(language, subject)}\n\n_${text.note}_`;
+}
+
+/** A follow-up ("und was noch?") right after a change of topic: the earlier turns are about
+ * another topic and are not sent, so the model would answer it without context ("Ja, und
+ * noch."). It asks for the full question with the same examples (B4). */
+export function followUpAnswer(typed: string, language: 'en' | 'de', subject: ExampleSubject, topic: string): string {
+ return `${chatRound3Text[language].followUp(shownPrompt(typed), topic)}\n\n${examples(language, subject)}\n\n_${noQuestionText[language].note}_`;
}
/** The names a prompt may use for what is at hand: the selection, the symbols around it, the
diff --cc graph-ui/src/browser-ai/strings.ts
index 629d5bd81,005720caa..6c4b0b9c4
--- a/graph-ui/src/browser-ai/strings.ts
+++ b/graph-ui/src/browser-ai/strings.ts
@@@ -381,89 -473,3 +473,91 @@@ export const fileWords =
patterns: (total: number, items: readonly string[]) => `${counted(total, 'pattern', 'patterns')}: ${listed(items, total)}.`,
root: (name: string) => `Root element: ${name}.`,
};
+
+/** Third hand test round (B1 to B7): the chat's own words for an answer handed to the model,
+ * a topic the reader comes back to, a follow-up without context, facts read from code and the
+ * purpose of well-known files. New strings only; the ones above keep their own wording. */
+const englishRound3Text = {
+ /** Under the question of a turn asked of the model from an answer the chat gave itself (B1). */
+ askedModel: 'Asked the local model',
+ /** Under every answer the model wrote freely (B1). */
+ modelNote: 'Generated by the local model; it can be wrong.',
+ askAgain: 'Ask again',
+ /** Above the first question about a file or selection that has earlier turns (B4). */
+ backTo: (label: string) => `Back to: ${label}. Earlier messages about it are sent again.`,
+ /** A follow-up ("und was noch?") right after a change of topic (B4). */
+ followUp: (typed: string, label: string) => `"${typed}" refers to earlier messages. Those were about another topic and are not sent with questions about ${label}. Please ask the full question, for example:`,
+ /** Above the lines read from the selected code (B2). */
+ inSource: 'In the source:',
+ moreMembers: (total: number) => `+${total.toLocaleString('en-US')} more ${total === 1 ? 'attribute or method' : 'attributes and methods'}`,
+ moreLines: (total: number) => `+${counted(total, 'more line', 'more lines')}`,
+ /** An open code file or marked code as facts read from it, for a short general question (B3). */
+ codeKind: (language: string) => language ? `${language} source file` : 'source file',
+ marked: (start: number, end: number, name: string, kind: string) => `${start === end ? `Marked line ${start}` : `Marked lines ${start}-${end}`} of ${name} (${kind}).`,
+ moduleDocstring: (text: string) => `Module docstring: "${text}"`,
+ definitions: (total: number, items: readonly string[], where: 'file' | 'marked') =>
+ `${where === 'file' ? 'Top-level definitions' : 'Definitions in the marked code'} (${total.toLocaleString('en-US')}): ${items.join(', ')}${total > items.length ? `, +${(total - items.length).toLocaleString('en-US')} more` : ''}.`,
+ /** Who wrote which part of an answer about a file (K12), in the language of the question. */
+ fileNotes: { factsAndSentence: browserChatText.fileFactsAndSentence, factsOnly: browserChatText.fileFactsOnly, sentenceDropped: browserChatText.fileSentenceDropped },
+ /** The first line of a file outline; the note under it says where it was read (B7). */
+ outlineHeading: (name: string, kind: string, lines: number) => `${name}: ${kind}, ${counted(lines, 'line', 'lines')}.`,
+ iniKind: 'INI configuration',
+ /** What a well-known file is for, by its name and structure, before its outline (B7). */
+ purposes: {
+ preCommit: 'pre-commit configuration: hooks that run before each commit.',
+ workflow: 'GitHub runs the jobs of this workflow when one of its triggers occurs.',
+ npmPackage: 'npm package manifest: the name, scripts and dependencies of a JavaScript package.',
+ pyproject: 'Python project configuration: how the package is built, its metadata and the settings of tools.',
+ tox: 'tox configuration: the test environments tox creates and the commands it runs in each.',
+ setupCfg: 'setuptools configuration: package metadata and options, often also settings of other tools.',
+ compose: 'Docker Compose file: the services that Docker Compose starts together.',
+ readTheDocs: 'Read the Docs configuration: how readthedocs.org builds the documentation.',
+ editorConfig: 'EditorConfig: indentation, line endings and similar editor settings per file pattern.',
+ tsconfig: 'TypeScript compiler configuration: which files are compiled and with which options.',
+ flake8: 'flake8 configuration: the rules of the Python linter flake8.',
+ pytest: 'pytest configuration: the options pytest runs the tests with.',
+ coverage: 'coverage.py configuration: which code test coverage measures and how it is reported.',
+ },
+};
+export const chatRound3Text: { en: typeof englishRound3Text; de: typeof englishRound3Text } = {
+ en: englishRound3Text,
+ de: {
+ askedModel: 'An das lokale Modell gestellt',
+ modelNote: 'Vom lokalen Modell erzeugt; kann falsch sein.',
+ askAgain: 'Erneut fragen',
+ backTo: (label: string) => `Zurück zu: ${label}. Die früheren Nachrichten dazu werden wieder mitgeschickt.`,
- followUp: (typed: string, label: string) => `"${typed}" bezieht sich auf frühere Nachrichten. Die betrafen ein anderes Thema und werden mit Fragen zu ${label} nicht mitgeschickt. Stell die Frage bitte vollständig, zum Beispiel:`,
++ followUp: (typed: string, label: string) => `„${typed}“ bezieht sich auf frühere Nachrichten. Die betrafen ein anderes Thema und werden mit Fragen zu ${label} nicht mitgeschickt. Stell die Frage bitte vollständig, zum Beispiel:`,
+ inSource: 'Im Quelltext:',
+ moreMembers: (total: number) => `+${total.toLocaleString('de-DE')} ${total === 1 ? 'weiteres Attribut oder weitere Methode' : 'weitere Attribute und Methoden'}`,
+ moreLines: (total: number) => `+${gezaehlt(total, 'weitere Zeile', 'weitere Zeilen')}`,
+ codeKind: (language: string) => language ? `${language}-Quelltext` : 'Quelltext',
+ marked: (start: number, end: number, name: string, kind: string) => `${start === end ? `Markierte Zeile ${start}` : `Markierte Zeilen ${start} bis ${end}`} von ${name} (${kind}).`,
+ moduleDocstring: (text: string) => `Docstring des Moduls: "${text}"`,
+ definitions: (total: number, items: readonly string[], where: 'file' | 'marked') =>
+ `${where === 'file' ? 'Definitionen auf oberster Ebene' : 'Definitionen im markierten Code'} (${total.toLocaleString('de-DE')}): ${items.join(', ')}${total > items.length ? `, +${(total - items.length).toLocaleString('de-DE')} weitere` : ''}.`,
+ fileNotes: {
+ factsAndSentence: 'Fakten aus der Datei gelesen; der Text danach ist vom Modell erzeugt.',
+ factsOnly: 'Aus der Datei gelesen, nicht vom Modell erzeugt.',
- sentenceDropped: 'Aus der Datei gelesen. Der Text des Modells nannte etwas, das die Datei nicht zeigt, und wurde weggelassen.',
++ sentenceDropped: (reason?: DroppedReason) => `Aus der Datei gelesen. Der Text des Modells ${!reason ? 'wurde weggelassen, weil die Datei ihn nicht stützt'
++ : reason.kind === 'claim' ? `behauptete etwas, das die Datei nicht zeigt (hier: „${reason.text}“), und wurde weggelassen`
++ : `nannte etwas, das die Datei nicht zeigt (hier: ${code(reason.text)}), und wurde weggelassen`}.`,
+ },
+ outlineHeading: (name: string, kind: string, lines: number) => `${name}: ${kind}, ${gezaehlt(lines, 'Zeile', 'Zeilen')}.`,
+ iniKind: 'INI-Konfiguration',
+ purposes: {
+ preCommit: 'pre-commit-Konfiguration: Hooks, die vor jedem Commit laufen.',
+ workflow: 'GitHub führt die Jobs dieses Workflows aus, wenn einer seiner Auslöser eintritt.',
+ npmPackage: 'npm-Paketmanifest: Name, Skripte und Abhängigkeiten eines JavaScript-Pakets.',
+ pyproject: 'Python-Projektkonfiguration: wie das Paket gebaut wird, seine Metadaten und die Einstellungen von Werkzeugen.',
+ tox: 'tox-Konfiguration: die Testumgebungen, die tox anlegt, und die Befehle, die es in jeder ausführt.',
+ setupCfg: 'setuptools-Konfiguration: Paketmetadaten und Optionen, oft auch Einstellungen anderer Werkzeuge.',
+ compose: 'Docker-Compose-Datei: die Services, die Docker Compose zusammen startet.',
+ readTheDocs: 'Read-the-Docs-Konfiguration: wie readthedocs.org die Dokumentation baut.',
+ editorConfig: 'EditorConfig: Einrückung, Zeilenenden und ähnliche Editor-Einstellungen je Dateimuster.',
+ tsconfig: 'TypeScript-Compilerkonfiguration: welche Dateien mit welchen Optionen kompiliert werden.',
+ flake8: 'flake8-Konfiguration: die Regeln des Python-Linters flake8.',
+ pytest: 'pytest-Konfiguration: die Optionen, mit denen pytest die Tests ausführt.',
+ coverage: 'coverage.py-Konfiguration: welcher Code bei der Testabdeckung gemessen und wie darüber berichtet wird.',
+ },
+ },
+};