Skip to content

Conversation

@jsonify
Copy link
Owner

@jsonify jsonify commented Nov 22, 2025

🎯 Summary

This PR enhances the note creation system with support for custom file extensions and comprehensive debugging capabilities. Users can
now specify file extensions when creating notes (e.g., .py, .js, .json), and the extension includes detailed logging to improve
troubleshooting.

✨ Key Features

📄 Custom File Extension Support

  • User-Specified Extensions: Preserve user-provided file extensions when creating notes (e.g., my-note.py creates a Python file)
  • Smart Sanitization: New sanitizeFileName() utility that preserves extensions while cleaning invalid characters
  • Comprehensive Testing: 172 new unit tests ensuring robust file name handling across edge cases
  • Backward Compatibility: Default behavior unchanged for standard note creation

🔍 Enhanced Debugging & Logging

  • Activation Logging: Info-level logs for extension activation and command triggers
  • Note Creation Tracing: Extensive logging throughout the note creation flow
  • File Name Debugging: Detailed logs for sanitization and validation steps
  • Category Service Logs: Improved logging in category-based note organization

🛠️ Technical Changes

New Files

  • src/utils/fileNameHelpers.ts (102 lines) - Core file name utilities with extension preservation
  • src/test/unit/fileNameHelpers.test.ts (172 lines) - Comprehensive unit test suite

Modified Files

  • src/extension.ts - Added activation and command logging
  • src/services/noteService.ts - Enhanced logging in note creation flow
  • src/services/categoryService.ts - Improved debug output for categorization

📊 Test Coverage

  • 172 unit tests covering:
    • Extension preservation (.py, .js, .md, etc.)
    • Invalid character sanitization
    • Edge cases (empty names, special chars, multiple dots)
    • Unicode and whitespace handling
    • Case sensitivity scenarios

🚀 Use Cases

// Create Python script note
noted.openWithTemplate("data-processor.py", "quick")

// Create JavaScript config
noted.openWithTemplate("webpack.config.js", "research")

// Create JSON data file
noted.openWithTemplate("settings.json", "problem-solution")

📝 Testing Instructions

  1. Create note with custom extension: Command Palette → "Noted: Create Note with Template" → Enter test.py
  2. Verify file created with .py extension (not default .txt or .md)
  3. Check Output panel (Noted channel) for detailed logging
  4. Run tests: npm test (all 172 tests should pass)

🔗 Related Issues

Addresses user request for custom file extension support while improving debuggability of the extension.

claude and others added 6 commits November 21, 2025 18:20
- Add new fileNameHelpers utility with extension detection and sanitization
- Extract and preserve common file extensions (.sh, .py, .js, etc.) when provided by user
- Fall back to default .md extension when no extension is provided
- Update createNoteFromTemplate to use new sanitization logic
- Update getCategoryFolderPath to preserve extensions
- Add comprehensive test suite with 20 unit tests

Fixes issue where creating "example.sh" would create "examplesh.md" instead of "example.sh"

BREAKING CHANGE: None - maintains backward compatibility with default behavior
Resolved conflict in src/extension.ts by adopting the logger service
from main branch, replacing console.log statements with proper
structured logging.

Changes merged from main:
- New logService.ts with structured logging
- Updated extension.ts to use logger service
- CHANGELOG.md updates
- package.json updates
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @jsonify, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the note-taking extension by allowing users to define custom file extensions for their notes. It achieves this by refactoring filename sanitization into a new, dedicated utility module, which intelligently parses user input to preserve explicit extensions while applying standard sanitization rules. This change improves user flexibility and maintains data integrity by ensuring filenames are always valid and consistently formatted.

Highlights

  • Custom File Extensions: Users can now specify custom file extensions when creating notes, providing greater flexibility beyond the default configured extension.
  • Centralized Filename Sanitization: A new utility module (fileNameHelpers.ts) has been introduced to centralize and improve the sanitization of note filenames, ensuring consistency and robustness across all note creation flows.
  • Enhanced Logging: More detailed logging has been added throughout the note creation process and extension activation to aid in debugging and understanding filename resolution.
  • Comprehensive Unit Tests: New unit tests were added for the filename helper functions to ensure correct behavior for various filename scenarios, including handling custom extensions, special characters, and default fallbacks.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a valuable feature by allowing users to specify custom file extensions when creating notes. The implementation correctly centralizes the filename sanitization logic into a new, well-tested utility file (fileNameHelpers.ts). My review focuses on removing leftover debugging code that would negatively impact the user experience and code maintainability. I've also pointed out an opportunity to improve an import statement for consistency and an unused function that should be removed to keep the codebase clean.

jsonify and others added 2 commits November 21, 2025 18:39
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
- Remove logger import from fileNameHelpers.ts
- Remove logger.info calls from sanitizeFileName
- Remove logger import and calls from noteService.ts createNoteFromTemplate
- Remove unused buildFileName function per code review
- All 599 unit tests now passing
@jsonify jsonify force-pushed the claude/custom-file-extensions-01LhD3jpyebrEcF34tfrua5y branch from 329d656 to 6cdfac4 Compare November 22, 2025 03:09
@jsonify jsonify merged commit 40b88cd into main Nov 22, 2025
8 checks passed
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