Commit Graph

17 Commits

Author SHA1 Message Date
Denis 851b7681ff Add held mouse buttons (Left click / Right click toggles) to the Touchpad tab
Two toggle buttons in the free corners of the D-pad press and hold the PC's
left or right mouse button until tapped again, for drag and drop, text
selection and window moves, with the touchpad moving the pointer in between.

- New input action "button" ({button, pressed}); the state carries
  input.buttons. VirtualInput remembers which connection pressed each button.
- A click on a held button is ignored so a touchpad tap does not drop the
  drag; the other button stays usable. Repeating a state is a no-op.
- A held button is always released: when its client disconnects (only its own
  buttons), when the server stops, and in the client when the tab is left or
  the page is hidden.
- Incoming states are set aside for 500 ms after a local tap, so a state
  already in flight cannot undo the toggle for a moment.
- D-pad rows are equal-sized (minmax(0, 1fr)) so the corner buttons do not
  stretch the top row.

tests/test_input.py covers the device logic and the full server (disconnect,
several clients); tests/test_ui_mouse_hold.py drives a real Chromium. Also
checked through the real uinput device with its pointer grabbed exclusively.
README (fr/en) and CLAUDE.md are updated.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-31 09:02:19 +01:00
Denis Defolie c6523ac213 Media tab: several players per file type, chosen by long press
Each type (sound, image, video) can now have 1 to 8 named players on
/admin, reordered with the arrows; the first opens by default. A tap opens
with it, a long press (or right click) on a file lists the others. The
open_media message takes an optional opener id; the client can only name a
player already configured for the file's type, and the command is still
rebuilt from the database. Tablets receive player names and kinds (never
the spec) and are notified on every change.

media_openers (one row per type) becomes media_players; existing settings
are migrated as unnamed players whose id is the type, so the old
PUT /api/media/openers/<type> keeps working. A type always keeps a player.

With real touch events the click following a long press landed on the
chooser backdrop (closing it at once) or on one of its buttons (opening a
player by mistake); clicks of the opening gesture are now ignored.

Tests: store, migration, REST, WebSocket choice and refusals, and a
Chromium test with touch long press, release click, Escape and right click.
The UI tests no longer leave /admin before the token is stored.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-30 17:28:04 +01:00
Denis Defolie 6c1a7efb0d Media tab: sort by name, date or size, and thumbnails for videos and sounds
The listing now returns the date (v) and size of every file, not just of
images. A selector next to the type filters sorts files by name (natural
order, default), date (newest first) or size (largest first), client side;
folders stay first and the choice is remembered on the tablet.

Video and sound tiles now request /thumb like images (the server already
made them). The existing icon fallback covers a sound without a cover.
Audio and video tiles with a thumbnail get a border in their type colour.

Tests: listing date and size, a Chromium sort test with three files whose
name, date and size orders all differ (kept after reload), and a
thumbnail test with real ffmpeg. Both UI tests were checked to fail when
the feature is reverted.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-30 16:57:29 +01:00
Denis Defolie df2c9b8933 Add make test-ui: Chromium flows against the real isolated server
New tests/test_ui_flows.py drives headless Chromium through the Media tab
(folders, breadcrumbs, filters, search, opening a hostile file name),
launchers (real launches of a command, a .desktop and a web launcher, live
grid updates) and the /admin page (edit, add, reorder, delete, file
openers used when opening a file). Any uncaught JavaScript exception fails
the test. Four UI mutations were checked to fail their test.

The driver now launches Chromium without any D-Bus session (a first
attempt let it activate real services on the test bus) and records
JavaScript exceptions. wait_for retries while the page is loading, which
fixes a race in test_ui_text_button; the older UI tests register their
cleanups before setup can fail, so a failed setup no longer leaks a
Chromium process.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-30 16:42:52 +01:00
Denis Defolie 64b9b15f19 Add make test-integration: full server scenario on a private D-Bus bus
Real MediaDeckServer under aiohttp.test_utils, private session bus,
isolated XDG dirs and PATH, fake MPRIS player and fake gio/pactl/launcher
programs that log their arguments. Covers authentication, player listing
and control, audio, media listing and path escapes, shell-free opening of
a hostile file name, imported launchers and admin changes pushed to
clients. Verified to fail when the hidden-component check, the token check
or the metadata enrichment is removed.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-30 15:46:17 +01:00
Denis Defolie 75a7e108d7 Warn when the detected advertised address is on a virtual interface
make url, make qr and make cert now print a warning (with candidate
addresses of real interfaces) when the address found through the default
route belongs to a tunnel or bridge, which the tablet cannot reach and
which the HTTPS certificate would wrongly cover. Silent when
server.advertise_host or an explicit server.host is set.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-30 15:31:07 +01:00
Denis 97cf2afb53 Document the certificate pitfalls behind "Your connection is not private"
The certificate is only valid for the advertised address (advertise_host), the
machine name and localhost: a PC reachable by cable and Wi-Fi has two addresses
and only the advertised one works. README (fr/en) says so; CLAUDE.md lists the
three causes to check in order (certificate issued for a VPN tunnel address,
CA not installed - each machine has its own CA -, other address of the PC),
with the read-only openssl probe that showed 10.2.0.2 in the SAN of a
certificate made while a VPN was active.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-26 19:27:55 +01:00
Denis 2fdb8f4ea0 Explain a greyed "Keyboard" button: show the reason on tap and log it
On a fresh install features.text_input is false, so the Keyboard button of the
Remote tab was greyed out, with the reason only in a title tooltip that cannot
be read on a tablet.

- The button now uses aria-disabled instead of disabled (same look); tapping
  it shows the reason in a toast instead of doing nothing.
- The server logs "text entry enabled" or "text entry unavailable: <reason>"
  at startup.
- README (fr/en): text entry is listed as optional and off by default in the
  installation steps, and the possible reasons are documented.

tests/test_ui_text_button.py (real Chromium) and a startup-log test in
tests/test_text.py cover it.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-26 19:05:39 +01:00
Denis 2892e39c71 Installation: tell VPN users to set advertise_host before make cert
make url, make qr and make cert take the PC address from the default route,
which goes through the tunnel when a VPN is active (e.g. 10.2.0.2 with Proton
VPN's WireGuard); the QR code then points to an address the tablet cannot
reach and the HTTPS certificate is issued for it.

The README (fr/en) installation steps, the example config and CLAUDE.md now
say to put the PC's local-network address in server.advertise_host before
make cert, how to find it (ip -4 -br addr), and that rerunning make cert
afterwards reissues the server certificate while keeping the CA.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-26 17:30:06 +01:00
Denis 7818cf5d17 Document the secure (HTTPS) mode in the installation steps
The quick start now lists `make cert` and the optional `make http-on`, with the
order (after `make config`, before `make service-install`), the reminder to run
make from the project folder rather than ~/.config/mediadeck, and a short
comparison of the secure and unsecured accesses. README fr/en and the command
list of CLAUDE.md are updated.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-26 17:15:42 +01:00
Denis 6bd8cbc822 Add [media] follow_symlinks and list make qr in the quick start
follow_symlinks (default true) keeps the new behaviour of following links
wherever they point; false restores the strict rule: only links whose target
stays inside the configured folder are followed, the search does not walk
linked folders, no picture is taken from outside the root and players are not
matched to a library file through a link.

The README (fr/en) quick start now lists `make qr`, next to `make url`.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-26 16:58:14 +01:00
Denis 167a4c674b Media tab: follow symbolic links wherever they point
Folders kept on another disk and linked from a configured media folder
(~/Videos/Cinema -> /datadisk/...) were hidden by the rule that the real path
must stay inside the root.

- Links are followed when listing, opening, searching and making thumbnails.
  What still bounds access: no absolute path, "..", or hidden component from
  the client, a closed list of extensions, and the type taken from the real
  file (lien.mp3 -> script.sh stays refused).
- Search follows links without scanning a folder twice (loops, second link to
  the same folder) and reports results under their link path.
- Players receive the path under the root, links kept (MediaLibrary.open_path),
  so the path they announce over MPRIS still maps to a library file (title and
  picture); locate() also resolves paths reached through a link.
- The picture next to a media file is looked up beside the real file.
- Tests for each case, including the path given to the player; docs updated.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-26 16:50:37 +01:00
Denis 1de5685338 Add thumbnails, name search and a title/image in the Playing tab; keep player controls visible
- Thumbnails (ffmpeg, optional): square crops of images, a frame or poster of
  videos, embedded or folder cover of sounds, cached on disk; /thumb route
  protected by the token like /art. [media] thumbnails = false disables it.
- Name search in the Media tab (server side, accents and case ignored, all
  words required, bounded by result count, scanned entries and time).
- Playing tab: title and picture for files of the library (also when the
  player gives none), and a "last opened file" card when no player runs.
- The player controls and the volume bar never leave the visible area:
  sticky controls and height breakpoints; tests/test_ui_layout.py measures
  13 window sizes in a real Chromium driven over DevTools (tests/uidriver.py).
- Static files are served under /static/<version>/ and pages are revalidated,
  so a tablet no longer keeps an old interface from its heuristic cache.
- Documentation (README fr/en, CLAUDE.md, config.example.toml, make deps).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-26 16:28:14 +01:00
Denis 5921b7c414 Add the Media tab: browse sound, image and video files and open them on the PC
Media tab (needs at least one folder, hidden otherwise):
- Folders from [media] roots in config.toml, default = the user's Music, Videos
  and Pictures (XDG, never $HOME); [] disables the tab
- Icons per type, subfolders, breadcrumb, back, refresh, All/Sounds/Images/
  Videos filter; a tap opens the file on the PC (WebSocket system/open_media)
- Three special launchers (audio, image, video), editable on /admin: system
  default (gio open), installed application (gio launch) or a raw command
  (allow_custom_command); the file path is appended as the last argument
- The client never sends an absolute path: (root, relative path) is resolved
  server side; refuses "..", hidden entries, symlinks leaving the root, and
  anything but known media extensions (a script renamed .mp3 is refused)
- GET /api/media (Bearer token), listing runs in a thread, 1000 entries max

Interface cache: pages are revalidated (Cache-Control: no-cache) and static
files are served under /static/<version>/ (immutable cache), so a tablet can
no longer keep an old interface after an update. Reproduced and verified:
opening the same link serves the cached page, one refresh fixes it for good.

Refactors: restapi.py (shared REST helpers), AppPicker (shared by the launcher
and opener forms on /admin).

Tests: 159 (library escapes, openers, admin API, config, cache headers). Also
checked end to end with a real server (fake gio recording its arguments) and
headless Chromium. Not tried on the real tablet.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-26 13:32:37 +01:00
Denis 353f36c888 Merge the Playing and Sound tabs; keep the volume bar always visible
- One "Playing" tab: the MPRIS player, then a volume bar (mute, master volume,
  button showing the active output). Frees a slot in the tab bar (4 tabs)
- The output list opens as a floating window above the bar (button, outside
  click or Escape closes it), so it never moves or squeezes the player
- Layout: the player takes the remaining height and scrolls inside its own
  area if needed; the bar stays at the bottom whatever the height. The cover
  is sized from the available height (cqh). Height steps for short screens;
  the output name is hidden on phones
- Fix: the cover's drop shadow greyed the title in portrait
- A stored "audio" tab falls back to "player"; WebSocket protocol unchanged

Checked in headless Chromium with a mock server (landscape 1280x800 down to
800x412, portrait, phone; with/without player and audio; interactions; no JS
errors). Not tried on the real tablet. README fr/en and CLAUDE.md updated.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-26 12:42:40 +01:00
Denis 27c8eeb37c Offer secure (HTTPS) and unsecured (HTTP) access side by side, add a QR codes page
Optional plain HTTP port next to HTTPS (server.http_port, off by default):
- open_sites()/serve() replace web.run_app: one AppRunner, two TCPSites, so the
  tablet picks https://<ip>:8765 or http://<ip>:8766 without a restart
- http_port requires TLS and must differ from port (validated in config.py)
- make http-on / http-off (--http-port N) write or remove the line, restoring
  the file if the result is invalid; make firewall accepts HTTP_PORT
- make url prints both addresses and QR codes

QR codes page (make qr, --qr):
- self-contained HTML written with mode 600 in $XDG_RUNTIME_DIR and opened as
  file://, never served: the codes contain the access token
- qrencode SVG with crispEdges (no seams between modules), fr/en from LANG
- cards for HTTPS, HTTP and the CA certificate, depending on the config

Tests: 107 (dual listeners with the local CA, set_http_port, QR page content
and file mode). Docs: README fr/en and CLAUDE.md updated.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-26 11:55:50 +01:00
Denis e823b2d470 Initial commit: MediaDeck web remote for a Linux media PC
Python bridge (aiohttp, single asyncio loop) between a tablet browser and
a Linux media PC: MPRIS players, PipeWire audio (pactl), virtual keyboard
and touchpad (uinput), power and session control (logind).

- Tablet UI with player, audio, touchpad, launchers and system tabs (fr/en)
- Launchers stored in SQLite and managed from /admin; raw commands are
  opt-in (admin.allow_custom_command)
- Optional text entry, translated to key presses from the PC's real
  keyboard layout with libxkbcommon and never through the clipboard
  (features.text_input, off by default)
- Local HTTPS with a private CA restricted by name constraints (make cert)
- Token-protected WebSocket and REST API, strict CSP, no JS dependencies

Checked: pyright 0 errors, 87 unit tests, browser tests in headless
Chromium. Not yet exercised on the real tablet, nor with real uinput key
presses.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-23 23:33:10 +02:00