π OpenHands: AI-Driven Development
Add trailing slash to directory paths in UI (#8188)
Robert Brennan906823f898c0
diff --git a/frontend/src/components/features/chat/path-component.tsx b/frontend/src/components/features/chat/path-component.tsxindex ad341b5769..d6865d4ef1 100644--- a/frontend/src/components/features/chat/path-component.tsx+++ b/frontend/src/components/features/chat/path-component.tsx@@ -12,6 +12,21 @@ const decodeHtmlEntities = (text: string): string => {return textarea.value;};+/**+ * Checks if a path is likely a directory+ * @param path The full path+ * @returns True if the path is likely a directory+ */+const isLikelyDirectory = (path: string): boolean => {+ if (!path) return false;+ // Check if path already ends with a slash+ if (path.endsWith("/") || path.endsWith("\\")) return true;+ // Check if path has no extension (simple heuristic)+ const lastPart = path.split(/[/\\]/).pop() || "";+ // If the last part has no dots or ends with a dot, it's likely a directory+ return !lastPart.includes(".") || lastPart.endsWith(".");+};+/*** Extracts the filename from a path* @param path The full path@@ -21,7 +36,14 @@ const extractFilename = (path: string): string => {if (!path) return "";// Handle both Unix and Windows pathsconst parts = path.split(/[/\\]/);- return parts[parts.length - 1];+ const filename = parts[parts.length - 1];++ // Add trailing slash for directories+ if (isLikelyDirectory(path) && !filename.endsWith("/")) {+ return `${filename}/`;+ }++ return filename;};/**