Skip to content

Beautiful, AI-native markdown IDE and LLM wiki

Show the full file path when hovering an editor tab (#3174)

Andrew Mikofalvy1ab077319fcc
diff --git a/.changeset/editor-tab-path-tooltip.md b/.changeset/editor-tab-path-tooltip.md
new file mode 100644
index 000000000..734a3daf3
--- /dev/null
+++ b/.changeset/editor-tab-path-tooltip.md
@@ -0,0 +1,5 @@
+---
+"@inkeep/open-knowledge": patch
+---
+
+Hovering an editor tab now shows the file's full path in a tooltip, so two tabs with the same file name — `SPEC.md` from two different folders, say — are no longer indistinguishable. The path was previously only available through the browser's native `title` tooltip, which is unstyled and takes about a second to appear; it now uses the app's own tooltip and appears immediately. Asset and skill-bundle-file tabs, which had no hover path at all, now show one too, and the tooltip stays out of the way while you drag a tab to reorder it.
diff --git a/packages/app/src/components/EditorTabs.dom.test.tsx b/packages/app/src/components/EditorTabs.dom.test.tsx
index 4dcd047c5..2b0cda915 100644
--- a/packages/app/src/components/EditorTabs.dom.test.tsx
+++ b/packages/app/src/components/EditorTabs.dom.test.tsx
@@ -55,6 +55,8 @@ const dndContextProps: DndContextProps[] = [];
const sensorCalls: Array<{ sensor: unknown; options: unknown }> = [];
const sortableContextProps: Array<{ items: string[]; strategy: unknown }> = [];
const sortableOptions: Array<{ id: string; disabled?: boolean }> = [];
+// Stands in for dnd-kit's in-flight drag; non-null simulates a reorder drag.
+let activeDrag: { id: string } | null = null;
import * as actualLinguiMacro from '@lingui/react/macro';
@@ -83,6 +85,7 @@ vi.doMock('@dnd-kit/core', () => ({
},
KeyboardSensor: keyboardSensorToken,
PointerSensor: pointerSensorToken,
+ useDndContext: () => ({ active: activeDrag }),
useSensor: (sensor: unknown, options: unknown) => {
sensorCalls.push({ sensor, options });
return { sensor, options };
@@ -245,6 +248,7 @@ function resetState() {
]);
lifecycleStatuses = new Map();
toastErrors = [];
+ activeDrag = null;
dndContextProps.length = 0;
sensorCalls.length = 0;
sortableContextProps.length = 0;
@@ -296,6 +300,14 @@ function tabButton(name: string) {
return button as HTMLButtonElement;
}
+// Radix appends a visually-hidden copy of the content for screen readers, so
+// the element's textContent repeats the label. The first node is what a
+// sighted user actually reads, and comparing it exactly keeps these
+// assertions from passing on a different tab's tooltip.
+function tooltipText(tooltip: HTMLElement): string {
+ return tooltip.firstChild?.textContent ?? tooltip.textContent ?? '';
+}
+
describe('EditorTabs runtime behavior', () => {
beforeEach(() => {
resetState();
@@ -305,24 +317,89 @@ describe('EditorTabs runtime behavior', () => {
cleanup();
});
- test('renders markdown doc labels without extensions while preserving full-path accessible names and titles', async () => {
+ test('renders markdown doc labels without extensions while preserving full-path accessible names', async () => {
await renderEditorTabs();
const markdownTab = tabButton('docs/team/notes.md');
expect(markdownTab.textContent).toBe('notes');
- expect(markdownTab.getAttribute('title')).toBe('docs/team/notes.md');
expect(markdownTab.closest('[data-sortable-id]')?.getAttribute('aria-keyshortcuts')).toBe(
'Meta+1 Control+1',
);
const mdxTab = tabButton('docs/team/spec.mdx');
expect(mdxTab.textContent).toBe('spec');
- expect(mdxTab.getAttribute('title')).toBe('docs/team/spec.mdx');
expect(mdxTab.closest('[data-sortable-id]')?.getAttribute('aria-current')).toBe('page');
const txtTab = tabButton('docs/team/readme.txt');
expect(txtTab.textContent).toBe('readme.txt');
- expect(txtTab.getAttribute('title')).toBe('docs/team/readme.txt');
+ });
+
+ // The visible label is only the base name, so two same-named files in
+ // different folders are indistinguishable without disclosing the path.
+ test('hovering a doc tab discloses its full path, which the label alone does not show', async () => {
+ await renderEditorTabs();
+
+ const markdownTab = tabButton('docs/team/notes.md');
+ expect(markdownTab.textContent).toBe('notes');
+ // The native tooltip attribute is deliberately gone: it would double up
+ // with the hover tooltip and renders OS-styled after a ~1s delay.
+ expect(markdownTab.getAttribute('title')).toBeNull();
+
+ fireEvent.pointerEnter(markdownTab, { pointerType: 'mouse' });
+ fireEvent.pointerMove(markdownTab, { pointerType: 'mouse' });
+
+ const tooltip = await screen.findByRole('tooltip');
+ expect(tooltipText(tooltip)).toBe('docs/team/notes.md');
+ });
+
+ test.each([
+ ['folder', 'docs/team/'],
+ ['asset', 'images/cat.png'],
+ ])('hovering a %s tab discloses its full path', async (_kind, expectedPath) => {
+ await renderEditorTabs();
+
+ const tab = tabButton(expectedPath);
+ fireEvent.pointerEnter(tab, { pointerType: 'mouse' });
+ fireEvent.pointerMove(tab, { pointerType: 'mouse' });
+
+ const tooltip = await screen.findByRole('tooltip');
+ expect(tooltipText(tooltip)).toBe(expectedPath);
+ });
+
+ test('a reorder drag suppresses the path tooltip instead of stranding it over the strip', async () => {
+ activeDrag = { id: 'docs/team/notes' };
+ await renderEditorTabs();
+
+ const markdownTab = tabButton('docs/team/notes.md');
+ fireEvent.pointerEnter(markdownTab, { pointerType: 'mouse' });
+ fireEvent.pointerMove(markdownTab, { pointerType: 'mouse' });
+
+ await Promise.resolve();
+ expect(screen.queryByRole('tooltip')).toBeNull();
+ // Load-bearing, not incidental coupling: the tooltip opens on a timer, so
+ // the absence above would also hold in the split second before an
+ // unsuppressed tooltip appeared. Asserting the trigger is gone is what
+ // makes this fail if the suppression is removed.
+ expect(markdownTab.getAttribute('data-slot')).not.toBe('tooltip-trigger');
+ });
+
+ // Tabs cap at max-w-64 and truncate, so a root-level name long enough to be
+ // clipped still needs the disclosure even though no folder prefix precedes
+ // it. Suppressing the apparent echo would leave that tab unreadable.
+ test('a doc at the content root still discloses its name on hover', async () => {
+ openTabs = ['readme'];
+ visibleTabIds = ['readme'];
+ pageMeta = new Map([['readme', { docExt: '.txt' }]]);
+ await renderEditorTabs();
+
+ const rootTab = tabButton('readme.txt');
+ expect(rootTab.textContent).toBe('readme.txt');
+
+ fireEvent.pointerEnter(rootTab, { pointerType: 'mouse' });
+ fireEvent.pointerMove(rootTab, { pointerType: 'mouse' });
+
+ const tooltip = await screen.findByRole('tooltip');
+ expect(tooltipText(tooltip)).toBe('readme.txt');
});
test('keeps folder, asset, and new-tab branches closeable and independently activatable', async () => {
@@ -687,7 +764,11 @@ describe('EditorTabs runtime behavior', () => {
name: 'docs/team/notes.md (conflict)',
});
expect(conflictedTabButton).toBeTruthy();
- expect(conflictedTabButton.getAttribute('title')).toBe('docs/team/notes.md (conflict)');
+ // A conflict is the one case where the tooltip carries state beyond the
+ // path, so pin that it tracks the label rather than just the path.
+ fireEvent.pointerEnter(conflictedTabButton, { pointerType: 'mouse' });
+ fireEvent.pointerMove(conflictedTabButton, { pointerType: 'mouse' });
+ expect(tooltipText(await screen.findByRole('tooltip'))).toBe('docs/team/notes.md (conflict)');
expect(screen.getByTestId('editor-tab-conflict-badge').getAttribute('aria-hidden')).toBe(
'true',
);
diff --git a/packages/app/src/components/EditorTabs.tsx b/packages/app/src/components/EditorTabs.tsx
index df078e387..91d10b52c 100644
--- a/packages/app/src/components/EditorTabs.tsx
+++ b/packages/app/src/components/EditorTabs.tsx
@@ -5,6 +5,7 @@ import {
type DragEndEvent,
KeyboardSensor,
PointerSensor,
+ useDndContext,
useSensor,
useSensors,
} from '@dnd-kit/core';
@@ -381,6 +382,40 @@ function TabPinOrCloseButton({
);
}
+/**
+ * Full-path hover disclosure for a tab whose visible label is only the base
+ * name — two `SPEC.md` tabs from different folders are otherwise
+ * indistinguishable. Supersedes the native `title` attribute, which carried
+ * the same string but renders OS-styled after the platform's own ~1s delay;
+ * keeping both would stack a second tooltip under the first.
+ *
+ * Shown even where the label already reads as the whole name. Tabs cap at
+ * `max-w-64` and truncate, so a long enough name is clipped whether or not a
+ * folder prefix precedes it, and that clipped case is exactly where the
+ * disclosure earns its keep. Suppressing the apparent echo would drop it.
+ * Same reasoning as the terminal tab strip and the footer project path.
+ *
+ * Anchored to the inner label button, not the outer sortable tab, because
+ * `SortableTab` spreads dnd-kit's `listeners` after `rest` — pointer handlers
+ * a trigger injected there would be silently overwritten.
+ */
+function TabPathTooltip({ children, path }: { children: ReactNode; path: string }) {
+ // A reorder drag keeps firing pointermove over the trigger, which re-opens
+ // the tooltip mid-drag still anchored to the tab's original slot. Radix
+ // closes on pointerdown but has no notion of an in-flight drag, so the
+ // active-drag check has to come from dnd-kit.
+ const { active } = useDndContext();
+ if (active) return children;
+ return (
+ <Tooltip>
+ <TooltipTrigger asChild>{children}</TooltipTrigger>
+ <TooltipContent side="bottom" sideOffset={8} className="max-w-xs break-all">
+ {path}
+ </TooltipContent>
+ </Tooltip>
+ );
+}
+
// The parent tab button owns the accessible conflict label; this icon is visual.
function TabConflictBadge({ hasConflict }: { hasConflict: boolean }) {
if (!hasConflict) return null;
@@ -418,27 +453,28 @@ function DocumentTabButton({
const buttonAccessibleLabel = hasConflict ? t`${accessibleLabel} (conflict)` : accessibleLabel;
return (
- <button
- type="button"
- aria-label={buttonAccessibleLabel}
- title={buttonAccessibleLabel}
- className={TAB_BUTTON_CLASS}
- onClick={() => {
- activateTab(tabId);
- }}
- onDoubleClick={(event) => {
- event.preventDefault();
- event.stopPropagation();
- enterRenameMode(tabId, docName);
- }}
- tabIndex={-1}
- >
- <TabConflictBadge hasConflict={hasConflict} />
- <span className="flex min-w-0 flex-1 items-center">
- <span className="min-w-0 truncate">{baseName}</span>
- {!hideDocExtension && <span className="shrink-0">{extension}</span>}
- </span>
- </button>
+ <TabPathTooltip path={buttonAccessibleLabel}>
+ <button
+ type="button"
+ aria-label={buttonAccessibleLabel}
+ className={TAB_BUTTON_CLASS}
+ onClick={() => {
+ activateTab(tabId);
+ }}
+ onDoubleClick={(event) => {
+ event.preventDefault();
+ event.stopPropagation();
+ enterRenameMode(tabId, docName);
+ }}
+ tabIndex={-1}
+ >
+ <TabConflictBadge hasConflict={hasConflict} />
+ <span className="flex min-w-0 flex-1 items-center">
+ <span className="min-w-0 truncate">{baseName}</span>
+ {!hideDocExtension && <span className="shrink-0">{extension}</span>}
+ </span>
+ </button>
+ </TabPathTooltip>
);
}
@@ -1010,36 +1046,37 @@ export function EditorTabs() {
activateTab(tabId);
}}
>
- <button
- type="button"
- aria-label={accessibleLabel}
- title={accessibleLabel}
- className={TAB_BUTTON_CLASS}
- onClick={() => {
- activateTab(tabId);
- }}
- tabIndex={-1}
- >
- {prefix && (
+ <TabPathTooltip path={accessibleLabel}>
+ <button
+ type="button"
+ aria-label={accessibleLabel}
+ className={TAB_BUTTON_CLASS}
+ onClick={() => {
+ activateTab(tabId);
+ }}
+ tabIndex={-1}
+ >
+ {prefix && (
+ <span
+ className={cn(
+ 'min-w-0 flex-1 truncate',
+ isActive && 'text-muted-foreground',
+ )}
+ >
+ {prefix}
+ </span>
+ )}
<span
className={cn(
- 'min-w-0 flex-1 truncate',
- isActive && 'text-muted-foreground',
+ 'flex min-w-0 items-center',
+ prefix ? 'max-w-[70%] shrink-0' : 'flex-1',
)}
>
- {prefix}
+ <span className="min-w-0 truncate">{baseName}</span>
+ <span className="shrink-0">/</span>
</span>
- )}
- <span
- className={cn(
- 'flex min-w-0 items-center',
- prefix ? 'max-w-[70%] shrink-0' : 'flex-1',
- )}
- >
- <span className="min-w-0 truncate">{baseName}</span>
- <span className="shrink-0">/</span>
- </span>
- </button>
+ </button>
+ </TabPathTooltip>
<TabPinOrCloseButton
accessibleLabel={accessibleLabel}
closeTab={closeTab}
@@ -1107,34 +1144,36 @@ export function EditorTabs() {
activateTab(tabId);
}}
>
- <button
- type="button"
- aria-label={accessibleLabel}
- className={TAB_BUTTON_CLASS}
- onClick={() => {
- activateTab(tabId);
- }}
- tabIndex={-1}
- >
- {prefix ? (
+ <TabPathTooltip path={accessibleLabel}>
+ <button
+ type="button"
+ aria-label={accessibleLabel}
+ className={TAB_BUTTON_CLASS}
+ onClick={() => {
+ activateTab(tabId);
+ }}
+ tabIndex={-1}
+ >
+ {prefix ? (
+ <span
+ className={cn(
+ 'min-w-0 flex-1 truncate text-muted-foreground/60',
+ isActive && 'text-muted-foreground',
+ )}
+ >
+ {prefix}
+ </span>
+ ) : null}
<span
className={cn(
- 'min-w-0 flex-1 truncate text-muted-foreground/60',
- isActive && 'text-muted-foreground',
+ 'min-w-0 truncate',
+ prefix ? 'max-w-[70%] shrink-0' : 'flex-1',
)}
>
- {prefix}
+ {baseName}
</span>
- ) : null}
- <span
- className={cn(
- 'min-w-0 truncate',
- prefix ? 'max-w-[70%] shrink-0' : 'flex-1',
- )}
- >
- {baseName}
- </span>
- </button>
+ </button>
+ </TabPathTooltip>
<TabPinOrCloseButton
accessibleLabel={accessibleLabel}
closeTab={closeTab}