Skip to content

Commit 9a55b7a

Browse files
committed
fix(fork): type guard for mothership-only, prevent title accumulation on re-fork
1 parent 45fb40b commit 9a55b7a

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

  • apps/sim/app/api/mothership/chats/[chatId]/fork

apps/sim/app/api/mothership/chats/[chatId]/fork/route.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export const POST = withRouteHandler(
5252
.where(eq(copilotChats.id, chatId))
5353
.limit(1)
5454

55-
if (!parent || parent.userId !== userId) {
55+
if (!parent || parent.userId !== userId || parent.type !== 'mothership') {
5656
return createNotFoundResponse('Chat not found')
5757
}
5858

@@ -74,7 +74,8 @@ export const POST = withRouteHandler(
7474
: []
7575

7676
const newId = generateId()
77-
const title = `${parent.title ?? 'New task'} | Fork`
77+
const baseTitle = (parent.title ?? 'New task').replace(/ \| Fork$/, '')
78+
const title = `${baseTitle} | Fork`
7879
const now = new Date()
7980

8081
const [newChat] = await db

0 commit comments

Comments
 (0)