Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

🐛 fix(agent-docs): restore the documents sidebar height and truncate titles natively (#19524)

Inneid270e8218006
diff --git a/src/features/AgentDocumentPage/RightPanel/index.tsx b/src/features/AgentDocumentPage/RightPanel/index.tsx
index f0c31c8584b..07d433cc15d 100644
--- a/src/features/AgentDocumentPage/RightPanel/index.tsx
+++ b/src/features/AgentDocumentPage/RightPanel/index.tsx
@@ -49,8 +49,7 @@ const styles = createStaticStyles(({ css, cssVar }) => ({
`,
body: css`
overflow-y: auto;
- flex: 1;
- min-height: 0;
+ height: 100%;
`,
}));
diff --git a/src/features/AgentDocumentsExplorer/DocumentExplorerTree.tsx b/src/features/AgentDocumentsExplorer/DocumentExplorerTree.tsx
index 49c39d8e659..c86c3537e14 100644
--- a/src/features/AgentDocumentsExplorer/DocumentExplorerTree.tsx
+++ b/src/features/AgentDocumentsExplorer/DocumentExplorerTree.tsx
@@ -32,15 +32,11 @@ import DocumentExplorerToolbar from './DocumentExplorerToolbar';
import { useDocumentTreeOps } from './hooks/useDocumentTreeOps';
import type { AgentDocumentItem } from './types';
import { isOrphanSkillBundleItem } from './types';
-import { usePanelBackground } from './usePanelBackground';
import { canDropDocument } from './utils/canDrop';
const SKILL_INDEX_FILENAME = 'SKILL.md';
const FILE_TREE_HOST_TAG = 'file-tree-container';
const RENAME_INPUT_SELECTOR = 'input[data-item-rename-input]';
-// Only used when every ancestor is transparent; the documents page is the
-// common case and paints colorBgLayout.
-const DEFAULT_PANEL_BACKGROUND = '#000';
const DOCUMENT_TREE_UNSAFE_CSS = [
DOCUMENT_TREE_ICON_CSS,
@@ -95,7 +91,6 @@ const styles = createStaticStyles(({ css, cssVar }) => ({
/* Consumed by DOCUMENT_TREE_ICON_CSS inside the shadow root. */
--explorer-tree-icon-fg: ${cssVar.colorTextDescription};
-
`,
}));
@@ -171,9 +166,6 @@ const DocumentExplorerTree = memo<Props>(({ agentId, data, mutate, onOpenDocumen
})),
[documents, resolveNodeName, resolveParentRowId],
);
- // pierre's truncation marker masks the characters it overlays with this color;
- // it has to be whatever the surrounding panel paints (see usePanelBackground).
- const panelBackground = usePanelBackground(containerRef, DEFAULT_PANEL_BACKGROUND);
const treeStyleVars = useMemo(
() =>
@@ -185,10 +177,7 @@ const DocumentExplorerTree = memo<Props>(({ agentId, data, mutate, onOpenDocumen
[nodes],
);
- const treeStyle = useMemo(
- () => ({ ...style, ...treeStyleVars, '--explorer-tree-panel-bg': panelBackground }),
- [panelBackground, style, treeStyleVars],
- );
+ const treeStyle = useMemo(() => ({ ...style, ...treeStyleVars }), [style, treeStyleVars]);
const parentMap = useMemo(() => {
const map = new Map<string, string | null>();
diff --git a/src/features/AgentDocumentsExplorer/usePanelBackground.ts b/src/features/AgentDocumentsExplorer/usePanelBackground.ts
deleted file mode 100644
index bcf8055ecd7..00000000000
--- a/src/features/AgentDocumentsExplorer/usePanelBackground.ts
+++ /dev/null
@@ -1,44 +0,0 @@
-import { type RefObject, useLayoutEffect, useState } from 'react';
-
-const TRANSPARENT = new Set(['transparent', 'rgba(0, 0, 0, 0)']);
-
-/**
- * Resolve the background actually painted behind a node.
- *
- * pierre's truncation marker paints the ellipsis over the characters it
- * replaces and masks them with `--truncate-marker-background-color`. The
- * document tree keeps its rows transparent so the surrounding panel shows
- * through, which leaves that mask with nothing to paint — the ellipsis lands on
- * top of the text. Feeding it the panel's own color fixes that, but the color is
- * not a constant: the documents page renders on `colorBgLayout` (#000) while the
- * conversation working sidebar renders on `colorBgContainer` (#0d0d0d), so a
- * single token leaves a visible patch on whichever surface it does not match.
- *
- * Walking up for the first non-transparent background reads whatever the current
- * host actually paints, so a third surface needs no change here. `fallback`
- * covers the case where every ancestor is transparent (nothing is painted, so
- * the mask has nothing to hide anyway).
- */
-export const usePanelBackground = (
- ref: RefObject<HTMLElement | null>,
- fallback: string,
-): string => {
- const [background, setBackground] = useState(fallback);
-
- useLayoutEffect(() => {
- let node: HTMLElement | null = ref.current;
- while (node) {
- const color = getComputedStyle(node).backgroundColor;
- if (color && !TRANSPARENT.has(color)) {
- setBackground(color);
- return;
- }
- node = node.parentElement;
- }
- setBackground(fallback);
- // The theme swaps every token at once, so re-resolve whenever the fallback
- // (itself a themed token) changes.
- }, [fallback, ref]);
-
- return background;
-};
diff --git a/src/features/ExplorerTree/documentTreeStyle.test.ts b/src/features/ExplorerTree/documentTreeStyle.test.ts
index f7f0ec6ae74..6ea3bece32a 100644
--- a/src/features/ExplorerTree/documentTreeStyle.test.ts
+++ b/src/features/ExplorerTree/documentTreeStyle.test.ts
@@ -39,7 +39,7 @@ describe('document tree and code tree are styled independently', () => {
it('confines the row treatment (folder weight, focus ring, trailing ellipsis) to the document tree', () => {
expect(DOCUMENT_TREE_ROW_CSS).toContain('font-weight: 500');
- expect(DOCUMENT_TREE_ROW_CSS).toContain('data-truncate-segment-priority');
+ expect(DOCUMENT_TREE_ROW_CSS).toContain('text-overflow: ellipsis');
expect(DOCUMENT_TREE_ROW_CSS).toContain('outline: none');
expect(FOLDER_ICON_CSS).not.toContain(DOCUMENT_TREE_ROW_CSS.trim());
});
diff --git a/src/features/ExplorerTree/documentTreeStyle.ts b/src/features/ExplorerTree/documentTreeStyle.ts
index 1f680f39094..0057c92bf11 100644
--- a/src/features/ExplorerTree/documentTreeStyle.ts
+++ b/src/features/ExplorerTree/documentTreeStyle.ts
@@ -109,49 +109,35 @@ const DOCUMENT_TREE_NO_FOCUS_BORDER_CSS = `
`;
// pierre truncates every row with `MiddleTruncate split:"extension"` and no way
-// to configure it (FileTreeView hard-codes it; FileTreeOptions has no field for
-// truncation). The stem is rendered as a shrink-first segment and the extension
-// as a shrink-last one, so a long title collapses to `…承载md` — the ellipsis
-// lands mid-word and the extension survives, which is backwards for a document
-// outline where the title is the content and `.md` is storage detail.
-//
-// The split itself is only a flex priority in pierre's own stylesheet, so
-// swapping the two priorities is enough: the stem now holds its width and the
-// extension collapses to its own leading marker, which renders as one trailing
-// ellipsis. A title that fits is untouched — both halves render in full.
+// to configure it (FileTreeView hard-codes it). It halves the label, renders each
+// half as its own overflow-measured segment and paints an opaque "…" marker over
+// whichever half overflows, so a title without an extension loses its entire
+// second half the moment it overflows by a pixel, and the marker's fade-in
+// flashes a plate over the text whenever rows re-render (folder expand/collapse).
+// A document outline wants a plain trailing ellipsis, so flatten the segments
+// back into one inline run and let the browser truncate it.
const DOCUMENT_TREE_TRAILING_ELLIPSIS_CSS = `
[data-item-section='content'] [data-truncate-group-container='middle'] {
- & > div[data-truncate-segment-priority='1'] {
- flex: 0 999999 max-content;
- }
-
- & > div[data-truncate-segment-priority='2'] {
- flex: 0 1 max-content;
+ overflow: hidden;
+ display: block;
+ min-width: 0;
+ white-space: nowrap;
+ text-overflow: ellipsis;
+
+ & * {
+ overflow: visible;
+ display: inline;
+ height: auto;
+ margin: 0;
+ direction: ltr;
}
- }
- /* The swap leaves a narrow band where the overflow is smaller than the
- extension: it then shrinks to a few pixels and, being right-aligned, leaks
- its last character ("…研究报告 d"). pierre's own overflow query fires on that
- segment, so stretch its marker across the segment — the marker is opaque and
- sits above the text, so a partially rendered extension is covered rather
- than half-shown. A fully collapsed one is zero-wide and stays invisible. */
- @container measure (height > 1lh) {
- [data-item-section='content'] [data-truncate-container='fruncate'] [data-truncate-marker] {
- inset: 0;
- justify-content: flex-start;
+ & [data-truncate-content='overflow'],
+ & [data-truncate-marker-cell],
+ & [data-truncate-fill] {
+ display: none;
}
}
-
- /* pierre paints the marker over the last characters and masks them with
- --truncate-marker-background-color, which defaults to --trees-bg. These rows
- are transparent so the panel shows through, and the ellipsis ended up drawn
- on top of the text. Point the marker at the panel's own background so it
- masks again, without giving the rows an opaque fill of their own. */
- [data-type='item'] {
- --truncate-marker-background-color: var(--explorer-tree-panel-bg, transparent);
- }
-
`;
// Row presentation for the document tree. Nesting is carried by indentation