Skip to content

Conversation

@werererer
Copy link

@werererer werererer commented Oct 12, 2025

Solves: #6817

State: Workes. waiting for Review
TODO:

Done:

  • Replaced scattered createNote calls with unified createNoteIntoPath / createNoteIntoInbox
  • Added CreateMode to autocomplete system
  • Introduced MentionAction enum for CKEditor mentions
  • Updated translations for new creation strings
  • Refactored note_autocomplete.ts and related widgets for consistency
  • Hopefully improved code structure for creating Notes

PS
Yes I had to put my hands on many files, because the logic of creating notes was handled by a lot of different files. After this PR managing the code for creating notes should becomes easier.

@werererer
Copy link
Author

werererer commented Oct 12, 2025

Hm, I can't get every checks to pass, I don't think this PR changes are at fault based on reviewing the logs. If it is pls send me back to draft.

I tested the code and it works reliably on my computer.

Its now officially open for review now, not a Draft anymore.

@werererer werererer marked this pull request as ready for review October 12, 2025 18:43
@dosubot dosubot bot added the size:XL This PR changes 500-999 lines, ignoring generated files. label Oct 12, 2025
@werererer werererer changed the title Draft: feat(search): add create into inbox to search feat(search): add create into inbox to search Oct 12, 2025
@werererer
Copy link
Author

werererer commented Oct 12, 2025

@eliandoran
image

for the code-review it is especially interesting if it was okay to edit these 2 files mention_customization and augmentation.ts (See picture). Through git blame i found your name there and concluded custome code there would be okay. Maybe there are other ways to fix what I did here, but fixing without editing these files would be a bit more convoluted.

@contributor
Copy link
Contributor

contributor commented Oct 12, 2025

for the code-review it is especially interesting if it was okay to edit these 2 files mention_customization and augmentation.ts

  • MentionAction placement in packages/ckeditor5/src/augmentation.ts looks off to me, it rather belongs to something like packages/commons
  • Also no need to make srtrings enum, just plain enum
  • The name NoteCreateAction better explains the type. The fact that we can create notes via mentions as well, should not be encoded in the type name.

I pushed commit 80afdaf with the changes to review (branch)

If @eliandoran is ok with that commit, please cherry pick it, or I can add it to your PR if it allows edits from maintainers.

@werererer
Copy link
Author

@contributor Thanks for the additional review. And Improvement
Your changes make sense. Let's wait for feedback from Elian. I will cherrypick your changes if he gives me the okay here.

Feel free to play around with things that don't align with standards I am not so much aware of to speed up the process.

marker: string;
text?: string;
range?: ModelRange;
mention: string | {
Copy link
Contributor

@contributor contributor Oct 12, 2025

Choose a reason for hiding this comment

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

This file already had mix of tab spaces on different lines. Now it has mix on the same lines too.

I see that all original files from ckeditor uses tabs (for easier sync with upstream maybe?). But this is not enforced on ci or editorconfig rules.

@eliandoran
Let's decide what to use for this file in the PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

It's fine to ignore the whitespace changes for now. I suppose they are a left over from when we merged the CKEditor customization into the monorepo.

@werererer
Copy link
Author

werererer commented Oct 17, 2025

Okay, I will revert to draft.
The following things I will fix before reopening for further review:

  • @contributor Cherrypicking your changes already. To reduce review workload by removing ambiguity of planned action.
    contributor@80afdaf
  • Remove some translations that cause merge issues. The solution was discussed in Matrix:
Matrix solution image image

@werererer werererer marked this pull request as draft October 17, 2025 16:55
@werererer
Copy link
Author

werererer commented Oct 18, 2025

@contributor The Commit contributor@80afdaf didn't work yet. In my case it generated the following error:

Error Message { "message": "unexpected-error\nRead more: https://ckeditor.com/docs/ckeditor5/latest/support/error-codes.html#error-unexpected-error\nOriginal error: ReferenceError: CreateNoteAction is not defined", "stack": "ReferenceError: CreateNoteAction is not defined\n at CustomMentionCommand.execute (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/Trilium/packages/ckeditor5/src/plugins/mention_customization.ts:32:35)\n at CustomMentionCommand. (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/Trilium/.cache/vite/deps/chunk-D46A7232.js?v=23194951:7728:37)\n at CustomMentionCommand.fire (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/Trilium/.cache/vite/deps/chunk-D46A7232.js?v=23194951:7413:16)\n at [as execute] (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/Trilium/.cache/vite/deps/chunk-D46A7232.js?v=23194951:7731:21)\n at CommandCollection.execute (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/Trilium/.cache/vite/deps/chunk-D46A7232.js?v=23194951:44674:20)\n at ClassicEditor.execute (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/Trilium/.cache/vite/deps/chunk-D46A7232.js?v=23194951:46394:28)\n at MentionsView. (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/Trilium/.cache/vite/deps/ckeditor5.js?v=23194951:38746:14)\n at MentionsView.fire (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/Trilium/.cache/vite/deps/chunk-D46A7232.js?v=23194951:7413:16)\n at MentionListItemView. (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/Trilium/.cache/vite/deps/ckeditor5.js?v=23194951:38729:22)\n at MentionListItemView.fire (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/Trilium/.cache/vite/deps/chunk-D46A7232.js?v=23194951:7413:16)", "filename": "http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/Trilium/.cache/vite/deps/chunk-D46A7232.js?v=23194951", "lineno": 7279, "colno": 11, "date": 1760748587043 }, { "message": "unexpected-error\nRead more: https://ckeditor.com/docs/ckeditor5/latest/support/error-codes.html#error-unexpected-error\nOriginal error: ReferenceError: CreateNoteAction is not defined", "stack": "ReferenceError: CreateNoteAction is not defined\n at CustomMentionCommand.execute (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/Trilium/packages/ckeditor5/src/plugins/mention_customization.ts:32:35)\n at CustomMentionCommand. (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/Trilium/.cache/vite/deps/chunk-D46A7232.js?v=23194951:7728:37)\n at CustomMentionCommand.fire (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/Trilium/.cache/vite/deps/chunk-D46A7232.js?v=23194951:7413:16)\n at [as execute] (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/Trilium/.cache/vite/deps/chunk-D46A7232.js?v=23194951:7731:21)\n at CommandCollection.execute (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/Trilium/.cache/vite/deps/chunk-D46A7232.js?v=23194951:44674:20)\n at ClassicEditor.execute (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/Trilium/.cache/vite/deps/chunk-D46A7232.js?v=23194951:46394:28)\n at MentionsView. (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/Trilium/.cache/vite/deps/ckeditor5.js?v=23194951:38746:14)\n at MentionsView.fire (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/Trilium/.cache/vite/deps/chunk-D46A7232.js?v=23194951:7413:16)\n at MentionListItemView. (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/Trilium/.cache/vite/deps/ckeditor5.js?v=23194951:38729:22)\n at MentionListItemView.fire (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/Trilium/.cache/vite/deps/chunk-D46A7232.js?v=23194951:7413:16)", "filename": "http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/Trilium/.cache/vite/deps/chunk-D46A7232.js?v=23194951", "lineno": 7279, "colno": 11, "date": 1760748592273 }, { "message": "unexpected-error\nRead more: https://ckeditor.com/docs/ckeditor5/latest/support/error-codes.html#error-unexpected-error\nOriginal error: ReferenceError: CreateNoteAction is not defined", "stack": "ReferenceError: CreateNoteAction is not defined\n at CustomMentionCommand.execute (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/Trilium/packages/ckeditor5/src/plugins/mention_customization.ts:32:35)\n at CustomMentionCommand. (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/Trilium/.cache/vite/deps/chunk-D46A7232.js?v=23194951:7728:37)\n at CustomMentionCommand.fire (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/Trilium/.cache/vite/deps/chunk-D46A7232.js?v=23194951:7413:16)\n at [as execute] (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/Trilium/.cache/vite/deps/chunk-D46A7232.js?v=23194951:7731:21)\n at CommandCollection.execute (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/Trilium/.cache/vite/deps/chunk-D46A7232.js?v=23194951:44674:20)\n at ClassicEditor.execute (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/Trilium/.cache/vite/deps/chunk-D46A7232.js?v=23194951:46394:28)\n at MentionsView. (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/Trilium/.cache/vite/deps/ckeditor5.js?v=23194951:38746:14)\n at MentionsView.fire (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/Trilium/.cache/vite/deps/chunk-D46A7232.js?v=23194951:7413:16)\n at MentionListItemView. (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/Trilium/.cache/vite/deps/ckeditor5.js?v=23194951:38729:22)\n at MentionListItemView.fire (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/Trilium/.cache/vite/deps/chunk-D46A7232.js?v=23194951:7413:16)", "filename": "http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/Trilium/.cache/vite/deps/chunk-D46A7232.js?v=23194951", "lineno": 7279, "colno": 11, "date": 1760748599023 } ] Stack: Error

What needs to be fixed
Please test the code on your own branch again and fix upcoming issues. I can only cherry pick if the feature still works after refactor. To check it works I test the code by running it.

I usually test trilium by pnpm run desktop:start or pnpm run server:start and literarly testing the intended feature, and trying to break it. Only afterward the feature works as intended i Compile it using pnpm run --filter desktop electron-forge:make --arch=x64 --platform=win32. You can ofc use linux instead of win32 if you have that instead. If it broke, then the mistake is either my mistake, or I test in a new test branch the code without my commit, then its the other persons fault (maybe this is why its called "git blame" lol)

Irrelvant extra details

While I love the code review, reviewing Code that isn't running properly yet is time consuming, as broken code always has weird glitches that need thinking investment in the code changes. So asking for cherry pick of a commit not tested yet, asks for more investment than glancing, which sometimes can be quite uncomfortable, as then the communication get ambiguous. What to do if it doesn't work? criticize creating bad impression? fix it yourself? reject?

How could it be fixed?
For this commit, while the naming is good, I would prefer not changing the build system for ckeditor, just for it to be able to import from trilium the same enum. As it might affect futur compatibility with upstream (trying to not diverge too much here).

previously one way I had to solved it is that i would let ckeditor define a subset of that enum that refers to a string, and then let have trilium refer to the same string.

I can fix the issue, but I am not 100% sure what you have planned, therefore would appreciate it, if you could fix it to preserve intent. I cherry pick afterwards

Conclusion
I can continue the PR if the ambiguity is resolved, by either the code fixed in logic or rejecting this commit 1 only taking over its central ideas. I prefer the first choice and will push for it, as it reduces duplication of work thus time commitment.

Therefore:

  • Wait on tested commit.
  • Then cherrypick it.

Status: DONE

Footnotes

  1. https://github.com/contributor/trilium/commit/80afdaf8ba835b3639c721309e3f158e1949d13e

@contributor
Copy link
Contributor

@werererer

The Commit contributor@80afdaf didn't work yet. In my case it generated the following error

I built, ran and tested the commit week ago before offering it.
I just double-checked my branch and confirmed that it works and can create both child and inbox note:

image

git log of the branch the branch https://github.com/contributor/trilium/tree/search-to-inbox:

80afdaf8b 2025-10-12     contributor     rename MentionAction to CreateNoteAction and move to packages/common
794060d8e 2025-10-12     Jakob Schlanstedt       refactor(ECMAScript Modules jsimport convention): refactor newly created imports to js convention
a254e96a3 2025-10-12     Jakob Schlanstedt       refactor(note-create): change order of noteCreate intoPath and intoInbox to improve code compatibility
fbb4ab6ae 2025-10-12     Jakob Schlanstedt       feat(search): add create into inbox to search
4a0afe68e 2025-10-12     Elian Doran     fix(desktop): alignment of window overlay on vertical layout (closes #7257)

I use the same command to build and run.

Probably you miss something during cherry pick. Can you build and run my branch?

@contributor
Copy link
Contributor

contributor commented Oct 18, 2025

I just tried the commit over current state of the PR - and it cherry picks cleanly, and the app is running perfectly as well

git cherry-pick 80afdaf8b 
[search-into-inbox-new acd8307d6] rename MentionAction to CreateNoteAction and move to packages/common
 Date: Sun Oct 12 23:06:53 2025 +0300
 8 files changed, 36 insertions(+), 35 deletions(-)
 create mode 100644 packages/commons/src/lib/create_note_actions.ts
git lgf
acd8307d6 2025-10-12     contributor     rename MentionAction to CreateNoteAction and move to packages/common
bc87aae68 2025-10-18     Jakob Schlanstedt       (refactor): Revert non-English translation files to resolve merge issues
794060d8e 2025-10-12     Jakob Schlanstedt       refactor(ECMAScript Modules jsimport convention): refactor newly created imports to js convention
a254e96a3 2025-10-12     Jakob Schlanstedt       refactor(note-create): change order of noteCreate intoPath and intoInbox to improve code compatibility
fbb4ab6ae 2025-10-12     Jakob Schlanstedt       feat(search): add create into inbox to search
4a0afe68e 2025-10-12     Elian Doran     fix(desktop): alignment of window overlay on vertical layout (closes #7257)

The branch is here: https://github.com/contributor/trilium/tree/search-into-inbox-new

@werererer

This comment was marked as outdated.

@werererer
Copy link
Author

werererer commented Oct 18, 2025

@contributor Actually sorry for my fast generalization: funnily I only tested what you didn't test. Thus miscommunication lol.

not working:
(tested on your branch): using @ to create a note. Reason: That part runs under a different part of the application specifically over the ckeditor part Which I had to modify for it to work.

image

@werererer
Copy link
Author

werererer commented Oct 18, 2025

@contributor Trace & Log

Stack Trace 200 GET /api/notes/RGCyxYx1gtqE/blob with 348 bytes took 0ms JS Error: Uncaught error: Message: Uncaught CKEditorError: unexpected-error Read more: https://ckeditor.com/docs/ckeditor5/latest/support/error-codes.html#error-unexpected-error Original error: ReferenceError: CreateNoteAction is not defined, URL: http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/contributor/trilium/.cache/vite/deps/chunk-D46A7232.js?v=f45fe61b, Line: 7279, Column: 11, Error object: TypeError: Converting circular structure to JSON --> starting at object with constructor 'ClassicEditor' | property 'accessibility' -> object with constructor 'Accessibility' --- property '_editor' closes the circle, Stack: ReferenceError: CreateNoteAction is not defined at CustomMentionCommand.execute (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/contributor/trilium/packages/ckeditor5/src/plugins/mention_customization.ts:32:35) at CustomMentionCommand. (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/contributor/trilium/.cache/vite/deps/chunk-D46A7232.js?v=f45fe61b:7728:37) at CustomMentionCommand.fire (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/contributor/trilium/.cache/vite/deps/chunk-D46A7232.js?v=f45fe61b:7413:16) at [as execute] (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/contributor/trilium/.cache/vite/deps/chunk-D46A7232.js?v=f45fe61b:7731:21) at CommandCollection.execute (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/contributor/trilium/.cache/vite/deps/chunk-D46A7232.js?v=f45fe61b:44674:20) at ClassicEditor.execute (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/contributor/trilium/.cache/vite/deps/chunk-D46A7232.js?v=f45fe61b:46394:28) at MentionsView. (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/contributor/trilium/.cache/vite/deps/ckeditor5.js?v=e341837d:38746:14) at MentionsView.fire (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/contributor/trilium/.cache/vite/deps/chunk-D46A7232.js?v=f45fe61b:7413:16) at MentionListItemView. (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/contributor/trilium/.cache/vite/deps/ckeditor5.js?v=e341837d:38729:22) at MentionListItemView.fire (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/contributor/trilium/.cache/vite/deps/chunk-D46A7232.js?v=f45fe61b:7413:16) Stack: Error at Object.logError (http://127.0.0.1:37742/assets/v0.99.1/src/services/ws.ts:22:14) at window.onerror (http://127.0.0.1:37742/assets/v0.99.1/src/services/glob.ts:33:8) JS Info: CKEditor state changed to crashed JS Error: CKEditor crash logs: [ { "message": "unexpected-error\nRead more: https://ckeditor.com/docs/ckeditor5/latest/support/error-codes.html#error-unexpected-error\nOriginal error: ReferenceError: CreateNoteAction is not defined", "stack": "ReferenceError: CreateNoteAction is not defined\n at CustomMentionCommand.execute (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/contributor/trilium/packages/ckeditor5/src/plugins/mention_customization.ts:32:35)\n at CustomMentionCommand. (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/contributor/trilium/.cache/vite/deps/chunk-D46A7232.js?v=f45fe61b:7728:37)\n at CustomMentionCommand.fire (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/contributor/trilium/.cache/vite/deps/chunk-D46A7232.js?v=f45fe61b:7413:16)\n at [as execute] (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/contributor/trilium/.cache/vite/deps/chunk-D46A7232.js?v=f45fe61b:7731:21)\n at CommandCollection.execute (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/contributor/trilium/.cache/vite/deps/chunk-D46A7232.js?v=f45fe61b:44674:20)\n at ClassicEditor.execute (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/contributor/trilium/.cache/vite/deps/chunk-D46A7232.js?v=f45fe61b:46394:28)\n at MentionsView. (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/contributor/trilium/.cache/vite/deps/ckeditor5.js?v=e341837d:38746:14)\n at MentionsView.fire (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/contributor/trilium/.cache/vite/deps/chunk-D46A7232.js?v=f45fe61b:7413:16)\n at MentionListItemView. (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/contributor/trilium/.cache/vite/deps/ckeditor5.js?v=e341837d:38729:22)\n at MentionListItemView.fire (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/contributor/trilium/.cache/vite/deps/chunk-D46A7232.js?v=f45fe61b:7413:16)", "filename": "http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/contributor/trilium/.cache/vite/deps/chunk-D46A7232.js?v=f45fe61b", "lineno": 7279, "colno": 11, "date": 1760782443406 } ] Stack: Error at logError (http://127.0.0.1:37742/assets/v0.99.1/src/services/ws.ts:22:14) at EditorWatchdog. (http://127.0.0.1:37742/assets/v0.99.1/src/widgets/type_widgets/editable_text.ts:119:7) at EditorWatchdog._fire (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/contributor/trilium/.cache/vite/deps/chunk-D46A7232.js?v=f45fe61b:42864:16) at EditorWatchdog._handleError (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/contributor/trilium/.cache/vite/deps/chunk-D46A7232.js?v=f45fe61b:42902:12) at Watchdog._boundErrorHandler (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/contributor/trilium/.cache/vite/deps/chunk-D46A7232.js?v=f45fe61b:42815:14) JS Info: CKEditor state changed to initializing JS Info: Creating new CKEditor 200 GET /api/search/%23textSnippet with 2 bytes took 1ms JS Info: CKEditor state changed to ready 204 PUT /api/notes/RGCyxYx1gtqE/data with 0 bytes took 4ms 200 GET /api/notes/RGCyxYx1gtqE/blob with 163 bytes took 1ms 200 GET /api/autocomplete?query=&activeNoteId=RGCyxYx1gtqE&fastSearch=true with 143 bytes took 1ms Slow 200 GET /api/autocomplete?query=jdkfls&activeNoteId=RGCyxYx1gtqE&fastSearch=true with 2 bytes took 12ms 204 PUT /api/notes/RGCyxYx1gtqE/data with 0 bytes took 7ms 200 GET /api/notes/RGCyxYx1gtqE/blob with 170 bytes took 0ms JS Error: Uncaught error: Message: Uncaught CKEditorError: unexpected-error Read more: https://ckeditor.com/docs/ckeditor5/latest/support/error-codes.html#error-unexpected-error Original error: ReferenceError: CreateNoteAction is not defined, URL: http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/contributor/trilium/.cache/vite/deps/chunk-D46A7232.js?v=f45fe61b, Line: 7279, Column: 11, Error object: TypeError: Converting circular structure to JSON --> starting at object with constructor 'ClassicEditor' | property 'accessibility' -> object with constructor 'Accessibility' --- property '_editor' closes the circle, Stack: ReferenceError: CreateNoteAction is not defined at CustomMentionCommand.execute (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/contributor/trilium/packages/ckeditor5/src/plugins/mention_customization.ts:32:35) at CustomMentionCommand. (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/contributor/trilium/.cache/vite/deps/chunk-D46A7232.js?v=f45fe61b:7728:37) at CustomMentionCommand.fire (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/contributor/trilium/.cache/vite/deps/chunk-D46A7232.js?v=f45fe61b:7413:16) at [as execute] (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/contributor/trilium/.cache/vite/deps/chunk-D46A7232.js?v=f45fe61b:7731:21) at CommandCollection.execute (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/contributor/trilium/.cache/vite/deps/chunk-D46A7232.js?v=f45fe61b:44674:20) at ClassicEditor.execute (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/contributor/trilium/.cache/vite/deps/chunk-D46A7232.js?v=f45fe61b:46394:28) at MentionsView. (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/contributor/trilium/.cache/vite/deps/ckeditor5.js?v=e341837d:38746:14) at MentionsView.fire (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/contributor/trilium/.cache/vite/deps/chunk-D46A7232.js?v=f45fe61b:7413:16) at MentionListItemView. (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/contributor/trilium/.cache/vite/deps/ckeditor5.js?v=e341837d:38729:22) at MentionListItemView.fire (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/contributor/trilium/.cache/vite/deps/chunk-D46A7232.js?v=f45fe61b:7413:16) Stack: Error at Object.logError (http://127.0.0.1:37742/assets/v0.99.1/src/services/ws.ts:22:14) at window.onerror (http://127.0.0.1:37742/assets/v0.99.1/src/services/glob.ts:33:8) JS Info: CKEditor state changed to crashed JS Error: CKEditor crash logs: [ { "message": "unexpected-error\nRead more: https://ckeditor.com/docs/ckeditor5/latest/support/error-codes.html#error-unexpected-error\nOriginal error: ReferenceError: CreateNoteAction is not defined", "stack": "ReferenceError: CreateNoteAction is not defined\n at CustomMentionCommand.execute (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/contributor/trilium/packages/ckeditor5/src/plugins/mention_customization.ts:32:35)\n at CustomMentionCommand. (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/contributor/trilium/.cache/vite/deps/chunk-D46A7232.js?v=f45fe61b:7728:37)\n at CustomMentionCommand.fire (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/contributor/trilium/.cache/vite/deps/chunk-D46A7232.js?v=f45fe61b:7413:16)\n at [as execute] (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/contributor/trilium/.cache/vite/deps/chunk-D46A7232.js?v=f45fe61b:7731:21)\n at CommandCollection.execute (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/contributor/trilium/.cache/vite/deps/chunk-D46A7232.js?v=f45fe61b:44674:20)\n at ClassicEditor.execute (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/contributor/trilium/.cache/vite/deps/chunk-D46A7232.js?v=f45fe61b:46394:28)\n at MentionsView. (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/contributor/trilium/.cache/vite/deps/ckeditor5.js?v=e341837d:38746:14)\n at MentionsView.fire (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/contributor/trilium/.cache/vite/deps/chunk-D46A7232.js?v=f45fe61b:7413:16)\n at MentionListItemView. (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/contributor/trilium/.cache/vite/deps/ckeditor5.js?v=e341837d:38729:22)\n at MentionListItemView.fire (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/contributor/trilium/.cache/vite/deps/chunk-D46A7232.js?v=f45fe61b:7413:16)", "filename": "http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/contributor/trilium/.cache/vite/deps/chunk-D46A7232.js?v=f45fe61b", "lineno": 7279, "colno": 11, "date": 1760782443406 }, { "message": "unexpected-error\nRead more: https://ckeditor.com/docs/ckeditor5/latest/support/error-codes.html#error-unexpected-error\nOriginal error: ReferenceError: CreateNoteAction is not defined", "stack": "ReferenceError: CreateNoteAction is not defined\n at CustomMentionCommand.execute (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/contributor/trilium/packages/ckeditor5/src/plugins/mention_customization.ts:32:35)\n at CustomMentionCommand. (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/contributor/trilium/.cache/vite/deps/chunk-D46A7232.js?v=f45fe61b:7728:37)\n at CustomMentionCommand.fire (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/contributor/trilium/.cache/vite/deps/chunk-D46A7232.js?v=f45fe61b:7413:16)\n at [as execute] (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/contributor/trilium/.cache/vite/deps/chunk-D46A7232.js?v=f45fe61b:7731:21)\n at CommandCollection.execute (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/contributor/trilium/.cache/vite/deps/chunk-D46A7232.js?v=f45fe61b:44674:20)\n at ClassicEditor.execute (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/contributor/trilium/.cache/vite/deps/chunk-D46A7232.js?v=f45fe61b:46394:28)\n at MentionsView. (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/contributor/trilium/.cache/vite/deps/ckeditor5.js?v=e341837d:38746:14)\n at MentionsView.fire (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/contributor/trilium/.cache/vite/deps/chunk-D46A7232.js?v=f45fe61b:7413:16)\n at MentionListItemView. (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/contributor/trilium/.cache/vite/deps/ckeditor5.js?v=e341837d:38729:22)\n at MentionListItemView.fire (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/contributor/trilium/.cache/vite/deps/chunk-D46A7232.js?v=f45fe61b:7413:16)", "filename": "http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/contributor/trilium/.cache/vite/deps/chunk-D46A7232.js?v=f45fe61b", "lineno": 7279, "colno": 11, "date": 1760782448777 } ] Stack: Error at logError (http://127.0.0.1:37742/assets/v0.99.1/src/services/ws.ts:22:14) at EditorWatchdog. (http://127.0.0.1:37742/assets/v0.99.1/src/widgets/type_widgets/editable_text.ts:119:7) at EditorWatchdog._fire (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/contributor/trilium/.cache/vite/deps/chunk-D46A7232.js?v=f45fe61b:42864:16) at EditorWatchdog._handleError (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/contributor/trilium/.cache/vite/deps/chunk-D46A7232.js?v=f45fe61b:42902:12) at Watchdog._boundErrorHandler (http://127.0.0.1:37742/assets/v0.99.1/@fs/home/jakob/git/contributor/trilium/.cache/vite/deps/chunk-D46A7232.js?v=f45fe61b:42815:14) JS Info: CKEditor state changed to initializing JS Info: Creating new CKEditor
git log commit 80afdaf (HEAD -> search-to-inbox, origin/search-to-inbox) Author: contributor Date: Sun Oct 12 23:06:53 2025 +0300
rename MentionAction to CreateNoteAction and move to packages/common

commit 794060d
Author: Jakob Schlanstedt [email protected]
Date: Sun Oct 12 19:03:56 2025 +0200

refactor(ECMAScript Modules jsimport convention): refactor newly created imports to js convention

https://nodejs.org/api/esm.html#import-specifiers

commit a254e96
Author: Jakob Schlanstedt [email protected]
Date: Sun Oct 12 18:54:39 2025 +0200

refactor(note-create): change order of noteCreate intoPath and intoInbox to improve code compatibility

commit fbb4ab6
Author: Jakob Schlanstedt [email protected]
Date: Sun Oct 12 06:31:48 2025 +0200

feat(search): add create into inbox to search

@werererer
Copy link
Author

werererer commented Oct 18, 2025

@contributor Everything else works as expected.

@contributor
Copy link
Contributor

@werererer I see the problem with creating a note via mentions. Looking into this

@werererer
Copy link
Author

werererer commented Oct 23, 2025

CreateNoteIntoInboxURLOpts (still a misnomer) should be a child of CreateNoteOpts, because CreateNoteAtUrlOpts describes a fixed URL input,

To me, CreateNoteIntoInboxURLOpts is still conceptually is closer to CreateNoteAtUrlOpts than to CreateNoteOpts. It serves the same purpose - to create a note in some location. It is just happen that on current stage we do not need to pass that location. But I can imagine scenario where location must be passed (like multiple inboxes, even now trilium has workspaceInbox attribute).

As for URL vs Url - I don't like both. I did named it CreateNoteLocationOpts (still present in a comment) but then renamed back to URL to keep the same API

@contributor
Actually I do not care about what it means for whom, but more about what the code already had specified before us, so that we only need to choose very good terms fitting the underlying logic, that was already given before we centralized anything. So we need to remodel their thinking to reduce the amount of logical changes as far as possible. So I am all about you chosing better terms, or remodeling the hierarchy to the logic of the code that was there before. The type check checks out the resulting application of logic anyways.

However I believe the problem here is that we can't communicate because there may be a missmatch in mental model thinking about this problem. I am thinking exactly like the porphyrian tree, the concept should be able to be understood in around 5 minutes. I don't know if you can understand my reasoning in code without it:

This is the best resource I used to learn about it: its basically theory about how to create types for this usecase:
https://faculty.washington.edu/smcohen/433/PorphyryTree.html

@contributor
Copy link
Contributor

contributor commented Oct 23, 2025

I still believe that original flatten structure (CreateNoteIntoInboxOpts is CreateNoteAtUrlOpts, and not CreateNoteOpts) is better and more type safe model.

Current state (allows assigning invalid values):

export type CreateNoteIntoInboxOpts = CreateNoteOpts;

const t: CreateNoteIntoInboxOpts = {
    target: CreateNoteTarget.IntoInbox
}
t.target = CreateNoteTarget.IntoNoteURL; // make no sense, but type system allows it

Originally (prevents assigning invalid values):

export type CreateNoteIntoInboxOpts = Extract<CreateNoteAtUrlOpts, { target: CreateNoteTarget.IntoInbox }>;

const t: CreateNoteIntoInboxOpts = {
    target: CreateNoteTarget.IntoInbox
}
t.target = CreateNoteTarget.IntoNoteURL; // error: Type 'CreateNoteTarget.IntoNoteURL' is not assignable to type 'CreateNoteTarget.IntoInbox'

@werererer
Copy link
Author

werererer commented Oct 23, 2025

@contributor Actually if you make the type check work! I will prob agree. That we have a semantic missmatch of understanding where which type belongs because of differences in understanding these concepts described by the types is not a problem for me!

So just make it work! I will update my own semantic understanding afterwards

@werererer
Copy link
Author

werererer commented Oct 23, 2025

@contributor if type check makes no error and even if I feel a semantic Missmatch I will cherry pick anyways and continue towards reopening review after usual testing. Because names are just syntax which I dont care much about in this case.

Later in review elian can decide the rest of open questions (that are given way above) so that we can finish this work.

Therefore:

  • If type check doesn't complain given any implementation, then continue to review.

@werererer
Copy link
Author

werererer commented Oct 28, 2025

@contributor Thanks to your input including correction suggestion, I simplified the type system, by removing layers. Another Reason is YAGNI1. Other parts of the code where also simplified, some names where improved.

Unfortunately I couldn't take your code suggestion as it created type errors which where not easily resolvable.

If you agree now with the new code, I will rebase onto the newest version and test again for bugs. If you do not: point out where, it will be improved.

To revert this decision the code I force pushed away is now here:
https://github.com/werererer/Trilium/tree/search-to-inbox-final-prototype-1

Footnotes

  1. https://de.wikipedia.org/wiki/YAGNI

@contributor
Copy link
Contributor

@contributor Thanks to your input including correction suggestion, I simplified the type system, by removing layers. Another Reason is YAGNI1. Other parts of the code where also simplified, some names where improved.

@werererer Looks simpler and much better now, good job! I like how createNote facade function is the only function that is exported.

We could avoid upcasting in createNote(options: CreateNoteOpts) of options param to other types and get rid of NeverDefineParentNoteUrlRule this way:
contributor@ca495e1

@werererer
Copy link
Author

werererer commented Oct 29, 2025

@contributor okay, i integrated your fix.

Actually the commit improved type checking and uncovered small logical errors in the code! caught by pnpm typecheck (proving that type safety really can eliminate real bugs).

If you are okay with the current state of code (without open questions resolved yet), then Pls explicitly give me an okay to move on to the next steps (resolving open questions) to improve PR merge efficiency. Else pls provide more criticism: I will addressed them.

Copy link
Contributor

@contributor contributor left a comment

Choose a reason for hiding this comment

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

@werererer there's likely a bug with creating ai chat note

@werererer
Copy link
Author

werererer commented Oct 30, 2025

https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#type-assertions:~:text=compile%2dtime

type-casting with AS removes typechecking, invalidating typechecking at compile time leading to its feature to remove obvious bugs deleted.

I removed all as casts from the commits.

@werererer
Copy link
Author

werererer commented Oct 31, 2025

@contributor I tested everything churned away through some more bugs. I can't find any more bugs. However I did not test the AI feature, because I am not familiar with it, maybe if you know better it would be great to get that tested as well.

if it fails the most likely culprit would be a change in behavior between the original create_note and the one we have right now.

The failing unit tests do not seem relevant to the code.

If it looks alright I will continue to request review from elian (after some more tests and rebase). If not, pls tell where we need what fix.

@contributor
Copy link
Contributor

contributor commented Oct 31, 2025

However I did not test the AI feature, because I am not familiar with it, maybe if you know better it would be great to get that tested as well.

@werererer I don't know it either. I migrated from Trilium Classic month ago, still have to try new features.

Quick AI test in release show that it can create notes, but seems only in root (or maybe I prompted not good enough lol)
image

Tool: create_note
{
  "success": true,
  "noteId": "NW7NRKuXyUYA",
  "title": "New Inbox Note",
  "type": "text",
  "message": "Note \"New Inbox Note\" created successfully"
}

Update: build for PR does the same. Creates a note in root. This aligns to code that hard code root path So this part seems work as intended

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

Labels

size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants