Add description truncation for slash commands in CLI UI
This commit is contained in:
parent
7318af41c1
commit
fc5e411d51
2 changed files with 12 additions and 2 deletions
3
extensions/cli/.gitignore
vendored
3
extensions/cli/.gitignore
vendored
|
|
@ -13,4 +13,5 @@ config.yaml
|
|||
.continue-debug/
|
||||
|
||||
*.expect
|
||||
!demo.expect
|
||||
!demo.expect
|
||||
*.cast
|
||||
|
|
@ -4,6 +4,15 @@ import React, { useMemo } from "react";
|
|||
|
||||
import { getAllSlashCommands } from "../commands/commands.js";
|
||||
|
||||
const MAX_DESCRIPTION_LENGTH = 80;
|
||||
|
||||
const truncateDescription = (description: string): string => {
|
||||
if (description.length <= MAX_DESCRIPTION_LENGTH) {
|
||||
return description;
|
||||
}
|
||||
return description.slice(0, MAX_DESCRIPTION_LENGTH).trim() + "…";
|
||||
};
|
||||
|
||||
interface SlashCommandUIProps {
|
||||
assistant?: AssistantConfig;
|
||||
filter: string;
|
||||
|
|
@ -74,7 +83,7 @@ const SlashCommandUI: React.FC<SlashCommandUIProps> = ({
|
|||
{paddedCommandName}
|
||||
<Text color={isSelected ? "blue" : "gray"}>
|
||||
{" "}
|
||||
{command.description}
|
||||
{truncateDescription(command.description)}
|
||||
</Text>
|
||||
</Text>
|
||||
</Box>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue