From 261a25e6df3c22191721fdde8ea5efe84985361c Mon Sep 17 00:00:00 2001 From: Brian Krabach Date: Mon, 30 Mar 2026 08:05:14 -0700 Subject: [PATCH] =?UTF-8?q?feat:=20inject=20hostname=20into=20page=20title?= =?UTF-8?q?=20=E2=80=94=20visible=20in=20browser=20tabs=20across=20machine?= =?UTF-8?q?s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- muxplex/main.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/muxplex/main.py b/muxplex/main.py index 7e30a70..505e27e 100644 --- a/muxplex/main.py +++ b/muxplex/main.py @@ -14,6 +14,7 @@ import logging import os import pathlib import pwd +import socket import subprocess import sys import time @@ -282,11 +283,15 @@ class CreateSessionPayload(BaseModel): # --------------------------------------------------------------------------- -# Frontend directory +# Frontend directory + hostname # --------------------------------------------------------------------------- _FRONTEND_DIR = pathlib.Path(__file__).parent / "frontend" +# Short hostname (no domain) injected into page titles so browser tabs show +# which machine each muxplex instance is running on. +_HOSTNAME = socket.gethostname().split(".")[0] + # --------------------------------------------------------------------------- # Routes @@ -564,6 +569,18 @@ async def terminal_ws_proxy(websocket: WebSocket) -> None: # --------------------------------------------------------------------------- +@app.get("/", response_class=HTMLResponse) +@app.get("/index.html", response_class=HTMLResponse) +async def index_page(): + """Serve index.html with hostname injected into the page title.""" + html = (_FRONTEND_DIR / "index.html").read_text() + html = html.replace( + "muxplex", + f"{_HOSTNAME} \u2014 muxplex", + ) + return HTMLResponse(html) + + @app.get("/login", response_class=HTMLResponse) async def login_page(): """Serve branded login.html with injected window.MUXPLEX_AUTH containing auth mode and username.""" @@ -573,6 +590,10 @@ async def login_page(): html = html.replace( "", f"" ) + html = html.replace( + "Sign in \u2014 muxplex", + f"Sign in \u2014 {_HOSTNAME} \u2014 muxplex", + ) return HTMLResponse(html)