-
Notifications
You must be signed in to change notification settings - Fork 4
[ENG-1168] Preserve list indicators in node tag flow #619
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
[ENG-1168] Preserve list indicators in node tag flow #619
Conversation
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
📝 WalkthroughWalkthroughThe change introduces a centralized regex pattern (LIST_INDICATOR_REGEX) to identify and strip list item indicators from titles, adds an extractListPrefix utility function, and updates the node replacement logic to preserve leading list prefixes when replacing tags with discourse node links. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Pre-merge checks✅ Passed checks (3 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
apps/obsidian/src/utils/tagNodeHandler.ts (2)
15-30: Centralized list regex + prefix extraction look good; consider broader Markdown coverageUsing a shared
LIST_INDICATOR_REGEXin bothsanitizeTitleandextractListPrefixis a solid refactor and correctly preserves the exact indentation + bullet/number prefix when replacing lines.If you want this to be more robust long‑term, consider extending the pattern to also recognize common Markdown variants such as:
- Ordered lists with
1)as well as1.- Task list prefixes like
- [ ]/- [x]/* [ ]so that checkboxes and alternate numbering styles can be treated as part of the “list prefix” you preserve. For example:
-const LIST_INDICATOR_REGEX = /^(\s*)(\d+\.\s+|-\s+|\*\s+|\+\s+)/; +const LIST_INDICATOR_REGEX = + /^(\s*)(\d+[.)]\s+|[-*+]\s+(?:\[[ xX]\]\s+)?)/;This keeps current behavior but handles more Markdown list forms and task items in one place. Based on learnings, this also stays clear of
#handling, so multi‑#tags remain unaffected.
357-362: List prefix preservation in replacement logic matches PR goalUsing
extractListPrefix(actualLineText)and thenreplacementText = listPrefix + linkTextachieves the stated goal of keeping list indicators when turning a tagged line into a node link (e.g.,- #tag foo→- [[Node]]instead of[[Node]]).One nuance: any additional list adornments (like
[ ]in task lists) and trailing text on the line are still discarded, as before. If you later want to preserve those too, you’ll need to split the line intoprefix,tag segment, andsuffixrather than replacing the entire line. For this PR, the current behavior is consistent with prior semantics while fixing the list‑indicator loss.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
apps/obsidian/src/utils/tagNodeHandler.ts(2 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/main.mdc)
**/*.{ts,tsx}: Use Tailwind CSS for styling where possible
When refactoring inline styles, use tailwind classes
Prefertypeoverinterfacein TypeScript
Use explicit return types for functions
Avoidanytypes when possible
Prefer arrow functions over regular function declarations
Use named parameters (object destructuring) when a function has more than 2 parameters
Use PascalCase for components and types
Use camelCase for variables and functions
Use UPPERCASE for constants
Function names should describe their purpose clearly
Prefer early returns over nested conditionals for better readability
Files:
apps/obsidian/src/utils/tagNodeHandler.ts
apps/obsidian/**
📄 CodeRabbit inference engine (.cursor/rules/obsidian.mdc)
apps/obsidian/**: Prefer existing dependencies from apps/obsidian/package.json when adding dependencies to the Obsidian plugin
Follow the Obsidian style guide from help.obsidian.md/style-guide and docs.obsidian.md/Developer+policies for UI and code styling
Use Lucide and custom Obsidian icons alongside detailed elements to provide visual representation of features in platform-native UI
Files:
apps/obsidian/src/utils/tagNodeHandler.ts
🧠 Learnings (2)
📓 Common learnings
Learnt from: sid597
Repo: DiscourseGraphs/discourse-graph PR: 372
File: apps/roam/src/components/DiscourseNodeMenu.tsx:116-116
Timestamp: 2025-08-25T15:53:21.799Z
Learning: In apps/roam/src/components/DiscourseNodeMenu.tsx, when handling tag insertion, multiple leading hashtags (like ##foo) should be preserved as they represent user intent, not normalized to a single hashtag. The current regex /^#/ is correct as it only removes one leading # before adding one back, maintaining any additional hashtags the user intended.
📚 Learning: 2025-08-25T15:53:21.799Z
Learnt from: sid597
Repo: DiscourseGraphs/discourse-graph PR: 372
File: apps/roam/src/components/DiscourseNodeMenu.tsx:116-116
Timestamp: 2025-08-25T15:53:21.799Z
Learning: In apps/roam/src/components/DiscourseNodeMenu.tsx, when handling tag insertion, multiple leading hashtags (like ##foo) should be preserved as they represent user intent, not normalized to a single hashtag. The current regex /^#/ is correct as it only removes one leading # before adding one back, maintaining any additional hashtags the user intended.
Applied to files:
apps/obsidian/src/utils/tagNodeHandler.ts
https://www.loom.com/share/be086c1e8e26487eb1f7cf3ea992eaf6
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.