This PR adds a Captain Assistant **Overview** page to show some KPI metrics (conversations handled, auto-resolution, handoff, hours saved, reopen-after-resolve, conversation depth) with trend deltas vs the previous window, a real knowledge card, and a lazily-loaded, cached LLM welcome summary. ### Highlights - **Two contextual banners** on the overview: - **Inbox banner** — prompts the user to connect an inbox when the assistant has none, so it can actually do work. - **Coverage banner** — warns when FAQ coverage is below 85% with more than 100 responses pending review, linking straight to the pending queue. Dismissal persists per-assistant for 24h via localStorage. - **Batched stats builder** (`Captain::AssistantStatsBuilder`) computes both windows in single FILTER-aggregated scans to cut round trips, behind new `stats`/`summary` endpoints. - **Cards included but intentionally left dummy / not rendered yet:** `ResponseQualityCard` (flagged responses) and `CreditUsageCard` (credit usage + daily chart). Credits are an account-wide counter with no per-assistant or daily history, so there is no real data to back them yet; they ship in the codebase but are not wired into the page. ### Index migration - Replaces `index_messages_on_sender_type_and_sender_id` with `index_messages_on_sender_and_created` `(sender_type, sender_id, created_at)`. - **Why it helps:** the per-assistant windowed lookups filter `sender_*` *and* a `created_at` range. The old 2-column index matched every lifetime row for the assistant and filtered the time slice at the heap (~89% of rows discarded); adding `created_at` as a range column lets Postgres scan only the window, and fixes the row-count estimate so the planner picks a hash join over a nested loop on `reporting_events`. - **Why dropping the old index is safe:** the new index is a left-prefix superset `(sender_type, sender_id, ...)`, so every query the old one served is still served. No code references it by name, and dropping it keeps write amplification on `messages` neutral. Built/dropped with `CONCURRENTLY` and `if_not_exists`/`if_exists` guards. ## Preview <img width="2572" height="1754" alt="CleanShot 2026-06-29 at 22 38 51@2x" src="https://github.com/user-attachments/assets/3798d09e-7850-48e4-b2cd-508533f15cea" /> ## Banners #### Inbox connect alert <img width="2178" height="612" alt="CleanShot 2026-06-30 at 14 26 55@2x" src="https://github.com/user-attachments/assets/373c371c-bb7d-4291-a0f9-620673078302" /> #### Coverage alert <img width="2178" height="612" alt="CleanShot 2026-06-30 at 14 25 41@2x" src="https://github.com/user-attachments/assets/e12d6308-11b6-4ba2-88a2-8a3077dd3e8f" /> --------- Co-authored-by: Sivin Varghese <64252451+iamsivin@users.noreply.github.com>
147 lines
4.6 KiB
JavaScript
147 lines
4.6 KiB
JavaScript
import { FEATURE_FLAGS } from 'dashboard/featureFlags';
|
|
import { INSTALLATION_TYPES } from 'dashboard/constants/installationTypes';
|
|
import { frontendURL } from '../../../helper/URLHelper';
|
|
|
|
import CaptainPageRouteView from './pages/CaptainPageRouteView.vue';
|
|
import AssistantsIndexPage from './pages/AssistantsIndexPage.vue';
|
|
import AssistantEmptyStateIndex from './assistants/Index.vue';
|
|
|
|
import AssistantOverviewIndex from './assistants/overview/Index.vue';
|
|
import AssistantSettingsIndex from './assistants/settings/Settings.vue';
|
|
import AssistantInboxesIndex from './assistants/inboxes/Index.vue';
|
|
import AssistantPlaygroundIndex from './assistants/playground/Index.vue';
|
|
import AssistantGuardrailsIndex from './assistants/guardrails/Index.vue';
|
|
import AssistantGuidelinesIndex from './assistants/guidelines/Index.vue';
|
|
import AssistantScenariosIndex from './assistants/scenarios/Index.vue';
|
|
import DocumentsIndex from './documents/Index.vue';
|
|
import ResponsesIndex from './responses/Index.vue';
|
|
import ResponsesPendingIndex from './responses/Pending.vue';
|
|
import CustomToolsIndex from './tools/Index.vue';
|
|
|
|
const meta = {
|
|
permissions: ['administrator', 'agent'],
|
|
featureFlag: FEATURE_FLAGS.CAPTAIN,
|
|
installationTypes: [INSTALLATION_TYPES.CLOUD, INSTALLATION_TYPES.ENTERPRISE],
|
|
};
|
|
|
|
const metaCustomTools = {
|
|
permissions: ['administrator', 'agent'],
|
|
featureFlag: FEATURE_FLAGS.CAPTAIN_CUSTOM_TOOLS,
|
|
installationTypes: [INSTALLATION_TYPES.CLOUD, INSTALLATION_TYPES.ENTERPRISE],
|
|
};
|
|
|
|
const metaV2 = {
|
|
permissions: ['administrator', 'agent'],
|
|
featureFlag: FEATURE_FLAGS.CAPTAIN_V2,
|
|
installationTypes: [INSTALLATION_TYPES.CLOUD, INSTALLATION_TYPES.ENTERPRISE],
|
|
};
|
|
|
|
const assistantRoutes = [
|
|
{
|
|
path: frontendURL('accounts/:accountId/captain/:assistantId/overview'),
|
|
component: AssistantOverviewIndex,
|
|
name: 'captain_assistants_overview_index',
|
|
meta,
|
|
},
|
|
{
|
|
path: frontendURL('accounts/:accountId/captain/:assistantId/faqs'),
|
|
component: ResponsesIndex,
|
|
name: 'captain_assistants_responses_index',
|
|
meta,
|
|
},
|
|
{
|
|
path: frontendURL('accounts/:accountId/captain/:assistantId/documents'),
|
|
component: DocumentsIndex,
|
|
name: 'captain_assistants_documents_index',
|
|
meta,
|
|
},
|
|
{
|
|
path: frontendURL('accounts/:accountId/captain/:assistantId/tools'),
|
|
component: CustomToolsIndex,
|
|
name: 'captain_tools_index',
|
|
meta: metaCustomTools,
|
|
},
|
|
{
|
|
path: frontendURL('accounts/:accountId/captain/:assistantId/scenarios'),
|
|
component: AssistantScenariosIndex,
|
|
name: 'captain_assistants_scenarios_index',
|
|
meta: metaV2,
|
|
},
|
|
{
|
|
path: frontendURL('accounts/:accountId/captain/:assistantId/playground'),
|
|
component: AssistantPlaygroundIndex,
|
|
name: 'captain_assistants_playground_index',
|
|
meta,
|
|
},
|
|
{
|
|
path: frontendURL('accounts/:accountId/captain/:assistantId/inboxes'),
|
|
component: AssistantInboxesIndex,
|
|
name: 'captain_assistants_inboxes_index',
|
|
meta,
|
|
},
|
|
{
|
|
path: frontendURL('accounts/:accountId/captain/:assistantId/faqs/pending'),
|
|
component: ResponsesPendingIndex,
|
|
name: 'captain_assistants_responses_pending',
|
|
meta,
|
|
},
|
|
{
|
|
path: frontendURL('accounts/:accountId/captain/:assistantId/settings'),
|
|
component: AssistantSettingsIndex,
|
|
name: 'captain_assistants_settings_index',
|
|
meta,
|
|
},
|
|
// Settings sub-pages (guardrails and guidelines)
|
|
{
|
|
path: frontendURL(
|
|
'accounts/:accountId/captain/:assistantId/settings/guardrails'
|
|
),
|
|
component: AssistantGuardrailsIndex,
|
|
name: 'captain_assistants_guardrails_index',
|
|
meta: metaV2,
|
|
},
|
|
{
|
|
path: frontendURL(
|
|
'accounts/:accountId/captain/:assistantId/settings/guidelines'
|
|
),
|
|
component: AssistantGuidelinesIndex,
|
|
name: 'captain_assistants_guidelines_index',
|
|
meta: metaV2,
|
|
},
|
|
{
|
|
path: frontendURL('accounts/:accountId/captain/assistants'),
|
|
component: AssistantEmptyStateIndex,
|
|
name: 'captain_assistants_create_index',
|
|
meta: {
|
|
permissions: ['administrator', 'agent'],
|
|
installationTypes: [
|
|
INSTALLATION_TYPES.CLOUD,
|
|
INSTALLATION_TYPES.ENTERPRISE,
|
|
],
|
|
},
|
|
},
|
|
{
|
|
path: frontendURL('accounts/:accountId/captain/:navigationPath'),
|
|
component: AssistantsIndexPage,
|
|
name: 'captain_assistants_index',
|
|
meta,
|
|
},
|
|
];
|
|
|
|
export const routes = [
|
|
{
|
|
path: frontendURL('accounts/:accountId/captain'),
|
|
component: CaptainPageRouteView,
|
|
redirect: to => {
|
|
return {
|
|
name: 'captain_assistants_index',
|
|
params: {
|
|
navigationPath: 'captain_assistants_overview_index',
|
|
...to.params,
|
|
},
|
|
};
|
|
},
|
|
children: [...assistantRoutes],
|
|
},
|
|
];
|