@@ -38,6 +38,9 @@ const DIFF_INLINE_LAYOUT_MEDIA_QUERY = "(max-width: 1180px)";
3838const DIFF_INLINE_SIDEBAR_WIDTH_STORAGE_KEY = "chat_diff_sidebar_width" ;
3939const DIFF_INLINE_DEFAULT_WIDTH = "clamp(28rem,48vw,44rem)" ;
4040const DIFF_INLINE_SIDEBAR_MIN_WIDTH = 26 * 16 ;
41+ const CODE_VIEWER_SIDEBAR_WIDTH_STORAGE_KEY = "chat_code_viewer_sidebar_width" ;
42+ const CODE_VIEWER_DEFAULT_WIDTH = "clamp(28rem,48vw,44rem)" ;
43+ const CODE_VIEWER_SIDEBAR_MIN_WIDTH = 26 * 16 ;
4144const COMPOSER_COMPACT_MIN_LEFT_CONTROLS_WIDTH_PX = 208 ;
4245
4346const DiffPanelSheet = ( props : {
@@ -189,17 +192,45 @@ const DiffPanelInlineSidebar = (props: {
189192 ) ;
190193} ;
191194
192- /** Full-page overlay for the code viewer — covers the chat area entirely. */
193- const CodeViewerFullPage = ( props : { codeViewerOpen : boolean ; renderContent : boolean } ) => {
194- if ( ! props . codeViewerOpen && ! props . renderContent ) return null ;
195+ /** Right-side sidebar panel for the code viewer — sits alongside the chat area. */
196+ const CodeViewerInlineSidebar = ( props : {
197+ codeViewerOpen : boolean ;
198+ onCloseCodeViewer : ( ) => void ;
199+ renderContent : boolean ;
200+ } ) => {
201+ const { codeViewerOpen, onCloseCodeViewer, renderContent } = props ;
202+ const onOpenChange = useCallback (
203+ ( open : boolean ) => {
204+ if ( ! open ) {
205+ onCloseCodeViewer ( ) ;
206+ }
207+ } ,
208+ [ onCloseCodeViewer ] ,
209+ ) ;
210+ const shouldAcceptInlineSidebarWidth = useShouldAcceptInlineSidebarWidth ( ) ;
195211
196212 return (
197- < div
198- className = "absolute inset-0 z-30 bg-background"
199- style = { { display : props . codeViewerOpen ? undefined : "none" } }
213+ < SidebarProvider
214+ defaultOpen = { false }
215+ open = { codeViewerOpen }
216+ onOpenChange = { onOpenChange }
217+ className = "w-auto min-h-0 flex-none bg-transparent"
218+ style = { { "--sidebar-width" : CODE_VIEWER_DEFAULT_WIDTH } as CSSProperties }
200219 >
201- { props . renderContent ? < LazyCodeViewerPanel /> : null }
202- </ div >
220+ < Sidebar
221+ side = "right"
222+ collapsible = "offcanvas"
223+ className = "border-l border-border bg-card text-foreground"
224+ resizable = { {
225+ minWidth : CODE_VIEWER_SIDEBAR_MIN_WIDTH ,
226+ shouldAcceptWidth : shouldAcceptInlineSidebarWidth ,
227+ storageKey : CODE_VIEWER_SIDEBAR_WIDTH_STORAGE_KEY ,
228+ } }
229+ >
230+ { renderContent ? < LazyCodeViewerPanel /> : null }
231+ < SidebarRail />
232+ </ Sidebar >
233+ </ SidebarProvider >
203234 ) ;
204235} ;
205236
@@ -287,11 +318,12 @@ function ChatThreadRouteView() {
287318 < >
288319 < SidebarInset className = "relative h-dvh min-h-0 overflow-hidden overscroll-y-none bg-background text-foreground" >
289320 < ChatView key = { threadId } threadId = { threadId } />
290- < CodeViewerFullPage
291- codeViewerOpen = { codeViewerOpen }
292- renderContent = { shouldRenderCodeViewerContent }
293- />
294321 </ SidebarInset >
322+ < CodeViewerInlineSidebar
323+ codeViewerOpen = { codeViewerOpen }
324+ onCloseCodeViewer = { closeCodeViewer }
325+ renderContent = { shouldRenderCodeViewerContent }
326+ />
295327 < DiffPanelInlineSidebar
296328 diffOpen = { diffOpen }
297329 onCloseDiff = { closeDiff }
@@ -306,11 +338,12 @@ function ChatThreadRouteView() {
306338 < >
307339 < SidebarInset className = "relative h-dvh min-h-0 overflow-hidden overscroll-y-none bg-background text-foreground" >
308340 < ChatView key = { threadId } threadId = { threadId } />
309- < CodeViewerFullPage
310- codeViewerOpen = { codeViewerOpen }
311- renderContent = { shouldRenderCodeViewerContent }
312- />
313341 </ SidebarInset >
342+ < CodeViewerInlineSidebar
343+ codeViewerOpen = { codeViewerOpen }
344+ onCloseCodeViewer = { closeCodeViewer }
345+ renderContent = { shouldRenderCodeViewerContent }
346+ />
314347 < DiffPanelSheet diffOpen = { diffOpen } onCloseDiff = { closeDiff } >
315348 { shouldRenderDiffContent ? < LazyDiffPanel mode = "sheet" /> : null }
316349 </ DiffPanelSheet >
0 commit comments