Skip to content

Commit e2da7a2

Browse files
committed
chat: persist selected thread
1 parent e725f9a commit e2da7a2

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/packages/frontend/chat/actions.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1207,6 +1207,13 @@ export class ChatActions extends Actions<ChatState> {
12071207
showPreview,
12081208
});
12091209
};
1210+
1211+
setSelectedThread = (threadKey: string | null) => {
1212+
this.frameTreeActions?.set_frame_data({
1213+
id: this.frameId,
1214+
selectedThreadKey: threadKey,
1215+
});
1216+
};
12101217
}
12111218

12121219
// We strip out any cased version of the string @chatgpt and also all mentions.

src/packages/frontend/chat/chatroom.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,14 +141,15 @@ export function ChatRoom({
141141
const [filterRecentOpen, setFilterRecentOpen] = useState<boolean>(false);
142142
const threads = useThreadList(messages);
143143
const [selectedThreadKey, setSelectedThreadKey0] = useState<string | null>(
144-
null,
144+
desc?.get("data-selectedThreadKey") ?? null,
145145
);
146-
const setSelectedThreadKey = (x) => {
146+
const setSelectedThreadKey = (x: string | null) => {
147147
if (x != null && x != ALL_THREADS_KEY) {
148148
actions.clearAllFilters();
149149
actions.setFragment();
150150
}
151151
setSelectedThreadKey0(x);
152+
actions.setSelectedThread?.(x);
152153
};
153154
const [lastThreadKey, setLastThreadKey] = useState<string | null>(null);
154155
const [renamingThread, setRenamingThread] = useState<string | null>(null);

0 commit comments

Comments
 (0)