Skip to content

Commit 72617d5

Browse files
committed
feat(gpt-runner-web): fix system prompt not working
1 parent 74e2207 commit 72617d5

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

packages/gpt-runner-web/client/src/pages/chat/chat-panel.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ export const ChatPanel: FC<ChatPanelProps> = (props) => {
5050
return
5151

5252
const index = chatIds.indexOf(chatId)
53-
let nextIndex = index - 1
53+
let nextIndex = index + 1
5454

55-
if (nextIndex < 0)
56-
nextIndex = chatIds.length - 1
55+
if (nextIndex >= chatIds.length)
56+
nextIndex = 0
5757

5858
const nextChatId = chatIds[nextIndex]
5959
onChatIdChange(nextChatId)
@@ -67,10 +67,10 @@ export const ChatPanel: FC<ChatPanelProps> = (props) => {
6767
return
6868

6969
const index = chatIds.indexOf(chatId)
70-
let nextIndex = index + 1
70+
let nextIndex = index - 1
7171

72-
if (nextIndex >= chatIds.length)
73-
nextIndex = 0
72+
if (nextIndex < 0)
73+
nextIndex = chatIds.length - 1
7474

7575
const nextChatId = chatIds[nextIndex]
7676
onChatIdChange(nextChatId)

packages/gpt-runner-web/client/src/store/zustand/global/sidebar-tree.slice.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,12 +167,13 @@ export const createSidebarTreeSlice: StateCreator<
167167
},
168168
createChatAndActive(gptFileId) {
169169
const state = get()
170+
const gptFileTreeItem = state.getSidebarTreeItem(gptFileId) as GptFileTreeItem
170171
const { chatInstance } = state.addChatInstance(gptFileId, {
171172
name: DEFAULT_CHAT_NAME,
172-
inputtingPrompt: '',
173-
systemPrompt: '',
173+
inputtingPrompt: gptFileTreeItem?.otherInfo?.singleFileConfig.userPrompt || '',
174+
systemPrompt: gptFileTreeItem?.otherInfo?.singleFileConfig.systemPrompt || '',
174175
messages: [],
175-
singleFileConfig: {},
176+
singleFileConfig: gptFileTreeItem?.otherInfo?.singleFileConfig || {},
176177
status: ChatMessageStatus.Success,
177178
})
178179

0 commit comments

Comments
 (0)