@@ -2,7 +2,15 @@ import { render, useKeyboard, useRenderer, useTerminalDimensions } from "@opentu
22import { Clipboard } from "@tui/util/clipboard"
33import { TextAttributes } from "@opentui/core"
44import { RouteProvider , useRoute , type Route } from "@tui/context/route"
5- import { Switch , Match , createEffect , untrack , ErrorBoundary , createMemo , createSignal } from "solid-js"
5+ import {
6+ Switch ,
7+ Match ,
8+ createEffect ,
9+ untrack ,
10+ ErrorBoundary ,
11+ createMemo ,
12+ createSignal ,
13+ } from "solid-js"
614import { Installation } from "@/installation"
715import { Global } from "@/global"
816import { DialogProvider , useDialog } from "@tui/ui/dialog"
@@ -11,11 +19,12 @@ import { SyncProvider, useSync } from "@tui/context/sync"
1119import { LocalProvider , useLocal } from "@tui/context/local"
1220import { DialogModel } from "@tui/component/dialog-model"
1321import { DialogStatus } from "@tui/component/dialog-status"
22+ import { DialogThemeList } from "@tui/component/dialog-theme-list"
1423import { CommandProvider , useCommandDialog } from "@tui/component/dialog-command"
1524import { DialogAgent } from "@tui/component/dialog-agent"
1625import { DialogSessionList } from "@tui/component/dialog-session-list"
1726import { KeybindProvider } from "@tui/context/keybind"
18- import { Theme } from "@tui/context/theme"
27+ import { ThemeProvider , useTheme } from "@tui/context/theme"
1928import { Home } from "@tui/routes/home"
2029import { Session } from "@tui/routes/session"
2130import { PromptHistoryProvider } from "./component/prompt/history"
@@ -24,12 +33,18 @@ import { ToastProvider, useToast } from "./ui/toast"
2433import { ExitProvider } from "./context/exit"
2534import type { SessionRoute } from "./context/route"
2635
27- export async function tui ( input : { url : string ; sessionID ?: string ; model ?: string ; agent ?: string ; onExit ?: ( ) => Promise < void > } ) {
36+ export async function tui ( input : {
37+ url : string
38+ sessionID ?: string
39+ model ?: string
40+ agent ?: string
41+ onExit ?: ( ) => Promise < void >
42+ } ) {
2843 const routeData : Route | undefined = input . sessionID
2944 ? {
30- type : "session" ,
31- sessionID : input . sessionID ,
32- }
45+ type : "session" ,
46+ sessionID : input . sessionID ,
47+ }
3348 : undefined
3449 await render (
3550 ( ) => {
@@ -40,17 +55,19 @@ export async function tui(input: { url: string; sessionID?: string; model?: stri
4055 < RouteProvider data = { routeData } >
4156 < SDKProvider url = { input . url } >
4257 < SyncProvider >
43- < LocalProvider initialModel = { input . model } initialAgent = { input . agent } >
44- < KeybindProvider >
45- < DialogProvider >
46- < CommandProvider >
47- < PromptHistoryProvider >
48- < App />
49- </ PromptHistoryProvider >
50- </ CommandProvider >
51- </ DialogProvider >
52- </ KeybindProvider >
53- </ LocalProvider >
58+ < ThemeProvider >
59+ < LocalProvider initialModel = { input . model } initialAgent = { input . agent } >
60+ < KeybindProvider >
61+ < DialogProvider >
62+ < CommandProvider >
63+ < PromptHistoryProvider >
64+ < App />
65+ </ PromptHistoryProvider >
66+ </ CommandProvider >
67+ </ DialogProvider >
68+ </ KeybindProvider >
69+ </ LocalProvider >
70+ </ ThemeProvider >
5471 </ SyncProvider >
5572 </ SDKProvider >
5673 </ RouteProvider >
@@ -63,7 +80,6 @@ export async function tui(input: { url: string; sessionID?: string; model?: stri
6380 targetFps : 60 ,
6481 gatherStats : false ,
6582 exitOnCtrlC : false ,
66- useKittyKeyboard : true ,
6783 } ,
6884 )
6985}
@@ -80,6 +96,7 @@ function App() {
8096 const sync = useSync ( )
8197 const toast = useToast ( )
8298 const [ sessionExists , setSessionExists ] = createSignal ( false )
99+ const { theme } = useTheme ( )
83100
84101 useKeyboard ( async ( evt ) => {
85102 if ( evt . meta && evt . name === "t" ) {
@@ -97,14 +114,13 @@ function App() {
97114 createEffect ( async ( ) => {
98115 if ( route . data . type === "session" ) {
99116 const data = route . data as SessionRoute
100- await sync . session . sync ( data . sessionID )
101- . catch ( ( ) => {
102- toast . show ( {
103- message : `Session not found: ${ data . sessionID } ` ,
104- type : "error" ,
105- } )
106- return route . navigate ( { type : "home" } )
117+ await sync . session . sync ( data . sessionID ) . catch ( ( ) => {
118+ toast . show ( {
119+ message : `Session not found: ${ data . sessionID } ` ,
120+ type : "error" ,
107121 } )
122+ return route . navigate ( { type : "home" } )
123+ } )
108124 setSessionExists ( true )
109125 }
110126 } )
@@ -182,6 +198,14 @@ function App() {
182198 } ,
183199 category : "System" ,
184200 } ,
201+ {
202+ title : "Switch theme" ,
203+ value : "theme.switch" ,
204+ onSelect : ( ) => {
205+ dialog . replace ( ( ) => < DialogThemeList /> )
206+ } ,
207+ category : "System" ,
208+ } ,
185209 ] )
186210
187211 createEffect ( ( ) => {
@@ -205,7 +229,7 @@ function App() {
205229 < box
206230 width = { dimensions ( ) . width }
207231 height = { dimensions ( ) . height }
208- backgroundColor = { Theme . background }
232+ backgroundColor = { theme . background }
209233 onMouseUp = { async ( ) => {
210234 const text = renderer . getSelection ( ) ?. getSelectedText ( )
211235 if ( text && text . length > 0 ) {
@@ -231,27 +255,36 @@ function App() {
231255 </ box >
232256 < box
233257 height = { 1 }
234- backgroundColor = { Theme . backgroundPanel }
258+ backgroundColor = { theme . backgroundPanel }
235259 flexDirection = "row"
236260 justifyContent = "space-between"
237261 flexShrink = { 0 }
238262 >
239263 < box flexDirection = "row" >
240- < box flexDirection = "row" backgroundColor = { Theme . backgroundElement } paddingLeft = { 1 } paddingRight = { 1 } >
241- < text fg = { Theme . textMuted } > open</ text >
264+ < box
265+ flexDirection = "row"
266+ backgroundColor = { theme . backgroundElement }
267+ paddingLeft = { 1 }
268+ paddingRight = { 1 }
269+ >
270+ < text fg = { theme . textMuted } > open</ text >
242271 < text attributes = { TextAttributes . BOLD } > code </ text >
243- < text fg = { Theme . textMuted } > v{ Installation . VERSION } </ text >
272+ < text fg = { theme . textMuted } > v{ Installation . VERSION } </ text >
244273 </ box >
245274 < box paddingLeft = { 1 } paddingRight = { 1 } >
246- < text fg = { Theme . textMuted } > { process . cwd ( ) . replace ( Global . Path . home , "~" ) } </ text >
275+ < text fg = { theme . textMuted } > { process . cwd ( ) . replace ( Global . Path . home , "~" ) } </ text >
247276 </ box >
248277 </ box >
249278 < box flexDirection = "row" flexShrink = { 0 } >
250- < text fg = { Theme . textMuted } paddingRight = { 1 } >
279+ < text fg = { theme . textMuted } paddingRight = { 1 } >
251280 tab
252281 </ text >
253282 < text fg = { local . agent . color ( local . agent . current ( ) . name ) } > { "" } </ text >
254- < text bg = { local . agent . color ( local . agent . current ( ) . name ) } fg = { Theme . background } wrapMode = "none" >
283+ < text
284+ bg = { local . agent . color ( local . agent . current ( ) . name ) }
285+ fg = { theme . background }
286+ wrapMode = "none"
287+ >
255288 < span style = { { bold : true } } > { local . agent . current ( ) . name . toUpperCase ( ) } </ span >
256289 < span > AGENT </ span >
257290 </ text >
0 commit comments