Skip to content

Commit be07af5

Browse files
authored
Merge pull request #8172 from continuedev/nate/truncate-slash
Add description truncation for slash commands in CLI UI
2 parents f3cf9e9 + 80f9b49 commit be07af5

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

extensions/cli/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ config.yaml
1313
.continue-debug/
1414

1515
*.expect
16-
!demo.expect
16+
!demo.expect
17+
*.cast

extensions/cli/src/ui/SlashCommandUI.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,18 @@ import React, { useMemo } from "react";
44

55
import { getAllSlashCommands } from "../commands/commands.js";
66

7+
const MAX_DESCRIPTION_LENGTH = 80;
8+
9+
const truncateDescription = (description: string): string => {
10+
if (description.length <= MAX_DESCRIPTION_LENGTH) {
11+
return description;
12+
}
13+
return (
14+
Array.from(description).slice(0, MAX_DESCRIPTION_LENGTH).join("").trim() +
15+
"…"
16+
);
17+
};
18+
719
interface SlashCommandUIProps {
820
assistant?: AssistantConfig;
921
filter: string;
@@ -74,7 +86,7 @@ const SlashCommandUI: React.FC<SlashCommandUIProps> = ({
7486
{paddedCommandName}
7587
<Text color={isSelected ? "blue" : "gray"}>
7688
{" "}
77-
{command.description}
89+
{truncateDescription(command.description)}
7890
</Text>
7991
</Text>
8092
</Box>

0 commit comments

Comments
 (0)