diff --git a/ROADMAP.md b/ROADMAP.md index c08ca0a79..0b5477acc 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -136,15 +136,15 @@ graph LR analytics_token_drain_graphs --> analytics_default_landing classDef done fill:#1f7a1f,stroke:#0d3d0d,color:#ffffff; - classDef todo fill:#6e7781,stroke:#3d4248,color:#ffffff; + classDef in_review fill:#9a6700,stroke:#5c3d00,color:#ffffff; class analytics_token_drain_graphs done; - class analytics_default_landing todo; + class analytics_default_landing in_review; ``` | Task | Status | Refs | | --- | --- | --- | | Per-server / per-tool token-drain graphs | 🟢 Done | — | -| Make dashboard the default landing page | ⚪ Todo | — | +| Make dashboard the default landing page | 🟡 In review | — | @@ -804,3 +804,4 @@ Legend: `shipped` ≥95% checked · `in-flight` 1–94% · `drafted` 0% · `—` | [098-tools-preflight](./specs/098-tools-preflight/) | `in-flight` | 26/33 (79%) | | [099-describe-check-mode](./specs/099-describe-check-mode/) | `in-flight` | 9/10 (90%) | | [100-prompt-rugpull-baseline](./specs/100-prompt-rugpull-baseline/) | — | — | +| [102-schema-deferred](./specs/102-schema-deferred/) | — | — | diff --git a/frontend/src/components/SidebarNav.vue b/frontend/src/components/SidebarNav.vue index 5016eb6c2..bf20844a7 100644 --- a/frontend/src/components/SidebarNav.vue +++ b/frontend/src/components/SidebarNav.vue @@ -655,9 +655,13 @@ const userInitials = computed(() => { return name.substring(0, 2).toUpperCase() }) +// Dashboard panels are deep-linkable routes that all render the Dashboard, so +// the "Dashboard" entry stays highlighted on each of them. +const DASHBOARD_PATHS = ['/', '/usage', '/overview'] + function isActiveRoute(path: string): boolean { if (path === '/') { - return route.path === '/' + return DASHBOARD_PATHS.includes(route.path) } return route.path.startsWith(path) } diff --git a/frontend/src/router/index.ts b/frontend/src/router/index.ts index 62a422280..2f8551ffd 100644 --- a/frontend/src/router/index.ts +++ b/frontend/src/router/index.ts @@ -12,12 +12,37 @@ const router = createRouter({ meta: { title: 'Sign In', public: true }, }, // Existing routes (admin/personal) + // + // The landing page (`/`) opens the Dashboard on its Usage (analytics) + // panel — that is the "analytics dashboard as default landing page" + // behaviour. `/usage` and `/overview` render the same Dashboard component + // so each panel is deep-linkable and survives a reload; `meta.dashboardView` + // is what the component reads to pick the active panel. { path: '/', name: 'dashboard', component: Dashboard, meta: { title: 'Dashboard', + dashboardView: 'usage', + }, + }, + { + path: '/usage', + name: 'usage', + component: Dashboard, + meta: { + title: 'Usage Analytics', + dashboardView: 'usage', + }, + }, + { + path: '/overview', + name: 'dashboard-overview', + component: Dashboard, + meta: { + title: 'Overview', + dashboardView: 'overview', }, }, { diff --git a/frontend/src/stores/servers.ts b/frontend/src/stores/servers.ts index cbb75a348..7c3045d8b 100644 --- a/frontend/src/stores/servers.ts +++ b/frontend/src/stores/servers.ts @@ -9,6 +9,14 @@ export const useServersStore = defineStore('servers', () => { const servers = ref([]) const loading = ref({ loading: false, error: null }) + // True once a server list has been fetched successfully at least once — the + // only reliable way to tell "no servers configured" from "we don't know yet". + // `servers` starts empty, and `loading.error` cannot stand in for this: it is + // shared state that any caller (including silent background refreshes and + // other components fetching concurrently) can write, and a success never + // clears it. + const loaded = ref(false) + // Computed const serverCount = computed(() => ({ total: servers.value.length, @@ -87,17 +95,35 @@ export const useServersStore = defineStore('servers', () => { return result.sort((a, b) => a.name.localeCompare(b.name)) } + // The server list has three independent writers: a fetch from any component + // (App.vue and Dashboard.vue both issue one on mount), a silent background + // refresh, and the Spec 047 SSE full-list payload. None of them cancel the + // others, so every write takes a ticket in issue order and a response that + // was already in flight when a newer list was applied is dropped — otherwise + // a stale list can resurrect servers the user just deleted, or blank out ones + // they just added. + let issueSeq = 0 + let appliedSeq = 0 + + function applyServerList(list: Server[], ticket: number) { + if (ticket < appliedSeq) return + appliedSeq = ticket + // Smart merge preserves object references and avoids unnecessary re-renders + servers.value = mergeServers(servers.value, list) + loaded.value = true + } + // Actions async function fetchServers(silent = false) { if (!silent) { loading.value = { loading: true, error: null } } + const ticket = ++issueSeq try { const response = await api.getServers() if (response.success && response.data) { - // Use smart merge to preserve object references and avoid unnecessary re-renders - servers.value = mergeServers(servers.value, response.data.servers) + applyServerList(response.data.servers, ticket) } else { loading.value.error = response.error || 'Failed to fetch servers' } @@ -309,8 +335,14 @@ export const useServersStore = defineStore('servers', () => { try { const response = await api.deleteServer(serverName) if (response.success) { - // Remove server from local state - servers.value = servers.value.filter(s => s.name !== serverName) + // Removing the server locally is itself an authoritative list state, so + // it claims the newest ticket: a GET that was already in flight when the + // delete landed would otherwise pass the sequencing check and restore + // the server the user just deleted. + applyServerList( + servers.value.filter(s => s.name !== serverName), + ++issueSeq + ) return true } else { throw new Error(response.error || 'Failed to delete server') @@ -370,7 +402,9 @@ export const useServersStore = defineStore('servers', () => { // when running against an older core that publishes notify-only events. const payload = customEvent.detail?.payload if (payload && Array.isArray(payload.servers)) { - servers.value = mergeServers(servers.value, payload.servers as Server[]) + // Authoritative and newer than anything currently in flight, so it takes + // the newest ticket — and it counts as a successful load in its own right. + applyServerList(payload.servers as Server[], ++issueSeq) return } @@ -392,6 +426,7 @@ export const useServersStore = defineStore('servers', () => { // State servers, loading, + loaded, // Computed serverCount, diff --git a/frontend/src/views/Dashboard.vue b/frontend/src/views/Dashboard.vue index 9564283df..4a1859740 100644 --- a/frontend/src/views/Dashboard.vue +++ b/frontend/src/views/Dashboard.vue @@ -6,15 +6,10 @@ - + + UsageView are mounted only once the panel has been active + (usageEverActive) AND the server list has arrived, and stay code-split + behind Suspense, so the Dashboard shell still paints immediately + (SC-004). -->
- + +
+
+ + + +

Add your first server to see usage

+

+ No upstream MCP servers are configured yet, so there is nothing to chart. + Add one and this page will show call volume, token sinks, error rates and a timeline. +

+
+ + Browse Registry + +
+
+
+ +
+ +
+