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.

fix(ui): read a single unnamed list item of a configuration file without parentheses (C7)

Bernhard Jackiewicz0db683605d2b
diff --git a/graph-ui/src/browser-ai/file-outline.test.ts b/graph-ui/src/browser-ai/file-outline.test.ts
index 14cfec5f1..8bd592f24 100644
--- a/graph-ui/src/browser-ai/file-outline.test.ts
+++ b/graph-ui/src/browser-ai/file-outline.test.ts
@@ -52,8 +52,10 @@ describe('the outline of a configuration file, read from it (C7)', () => {
});
it('keeps mappings by their keys and bounds long lists with "+N more"', () => {
- const docs = 'version: 2\nbuild:\n os: ubuntu-22.04\n tools:\n python: "3.12"\nformats:\n - pdf\n - epub\n';
+ const docs = 'version: 2\nbuild:\n os: ubuntu-22.04\n tools:\n python: "3.12"\npython:\n install:\n - requirements: docs/requirements.txt\nformats:\n - pdf\n - epub\n';
const outline = fileOutline('.readthedocs.yml', docs, 'en')!;
+ // A single item without a naming field reads as its fields, without parentheses.
+ expect(outline).toContain('- `python`: install (1): requirements `docs/requirements.txt`');
expect(outline).toContain('- `version`: `2`');
expect(outline).toContain('- `build`: os `ubuntu-22.04`; tools: python `3.12`');
expect(outline).toContain('- `formats` (list of 2): `pdf`, `epub`');
diff --git a/graph-ui/src/browser-ai/file-outline.ts b/graph-ui/src/browser-ai/file-outline.ts
index bc0fcfbdf..ec8e9d0a9 100644
--- a/graph-ui/src/browser-ai/file-outline.ts
+++ b/graph-ui/src/browser-ai/file-outline.ts
@@ -83,12 +83,16 @@ function field(key: string, value: YamlValue, depth: number, words: Words): stri
if (value.kind === 'scalar') return `${key} ${scalarText(value, words)}`;
if (value.kind === 'map') return depth < 2 ? `${key}: ${inlineMap(value, depth + 1, words)}` : `${key} (${words.keys(value.entries.length)})`;
if (!value.items.some(isMap)) return `${key}: ${value.items.slice(0, ITEMS).map(item => scalarText(item, words) || words.list(0)).join(', ')}${more(value.items.length, ITEMS, words, ', ')}`;
+ // A single item without a naming field needs no parentheses to stand apart from the next.
+ const [only] = value.items;
+ if (value.items.length === 1 && isMap(only) && !namingOf(only)) return `${key} (1): ${inlineMap(only, depth + 1, words)}`;
return `${key} (${value.items.length}): ${value.items.slice(0, ITEMS).map(item => named(item, depth + 1, words)).join('; ')}${more(value.items.length, ITEMS, words)}`;
}
+const namingOf = (value: Extract<YamlValue, { kind: 'map' }>) => NAMING.map(key => value.entries.find(([name, item]) => name === key && item.kind === 'scalar')).find(Boolean);
/** An item of a nested list by its naming field, the others in parentheses. */
function named(value: YamlValue, depth: number, words: Words): string {
if (!isMap(value)) return scalarText(value, words) || words.list(value.kind === 'list' ? value.items.length : 0);
- const naming = NAMING.map(key => value.entries.find(([name, item]) => name === key && item.kind === 'scalar')).find(Boolean);
+ const naming = namingOf(value);
if (!naming) return depth < 3 ? `(${inlineMap(value, depth, words)})` : `(${words.keys(value.entries.length)})`;
const rest = value.entries.filter(entry => entry !== naming);
const details = rest.length && depth < 3 ? ` (${inlineMap({ kind: 'map', entries: rest }, depth, words)})` : '';