@@ -12,6 +12,8 @@ const LAYOUT_STORAGE_KEY = "opencode.layout";
1212const DEFAULT_REVIEW_WIDTH = 320 ;
1313const DEFAULT_INFO_WIDTH = 256 ;
1414const DEFAULT_SIDEBAR_WIDTH = 256 ;
15+ const SIDEBAR_MIN_WIDTH = 180 ;
16+ const SIDEBAR_MAX_WIDTH = 480 ;
1517
1618interface PanelState {
1719 opened : boolean ;
@@ -54,6 +56,7 @@ interface LayoutContextValue {
5456 sidebar : {
5557 width : ( ) => number ;
5658 resize : ( width : number ) => void ;
59+ persist : ( ) => void ;
5760 } ;
5861 // File tabs
5962 tabs : {
@@ -135,9 +138,11 @@ export function LayoutProvider(props: ParentProps) {
135138 initial . info . width ?? DEFAULT_INFO_WIDTH ,
136139 ) ;
137140
138- // Sidebar state
141+ // Sidebar state (clamp loaded value to valid range)
139142 const [ sidebarWidth , setSidebarWidth ] = createSignal (
140- initial . sidebar ?. width ?? DEFAULT_SIDEBAR_WIDTH ,
143+ Math . max ( SIDEBAR_MIN_WIDTH , Math . min ( SIDEBAR_MAX_WIDTH ,
144+ Number . isFinite ( initial . sidebar ?. width ) ? initial . sidebar ! . width ! : DEFAULT_SIDEBAR_WIDTH ,
145+ ) ) ,
141146 ) ;
142147
143148 // File tabs state
@@ -201,9 +206,9 @@ export function LayoutProvider(props: ParentProps) {
201206 sidebar : {
202207 width : sidebarWidth ,
203208 resize : ( width : number ) => {
204- setSidebarWidth ( width ) ;
205- persist ( ) ;
209+ setSidebarWidth ( Math . max ( SIDEBAR_MIN_WIDTH , Math . min ( SIDEBAR_MAX_WIDTH , width ) ) ) ;
206210 } ,
211+ persist,
207212 } ,
208213 tabs : {
209214 all : fileTabs ,
0 commit comments