feat(webui): history routing

createWebHistory with base "/". The Go server already falls back to index.html
for any unmatched path and [web] has no path-prefix option, so the dashboard is
always at the root.

legacy-hash-redirect.ts rewrites `#/path` links minted before this change.
Verified against archie-ui rather than the Vite dev server: /tasks, /tasks/42
and /settings all serve index.html with assets resolving, and #/settings lands
on /settings.
This commit is contained in:
sam committed 2026-09-20 18:14:37 +10:00
1 parent 83c939b3df
commit 8c83449cf4
11 files changed
+28 -41

No files matched your search

+7
View File
@@ -0,0 +1,7 @@
// Rewrites a legacy `#/path` URL to `/path`.
const legacy = window.location.hash;
if (legacy.startsWith("#/")) {
const path = legacy.slice(1);
window.history.replaceState(null, "", path + window.location.search);
}
+2
View File
@@ -1,3 +1,5 @@
import "./legacy-hash-redirect";
import { createApp } from "vue";
import App from "./App.vue";
+3 -14
View File
@@ -1,19 +1,8 @@
import { createRouter, createWebHashHistory } from "vue-router";
import { createRouter, createWebHistory } from "vue-router";
import Placeholder from "@/views/Placeholder.vue";
// The dashboard's route table, and the single source of truth for what the
// dashboard exposes.
//
// internal/gateway/dashboard_tools.go hand-copies this list so the chat agent
// can navigate the operator, and TestDashboardPagesRegistryCoversEveryRoute
// parses this file to hold the two in step. That test reads `const routes = [`
// through to `];`, one route per line, skipping `nav: false` entries -- keep
// the shape below literal enough for it to parse.
//
// Hash history, not web history: the dashboard is served from a path the build
// does not know (ui/embed.go embeds a relative-base bundle), and every existing
// link, bookmark and agent-issued navigation is of the form #/tasks.
// internal/gateway/dashboard_tools.go mirrors this table; its test parses this file.
const routes = [
{ path: "/", name: "dashboard", label: "Dashboard", component: Placeholder },
{ path: "/tasks", name: "tasks", label: "Tasks", component: Placeholder },
@@ -32,7 +21,7 @@ const routes = [
export const dashboardRoutes = routes;
export const router = createRouter({
history: createWebHashHistory(),
history: createWebHistory(),
routes,
});
-3
View File
@@ -1,9 +1,6 @@
<script setup lang="ts">
import { useRoute } from "vue-router";
// Every route resolves here until its view is ported. Named so an unported
// page is obvious in the running app rather than rendering blank -- the
// failure mode the Preact /chat route had.
const route = useRoute();
</script>