From 73b034aa18210ecfedaa541e4693df33156f1e2a Mon Sep 17 00:00:00 2001 From: Hector Ventura Date: Tue, 13 Oct 2026 22:26:58 -0500 Subject: [PATCH] feat(ui): turn the landing page into a dashboard with a built-in wait view (#5594) * feat(ui): turn the landing page into a dashboard with a built-in wait view The page served to browsers on / becomes a dashboard: how to connect (endpoint, region, account and copyable snippets), the init stages and scripts, runtime facts, services grouped by category with a filter, and an opt-in news panel. The top bar shows the emulator status and its version, and reports "Shutting down" once shutdown has started. The news panel makes no request until it is turned on. It then reads floci.io/news.json, a feed shared by every Floci emulator: an item may carry a product, and this page shows items for "aws" and items with no product. The choice is remembered in local storage when the browser allows it and otherwise lasts for the page view. An item without a date is shown without one. The "starting Floci UI" interstitial is now a second view of the same file, picked from the request path, so /_floci/ui serves index.html and starting.html is removed. The wait view shows elapsed time, the error the emulator reports, and a retry, and still redirects once the UI sidecar is ready. StartingPageEscapesUntrustedTextTest now reads index.html: the launch error must go through textContent and the status error shown on the dashboard must be escaped. Signed-off-by: Hector Ventura * fix(ui): correct the update hint and the news gate wording, drop em-dashes The release note told users to run "floci update", which replaces only the CLI binary; "floci start" pulls with the "missing" policy and "floci restart" forces it, so a cached image stayed in place. The note now says to pull the new image and restart, and gives the CLI form: "floci stop", then "floci start --pull always". The news gate said the page only talks to the local emulator, which is not true while the fonts load from Google Fonts. It now says what holds: nothing is fetched from the news host until news is turned on. Em-dashes are removed from the UiController Javadoc, the Runtime placeholders and the page title. Signed-off-by: Hector Ventura --------- Signed-off-by: Hector Ventura --- .../floci/lifecycle/UiController.java | 9 +- .../floci/services/floci/ui/UiPages.java | 21 +- src/main/resources/ui/index.html | 953 +++++++++++++----- src/main/resources/ui/starting.html | 80 -- .../StartingPageEscapesUntrustedTextTest.java | 40 +- 5 files changed, 759 insertions(+), 344 deletions(-) delete mode 100644 src/main/resources/ui/starting.html diff --git a/src/main/java/io/github/hectorvent/floci/lifecycle/UiController.java b/src/main/java/io/github/hectorvent/floci/lifecycle/UiController.java index 72e70a1497..c76117ffd6 100644 --- a/src/main/java/io/github/hectorvent/floci/lifecycle/UiController.java +++ b/src/main/java/io/github/hectorvent/floci/lifecycle/UiController.java @@ -16,9 +16,10 @@ import jakarta.ws.rs.core.Response; * Browser-facing endpoints that launch and redirect to the floci-ui sidecar. * *
    - *
  • {@code GET /_floci/ui} — kicks off the sidecar start (async) and returns a - * small interstitial page that polls {@code /status} and redirects when ready.
  • - *
  • {@code GET /_floci/ui/status} — JSON {@code {ready, url, error}} the + *
  • {@code GET /_floci/ui}: kicks off the sidecar start (async) and returns the + * landing page, which shows its wait view on this path: it polls {@code /status} + * and redirects when ready.
  • + *
  • {@code GET /_floci/ui/status}: JSON {@code {ready, url, error}} the * interstitial polls.
  • *
*/ @@ -38,7 +39,7 @@ public class UiController { @Produces(MediaType.TEXT_HTML) public Response ui() { uiManager.ensureStartedAsync(); - return Response.ok(uiPages.startingHtml()).build(); + return Response.ok(uiPages.landingHtml()).build(); } @RegisterForReflection diff --git a/src/main/java/io/github/hectorvent/floci/services/floci/ui/UiPages.java b/src/main/java/io/github/hectorvent/floci/services/floci/ui/UiPages.java index 1b6da98c68..c2f25993b4 100644 --- a/src/main/java/io/github/hectorvent/floci/services/floci/ui/UiPages.java +++ b/src/main/java/io/github/hectorvent/floci/services/floci/ui/UiPages.java @@ -7,20 +7,18 @@ import java.io.InputStream; import java.nio.charset.StandardCharsets; /** - * Loads and caches the small embedded HTML pages served to browsers: the Floci - * landing page and the "starting the UI" interstitial. Resources are read from - * the classpath ({@code ui/*.html}) and must be registered in - * {@code quarkus.native.resources.includes} so they are embedded in the native - * image. + * Loads and caches the embedded HTML page served to browsers. One file holds two + * views, the dashboard and the "starting the UI" wait view, and picks between them + * from the request path. It is read from the classpath ({@code ui/*.html}) and must + * be registered in {@code quarkus.native.resources.includes} so it is embedded in + * the native image. */ @ApplicationScoped public class UiPages { private static final String LANDING_RESOURCE = "ui/index.html"; - private static final String STARTING_RESOURCE = "ui/starting.html"; private volatile String landing; - private volatile String starting; public String landingHtml() { String result = landing; @@ -31,15 +29,6 @@ public class UiPages { return result; } - public String startingHtml() { - String result = starting; - if (result == null) { - result = readResource(STARTING_RESOURCE); - starting = result; - } - return result; - } - private static String readResource(String resourceName) { ClassLoader loader = UiPages.class.getClassLoader(); try (InputStream input = loader.getResourceAsStream(resourceName)) { diff --git a/src/main/resources/ui/index.html b/src/main/resources/ui/index.html index c40209e9f4..98f8d486ef 100644 --- a/src/main/resources/ui/index.html +++ b/src/main/resources/ui/index.html @@ -3,287 +3,780 @@ - Floci — local AWS emulator + Floci: local AWS emulator + - + -
-
- - - connecting… - -
-

Any cloud. Locally. — a local AWS emulator speaking real AWS wire protocols.

-

You've reached the Floci endpoint. Point your AWS SDK or CLI here with - --endpoint-url http://localhost:4566 and it behaves like AWS.

-
-
Endpoint
http://localhost:4566
-
Region
us-east-1 (default)
-
Account
000000000000
-
Version
…
-
-
-
-

Services

- — running · — available +
+ + + + + Connecting… + + + +
+
+ +
+
+
+

Connect

+

Point any AWS SDK or CLI at this endpoint and it behaves like AWS. Any credentials work.

+
+
Endpoint
+
Region
us-east-1
+
Account
000000000000
+
+
+ + + +
- -
-
Loading services…
+
+

       
-
- - Open Floci UI → - -

The UI launches on demand as a sidecar container the first time you open it. -  ·  health · info

-
+
- + } + start(); + })(); + diff --git a/src/main/resources/ui/starting.html b/src/main/resources/ui/starting.html deleted file mode 100644 index acf09cc5cf..0000000000 --- a/src/main/resources/ui/starting.html +++ /dev/null @@ -1,80 +0,0 @@ - - - - - - Starting Floci UI… - - - -
-
-

Starting Floci UI…

-

Launching the UI container. This can take a moment the first time while the image is pulled.

-
- - - diff --git a/src/test/java/io/github/hectorvent/floci/services/floci/ui/StartingPageEscapesUntrustedTextTest.java b/src/test/java/io/github/hectorvent/floci/services/floci/ui/StartingPageEscapesUntrustedTextTest.java index 3e3b87c371..34fe84fbeb 100644 --- a/src/test/java/io/github/hectorvent/floci/services/floci/ui/StartingPageEscapesUntrustedTextTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/floci/ui/StartingPageEscapesUntrustedTextTest.java @@ -13,31 +13,43 @@ import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; /** - * Guards the startup interstitial against HTML/script injection through server-derived error - * text. {@code /_floci/ui/status} forwards {@code error} straight from the floci-ui sidecar's own + * Guards the landing page against HTML/script injection through server-derived error text. + * {@code /_floci/ui/status} forwards {@code error} straight from the floci-ui sidecar's own * health JSON ({@link FlociUiManager}'s {@code unavailableMessage}) and from Docker daemon - * exception messages, so the polling script in {@code starting.html} must render that text as - * text, never parse it as markup. + * exception messages, so both views of {@code index.html} must render that text as text, never + * parse it as markup: the wait view through {@code textContent}, the dashboard through + * {@code escapeHtml}. */ class StartingPageEscapesUntrustedTextTest { - private static final Path STARTING_PAGE = Path.of("src", "main", "resources", "ui", "starting.html"); - private static final Pattern MSG_HTML_ASSIGNMENT = Pattern.compile("\\bmsg\\.innerHTML\\s*="); - private static final Pattern MSG_TEXT_ASSIGNMENT = Pattern.compile("\\bmsg\\.textContent\\s*="); + private static final Path LANDING_PAGE = Path.of("src", "main", "resources", "ui", "index.html"); + private static final Pattern ERROR_HTML_ASSIGNMENT = Pattern.compile("\\(\"launch-error\"\\)\\.innerHTML\\s*="); + private static final Pattern ERROR_TEXT_ASSIGNMENT = Pattern.compile("\\(\"launch-error\"\\)\\.textContent\\s*="); + private static final Pattern RAW_ERROR_CONCATENATION = Pattern.compile("\\+\\s*(?:ui|s)\\.error\\b"); @Test void failRendersServerTextWithoutParsingItAsHtml() { - String content = readStartingPage(); + String content = readLandingPage(); - assertFalse(MSG_HTML_ASSIGNMENT.matcher(content).find(), - "starting.html must not assign the status message through innerHTML"); - assertTrue(MSG_TEXT_ASSIGNMENT.matcher(content).find(), - "starting.html must render the untrusted status message with textContent"); + assertFalse(ERROR_HTML_ASSIGNMENT.matcher(content).find(), + "index.html must not assign the launch error through innerHTML"); + assertTrue(ERROR_TEXT_ASSIGNMENT.matcher(content).find(), + "index.html must render the untrusted launch error with textContent"); } - private static String readStartingPage() { + @Test + void dashboardEscapesServerTextBeforeConcatenatingItIntoHtml() { + String content = readLandingPage(); + + assertFalse(RAW_ERROR_CONCATENATION.matcher(content).find(), + "index.html must not concatenate the status error into markup unescaped"); + assertTrue(content.contains("escapeHtml(ui.error)"), + "index.html must escape the status error shown in the Runtime block"); + } + + private static String readLandingPage() { try { - return Files.readString(STARTING_PAGE, StandardCharsets.UTF_8); + return Files.readString(LANDING_PAGE, StandardCharsets.UTF_8); } catch (IOException e) { throw new UncheckedIOException(e); }