Surface the elected port in the setup wizard and device settings
❌ 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.)
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_HOOKSis empty. - Read-only, with the reason shown, when
HTTP_PORTcomes from an env var or--port(restart re-execs with the same argv/env, so a saved change would not apply), or whenADVERTISED_HTTP_PORTis 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.
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_portand 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: 0in their option defaults); if they should show it, drop theisAppContextgate and expectCANNOT_RESTARTon Android. - Read-only, with the reason, when
HTTP_PORTcomes from an env var or--port, orADVERTISED_HTTP_PORTis 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 forkolibri start, foreground or daemonized; if a supported deployment serves from another process and still moves its port on restart, it wrongly readsCANNOT_RESTART. - kolibri-server gets no way to change its port in the UI; if it must, that is a
RESTART_HOOKSentry 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
requireConfirmationin 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.icounhashed (committed atkolibri/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 revertsHTTP_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.