-
Notifications
You must be signed in to change notification settings - Fork 37
fix(dev-cli): handle shared-port services in status command #1302
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
evan-claw
wants to merge
1
commit into
Kilo-Org:improvement/kiloclaw-dev-cli
from
evan-claw:fix/status-shared-ports
+95
−4
Closed
Changes from all commits
Commits
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| import { describe, expect, test } from 'bun:test'; | ||
| import { services } from '../src/services/registry'; | ||
|
|
||
| describe('status: shared-port detection', () => { | ||
| test('identifies services that share a port', () => { | ||
| const portServices = services.filter(s => s.port && s.type !== 'infra'); | ||
| const portGroups = new Map<number, string[]>(); | ||
| for (const svc of portServices) { | ||
| const group = portGroups.get(svc.port!) ?? []; | ||
| group.push(svc.name); | ||
| portGroups.set(svc.port!, group); | ||
| } | ||
| const sharedPorts = [...portGroups.entries()].filter(([, names]) => names.length > 1); | ||
|
|
||
| // Verify the known shared ports are detected | ||
| expect(sharedPorts.length).toBeGreaterThanOrEqual(2); | ||
|
|
||
| const port8792 = portGroups.get(8792); | ||
| expect(port8792).toBeDefined(); | ||
| expect(port8792).toContain('auto-fix'); | ||
| expect(port8792).toContain('db-proxy'); | ||
|
|
||
| const port8795 = portGroups.get(8795); | ||
| expect(port8795).toBeDefined(); | ||
| expect(port8795).toContain('kiloclaw'); | ||
| expect(port8795).toContain('git-token'); | ||
| }); | ||
|
|
||
| test('unique-port services are not grouped', () => { | ||
| const portServices = services.filter(s => s.port && s.type !== 'infra'); | ||
| const portGroups = new Map<number, string[]>(); | ||
| for (const svc of portServices) { | ||
| const group = portGroups.get(svc.port!) ?? []; | ||
| group.push(svc.name); | ||
| portGroups.set(svc.port!, group); | ||
| } | ||
|
|
||
| // Port 3000 belongs only to nextjs | ||
| const port3000 = portGroups.get(3000); | ||
| expect(port3000).toEqual(['nextjs']); | ||
| }); | ||
|
|
||
| test('all non-infra port services are accounted for in port groups', () => { | ||
| const portServices = services.filter(s => s.port && s.type !== 'infra'); | ||
| const portGroups = new Map<number, string[]>(); | ||
| for (const svc of portServices) { | ||
| const group = portGroups.get(svc.port!) ?? []; | ||
| group.push(svc.name); | ||
| portGroups.set(svc.port!, group); | ||
| } | ||
|
|
||
| // Every port-having service should be in exactly one group | ||
| const allGroupedNames = [...portGroups.values()].flat(); | ||
| const serviceNames = portServices.map(s => s.name); | ||
| expect(allGroupedNames.sort()).toEqual(serviceNames.sort()); | ||
| }); | ||
| }); | ||
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.
WARNING: These tests don't exercise the
status()behavior that changedEach test rebuilds the port-grouping map directly from
services, so they still pass even ifstatus.tsregresses to probing every service independently again. The shared-port fix indev/cli/src/commands/status.tsneeds at least one behavior-level assertion on the command output orisPortListeningcall pattern to prevent that regression.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.
@evan-claw