fix(chat): support Hermes clarify batches
Build / build (push) Canceled after 0s
Playwright / e2e (push) Canceled after 0s

This commit is contained in:
2026-11-09 09:14:42 +08:00
parent 96aac671b3
commit f935385356
10 changed files with 233 additions and 10 deletions
@@ -189,6 +189,11 @@ const queuedMessages = computed(() => {
const visibleApproval = computed(() => chatStore.activePendingApproval);
const visibleClarify = computed(() => chatStore.activePendingClarify);
const clarifyResponse = ref("");
const clarifySelections = ref<string[]>([]);
watch(() => visibleClarify.value?.clarifyId, () => {
clarifyResponse.value = "";
clarifySelections.value = [];
});
const hasFloatingPrompt = computed(() => !!visibleApproval.value || !!visibleClarify.value);
const virtualListPadding = computed(() => {
if (queuedMessages.value.length > 0 && hasFloatingPrompt.value) return "20px 20px 380px";
@@ -242,6 +247,13 @@ function handleClarify(response?: string) {
clarifyResponse.value = "";
}
function handleClarifyMulti() {
const responses = [...clarifySelections.value];
const custom = clarifyResponse.value.trim();
if (custom) responses.push(custom);
handleClarify(responses.length ? JSON.stringify(responses) : '');
}
function removeQueuedMessage(messageId: string) {
const sid = chatStore.activeSessionId;
if (!sid) return;
@@ -829,7 +841,10 @@ defineExpose({
</div>
<div class="approval-float-title">{{ t("chat.clarifyTitle") }}</div>
<div class="approval-float-desc">{{ visibleClarify.question }}</div>
<div v-if="visibleClarify.choices && visibleClarify.choices.length" class="approval-float-actions">
<a-checkbox-group v-if="visibleClarify.multiSelect && visibleClarify.choices?.length" v-model="clarifySelections" class="approval-float-actions">
<a-checkbox v-for="choice in visibleClarify.choices" :key="choice" :value="choice">{{ choice }}</a-checkbox>
</a-checkbox-group>
<div v-else-if="visibleClarify.choices && visibleClarify.choices.length" class="approval-float-actions">
<a-button
v-for="choice in visibleClarify.choices"
:key="choice"
@@ -839,19 +854,19 @@ defineExpose({
>
{{ choice }}
</a-button>
<a-button size="small" status="danger" type="secondary" @click="handleClarify('')">
{{ t("chat.clarifyDismiss") }}
</a-button>
</div>
<div v-else class="clarify-float-input-row">
<div class="clarify-float-input-row">
<a-input
v-model="clarifyResponse"
size="small"
:placeholder="t('chat.clarifyPlaceholder')"
/>
<a-button size="small" type="primary" @click="handleClarify()">
<a-button size="small" type="primary" @click="visibleClarify.multiSelect ? handleClarifyMulti() : handleClarify()">
{{ t("chat.clarifySubmit") }}
</a-button>
<a-button size="small" status="danger" type="secondary" @click="handleClarify('')">
{{ t("chat.clarifyDismiss") }}
</a-button>
</div>
</div>
</Transition>
@@ -88,6 +88,7 @@ export interface PendingClarify {
clarifyId: string
question: string
choices: string[] | null
multiSelect: boolean
timeoutMs: number
requestedAt: number
}
@@ -2113,6 +2114,7 @@ export const useChatStore = defineStore('chat', () => {
clarifyId,
question: String((evt as any).question || ''),
choices: Array.isArray((evt as any).choices) ? (evt as any).choices : null,
multiSelect: !!(evt as any).multi_select,
timeoutMs: Number((evt as any).timeout_ms) || 300000,
requestedAt: Date.now(),
})