Skip to content

Conversation

raunakab
Copy link
Contributor

@raunakab raunakab commented May 21, 2025

Description

UI updates to sidebar.

How Has This Been Tested?

This is a pure UI change; no tests were written.

@raunakab raunakab requested a review from a team as a code owner May 21, 2025 15:15
Copy link

vercel bot commented May 21, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
internal-search ❌ Failed (Inspect) May 22, 2025 0:13am

@raunakab raunakab marked this pull request as draft May 21, 2025 15:15
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

This PR refactors the sidebar UI to fix chat dragging within groups while introducing a new standardized sidebar component system. The changes primarily focus on improving the user experience and fixing a specific dragging issue.

  • New sidebar.tsx component introduces a comprehensive, accessible sidebar system with proper TypeScript typing and mobile responsiveness
  • Removed drag handle from ChatSessionDisplay.tsx in favor of making the entire chat item draggable
  • ChatGroup.tsx now uses a collapsible menu structure but has commented-out props that need review
  • useIsMobile hook needs SSR consideration and consistent width checking between initial load and subsequent changes
  • Potential state management concerns in PagesTab.tsx with commented-out drag-and-drop implementation

9 file(s) reviewed, 11 comment(s)
Edit PR Review Bot Settings | Greptile

<CollapsibleContent>
<SidebarMenuSub>
{chatSessions.map((chatSession) => (
<SidebarMenuSubItem key={chatSession.name}>
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: Using chatSession.name as key is unsafe. Should use chatSession.id for stable list rendering

Suggested change
<SidebarMenuSubItem key={chatSession.name}>
<SidebarMenuSubItem key={chatSession.id}>

Comment on lines 58 to 61
// showShareModal={showShareModal}
// showDeleteModal={showDeleteModal}
// closeSidebar={closeSidebar}
// isDragging={isDraggingSessionId === chat.id}
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: Critical props are commented out. These need to be properly passed through or the chat sharing, deletion and dragging functionality will break

Comment on lines 201 to 202
draggable={!isMobile}
onDragStart={!isMobile ? handleDragStart : undefined}
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: draggable and onDragStart are only set when !isMobile, but handleTouchStart is never used. Mobile drag-and-drop functionality may be broken.

Comment on lines 36 to 38
open={hasChatsToShow && expanded}
defaultOpen={true}
>
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Conflicting open states - defaultOpen is true but open depends on hasChatsToShow && expanded. This could cause unexpected behavior

Comment on lines 360 to 365
const groupedChatSessionsLength = Object.entries(groupedChatSesssions).length;
const foldersLength = (folders ?? []).length;
const totalLength = groupedChatSessionsLength + foldersLength;
const [expands, setExpands] = useState<boolean[]>(
Array(totalLength).fill(true)
);
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: Initial state of expands array depends on dynamic length calculation, which could cause UI flicker if folders/chats load asynchronously

>(({ className, ...props }, ref) => (
<SheetPrimitive.Overlay
className={cn(
"fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
Copy link
Contributor

Choose a reason for hiding this comment

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

syntax: Extra space after bg-black/80 in className string could cause inconsistent styling

Suggested change
"fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
"fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",

"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",
left: "inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",
right:
"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm",
Copy link
Contributor

Choose a reason for hiding this comment

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

syntax: Extra space after w-3/4 in className string could cause inconsistent styling

Suggested change
"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm",
"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm",

ref={ref}
data-sidebar="rail"
aria-label="Toggle Sidebar"
tabIndex={-1}
Copy link
Contributor

Choose a reason for hiding this comment

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

style: tabIndex={-1} on a clickable button may cause accessibility issues for keyboard users.

Suggested change
tabIndex={-1}
aria-label="Toggle Sidebar"
onClick={toggleSidebar}
title="Toggle Sidebar"

Comment on lines +11 to +14
const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
const onChange = () => {
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
};
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: Inconsistent width checking between matchMedia and innerWidth. Use mql.matches instead of innerWidth for consistency

Suggested change
const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
const onChange = () => {
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
};
const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
const onChange = () => {
setIsMobile(mql.matches);
};

Comment on lines +10 to +18
React.useEffect(() => {
const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
const onChange = () => {
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
};
mql.addEventListener("change", onChange);
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
return () => mql.removeEventListener("change", onChange);
}, []);
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Add check for window object to support SSR: if (typeof window === 'undefined') return false

Suggested change
React.useEffect(() => {
const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
const onChange = () => {
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
};
mql.addEventListener("change", onChange);
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
return () => mql.removeEventListener("change", onChange);
}, []);
React.useEffect(() => {
if (typeof window === 'undefined') return;
const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
const onChange = () => {
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
};
mql.addEventListener("change", onChange);
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
return () => mql.removeEventListener("change", onChange);
}, []);

- this cancels the editing state
@raunakab raunakab changed the title fix: Chats dragging issue feat: Sidebar UI updates May 22, 2025
Copy link

github-actions bot commented Aug 6, 2025

This PR is stale because it has been open 75 days with no activity. Remove stale label or comment or this will be closed in 15 days.

@github-actions github-actions bot added the Stale label Aug 6, 2025
Copy link

This PR was closed because it has been stalled for 90 days with no activity.

@github-actions github-actions bot closed this Aug 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant