Skip to content

armgit / jan

Public Imported from GitHub
0

Jan is an open source alternative to ChatGPT that runs 100% offline on your computer.

Merge pull request #7509 from janhq/fix/assistant-for-project

Louisf892648b0143
diff --git a/web-app/src/routes/threads/$threadId.tsx b/web-app/src/routes/threads/$threadId.tsx
index 6f2f67f6e..8c1af73d4 100644
--- a/web-app/src/routes/threads/$threadId.tsx
+++ b/web-app/src/routes/threads/$threadId.tsx
@@ -117,7 +117,7 @@ function ThreadDetail() {
// Get system message from thread's assistant instructions (if thread has an assigned assistant)
// Only use assistant instructions if the thread was created with one (e.g., via a project)
- const threadAssistant = !projectId && thread?.assistants?.[0]
+ const threadAssistant = thread?.assistants?.[0]
const systemMessage = threadAssistant?.instructions
? renderInstructions(threadAssistant.instructions)
: undefined
diff --git a/web-app/src/services/__tests__/threads.test.ts b/web-app/src/services/__tests__/threads.test.ts
index 68da99687..e9288c1e2 100644
--- a/web-app/src/services/__tests__/threads.test.ts
+++ b/web-app/src/services/__tests__/threads.test.ts
@@ -54,8 +54,7 @@ describe('DefaultThreadsService', () => {
order: 1,
isFavorite: true,
model: { id: 'gpt-4', provider: 'openai' },
- // assistants without instructions are not considered "real" assistants
- assistants: [],
+ assistants: [{ model: { id: 'gpt-4', engine: 'openai' } }],
})
})
@@ -89,8 +88,7 @@ describe('DefaultThreadsService', () => {
order: 1,
isFavorite: true,
model: { id: 'gpt-4', provider: 'openai' },
- // assistants without instructions are not considered "real" assistants
- assistants: [],
+ assistants: [{ model: { id: 'gpt-4', engine: 'openai' } }],
})
expect(result[1]).toMatchObject({
id: '2',
@@ -99,8 +97,7 @@ describe('DefaultThreadsService', () => {
order: 1,
isFavorite: true,
model: { id: 'gpt-4', provider: 'openai' },
- // assistants without instructions are not considered "real" assistants
- assistants: [],
+ assistants: [{ model: { id: 'gpt-4', engine: 'openai' } }],
})
})
@@ -308,8 +305,6 @@ describe('DefaultThreadsService', () => {
updated: 0,
order: undefined,
isFavorite: undefined,
- // No assistants when missing
- assistants: [],
})
})
@@ -335,8 +330,6 @@ describe('DefaultThreadsService', () => {
updated: 1234567890,
order: 1,
isFavorite: true,
- // No assistants when missing
- assistants: [],
})
})
@@ -507,8 +500,7 @@ describe('DefaultThreadsService', () => {
updated: 1234567890,
model: { id: 'gpt-4', provider: 'openai' },
order: 1, // Should fall back to original thread order
- // No real assistants when they lack instructions
- assistants: [],
+ assistants: [{ model: { id: 'gpt-4', engine: 'openai' } }],
})
})
})
diff --git a/web-app/src/services/threads/default.ts b/web-app/src/services/threads/default.ts
index 80ee9a78c..c4addacb2 100644
--- a/web-app/src/services/threads/default.ts
+++ b/web-app/src/services/threads/default.ts
@@ -17,7 +17,9 @@ export class DefaultThreadsService implements ThreadsService {
if (!Array.isArray(threads)) return []
// Filter out temporary threads from the list
- const filteredThreads = threads.filter((e) => e.id !== TEMPORARY_CHAT_ID)
+ const filteredThreads = threads.filter(
+ (e) => e.id !== TEMPORARY_CHAT_ID
+ )
return filteredThreads.map((e) => {
// Model is always stored in assistants[0].model
@@ -29,8 +31,7 @@ export class DefaultThreadsService implements ThreadsService {
: undefined
// Check if this is a "real" assistant (has instructions) or just model storage
- const hasRealAssistant = e.assistants?.[0]?.instructions
- const assistants = hasRealAssistant ? e.assistants : []
+ const assistants = e.assistants
return {
...e,
@@ -67,7 +68,7 @@ export class DefaultThreadsService implements ThreadsService {
// Build assistants payload - always include model info
// If there's a real assistant (with instructions), include full assistant data
// Otherwise, just include minimal model-only entry for storage
- const hasRealAssistant = thread.assistants && thread.assistants.length > 0 && thread.assistants[0]?.instructions
+ const hasRealAssistant = thread.assistants && thread.assistants.length > 0
const assistantsPayload = hasRealAssistant
? [
{
@@ -110,9 +111,7 @@ export class DefaultThreadsService implements ThreadsService {
}
: thread.model
- // Check if this is a "real" assistant (has instructions) or just model storage
- const hasRealAssistant = e.assistants?.[0]?.instructions
- const assistants = hasRealAssistant ? e.assistants : []
+ const assistants = e.assistants
return {
...e,