@@ -6,7 +6,7 @@ import { Panel } from "../components/Panel.js";
66import { KVRow , TuiFooter , TuiHeader } from "../components/TuiFrame.js" ;
77import { useFocusNavigation , type FocusItem } from "../hooks/useFocusNavigation.js" ;
88import { useTerminalSize } from "../hooks/useTerminalSize.js" ;
9- import { colors } from "../theme.js" ;
9+ import { colors , layout as tuiLayout } from "../theme.js" ;
1010
1111const LABELS : Record < AIProvider , string > = {
1212 openai : "OpenAI" ,
@@ -71,7 +71,7 @@ export function AuthLayout() {
7171 < Box key = { `${ terminal . width } x${ terminal . height } ` } flexDirection = "column" width = { terminal . width } height = { terminal . height } >
7272 < TuiHeader command = "setupr auth" title = "global auth" status = { activeModel . id } statusColor = { colors . success } right = "masked keys only" width = { terminal . width } />
7373
74- < Box flexDirection = { layout . stacked ? "column" : "row" } width = "100%" height = { layout . contentHeight } flexShrink = { 1 } overflow = "hidden" >
74+ < Box flexDirection = { layout . stacked ? "column" : "row" } width = "100%" height = { layout . contentHeight } flexShrink = { 1 } overflow = "hidden" gap = { tuiLayout . panelGap } >
7575 < Panel title = "Providers" focusState = { focus . focusState ( "providers" ) } width = { layout . stacked ? "100%" : layout . providers . width } height = { layout . providers . height } >
7676 < Box flexDirection = "column" >
7777 { rows . slice ( 0 , layout . providerLimit ) . map ( ( row ) => (
@@ -83,18 +83,19 @@ export function AuthLayout() {
8383 </ Box >
8484 </ Panel >
8585
86- < Panel title = "Active Model" focusState = { focus . focusState ( "model" ) } width = { layout . stacked ? "100%" : layout . model . width } height = { layout . stacked ? layout . model . height : Math . max ( 8 , Math . floor ( layout . model . height * 0.36 ) ) } >
87- < ModelPanel activeModel = { activeModel } />
88- </ Panel >
89-
90- { ! layout . stacked && (
91- < Panel title = "Model Catalog" focusState = { focus . focusState ( "catalog" ) } width = { layout . model . width } height = { layout . model . height - Math . max ( 8 , Math . floor ( layout . model . height * 0.36 ) ) } >
92- < ModelCatalog availableModels = { availableModels } activeModelId = { activeModel . id } limit = { layout . modelLimit } />
86+ < Box flexDirection = "column" width = { layout . stacked ? "100%" : layout . model . width } height = { layout . model . height } gap = { tuiLayout . panelGap } >
87+ < Panel title = "Active Model" focusState = { focus . focusState ( "model" ) } width = "100%" height = { layout . stacked ? layout . model . height : Math . max ( 8 , Math . floor ( ( layout . model . height - tuiLayout . panelGap ) * 0.36 ) ) } >
88+ < ModelPanel activeModel = { activeModel } />
9389 </ Panel >
94- ) }
90+ { ! layout . stacked && (
91+ < Panel title = "Model Catalog" focusState = { focus . focusState ( "catalog" ) } width = "100%" flexGrow = { 1 } minHeight = { 8 } >
92+ < ModelCatalog availableModels = { availableModels } activeModelId = { activeModel . id } limit = { layout . modelLimit } />
93+ </ Panel >
94+ ) }
95+ </ Box >
9596
96- < Box flexDirection = "column" width = { layout . stacked ? "100%" : layout . actions . width } height = { layout . actions . height } >
97- < Panel title = "Test Results" focusState = { focus . focusState ( "tests" ) } width = "100%" height = { layout . stacked ? Math . max ( 6 , Math . floor ( layout . actions . height * 0.46 ) ) : Math . max ( 8 , Math . floor ( layout . actions . height * 0.48 ) ) } >
97+ < Box flexDirection = "column" width = { layout . stacked ? "100%" : layout . actions . width } height = { layout . actions . height } gap = { tuiLayout . panelGap } >
98+ < Panel title = "Test Results" focusState = { focus . focusState ( "tests" ) } width = "100%" height = { layout . stacked ? Math . max ( 6 , Math . floor ( layout . actions . height * 0.46 ) ) : Math . max ( 8 , Math . floor ( ( layout . actions . height - tuiLayout . panelGap ) * 0.48 ) ) } >
9899 < TestResults rows = { rows } activeModelProvider = { activeModel . provider } />
99100 </ Panel >
100101 < Panel title = "Secure Storage" focusState = { focus . focusState ( "storage" ) } width = "100%" flexGrow = { 1 } minHeight = { 6 } >
@@ -192,6 +193,7 @@ interface AuthLayoutGeometry {
192193
193194function buildAuthLayout ( width : number , height : number ) : AuthLayoutGeometry {
194195 const contentHeight = Math . max ( 8 , height - 2 ) ;
196+ const gap = tuiLayout . panelGap ;
195197 const compact = width < 96 || contentHeight < 18 ;
196198 if ( compact ) {
197199 return {
@@ -212,7 +214,7 @@ function buildAuthLayout(width: number, height: number): AuthLayoutGeometry {
212214 if ( stacked ) {
213215 const providerHeight = clamp ( Math . floor ( contentHeight * 0.42 ) , 6 , Math . max ( 6 , contentHeight - 8 ) ) ;
214216 const modelHeight = clamp ( Math . floor ( contentHeight * 0.30 ) , 5 , Math . max ( 5 , contentHeight - providerHeight - 4 ) ) ;
215- const actionsHeight = Math . max ( 4 , contentHeight - providerHeight - modelHeight ) ;
217+ const actionsHeight = Math . max ( 4 , contentHeight - providerHeight - modelHeight - gap * 2 ) ;
216218 return {
217219 width,
218220 height,
@@ -222,12 +224,12 @@ function buildAuthLayout(width: number, height: number): AuthLayoutGeometry {
222224 providerLimit : Math . max ( 1 , providerHeight - 3 ) ,
223225 modelLimit : Math . max ( 1 , modelHeight - 6 ) ,
224226 providers : { x : 1 , y : 2 , width, height : providerHeight } ,
225- model : { x : 1 , y : providerHeight + 2 , width, height : modelHeight } ,
226- actions : { x : 1 , y : providerHeight + modelHeight + 2 , width, height : actionsHeight } ,
227+ model : { x : 1 , y : providerHeight + gap + 2 , width, height : modelHeight } ,
228+ actions : { x : 1 , y : providerHeight + modelHeight + gap * 2 + 2 , width, height : actionsHeight } ,
227229 } ;
228230 }
229231
230- const [ providersWidth , modelWidth , actionsWidth ] = distributeWidths ( width , [ 0.28 , 0.48 , 0.24 ] , [ 30 , 40 , 28 ] ) ;
232+ const [ providersWidth , modelWidth , actionsWidth ] = distributeWidths ( Math . max ( 1 , width - gap * 2 ) , [ 0.28 , 0.48 , 0.24 ] , [ 30 , 40 , 28 ] ) ;
231233 return {
232234 width,
233235 height,
@@ -237,8 +239,8 @@ function buildAuthLayout(width: number, height: number): AuthLayoutGeometry {
237239 providerLimit : Math . max ( 1 , contentHeight - 3 ) ,
238240 modelLimit : Math . max ( 1 , contentHeight - 7 ) ,
239241 providers : { x : 1 , y : 2 , width : providersWidth , height : contentHeight } ,
240- model : { x : providersWidth + 1 , y : 2 , width : modelWidth , height : contentHeight } ,
241- actions : { x : providersWidth + modelWidth + 1 , y : 2 , width : actionsWidth , height : contentHeight } ,
242+ model : { x : providersWidth + gap + 1 , y : 2 , width : modelWidth , height : contentHeight } ,
243+ actions : { x : providersWidth + modelWidth + gap * 2 + 1 , y : 2 , width : actionsWidth , height : contentHeight } ,
242244 } ;
243245}
244246
@@ -258,10 +260,10 @@ function buildFocusItems(layout: AuthLayoutGeometry): FocusItem[] {
258260 }
259261 return [
260262 { id : "providers" , row : 0 , column : 0 , bounds : layout . providers } ,
261- { id : "model" , row : 0 , column : 1 , bounds : layout . model } ,
262- { id : "catalog" , row : 1 , column : 1 , bounds : layout . model } ,
263- { id : "tests" , row : 0 , column : 2 , bounds : layout . actions } ,
264- { id : "storage" , row : 1 , column : 2 , bounds : layout . actions } ,
263+ { id : "model" , row : 0 , column : 1 , bounds : { ... layout . model , height : Math . max ( 8 , Math . floor ( ( layout . model . height - tuiLayout . panelGap ) * 0.36 ) ) } } ,
264+ { id : "catalog" , row : 1 , column : 1 , bounds : { ... layout . model , y : layout . model . y + Math . max ( 8 , Math . floor ( ( layout . model . height - tuiLayout . panelGap ) * 0.36 ) ) + tuiLayout . panelGap , height : Math . max ( 8 , layout . model . height - Math . max ( 8 , Math . floor ( ( layout . model . height - tuiLayout . panelGap ) * 0.36 ) ) - tuiLayout . panelGap ) } } ,
265+ { id : "tests" , row : 0 , column : 2 , bounds : { ... layout . actions , height : Math . max ( 8 , Math . floor ( ( layout . actions . height - tuiLayout . panelGap ) * 0.48 ) ) } } ,
266+ { id : "storage" , row : 1 , column : 2 , bounds : { ... layout . actions , y : layout . actions . y + Math . max ( 8 , Math . floor ( ( layout . actions . height - tuiLayout . panelGap ) * 0.48 ) ) + tuiLayout . panelGap , height : Math . max ( 6 , layout . actions . height - Math . max ( 8 , Math . floor ( ( layout . actions . height - tuiLayout . panelGap ) * 0.48 ) ) - tuiLayout . panelGap ) } } ,
265267 ] ;
266268}
267269
0 commit comments