Skip to content

Commit fc5e411

Browse files
committed
Add description truncation for slash commands in CLI UI
1 parent 7318af4 commit fc5e411

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-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: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@ 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 description.slice(0, MAX_DESCRIPTION_LENGTH).trim() + "…";
14+
};
15+
716
interface SlashCommandUIProps {
817
assistant?: AssistantConfig;
918
filter: string;
@@ -74,7 +83,7 @@ const SlashCommandUI: React.FC<SlashCommandUIProps> = ({
7483
{paddedCommandName}
7584
<Text color={isSelected ? "blue" : "gray"}>
7685
{" "}
77-
{command.description}
86+
{truncateDescription(command.description)}
7887
</Text>
7988
</Text>
8089
</Box>

0 commit comments

Comments
 (0)