Skip to content

Enhance container port metadata with protocol, label, and browsable flag - #24

Merged
Pierre-Gilles merged 2 commits into
mainfrom
claude/sdk-adaptation-pr-2786-l85nhg
Aug 7, 2026
Merged

Enhance container port metadata with protocol, label, and browsable flag#24
Pierre-Gilles merged 2 commits into
mainfrom
claude/sdk-adaptation-pr-2786-l85nhg

Conversation

@Pierre-Gilles

@Pierre-Gilles Pierre-Gilles commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR extends the ContainerPort interface to include additional metadata about published ports, enabling better representation of port capabilities in the supervision UI and providing integration developers with complete port information from the manifest.

Key Changes

  • Extended ContainerPort interface with new fields:

    • protocol: TCP or UDP protocol type (declared in manifest, defaults to TCP)
    • label: Multi-language label for the port (from manifest)
    • browsable: Boolean flag indicating if the port serves a web UI (defaults to true)
    • Made host_port nullable (number | null) to represent unallocated ports
  • Updated type definitions (index.d.ts):

    • Added ContainerPortProtocol type for protocol validation
    • Enhanced ContainerPort interface with comprehensive JSDoc comments
    • Updated test types to validate the new port properties
  • Improved documentation:

    • Updated README with detailed explanation of port structure and allocation behavior
    • Added example showing how to access host ports from container declarations
    • Clarified that host_port is chosen by Gladys and persisted across recreations
    • Documented the browsable flag use case (e.g., OCPP WebSocket endpoints)
  • Enhanced test coverage:

    • Updated existing test to validate all new port fields
    • Added new test case for OCPP-like scenario with browsable: false and host_port: null
    • Added type checking tests for new port properties

Implementation Details

  • The host_port field is now null while Gladys has not yet allocated a port (e.g., container never started)
  • The browsable flag allows the supervision UI to distinguish between web UI ports (showing "Open" links) and non-browsable ports like WebSocket endpoints (showing plain badges)
  • All changes are backward-compatible in terms of API structure; existing integrations will receive the new fields

https://claude.ai/code/session_01WxpcyV2TFQvTJkYdTa9YET

Summary by CodeRabbit

  • New Features

    • Container information now includes detailed port metadata, including TCP/UDP protocol, localized labels, browser visibility, and allocated host ports.
    • Host ports may now be reported as unassigned when no mapping is available.
    • Added type support for the expanded container port information.
  • Documentation

    • Added guidance and examples for interpreting port assignments and identifying non-browsable endpoints.
  • Tests

    • Expanded coverage for port metadata, nullable host ports, protocols, labels, and browser visibility.

…spec C.7/C.3)

Adapt the SDK to GladysAssistant/Gladys#2786, which adds a `browsable`
field (default true) to the manifest sub-container ports and returns the
full port shape from `GET /container`: a port that serves no web UI (a
WebSocket endpoint waiting for devices, the OCPP case) is shown as a
plain badge instead of an "Open" link.

- ContainerPort typings resynced with the core state: `protocol`, `label`
  and `browsable` added, `host_port` corrected to `number | null` (no
  host port is allocated before the first start); new exported
  ContainerPortProtocol union
- getContainers JSDoc + README document the full port entry and what
  browsable: false means for the integration
- tests: the getContainers fixture carries the real port shape, plus a
  non-browsable port with an unassigned host port; compile-time checks on
  the new fields

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WxpcyV2TFQvTJkYdTa9YET
@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@Pierre-Gilles, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 53 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 6144260d-15da-4416-a8d0-af1ae26fe177

📥 Commits

Reviewing files that changed from the base of the PR and between c635dc9 and 111c504.

📒 Files selected for processing (1)
  • test/types/api.test-d.ts
📝 Walkthrough

Walkthrough

The PR expands ContainerPort with protocol, nullable host-port, localized label, and browsability metadata. It updates getContainers() documentation and examples. Tests validate the new fields and non-browsable ports with unassigned host ports.

Changes

Container port metadata

Layer / File(s) Summary
Port contract and documentation
index.d.ts, lib/gladys-integration.js, README.md
ContainerPort now defines protocol, nullable host_port, localized label, and browsable. Documentation describes these fields and their allocation behavior.
Port metadata validation
test/containers.test.js, test/types/api.test-d.ts
Container tests validate detailed port metadata and non-browsable ports. Type tests validate the new public fields and ContainerPortProtocol.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Poem

A rabbit hops through ports so neat,
With labels, protocols, and hosts to greet.
If no host port has yet been spun,
null records the missing one.
Browsable paths shine bright and clear—
Non-web ports stay safely near.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main container port metadata changes, including protocol, label, and browsable status.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/sdk-adaptation-pr-2786-l85nhg

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@test/types/api.test-d.ts`:
- Around line 148-157: The type test currently allows host_port to be
number-only because optional chaining contributes undefined; add a direct
type-only assignment proving the underlying ContainerPort host_port accepts
null. Use the existing IntegrationContainer symbol and its ports element type,
alongside the other declarations, without changing runtime behavior.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 85af8e3f-541d-45b6-b40b-d7d4c3e5b385

📥 Commits

Reviewing files that changed from the base of the PR and between c29defe and c635dc9.

📒 Files selected for processing (5)
  • README.md
  • index.d.ts
  • lib/gladys-integration.js
  • test/containers.test.js
  • test/types/api.test-d.ts

Comment thread test/types/api.test-d.ts Outdated
The optional chaining on `containers[0]?.ports[0]?.host_port` contributes
`undefined` on its own, so the widened `number | null | undefined`
annotation type-checked even when `host_port` was `number` — the check
did not actually prove the field is nullable. Assign `null` straight to
`ContainerPort['host_port']` instead, which fails to compile without the
null in the type.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WxpcyV2TFQvTJkYdTa9YET
@Pierre-Gilles
Pierre-Gilles merged commit 4b7ea0c into main Aug 7, 2026
6 checks passed
@Pierre-Gilles
Pierre-Gilles deleted the claude/sdk-adaptation-pr-2786-l85nhg branch August 7, 2026 09:47
Pierre-Gilles pushed a commit that referenced this pull request Aug 7, 2026
Resolve the overlap with #24 (adaptation of GladysAssistant/Gladys#2786),
which landed on main the port fields this branch had added on its own:
keep main's version of `protocol`, `label`, `browsable` and the nullable
`host_port` (its ContainerPortProtocol union and its direct-assignment
type check are the stronger form), and keep only the delta specific to
GladysAssistant/Gladys#2787 on top — the `name` field of ContainerPort,
its JSDoc/README documentation and a dedicated test.

- index.d.ts: `name: string | null` added to main's ContainerPort
- getContainers JSDoc and the README port entry list `name`
- README: the "Placeholders in section texts" subsection stays, the
  Sub-containers block explains `name` after main's `browsable` paragraph
- tests: main's browsable/unassigned-port case kept as is, the port name
  gets its own case; the type test keeps both direct assignments

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Bb3mfS9ufKovY8WxwDk9VB
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