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.

feat(ui): spell out Back and Forward while the Galaxy toolbar has room (K2)

Bernhard Jackiewicz7e73441881d6
diff --git a/graph-ui/src/galaxy/GalaxyPanel.toolbar.test.tsx b/graph-ui/src/galaxy/GalaxyPanel.toolbar.test.tsx
index dcd1534b0..44ba42161 100644
--- a/graph-ui/src/galaxy/GalaxyPanel.toolbar.test.tsx
+++ b/graph-ui/src/galaxy/GalaxyPanel.toolbar.test.tsx
@@ -78,6 +78,16 @@ it('K2: the history group and the root button say what they are to assistive tec
const name = host.querySelector<HTMLButtonElement>('button.atlas-graph-scope-name')!;
expect(name.getAttribute('aria-label')).toBe('Open the source of n2');
expect(name.textContent).toBe('n2');
+ // K2 as planned: "← Back" and "Forward →" in words while the row has room, the glyphs alone in its compact levels.
+ const back = group.querySelector<HTMLButtonElement>('button[aria-label="Back"]')!;
+ const forward = group.querySelector<HTMLButtonElement>('button[aria-label="Forward"]')!;
+ expect(back.querySelector('.atlas-fit-wide')?.textContent).toBe('← Back');
+ expect(back.querySelector('.atlas-fit-narrow')?.getAttribute('data-label')).toBe('←');
+ expect(forward.querySelector('.atlas-fit-wide')?.textContent).toBe('Forward →');
+ expect(forward.querySelector('.atlas-fit-narrow')?.getAttribute('data-label')).toBe('→');
+ // The tooltips stay.
+ expect(back.title).toBe('Back to n1 · 1 layer (Alt+Left)');
+ expect(forward.title).toBe('Nothing to go forward to');
});
it('K3: the scoped toolbar measures its fit and carries a short label for each wide control', async () => {
diff --git a/graph-ui/src/galaxy/GalaxyPanel.tsx b/graph-ui/src/galaxy/GalaxyPanel.tsx
index d842d2e16..be266df88 100644
--- a/graph-ui/src/galaxy/GalaxyPanel.tsx
+++ b/graph-ui/src/galaxy/GalaxyPanel.tsx
@@ -2035,9 +2035,11 @@ export default function GalaxyPanel(props: GalaxyPanelProps): JSX.Element {
}, [props.workspaceExpanded, scope.scope, trailView, escapeTaken, leaveScope]);
const historyControls = props.workspaceExpanded ? <span className="atlas-graph-history" role="group" aria-label={galaxyHistoryText.group}>
<button type="button" aria-label={galaxyHistoryText.back} disabled={!historyBack} onClick={() => goHistory(-1)}
- title={historyBack ? galaxyHistoryText.backTo(historyEntryLabel(historyBack)) : galaxyHistoryText.noBack}>{galaxyHistoryText.backGlyph}</button>
+ title={historyBack ? galaxyHistoryText.backTo(historyEntryLabel(historyBack)) : galaxyHistoryText.noBack}>
+ <FitLabel wide={galaxyHistoryText.backWide} narrow={galaxyHistoryText.backGlyph} /></button>
<button type="button" aria-label={galaxyHistoryText.forward} disabled={!historyForward} onClick={() => goHistory(1)}
- title={historyForward ? galaxyHistoryText.forwardTo(historyEntryLabel(historyForward)) : galaxyHistoryText.noForward}>{galaxyHistoryText.forwardGlyph}</button>
+ title={historyForward ? galaxyHistoryText.forwardTo(historyEntryLabel(historyForward)) : galaxyHistoryText.noForward}>
+ <FitLabel wide={galaxyHistoryText.forwardWide} narrow={galaxyHistoryText.forwardGlyph} /></button>
{history.recent.length > 1 && <details className="atlas-graph-recent" onKeyDown={event => {
if (event.key === 'Escape') { event.stopPropagation(); event.currentTarget.open = false; }
}}>
@@ -2612,9 +2614,9 @@ export default function GalaxyPanel(props: GalaxyPanelProps): JSX.Element {
* die Tastatur weiter im Menue "⋯".
*/}
{props.workspaceExpanded && openRoot
- ? <button type="button" className="atlas-graph-scope-name" onClick={openRoot} aria-label={galaxyToolbarText.openRootLabel(scope.scope.name)}
+ ? <button type="button" className="atlas-graph-scope-name" data-fit-whole="" onClick={openRoot} aria-label={galaxyToolbarText.openRootLabel(scope.scope.name)}
title={galaxyToolbarText.openRootTitle(scope.scope.name, scopedRoot?.file_path ?? '', scopedRoot?.start_line)}>{scope.scope.name}</button>
- : <strong className="atlas-graph-scope-name" title={scope.scope.name}>{scope.scope.name}</strong>}
+ : <strong className="atlas-graph-scope-name" data-fit-whole="" title={scope.scope.name}>{scope.scope.name}</strong>}
{props.workspaceExpanded && <select aria-label="Trace direction" title={galaxyToolbarText.traceTitle} value={scope.direction}
onChange={event => scope.setDirection(event.target.value as 'both' | 'inbound' | 'outbound')}>
<option value="both">Both directions</option><option value="inbound">Incoming</option><option value="outbound">Outgoing</option>
diff --git a/graph-ui/src/galaxy/galaxy-strings.ts b/graph-ui/src/galaxy/galaxy-strings.ts
index c33840525..8e76ab002 100644
--- a/graph-ui/src/galaxy/galaxy-strings.ts
+++ b/graph-ui/src/galaxy/galaxy-strings.ts
@@ -43,6 +43,9 @@ export const galaxyHistoryText = {
forward: 'Forward',
backGlyph: '←',
forwardGlyph: '→',
+ /** The visible words while the row has room (K2: "← Back" and "Forward →"); the glyphs alone in its compact levels. */
+ backWide: '← Back',
+ forwardWide: 'Forward →',
backTo: (label: string) => `Back to ${label} (Alt+Left)`,
forwardTo: (label: string) => `Forward to ${label} (Alt+Right)`,
noBack: 'Nothing to go back to yet',
diff --git a/graph-ui/src/galaxy/toolbar-fit.test.ts b/graph-ui/src/galaxy/toolbar-fit.test.ts
index 8b481537d..cf35fe7b3 100644
--- a/graph-ui/src/galaxy/toolbar-fit.test.ts
+++ b/graph-ui/src/galaxy/toolbar-fit.test.ts
@@ -58,4 +58,28 @@ describe('fitToolbar', () => {
element.getBoundingClientRect = () => ({ left: 0, right: 1200, width: 1200, top: 0, bottom: 40, height: 40, x: 0, y: 0, toJSON: () => ({}) }) as DOMRect;
expect(fitToolbar(element)).toBe('full');
});
+
+ /*
+ * Hand test K2 seen in the browser: with "← Back" and "Forward →" in words
+ * the root name shrank to "JS…" with the chat open, while nothing stuck
+ * out. The full level now also needs the root name whole.
+ */
+ it('leaves the full level when the root name would be squeezed below its text, but not for a name only its maximum width clips', () => {
+ const element = bar({ full: 990, compact: 900, tight: 900, wrap: 900 });
+ const name = document.createElement('button');
+ name.dataset.fitWhole = '';
+ name.style.maxWidth = '176px';
+ name.style.boxSizing = 'border-box';
+ let widths = { full: 40, compact: 100 } as Record<string, number>, content = 100;
+ Object.defineProperty(name, 'scrollWidth', { get: () => content });
+ Object.defineProperty(name, 'clientWidth', { get: () => widths[element.dataset.fit ?? 'full'] ?? 100 });
+ element.append(name);
+ expect(fitToolbar(element)).toBe('compact');
+ widths = { full: 100, compact: 100 };
+ expect(fitToolbar(element)).toBe('full');
+ // A long name is cut by its maximum width at every level: that alone is no reason to leave the full labels.
+ content = 300;
+ widths = { full: 176, compact: 176 };
+ expect(fitToolbar(element)).toBe('full');
+ });
});
diff --git a/graph-ui/src/galaxy/toolbar-fit.tsx b/graph-ui/src/galaxy/toolbar-fit.tsx
index 4c64751b4..dde4a0184 100644
--- a/graph-ui/src/galaxy/toolbar-fit.tsx
+++ b/graph-ui/src/galaxy/toolbar-fit.tsx
@@ -8,7 +8,8 @@
* also genau das Menue, auf das der Hinweis einer abgeschnittenen Ebene
* verweist. Jetzt wird gemessen, in drei Stufen:
*
- * - `full`: alle Beschriftungen ausgeschrieben.
+ * - `full`: alle Beschriftungen ausgeschrieben ("← Back", "Forward →"), und
+ * der Name der Wurzel steht dabei ganz (`toolbarSqueezes`).
* - `compact`: knappe Beschriftungen ("+1" statt "Expand +1", "All",
* "Path…", "Types · All", "Calls"); so passt sie bei offenem Chat und
* 1.494 px, auch mit der Liste der letzten Wurzeln.
@@ -48,9 +49,28 @@ export function toolbarOverflows(bar: HTMLElement): boolean {
return false;
}
-/** Setzt die Leiste auf die erste Stufe, die passt, und gibt sie zurueck. */
+/*
+ * Ob ein Element, das in voller Stufe ganz zu lesen sein soll
+ * (`data-fit-whole`, der Name der Wurzel), schmaler steht, als sein Text und
+ * seine Hoechstbreite es wollen (Handtest K2, im Browser gesehen: mit "← Back"
+ * und "Forward →" in Worten schrumpfte die Wurzel bei offenem Chat auf
+ * "JS…", und nichts ragte hinaus). Gerechnet in der Innenbreite (`clientWidth`).
+ */
+export function toolbarSqueezes(bar: HTMLElement): boolean {
+ for (const element of bar.querySelectorAll<HTMLElement>('[data-fit-whole]')) {
+ const style = getComputedStyle(element);
+ const max = parseFloat(style.maxWidth);
+ const padding = (parseFloat(style.paddingLeft) || 0) + (parseFloat(style.paddingRight) || 0);
+ const border = (parseFloat(style.borderLeftWidth) || 0) + (parseFloat(style.borderRightWidth) || 0);
+ const room = Number.isFinite(max) ? (style.boxSizing === 'border-box' ? max - border : max + padding) : Number.POSITIVE_INFINITY;
+ if (element.clientWidth + 1 < Math.min(element.scrollWidth, room)) return true;
+ }
+ return false;
+}
+
+/** Setzt die Leiste auf die erste Stufe, die passt, und gibt sie zurueck. In voller Stufe passt sie nur, wenn auch die Wurzel ganz steht. */
export function fitToolbar(bar: HTMLElement): ToolbarFit {
- const fit = chooseToolbarFit(level => { bar.dataset.fit = level; return toolbarOverflows(bar); });
+ const fit = chooseToolbarFit(level => { bar.dataset.fit = level; return toolbarOverflows(bar) || (level === 'full' && toolbarSqueezes(bar)); });
bar.dataset.fit = fit;
return fit;
}