Repository navigation
chore(ipc): drop the unused @roo-code/ipc client half #2265
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
Open
myk1yt
wants to merge
6
commits into
Zoo-Code-Org:main
Choose a base branch
from
myk1yt:chore/ipc-client-drop
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
6c10e6f
chore(ipc): drop the unused @roo-code/ipc client half
myk1yt 6547456
fix(ipc): reset the frame buffer on close and bound pre-delimiter growth
myk1yt be2acdc
fix(ipc): address CodeRabbit round-2 findings on the eval client
myk1yt bbbef70
test(ipc): wait for the dropped connection, not just the ceiling log
myk1yt 8b5bf9e
fix(ipc): enforce the frame ceiling on delimited frames
myk1yt f5ffe8c
test(ipc): destroy the partial-frame peer only after the write flushes
myk1yt 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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1 @@ | ||
| export * from "./ipc-client.js" | ||
| export * from "./ipc-server.js" |
This file was deleted.
Oops, something went wrong.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| import assert from "node:assert/strict" | ||
| import fs from "node:fs/promises" | ||
| import { createRequire } from "node:module" | ||
| import os from "node:os" | ||
| import path from "node:path" | ||
| import { describe, it } from "node:test" | ||
| import { fileURLToPath, pathToFileURL } from "node:url" | ||
|
|
||
| import { IpcMessageType, IpcOrigin, RooCodeEventName, TaskCommandName, type TaskEvent } from "@roo-code/types" | ||
| import { IpcServer } from "@roo-code/ipc" | ||
| import { EvalIpcClient } from "./ipc-client.ts" | ||
|
|
||
| const repoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../..") | ||
|
|
||
| // IpcServer keeps node-ipc's listening handle open and exposes no stop(), so the | ||
| // suite has to close it or the runner never exits. scripts/ cannot resolve | ||
| // node-ipc itself, and the ESM entry is the singleton IpcServer actually uses, | ||
| // so resolve it through packages/ipc and import that exact module URL. | ||
| const stopListening = async (): Promise<void> => { | ||
| const requireFromIpc = createRequire(path.join(repoRoot, "packages/ipc/package.json")) | ||
| const esmEntry = requireFromIpc.resolve("node-ipc").replace(/node-ipc\.cjs$/, "node-ipc.js") | ||
| const ipc = (await import(pathToFileURL(esmEntry).href)).default as { server: { stop?: () => void } | false } | ||
| ipc.server && ipc.server.stop?.() | ||
| } | ||
|
|
||
| const socketDir = async (): Promise<string> => fs.mkdtemp(path.join(os.tmpdir(), "agent-evals-interop-")) | ||
|
|
||
| const socketPathIn = (dir: string, name: string): string => | ||
| process.platform === "win32" ? `agent-evals-interop-${process.pid}-${name}` : path.join(dir, `${name}.sock`) | ||
|
|
||
| const waitFor = async (check: () => boolean, timeoutMs = 5_000): Promise<void> => { | ||
| const deadline = Date.now() + timeoutMs | ||
| while (!check() && Date.now() < deadline) await new Promise((resolve) => setTimeout(resolve, 20)) | ||
| } | ||
|
|
||
| // The extension runs the real IpcServer, so the launcher client has to speak its | ||
| // exact framing. This suite is the interop gate between the two halves. | ||
| describe("eval ipc client against the real extension server", () => { | ||
| it("handshakes with IpcServer and round-trips a command and a task event", async () => { | ||
| const dir = await socketDir() | ||
| const socketPath = socketPathIn(dir, "interop") | ||
| const server = new IpcServer(socketPath, () => {}) | ||
| const commands: string[] = [] | ||
| const events: TaskEvent[] = [] | ||
|
|
||
| server.on(IpcMessageType.TaskCommand, (clientId, command) => { | ||
| commands.push(command.commandName) | ||
| server.send(clientId, { | ||
| type: IpcMessageType.TaskEvent, | ||
| origin: IpcOrigin.Server, | ||
| data: { eventName: RooCodeEventName.TaskStarted, payload: ["task-1"], taskId: 1 } satisfies TaskEvent, | ||
| }) | ||
| }) | ||
| server.listen() | ||
|
|
||
| const client = new EvalIpcClient(socketPath, () => {}) | ||
| client.on(IpcMessageType.TaskEvent, (event) => events.push(event as TaskEvent)) | ||
|
|
||
| try { | ||
| await waitFor(() => client.isReady) | ||
| assert.equal(client.isReady, true, "client must receive the server ack") | ||
|
|
||
| client.sendCommand({ commandName: TaskCommandName.CloseTask }) | ||
| await waitFor(() => events.length > 0) | ||
|
|
||
| assert.deepEqual(commands, [TaskCommandName.CloseTask]) | ||
| assert.equal(events.length, 1) | ||
| assert.equal(events[0]?.eventName, RooCodeEventName.TaskStarted) | ||
| } finally { | ||
| client.disconnect() | ||
| await stopListening() | ||
| await fs.rm(dir, { recursive: true, force: true }) | ||
| } | ||
| }) | ||
| }) |
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.
Where does
clientIdcome from in this example? The server sends it only in the Ack frame on connect (ipc-server.ts:46-54), and the schema requires it on a TaskCommand. Should the text say to wait for the Ack and use itsclientId, and should the snippet definesocket(for examplenet.connect(path))?