Order chat sessions by time updated, not created (#4143)

* order chat sessions by time updated, not created

* quick update

* k
This commit is contained in:
pablonyx
2025-02-27 09:35:42 -08:00
committed by GitHub
parent e10cc8ccdb
commit 85e3ed57f1
12 changed files with 16 additions and 7 deletions

View File

@ -138,6 +138,7 @@ def get_user_chat_sessions(
name=chat.description,
persona_id=chat.persona_id,
time_created=chat.time_created.isoformat(),
time_updated=chat.time_updated.isoformat(),
shared_status=chat.shared_status,
folder_id=chat.folder_id,
current_alternate_model=chat.current_alternate_model,

View File

@ -168,7 +168,7 @@ def get_chat_sessions_by_user(
if not include_onyxbot_flows:
stmt = stmt.where(ChatSession.onyxbot_flow.is_(False))
stmt = stmt.order_by(desc(ChatSession.time_created))
stmt = stmt.order_by(desc(ChatSession.time_updated))
if deleted is not None:
stmt = stmt.where(ChatSession.deleted == deleted)

View File

@ -49,6 +49,7 @@ def get_folders(
name=chat_session.description,
persona_id=chat_session.persona_id,
time_created=chat_session.time_created.isoformat(),
time_updated=chat_session.time_updated.isoformat(),
shared_status=chat_session.shared_status,
folder_id=folder.id,
)

View File

@ -147,9 +147,11 @@ def list_threads(
name=chat.description,
persona_id=chat.persona_id,
time_created=chat.time_created.isoformat(),
time_updated=chat.time_updated.isoformat(),
shared_status=chat.shared_status,
folder_id=chat.folder_id,
current_alternate_model=chat.current_alternate_model,
current_temperature_override=chat.temperature_override,
)
for chat in chat_sessions
]

View File

@ -119,6 +119,7 @@ def get_user_chat_sessions(
name=chat.description,
persona_id=chat.persona_id,
time_created=chat.time_created.isoformat(),
time_updated=chat.time_updated.isoformat(),
shared_status=chat.shared_status,
folder_id=chat.folder_id,
current_alternate_model=chat.current_alternate_model,

View File

@ -181,6 +181,7 @@ class ChatSessionDetails(BaseModel):
name: str | None
persona_id: int | None = None
time_created: str
time_updated: str
shared_status: ChatSessionSharedStatus
folder_id: int | None = None
current_alternate_model: str | None = None

View File

@ -159,6 +159,7 @@ def get_user_search_sessions(
name=sessions_with_documents_dict[search.id],
persona_id=search.persona_id,
time_created=search.time_created.isoformat(),
time_updated=search.time_updated.isoformat(),
shared_status=search.shared_status,
folder_id=search.folder_id,
current_alternate_model=search.current_alternate_model,

View File

@ -168,7 +168,7 @@ const FolderItem = ({
};
const folders = folder.chat_sessions.sort((a, b) => {
return a.time_created.localeCompare(b.time_created);
return a.time_updated.localeCompare(b.time_updated);
});
// Determine whether to show the trash can icon

View File

@ -70,6 +70,7 @@ export interface ChatSession {
name: string;
persona_id: number;
time_created: string;
time_updated: string;
shared_status: ChatSessionSharedStatus;
folder_id: number | null;
current_alternate_model: string;
@ -123,6 +124,7 @@ export interface BackendChatSession {
persona_icon_shape: number | null;
messages: BackendMessage[];
time_created: string;
time_updated: string;
shared_status: ChatSessionSharedStatus;
current_temperature_override: number | null;
current_alternate_model?: string;

View File

@ -48,10 +48,10 @@ export function getChatRetentionInfo(
): ChatRetentionInfo {
// If `maximum_chat_retention_days` isn't set- never display retention warning.
const chatRetentionDays = settings.maximum_chat_retention_days || 10000;
const createdDate = new Date(chatSession.time_created);
const updatedDate = new Date(chatSession.time_updated);
const today = new Date();
const daysFromCreation = Math.ceil(
(today.getTime() - createdDate.getTime()) / (1000 * 3600 * 24)
(today.getTime() - updatedDate.getTime()) / (1000 * 3600 * 24)
);
const daysUntilExpiration = chatRetentionDays - daysFromCreation;
const showRetentionWarning =
@ -419,7 +419,7 @@ export function groupSessionsByDateRange(chatSessions: ChatSession[]) {
};
chatSessions.forEach((chatSession) => {
const chatSessionDate = new Date(chatSession.time_created);
const chatSessionDate = new Date(chatSession.time_updated);
const diffTime = today.getTime() - chatSessionDate.getTime();
const diffDays = diffTime / (1000 * 3600 * 24); // Convert time difference to days

View File

@ -206,7 +206,7 @@ export function SharedChatDisplay({
{chatSession.description || `Unnamed Chat`}
</h1>
<p className=" text-text-darker">
{humanReadableFormat(chatSession.time_created)}
{humanReadableFormat(chatSession.time_updated)}
</p>
<div
className={`

View File

@ -148,7 +148,7 @@ export async function fetchChatData(searchParams: {
chatSessions.sort(
(a, b) =>
new Date(b.time_created).getTime() - new Date(a.time_created).getTime()
new Date(b.time_updated).getTime() - new Date(a.time_updated).getTime()
);
let documentSets: DocumentSet[] = [];