-
Notifications
You must be signed in to change notification settings - Fork 3.1k
feat(cli): advertise spawner instance in remote heartbeat #12506
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
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
4f0df2b
feat(cli): advertise spawner instance in remote heartbeat
iscekic 3d23537
fix(cli): accept connection-scoped remote create_session
iscekic ffe3807
refactor(cli): dedupe remote instance label sanitization
iscekic e840a49
chore(cli): retrigger code review after workspace setup failure
iscekic 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
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
81 changes: 81 additions & 0 deletions
81
packages/opencode/test/kilocode/sessions/remote-instance.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,81 @@ | ||
| import { describe, expect, test } from "bun:test" | ||
| import { | ||
| buildRemoteInstance, | ||
| hostLabel, | ||
| projectLabel, | ||
| sanitizeLabel, | ||
| versionLabel, | ||
| } from "../../../src/kilo-sessions/kilo-sessions" | ||
|
|
||
| describe("remote instance labels", () => { | ||
| test("hostLabel uses hostname and falls back when empty", () => { | ||
| expect(hostLabel("macbook.local")).toBe("macbook.local") | ||
| expect(hostLabel(" ")).toBe("Kilo runtime") | ||
| expect(hostLabel("")).toBe("Kilo runtime") | ||
| }) | ||
|
|
||
| test("hostLabel strips controls, collapses whitespace, clamps to 64", () => { | ||
| expect(hostLabel("ab\u0001c\td")).toBe("ab c d") | ||
| expect(hostLabel("x".repeat(80))).toBe("x".repeat(64)) | ||
| expect(hostLabel("\u0001\u0002")).toBe("Kilo runtime") | ||
| }) | ||
|
|
||
| test("projectLabel takes basename and falls back", () => { | ||
| expect(projectLabel("/Users/igor/Projects/cloud")).toBe("cloud") | ||
| expect(projectLabel("/Users/igor/Projects/cloud/")).toBe("cloud") | ||
| expect(projectLabel("C:\\work\\app\\")).toBe("app") | ||
| expect(projectLabel("/")).toBe("unknown-project") | ||
| expect(projectLabel("")).toBe("unknown-project") | ||
| }) | ||
|
|
||
| test("projectLabel sanitizes and clamps", () => { | ||
| expect(projectLabel(`/tmp/${"p".repeat(80)}`)).toBe("p".repeat(64)) | ||
| expect(projectLabel("/tmp/my\nproj")).toBe("my proj") | ||
| }) | ||
|
|
||
| test("versionLabel clamps to 32 and drops empty", () => { | ||
| expect(versionLabel("7.4.15")).toBe("7.4.15") | ||
| expect(versionLabel("v".repeat(40))).toBe("v".repeat(32)) | ||
| expect(versionLabel(" ")).toBeUndefined() | ||
| expect(versionLabel("\u0000")).toBeUndefined() | ||
| }) | ||
|
|
||
| test("sanitizeLabel applies fallback after empty sanitize", () => { | ||
| expect(sanitizeLabel("ok", "fb", 64)).toBe("ok") | ||
| expect(sanitizeLabel("\t\n", "fb", 64)).toBe("fb") | ||
| }) | ||
|
|
||
| test("buildRemoteInstance validates a complete instance", () => { | ||
| const instance = buildRemoteInstance({ | ||
| directory: "/tmp/my-app", | ||
| hostname: "dev-box", | ||
| version: "1.2.3", | ||
| }) | ||
| expect(instance).toEqual({ | ||
| name: "dev-box", | ||
| projectName: "my-app", | ||
| version: "1.2.3", | ||
| }) | ||
| }) | ||
|
|
||
| test("buildRemoteInstance applies hostname and project fallbacks", () => { | ||
| const instance = buildRemoteInstance({ | ||
| directory: "/", | ||
| hostname: " ", | ||
| version: "9.0.0", | ||
| }) | ||
| expect(instance.name).toBe("Kilo runtime") | ||
| expect(instance.projectName).toBe("unknown-project") | ||
| expect(instance.version).toBe("9.0.0") | ||
| }) | ||
|
|
||
| test("buildRemoteInstance omits empty version after clamp", () => { | ||
| const instance = buildRemoteInstance({ | ||
| directory: "/tmp/p", | ||
| hostname: "h", | ||
| version: " ", | ||
| }) | ||
| expect(instance).toEqual({ name: "h", projectName: "p" }) | ||
| expect(instance).not.toHaveProperty("version") | ||
| }) | ||
| }) |
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.
Uh oh!
There was an error while loading. Please reload this page.