Skip to content

Commit 0121b39

Browse files
authored
Show task title as page title on task details page, truncate prompt (#158)
Co-authored-by: Chris Tate <ctate@users.noreply.github.com>
1 parent 46c2a44 commit 0121b39

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

app/tasks/[taskId]/page.tsx

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,40 @@ export default async function TaskPage({ params }: TaskPageProps) {
3131

3232
export async function generateMetadata({ params }: TaskPageProps) {
3333
const { taskId } = await params
34+
const session = await getServerSession()
35+
36+
// Try to fetch the task to get its title
37+
let pageTitle = `Task ${taskId}`
38+
39+
if (session?.user?.id) {
40+
try {
41+
const { db } = await import('@/lib/db/client')
42+
const { tasks } = await import('@/lib/db/schema')
43+
const { eq, and, isNull } = await import('drizzle-orm')
44+
45+
const task = await db
46+
.select()
47+
.from(tasks)
48+
.where(and(eq(tasks.id, taskId), eq(tasks.userId, session.user.id), isNull(tasks.deletedAt)))
49+
.limit(1)
50+
51+
if (task[0]) {
52+
// Use title if available, otherwise use truncated prompt
53+
if (task[0].title) {
54+
pageTitle = task[0].title
55+
} else if (task[0].prompt) {
56+
// Truncate prompt to 60 characters
57+
pageTitle = task[0].prompt.length > 60 ? task[0].prompt.slice(0, 60) + '...' : task[0].prompt
58+
}
59+
}
60+
} catch (error) {
61+
// If fetching fails, fall back to task ID
62+
console.error('Failed to fetch task for metadata:', error)
63+
}
64+
}
3465

3566
return {
36-
title: `Task ${taskId} - Coding Agent Platform`,
67+
title: `${pageTitle} - Coding Agent Platform`,
3768
description: 'View task details and execution logs',
3869
}
3970
}

0 commit comments

Comments
 (0)