Skip to content

Commit 3e9a87f

Browse files
committed
Refactor conversation/session handling in chat stores
Refactored chat history and message stores to use a new SessionEntry type for conversations, improving consistency and maintainability. Updated related components and screens to use the new structure, and added support for 'Continue' action in chat UI. Also updated localization files and incremented version numbers.
1 parent acb04ff commit 3e9a87f

File tree

14 files changed

+137
-119
lines changed

14 files changed

+137
-119
lines changed

docs/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "tuui-docs",
33
"private": true,
4-
"version": "1.2.3",
4+
"version": "1.3.0",
55
"scripts": {
66
"dev": "vitepress dev src",
77
"build": "vitepress build src",

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"name": "tuui",
33
"appId": "com.tuui.app",
4-
"version": "1.2.3",
5-
"schemaVersion": "1.0",
4+
"version": "1.3.0",
5+
"schemaVersion": "1.3",
66
"description": "Tool Unitary User Interface",
77
"homepage": "https://www.tuui.com",
88
"author": "AIQL <contact@aiql.com>",

src/renderer/components/common/CommandCard.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const handleProgress: IpcCommandRequestCallback = (_event, progress) => {
1414
role: 'user'
1515
} as ChatConversationMessage
1616
]
17-
messageStore.applyPrompt(conversations)
17+
messageStore.initConversation(conversations)
1818
messageStore.userMessage = params.input
1919
}
2020

src/renderer/components/pages/ChatInputPage.vue

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ const agentStore = useAgentStore()
6666
</v-col>
6767
<v-col cols="4" class="pt-4 pb-0 pr-0">
6868
<!-- Adds a horizontal flex container (row direction) to override parent column layout, ensuring right alignment within v-col -->
69-
<div class="d-flex justify-end">
69+
<span class="d-flex justify-end">
7070
<v-spacer></v-spacer>
7171

72-
<div v-if="messageStore.historyId in messageStore.generating">
72+
<span v-if="messageStore.conversation.id in messageStore.generating">
7373
<v-icon-btn
7474
v-tooltip:start="$t('chat.wipe')"
7575
color="error"
@@ -86,7 +86,7 @@ const agentStore = useAgentStore()
8686
rounded="lg"
8787
@click="messageStore.stop"
8888
></v-icon-btn>
89-
</div>
89+
</span>
9090

9191
<v-icon-btn
9292
v-else-if="messageStore.userMessage"
@@ -97,7 +97,7 @@ const agentStore = useAgentStore()
9797
@click="messageStore.sendMessage"
9898
></v-icon-btn>
9999

100-
<div v-else-if="messageStore.conversation.length > 0">
100+
<span v-else-if="messageStore.conversation.messages.length > 0">
101101
<v-icon-btn
102102
v-tooltip:start="$t('chat.wipe')"
103103
color="error"
@@ -109,23 +109,35 @@ const agentStore = useAgentStore()
109109

110110
<v-divider class="mx-1" vertical></v-divider>
111111

112-
<v-icon-btn
113-
v-tooltip:start="$t('chat.reg')"
114-
color="teal"
115-
variant="tonal"
116-
icon="mdi-autorenew"
117-
rounded="lg"
118-
@click="messageStore.resendMessage"
119-
></v-icon-btn>
120-
</div>
112+
<span v-if="messageStore.conversation.messages.at(-1)?.role === 'assistant'">
113+
<v-icon-btn
114+
v-tooltip:top="$t('chat.reg')"
115+
color="teal"
116+
variant="tonal"
117+
icon="mdi-autorenew"
118+
rounded="lg"
119+
@click="messageStore.resendMessage"
120+
></v-icon-btn>
121+
</span>
122+
<span v-else>
123+
<v-icon-btn
124+
v-tooltip:top="$t('chat.continue')"
125+
color="primary"
126+
variant="tonal"
127+
icon="mdi-step-forward"
128+
rounded="lg"
129+
@click="messageStore.startInference"
130+
></v-icon-btn>
131+
</span>
132+
</span>
121133
<v-icon-btn
122134
v-else
123135
color="grey"
124136
variant="tonal"
125137
icon="mdi-account-edit"
126138
rounded="lg"
127139
></v-icon-btn>
128-
</div>
140+
</span>
129141
</v-col>
130142
</v-row>
131143
</template>

src/renderer/components/pages/McpPromptPage.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const navigateTo = (route: string, screenValue: number) => {
1616
1717
const handleApplyPrompt = async () => {
1818
const conversations = await promptStore.fetchSelect()
19-
messageStore.applyPrompt(conversations)
19+
messageStore.initConversation(conversations)
2020
navigateTo('/chat', 1)
2121
}
2222
</script>

src/renderer/locales/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
"chat": {
6868
"wipe": "Wipe",
6969
"reg": "Regenerate",
70+
"continue": "Continue",
7071
"token-refresh": "Invalid API key, updating now...",
7172
"token-fail": "Update API key failed.",
7273
"select-model": "Select Model",

src/renderer/locales/zh.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
"chat": {
6868
"wipe": "清理对话",
6969
"reg": "重新生成",
70+
"continue": "继续生成",
7071
"token-refresh": "无效的 API key, 正在更新中...",
7172
"token-fail": "更新 API key 失败.",
7273
"select-model": "选择模型",

src/renderer/screens/chat/ChatHistoryScreen.vue

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
<script setup lang="tsx">
1+
<script setup lang="ts">
2+
import { computed } from 'vue'
23
import { useHistoryStore } from '@/renderer/store/history'
34
import { useMessageStore } from '@/renderer/store/message'
45
import { ChatConversationMessage } from '@/renderer/types/message'
@@ -19,19 +20,25 @@ function parseContent(content: undefined | string | ChatConversationMessage['con
1920
return content
2021
}
2122
}
23+
24+
const selectedConversation = computed({
25+
get: () => [messageStore.conversation.id],
26+
set: ([value]) => {
27+
historyStore.select(value)
28+
}
29+
})
2230
</script>
2331
<template>
24-
<v-list v-model:selected="historyStore.selected" nav>
32+
<v-list v-model:selected="selectedConversation" nav>
2533
<v-list-item
26-
v-for="(item, index) in historyStore.conversation"
34+
v-for="(item, index) in historyStore.conversations"
2735
:key="item.id"
2836
:ripple="false"
2937
two-line
3038
:value="item.id"
3139
link
3240
:title="parseContent(item.messages[0]?.content)"
3341
:subtitle="parseContent(item.messages.at(-1)?.content)"
34-
@click="historyStore.select(index)"
3542
>
3643
<template #append>
3744
<v-list-item-action>

0 commit comments

Comments
 (0)