Skip to content

Commit 0c6ddf6

Browse files
committed
Distinguish Iris dashboard titles
1 parent 28163ea commit 0c6ddf6

3 files changed

Lines changed: 28 additions & 4 deletions

File tree

lib/iris/dashboard/src/template.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,15 @@
1212
document.documentElement.classList.add('dark');
1313
}
1414
} catch(e) {}
15+
16+
try {
17+
var params = new URLSearchParams(window.location.search);
18+
var dashboardTitle = (params.get('iris_title') || sessionStorage.getItem('iris-title') || '').trim();
19+
if (dashboardTitle) {
20+
sessionStorage.setItem('iris-title', dashboardTitle);
21+
document.title = dashboardTitle + ' | Iris';
22+
}
23+
} catch(e) {}
1524
</script>
1625
</head>
1726
<body class="bg-surface text-text font-sans antialiased">

lib/iris/src/iris/cli/cluster.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
find_marin_root,
2121
get_git_sha,
2222
)
23-
from iris.cli.main import IRIS_CLUSTER_CONFIG_DIRS, require_controller_url, rpc_client
23+
from iris.cli.main import IRIS_CLUSTER_CONFIG_DIRS, dashboard_url, require_controller_url, rpc_client
2424
from iris.cluster.config import IrisConfig, clear_remote_state, make_local_config
2525
from iris.cluster.controller.autoscaler.scaling_group import (
2626
build_worker_config_for_group,
@@ -267,11 +267,13 @@ def cluster_start(ctx, local: bool, fresh: bool):
267267
cluster = LocalCluster(config)
268268
address = cluster.start()
269269
click.echo(f"Controller started at {address}")
270+
title_url = dashboard_url(address, ctx.obj.get("cluster_name"))
270271
token = cluster.auto_login_token
271272
if token:
272-
click.echo(f"Dashboard: {address}?session_token={token}")
273+
separator = "&" if "?" in title_url else "?"
274+
click.echo(f"Dashboard: {title_url}{separator}session_token={token}")
273275
else:
274-
click.echo(f"Dashboard: {address}")
276+
click.echo(f"Dashboard: {title_url}")
275277
click.echo("\nController is running with integrated autoscaler.")
276278
click.echo("Press Ctrl+C to stop.")
277279
if threading.current_thread() is threading.main_thread():
@@ -567,7 +569,7 @@ def on_signal(sig, frame):
567569
signal.signal(signal.SIGINT, on_signal)
568570
signal.signal(signal.SIGTERM, on_signal)
569571

570-
click.echo(f"\nDashboard: {controller_url}")
572+
click.echo(f"\nDashboard: {dashboard_url(controller_url, ctx.obj.get('cluster_name'))}")
571573
click.echo(f"Controller RPC: {controller_url}")
572574
click.echo("\nPress Ctrl+C to close tunnel.")
573575
stop.wait()

lib/iris/src/iris/cli/main.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import logging as _logging_module
1010
import sys
1111
from pathlib import Path
12+
from urllib.parse import parse_qsl, urlencode, urlsplit, urlunsplit
1213

1314
import click
1415

@@ -82,6 +83,18 @@ def resolve_cluster_name(
8283
return "default"
8384

8485

86+
def dashboard_url(controller_url: str, cluster_name: str | None) -> str:
87+
"""Return a dashboard URL that lets the frontend set a cluster-specific tab title."""
88+
name = (cluster_name or "").strip()
89+
if not name:
90+
return controller_url
91+
parsed = urlsplit(controller_url)
92+
query = [(key, value) for key, value in parse_qsl(parsed.query, keep_blank_values=True) if key != "iris_title"]
93+
query.append(("iris_title", name))
94+
path = parsed.path or "/"
95+
return urlunsplit((parsed.scheme, parsed.netloc, path, urlencode(query), parsed.fragment))
96+
97+
8598
def create_client_token_provider(
8699
auth_config: config_pb2.AuthConfig, cluster_name: str = "default"
87100
) -> TokenProvider | None:

0 commit comments

Comments
 (0)