Skip to content

Commit ca00d30

Browse files
committed
fix(dashboard): strip glob chars before fuzzy matching, respond to reviews
Strip glob metacharacters (*?[]) from the filter before passing to fuzzyMatch so they don't inflate Levenshtein distances. 'Error*' now correctly suggests 'Error Rate' etc.
1 parent 433e641 commit ca00d30

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/commands/dashboard/list.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,16 @@ export function decodeCursor(cursor: string): {
119119
function formatDashboardListHuman(result: DashboardListResult): string {
120120
if (result.dashboards.length === 0) {
121121
if (result.titleFilter && result.allTitles && result.allTitles.length > 0) {
122-
const similar = fuzzyMatch(result.titleFilter, result.allTitles, {
123-
maxResults: 5,
124-
});
122+
// Strip glob metacharacters before fuzzy matching so '*', '?', '['
123+
// don't inflate Levenshtein distances (e.g. "Error*" → "Error").
124+
const stripped = result.titleFilter.replace(/[*?[\]]/g, "");
125+
const similar = fuzzyMatch(
126+
stripped || result.titleFilter,
127+
result.allTitles,
128+
{
129+
maxResults: 5,
130+
}
131+
);
125132
if (similar.length > 0) {
126133
return `No dashboards matching '${result.titleFilter}'. Did you mean:\n${similar.map((t) => ` • ${t}`).join("\n")}`;
127134
}

0 commit comments

Comments
 (0)