Skip to content

Fix: Remove leading # from search result tags in advanced search#1115

Open
mdroidian wants to merge 1 commit into
mainfrom
cursor/fix-search-tag-hash-prefix-e4c0
Open

Fix: Remove leading # from search result tags in advanced search#1115
mdroidian wants to merge 1 commit into
mainfrom
cursor/fix-search-tag-hash-prefix-e4c0

Conversation

@mdroidian

@mdroidian mdroidian commented Jun 9, 2026

Copy link
Copy Markdown
Member

Problem

In the advanced search dialog, node type tags were displaying with a leading # character, showing abbreviated forms like #CL and #QU instead of the intended CLM and QUE.

Solution

Updated the tag display logic to strip the leading # character before extracting the 3-letter abbreviation:

  • Modified getNodeBadgeText() to remove # prefix using .replace(/^#/, "") before slicing
  • Applied same fix to the fallback case when nodeConfig is unavailable

Changes

  • apps/roam/src/components/AdvancedNodeSearchDialog/AdvancedSearchDialog.tsx
    • Updated getNodeBadgeText function to strip leading # before taking first 3 characters
    • Updated inline tag rendering to handle nodeTypeLabel fallback with same # stripping logic

Testing

Build: Compiled successfully with 0 errors
Type checking: No TypeScript errors
Linting: All style checks passed
Logic verification: Tested with multiple scenarios

Test Cases Verified

Input Before After
#CLM #CL CLM
#QUE #QU QUE
#CLAIM #CL CLA
CLAIM CLA CLA

The fix ensures that:

  • Tags starting with # have the prefix removed before abbreviation
  • Tags without # continue to work as expected
  • All node type tags display their correct 3-letter abbreviations

Fixes ENG-1839

Linear Issue: ENG-1839

Open in Web Open in Cursor 

- Strip # prefix from node badges to show correct 3-letter abbreviations
- Applies to both nodeConfig and nodeTypeLabel fallback cases
- Fixes tags showing as #CL and #QU instead of CLM and QUE

Co-authored-by: Michael Gartner <mdroidian@users.noreply.github.com>
@linear-code

linear-code Bot commented Jun 9, 2026

Copy link
Copy Markdown

ENG-1839

@vercel

vercel Bot commented Jun 9, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
discourse-graph Skipped Skipped Jun 9, 2026 7:56am

Request Review

@supabase

supabase Bot commented Jun 9, 2026

Copy link
Copy Markdown

This pull request has been ignored for the connected project zytfjzqyijgagqxrzbmz because there are no changes detected in packages/database/supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

@mdroidian mdroidian marked this pull request as ready for review June 9, 2026 08:04
@mdroidian

Copy link
Copy Markdown
Member Author

@codex review

@mdroidian mdroidian requested a review from trangdoan982 June 9, 2026 08:04

@devin-ai-integration devin-ai-integration Bot left a comment

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.

Devin Review found 2 potential issues.

View 1 additional finding in Devin Review.

Open in Devin Review

{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
{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.

🚩 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.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@trangdoan982 trangdoan982 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@mdroidian the devin comments are worth addressing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants