kolibri icon indicating copy to clipboard operation
kolibri copied to clipboard

Surface the elected port in the setup wizard and device settings

Open rtibbles opened this issue 5 months ago • 2 comments

❌ This issue is not open for contribution. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues.

Overview

learningequality/kolibri#14962 elects the port silently at setup; users need somewhere to see and override the result (parent: #14960).

  • Setup wizard: port choice as an advanced option — early enough that a change can restart and redirect cleanly.
  • Device settings: the same control post-setup — the in-product path for an existing install to move to port 80.

Complexity: Medium Target branch: develop

Acceptance Criteria

General

  • [ ] Setup wizard: an advanced option shows the elected port and allows overriding it.
  • [ ] Changing the port restarts the server and redirects the browser to the new address.
  • [ ] Device settings: the same control available post-setup.
  • [ ] A failed port claim shows what's blocking it and keeps the current port.

Accessibility and i18n

  • [ ] All text via createTranslator.
  • [ ] Control is keyboard-accessible and labelled.

Testing

  • [ ] Jest: option renders the elected port.
  • [ ] Jest: failure state shows the blocking reason.

AI usage

Written with Claude Code in an interactive design session; all decisions were made by the author in dialogue. (Section required by Learning Equality's AI-usage disclosure policy.)

rtibbles avatar Jul 04 '26 05:07 rtibbles

Plan: one port control, shown on the setup wizard's first screen and in device settings; it test-binds the chosen port, saves it to options.ini, restarts, and redirects to the new address.

  • [ ] Strict port claim with a structured result (port, reason) in port_election.py
  • [ ] Port API: wizard (NotProvisionedHasPermission) and device settings (IsSuperuser)
  • [ ] Shared port control component, plus restart-and-redirect via the new origin
  • [ ] Wizard: "Advanced" disclosure on the first screen
  • [ ] Device settings: control with confirmation
  • [ ] Jest and API tests

Assumptions — the issue did not settle these; say so if one is wrong.

  • A failed claim writes nothing and does not fall back to 8080, unlike --preferred-port.
  • The wizard control sits on the first screen: wizard progress lives in localStorage, which is per-port, so a later change would lose it.
  • Hidden in the desktop/Android apps and when RESTART_HOOKS is empty.
  • Read-only, with the reason shown, when HTTP_PORT comes from an env var or --port (restart re-execs with the same argv/env, so a saved change would not apply), or when ADVERTISED_HTTP_PORT is set.
  • The blocking reason is the server's English text, e.g. in use by nginx (nginx.service); the text around it is translated.
  • Device settings asks for confirmation first: bookmarks and peers' saved addresses on the old port stop working.
  • After the restart, the page polls the new address with no-CORS fetches, then navigates to the same hostname, dropping :80.

Written by rtibblesbot, an LLM-based coding agent.

rtibblesbot avatar Nov 21 '26 10:11 rtibblesbot

Plan: One port control, on the setup wizard's first screen and in device settings, that test-binds a chosen port, saves it to options.ini, restarts, and sends the browser to the new address.

  • [ ] Strict port claim
  • [ ] Port API
  • [ ] Let the two pages reach other ports
  • [ ] Shared port control
  • [ ] Wizard advanced option
  • [ ] Device settings section
  • [ ] Live QA
  • [ ] Self-review the produced code

Assumptions — the issue did not settle these; say so if one is wrong.

  • A failed claim writes nothing and does not fall back to 8080; if wrong, the API calls elect_http_port and reports the port it fell back to.
  • The wizard control sits on the first screen; if wanted later, wizard progress must move across origins.
  • The control is hidden in the desktop and Android apps, which pick their own port (HTTP_PORT: 0 in their option defaults); if they should show it, drop the isAppContext gate and expect CANNOT_RESTART on Android.
  • Read-only, with the reason, when HTTP_PORT comes from an env var or --port, or ADVERTISED_HTTP_PORT is set; if editable, a saved change would not apply after the restart.
  • "Request served by the PID-file process" is tested as PID-file pid equal to os.getpid(), which holds for kolibri start, foreground or daemonized; if a supported deployment serves from another process and still moves its port on restart, it wrongly reads CANNOT_RESTART.
  • kolibri-server gets no way to change its port in the UI; if it must, that is a RESTART_HOOKS entry in the kolibri-server package that rewrites the nginx config, outside this issue.
  • Device settings asks for confirmation; the wizard does not; if both should, set requireConfirmation in the wizard too.
  • The two pages' CSP allows connect-src http: https:; if too broad, the probe needs a same-host-any-port source or another mechanism.
  • The built static tree serves assets/favicons/logo.ico unhashed (committed at kolibri/core/static/); if not, Task 7 picks another unhashed core file.
  • restart() failing after the save returns 500 and leaves the new port saved for next start; if wrong, the API reverts HTTP_PORT.
  • Polling the new address has no timeout, as useDeviceRestart; if a bind race should surface, add a failure state after the old origin is gone.

Written by rtibblesbot, an LLM-based coding agent.

rtibblesbot avatar Nov 21 '26 11:11 rtibblesbot