Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,10 @@ import { AdvancedSearchFooter } from "./AdvancedSearchFooter";

type Props = Record<string, unknown>;

const getNodeBadgeText = (node: DiscourseNode): string =>
(node.tag?.trim() || node.text).slice(0, 3).toUpperCase();
const getNodeBadgeText = (node: DiscourseNode): string => {
const text = (node.tag?.trim() || node.text).replace(/^#/, "");
return text.slice(0, 3).toUpperCase();
};

const getTagStyle = (node: DiscourseNode | undefined): React.CSSProperties => {
const color = node?.canvasSettings?.color;
Expand Down Expand Up @@ -102,7 +104,9 @@ const ResultRow = ({
}}
>
<Tag minimal style={getTagStyle(nodeConfig)}>
{nodeConfig ? getNodeBadgeText(nodeConfig) : result.nodeTypeLabel}
{nodeConfig
? getNodeBadgeText(nodeConfig)
: result.nodeTypeLabel.replace(/^#/, "").slice(0, 3).toUpperCase()}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Duplicated badge-formatting logic inline instead of reusing a utility function

The badge text formatting logic .replace(/^#/, "").slice(0, 3).toUpperCase() at line 109 duplicates the same transformation already implemented in getNodeBadgeText (lines 52-55). This violates the AGENTS.md rule: "Prefer util functions for reusable logic and common operations" and "Prefer small, focused functions over inline code". A small helper (e.g., formatBadgeText(label: string): string) should be extracted and used in both getNodeBadgeText and the fallback branch.

Prompt for agents
The badge text formatting logic (strip leading #, take first 3 chars, uppercase) is duplicated: once in getNodeBadgeText (line 52-55) and once inline in the ResultRow fallback (line 109). Per AGENTS.md rules, reusable logic should be extracted into utility functions.

Suggested approach:
1. Extract a small helper like formatBadgeText(text: string): string that does text.replace(/^#/, '').slice(0, 3).toUpperCase()
2. Use it in getNodeBadgeText: return formatBadgeText(node.tag?.trim() || node.text)
3. Use it in the ResultRow fallback: formatBadgeText(result.nodeTypeLabel)

This keeps the logic in one place and follows the repo's code organization guidelines.
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Comment on lines +107 to +109

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚩 Fallback branch now truncates nodeTypeLabel (behavioral change)

Previously when nodeConfig was undefined, the full result.nodeTypeLabel string was displayed in the <Tag>. Now it's truncated to 3 uppercase characters (line 109). This is likely an intentional fix for visual consistency with the getNodeBadgeText path, but it is a user-visible change: any result without a matching nodeConfig will now show an abbreviated badge instead of the full label.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

</Tag>
<span className="min-w-0 break-words text-sm leading-snug text-gray-900">
{renderHighlightedText(stripTypePrefix(result.title), keywords)}
Expand Down