Skip to content

Conversation

@SiriusXT
Copy link
Member

@SiriusXT SiriusXT commented Dec 29, 2025

  1. Track notes from recently opened windows, so that extra windows can restore their browsing state upon refresh.
  2. Restore recently opened windows from the tray.
图片
  1. Close (Feature request) Restore previous windows and tabs open on startup #3053

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @SiriusXT, 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 multi-window experience by introducing robust state persistence and recovery mechanisms. It ensures that all application windows, especially extra ones, can maintain their open note contexts across sessions and refreshes. Furthermore, it adds a user-friendly feature to restore recently closed windows from the tray, making the application more resilient and convenient for users who frequently work with multiple note windows.

Highlights

  • Multi-Window State Persistence: Extra windows now persistently track their open notes and browsing state, ensuring that their content is restored even after a refresh or application restart.
  • Restore Recently Closed Windows: A new feature allows users to restore recently closed windows directly from the application's tray menu, improving workflow and preventing accidental data loss.
  • Unique Window Identification: Each application window is now assigned a unique windowId, enabling individual state management and tracking for both main and extra windows.
  • Data Structure Update: The openNoteContexts option has been refactored to store a comprehensive list of window states, including windowId, creation/closure timestamps, and their respective note contexts.
  • Database Migration: A new migration script (0234__migrate_open_note_contexts_format.ts) is introduced to seamlessly update existing openNoteContexts data to the new structured format.

🧠 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.

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 great feature for tracking and restoring recently opened notes across multiple windows. The implementation is mostly solid, but I've identified a few critical and high-severity issues that should be addressed before merging. These include a data corruption bug that could lead to circular JSON structures, potential crashes from unsafe array operations, and an HTML validation error. I've provided specific comments and suggestions to fix these problems.

@SiriusXT
Copy link
Member Author

/gemini review

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 mechanism to track and restore recently opened notes across multiple windows. This is achieved by assigning a unique ID to each window and storing its tab context. The changes span across the client and server, including a database schema migration, frontend context management, and backend window tracking. The implementation also adds a "Recently closed windows" feature to the tray menu.

My feedback focuses on improving code robustness and maintainability. I've pointed out a potential bug due to missing logic in one of two duplicated code blocks, suggested extracting magic numbers into constants, and recommended adding error handling for JSON parsing to prevent crashes.

@SiriusXT
Copy link
Member Author

/gemini review

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 great feature for tracking and restoring recently opened windows. The implementation is mostly solid, but there are a few areas that need improvement for robustness and consistency. I've identified potential crashes related to unsafe array operations and JSON parsing, as well as inconsistent logic for managing the number of saved windows. I've also suggested using a more reliable method for generating unique window IDs. Addressing these points will make the feature more stable and maintainable.

@SiriusXT SiriusXT changed the title Feat: Record recently opened notes Feat: Record recently opened windows Dec 29, 2025
@SiriusXT
Copy link
Member Author

/gemini review

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 for recording and restoring recently opened windows, which significantly improves the user experience by preserving browsing states across sessions. The implementation is comprehensive, touching both client and server-side code to manage window states. I've identified a few potential issues concerning null safety and the logic for managing the maximum number of saved windows, which could lead to runtime errors or unintended behavior. My review comments include specific suggestions to rectify these issues. Overall, this is a well-executed feature addition.

@SiriusXT
Copy link
Member Author

/gemini review

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 great feature for tracking and restoring recently opened windows. The implementation is comprehensive, covering state saving for extra windows, UI for restoring from the tray, and a database migration for the new data structure. The changes are well-structured across the client, server, and desktop applications.

My main feedback is regarding some code duplication and inconsistency in apps/client/src/components/tab_manager.ts for saving window state, which I've detailed in a specific comment. Addressing this will improve the maintainability and robustness of the new feature.

Overall, this is a solid contribution that will significantly improve the user experience for multi-window usage.

@SiriusXT SiriusXT marked this pull request as ready for review December 30, 2025 02:58
@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Dec 30, 2025
@SiriusXT SiriusXT marked this pull request as draft December 31, 2025 17:17
@rom1dep
Copy link
Contributor

rom1dep commented Jan 1, 2026

@SiriusXT that's pretty cool!
Out of curiosity, how do you reconcile this with desktop and web clients not sharing their tab state?
Would it make sense to have "Sessions" as an abstraction to build this on top of?

@SiriusXT
Copy link
Member Author

SiriusXT commented Jan 1, 2026

@SiriusXT that's pretty cool! Out of curiosity, how do you reconcile this with desktop and web clients not sharing their tab state? Would it make sense to have "Sessions" as an abstraction to build this on top of?

@rom1dep Desktop and web clients maintain independent tab states. The tabs of the most recent 10 windows are stored in the options table of their respective databases (previously, only the main window’s tabs were stored). On the desktop client, recently closed windows can be restored via the system tray; on the web client, recently closed Trilium windows can be restored using the browser’s built-in tab/window recovery feature.

@SiriusXT
Copy link
Member Author

SiriusXT commented Jan 3, 2026

/gemini review

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 great new feature for tracking and restoring recently opened windows. The implementation is comprehensive, touching both client and server-side code, including a database migration. My review focuses on improving correctness, maintainability, and robustness. I've identified a couple of potential bugs: one in the window state management logic that could affect the eviction of old windows, and another in an event handler that could lead to data loss on window close. I've also pointed out a potential issue with handling URL query parameters and a minor maintainability improvement. Overall, these are solid changes, and with a few adjustments, they will be even better.

@SiriusXT SiriusXT marked this pull request as ready for review January 3, 2026 12:20
@SiriusXT SiriusXT marked this pull request as draft January 4, 2026 06:23
@SiriusXT SiriusXT marked this pull request as ready for review January 4, 2026 07:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

(Feature request) Restore previous windows and tabs open on startup

4 participants