Skip to content

Commit 1f103b7

Browse files
committed
Revert unnecessary changes
1 parent 9fb83ba commit 1f103b7

File tree

10 files changed

+50
-34
lines changed

10 files changed

+50
-34
lines changed

evals/packages/types/src/roo-code.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,7 @@ export const isGlobalStateKey = (key: string): key is Keys<GlobalState> =>
758758
export const clineAsks = [
759759
"followup",
760760
"command",
761+
"command_output",
761762
"completion_result",
762763
"tool",
763764
"api_req_failed",

src/core/tools/attemptCompletionTool.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,13 @@ export async function attemptCompletionTool(
7676
}
7777

7878
// Complete command message.
79-
const executionId = Date.now().toString()
80-
const didApprove = await askApproval("command", command, { id: executionId })
79+
const didApprove = await askApproval("command", command)
8180

8281
if (!didApprove) {
8382
return
8483
}
8584

85+
const executionId = cline.lastMessageTs?.toString() ?? Date.now().toString()
8686
const options: ExecuteCommandOptions = { executionId, command }
8787
const [userRejected, execCommandResult] = await executeCommand(cline, options)
8888

src/core/tools/executeCommandTool.ts

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { ToolUse, AskApproval, HandleError, PushToolResult, RemoveClosingTag, To
99
import { formatResponse } from "../prompts/responses"
1010
import { unescapeHtmlEntities } from "../../utils/text-normalization"
1111
import { telemetryService } from "../../services/telemetry/TelemetryService"
12-
import { ExitCodeDetails, RooTerminalCallbacks } from "../../integrations/terminal/types"
12+
import { ExitCodeDetails, RooTerminalCallbacks, RooTerminalProcess } from "../../integrations/terminal/types"
1313
import { TerminalRegistry } from "../../integrations/terminal/TerminalRegistry"
1414
import { Terminal } from "../../integrations/terminal/Terminal"
1515

@@ -56,7 +56,6 @@ export async function executeCommandTool(
5656
}
5757

5858
const executionId = cline.lastMessageTs?.toString() ?? Date.now().toString()
59-
6059
const clineProvider = await cline.providerRef.deref()
6160
const clineProviderState = await clineProvider?.getState()
6261
const { terminalOutputLineLimit = 500, terminalShellIntegrationDisabled = false } = clineProviderState ?? {}
@@ -141,6 +140,7 @@ export async function executeCommand(
141140
}
142141

143142
let message: { text?: string; images?: string[] } | undefined
143+
let runInBackground = false
144144
let completed = false
145145
let result: string = ""
146146
let exitDetails: ExitCodeDetails | undefined
@@ -150,9 +150,23 @@ export async function executeCommand(
150150
const clineProvider = await cline.providerRef.deref()
151151

152152
const callbacks: RooTerminalCallbacks = {
153-
onLine: async (output: string) => {
153+
onLine: async (output: string, process: RooTerminalProcess) => {
154154
const status: CommandExecutionStatus = { executionId, status: "output", output }
155155
clineProvider?.postMessageToWebview({ type: "commandExecutionStatus", text: JSON.stringify(status) })
156+
157+
if (runInBackground) {
158+
return
159+
}
160+
161+
try {
162+
const { response, text, images } = await cline.ask("command_output", "")
163+
runInBackground = true
164+
165+
if (response === "messageResponse") {
166+
message = { text, images }
167+
process.continue()
168+
}
169+
} catch (_error) {}
156170
},
157171
onCompleted: (output: string | undefined) => {
158172
result = Terminal.compressTerminalOutput(output ?? "", terminalOutputLineLimit)
@@ -163,9 +177,6 @@ export async function executeCommand(
163177
console.log(`[executeCommand] onShellExecutionStarted: ${pid}`)
164178
const status: CommandExecutionStatus = { executionId, status: "started", pid, command }
165179
clineProvider?.postMessageToWebview({ type: "commandExecutionStatus", text: JSON.stringify(status) })
166-
// This `command_output` message tells the webview to render the
167-
// appropriate primary and secondary buttons.
168-
cline.say("command_output", "")
169180
},
170181
onShellExecutionComplete: (details: ExitCodeDetails) => {
171182
const status: CommandExecutionStatus = { executionId, status: "exited", exitCode: details.exitCode }
@@ -205,7 +216,8 @@ export async function executeCommand(
205216
// Wait for a short delay to ensure all messages are sent to the webview.
206217
// This delay allows time for non-awaited promises to be created and
207218
// for their associated messages to be sent to the webview, maintaining
208-
// the correct order of messages.
219+
// the correct order of messages (although the webview is smart about
220+
// grouping command_output messages despite any gaps anyways).
209221
await delay(50)
210222

211223
if (message) {

src/core/webview/webviewMessageHandler.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,7 @@ export const webviewMessageHandler = async (provider: ClineProvider, message: We
184184
await provider.postStateToWebview()
185185
break
186186
case "askResponse":
187-
const instance = provider.getCurrentCline()
188-
console.log("askResponse ->", message, !!instance)
189-
instance?.handleWebviewAskResponse(message.askResponse!, message.text, message.images)
187+
provider.getCurrentCline()?.handleWebviewAskResponse(message.askResponse!, message.text, message.images)
190188
break
191189
case "terminalOperation":
192190
if (message.terminalOperation) {

src/exports/roo-code.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ type ClineMessage = {
305305
| (
306306
| "followup"
307307
| "command"
308+
| "command_output"
308309
| "completion_result"
309310
| "tool"
310311
| "api_req_failed"
@@ -352,7 +353,6 @@ type ClineMessage = {
352353
| undefined
353354
progressStatus?:
354355
| {
355-
id?: string | undefined
356356
icon?: string | undefined
357357
text?: string | undefined
358358
}
@@ -380,6 +380,7 @@ type RooCodeEvents = {
380380
| (
381381
| "followup"
382382
| "command"
383+
| "command_output"
383384
| "completion_result"
384385
| "tool"
385386
| "api_req_failed"
@@ -427,7 +428,6 @@ type RooCodeEvents = {
427428
| undefined
428429
progressStatus?:
429430
| {
430-
id?: string | undefined
431431
icon?: string | undefined
432432
text?: string | undefined
433433
}

src/exports/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ type ClineMessage = {
310310
| (
311311
| "followup"
312312
| "command"
313+
| "command_output"
313314
| "completion_result"
314315
| "tool"
315316
| "api_req_failed"
@@ -357,7 +358,6 @@ type ClineMessage = {
357358
| undefined
358359
progressStatus?:
359360
| {
360-
id?: string | undefined
361361
icon?: string | undefined
362362
text?: string | undefined
363363
}
@@ -389,6 +389,7 @@ type RooCodeEvents = {
389389
| (
390390
| "followup"
391391
| "command"
392+
| "command_output"
392393
| "completion_result"
393394
| "tool"
394395
| "api_req_failed"
@@ -436,7 +437,6 @@ type RooCodeEvents = {
436437
| undefined
437438
progressStatus?:
438439
| {
439-
id?: string | undefined
440440
icon?: string | undefined
441441
text?: string | undefined
442442
}

src/schemas/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -767,6 +767,7 @@ export const isGlobalStateKey = (key: string): key is Keys<GlobalState> =>
767767
export const clineAsks = [
768768
"followup",
769769
"command",
770+
"command_output",
770771
"completion_result",
771772
"tool",
772773
"api_req_failed",
@@ -816,7 +817,6 @@ export type ClineSay = z.infer<typeof clineSaySchema>
816817
*/
817818

818819
export const toolProgressStatusSchema = z.object({
819-
id: z.string().optional(),
820820
icon: z.string().optional(),
821821
text: z.string().optional(),
822822
})

src/shared/__tests__/combineCommandSequences.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,20 @@ const messages: ClineMessage[] = [
2121
},
2222
{ ts: 1745710930748, type: "ask", ask: "command", text: "ping www.google.com", partial: false },
2323
{ ts: 1745710930894, type: "say", say: "command_output", text: "", images: undefined },
24+
{ ts: 1745710930894, type: "ask", ask: "command_output", text: "" },
2425
{
2526
ts: 1745710930954,
2627
type: "say",
2728
say: "command_output",
2829
text: "PING www.google.com (142.251.46.228): 56 data bytes\n",
2930
images: undefined,
3031
},
32+
{
33+
ts: 1745710930954,
34+
type: "ask",
35+
ask: "command_output",
36+
text: "PING www.google.com (142.251.46.228): 56 data bytes\n",
37+
},
3138
]
3239

3340
describe("combineCommandSequences", () => {

src/shared/combineCommandSequences.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export function combineCommandSequences(messages: ClineMessage[]): ClineMessage[
3939
break // Stop if we encounter the next command.
4040
}
4141

42-
if (say === "command_output") {
42+
if (ask === "command_output" || say === "command_output") {
4343
if (!previous) {
4444
combinedText += `\n${COMMAND_OUTPUT_STRING}`
4545
}
@@ -68,7 +68,7 @@ export function combineCommandSequences(messages: ClineMessage[]): ClineMessage[
6868
// Second pass: remove command_outputs and replace original commands with
6969
// combined ones.
7070
return messages
71-
.filter((msg) => msg.say !== "command_output")
71+
.filter((msg) => !(msg.ask === "command_output" || msg.say === "command_output"))
7272
.map((msg) => {
7373
if (msg.type === "ask" && msg.ask === "command") {
7474
return combinedCommands.find((cmd) => cmd.ts === msg.ts) || msg

webview-ui/src/components/chat/ChatView.tsx

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
116116
const [selectedImages, setSelectedImages] = useState<string[]>([])
117117

118118
// we need to hold on to the ask because useEffect > lastMessage will always let us know when an ask comes in and handle it, but by the time handleMessage is called, the last message might not be the ask anymore (it could be a say that followed)
119-
const [clineAsk, setClineAsk] = useState<ClineAsk | "command_output" | undefined>(undefined)
119+
const [clineAsk, setClineAsk] = useState<ClineAsk | undefined>(undefined)
120120
const [enableButtons, setEnableButtons] = useState<boolean>(false)
121121
const [primaryButtonText, setPrimaryButtonText] = useState<string | undefined>(undefined)
122122
const [secondaryButtonText, setSecondaryButtonText] = useState<string | undefined>(undefined)
@@ -229,6 +229,13 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
229229
setPrimaryButtonText(t("chat:runCommand.title"))
230230
setSecondaryButtonText(t("chat:reject.title"))
231231
break
232+
case "command_output":
233+
setTextAreaDisabled(false)
234+
setClineAsk("command_output")
235+
setEnableButtons(true)
236+
setPrimaryButtonText(t("chat:proceedWhileRunning.title"))
237+
setSecondaryButtonText(t("chat:killCommand.title"))
238+
break
232239
case "use_mcp_server":
233240
if (!isAutoApproved(lastMessage) && !isPartial) {
234241
playSound("notification")
@@ -282,8 +289,8 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
282289
setTextAreaDisabled(true)
283290
break
284291
case "api_req_started":
285-
if (secondLastMessage?.ask === "command") {
286-
// If the last ask is a command, and we
292+
if (secondLastMessage?.ask === "command_output") {
293+
// If the last ask is a command_output, and we
287294
// receive an api_req_started, then that means
288295
// the command has finished and we don't need
289296
// input from the user anymore (in every other
@@ -297,18 +304,12 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
297304
setEnableButtons(false)
298305
}
299306
break
300-
case "command_output":
301-
setTextAreaDisabled(false)
302-
setClineAsk("command_output")
303-
setEnableButtons(true)
304-
setPrimaryButtonText(t("chat:proceedWhileRunning.title"))
305-
setSecondaryButtonText(t("chat:killCommand.title"))
306-
break
307307
case "api_req_finished":
308308
case "error":
309309
case "text":
310310
case "browser_action":
311311
case "browser_action_result":
312+
case "command_output":
312313
case "mcp_server_request_started":
313314
case "mcp_server_response":
314315
case "completion_result":
@@ -398,6 +399,7 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
398399
case "tool":
399400
case "browser_action_launch":
400401
case "command": // User can provide feedback to a tool or command use.
402+
case "command_output": // User can send input to command stdin.
401403
case "use_mcp_server":
402404
case "completion_result": // If this happens then the user has feedback for the completion result.
403405
case "resume_task":
@@ -439,8 +441,6 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
439441
(text?: string, images?: string[]) => {
440442
const trimmedInput = text?.trim()
441443

442-
console.log(`handlePrimaryButtonClick -> clineAsk=${clineAsk}`, text)
443-
444444
switch (clineAsk) {
445445
case "api_req_failed":
446446
case "command":
@@ -521,7 +521,6 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
521521
vscode.postMessage({ type: "terminalOperation", terminalOperation: "abort" })
522522
break
523523
}
524-
525524
setTextAreaDisabled(true)
526525
setClineAsk(undefined)
527526
setEnableButtons(false)
@@ -750,8 +749,7 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
750749
return alwaysAllowExecute && isAllowedCommand(message)
751750
}
752751

753-
// For read/write operations, check if it's outside workspace and
754-
// if we have permission for that.
752+
// For read/write operations, check if it's outside workspace and if we have permission for that
755753
if (message.ask === "tool") {
756754
let tool: any = {}
757755

0 commit comments

Comments
 (0)