Several Pastures pages include “Diagnose →” links that open the AI drawer with a pre-filled query, giving users one-click access to AI diagnostics for a specific issue.
Pages with Ask AI buttons
| Page | Trigger | Example pre-filled query |
|---|
| Advisories | Each advisory card | ”Diagnose: etcd cluster has only 1 member” |
| Cluster Intelligence | Each detected issue | ”Diagnose: Longhorn replica count degraded” |
| Monitoring | Each active alert | ”Diagnose: Node memory pressure on worker-03” |
| Harvester VMs | VM error states | ”Diagnose: VM stuck in Starting state” |
How it works
When a user clicks a “Diagnose →” link, the page dispatches a CustomEvent on the window object:
window.dispatchEvent(
new CustomEvent('pastures:drawer:open', {
detail: { query: 'Diagnose: etcd cluster has only 1 member' },
})
);
The AI drawer listens for this event. When received, it:
- Opens the drawer (if not already open)
- Pre-fills the input textarea with
detail.query
- Automatically submits the query
This means the user sees the drawer open and immediately begin generating a diagnosis — no manual typing required.
Integration pattern
To add a “Diagnose →” button to any Pastures page, dispatch the event with the relevant diagnostic text:
<template>
<button @click="diagnose">Diagnose →</button>
</template>
<script setup lang="ts">
function diagnose() {
window.dispatchEvent(
new CustomEvent('pastures:drawer:open', {
detail: { query: `Diagnose: ${issue.title}` },
})
);
}
</script>
The event-based pattern means any page — including custom pages added by contributors — can integrate with Pastures AI without importing drawer components directly.
Behavior details
- If the drawer is already open, a new event replaces the current input and submits
- The pre-filled query appears in the user’s message history as if they typed it
- Context awareness still applies — if the user is on the Advisories page, page-specific suggestions remain available after the conversation