@@ -27,6 +27,7 @@ import { useDialog } from "@tui/ui/dialog"
2727import { DialogProvider as DialogProviderConnect } from "../dialog-provider"
2828import { DialogAlert } from "../../ui/dialog-alert"
2929import { useToast } from "../../ui/toast"
30+ import { useKV } from "../../context/kv"
3031
3132export type PromptProps = {
3233 sessionID ?: string
@@ -35,6 +36,7 @@ export type PromptProps = {
3536 ref ?: ( ref : PromptRef ) => void
3637 hint ?: JSX . Element
3738 showPlaceholder ?: boolean
39+ footerVisible ?: boolean
3840}
3941
4042export type PromptRef = {
@@ -117,6 +119,12 @@ export function Prompt(props: PromptProps) {
117119 const dialog = useDialog ( )
118120 const toast = useToast ( )
119121 const status = createMemo ( ( ) => sync . data . session_status ?. [ props . sessionID ?? "" ] ?? { type : "idle" } )
122+ const kv = useKV ( )
123+ const permissions = createMemo ( ( ) => {
124+ if ( ! props . sessionID ) return [ ]
125+ return sync . data . permission [ props . sessionID ] ?? [ ]
126+ } )
127+ const shortcutsVisible = createMemo ( ( ) => ! kv . get ( "shortcuts_hidden" , false ) )
120128 const history = usePromptHistory ( )
121129 const command = useCommandDialog ( )
122130 const renderer = useRenderer ( )
@@ -881,17 +889,50 @@ export function Prompt(props: PromptProps) {
881889 cursorColor = { theme . text }
882890 syntaxStyle = { syntax ( ) }
883891 />
884- < box flexDirection = "row" flexShrink = { 0 } paddingTop = { 1 } gap = { 1 } >
885- < text fg = { highlight ( ) } >
886- { store . mode === "shell" ? "Shell" : Locale . titlecase ( local . agent . current ( ) . name ) } { " " }
887- </ text >
888- < Show when = { store . mode === "normal" } >
889- < box flexDirection = "row" gap = { 1 } >
890- < text flexShrink = { 0 } fg = { keybind . leader ? theme . textMuted : theme . text } >
891- { local . model . parsed ( ) . model }
892- </ text >
893- < text fg = { theme . textMuted } > { local . model . parsed ( ) . provider } </ text >
894- </ box >
892+ < box flexDirection = "row" flexShrink = { 0 } paddingTop = { 1 } gap = { 1 } justifyContent = "space-between" >
893+ < box flexDirection = "row" gap = { 1 } >
894+ < text fg = { highlight ( ) } >
895+ { store . mode === "shell" ? "Shell" : Locale . titlecase ( local . agent . current ( ) . name ) } { " " }
896+ </ text >
897+ < Show when = { store . mode === "normal" } >
898+ < box flexDirection = "row" gap = { 1 } >
899+ < text flexShrink = { 0 } fg = { keybind . leader ? theme . textMuted : theme . text } >
900+ { local . model . parsed ( ) . model }
901+ </ text >
902+ < text fg = { theme . textMuted } > { local . model . parsed ( ) . provider } </ text >
903+ </ box >
904+ </ Show >
905+ </ box >
906+ < Show when = { store . mode === "normal" && props . sessionID && ! props . footerVisible } >
907+ < Switch >
908+ < Match when = { permissions ( ) . length > 0 } >
909+ < text fg = { theme . warning } >
910+ < span style = { { fg : theme . warning } } > ◉</ span > { permissions ( ) . length } Permission
911+ { permissions ( ) . length > 1 ? "s" : "" } pending
912+ </ text >
913+ </ Match >
914+ < Match when = { status ( ) . type !== "idle" } >
915+ < box flexDirection = "row" gap = { 1 } flexShrink = { 0 } >
916+ < spinner color = { spinnerDef ( ) . color } frames = { spinnerDef ( ) . frames } interval = { 40 } />
917+ < text fg = { store . interrupt > 0 ? theme . primary : theme . text } >
918+ esc{ " " }
919+ < span style = { { fg : store . interrupt > 0 ? theme . primary : theme . textMuted } } >
920+ { store . interrupt > 0 ? "again to interrupt" : "interrupt" }
921+ </ span >
922+ </ text >
923+ </ box >
924+ </ Match >
925+ < Match when = { shortcutsVisible ( ) } >
926+ < box gap = { 2 } flexDirection = "row" flexShrink = { 0 } >
927+ < text fg = { theme . text } >
928+ { keybind . print ( "agent_cycle" ) } < span style = { { fg : theme . textMuted } } > switch agent</ span >
929+ </ text >
930+ < text fg = { theme . text } >
931+ { keybind . print ( "command_list" ) } < span style = { { fg : theme . textMuted } } > commands</ span >
932+ </ text >
933+ </ box >
934+ </ Match >
935+ </ Switch >
895936 </ Show >
896937 </ box >
897938 </ box >
@@ -922,103 +963,117 @@ export function Prompt(props: PromptProps) {
922963 }
923964 />
924965 </ box >
925- < box flexDirection = "row" justifyContent = "space-between" >
926- < Show when = { status ( ) . type !== "idle" } fallback = { < text /> } >
927- < box
928- flexDirection = "row"
929- gap = { 1 }
930- flexGrow = { 1 }
931- justifyContent = { status ( ) . type === "retry" ? "space-between" : "flex-start" }
932- >
933- < box flexShrink = { 0 } flexDirection = "row" gap = { 1 } >
934- { /* @ts -ignore // SpinnerOptions doesn't support marginLeft */ }
935- < spinner marginLeft = { 1 } color = { spinnerDef ( ) . color } frames = { spinnerDef ( ) . frames } interval = { 40 } />
936- < box flexDirection = "row" gap = { 1 } flexShrink = { 0 } >
937- { ( ( ) => {
938- const retry = createMemo ( ( ) => {
939- const s = status ( )
940- if ( s . type !== "retry" ) return
941- return s
942- } )
943- const message = createMemo ( ( ) => {
944- const r = retry ( )
945- if ( ! r ) return
946- if ( r . message . includes ( "exceeded your current quota" ) && r . message . includes ( "gemini" ) )
947- return "gemini is way too hot right now"
948- if ( r . message . length > 80 ) return r . message . slice ( 0 , 80 ) + "..."
949- return r . message
950- } )
951- const isTruncated = createMemo ( ( ) => {
952- const r = retry ( )
953- if ( ! r ) return false
954- return r . message . length > 120
955- } )
956- const [ seconds , setSeconds ] = createSignal ( 0 )
957- onMount ( ( ) => {
958- const timer = setInterval ( ( ) => {
959- const next = retry ( ) ?. next
960- if ( next ) setSeconds ( Math . round ( ( next - Date . now ( ) ) / 1000 ) )
961- } , 1000 )
962-
963- onCleanup ( ( ) => {
964- clearInterval ( timer )
966+ < Show when = { store . mode === "shell" } >
967+ < box gap = { 2 } flexDirection = "row" >
968+ < text fg = { theme . text } >
969+ esc < span style = { { fg : theme . textMuted } } > exit shell mode</ span >
970+ </ text >
971+ </ box >
972+ </ Show >
973+ < Show when = { store . mode !== "shell" } >
974+ < box flexDirection = "row" justifyContent = "space-between" >
975+ < Show when = { props . footerVisible && status ( ) . type !== "idle" } fallback = { < text /> } >
976+ < box
977+ flexDirection = "row"
978+ gap = { 1 }
979+ flexGrow = { 1 }
980+ justifyContent = { status ( ) . type === "retry" ? "space-between" : "flex-start" }
981+ >
982+ < box flexShrink = { 0 } flexDirection = "row" gap = { 1 } >
983+ { /* @ts -ignore // SpinnerOptions doesn't support marginLeft */ }
984+ < spinner marginLeft = { 1 } color = { spinnerDef ( ) . color } frames = { spinnerDef ( ) . frames } interval = { 40 } />
985+ < box flexDirection = "row" gap = { 1 } flexShrink = { 0 } >
986+ { ( ( ) => {
987+ const retry = createMemo ( ( ) => {
988+ const s = status ( )
989+ if ( s . type !== "retry" ) return
990+ return s
965991 } )
966- } )
967- const handleMessageClick = ( ) => {
968- const r = retry ( )
969- if ( ! r ) return
970- if ( isTruncated ( ) ) {
971- DialogAlert . show ( dialog , "Retry Error" , r . message )
992+ const message = createMemo ( ( ) => {
993+ const r = retry ( )
994+ if ( ! r ) return
995+ if ( r . message . includes ( "exceeded your current quota" ) && r . message . includes ( "gemini" ) )
996+ return "gemini is way too hot right now"
997+ if ( r . message . length > 80 ) return r . message . slice ( 0 , 80 ) + "..."
998+ return r . message
999+ } )
1000+ const isTruncated = createMemo ( ( ) => {
1001+ const r = retry ( )
1002+ if ( ! r ) return false
1003+ return r . message . length > 120
1004+ } )
1005+ const [ seconds , setSeconds ] = createSignal ( 0 )
1006+ onMount ( ( ) => {
1007+ const timer = setInterval ( ( ) => {
1008+ const next = retry ( ) ?. next
1009+ if ( next ) setSeconds ( Math . round ( ( next - Date . now ( ) ) / 1000 ) )
1010+ } , 1000 )
1011+
1012+ onCleanup ( ( ) => {
1013+ clearInterval ( timer )
1014+ } )
1015+ } )
1016+ const handleMessageClick = ( ) => {
1017+ const r = retry ( )
1018+ if ( ! r ) return
1019+ if ( isTruncated ( ) ) {
1020+ DialogAlert . show ( dialog , "Retry Error" , r . message )
1021+ }
9721022 }
973- }
9741023
975- const retryText = ( ) => {
976- const r = retry ( )
977- if ( ! r ) return ""
978- const baseMessage = message ( )
979- const truncatedHint = isTruncated ( ) ? " (click to expand)" : ""
980- const retryInfo = ` [retrying ${ seconds ( ) > 0 ? `in ${ seconds ( ) } s ` : "" } attempt #${ r . attempt } ]`
981- return baseMessage + truncatedHint + retryInfo
982- }
1024+ const retryText = ( ) => {
1025+ const r = retry ( )
1026+ if ( ! r ) return ""
1027+ const baseMessage = message ( )
1028+ const truncatedHint = isTruncated ( ) ? " (click to expand)" : ""
1029+ const retryInfo = ` [retrying ${ seconds ( ) > 0 ? `in ${ seconds ( ) } s ` : "" } attempt #${ r . attempt } ]`
1030+ return baseMessage + truncatedHint + retryInfo
1031+ }
9831032
984- return (
985- < Show when = { retry ( ) } >
986- < box onMouseUp = { handleMessageClick } >
987- < text fg = { theme . error } > { retryText ( ) } </ text >
988- </ box >
989- </ Show >
990- )
991- } ) ( ) }
1033+ return (
1034+ < Show when = { retry ( ) } >
1035+ < box onMouseUp = { handleMessageClick } >
1036+ < text fg = { theme . error } > { retryText ( ) } </ text >
1037+ </ box >
1038+ </ Show >
1039+ )
1040+ } ) ( ) }
1041+ </ box >
9921042 </ box >
1043+ < text fg = { store . interrupt > 0 ? theme . primary : theme . text } >
1044+ esc{ " " }
1045+ < span style = { { fg : store . interrupt > 0 ? theme . primary : theme . textMuted } } >
1046+ { store . interrupt > 0 ? "again to interrupt" : "interrupt" }
1047+ </ span >
1048+ </ text >
9931049 </ box >
994- < text fg = { store . interrupt > 0 ? theme . primary : theme . text } >
995- esc{ " " }
996- < span style = { { fg : store . interrupt > 0 ? theme . primary : theme . textMuted } } >
997- { store . interrupt > 0 ? "again to interrupt" : "interrupt" }
998- </ span >
999- </ text >
1000- </ box >
1001- </ Show >
1002- < Show when = { status ( ) . type !== "retry" } >
1003- < box gap = { 2 } flexDirection = "row" >
1004- < Switch >
1005- < Match when = { store . mode === "normal" } >
1050+ </ Show >
1051+ < Show when = { ! props . sessionID && status ( ) . type === "idle" && shortcutsVisible ( ) } >
1052+ < box flexDirection = "row" justifyContent = "flex-end" flexGrow = { 1 } >
1053+ < box gap = { 2 } flexDirection = "row" >
10061054 < text fg = { theme . text } >
10071055 { keybind . print ( "agent_cycle" ) } < span style = { { fg : theme . textMuted } } > switch agent</ span >
10081056 </ text >
10091057 < text fg = { theme . text } >
10101058 { keybind . print ( "command_list" ) } < span style = { { fg : theme . textMuted } } > commands</ span >
10111059 </ text >
1012- </ Match >
1013- < Match when = { store . mode === "shell" } >
1060+ </ box >
1061+ </ box >
1062+ </ Show >
1063+ < Show when = { props . sessionID && props . footerVisible && status ( ) . type === "idle" && shortcutsVisible ( ) } >
1064+ < box flexDirection = "row" justifyContent = "flex-end" flexGrow = { 1 } >
1065+ < box gap = { 2 } flexDirection = "row" >
10141066 < text fg = { theme . text } >
1015- esc < span style = { { fg : theme . textMuted } } > exit shell mode </ span >
1067+ { keybind . print ( "agent_cycle" ) } < span style = { { fg : theme . textMuted } } > switch agent </ span >
10161068 </ text >
1017- </ Match >
1018- </ Switch >
1019- </ box >
1020- </ Show >
1021- </ box >
1069+ < text fg = { theme . text } >
1070+ { keybind . print ( "command_list" ) } < span style = { { fg : theme . textMuted } } > commands</ span >
1071+ </ text >
1072+ </ box >
1073+ </ box >
1074+ </ Show >
1075+ </ box >
1076+ </ Show >
10221077 </ box >
10231078 </ >
10241079 )
0 commit comments