Skip to content

Conversation

@mikr13
Copy link

@mikr13 mikr13 commented Jun 12, 2025

  • Introduce pinning capability for the sidebar in offscreen mode, allowing users to keep it open regardless of hover state.
  • Update sidebar behavior to prevent auto-hiding when pinned.
  • Refactor sidebar context to manage pinned state and variant.
  • Enhance navigation controls to include a pin button for user interaction.

SS:
image

Summary by CodeRabbit

  • New Features

    • Introduced a pinning feature for the sidebar, allowing users to pin or unpin the sidebar to keep it visible or allow it to auto-hide.
    • Added a pin/unpin button to the sidebar header when in floating mode for easy toggling.
  • Improvements

    • Sidebar now remembers its pinned state across sessions.
    • Enhanced sidebar hover behavior to prevent auto-hiding when pinned.

- Introduce pinning capability for the sidebar in offscreen mode, allowing users to keep it open regardless of hover state.
- Update sidebar behavior to prevent auto-hiding when pinned.
- Refactor sidebar context to manage pinned state and variant.
- Enhance navigation controls to include a pin button for user interaction.
Copilot AI review requested due to automatic review settings June 12, 2025 07:28
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 12, 2025

Walkthrough

The changes introduce a "pinned" state to the sidebar, allowing users to pin or unpin it. This state is managed via context, persisted in cookies, and exposed through a new pin button in the sidebar header. Sidebar hover and auto-hide behaviors are updated to respect the pinned state, and related imports are reorganized for clarity.

Changes

File(s) Change Summary
src/renderer/src/components/browser-ui/browser-sidebar.tsx Reorganized imports; updated useSidebarHover to respect pinned state and prevent hover state changes if pinned.
src/renderer/src/components/browser-ui/main.tsx Grouped imports; removed SidebarVariant export; used sidebar context for variant and pinned state; updated effect.
src/renderer/src/components/browser-ui/sidebar/header/action-buttons.tsx Added PinButton component; updated NavigationControls to show pin button for floating variant; reordered imports.
src/renderer/src/components/ui/resizable-sidebar.tsx Added SidebarVariant type; extended context with variant, pinned, and handlers; persisted pinned state to cookie.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant PinButton
    participant SidebarContext
    participant Sidebar
    participant Cookie

    User->>PinButton: Click pin/unpin
    PinButton->>SidebarContext: togglePin()
    SidebarContext->>Sidebar: Update pinned state
    SidebarContext->>Cookie: Persist pinned state
    Sidebar->>Sidebar: Render with data-pinned attribute
    PinButton->>PinButton: Update icon and tooltip
Loading

Suggested labels

enhancement

Poem

In the warren of code, a sidebar stands tall,
Now pinned or unpinned, it answers the call.
With a click of the pin, it stays or it hides,
Cookies remember where preference resides.
Hopping with joy, this rabbit proclaims—
Sidebar’s new pinning has entered the game!
🐇📌


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a23003b and cc3c4b6.

📒 Files selected for processing (1)
  • src/renderer/src/components/ui/resizable-sidebar.tsx (9 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/renderer/src/components/ui/resizable-sidebar.tsx
✨ 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.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces a sidebar pinning functionality in offscreen mode by updating the sidebar’s behavior and context state management along with UI controls for pinning.

  • Added pinned state management with cookie persistence.
  • Integrated UI changes including a new PinButton component and conditional auto-hide behavior.
  • Refactored sidebar context and hover detection logic to incorporate the pinned state.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/renderer/src/components/ui/resizable-sidebar.tsx Added pinned state management, cookie persistence, and updated context.
src/renderer/src/components/browser-ui/sidebar/header/action-buttons.tsx Added PinButton and updated sidebar interaction logic.
src/renderer/src/components/browser-ui/main.tsx Modified auto-hide logic for the floating sidebar based on pinned state.
src/renderer/src/components/browser-ui/browser-sidebar.tsx Updated hover detection to account for the pinned state.

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: 1

🧹 Nitpick comments (3)
src/renderer/src/components/browser-ui/main.tsx (1)

52-57: Avoid unnecessary re-creation of the auto-hide effect

setOpen is a stable function coming from useSidebar; keeping it in the dependency array needlessly re-creates this effect every render and can cause “exhaustive-deps” noise in linters.
The dependency can safely be removed.

-}, [isHoveringSidebar, open, variant, pinned, setOpen]);
+}, [isHoveringSidebar, open, variant, pinned]);
src/renderer/src/components/browser-ui/browser-sidebar.tsx (1)

60-90: Clean up pending hover-state timeouts on unmount

useSidebarHover sets timeoutIdRef but never clears it when the component unmounts.
In practice that’s a memory leak risk and can fire state updates on an unmounted component.

 function useSidebarHover(setIsHoveringSidebar: (isHovering: boolean) => void) {
   const { pinned } = useSidebar();
   const isHoveringSidebarRef = useRef(false);
   const timeoutIdRef = useRef<NodeJS.Timeout | null>(null);

+  // Clear any outstanding timers on unmount
+  useEffect(() => () => {
+    if (timeoutIdRef.current) {
+      clearTimeout(timeoutIdRef.current);
+    }
+  }, []);
src/renderer/src/components/browser-ui/sidebar/header/action-buttons.tsx (1)

97-108: Add accessible label for the pin toggle

The PinButton relies on the title attribute, which is not read by most screen readers.
Provide an explicit aria-label to keep the control accessible.

-    />
+      aria-label={pinned ? "Unpin sidebar" : "Pin sidebar"}
+    />
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7d8628c and a23003b.

📒 Files selected for processing (4)
  • src/renderer/src/components/browser-ui/browser-sidebar.tsx (4 hunks)
  • src/renderer/src/components/browser-ui/main.tsx (2 hunks)
  • src/renderer/src/components/browser-ui/sidebar/header/action-buttons.tsx (3 hunks)
  • src/renderer/src/components/ui/resizable-sidebar.tsx (9 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/renderer/src/components/browser-ui/main.tsx (1)
src/renderer/src/components/ui/resizable-sidebar.tsx (1)
  • useSidebar (787-787)

@iamEvanYT
Copy link
Member

Seems like an extra button that isn't really needed. How useful would this be?

@mikr13
Copy link
Author

mikr13 commented Sep 21, 2025

Seems like an extra button that isn't really needed. How useful would this be?

Sorry for getting back this late. I haven't been able to keep up with the latest developments on this awesome project.
Let me see if this functionality will be needed anymore. Will get back soon!

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