Skip to content

feat(desktop): open ports over https via ports.json protocol field - #5995

Closed
evansking wants to merge 1 commit into
ParadevAI:mainfrom
evansking:feat/ports-json-protocol
Closed

evansking wants to merge 1 commit into
ParadevAI:mainfrom
evansking:feat/ports-json-protocol

Conversation

@evansking

@evansking evansking commented Jul 27, 2026 •

Copy link
Copy Markdown

What

Adds an optional protocol field ("http" | "https") to each entry in a
workspace's .superset/ports.json. When set to "https", the sidebar's
port-open action opens https://localhost:PORT instead of http://.

{
  "ports": [
    { "port": 3000, "label": "Frontend Dev Server", "protocol": "https" },
    { "port": 8080, "label": "API Server" }
  ]
}

Why

Port open actions were hardcoded to http://localhost:PORT
(usePortOpenActions.ts, MergedPortBadge.tsx). Dev servers running behind a
local TLS cert (e.g. mkcert) 301/refuse on http://, so opening them from
the sidebar lands on a broken page and you have to retype the URL with
https://. There was no config or preference to control the scheme.

This rides the same rails the existing label field already uses, so it's
purely additive and backward compatible — omit protocol and behavior is
unchanged (defaults to http).

How

protocol is resolved from ports.json alongside label and travels the two
existing paths that carry label to the renderer:

  • Query path: parseStaticPortsConfig → static-port label caches (desktop
    • host-service) → ports.getAll enrichment → EnrichedPort /
      DashboardSidebarPort.
  • Event path: host-service port:changed broadcast → workspace-client
    PortChangedPayload → applyPortEventsToHostPortsResult.

Both the v2 sidebar (usePortOpenActions) and the v1 sidebar
(MergedPortBadge) then build the URL as
`${port.protocol ?? "http"}://localhost:${port.port}`.

The label caches' Map<number, string> (port → label) becomes
Map<number, StaticPortLabel> so the same lookup yields both label and
protocol.

Validation

parseStaticPortsConfig rejects any protocol that isn't exactly "http" or
"https" with ports[N].protocol must be "http" or "https", consistent with
the existing per-field error messages. Malformed files are still ignored
wholesale (unchanged behavior).

Testing

  • bun run typecheck
  • bun run lint
  • bun run test — added cases:
    • static-ports loader: loads https/http, omits when absent, rejects an
      invalid protocol.
    • applyPortEventsToHostPortsResult: carries protocol from an add event
      onto the port row.

Notes

  • Backward compatible: entries without protocol serialize and behave exactly
    as before (toEqual on existing loader fixtures is unchanged).
  • Docs updated: apps/docs/content/docs/ports.mdx.
  • Happy to split or convert to an issue-first discussion if you'd prefer — kept
    it to one focused change per the contributing guide.

Open in Stage

Summary by cubic

Add optional HTTPS support for sidebar port-open actions via a new protocol field in .superset/ports.json. Defaults to HTTP, so existing configs work unchanged.

  • New Features
    • Add protocol ("http" | "https") to .superset/ports.json; when set to "https", ports open at https://localhost:PORT.
    • Thread protocol through label cache, host port:changed events, TRPC, and renderer; exposed on EnrichedPort and PortChangedPayload.
    • Update open actions in usePortOpenActions and MergedPortBadge to use protocol ?? "http".
    • Validate values in @superset/port-scanner; tests and docs updated.

Written for commit 11b929c. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

  • New Features
    • Added optional per-port protocol settings for http or https.
    • Port listings and live updates now retain and display protocol information.
    • Opening a port now uses its configured protocol, defaulting to HTTP.
  • Bug Fixes
    • Improved handling of missing or invalid protocol values.
  • Documentation
    • Updated port configuration guidance with protocol examples and HTTPS behavior.
  • Tests
    • Added coverage for valid, missing, and invalid protocol configurations.

Add an optional `protocol` ("http" | "https") field to `.superset/ports.json`
entries. When set to "https", the sidebar port-open action opens
https://localhost:PORT instead of http://, which fixes opening dev servers
that run behind a local TLS certificate (e.g. mkcert).

The field is resolved alongside `label` and travels the same query and
`port:changed` event paths to the renderer, then is consumed by both the v2
and v1 sidebar open actions. Omitting `protocol` is unchanged (defaults to
http), so the change is backward compatible.

Co-Authored-By: Claude <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 27, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: ed607062-aa97-4a5f-92ec-d6edc1b89bbb

📥 Commits

Reviewing files that changed from the base of the PR and between 97e0446 and 11b929c.

📒 Files selected for processing (16)
  • apps/desktop/src/lib/trpc/routers/ports/label-cache.ts
  • apps/desktop/src/lib/trpc/routers/ports/ports.ts
  • apps/desktop/src/main/lib/static-ports/loader.test.ts
  • apps/desktop/src/renderer/routes/_authenticated/_dashboard/components/DashboardSidebar/components/DashboardSidebarPortsList/hooks/useDashboardSidebarPortsData/useDashboardSidebarPortsData.test.ts
  • apps/desktop/src/renderer/routes/_authenticated/_dashboard/components/DashboardSidebar/components/DashboardSidebarPortsList/hooks/useDashboardSidebarPortsData/useDashboardSidebarPortsData.utils.ts
  • apps/desktop/src/renderer/routes/_authenticated/_dashboard/components/DashboardSidebar/hooks/usePortOpenActions/usePortOpenActions.ts
  • apps/desktop/src/renderer/screens/main/components/WorkspaceSidebar/PortsList/components/MergedPortBadge/MergedPortBadge.tsx
  • apps/desktop/src/shared/types/ports.ts
  • apps/docs/content/docs/ports.mdx
  • packages/host-service/src/events/event-bus.ts
  • packages/host-service/src/events/types.ts
  • packages/host-service/src/ports/static-ports.ts
  • packages/host-service/src/trpc/router/ports/ports.ts
  • packages/port-scanner/src/index.ts
  • packages/port-scanner/src/static-ports.ts
  • packages/workspace-client/src/lib/eventBus.ts

📝 Walkthrough

Walkthrough

Static port configuration now supports optional HTTP/HTTPS protocols. Protocol values are validated, cached, exposed through host and desktop APIs, propagated through events and sidebar state, and used when opening local ports.

Changes

Protocol-aware static ports

Layer / File(s) Summary
Static port protocol contract
packages/port-scanner/..., apps/desktop/src/main/lib/static-ports/loader.test.ts
Static port entries accept validated http or https protocols, preserve configured values, and expose the protocol type.
Host-service caching and event propagation
packages/host-service/src/ports/..., packages/host-service/src/trpc/router/ports/ports.ts, packages/host-service/src/events/..., packages/workspace-client/src/lib/eventBus.ts
Caches retain complete static port entries, API responses include protocol, and port-change events carry the protocol to workspace subscribers.
Desktop cache and port models
apps/desktop/src/lib/trpc/routers/ports/..., apps/desktop/src/shared/types/ports.ts
Desktop caches and enriched port types now represent nullable protocol values.
Renderer propagation and URL opening
apps/desktop/src/renderer/..., apps/docs/content/docs/ports.mdx
Sidebar state and port-opening actions preserve protocol values, while documentation describes protocol configuration and URL behavior.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Config as ports.json
  participant Scanner as port-scanner
  participant Host as host-service
  participant Client as workspace-client
  participant UI as port-opening UI
  Config->>Scanner: Parse protocol
  Scanner->>Host: Validated StaticPortLabel
  Host->>Client: port:changed with protocol
  Client->>UI: PortChangedPayload
  UI->>UI: Build protocol://localhost:PORT
Loading

Possibly related PRs

Suggested reviewers: kitenite

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 12.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is a concise conventional commit that accurately summarizes the HTTPS protocol-field change for desktop port opening.
Description check ✅ Passed The description covers what, why, how, validation, testing, and notes; only the checklist section is not explicitly filled in.
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 unit tests (beta)
  • Create PR with unit tests

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.

@ghost

ghost commented Jul 27, 2026

Copy link
Copy Markdown

Ready to review this PR? Stage has broken it down into 6 individual chapters for you:

Title
1 Define StaticPortProtocol and update scanner schema
2 Update shared desktop types and loader tests
3 Propagate protocol through desktop label cache
4 Update host-service and workspace-client events
5 Wire protocol into renderer and sidebar UI
6 Update documentation for ports.json
Open in Stage

Chapters generated by Stage for commit 11b929c on Jul 27, 2026 7:36pm UTC.

@Kitenite

Copy link
Copy Markdown
Member

Closing as a duplicate. Same feature as #6330 (https ports via ports.json protocol field); #6330 is newer and larger.

@Kitenite Kitenite closed this Aug 22, 2026
@Kitenite

Copy link
Copy Markdown
Member

Thanks for the https-ports idea. #6330 lands the same ports.json protocol field against current main, so we're keeping that one.

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