Skip to content

Conversation

@contributor
Copy link
Contributor

@contributor contributor commented Oct 23, 2025

This adds menu item "Open note on server" to note's three dot menu for desktop app

The main use case for this new item is to open a note for reference in your browser (you can also optionally turn zen mode on), while keep working in electron app with other notes and prevent accidental replacing the reference note with another note (which is very likely to happen unless you only use Ctrl+Click in the tree) ,

image

The menu item “Open note on server” is only visible in electron app and if you have sync server configured. It goes as last item in its group on purpose - to keep existing items in original order and keep order in the group consistent between web and electron versions.

@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Oct 23, 2025
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @contributor, 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 introduces a valuable new feature to the desktop application, providing users with the ability to open any note directly in a web browser via their configured sync server. This enhancement aims to improve workflow efficiency by allowing users to maintain a reference note in an external browser without disrupting their active work within the Electron application, thereby offering greater flexibility and reducing the likelihood of unintended edits or navigation.

Highlights

  • New Menu Item: A new menu item, 'Open note on server', has been added to the three-dot menu for notes within the desktop application.
  • Functionality: This new option allows users to open the currently active note directly in a web browser, leveraging the configured sync server URL.
  • Conditional Visibility: The 'Open note on server' menu item is only visible and available when the application is running in the Electron desktop environment and a sync server has been configured.
  • Workflow Enhancement: The primary use case is to enable users to reference a note in a separate browser window (with optional zen mode) while continuing to work on other notes in the Electron app, preventing accidental note replacements.
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 new 'Open note on server' menu item, which is a useful feature for users who want to reference a note in their browser while working in the desktop application. The implementation is well-executed across the frontend and services. The new command, its executor, and the UI changes are all clear and follow existing patterns. The feature is also correctly made available only when a sync server is configured and the app is running in Electron.

I have one minor suggestion to improve code clarity by removing a redundant property in the React component. Overall, this is a solid contribution.

<CommandItem command="openNoteCustom" icon="bx bx-customize" disabled={isSearchOrBook || isMac || !isElectron} text={t("note_actions.open_note_custom")} />
<CommandItem command="showNoteSource" icon="bx bx-code" disabled={!hasSource} text={t("note_actions.note_source")} />
{(syncServerHost && isElectron) &&
<CommandItem command="openNoteOnServer" icon="bx bx-world" disabled={!syncServerHost} text={t("note_actions.open_note_on_server")} />
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The disabled={!syncServerHost} prop is redundant here. The CommandItem is only rendered if syncServerHost is truthy due to the conditional rendering on line 87. In that case, !syncServerHost will always evaluate to false. You can remove this prop for cleaner and more maintainable code.

Suggested change
<CommandItem command="openNoteOnServer" icon="bx bx-world" disabled={!syncServerHost} text={t("note_actions.open_note_on_server")} />
<CommandItem command="openNoteOnServer" icon="bx bx-world" text={t("note_actions.open_note_on_server")} />

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@gemini-code-assist it is redundant, but I would still keep disabled attribute to be replaced with potential another check - for notes that cannot be opened on server. I haven't identified if there are such notes - notes like Options and User Guide are still openable.

Copy link
Contributor

Choose a reason for hiding this comment

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

I understand your intention to keep the disabled attribute for potential future checks. However, the current disabled={!syncServerHost} is still redundant.

Here's why:

  • The CommandItem on line 88 is only rendered if syncServerHost is truthy (due to (syncServerHost && isElectron) on line 87).
  • If syncServerHost is truthy, then !syncServerHost will always evaluate to false.
  • Therefore, the disabled prop will effectively always be disabled={false} when this CommandItem is visible.

If you plan to add more complex disabling logic in the future (e.g., based on the note type), you would modify this disabled prop anyway. Removing the currently redundant disabled={!syncServerHost} now would simplify the code without hindering future enhancements, as you'd be adding the new logic to a clean slate. The current disabled={!syncServerHost} doesn't serve as a useful placeholder for future, more complex disabling conditions.

Suggested change
<CommandItem command="openNoteOnServer" icon="bx bx-world" disabled={!syncServerHost} text={t("note_actions.open_note_on_server")} />
<CommandItem command="openNoteOnServer" icon="bx bx-world" text={t("note_actions.open_note_on_server")} />

Copy link

@werererer werererer Oct 24, 2025

Choose a reason for hiding this comment

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

@contributor I'd go here with gemini, had the same argument in my head. I can't imagine why the server shouldn't support a note type that is supported on desktop that would be instantly a Bug.

Copy link
Contributor Author

@contributor contributor Oct 24, 2025

Choose a reason for hiding this comment

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

For example, folder view - a note that shows content of a local folder. You are likely won't have such note on server due to security reason and file system path differences.

Choose a reason for hiding this comment

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

@contributor I think even syncing up a potential folder view would be beneficial and it then would just open with error, it is only configured for X, Y, Z. Because the structure reminds the user oh wait I might have to open it up on my Computer.

Copy link

@werererer werererer Oct 24, 2025

Choose a reason for hiding this comment

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

@contributor however I might see an edge case where you'd be right. Assume you upload images that you dont want to be shared on your trilium server instance. Then not having them synced up, maybe if there would be an option to hide this from the server, that would be beneficial, making the approach ofc worth keep having.

I would think this would resolve the comments then.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, local only (not synced) notes too. Evernote had it 15+ years ago. And if you don't trust the trilium sync server - that could be useful feature (even more true if they turn trilium to multi-user server)

@rom1dep
Copy link
Contributor

rom1dep commented Oct 23, 2025

@contributor: That's completely blowing-up the scope of this PR, but I would love to hear your comments on a more generic concept of "Sessions".

  • Sessions would hold a subset of the configuration and client state: appearance and tabs
  • Different devices and form factors could connect to different sessions (e.g. a "work computer" session, a "home" session, and a "mobile" session, …), making sure that the experience and context are ideal for that device (e.g. light theme on the "work computer", dark theme and custom font on the "home" computer, custom mobile theme and short list of tabs on the "mobile" screen…)
  • … or share the same session, so that acting on the appearance or the tabs on one device reflects on/syncs with the other devices having the same session open
  • Any client could switch to any session at any time

This solves several practical aspects

  • the electron client is essentially cut-off from the others (which can be both a good or bad thing)
  • simultaneously using Trilium across multiple devices feels inconsistent (giving the impression of themes and tabs "jumping around")
  • if sessions were to exist, your PR would be about "sending tab to sessions", which is not dissimilar to "sending tab to device" in Firefox (when using Firefox sync)

@contributor
Copy link
Contributor Author

contributor commented Oct 23, 2025

@rom1dep

Sharing sessions between devices is quite advanced use case. I rarely need my desktop full state (as opposed to one or two pages) on mobile or web. Though opening session on another desktop may be useful.

In fact, I use desktop app 99.99% of the time. No one can be productive on phone version. And it is hard to be productive in web version either (conflicting keyboard shortcuts, conflicting navigation between browser and trilium tabs, slower search performance etc).

Though desktop app has its own nuisances. One of them - replacing important tab after clicking in the tree. This PR is work-arround for that. Alternative option is to open new tab on click in the tree (instead of ctrl+click). But that leads straight to another problem - tab management. Currently, you can't see the note titles in tiny tabs if you have more than 5-7 open. Vertical tabs would help a bit with that. Vertical tabs like Firefox's Tree Style Tree would definitely fix that.

Using multiple windows in desktop desktop (with different workspaces) also don't go smoothly - keyboard shortcut opens search in first window, not in current window. No sticky differentiating titles on each window make it harder to switch between them. And others.

So I hope that partial offload to browser via "Open note on server" could help with tab management too.

@werererer
Copy link

werererer commented Oct 24, 2025

@rom1dep your request reminds me about tmux 1. In general I agree about such a feature, however, I do not agree this PR should advance its scope this much, because talking about sessions is a whole new Box, that needs very careful thinking to get it right.

So you should make it a new issue instead

Footnotes

  1. https://stackoverflow.com/questions/48000910/how-can-i-move-a-window-to-another-session-in-tmux

@werererer
Copy link

@contributor

I think the order should be switched Open note on Server should be just below Open note custom. To be more precise I actually i don't care about their exact order, but Open note externally, Open note custom and Open note on server should be grouped.

image
Tips for reviewers faster testing on Linux

Testing more quickly can be done like this on linux. Since the menu cannot been without a sync server this might be the most efficient solution:

pnpm install
TRILIUM_DOCUMENT_PATH=$(realpath ~/.local/share/trilium-data/document.db) pnpm run desktop:start

@contributor
Copy link
Contributor Author

I think the order should be switched Open note on Server should be just below Open note custom. To be more precise I actually i don't care about their exact order, but Open note externally, Open note custom and Open note on server should be grouped.

Why? Because of menu item title? If we name it “View note on server” will there be less temptation for grouping?

Regardless of the name we will use

Here is how menu looks on server:
image

Here is how it looks on desktop without sync server:
image

Here is how it looks on desktop with sync server:
image

This UI is consistent. Menu item "View source" is always third item in the group.

The position of menu item in the PR prevents swapping of “Open note on server” and "View Source" for users that use both web and electron

@werererer
Copy link

@contributor that view also makes sense. I think both ways are okay. So you can do that.

@werererer
Copy link

werererer commented Oct 24, 2025

@contributor if you think its ready, because I dont know if you mean its truely ready, a short notice on matrix towards elian might be useful, to clarify readiness for merge. Because this never went through a draft phase it makes unclear what state it is in right now. The code works as explained.

Else, if not ready, pls convert to draft, to clarify communication.

@contributor
Copy link
Contributor Author

@eliandoran it is ready

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.

3 participants