kolibri icon indicating copy to clipboard operation
kolibri copied to clipboard

Preview the generated kolibri.local URL when setting the device name

Open rtibbles opened this issue 5 months ago • 8 comments

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

Overview

#14858 makes each Kolibri server advertise a <device-name>.kolibri.local mDNS record derived from a slugified device name, giving a memorable, bookmarkable URL. But nothing tells the user, at the moment they choose the name, what URL it will produce — so the naming and its consequence are disconnected. Add a live preview of the generated URL (with port suffix) wherever the device name is set: the setup wizard and the Device Info edit modal.

Complexity: Low Target branch: develop

Context

  • The URL is built server-side in kolibri/core/discovery/utils/network/broadcast.py (LOCAL_DOMAIN = "kolibri.local").
  • The served port comes from the HTTP_PORT option (kolibri/utils/options.py, default 8080).
  • #14858's slug rule: lowercase, drop characters outside [a-z0-9-] ("Tony's Laptop" → tonyslaptop).
  • An empty slug publishes no device-name record.

Device name is set in two places:

  • Setup wizard: DeviceNameForm.vue (KTextbox, seeded into the wizard state machine).
  • Device Info page: DeviceNameModal.vue (KTextbox, PATCHes kolibri:core:devicename).

The frontend needs the slug rule and the port to render the same URL the server will own.

The Change

Below the device-name field, show a live preview of the URL the name will produce, so the user can choose a name for the address they want. Replicate #14858's slug rule in JS rather than round-tripping to the server. Preview only the <device-name>.kolibri.local URL — the one the input controls — not the bare kolibri.local. Both edit surfaces (DeviceNameForm.vue, DeviceNameModal.vue) share one implementation, factored into kolibri-common.

The concrete requirements are in Acceptance Criteria.

How to Get There

  • Setup wizard: start an unprovisioned Kolibri, proceed to the "Device name" step.
  • Device Info: as an admin, go to Device → Info, click the edit (pencil) button on the device-name row to open the modal.

Out of Scope

  • Publishing the mDNS records themselves — that is #14858.
  • Previewing the bare kolibri.local URL.
  • The Device Info page's owned-URL list (also #14858); this task only touches the name-editing surfaces.
  • Any server-side change — the preview is client-side only.

Acceptance Criteria

General

  • [ ] Both DeviceNameForm.vue (setup wizard) and DeviceNameModal.vue (Device Info) show a live URL preview below the device-name field.
  • [ ] The preview shows http://<slug>.kolibri.local:<port>, with <slug> matching #14858's slug rule and <port> the configured HTTP_PORT.
  • [ ] The preview updates on each keystroke.
  • [ ] When the name slugifies to empty, no URL is shown; instead a message explains the name produces no custom address and the server stays reachable via kolibri.local and its IP.
  • [ ] The slug + preview logic lives in one shared implementation in kolibri-common, used by both surfaces.

Accessibility and i18n

  • [ ] All preview text is internationalized via createTranslator.
  • [ ] The preview is associated with the input for screen readers (not a bare floating string).

Testing

  • [ ] Tests cover the slug function, including a name that slugifies to empty.
  • [ ] Tests cover that a typed name renders the expected URL preview and that an empty-slug name renders the fallback message instead.

AI usage

Drafted with Claude Code. Claude located the two device-name editing components, the slug rule and port in #14858 and the broadcast/options code, and drafted the issue section by section from my instructions. I chose the JS-replicated slug, the shared kolibri-common code, the live-on-keystroke behaviour, and the empty-slug handling.

rtibbles avatar Jul 02 '26 21:07 rtibbles

Blocking discrepancy with the merged #14858 — the URL format to preview has changed.

This issue specifies previewing http://<slug>.kolibri.local:<port>. #14858 (merged into develop via #14944 on 2026-07-10) does not publish a <device-name>.kolibri.local record. It publishes a single-label <slug>.local hostname:

  • slugify_device_name() in broadcast.py builds a slug for a <device-name>.local hostname (docstring example: tonyslaptop.local).
  • local_hostnames returns e.g. ["kolibri.local", "tonyslaptop.local"] — the bare kolibri.local plus the single-label device name, never <slug>.kolibri.local.

The multi-label <device>.kolibri.local form was dropped precisely because it's unresolvable on standard mDNS clients.

Implementing this issue as written would preview a URL (<slug>.kolibri.local) that the server does not own and that won't resolve — the opposite of the "choose a name for the address you'll get" goal.

Two things need confirming before implementing:

  1. Preview URL format — should the preview show http://<slug>.local:<port>, matching what #14858 actually publishes?
  2. Slug rule — the shipped rule is re.sub(r"[^a-z0-9-]", "", name.lower()) plus a 32-char cap (MAX_DEVICE_NAME_LABEL_LENGTH), which the issue's slug description omits. Should the JS replica mirror the cap?

Two notes, no action needed:

  • The empty-slug fallback message referencing kolibri.local + IP is still accurate — the bare name is unchanged.
  • The Context section points at LOCAL_DOMAIN = "kolibri.local" as the device-URL source. The authoritative source is now slugify_device_name and the <slug>.local construction.

Everything else in the AC looks implementable once the URL scheme is corrected.

rtibblesbot avatar Jul 10 '26 21:07 rtibblesbot

The bot has been waiting for a response for 2 hour(s). It will resume automatically when someone replies.

rtibblesbot avatar Jul 10 '26 23:07 rtibblesbot

1 Yes 2 Yes

rtibbles avatar Jul 13 '26 02:07 rtibbles

Plan: Show a live http://<slug>.local:<port> preview below the device-name field in the setup wizard and the Device Info edit modal, so a user sees the address their chosen name produces as they type.

  • [ ] Shared slug util
  • [ ] Shared DeviceUrlPreview.vue component
  • [ ] Wire the preview into both edit surfaces

@rtibblesbot's comments are generated by an LLM, and should be evaluated accordingly

How was this generated?
  • Implemented code following the pre-approved plan using test-driven development (red-green-refactor)
  • Ran the project's full test suite and linter before committing
  • For UI changes: captured live screenshots to verify rendering
  • For backend changes: verified with example API/CLI output

rtibblesbot avatar Jul 13 '26 02:07 rtibblesbot

The bot has been waiting for a response for 2 hour(s). It will resume automatically when someone replies.

rtibblesbot avatar Jul 13 '26 05:07 rtibblesbot

The bot has been waiting for a response for 2 hour(s). It will resume automatically when someone replies.

rtibblesbot avatar Jul 14 '26 07:07 rtibblesbot

The bot has been waiting for a response for 2 hour(s). It will resume automatically when someone replies.

rtibblesbot avatar Jul 17 '26 09:07 rtibblesbot

Fixed in #15003

rtibbles avatar Jul 18 '26 03:07 rtibbles