Skip to content

Conversation

@rootz491
Copy link
Contributor

@rootz491 rootz491 commented May 15, 2025

Summary by CodeRabbit

  • New Features

    • Introduced a "Sleep Tab After" setting, allowing users to specify when inactive tabs should be put to sleep (options range from 5 minutes to 24 hours, or never).
    • Tabs that are inactive for the configured duration will now automatically enter sleep mode, helping conserve system resources.
  • Settings

    • Updated the performance settings card to include both tab archiving and sleeping options for improved resource management.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented May 15, 2025

Walkthrough

This update introduces a new "Sleep Tab After" setting, allowing users to specify when inactive tabs should be put to sleep. The TabManager now periodically checks and puts eligible tabs to sleep using new logic based on this setting. Supporting functions and configuration mappings were added to handle the sleep criteria.

Changes

File(s) Change Summary
src/main/browser/tabs/tab-manager.ts Enhanced periodic tab management to check for and put tabs to sleep based on new sleep criteria and imported logic.
src/main/modules/basic-settings.ts Added "Sleep Tab After" setting, mapping, and settings card for user configuration of tab sleep intervals.
src/main/saving/tabs.ts Added shouldSleepTab function and imported sleep duration mapping for determining when tabs should sleep.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant TabManager
    participant Settings
    participant Tab

    loop Every 10 seconds
        TabManager->Tab: Check visibility and state
        TabManager->Settings: Get "sleepTabAfter" setting
        TabManager->Tab: Get lastActiveAt
        TabManager->Tab: shouldSleepTab(lastActiveAt)
        alt Tab should sleep
            TabManager->Tab: putToSleep()
        end
        TabManager->Tab: shouldArchiveTab(lastActiveAt)
        alt Tab should archive
            TabManager->Tab: destroy()
        end
    end
Loading

Poem

In the warren of tabs, some frolic, some nap,
Now a gentle new setting lets sleepy ones nap.
With a whisk of a paw, they snooze out of sight,
While others keep hopping through digital night.
Sleep well, dear tabs, in code’s cozy embrace—
You’ll wake when it’s time to rejoin the race!
💤🐇

Note

⚡️ AI Code Reviews for VS Code, Cursor, Windsurf

CodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback.
Learn more here.


Note

⚡️ Faster reviews with caching

CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.
Enjoy the performance boost—your workflow just got faster.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between 4ae4722 and d225b08.

📒 Files selected for processing (1)
  • src/main/modules/basic-settings.ts (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/modules/basic-settings.ts
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: build (ubuntu-latest)
  • GitHub Check: build (windows-latest)
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions
Copy link
Contributor

github-actions bot commented May 15, 2025

Build artifacts for all platforms are ready! 🚀

Download the artifacts from:

(execution 15079224602 / attempt 1)

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/main/saving/tabs.ts (1)

64-73: Well-implemented shouldSleepTab function with proper error handling.

The shouldSleepTab function follows the same structure as the existing shouldArchiveTab function, which is good for consistency. The function:

  1. Retrieves the user's preference for the sleep tab timeout
  2. Maps it to seconds using the SleepTabValueMap
  3. Includes proper error handling (returning false if the mapping is invalid)
  4. Calculates the elapsed time since last activity
  5. Returns a boolean indicating whether the tab should be put to sleep

One suggestion: Consider adding a JSDoc comment to describe the function's purpose and parameters, similar to documentation elsewhere in the codebase.

+/**
+ * Determines if a tab should be put to sleep based on its last active time
+ * and the user's sleep tab preference.
+ * 
+ * @param lastActiveAt Unix timestamp in seconds of when the tab was last active
+ * @returns Boolean indicating whether the tab should be put to sleep
+ */
 export function shouldSleepTab(lastActiveAt: number) {
   const sleepTabAfter = getSettingValueById("sleepTabAfter");
   const sleepTabAfterSeconds = SleepTabValueMap[sleepTabAfter as keyof typeof SleepTabValueMap];
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between 98d6324 and 4ae4722.

📒 Files selected for processing (3)
  • src/main/browser/tabs/tab-manager.ts (2 hunks)
  • src/main/modules/basic-settings.ts (3 hunks)
  • src/main/saving/tabs.ts (2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
src/main/browser/tabs/tab-manager.ts (1)
src/main/saving/tabs.ts (1)
  • shouldSleepTab (64-73)
src/main/saving/tabs.ts (2)
src/main/saving/settings.ts (1)
  • getSettingValueById (54-56)
src/main/modules/basic-settings.ts (1)
  • SleepTabValueMap (22-33)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: build (ubuntu-latest)
  • GitHub Check: build (windows-latest)
  • GitHub Check: build (macos-latest)
🔇 Additional comments (6)
src/main/modules/basic-settings.ts (3)

18-33: Well-structured implementation of Sleep Tab Value Map.

The new SleepTabValueMap object is implemented correctly and follows the same pattern as the existing ArchiveTabValueMap. It provides a comprehensive range of time intervals from 5 minutes to 24 hours, giving users flexible options for tab sleeping behavior.


160-209: Clear and consistent implementation of the sleep tab settings.

The implementation of the sleepTabAfter setting follows the same structure as other settings in the file. The default value of "never" is a good choice as it ensures users have to explicitly opt-in to the automatic sleep functionality.


257-262: Good integration of Sleep Tab settings card.

The settings card for "Sleep Tab After" is properly implemented and follows the same pattern as the existing "Archive Tab After" card. The subtitle clearly explains the purpose of this setting.

src/main/browser/tabs/tab-manager.ts (2)

9-9: Import updated to include the new function.

The import statement has been updated to include the new shouldSleepTab function alongside the existing shouldArchiveTab function.


86-88: Effective implementation of tab sleep functionality.

The tab sleep functionality is well integrated into the existing periodic tab lifecycle management. The conditions for sleeping a tab are clearly defined:

  1. The tab must not be visible
  2. The tab must not already be asleep
  3. The tab must meet the time-based criteria defined in shouldSleepTab

This implementation follows the same pattern as the existing archive logic, ensuring consistency in behavior.

src/main/saving/tabs.ts (1)

5-5: Import properly updated to include SleepTabValueMap.

The import statement has been updated to include the new SleepTabValueMap alongside the existing ArchiveTabValueMap.

@iamEvanYT iamEvanYT merged commit c753eec into MultiboxLabs:main May 16, 2025
6 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.

2 participants