Skip to content

Commit 53a3edd

Browse files
committed
Show parent directory in file mention chips
1 parent 7ecb7c3 commit 53a3edd

2 files changed

Lines changed: 20 additions & 8 deletions

File tree

apps/code/src/renderer/features/message-editor/suggestions/getSuggestions.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,18 @@ export async function getFileSuggestions(
5252
const { files, fzf } = await fetchRepoFiles(repoPath);
5353
const matched = searchFiles(fzf, files, query);
5454

55-
return matched.map((file) => ({
56-
id: file.path,
57-
label: file.name,
58-
description: file.dir || undefined,
59-
filename: file.name,
60-
path: file.path,
61-
}));
55+
return matched.map((file) => {
56+
const parentDir = file.dir ? file.dir.split("/").pop() : undefined;
57+
const label = parentDir ? `${parentDir}/${file.name}` : file.name;
58+
59+
return {
60+
id: file.path,
61+
label,
62+
description: file.dir || undefined,
63+
filename: file.name,
64+
path: file.path,
65+
};
66+
});
6267
}
6368

6469
export function getCommandSuggestions(

apps/code/src/renderer/features/message-editor/tiptap/MentionChipView.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@ function DefaultChip({
3535

3636
const isCommand = type === "command";
3737
const prefix = isCommand ? "/" : "@";
38+
const isFile = type === "file";
3839

39-
return (
40+
const chip = (
4041
<span
4142
className={`${isCommand ? "cli-slash-command" : "cli-file-mention"} ${chipClass}`}
4243
contentEditable={false}
@@ -45,6 +46,12 @@ function DefaultChip({
4546
{label}
4647
</span>
4748
);
49+
50+
if (isFile) {
51+
return <Tooltip content={id}>{chip}</Tooltip>;
52+
}
53+
54+
return chip;
4855
}
4956

5057
function PastedTextChip({

0 commit comments

Comments
 (0)