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
|
||||
}
|
||||
|
||||
const timestamp = Date.now()
|
||||
const timestamp = Date.now() / 1000
|
||||
const message: ThreadMessage = {
|
||||
id: ulid(),
|
||||
thread_id: data.threadId,
|
||||
|
||||
@ -127,7 +127,7 @@ export default class JanAssistantExtension extends AssistantExtension {
|
||||
thread_location: undefined,
|
||||
id: 'jan',
|
||||
object: 'assistant',
|
||||
created_at: Date.now(),
|
||||
created_at: Date.now() / 1000,
|
||||
name: 'Jan',
|
||||
description: 'A default assistant that can use all downloaded models',
|
||||
model: '*',
|
||||
|
||||
@ -264,6 +264,9 @@ export default function ModelHandler() {
|
||||
if (updatedMessage) {
|
||||
deleteMessage(message.id)
|
||||
addNewMessage(updatedMessage)
|
||||
setTokenSpeed((prev) =>
|
||||
prev ? { ...prev, message: updatedMessage.id } : undefined
|
||||
)
|
||||
}
|
||||
})()
|
||||
|
||||
|
||||
@ -91,7 +91,8 @@ const MessageContainer: React.FC<
|
||||
: (activeAssistant?.assistant_name ?? props.role)}
|
||||
</div>
|
||||
<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>
|
||||
</div>
|
||||
|
||||
|
||||
@ -71,7 +71,6 @@ const ThreadLeftPanel = () => {
|
||||
useEffect(() => {
|
||||
if (
|
||||
threadDataReady &&
|
||||
activeAssistant &&
|
||||
assistants.length > 0 &&
|
||||
threads.length === 0 &&
|
||||
downloadedModels.length > 0
|
||||
@ -81,7 +80,9 @@ const ThreadLeftPanel = () => {
|
||||
)
|
||||
const selectedModel = model[0] || recommendedModel
|
||||
requestCreateNewThread(
|
||||
{ ...assistants[0], ...activeAssistant },
|
||||
activeAssistant
|
||||
? { ...assistants[0], ...activeAssistant }
|
||||
: assistants[0],
|
||||
selectedModel
|
||||
)
|
||||
} else if (threadDataReady && !activeThreadId) {
|
||||
|
||||
@ -4,11 +4,7 @@ import { isToday } from './datetime'
|
||||
test("should return only time for today's timestamp", () => {
|
||||
const today = new Date()
|
||||
const timestamp = today.getTime()
|
||||
const expectedTime = `${today.toLocaleDateString(undefined, {
|
||||
day: '2-digit',
|
||||
month: 'short',
|
||||
year: 'numeric',
|
||||
})}, ${today.toLocaleTimeString(undefined, {
|
||||
const expectedTime = `${today.toLocaleTimeString(undefined, {
|
||||
hour: '2-digit',
|
||||
minute: '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", () => {
|
||||
const today = new Date()
|
||||
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) => {
|
||||
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) => {
|
||||
|
||||
@ -15,7 +15,7 @@ import { ulid } from 'ulidx'
|
||||
|
||||
import { Stack } from '@/utils/Stack'
|
||||
|
||||
import { FileInfo, FileType } from '@/types/file'
|
||||
import { FileInfo } from '@/types/file'
|
||||
|
||||
export class MessageRequestBuilder {
|
||||
msgId: string
|
||||
|
||||
@ -22,7 +22,7 @@ export class ThreadMessageBuilder {
|
||||
}
|
||||
|
||||
build(): ThreadMessage {
|
||||
const timestamp = Date.now()
|
||||
const timestamp = Date.now() / 1000
|
||||
return {
|
||||
id: this.messageRequest.msgId,
|
||||
thread_id: this.messageRequest.thread.id,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user