Skip to content

Commit b53e452

Browse files
committed
fix(panel): clean up login screen copy and add runtime awareness
- Remove environment variable password hint from login form - Add `runtime` field to session info to indicate `"docker"` or `"process"` mode - Only show Docker-socket warning when panel is actually running in Docker mode - Refactor `SessionBody` creation into reusable `session_body()` function - Update TypeScript types with `PanelRuntime` type and runtime field
1 parent a722acf commit b53e452

7 files changed

Lines changed: 33 additions & 25 deletions

File tree

.textile-monorepo-source

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
cd5d47e8de947e521ceee2eb619f6da312c1a912
1+
549519de470ac23089c433e55e132b452658e0e5

.textile-stitch-release-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.1.151
1+
0.1.152

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "stitch-bot"
3-
version = "0.1.151"
3+
version = "0.1.152"
44
edition = "2021"
55
description = "Stitch — Textile filler-network operator bot; market-makes the filler order book with signed UniswapX limit orders."
66
license = "AGPL-3.0-or-later"

src/panel/http/session.rs

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,28 @@ pub struct SessionBody {
3030
/// True when the panel accepts a proxy identity header, so the UI can explain
3131
/// why it's waiting on `tailscale serve` instead of showing a blank page.
3232
tailnet_login: bool,
33+
/// How the panel supervises bots: `"docker"` or `"process"` (desktop).
34+
/// The login screen uses this to show a Docker-socket warning only when it
35+
/// applies.
36+
runtime: &'static str,
3337
}
3438

35-
/// Who am I? Never fails: an unauthenticated caller gets `authenticated: false`
36-
/// plus which login methods exist.
37-
pub async fn current(State(state): State<AppState>, req: axum::extract::Request) -> Response {
38-
let identity = identify(&state, &req).ok();
39-
Json(SessionBody {
39+
fn session_body(state: &AppState, identity: Option<&Identity>) -> SessionBody {
40+
SessionBody {
4041
authenticated: identity.is_some(),
41-
identity: identity.as_ref().map(|i| i.label().to_string()),
42+
identity: identity.map(|i| i.label().to_string()),
4243
password_login: state.cfg.auth.password_hash().is_some(),
4344
tailnet_login: state.cfg.trust_identity_header
4445
&& !state.cfg.auth.allowed_users().is_empty(),
45-
})
46-
.into_response()
46+
runtime: state.cfg.runtime.as_str(),
47+
}
48+
}
49+
50+
/// Who am I? Never fails: an unauthenticated caller gets `authenticated: false`
51+
/// plus which login methods exist.
52+
pub async fn current(State(state): State<AppState>, req: axum::extract::Request) -> Response {
53+
let identity = identify(&state, &req).ok();
54+
Json(session_body(&state, identity.as_ref())).into_response()
4755
}
4856

4957
#[derive(Deserialize)]
@@ -93,12 +101,7 @@ pub async fn login(
93101
tracing::info!("a password login succeeded");
94102
Ok((
95103
[(header::SET_COOKIE, session_cookie_header(&token))],
96-
Json(SessionBody {
97-
authenticated: true,
98-
identity: Some(Identity::Password.label().to_string()),
99-
password_login: true,
100-
tailnet_login: false,
101-
}),
104+
Json(session_body(&state, Some(&Identity::Password))),
102105
)
103106
.into_response())
104107
}
@@ -269,6 +272,7 @@ mod tests {
269272
assert_eq!(v["authenticated"], false);
270273
assert_eq!(v["passwordLogin"], true);
271274
assert_eq!(v["tailnetLogin"], false);
275+
assert_eq!(v["runtime"], "docker");
272276
}
273277

274278
#[tokio::test]

web/src/pages/Login.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,7 @@ export default function Login({
6363
aria-hidden
6464
className="sr-only"
6565
/>
66-
<Field
67-
label="Panel password"
68-
hint="The password you chose in the Stitch desktop app (or STITCH_PANEL_PASSWORD_HASH)."
69-
>
66+
<Field label="Panel password">
7067
<Input
7168
type="password"
7269
name="password"
@@ -99,9 +96,12 @@ export default function Login({
9996
</Card>
10097
)}
10198

102-
<p className="text-center text-xs text-faint">
103-
Whoever reaches this panel controls the Docker socket on this host.
104-
</p>
99+
{session.runtime === 'docker' && (
100+
<p className="text-center text-xs text-faint">
101+
Access to this panel includes control of the Docker socket on this
102+
host.
103+
</p>
104+
)}
105105
</div>
106106
</div>
107107
)

web/src/types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,15 @@ export interface SaveResult {
121121
message: string
122122
}
123123

124+
export type PanelRuntime = 'docker' | 'process'
125+
124126
export interface SessionInfo {
125127
authenticated: boolean
126128
identity: string | null
127129
passwordLogin: boolean
128130
tailnetLogin: boolean
131+
/** How the panel supervises bots. Desktop uses `process` (no Docker socket). */
132+
runtime: PanelRuntime
129133
}
130134

131135
export interface ActionResult {

0 commit comments

Comments
 (0)