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.

fix: preserve manually-set thread titles from LLM overwrite

Akarshan Biswas2a0e1952347e
diff --git a/web-app/src/hooks/useThreads.ts b/web-app/src/hooks/useThreads.ts
index eb1d3e214..f207caceb 100644
--- a/web-app/src/hooks/useThreads.ts
+++ b/web-app/src/hooks/useThreads.ts
@@ -405,6 +405,7 @@ export const useThreads = create<ThreadState>()((set, get) => ({
...thread,
title: newTitle,
updated: Date.now() / 1000,
+ metadata: { ...thread.metadata, titleSetManually: true },
}
getServiceHub().threads().updateThread(updatedThread) // External call, order is fine
const newThreads = { ...state.threads, [threadId]: updatedThread }
diff --git a/web-app/src/routes/threads/$threadId.tsx b/web-app/src/routes/threads/$threadId.tsx
index 9e773dd83..3717f2c90 100644
--- a/web-app/src/routes/threads/$threadId.tsx
+++ b/web-app/src/routes/threads/$threadId.tsx
@@ -414,7 +414,8 @@ function ThreadDetail() {
assistantCount === 1 ||
(assistantCount > 0 &&
assistantCount % TITLE_REFRESH_EVERY_N_ASSISTANT_MESSAGES === 0)
- if (isRefreshTick) {
+ const currentThread = useThreads.getState().threads[threadId]
+ if (isRefreshTick && !currentThread?.metadata?.titleSetManually) {
const TITLE_TRANSCRIPT_MAX_TURNS = 8
const recent = localMessages.slice(-TITLE_TRANSCRIPT_MAX_TURNS)
const inputText =