@@ -166,17 +166,19 @@ const TiledViewsContainer = observer(function TiledViewsContainer({
166166 : undefined
167167
168168 // If we have init configuration from URL params, use it
169- if ( initLayout ) {
169+ if ( initLayout && isSessionWithDockviewLayout ( session ) ) {
170170 trackedViewIdsRef . current . clear ( )
171171 let firstPanelId : string | undefined
172172
173+ // Collect groups and their sizes for post-processing
174+ const groupSizes : { group : DockviewGroupPanel ; size : number } [ ] = [ ]
175+
173176 // Process nested layout structure
174177 // Returns the group created for this node (for use as reference by siblings)
175178 function processNode (
176179 node : typeof initLayout ,
177180 referenceGroup : DockviewGroupPanel | undefined ,
178181 direction : 'right' | 'below' | undefined ,
179- size : number | undefined ,
180182 ) : DockviewGroupPanel | undefined {
181183 if ( ! node ) {
182184 return undefined
@@ -189,7 +191,7 @@ const TiledViewsContainer = observer(function TiledViewsContainer({
189191 }
190192 const position =
191193 referenceGroup && direction
192- ? { referenceGroup, direction, size }
194+ ? { referenceGroup, direction }
193195 : referenceGroup
194196 ? { referenceGroup }
195197 : undefined
@@ -199,11 +201,18 @@ const TiledViewsContainer = observer(function TiledViewsContainer({
199201 } )
200202 // Populate panelViewAssignments from init
201203 for ( const viewId of node . viewIds ) {
202- session . assignViewToPanel ( panelId , viewId )
204+ if ( isSessionWithDockviewLayout ( session ) ) {
205+ session . assignViewToPanel ( panelId , viewId )
206+ }
203207 trackedViewIdsRef . current . add ( viewId )
204208 }
205209 // Return the group this panel was added to
206- return dockviewApi . getPanel ( panelId ) ?. group
210+ const group = dockviewApi . getPanel ( panelId ) ?. group
211+ // Track size for this group if specified
212+ if ( group && node . size !== undefined ) {
213+ groupSizes . push ( { group, size : node . size } )
214+ }
215+ return group
207216 }
208217 if ( node . children && node . children . length > 0 ) {
209218 // Container node - process children
@@ -215,12 +224,7 @@ const TiledViewsContainer = observer(function TiledViewsContainer({
215224 // First child uses parent's reference/direction, subsequent children split from previous
216225 const childDirection = i === 0 ? direction : dockviewDirection
217226 const childRef = i === 0 ? referenceGroup : currentGroup
218- const newGroup = processNode (
219- child ,
220- childRef ,
221- childDirection ,
222- child . size ,
223- )
227+ const newGroup = processNode ( child , childRef , childDirection )
224228 if ( newGroup ) {
225229 currentGroup = newGroup
226230 }
@@ -230,7 +234,42 @@ const TiledViewsContainer = observer(function TiledViewsContainer({
230234 return undefined
231235 }
232236
233- processNode ( initLayout , undefined , undefined , undefined )
237+ processNode ( initLayout , undefined , undefined )
238+
239+ // Apply proportional sizes after all panels are created
240+ // Only handle simple horizontal/vertical splits at the root level
241+ // Use requestAnimationFrame to ensure layout is complete
242+ if (
243+ groupSizes . length >= 2 &&
244+ initLayout . direction &&
245+ groupSizes . length === initLayout . children ?. length
246+ ) {
247+ const direction = initLayout . direction
248+ requestAnimationFrame ( ( ) => {
249+ const totalSize = groupSizes . reduce ( ( sum , g ) => sum + g . size , 0 )
250+ if ( totalSize > 0 ) {
251+ if ( direction === 'horizontal' ) {
252+ const containerWidth = dockviewApi . width
253+ if ( containerWidth > 0 ) {
254+ for ( const { group, size } of groupSizes ) {
255+ const width = Math . round ( containerWidth * ( size / totalSize ) )
256+ group . api . setSize ( { width } )
257+ }
258+ }
259+ } else {
260+ const containerHeight = dockviewApi . height
261+ if ( containerHeight > 0 ) {
262+ for ( const { group, size } of groupSizes ) {
263+ const height = Math . round (
264+ containerHeight * ( size / totalSize ) ,
265+ )
266+ group . api . setSize ( { height } )
267+ }
268+ }
269+ }
270+ }
271+ } )
272+ }
234273
235274 // Clear init after processing (it's only needed once)
236275 session . setInit ( undefined )
0 commit comments