fix(ui): truncate document paths from left to show filename

Apply RTL text direction with LTR text isolation to show the rightmost
(filename) portion of document paths when truncated, while maintaining
full path on hover via title attribute.

Updated components:
- DocumentsPanel: Auto Run document list entries
- RightPanel: Auto Run progress indicator (single and multi-doc views)
This commit is contained in:
Pedram Amini
2026-02-02 02:34:10 -06:00
parent a23cb425c3
commit 2f945ec032
2 changed files with 54 additions and 14 deletions

View File

@@ -14,6 +14,8 @@ import {
} from 'lucide-react';
import type { Theme, BatchDocumentEntry } from '../types';
import { generateId } from '../utils/ids';
import { useLayerStack } from '../contexts/LayerStackContext';
import { MODAL_PRIORITIES } from '../constants/modalPriorities';
// Platform detection helper (userAgentData is newer but not in all TS types yet)
const isMacPlatform = (): boolean => {
@@ -71,6 +73,27 @@ function DocumentSelectorModal({
onAdd,
onRefresh,
}: DocumentSelectorModalProps) {
// Layer stack for escape handling
const { registerLayer, unregisterLayer } = useLayerStack();
const onCloseRef = useRef(onClose);
onCloseRef.current = onClose;
// Register with layer stack for escape handling
useEffect(() => {
const id = registerLayer({
type: 'modal',
priority: MODAL_PRIORITIES.DOCUMENT_SELECTOR,
blocksLowerLayers: true,
capturesFocus: true,
focusTrap: 'strict',
ariaLabel: 'Select Documents',
onEscape: () => {
onCloseRef.current();
},
});
return () => unregisterLayer(id);
}, [registerLayer, unregisterLayer]);
// Pre-select currently added documents
const [selectedDocs, setSelectedDocs] = useState<Set<string>>(() => {
return new Set(documents.map((d) => d.filename));
@@ -956,14 +979,17 @@ export function DocumentsPanel({
}}
/>
{/* Document Name */}
{/* Document Name - truncates from left to show filename */}
<span
className={`flex-1 text-sm font-medium truncate ${doc.isMissing ? 'line-through' : ''}`}
className={`flex-1 text-sm font-medium overflow-hidden text-ellipsis whitespace-nowrap ${doc.isMissing ? 'line-through' : ''}`}
style={{
color: doc.isMissing ? theme.colors.error : theme.colors.textMain,
direction: 'rtl',
textAlign: 'left',
}}
title={`${doc.filename}.md`}
>
{doc.filename}.md
<bdi>{doc.filename}.md</bdi>
</span>
{/* Missing Indicator */}

View File

@@ -586,8 +586,16 @@ export const RightPanel = memo(
{currentSessionBatchState.documents &&
currentSessionBatchState.documents.length === 1 && (
<div className="mb-2">
<span className="text-xs" style={{ color: theme.colors.textDim }}>
{currentSessionBatchState.documents[0]}.md
<span
className="text-xs overflow-hidden text-ellipsis whitespace-nowrap block"
style={{
color: theme.colors.textDim,
direction: 'rtl',
textAlign: 'left',
}}
title={`${currentSessionBatchState.documents[0]}.md`}
>
<bdi>{currentSessionBatchState.documents[0]}.md</bdi>
</span>
</div>
)}
@@ -599,17 +607,23 @@ export const RightPanel = memo(
{/* Document name with progress bar */}
<div className="flex items-center gap-2 min-w-0">
<span
className="text-xs font-medium truncate min-w-0"
style={{ color: theme.colors.textMain }}
className="text-xs font-medium overflow-hidden text-ellipsis whitespace-nowrap min-w-0"
style={{
color: theme.colors.textMain,
direction: 'rtl',
textAlign: 'left',
}}
title={`Document ${currentSessionBatchState.currentDocumentIndex + 1}/${currentSessionBatchState.documents.length}: ${currentSessionBatchState.documents[currentSessionBatchState.currentDocumentIndex]}.md`}
>
Document {currentSessionBatchState.currentDocumentIndex + 1}/
{currentSessionBatchState.documents.length}:{' '}
{
currentSessionBatchState.documents[
currentSessionBatchState.currentDocumentIndex
]
}
<bdi>
Document {currentSessionBatchState.currentDocumentIndex + 1}/
{currentSessionBatchState.documents.length}:{' '}
{
currentSessionBatchState.documents[
currentSessionBatchState.currentDocumentIndex
]
}
</bdi>
</span>
<div
className="flex-1 h-1 rounded-full overflow-hidden shrink-0"