231231 color : # e0e0e0 ;
232232 font-size : 15px ;
233233 outline : none;
234+ -webkit-appearance : none;
235+ appearance : none;
234236 }
235- .modal input : focus {
237+ .modal select {
238+ background-image : url ("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E" );
239+ background-repeat : no-repeat;
240+ background-position : right 12px center;
241+ padding-right : 32px ;
242+ cursor : pointer;
243+ }
244+ .modal input : focus ,
245+ .modal select : focus {
236246 border-color : # 533483 ;
237247 }
238248 .modal-actions {
@@ -459,8 +469,12 @@ <h1>📡 Term<span>Cast</span></h1>
459469 < h2 > New Session</ h2 >
460470 < label for ="sess-name "> Name</ label >
461471 < input type ="text " id ="sess-name " placeholder ="My Session " />
462- < label for ="sess-shell "> Shell / Command</ label >
463- < input type ="text " id ="sess-shell " placeholder ="/bin/zsh " />
472+ < label for ="sess-shell "> Shell</ label >
473+ < select id ="sess-shell ">
474+ < option value =""> Loading shells…</ option >
475+ </ select >
476+ < label for ="sess-cmd "> Initial Command < span style ="color:#666;font-weight:normal "> (optional)</ span > </ label >
477+ < input type ="text " id ="sess-cmd " placeholder ="e.g. copilot, htop, vim " />
464478 < label for ="sess-cwd "> Working Directory</ label >
465479 < div class ="cwd-picker ">
466480 < input type ="text " id ="sess-cwd " placeholder ="/Users/dorlugasigal " />
568582 }
569583
570584 document . getElementById ( 'new-session-btn' ) . addEventListener ( 'click' , ( ) => {
585+ loadShells ( ) ;
571586 modal . classList . add ( 'visible' ) ;
572587 } ) ;
573588 document . getElementById ( 'modal-cancel' ) . addEventListener ( 'click' , ( ) => {
@@ -581,11 +596,13 @@ <h3>
581596 const name = document . getElementById ( 'sess-name' ) . value . trim ( ) ;
582597 const shell = document . getElementById ( 'sess-shell' ) . value . trim ( ) ;
583598 const cwd = document . getElementById ( 'sess-cwd' ) . value . trim ( ) ;
599+ const initialCommand = document . getElementById ( 'sess-cmd' ) . value . trim ( ) ;
584600
585601 const body = { } ;
586602 if ( name ) body . name = name ;
587603 if ( shell ) body . shell = shell ;
588604 if ( cwd ) body . cwd = cwd ;
605+ if ( initialCommand ) body . initialCommand = initialCommand ;
589606
590607 const res = await fetch ( '/api/sessions' , {
591608 method : 'POST' ,
@@ -596,6 +613,30 @@ <h3>
596613 location . href = data . url ;
597614 } ) ;
598615
616+ // --- Shell detection ---
617+ let shellsLoaded = false ;
618+ async function loadShells ( ) {
619+ if ( shellsLoaded ) return ;
620+ const shellSelect = document . getElementById ( 'sess-shell' ) ;
621+ try {
622+ const res = await fetch ( '/api/shells' ) ;
623+ const data = await res . json ( ) ;
624+ shellSelect . innerHTML = '' ;
625+ for ( const s of data . shells ) {
626+ const opt = document . createElement ( 'option' ) ;
627+ opt . value = s . cmd ;
628+ opt . textContent = `${ s . name } (${ s . cmd } )` ;
629+ if ( s . cmd === data . default || s . path === data . default ) {
630+ opt . selected = true ;
631+ }
632+ shellSelect . appendChild ( opt ) ;
633+ }
634+ shellsLoaded = true ;
635+ } catch {
636+ shellSelect . innerHTML = '<option value="">Could not detect shells</option>' ;
637+ }
638+ }
639+
599640 // --- Swipe to delete ---
600641 async function deleteSession ( id , e ) {
601642 e . stopPropagation ( ) ;
0 commit comments