Skip to content

feat(cli): warn when --port is outside discovery range - #11143

Merged
catrielmuller merged 2 commits into
Kilo-Org:mainfrom
IamCoder18:feat/cli-port-discovery-warning
Jun 12, 2026
Merged

feat(cli): warn when --port is outside discovery range#11143
catrielmuller merged 2 commits into
Kilo-Org:mainfrom
IamCoder18:feat/cli-port-discovery-warning

Conversation

@IamCoder18

Copy link
Copy Markdown
Contributor

Issue

Context

When kilo console --port <port> or kilo daemon start/restart --port <port> is called with an explicit port outside the daemon discovery range (4097–4116), the daemon still starts successfully but Kilo's browser auto-discovery only scans that 20-port window. This means later manual launches or dev-mode auto-connect can silently fail to find the daemon, leaving the user with no feedback about why the console can't connect.

The fix is to print a non-fatal yellow warning when an explicit port is passed outside that range, while still allowing the command to succeed normally.

Implementation

I added a small shared helper in a Kilo-owned path (packages/opencode/src/kilocode/cli/port-warning.ts) so the change avoids touching upstream shared files and doesn't require kilocode_change markers.

The helper warnIfPortOutsideDiscoveryRange(port):

  • Skips the check when port === 0 (auto-pick mode).
  • Reads the range from Daemon.PortRange (40974116).
  • Emits a yellow console.warn when the explicit port is out of range.

I then called this helper from:

  • packages/opencode/src/kilocode/cli/cmd/console.ts: after resolving network options and before Daemon.start().
  • packages/opencode/src/kilocode/cli/cmd/daemon.ts: in both the start and restart handlers.

The warning is informational only; the command starts the daemon and opens the console as normal.

Screenshots / Video

WindowsTerminal_ObyVryMH1u

How to Test

Manual/local verification:

  • kilo daemon stop && kilo console --port 4097 → no warning.
  • kilo daemon stop && kilo console --port 4321 → yellow warning, then console opens.
  • kilo daemon stop && kilo console --port 0 → no warning (auto-pick).
  • kilo daemon stop && kilo daemon start --port 5000 → yellow warning.
  • kilo daemon stop && kilo daemon restart --port 5000 → yellow warning.

Checklist

  • Issue linked above, or exception explained
  • Tests/verification described
  • Screenshots/video included for visual changes, or marked N/A
  • Changeset considered for user-facing changes
  • I personally reviewed the diff and can explain the changes, including any AI-assisted work.

Get in Touch

Discord: @IamCoder18

Comment thread packages/opencode/src/kilocode/cli/port-warning.ts Outdated
@kilo-code-bot

kilo-code-bot Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Resolved Issues
File Line Issue Status
packages/opencode/src/kilocode/cli/port-warning.ts N/A warnIfPortOutsideDiscoveryRange renamed to warnPort — single-word name now matches style guide ✅ Fixed
N/A N/A No changeset — PR was missing a .changeset/*.md file for the user-visible warning ✅ Fixed
Files Reviewed (4 files)
  • packages/opencode/src/kilocode/cli/port-warning.ts — clean
  • packages/opencode/src/kilocode/cli/cmd/console.ts — clean
  • packages/opencode/src/kilocode/cli/cmd/daemon.ts — clean
  • .changeset/feat-cli-port-discovery-warning.md — correct package, bump level (patch), and user-facing description

Reviewed by claude-sonnet-4.6 · 137,820 tokens

Review guidance: REVIEW.md from base branch main

Print a yellow non-fatal warning when kilo console or kilo daemon
start/restart is invoked with an explicit --port outside 4097-4116.
Auto-discovery only scans that window, so an out-of-range port can
silently break later manual or auto-connect attempts.

Implementation stays entirely in Kilo-owned files to avoid touching
upstream shared code:

- Added packages/opencode/src/kilocode/cli/port-warning.ts helper
  exporting warnPort(port), which skips port 0 (auto-pick) and emits
  a yellow console.warn when the explicit port is outside
  Daemon.PortRange.
- Hooks the helper from console.ts and daemon.ts (start/restart)

The command still succeeds; the warning is informational only.
@IamCoder18
IamCoder18 force-pushed the feat/cli-port-discovery-warning branch from d7f68bf to 4ba2bac Compare June 12, 2026 01:14
@johnnyeric
johnnyeric requested a review from catrielmuller June 12, 2026 11:19
@catrielmuller
catrielmuller merged commit 2f7657f into Kilo-Org:main Jun 12, 2026
18 checks passed
t7tran pushed a commit to t7tran/kilocode that referenced this pull request Aug 14, 2026
…very-warning

feat(cli): warn when --port is outside discovery range
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants