diff --git a/apps/web/src/app/app/(primary_layout)/(chat_experience)/chats/[chatId]/dashboards/[dashboardId]/layout.tsx b/apps/web/src/app/app/(primary_layout)/(chat_experience)/chats/[chatId]/dashboards/[dashboardId]/layout.tsx
index 69cae866c..8f36c8ff1 100644
--- a/apps/web/src/app/app/(primary_layout)/(chat_experience)/chats/[chatId]/dashboards/[dashboardId]/layout.tsx
+++ b/apps/web/src/app/app/(primary_layout)/(chat_experience)/chats/[chatId]/dashboards/[dashboardId]/layout.tsx
@@ -1,13 +1,4 @@
-import { DashboardLayout } from '@/layouts/DashboardLayout';
+import DashboardLayout, { generateMetadata } from '@dashboards/layout';
-export default async function Layout({
- children,
- params
-}: {
- children: React.ReactNode;
- params: Promise<{ dashboardId: string }>;
-}) {
- const { dashboardId } = await params;
-
- return {children};
-}
+export default DashboardLayout;
+export { generateMetadata };
diff --git a/apps/web/src/app/app/(primary_layout)/(chat_experience)/chats/[chatId]/dashboards/[dashboardId]/metrics/[metricId]/layout.tsx b/apps/web/src/app/app/(primary_layout)/(chat_experience)/chats/[chatId]/dashboards/[dashboardId]/metrics/[metricId]/layout.tsx
index 98e472be8..e90da7a8f 100644
--- a/apps/web/src/app/app/(primary_layout)/(chat_experience)/chats/[chatId]/dashboards/[dashboardId]/metrics/[metricId]/layout.tsx
+++ b/apps/web/src/app/app/(primary_layout)/(chat_experience)/chats/[chatId]/dashboards/[dashboardId]/metrics/[metricId]/layout.tsx
@@ -1,3 +1,4 @@
-import MetricLayout from '@metrics/layout';
+import MetricLayout, { generateMetadata } from '@metrics/layout';
export default MetricLayout;
+export { generateMetadata };
diff --git a/apps/web/src/app/app/(primary_layout)/(chat_experience)/chats/[chatId]/layout.tsx b/apps/web/src/app/app/(primary_layout)/(chat_experience)/chats/[chatId]/layout.tsx
new file mode 100644
index 000000000..d2cbdac7f
--- /dev/null
+++ b/apps/web/src/app/app/(primary_layout)/(chat_experience)/chats/[chatId]/layout.tsx
@@ -0,0 +1,25 @@
+import { getTitle_server } from '@/api/buster_rest/title';
+
+export default function ChatLayout({ children }: { children: React.ReactNode }) {
+ return <>{children}>;
+}
+
+export async function generateMetadata({ params }: { params: Promise<{ chatId: string }> }) {
+ const { chatId } = await params;
+
+ try {
+ const response = await getTitle_server({
+ assetId: chatId,
+ assetType: 'chat'
+ });
+
+ return {
+ title: response.title || 'New Chat'
+ };
+ } catch (error) {
+ console.error('Failed to fetch chat title:', error);
+ return {
+ title: 'New Chat'
+ };
+ }
+}
diff --git a/apps/web/src/app/app/(primary_layout)/(chat_experience)/chats/[chatId]/metrics/[metricId]/layout.tsx b/apps/web/src/app/app/(primary_layout)/(chat_experience)/chats/[chatId]/metrics/[metricId]/layout.tsx
index 98e472be8..e90da7a8f 100644
--- a/apps/web/src/app/app/(primary_layout)/(chat_experience)/chats/[chatId]/metrics/[metricId]/layout.tsx
+++ b/apps/web/src/app/app/(primary_layout)/(chat_experience)/chats/[chatId]/metrics/[metricId]/layout.tsx
@@ -1,3 +1,4 @@
-import MetricLayout from '@metrics/layout';
+import MetricLayout, { generateMetadata } from '@metrics/layout';
export default MetricLayout;
+export { generateMetadata };
diff --git a/apps/web/src/app/app/(primary_layout)/(chat_experience)/dashboards/[dashboardId]/layout.tsx b/apps/web/src/app/app/(primary_layout)/(chat_experience)/dashboards/[dashboardId]/layout.tsx
index 69cae866c..449593d04 100644
--- a/apps/web/src/app/app/(primary_layout)/(chat_experience)/dashboards/[dashboardId]/layout.tsx
+++ b/apps/web/src/app/app/(primary_layout)/(chat_experience)/dashboards/[dashboardId]/layout.tsx
@@ -1,3 +1,4 @@
+import { getTitle_server } from '@/api/buster_rest/title';
import { DashboardLayout } from '@/layouts/DashboardLayout';
export default async function Layout({
@@ -11,3 +12,23 @@ export default async function Layout({
return {children};
}
+
+export async function generateMetadata({ params }: { params: Promise<{ dashboardId: string }> }) {
+ const { dashboardId } = await params;
+
+ try {
+ const response = await getTitle_server({
+ assetId: dashboardId,
+ assetType: 'dashboard'
+ });
+
+ return {
+ title: response.title || 'New Dashboard'
+ };
+ } catch (error) {
+ console.error('Failed to fetch dashboard title:', error);
+ return {
+ title: 'New Dashboard'
+ };
+ }
+}
diff --git a/apps/web/src/app/app/(primary_layout)/(chat_experience)/metrics/[metricId]/layout.tsx b/apps/web/src/app/app/(primary_layout)/(chat_experience)/metrics/[metricId]/layout.tsx
index bc1260c8e..104c1b1e7 100644
--- a/apps/web/src/app/app/(primary_layout)/(chat_experience)/metrics/[metricId]/layout.tsx
+++ b/apps/web/src/app/app/(primary_layout)/(chat_experience)/metrics/[metricId]/layout.tsx
@@ -1,4 +1,6 @@
import { AppAssetCheckLayout } from '@/layouts/AppAssetCheckLayout';
+import type { Metadata } from 'next';
+import { getTitle_server } from '@/api/buster_rest/title';
export default async function MetricLayout({
children,
@@ -15,3 +17,30 @@ export default async function MetricLayout({
);
}
+
+// Generate metadata dynamically based on the metric - shared across all child pages
+export async function generateMetadata({
+ params
+}: {
+ params: Promise<{ metricId: string }>;
+}): Promise {
+ const { metricId } = await params;
+
+ try {
+ // Fetch the metric title using the server-side request
+ const response = await getTitle_server({
+ assetId: metricId,
+ assetType: 'metric'
+ });
+
+ return {
+ title: response.title || 'New Metric'
+ };
+ } catch (error) {
+ // Fallback title if the request fails
+ console.error('Failed to fetch metric title:', error);
+ return {
+ title: 'New Metric'
+ };
+ }
+}
diff --git a/apps/web/tsconfig.json b/apps/web/tsconfig.json
index d2b8aefb9..5b37633cc 100644
--- a/apps/web/tsconfig.json
+++ b/apps/web/tsconfig.json
@@ -13,7 +13,7 @@
"paths": {
"@/*": ["src/*"],
"@metrics/*": ["src/app/app/(primary_layout)/(chat_experience)/metrics/[metricId]/*"],
- "@dashboards": ["src/app/app/(primary_layout)/(chat_experience)/dashboards/[dashboardId]/*"]
+ "@dashboards/*": ["src/app/app/(primary_layout)/(chat_experience)/dashboards/[dashboardId]/*"]
},
"plugins": [
{