Skip to content

Commit

Permalink
Revert "V1 new client extension API, for inline edits + document code (
Browse files Browse the repository at this point in the history
…#3445)"

This reverts commit 5356bb5.

This is missing code review feedback which went to
stevey/extension-client-api branch.
  • Loading branch information
dominiccooney committed Mar 21, 2024
1 parent 9036dbf commit 2c7c8e8
Show file tree
Hide file tree
Showing 33 changed files with 501 additions and 874 deletions.
7 changes: 0 additions & 7 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,6 @@
"outFiles": ["${workspaceFolder}/vscode/dist/**/*.js"],
"args": ["--extensionDevelopmentPath=${workspaceRoot}/vscode", "--extensionDevelopmentKind=web"]
},
{
"name": "Attach to Agent",
"port": 9229,
"request": "attach",
"skipFiles": ["<node_internals>/**"],
"type": "node"
},
{
"type": "node",
"request": "launch",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,8 @@ interface CodyAgentClient {
// =============
@JsonNotification("debug/message")
fun debug_message(params: DebugMessage)
@JsonNotification("editTask/didUpdate")
fun editTask_didUpdate(params: EditTask)
@JsonNotification("editTask/didDelete")
fun editTask_didDelete(params: EditTask)
@JsonNotification("editTaskState/didChange")
fun editTaskState_didChange(params: EditTask)
@JsonNotification("codeLenses/display")
fun codeLenses_display(params: DisplayCodeLensParams)
@JsonNotification("webview/postMessage")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,10 @@ interface CodyAgentServer {
fun commands_smell(params: Null): CompletableFuture<String>
@JsonRequest("commands/custom")
fun commands_custom(params: Commands_CustomParams): CompletableFuture<CustomCommandResult>
@JsonRequest("editCommands/code")
fun editCommands_code(params: EditCommands_CodeParams): CompletableFuture<EditTask>
@JsonRequest("editCommands/test")
fun editCommands_test(params: Null): CompletableFuture<EditTask>
@JsonRequest("commands/document")
fun commands_document(params: Null): CompletableFuture<EditTask>
@JsonRequest("editTask/accept")
fun editTask_accept(params: FixupTaskID): CompletableFuture<Null>
@JsonRequest("editTask/undo")
fun editTask_undo(params: FixupTaskID): CompletableFuture<Null>
@JsonRequest("editTask/cancel")
fun editTask_cancel(params: FixupTaskID): CompletableFuture<Null>
@JsonRequest("editTask/getFoldingRanges")
fun editTask_getFoldingRanges(params: GetFoldingRangeParams): CompletableFuture<GetFoldingRangeResult>
@JsonRequest("command/execute")
fun command_execute(params: ExecuteCommandParams): CompletableFuture<Any>
@JsonRequest("autocomplete/execute")
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@ data class EditTask(
val id: String? = null,
val state: CodyTaskState? = null,
val error: CodyError? = null,
val selectionRange: Range? = null,
)

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion agent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"build": "pnpm run build:root && pnpm run build:agent",
"build-minify": "pnpm run build --minify",
"agent": "pnpm run build && node dist/index.js",
"agent:debug": "pnpm run build && CODY_AGENT_TRACE_PATH=/tmp/agent.json CODY_AGENT_DEBUG_REMOTE=true node --enable-source-maps ./dist/index.js",
"agent:debug": "pnpm run build && node --inspect --enable-source-maps ./dist/index.js",
"build-ts": "tsc --build",
"build-agent-binaries": "pnpm run build && pkg --compress GZip --no-bytecode --public-packages \"*\" --public . --out-path ${AGENT_EXECUTABLE_TARGET_DIRECTORY:-dist}",
"test-agent-binary": "esbuild ./scripts/test-agent-binary.ts --bundle --platform=node --alias:vscode=./src/vscode-shim.ts --outdir=dist && node ./dist/test-agent-binary.js",
Expand Down
56 changes: 0 additions & 56 deletions agent/src/AgentFixupControls.ts

This file was deleted.

68 changes: 23 additions & 45 deletions agent/src/TestClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -343,52 +343,33 @@ export class TestClient extends MessageHandler {
)
}

let disposables: vscode.Disposable[]
let disposable: vscode.Disposable
return new Promise<void>((resolve, reject) => {
disposables = [
this.onDidUpdateTask(({ id, state, error }) => {
if (id === params.id) {
switch (state) {
case CodyTaskState.applied:
return resolve()
case CodyTaskState.error:
case CodyTaskState.finished:
return reject(
new Error(
`Task reached terminal state before being applied ${JSON.stringify(
{
id,
state: CodyTaskState[state],
error,
}
)}`
)
disposable = this.onDidChangeTaskState(({ id, state, error }) => {
if (id === params.id) {
switch (state) {
case CodyTaskState.applied:
return resolve()
case CodyTaskState.error:
case CodyTaskState.finished:
return reject(
new Error(
`Task reached terminal state before being applied ${JSON.stringify({
id,
state: CodyTaskState[state],
error,
})}`
)
}
)
}
}),
this.onDidDeleteTask(task => {
if (task.id === params.id) {
// Applied tasks can also be deleted, but in that case
// the Promise is already resolved and this is a no-op.
reject(
new Error(`Task was deleted before being applied ${JSON.stringify(task)}`)
)
}
}),
]
}).finally(() => {
for (const disposable of disposables) {
disposable.dispose()
}
})
}
})
}).finally(() => disposable.dispose())
}

public codeLenses = new Map<string, ProtocolCodeLens[]>()
public taskUpdate = new vscode.EventEmitter<EditTask>()
public onDidUpdateTask = this.taskUpdate.event
public taskDelete = new vscode.EventEmitter<EditTask>()
public onDidDeleteTask = this.taskDelete.event
public newTaskState = new vscode.EventEmitter<EditTask>()
public onDidChangeTaskState = this.newTaskState.event
public webviewMessages: WebviewPostMessageParams[] = []
public webviewMessagesEmitter = new vscode.EventEmitter<WebviewPostMessageParams>()

Expand Down Expand Up @@ -435,11 +416,8 @@ export class TestClient extends MessageHandler {
this.connectProcess(this.agentProcess, error => {
console.error(error)
})
this.registerNotification('editTask/didUpdate', params => {
this.taskUpdate.fire(params)
})
this.registerNotification('editTask/didDelete', params => {
this.taskDelete.fire(params)
this.registerNotification('editTaskState/didChange', params => {
this.newTaskState.fire(params)
})

this.registerNotification('webview/postMessage', params => {
Expand Down
Loading

0 comments on commit 2c7c8e8

Please sign in to comment.