Skip to content

Commit 6082ec2

Browse files
committed
Get rid of VSCodeCommand
1 parent f06cd96 commit 6082ec2

File tree

6 files changed

+25
-86
lines changed

6 files changed

+25
-86
lines changed

benchmark/apps/cli/src/index.ts

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -346,19 +346,14 @@ const runExercise = async ({ run, task, server }: { run: Run; task: Task; server
346346

347347
if (!isClientDisconnected) {
348348
try {
349-
client.sendMessage({
350-
type: IpcMessageType.VSCodeCommand,
351-
origin: IpcOrigin.Client,
352-
clientId: client.clientId!,
353-
data: "workbench.action.files.saveFiles",
354-
})
355-
356-
client.sendMessage({
357-
type: IpcMessageType.VSCodeCommand,
358-
origin: IpcOrigin.Client,
359-
clientId: client.clientId!,
360-
data: "workbench.action.closeWindow",
361-
})
349+
if (rooTaskId) {
350+
client.sendMessage({
351+
type: IpcMessageType.TaskCommand,
352+
origin: IpcOrigin.Client,
353+
clientId: client.clientId!,
354+
data: { commandName: TaskCommandName.CloseTask, data: rooTaskId },
355+
})
356+
}
362357

363358
client.disconnect()
364359
} catch (error) {

benchmark/packages/ipc/src/server.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ type IpcServerEvents = {
1111
[IpcMessageType.Disconnect]: [clientId: string]
1212
[IpcMessageType.TaskCommand]: [clientId: string, data: TaskCommand]
1313
[IpcMessageType.TaskEvent]: [relayClientId: string | undefined, data: TaskEvent]
14-
[IpcMessageType.VSCodeCommand]: [clientId: string, data: string]
1514
}
1615

1716
export class IpcServer extends EventEmitter<IpcServerEvents> {

benchmark/packages/types/src/ipc.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export type Ack = z.infer<typeof ackSchema>
2121
export enum TaskCommandName {
2222
StartNewTask = "StartNewTask",
2323
CancelTask = "CancelTask",
24+
CloseTask = "CloseTask",
2425
}
2526

2627
export const taskCommandSchema = z.discriminatedUnion("commandName", [
@@ -37,6 +38,10 @@ export const taskCommandSchema = z.discriminatedUnion("commandName", [
3738
commandName: z.literal(TaskCommandName.CancelTask),
3839
data: z.string(),
3940
}),
41+
z.object({
42+
commandName: z.literal(TaskCommandName.CloseTask),
43+
data: z.string(),
44+
}),
4045
])
4146

4247
export type TaskCommand = z.infer<typeof taskCommandSchema>
@@ -115,7 +120,6 @@ export enum IpcMessageType {
115120
Ack = "Ack",
116121
TaskCommand = "TaskCommand",
117122
TaskEvent = "TaskEvent",
118-
VSCodeCommand = "VSCodeCommand",
119123
}
120124

121125
export enum IpcOrigin {
@@ -141,12 +145,6 @@ export const ipcMessageSchema = z.discriminatedUnion("type", [
141145
relayClientId: z.string().optional(),
142146
data: taskEventSchema,
143147
}),
144-
z.object({
145-
type: z.literal(IpcMessageType.VSCodeCommand),
146-
origin: z.literal(IpcOrigin.Client),
147-
clientId: z.string(),
148-
data: z.string(),
149-
}),
150148
])
151149

152150
export type IpcMessage = z.infer<typeof ipcMessageSchema>

src/exports/api.ts

Lines changed: 7 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -38,67 +38,20 @@ export class API extends EventEmitter<RooCodeEvents> implements RooCodeAPI {
3838
ipc.on(IpcMessageType.TaskCommand, async (_clientId, { commandName, data }) => {
3939
switch (commandName) {
4040
case TaskCommandName.StartNewTask:
41-
this.log(`[API] StartNewTask -> ${data.text}`)
42-
this.log(`[API] StartNewTask -> ${JSON.stringify(data.configuration)}`)
43-
44-
try {
45-
await this.startNewTask(data)
46-
47-
ipc.broadcast({
48-
type: IpcMessageType.TaskEvent,
49-
origin: IpcOrigin.Server,
50-
data: {
51-
eventName: RooCodeEventName.Message,
52-
payload: [
53-
{
54-
taskId: "[system]",
55-
action: "created",
56-
message: {
57-
ts: Date.now(),
58-
type: "say",
59-
text: `ACK: TaskCommand -> ${commandName}`,
60-
},
61-
},
62-
],
63-
},
64-
})
65-
} catch (error) {
66-
this.log(`[API] error starting new task: ${error}`)
67-
}
68-
41+
this.log(`[API] StartNewTask -> ${data.text}, ${JSON.stringify(data.configuration)}`)
42+
await this.startNewTask(data)
6943
break
7044
case TaskCommandName.CancelTask:
7145
this.log(`[API] CancelTask -> ${data}`)
72-
7346
await this.cancelTask(data)
74-
75-
ipc.broadcast({
76-
type: IpcMessageType.TaskEvent,
77-
origin: IpcOrigin.Server,
78-
data: {
79-
eventName: RooCodeEventName.Message,
80-
payload: [
81-
{
82-
taskId: "[system]",
83-
action: "created",
84-
message: {
85-
ts: Date.now(),
86-
type: "say",
87-
text: `ACK: CancelTask -> ${data}`,
88-
},
89-
},
90-
],
91-
},
92-
})
93-
47+
break
48+
case TaskCommandName.CloseTask:
49+
this.log(`[API] CloseTask -> ${data}`)
50+
await vscode.commands.executeCommand("workbench.action.files.saveFiles")
51+
await vscode.commands.executeCommand("workbench.action.closeWindow")
9452
break
9553
}
9654
})
97-
98-
ipc.on(IpcMessageType.VSCodeCommand, async (_clientId, command) => {
99-
this.log(`[API] VSCodeCommand -> ${command}`)
100-
await vscode.commands.executeCommand(command)
101-
})
10255
}
10356
}
10457

src/exports/ipc.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ type IpcServerEvents = {
1515
[IpcMessageType.Disconnect]: [clientId: string]
1616
[IpcMessageType.TaskCommand]: [clientId: string, data: TaskCommand]
1717
[IpcMessageType.TaskEvent]: [relayClientId: string | undefined, data: TaskEvent]
18-
[IpcMessageType.VSCodeCommand]: [clientId: string, data: string]
1918
}
2019

2120
export class IpcServer extends EventEmitter<IpcServerEvents> {
@@ -99,9 +98,6 @@ export class IpcServer extends EventEmitter<IpcServerEvents> {
9998
case IpcMessageType.TaskCommand:
10099
this.emit(IpcMessageType.TaskCommand, payload.clientId, payload.data)
101100
break
102-
case IpcMessageType.VSCodeCommand:
103-
this.emit(IpcMessageType.VSCodeCommand, payload.clientId, payload.data)
104-
break
105101
default:
106102
throw new Error(`[server#onMessage] unhandled payload: ${JSON.stringify(payload)}`)
107103
break

src/schemas/ipc.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export type Ack = z.infer<typeof ackSchema>
2121
export enum TaskCommandName {
2222
StartNewTask = "StartNewTask",
2323
CancelTask = "CancelTask",
24+
CloseTask = "CloseTask",
2425
}
2526

2627
export const taskCommandSchema = z.discriminatedUnion("commandName", [
@@ -37,6 +38,10 @@ export const taskCommandSchema = z.discriminatedUnion("commandName", [
3738
commandName: z.literal(TaskCommandName.CancelTask),
3839
data: z.string(),
3940
}),
41+
z.object({
42+
commandName: z.literal(TaskCommandName.CloseTask),
43+
data: z.string(),
44+
}),
4045
])
4146

4247
export type TaskCommand = z.infer<typeof taskCommandSchema>
@@ -100,7 +105,6 @@ export enum IpcMessageType {
100105
Ack = "Ack",
101106
TaskCommand = "TaskCommand",
102107
TaskEvent = "TaskEvent",
103-
VSCodeCommand = "VSCodeCommand",
104108
}
105109

106110
export enum IpcOrigin {
@@ -126,12 +130,6 @@ export const ipcMessageSchema = z.discriminatedUnion("type", [
126130
relayClientId: z.string().optional(),
127131
data: taskEventSchema,
128132
}),
129-
z.object({
130-
type: z.literal(IpcMessageType.VSCodeCommand),
131-
origin: z.literal(IpcOrigin.Client),
132-
clientId: z.string(),
133-
data: z.string(),
134-
}),
135133
])
136134

137135
export type IpcMessage = z.infer<typeof ipcMessageSchema>

0 commit comments

Comments
 (0)