fix: share the dashboard assistant and count leads from data
The hero ask box now uses the same confirm-before-create path as the assistant, count questions use real filters, and lead mobile, Jalali follow-ups, and rial labels stay consistent. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -30,6 +30,8 @@ const activities = ref<ActivityDto[]>([]);
|
||||
const board = ref<PipelineBoardDto | null>(null);
|
||||
const askQuery = ref('');
|
||||
const asking = ref(false);
|
||||
const assistantBusy = ref(false);
|
||||
const assistantRef = ref<{ submitFromInput: () => Promise<void> } | null>(null);
|
||||
const askAnswer = ref('');
|
||||
const askError = ref('');
|
||||
const askSources = ref<AskMentoSourceDto[]>([]);
|
||||
@@ -83,6 +85,28 @@ function clearAsk() {
|
||||
askSources.value = [];
|
||||
}
|
||||
|
||||
function onHeroAsk() {
|
||||
if (!assistantRef.value) {
|
||||
askError.value = 'داشبورد هنوز آماده نیست. چند لحظه بعد دوباره بفرستید.';
|
||||
return;
|
||||
}
|
||||
void assistantRef.value.submitFromInput();
|
||||
}
|
||||
|
||||
function onAssistantNotice(payload: { error: string; done: string }) {
|
||||
if (payload.done) {
|
||||
askAnswer.value = payload.done;
|
||||
askError.value = '';
|
||||
return;
|
||||
}
|
||||
if (payload.error) {
|
||||
askError.value = payload.error;
|
||||
askAnswer.value = '';
|
||||
return;
|
||||
}
|
||||
if (!asking.value) askError.value = '';
|
||||
}
|
||||
|
||||
async function submitAsk(preset?: string) {
|
||||
const q = (preset || askQuery.value).trim();
|
||||
if (!q || asking.value) return;
|
||||
@@ -154,11 +178,12 @@ onUnmounted(() => {
|
||||
:first-name="firstName"
|
||||
:user-initial="userInitial"
|
||||
:alerts="home?.alerts ?? []"
|
||||
:asking="asking"
|
||||
:asking="asking || assistantBusy"
|
||||
:ask-answer="askAnswer"
|
||||
:ask-error="askError"
|
||||
:status-text="assistantBusy && !asking ? 'در حال فهمیدن دستور…' : ''"
|
||||
v-model:ask-query="askQuery"
|
||||
@ask="submitAsk"
|
||||
@ask="onHeroAsk"
|
||||
/>
|
||||
|
||||
<p v-if="loading" class="muted center">در حال بارگذاری داشبورد…</p>
|
||||
@@ -181,6 +206,7 @@ onUnmounted(() => {
|
||||
<HomeSourcesChart :sources="home?.sources ?? []" />
|
||||
<HomeAiAssistant
|
||||
id="home-ai-assistant"
|
||||
ref="assistantRef"
|
||||
v-model:ask-query="askQuery"
|
||||
:asking="asking"
|
||||
:answer="askAnswer"
|
||||
@@ -188,6 +214,8 @@ onUnmounted(() => {
|
||||
:sources="askSources"
|
||||
@ask="submitAsk"
|
||||
@clear="clearAsk"
|
||||
@busy="assistantBusy = $event"
|
||||
@notice="onAssistantNotice"
|
||||
/>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user