@@ -2,29 +2,16 @@ import { useSync } from "@tui/context/sync"
22import { createMemo , For , Show , Switch , Match } from "solid-js"
33import { createStore } from "solid-js/store"
44import { useTheme } from "../../context/theme"
5- import { formatDuration } from "@/util/format"
5+ import { Locale } from "@/util/locale"
6+ import path from "path"
67import type { AssistantMessage } from "@opencode-ai/sdk/v2"
8+ import { Global } from "@/global"
79import { Installation } from "@/installation"
10+ import { useKeybind } from "../../context/keybind"
811import { useDirectory } from "../../context/directory"
912import { useKV } from "../../context/kv"
1013import { TodoItem } from "../../component/todo-item"
11- import { createRunningState } from "../../util/running"
12-
13- function RunningToolItem ( props : { command : string ; startTime : number ; now : number } ) {
14- const { theme } = useTheme ( )
15-
16- return (
17- < box flexDirection = "row" gap = { 1 } >
18- < text flexShrink = { 0 } fg = { theme . warning } >
19- ●
20- </ text >
21- < text fg = { theme . text } wrapMode = "none" >
22- { props . command }
23- < span style = { { fg : theme . textMuted } } > { formatDuration ( Math . floor ( ( props . now - props . startTime ) / 1000 ) ) } </ span >
24- </ text >
25- </ box >
26- )
27- }
14+ import { createRunningState , RunningItemView } from "../../util/running.tsx"
2815
2916export function Sidebar ( props : { sessionID : string ; overlay ?: boolean } ) {
3017 const sync = useSync ( )
@@ -34,7 +21,7 @@ export function Sidebar(props: { sessionID: string; overlay?: boolean }) {
3421 const todo = createMemo ( ( ) => sync . data . todo [ props . sessionID ] ?? [ ] )
3522 const messages = createMemo ( ( ) => sync . data . message [ props . sessionID ] ?? [ ] )
3623
37- const { tick, runningTools , inferenceStatus } = createRunningState ( ( ) => props . sessionID , sync . data )
24+ const { tick, runningItems } = createRunningState ( ( ) => props . sessionID , sync . data )
3825
3926 const [ expanded , setExpanded ] = createStore ( {
4027 mcp : true ,
@@ -113,88 +100,12 @@ export function Sidebar(props: { sessionID: string; overlay?: boolean }) {
113100 < text fg = { theme . textMuted } > { context ( ) ?. percentage ?? 0 } % used</ text >
114101 < text fg = { theme . textMuted } > { cost ( ) } spent</ text >
115102 </ box >
116- < Show when = { runningTools ( ) . length > 0 || inferenceStatus ( ) } >
103+ < Show when = { runningItems ( ) . length > 0 } >
117104 < box >
118105 < text fg = { theme . text } >
119106 < b > Running</ b >
120107 </ text >
121- < Show when = { inferenceStatus ( ) } >
122- { ( status ) => (
123- < Switch >
124- < Match when = { status ( ) . type === "sending" } >
125- < box flexDirection = "row" gap = { 1 } >
126- < text flexShrink = { 0 } fg = { theme . warning } >
127- ●
128- </ text >
129- < text fg = { theme . text } wrapMode = "none" >
130- Sending...
131- < span style = { { fg : theme . textMuted } } >
132- { " " }
133- { formatDuration (
134- Math . floor (
135- ( tick ( ) - ( status ( ) as { type : "sending" ; startTime : number } ) . startTime ) / 1000 ,
136- ) ,
137- ) }
138- </ span >
139- </ text >
140- </ box >
141- </ Match >
142- < Match when = { status ( ) . type === "pondering" } >
143- < box flexDirection = "row" gap = { 1 } >
144- < text flexShrink = { 0 } fg = { theme . warning } >
145- ●
146- </ text >
147- < text fg = { theme . text } wrapMode = "none" >
148- Pondering...
149- < span style = { { fg : theme . textMuted } } >
150- { " " }
151- { formatDuration (
152- Math . floor (
153- ( tick ( ) - ( status ( ) as { type : "pondering" ; startTime : number } ) . startTime ) / 1000 ,
154- ) ,
155- ) }
156- </ span >
157- </ text >
158- </ box >
159- </ Match >
160- < Match when = { status ( ) . type === "streaming" } >
161- < box flexDirection = "row" gap = { 1 } >
162- < text flexShrink = { 0 } fg = { theme . warning } >
163- ●
164- </ text >
165- < text fg = { theme . text } wrapMode = "none" >
166- Streaming...
167- < span style = { { fg : theme . textMuted } } >
168- { " " }
169- { formatDuration (
170- Math . floor (
171- ( tick ( ) - ( status ( ) as { type : "streaming" ; startTime : number } ) . startTime ) / 1000 ,
172- ) ,
173- ) }
174- </ span >
175- </ text >
176- </ box >
177- </ Match >
178- < Match when = { status ( ) . type === "retry" } >
179- < box flexDirection = "row" gap = { 1 } >
180- < text flexShrink = { 0 } fg = { theme . warning } >
181- ●
182- </ text >
183- < text fg = { theme . text } wrapMode = "none" >
184- Retrying in { ( status ( ) as { type : "retry" ; message : string ; remaining : number } ) . remaining } s
185- < span style = { { fg : theme . textMuted } } >
186- { " " }
187- ({ ( status ( ) as { type : "retry" ; message : string ; remaining : number } ) . message } )
188- </ span >
189- </ text >
190- </ box >
191- </ Match >
192- </ Switch >
193- ) }
194- </ Show >
195- < For each = { runningTools ( ) } >
196- { ( item ) => < RunningToolItem command = { item . command } startTime = { item . startTime } now = { tick ( ) } /> }
197- </ For >
108+ < For each = { runningItems ( ) } > { ( item ) => < RunningItemView item = { item } now = { tick ( ) } /> } </ For >
198109 </ box >
199110 </ Show >
200111 < Show when = { mcpEntries ( ) . length > 0 } >
0 commit comments