Skip to content

Commit 6c9bfc3

Browse files
committed
feat: show status msg using tool
1 parent 4b1ae3d commit 6c9bfc3

File tree

3 files changed

+27
-4
lines changed

3 files changed

+27
-4
lines changed

electron/src/frontend/lib/services/stateMachineService/stateMachine.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ type ServerEventContext = {
7171
}
7272
gitError: string | null
7373
gitInit: string | null
74+
status: string | null //'idle' | 'thinking' | 'executing' | 'waiting_for_user'
7475
}
7576

7677
export const eventHandlingLogic = fromTransition(
@@ -95,12 +96,13 @@ export const eventHandlingLogic = fromTransition(
9596
return { ...state, ended: true }
9697
}
9798
case 'ModelRequest': {
98-
return { ...state, modelLoading: true }
99+
return { ...state, modelLoading: true, status: 'thinking' }
99100
}
100101
case 'ModelResponse': {
101102
const content = JSON.parse(event.content)
102103
return {
103104
...state,
105+
status: 'idle',
104106
modelLoading: false,
105107
messages: [
106108
...state.messages,
@@ -135,13 +137,16 @@ export const eventHandlingLogic = fromTransition(
135137
case 'ToolRequest': {
136138
return {
137139
...state,
140+
status: 'executing',
141+
toolLoading: true,
138142
toolMessage:
139143
'Running command: ' + event.content.raw_command.trim(),
140144
}
141145
}
142146
case 'Checkpoint': {
143147
return {
144148
...state,
149+
status: 'idle',
145150
messages: [
146151
...state.messages,
147152
{ text: event.content, type: 'checkpoint' } as Message,
@@ -153,6 +158,7 @@ export const eventHandlingLogic = fromTransition(
153158
state.toolMessage + '|START_RESPONSE|' + event.content
154159
return {
155160
...state,
161+
toolLoading: false,
156162
toolMessage: '',
157163
messages: [
158164
...state.messages,
@@ -181,6 +187,7 @@ export const eventHandlingLogic = fromTransition(
181187
case 'UserRequest': {
182188
return {
183189
...state,
190+
status: 'waiting_for_user',
184191
userRequest: true,
185192
messages: [
186193
...state.messages,
@@ -292,6 +299,7 @@ export const eventHandlingLogic = fromTransition(
292299
},
293300
gitError: null,
294301
gitInit: null,
302+
status: 'idle',
295303
}
296304
)
297305

electron/src/frontend/panels/chat/chat-panel.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ export default function Chat({
4848
const eventState = SessionMachineContext.useSelector(
4949
state => state.context.serverEventContext
5050
)
51+
5152
const isPaused = SessionMachineContext.useActorRef()
5253
.getSnapshot()
5354
.matches('paused')

electron/src/frontend/panels/chat/components/input/chat-input-field.tsx

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,16 @@ const ChatInputField = ({
4848
const disableInput = loading || timeTraveling
4949
const prevProjectPath = useRef<string>('')
5050

51-
const [openProjectModal, setOpenProjectModal] = useState(false)
52-
const { backendUrl } = useBackendUrl()
51+
// const [openProjectModal, setOpenProjectModal] = useState(false)
52+
// const { backendUrl } = useBackendUrl()
5353

5454
const sessionActorRef = SessionMachineContext.useActorRef()
5555
const projectPath = SessionMachineContext.useSelector(
5656
state => state?.context?.sessionConfig?.path
5757
)
58+
const status = SessionMachineContext.useSelector(
59+
state => state?.context?.serverEventContext?.status
60+
)
5861

5962
useEffect(() => {
6063
// For autofilling the input field after finished loading (after a revert)
@@ -177,6 +180,7 @@ const ChatInputField = ({
177180
paused={sessionActorRef.getSnapshot().matches('paused')}
178181
pauseHandler={handlePause}
179182
backInTime={Boolean(checkpointTracker?.selected)}
183+
status={status}
180184
/>
181185
)}
182186

@@ -276,13 +280,15 @@ const InformationBox = ({
276280
paused,
277281
pauseHandler,
278282
backInTime,
283+
status,
279284
}: {
280285
modelLoading: boolean
281286
userRequested: boolean
282287
loading: boolean
283288
paused: boolean
284289
pauseHandler: () => void
285290
backInTime: boolean
291+
status: string | null
286292
}) => {
287293
const types: {
288294
[key: string]: {
@@ -314,8 +320,15 @@ const InformationBox = ({
314320
text: 'Devon is time traveling with you...',
315321
accessory: <></>,
316322
},
323+
executing: {
324+
text: 'Devon is using a tool...',
325+
accessory: (
326+
<PauseButton paused={paused} pauseHandler={pauseHandler} />
327+
),
328+
},
317329
error: {
318330
// text: 'Something went wrong',
331+
// text: 'Something unexpected occurred',
319332
text: 'Devon is cleaning up his desk...',
320333
accessory: <></>,
321334
},
@@ -327,12 +340,13 @@ const InformationBox = ({
327340
} else if (backInTime) {
328341
currentType = types.backInTime
329342
} else if (paused) {
330-
// console.log("type is paused")
331343
currentType = types.paused
332344
} else if (modelLoading) {
333345
currentType = types.modelLoading
334346
} else if (userRequested) {
335347
currentType = types.userRequested
348+
} else if (status === 'executing') {
349+
currentType = types.executing
336350
} else {
337351
currentType = types.error
338352
}

0 commit comments

Comments
 (0)