From 4d4eacfc40f87ecc991aaecc12c046d49654425c Mon Sep 17 00:00:00 2001
From: Shreya Keshive <skeshive@gmail.com>
Date: Thu, 7 Aug 2025 17:19:31 -0400
Subject: Few IDE integration polishes (#5727)

---
 .../src/ui/components/IDEContextDetailDisplay.tsx  | 27 +++++++++++++++++-----
 1 file changed, 21 insertions(+), 6 deletions(-)

(limited to 'packages/cli/src/ui/components/IDEContextDetailDisplay.tsx')

diff --git a/packages/cli/src/ui/components/IDEContextDetailDisplay.tsx b/packages/cli/src/ui/components/IDEContextDetailDisplay.tsx
index a1739227..ec3c2dad 100644
--- a/packages/cli/src/ui/components/IDEContextDetailDisplay.tsx
+++ b/packages/cli/src/ui/components/IDEContextDetailDisplay.tsx
@@ -23,6 +23,12 @@ export function IDEContextDetailDisplay({
     return null;
   }
 
+  const basenameCounts = new Map<string, number>();
+  for (const file of openFiles) {
+    const basename = path.basename(file.path);
+    basenameCounts.set(basename, (basenameCounts.get(basename) || 0) + 1);
+  }
+
   return (
     <Box
       flexDirection="column"
@@ -38,12 +44,21 @@ export function IDEContextDetailDisplay({
       {openFiles.length > 0 && (
         <Box flexDirection="column" marginTop={1}>
           <Text bold>Open files:</Text>
-          {openFiles.map((file: File) => (
-            <Text key={file.path}>
-              - {path.basename(file.path)}
-              {file.isActive ? ' (active)' : ''}
-            </Text>
-          ))}
+          {openFiles.map((file: File) => {
+            const basename = path.basename(file.path);
+            const isDuplicate = (basenameCounts.get(basename) || 0) > 1;
+            const parentDir = path.basename(path.dirname(file.path));
+            const displayName = isDuplicate
+              ? `${basename} (/${parentDir})`
+              : basename;
+
+            return (
+              <Text key={file.path}>
+                - {displayName}
+                {file.isActive ? ' (active)' : ''}
+              </Text>
+            );
+          })}
         </Box>
       )}
     </Box>
-- 
cgit v1.2.3

