Skip to content

web-clipper: prevent cloning when clipping to an existing note + optimizations#8894

Open
contributor wants to merge 6 commits intoTriliumNext:mainfrom
contributor:web-clipper-prevent-note-cloning
Open

web-clipper: prevent cloning when clipping to an existing note + optimizations#8894
contributor wants to merge 6 commits intoTriliumNext:mainfrom
contributor:web-clipper-prevent-note-cloning

Conversation

@contributor
Copy link
Copy Markdown
Contributor

@contributor contributor commented Mar 3, 2026

This removes undesired note cloning when clipping to existing note

Background

I noticed lot of cloned notes in clipper inbox appeared periodically. I blamed sync, but it turned out to be web clipper handler bug/feature.

The cloning was introduced in https://github.com/TriliumNext/Trilium/pull/4075/changes

But this does not works properly in my opinion:

  • when clipping note is in inbox, it still tries to clone it (and siliently fails due to validation)
  • when clipping note has been moved outside of inbox, it clones it to inbox (cluttering already organized inbox)

Proposed solution

  • When you clip an URL for the first time the note appears in clipper inbox (like it was before this PR)
  • When you clip the same URL another time, it keeps appending to the note regardless of note location, and does not clone it ("does not clone it" part is added in this PR)

Additional refactoring made

Finding clipping note code is now more correct semantically (uses searchService.searchNotes method instead of misleading indirection via note.searchNotesInSubtree method. As a bonus, it saves extra call to getClipperInboxNote on each click on browser extension, and in case of clipping selection to an exiting note.

@dosubot dosubot bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Mar 3, 2026
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 resolves an issue in the web clipper where re-clipping a URL to an already existing note would incorrectly create a clone of that note, often cluttering the clipper inbox. The modification ensures that when an existing URL is clipped again, new content is appended to the original note, regardless of its current location, thereby preventing unintended duplication and maintaining an organized inbox.

Highlights

  • Prevented undesired note cloning: Removed the logic that would clone an existing note to the clipper inbox when re-clipping the same URL, ensuring content is appended instead of duplicated.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • apps/server/src/routes/api/clipper.ts
    • Removed the conditional cloning logic within the addClipping function.
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
Copy Markdown
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 removes the logic that automatically clones a note to the clipper inbox when content is appended to it. This change addresses an issue where notes that were moved out of the inbox would be cloned back, cluttering the inbox. The removal of the cloning code is a direct and effective fix for the described problem.

@dosubot dosubot bot added size:S This PR changes 10-29 lines, ignoring generated files. and removed size:XS This PR changes 0-9 lines, ignoring generated files. labels Mar 8, 2026
…ctly)

instead of (misnamed) note.searchNotesInSubtree method
@contributor contributor marked this pull request as draft March 8, 2026 17:32
@contributor
Copy link
Copy Markdown
Contributor Author

/gemini review

@contributor contributor changed the title web-clipper: prevent note cloning when clipping to an existing note web-clipper: prevent cloning when clipping to an existing note + optimizations Mar 8, 2026
Copy link
Copy Markdown
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 primarily refactors the note clipping functionality by replacing the cloneService with a new searchService for finding existing clipping notes. The findClippingNote function was updated to use this global searchService and no longer requires a clipperInboxNote parameter. Consequently, the addClipping, createNote, and findNotesByUrl functions were adjusted to call the updated findClippingNote signature. The clipperInbox note is now only fetched when a new clipping note needs to be created, optimizing its retrieval. Additionally, the logic for appending content to existing #clipType=clippings notes with matching pageUrl attributes has been clarified in comments, and a minor formatting adjustment was made in the openNote function.

@contributor contributor marked this pull request as ready for review March 8, 2026 19:15
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:S This PR changes 10-29 lines, ignoring generated files. labels Mar 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant