-
Notifications
You must be signed in to change notification settings - Fork 3.1k
fix(vscode): start Agent Manager terminals instantly #12866
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "kilo-code": patch | ||
| --- | ||
|
|
||
| Accept terminal input immediately while the Agent Manager shell starts. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
146 changes: 146 additions & 0 deletions
146
packages/kilo-vscode/tests/unit/agent-manager-terminal-replay.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,146 @@ | ||
| import { describe, expect, it } from "bun:test" | ||
| import { createInputBuffer, createReplayGate } from "../../webview-ui/agent-manager/terminal/replay" | ||
|
|
||
| describe("Agent Manager terminal input buffer", () => { | ||
| it("sends parser replies first while preserving user input order", () => { | ||
| const input = createInputBuffer() | ||
| input.add("early ") | ||
| input.add("reply", true) | ||
| input.add("command\r") | ||
|
|
||
| expect(input.take()).toBe("replyearly command\r") | ||
| expect(input.take()).toBe("") | ||
| }) | ||
|
|
||
| it("caps user input and protocol replies independently", () => { | ||
| const input = createInputBuffer(4) | ||
| input.add("12345") | ||
| input.add("abcde", true) | ||
|
|
||
| expect(input.take()).toBe("bcde2345") | ||
| }) | ||
| }) | ||
|
|
||
| describe("Agent Manager terminal replay gate", () => { | ||
| it("flushes initial input only after replay parsing completes", () => { | ||
| const events: string[] = [] | ||
| let complete: (() => void) | undefined | ||
| const gate = createReplayGate({ | ||
| write: (data, callback) => { | ||
| events.push(typeof data === "string" ? data : `bytes:${data.join(",")}`) | ||
| if (callback) complete = callback | ||
| }, | ||
| flush: () => events.push("flush"), | ||
| }) | ||
|
|
||
| gate.attach(false) | ||
| expect(gate.blocked()).toBe(true) | ||
| gate.output("replay") | ||
| gate.output(new Uint8Array([1, 2, 3])) | ||
| expect(events).toEqual([]) | ||
| expect(gate.frame(new Uint8Array([0, 123, 125]))).toBe(true) | ||
| expect(gate.blocked()).toBe(true) | ||
| expect(gate.draining()).toBe(true) | ||
| expect(events).toEqual(["replay", "bytes:1,2,3", ""]) | ||
|
|
||
| complete?.() | ||
| expect(gate.blocked()).toBe(false) | ||
| expect(gate.draining()).toBe(false) | ||
| expect(events).toEqual(["replay", "bytes:1,2,3", "", "flush"]) | ||
| }) | ||
|
|
||
| it("leaves reconnect input on the output-settle path", () => { | ||
| const events: string[] = [] | ||
| const gate = createReplayGate({ | ||
| write: () => events.push("write"), | ||
| flush: () => events.push("flush"), | ||
| }) | ||
|
|
||
| gate.attach(true) | ||
| expect(gate.blocked()).toBe(false) | ||
| expect(gate.draining()).toBe(false) | ||
| gate.output("live") | ||
| expect(gate.frame(new Uint8Array([0]))).toBe(true) | ||
| expect(events).toEqual(["write"]) | ||
| }) | ||
|
|
||
| it("consumes only one initial replay boundary", () => { | ||
| let drains = 0 | ||
| const gate = createReplayGate({ | ||
| write: (_data, callback) => { | ||
| if (callback) drains++ | ||
| }, | ||
| flush: () => undefined, | ||
| }) | ||
|
|
||
| gate.attach(false) | ||
| expect(gate.frame(new Uint8Array())).toBe(false) | ||
| expect(gate.frame(new Uint8Array([0]))).toBe(true) | ||
| expect(gate.frame(new Uint8Array([0]))).toBe(true) | ||
| expect(drains).toBe(1) | ||
| }) | ||
|
|
||
| it("ignores an initial parse callback after reconnect starts", () => { | ||
| let complete: (() => void) | undefined | ||
| let flushed = 0 | ||
| const gate = createReplayGate({ | ||
| write: (_data, callback) => { | ||
| if (callback) complete = callback | ||
| }, | ||
| flush: () => flushed++, | ||
| }) | ||
|
|
||
| gate.attach(false) | ||
| gate.frame(new Uint8Array([0])) | ||
| gate.attach(true) | ||
| complete?.() | ||
|
|
||
| expect(gate.blocked()).toBe(false) | ||
| expect(flushed).toBe(0) | ||
| }) | ||
|
|
||
| it("lets terminal replies pass while queued replay parses before user input flushes", () => { | ||
| const events: string[] = [] | ||
| let complete: (() => void) | undefined | ||
| const gate = createReplayGate({ | ||
| write: (data, callback) => { | ||
| events.push(String(data)) | ||
| if (callback) complete = callback | ||
| }, | ||
| flush: () => events.push("flush"), | ||
| }) | ||
|
|
||
| gate.attach(false) | ||
| expect(gate.blocked()).toBe(true) | ||
| gate.output("replay") | ||
| gate.frame(new Uint8Array([0])) | ||
| expect(gate.blocked()).toBe(true) | ||
| expect(gate.draining()).toBe(true) | ||
| gate.output("terminal-reply") | ||
| expect(events).toEqual(["replay", "", "terminal-reply"]) | ||
| expect(complete).toBeFunction() | ||
| complete?.() | ||
| expect(gate.blocked()).toBe(false) | ||
| expect(gate.draining()).toBe(false) | ||
| expect(events).toEqual(["replay", "", "terminal-reply", "flush"]) | ||
| }) | ||
|
|
||
| it("keeps user input blocked for the complete parser-drain window", () => { | ||
| let complete: (() => void) | undefined | ||
| const gate = createReplayGate({ | ||
| write: (_data, callback) => { | ||
| if (callback) complete = callback | ||
| }, | ||
| flush: () => undefined, | ||
| }) | ||
|
|
||
| gate.attach(false) | ||
| gate.frame(new Uint8Array([0])) | ||
| expect(gate.blocked()).toBe(true) | ||
| expect(gate.draining()).toBe(true) | ||
|
|
||
| complete?.() | ||
| expect(gate.blocked()).toBe(false) | ||
| expect(gate.draining()).toBe(false) | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SUGGESTION: The
createdocstring is now staleWith this new parameter, the terminal ID is generated by the webview and echoed back, but the docstring above still says "Returns the attach info the webview needs: our synthetic terminal ID, …". Suggest updating it to note the ID is caller-supplied (e.g. "the webview-supplied logical terminal ID, echoed back").
Reply with
@kilocode-bot fix itto have Kilo Code address this issue.