Merge pull request #4295 from janhq/fix/no-new-thread-created-on-factory-reset
fix: new thread isn't automatically created on factory reset
This commit is contained in:
commit
fd45e7e47f
@ -71,7 +71,7 @@ export abstract class OAIEngine extends AIEngine {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const timestamp = Date.now()
|
const timestamp = Date.now() / 1000
|
||||||
const message: ThreadMessage = {
|
const message: ThreadMessage = {
|
||||||
id: ulid(),
|
id: ulid(),
|
||||||
thread_id: data.threadId,
|
thread_id: data.threadId,
|
||||||
|
|||||||
@ -127,7 +127,7 @@ export default class JanAssistantExtension extends AssistantExtension {
|
|||||||
thread_location: undefined,
|
thread_location: undefined,
|
||||||
id: 'jan',
|
id: 'jan',
|
||||||
object: 'assistant',
|
object: 'assistant',
|
||||||
created_at: Date.now(),
|
created_at: Date.now() / 1000,
|
||||||
name: 'Jan',
|
name: 'Jan',
|
||||||
description: 'A default assistant that can use all downloaded models',
|
description: 'A default assistant that can use all downloaded models',
|
||||||
model: '*',
|
model: '*',
|
||||||
|
|||||||
@ -264,6 +264,9 @@ export default function ModelHandler() {
|
|||||||
if (updatedMessage) {
|
if (updatedMessage) {
|
||||||
deleteMessage(message.id)
|
deleteMessage(message.id)
|
||||||
addNewMessage(updatedMessage)
|
addNewMessage(updatedMessage)
|
||||||
|
setTokenSpeed((prev) =>
|
||||||
|
prev ? { ...prev, message: updatedMessage.id } : undefined
|
||||||
|
)
|
||||||
}
|
}
|
||||||
})()
|
})()
|
||||||
|
|
||||||
|
|||||||
@ -91,7 +91,8 @@ const MessageContainer: React.FC<
|
|||||||
: (activeAssistant?.assistant_name ?? props.role)}
|
: (activeAssistant?.assistant_name ?? props.role)}
|
||||||
</div>
|
</div>
|
||||||
<p className="text-xs font-medium text-gray-400">
|
<p className="text-xs font-medium text-gray-400">
|
||||||
{props.created_at && displayDate(props.created_at ?? new Date())}
|
{props.created_at &&
|
||||||
|
displayDate(props.created_at ?? Date.now() / 1000)}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@ -71,7 +71,6 @@ const ThreadLeftPanel = () => {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (
|
if (
|
||||||
threadDataReady &&
|
threadDataReady &&
|
||||||
activeAssistant &&
|
|
||||||
assistants.length > 0 &&
|
assistants.length > 0 &&
|
||||||
threads.length === 0 &&
|
threads.length === 0 &&
|
||||||
downloadedModels.length > 0
|
downloadedModels.length > 0
|
||||||
@ -81,7 +80,9 @@ const ThreadLeftPanel = () => {
|
|||||||
)
|
)
|
||||||
const selectedModel = model[0] || recommendedModel
|
const selectedModel = model[0] || recommendedModel
|
||||||
requestCreateNewThread(
|
requestCreateNewThread(
|
||||||
{ ...assistants[0], ...activeAssistant },
|
activeAssistant
|
||||||
|
? { ...assistants[0], ...activeAssistant }
|
||||||
|
: assistants[0],
|
||||||
selectedModel
|
selectedModel
|
||||||
)
|
)
|
||||||
} else if (threadDataReady && !activeThreadId) {
|
} else if (threadDataReady && !activeThreadId) {
|
||||||
|
|||||||
@ -4,11 +4,7 @@ import { isToday } from './datetime'
|
|||||||
test("should return only time for today's timestamp", () => {
|
test("should return only time for today's timestamp", () => {
|
||||||
const today = new Date()
|
const today = new Date()
|
||||||
const timestamp = today.getTime()
|
const timestamp = today.getTime()
|
||||||
const expectedTime = `${today.toLocaleDateString(undefined, {
|
const expectedTime = `${today.toLocaleTimeString(undefined, {
|
||||||
day: '2-digit',
|
|
||||||
month: 'short',
|
|
||||||
year: 'numeric',
|
|
||||||
})}, ${today.toLocaleTimeString(undefined, {
|
|
||||||
hour: '2-digit',
|
hour: '2-digit',
|
||||||
minute: '2-digit',
|
minute: '2-digit',
|
||||||
second: '2-digit',
|
second: '2-digit',
|
||||||
@ -24,5 +20,5 @@ test('should return N/A for undefined timestamp', () => {
|
|||||||
test("should return true for today's timestamp", () => {
|
test("should return true for today's timestamp", () => {
|
||||||
const today = new Date()
|
const today = new Date()
|
||||||
const timestamp = today.setHours(0, 0, 0, 0)
|
const timestamp = today.setHours(0, 0, 0, 0)
|
||||||
expect(isToday(timestamp)).toBe(true)
|
expect(isToday(timestamp / 1000)).toBe(true)
|
||||||
})
|
})
|
||||||
|
|||||||
@ -1,6 +1,9 @@
|
|||||||
export const isToday = (timestamp: number) => {
|
export const isToday = (timestamp: number) => {
|
||||||
const today = new Date()
|
const today = new Date()
|
||||||
return today.setHours(0, 0, 0, 0) === new Date(timestamp).setHours(0, 0, 0, 0)
|
return (
|
||||||
|
today.setHours(0, 0, 0, 0) ===
|
||||||
|
new Date(timestamp * 1000).setHours(0, 0, 0, 0)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const displayDate = (timestamp?: string | number | Date) => {
|
export const displayDate = (timestamp?: string | number | Date) => {
|
||||||
|
|||||||
@ -15,7 +15,7 @@ import { ulid } from 'ulidx'
|
|||||||
|
|
||||||
import { Stack } from '@/utils/Stack'
|
import { Stack } from '@/utils/Stack'
|
||||||
|
|
||||||
import { FileInfo, FileType } from '@/types/file'
|
import { FileInfo } from '@/types/file'
|
||||||
|
|
||||||
export class MessageRequestBuilder {
|
export class MessageRequestBuilder {
|
||||||
msgId: string
|
msgId: string
|
||||||
|
|||||||
@ -22,7 +22,7 @@ export class ThreadMessageBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
build(): ThreadMessage {
|
build(): ThreadMessage {
|
||||||
const timestamp = Date.now()
|
const timestamp = Date.now() / 1000
|
||||||
return {
|
return {
|
||||||
id: this.messageRequest.msgId,
|
id: this.messageRequest.msgId,
|
||||||
thread_id: this.messageRequest.thread.id,
|
thread_id: this.messageRequest.thread.id,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user