1- import {
2- Show ,
3- createEffect ,
4- createMemo ,
5- createSignal ,
6- onCleanup ,
7- onMount ,
8- } from "solid-js" ;
1+ import { Show , createEffect , createMemo , createSignal , onCleanup , onMount } from "solid-js" ;
92import { Cpu , MessageCircle , Server , Settings } from "lucide-solid" ;
103
114import type { OpenworkServerStatus } from "../lib/openwork-server" ;
125import type { OpenCodeRouterStatus } from "../lib/tauri" ;
13- import type { McpStatusMap , StartupPreference } from "../types" ;
6+ import type { McpStatusMap } from "../types" ;
147import { getOpenCodeRouterStatus } from "../lib/tauri" ;
158
169import Button from "./button" ;
1710
1811type StatusBarProps = {
1912 clientConnected : boolean ;
2013 openworkServerStatus : OpenworkServerStatus ;
21- startupPreference : StartupPreference | null ;
2214 developerMode : boolean ;
2315 onOpenSettings : ( ) => void ;
2416 onOpenMessaging : ( ) => void ;
@@ -29,33 +21,8 @@ type StatusBarProps = {
2921} ;
3022
3123export default function StatusBar ( props : StatusBarProps ) {
32- const [ opencodeRouterStatus , setOpenCodeRouterStatus ] =
33- createSignal < OpenCodeRouterStatus | null > ( null ) ;
24+ const [ opencodeRouterStatus , setOpenCodeRouterStatus ] = createSignal < OpenCodeRouterStatus | null > ( null ) ;
3425 const [ documentVisible , setDocumentVisible ] = createSignal ( true ) ;
35- const [ statusDetailOpen , setStatusDetailOpen ] = createSignal ( false ) ;
36- let statusPopoverRef : HTMLDivElement | undefined ;
37- let statusAutoCloseTimer : number | undefined ;
38-
39- const openStatusDetail = ( ) => {
40- setStatusDetailOpen ( true ) ;
41- if ( statusAutoCloseTimer ) window . clearTimeout ( statusAutoCloseTimer ) ;
42- statusAutoCloseTimer = window . setTimeout ( ( ) => setStatusDetailOpen ( false ) , 5000 ) ;
43- } ;
44-
45- const closeStatusDetail = ( ) => {
46- setStatusDetailOpen ( false ) ;
47- if ( statusAutoCloseTimer ) window . clearTimeout ( statusAutoCloseTimer ) ;
48- } ;
49-
50- createEffect ( ( ) => {
51- if ( ! statusDetailOpen ( ) ) return ;
52- const onClick = ( e : MouseEvent ) => {
53- if ( statusPopoverRef ?. contains ( e . target as Node ) ) return ;
54- closeStatusDetail ( ) ;
55- } ;
56- window . addEventListener ( "click" , onClick , true ) ;
57- onCleanup ( ( ) => window . removeEventListener ( "click" , onClick , true ) ) ;
58- } ) ;
5926
6027 const opencodeStatusMeta = createMemo ( ( ) => ( {
6128 dot : props . clientConnected ? "bg-green-9" : "bg-gray-6" ,
@@ -66,59 +33,29 @@ export default function StatusBar(props: StatusBarProps) {
6633 const openworkStatusMeta = createMemo ( ( ) => {
6734 switch ( props . openworkServerStatus ) {
6835 case "connected" :
69- return { dot : "bg-green-9" , text : "text-green-11" , label : "Connected " } ;
36+ return { dot : "bg-green-9" , text : "text-green-11" , label : "Ready " } ;
7037 case "limited" :
71- return {
72- dot : "bg-amber-9" ,
73- text : "text-amber-11" ,
74- label : "Limited access" ,
75- } ;
38+ return { dot : "bg-amber-9" , text : "text-amber-11" , label : "Limited access" } ;
7639 default :
7740 return { dot : "bg-gray-6" , text : "text-gray-10" , label : "Unavailable" } ;
7841 }
7942 } ) ;
8043
81- const unifiedStatusMeta = createMemo ( ( ) => {
82- const allGreen =
83- props . clientConnected && props . openworkServerStatus === "connected" ;
84- return allGreen
85- ? { dot : "bg-green-9" , text : "text-green-11" , label : "Ready" }
86- : { dot : "bg-red-9" , text : "text-red-11" , label : "Unavailable" } ;
87- } ) ;
88-
8944 const messagingMeta = createMemo ( ( ) => {
9045 const status = opencodeRouterStatus ( ) ;
9146 if ( ! status ) {
92- return {
93- dot : "bg-gray-6" ,
94- text : "text-gray-10" ,
95- label : "Messaging bridge unavailable" ,
96- } ;
47+ return { dot : "bg-gray-6" , text : "text-gray-10" , label : "Messaging bridge unavailable" } ;
9748 }
9849 const telegramConfigured = ( status . telegram . items ?. length ?? 0 ) > 0 ;
9950 const slackConfigured = ( status . slack . items ?. length ?? 0 ) > 0 ;
100- const configuredCount = [ telegramConfigured , slackConfigured ] . filter (
101- Boolean ,
102- ) . length ;
51+ const configuredCount = [ telegramConfigured , slackConfigured ] . filter ( Boolean ) . length ;
10352 if ( status . running && configuredCount > 0 ) {
104- return {
105- dot : "bg-green-9" ,
106- text : "text-green-11" ,
107- label : "Messaging bridge ready" ,
108- } ;
53+ return { dot : "bg-green-9" , text : "text-green-11" , label : "Messaging bridge ready" } ;
10954 }
11055 if ( configuredCount > 0 || status . running ) {
111- return {
112- dot : "bg-amber-9" ,
113- text : "text-amber-11" ,
114- label : "Messaging bridge setup" ,
115- } ;
56+ return { dot : "bg-amber-9" , text : "text-amber-11" , label : "Messaging bridge setup" } ;
11657 }
117- return {
118- dot : "bg-gray-6" ,
119- text : "text-gray-10" ,
120- label : "Messaging bridge offline" ,
121- } ;
58+ return { dot : "bg-gray-6" , text : "text-gray-10" , label : "Messaging bridge offline" } ;
12259 } ) ;
12360
12461 type ProTip = {
@@ -128,12 +65,8 @@ export default function StatusBar(props: StatusBarProps) {
12865 action : ( ) => void | Promise < void > ;
12966 } ;
13067
131- const providerConnectedCount = createMemo (
132- ( ) => props . providerConnectedIds ?. length ?? 0 ,
133- ) ;
134- const notionStatus = createMemo (
135- ( ) => props . mcpStatuses ?. notion ?. status ?? "disconnected" ,
136- ) ;
68+ const providerConnectedCount = createMemo ( ( ) => props . providerConnectedIds ?. length ?? 0 ) ;
69+ const notionStatus = createMemo ( ( ) => props . mcpStatuses ?. notion ?. status ?? "disconnected" ) ;
13770
13871 const runAction = ( action ?: ( ) => void | Promise < void > ) => {
13972 if ( ! action ) return ;
@@ -176,9 +109,7 @@ export default function StatusBar(props: StatusBarProps) {
176109 } ,
177110 ] ) ;
178111
179- const availableTips = createMemo < ProTip [ ] > ( ( ) =>
180- proTips ( ) . filter ( ( tip : ProTip ) => tip . enabled ( ) ) ,
181- ) ;
112+ const availableTips = createMemo < ProTip [ ] > ( ( ) => proTips ( ) . filter ( ( tip : ProTip ) => tip . enabled ( ) ) ) ;
182113 const [ activeTip , setActiveTip ] = createSignal < ProTip | null > ( null ) ;
183114 const [ tipVisible , setTipVisible ] = createSignal ( false ) ;
184115 const [ tipCursor , setTipCursor ] = createSignal ( 0 ) ;
@@ -235,8 +166,7 @@ export default function StatusBar(props: StatusBarProps) {
235166
236167 createEffect ( ( ) => {
237168 if ( typeof document === "undefined" ) return ;
238- const update = ( ) =>
239- setDocumentVisible ( document . visibilityState !== "hidden" ) ;
169+ const update = ( ) => setDocumentVisible ( document . visibilityState !== "hidden" ) ;
240170 update ( ) ;
241171 document . addEventListener ( "visibilitychange" , update ) ;
242172 onCleanup ( ( ) => document . removeEventListener ( "visibilitychange" , update ) ) ;
@@ -258,56 +188,29 @@ export default function StatusBar(props: StatusBarProps) {
258188 } ) ;
259189
260190 return (
261- < div class = "border-t border-gray-6 bg-gray-1/90 backdrop-blur-md z-[100] relative " >
191+ < div class = "border-t border-gray-6 bg-gray-1/90 backdrop-blur-md" >
262192 < div class = "px-4 py-2 flex flex-wrap items-center gap-3 text-xs" >
263- < div class = "relative" >
264- < button
265- type = "button"
266- class = "flex items-center gap-2 hover:opacity-80 transition-opacity"
267- title = { `Status: ${ unifiedStatusMeta ( ) . label } ` }
268- onClick = { ( ) => ( statusDetailOpen ( ) ? closeStatusDetail ( ) : openStatusDetail ( ) ) }
269- >
270- < span class = { `w-2 h-2 rounded-full ${ unifiedStatusMeta ( ) . dot } ` } />
271- < span class = { `font-medium ${ unifiedStatusMeta ( ) . text } ` } >
272- { unifiedStatusMeta ( ) . label }
273- </ span >
274- </ button >
275-
276- < Show when = { statusDetailOpen ( ) } >
277- < div
278- ref = { statusPopoverRef }
279- class = "absolute bottom-full left-0 mb-2 z-[200] w-64 rounded-xl border border-gray-6 bg-gray-2 shadow-xl p-3 space-y-3"
280- >
281- < div class = "text-[11px] font-medium text-gray-11 uppercase tracking-wider" >
282- Service Status
283- </ div >
284- < div class = "space-y-2" >
285- < div class = "flex items-center gap-2" >
286- < span
287- class = { `w-2 h-2 rounded-full ${ opencodeStatusMeta ( ) . dot } ` }
288- />
289- < Cpu class = "w-3.5 h-3.5 text-gray-11" />
290- < span class = "text-xs text-gray-12 font-medium" >
291- OpenCode Engine
292- </ span >
293- < span class = { `ml-auto text-xs ${ opencodeStatusMeta ( ) . text } ` } >
294- { opencodeStatusMeta ( ) . label }
295- </ span >
296- </ div >
297- < div class = "flex items-center gap-2" >
298- < span
299- class = { `w-2 h-2 rounded-full ${ openworkStatusMeta ( ) . dot } ` }
300- />
301- < Server class = "w-3.5 h-3.5 text-gray-11" />
302- < span class = "text-xs text-gray-12 font-medium" >
303- { props . startupPreference === "server" ? "Remote Server" : "Local Server" }
304- </ span >
305- < span class = { `ml-auto text-xs ${ openworkStatusMeta ( ) . text } ` } >
306- { openworkStatusMeta ( ) . label }
307- </ span >
308- </ div >
309- </ div >
310- </ div >
193+ < div
194+ class = "flex items-center gap-2"
195+ title = { `OpenCode Engine: ${ opencodeStatusMeta ( ) . label } ` }
196+ >
197+ < span class = { `w-2 h-2 rounded-full ${ opencodeStatusMeta ( ) . dot } ` } />
198+ < Cpu class = "w-4 h-4 text-gray-11" />
199+ < Show when = { props . developerMode || ! props . clientConnected } >
200+ < span class = "text-gray-11 font-medium" > OpenCode</ span >
201+ < span class = { opencodeStatusMeta ( ) . text } > { opencodeStatusMeta ( ) . label } </ span >
202+ </ Show >
203+ </ div >
204+ < div class = "w-px h-4 bg-gray-6/70" />
205+ < div
206+ class = "flex items-center gap-2"
207+ title = { `OpenWork Server: ${ openworkStatusMeta ( ) . label } ` }
208+ >
209+ < span class = { `w-2 h-2 rounded-full ${ openworkStatusMeta ( ) . dot } ` } />
210+ < Server class = "w-4 h-4 text-gray-11" />
211+ < Show when = { props . developerMode || props . openworkServerStatus !== "connected" } >
212+ < span class = "text-gray-11 font-medium" > OpenWork</ span >
213+ < span class = { openworkStatusMeta ( ) . text } > { openworkStatusMeta ( ) . label } </ span >
311214 </ Show >
312215 </ div >
313216 < div class = "ml-auto flex items-center gap-2" >
@@ -319,9 +222,7 @@ export default function StatusBar(props: StatusBarProps) {
319222 title = { activeTip ( ) ?. label }
320223 aria-label = { activeTip ( ) ?. label }
321224 >
322- < span class = "uppercase tracking-[0.2em] text-[10px] text-gray-8" >
323- Tip
324- </ span >
225+ < span class = "uppercase tracking-[0.2em] text-[10px] text-gray-8" > Tip</ span >
325226 < span class = "text-gray-11 font-medium" > { activeTip ( ) ?. label } </ span >
326227 </ button >
327228 </ Show >
0 commit comments