Skip to content

feat(web): LAN modal stays open — status panel, QR connect, loopback link - #200

Merged
falbany merged 6 commits into
mainfrom
feat/lan-modal-197-198-199
Nov 19, 2026
Merged

falbany merged 6 commits into
mainfrom
feat/lan-modal-197-198-199

Conversation

@falbany

@falbany falbany commented Nov 18, 2026 •

Copy link
Copy Markdown
Owner

Resolves the three LAN-modal issues filed this morning, in one PR as planned:

What changed

LanConfirmDialog keeps its App contract (pending / onConfirmed / onCancel — zero App.tsx changes) but the two directions now diverge:

Enable (new panel flow): confirming no longer calls onCancel() first. The dialog moves through Enabling… → Enabled / Failed inline:

Restrict (unchanged): keeps the historical confirm-and-vanish flow with the dialog-closes-first quirk and toast feedback, verbatim.

#199 loopback link: shown in the enable-confirm phase and the enabled panel (target="_blank" rel="noopener noreferrer", StatusBar/MarkdownMessage precedent) — loopback always resolves on this machine, useful for --server-only runs.

Tests

  • LanConfirmDialog.test.tsx rewritten: 16 tests covering confirm/restrict phases, the panel states (gated deterministic flow), QR generation + failure degradation, loopback link attributes, mid-flow close fallback to toasts, and the unchanged restrict contract.
  • Full web suite: 394 passed (31 files); tsc -b && vite build clean.

Verified in the real browser

Served the rebuilt dist via uv run profiles --server-only and drove the real flow: confirm phase (URLs + loopback link) → Enable LAN → Enabling LAN… panel → LAN access enabled with live QR PNG from the barcode endpoint → ❌ close → restrict back to loopback-only (state restored, restrict toast confirmed).

… link

Enable-LAN used to close the dialog before the async rebind (the
"dialog-closes-first" quirk), leaving only toasts behind: the copyable
hostname/IP URLs vanished exactly when they became reachable, and a
failed bind flashed by unnoticed (issue #197).

The enable flow now owns the modal until the user closes it:
- confirming moves to a status panel (Enabling… → Enabled / Failed)
  that reports the rebind outcome inline instead of toast-only;
- the enabled panel keeps the copyable hostname + IP URLs, adds the
  one-line "on another device" instruction, and an explicit ❌ close
  (Escape works too) — the panel uses useModalA11y (#146);
- a QR encoding the IP URL appears once LAN is actually enabled,
  reusing generateBarcode / POST /api/actions/barcode — no new client
  dependency, display-only for phone scanning (issue #198);
- a clickable http://127.0.0.1:{port} link sits alongside the copyable
  URLs in both phases — loopback always resolves on this machine and
  gives a one-click re-entry for --server-only runs (issue #199).

The restrict path keeps its historical confirm-and-vanish flow, the
App.tsx contract is unchanged (pending/onConfirmed/onCancel), and a
stale flow can never paint over a reopened dialog (BarcodeModal's
issue-#140 seq pattern).

Closes #197
Closes #198
Closes #199
@falbany

falbany commented Nov 18, 2026

Copy link
Copy Markdown
Owner Author

Live verification transcript (real browser, rebuilt dist served by uv run profiles --server-only, service worker cache-busted first):

  • Confirm phase — dialog "Enable LAN access?" with warning, copyable hostname + IP URLs, and the loopback link http://127.0.0.1:8088 (target="_blank", rel="noopener noreferrer").
  • Enable LAN — the modal stays open on "Enabling LAN…" while the rebind runs, then lands on "LAN access enabled": status line, instruction line, both copyable URLs, loopback link, live QR PNG from POST /api/actions/barcode (data:image/png;base64,…, alt "QR code of the LAN address"), ❌ Close focused (initial focus).
  • ❌ Close — dialog closes; toggle re-opens straight into the confirm phase.
  • Restrict — dialog-closes-first preserved; toast "ProFiles is restricted to this machine."; /api/system confirmed lan_enabled: false afterwards (machine restored to loopback-only).

npm test: 394 passed (31 files). tsc -b && vite build: clean.

…ame UX both ways

User review on PR #200 reshaped the modal into a single LAN panel used
for BOTH directions:

- ONE modal (LanConfirmDialog → LanModal): it reflects the live
  systemInfo.lan_enabled and offers the opposite action, so enable and
  disable share the same UX. The disable path no longer uses the
  confirm-and-vanish flow — it runs in place like the enable one, and
  the dialog-closes-first quirk is gone entirely.
- QR always displayed, on the LEFT of the addresses column, even while
  LAN is disabled (user decision overriding #198's original gating:
  the URL is unreachable for other devices until enabled).
- Footer buttons never disappear: Cancel + the flip action
  ("Enable LAN" / "Disable LAN" per the live state) stay in every
  state, the action disabling while a rebind is in flight.
- ❌ close always visible in the header; Escape still works; initial
  focus sits on Cancel (ConfirmDialog safety precedent).
- App contract: pending/onCancel becomes open/onClose — toggleLan
  ignores the requested direction and just opens the modal.

391 web tests pass (31 files); verified in the real browser across
enable → disable round trip with the rebuilt dist.
@falbany

falbany commented Nov 18, 2026

Copy link
Copy Markdown
Owner Author

UX revision pushed (b2220ee) — user review reshaped the modal into ONE unified LAN panel:

  • Same modal for enable and disable (overrides Web UI: LAN modal — keep the modal open after "Enable LAN" and turn it into a LAN status panel (status, copyable URLs, ❌ close) #197's "Restrict keeps confirm-and-vanish"): the modal reflects the live systemInfo.lan_enabled and offers the opposite action in the footer — Enable LAN / Disable LAN — which runs in place with the identical busy → outcome flow both ways. The dialog-closes-first quirk is gone entirely.
  • QR always displayed (overrides Web UI: LAN modal — QR code encoding the LAN URL so phones can scan to connect #198's "only once enabled"), moved to the left of the addresses column. Pre-enable, the QR encodes the IP URL that isn't reachable yet — accepted trade-off per user decision.
  • Footer buttons never disappear: Cancel + the flip action in every state; the action disables while a rebind is in flight.
  • ❌ always visible in the header, Escape still closes, initial focus on Cancel.
  • Component renamed LanConfirmDialog → LanModal; App contract pending/onCancel → open/onClose (toggleLan ignores the requested direction and just opens the modal).

391 web tests pass (31 files, incl. 13 rewritten LanModal.test.tsx covering both directions); tsc -b && vite build clean; verified in the real browser across an enable → disable round trip with the rebuilt dist (QR on the left in every state, footer persistent, machine restored to loopback-only afterwards).

…olumn

User review on PR #200: the header now carries the live state at a
glance — icon chip (Wifi on success-green when exposed, WifiOff neutral
when restricted) plus "LAN Access — Reachable on this network." /
"LAN Access — Restricted to the host machine." The body status line and
the "On another device…" instruction are removed (that information
lives in the header), and the loopback row gets its own margin so it no
longer hugs the IP address row (8px → 16px).

391 web tests pass; both states verified in the real browser with the
rebuilt dist.
@falbany

falbany commented Nov 18, 2026

Copy link
Copy Markdown
Owner Author

Layout adjustment pushed (6820a1e): the header now carries the live state at a glance — icon chip (Wifi on success-green when exposed, WifiOff neutral-grey when restricted) plus "LAN Access — Reachable on this network." / "LAN Access — Restricted to the host machine.". The body status line and the "On another device…" instruction are removed (that information lives in the header), and the loopback row got its own margin — 8px → 16px below the IP row. 391 web tests pass; both states verified in the real browser.

User review on PR #200: the "Updating the LAN binding…" progress leaves
the addresses column for the footer's left slot, announced via
role="status"; the Cancel + action buttons stay right (ml-auto) and the
action keeps its disabled-in-flight state. The body now holds only the
addresses and (on failure) the inline error box.

391 web tests pass; footer placement verified in the real browser
(status is the footer's first child, same row, left of the buttons).
@falbany

falbany commented Nov 18, 2026

Copy link
Copy Markdown
Owner Author

Pushed the footer placement (HEAD): "Updating the LAN binding…" now sits on the footer's left (role="status" for screen readers), with Cancel + the action button staying right. The addresses column holds only the URLs + loopback row, plus the inline failure box when a rebind fails. 391 web tests pass; placement verified in the real browser.

…warning back

User-approved layout from the design-mode mockup (原型/lan-modal-proposals.html):

- Header split: stable "LAN Access" title over a color-coded subtitle —
  grey "Restricted to the host machine" / green "Reachable on this
  network" / amber "Updating the LAN binding…" with a mini-spinner while
  a rebind is in flight (chip follows: grey WifiOff, green Wifi, amber).
  The subtitle is the single role=status surface — the footer busy slot
  is gone (user review: no duplicate when the header shows it).
- Addresses grouped by audience: "For other devices" with the IP URL
  FIRST (the one the QR encodes — caption now says "Scans the IP
  address") then the hostname; "This machine" holds the loopback row,
  which gains a copy button for symmetry. Rows get a subtle elevated
  background.
- Security warning restored while restricted — the line the old confirm
  dialog carried, in the user's wording: "If Enabled, ProFiles will be
  reachable by anyone on this network." Hidden once LAN is on or a
  rebind is in flight.

391 web tests pass (31 files); verified in the real browser across an
enable → disable round trip with the rebuilt dist (machine restored to
loopback-only).
@falbany

falbany commented Nov 19, 2026

Copy link
Copy Markdown
Owner Author

Pushed the approved mockup layout (HEAD): header carries the status (stable "LAN Access" title + color-coded subtitle — grey/green/amber with mini-spinner during a rebind, chip follows), addresses grouped ("For other devices": IP first — the QR's target, caption "Scans the IP address" — then hostname; "This machine": loopback, now copyable), and the security warning restored while restricted in your wording: "If Enabled, ProFiles will be reachable by anyone on this network." The footer busy slot is removed — the header subtitle is the single progress surface. 391 web tests pass; verified end-to-end in the real browser (machine restored to loopback-only).

Ctrl+N — the requested mnemonic — is reserved by browsers for "new
window": a page handler never fires and the WebView2 accelerator table
does the same on Windows, so the LAN modal lands on Ctrl+K instead
(free in this shortcut table, browser-overridable like the GitHub
palette). Wired in useGlobalShortcuts next to the other surface
openers, guarded by the inert-while-modal rule (#55); ShortcutsModal
lists it; the second deps fixture (useBarcodeMode cross-hook harness)
gains the new setter.

391 web tests pass; the handler was exercised in the real browser via
the page's keydown path (real-key automation was inconclusive — the
review tab runs backgrounded and Chrome suppresses input to hidden
tabs — same mechanism as the table's existing shortcuts).
@falbany

falbany commented Nov 19, 2026

Copy link
Copy Markdown
Owner Author

Added a Ctrl + K shortcut to open the LAN modal (HEAD): wired in useGlobalShortcuts next to the other surface openers (inert while a modal is open, per #55), listed in the Shortcuts dialog. \n\nWhy not Ctrl+N: browsers reserve it for "new window" — a page handler never fires, and WebView2's accelerator table does the same on Windows, so the requested mnemonic would have been dead everywhere. Ctrl+K is free in the table and browser-overridable (GitHub palette precedent). Happy to re-key it if you prefer another combo.\n\n391 web tests pass (shortcut pinned in the hooks tests incl. the Ctrl+Shift+K disambiguation); handler exercised in the real browser via the keydown path.

@falbany
falbany merged commit ce8b320 into main Nov 19, 2026
3 checks passed
@falbany
falbany deleted the feat/lan-modal-197-198-199 branch November 19, 2026 00:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant