Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Gate Assistant sends on provider readiness

rcourtman21994238213b
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.md
index 29a4cf85db..0dea285799 100644
--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md
+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md
@@ -77,7 +77,10 @@ runtime cost control, and shared AI transport surfaces.
by `internal/ai/`, not Patrol runtime-finding wording, and the drawer may
surface the result as actionable retry/settings status plus same-model
configured-provider alternatives without converting it into
- assistant-authored output or disabling model-owned chat by default.
+ assistant-authored output. The composer must keep typed text and focus while
+ the selected provider is checking or failed, but it must not dispatch a user
+ turn until that selected provider route is ready or the operator chooses a
+ ready alternative.
Operator interruption is likewise chat-runtime state: Stop and replacement
sends must abort the active stream, clear pending tool/approval/question
affordances, preserve any partial model text, return focus to the composer,
diff --git a/frontend-modern/src/components/AI/Chat/__tests__/AIChat.test.tsx b/frontend-modern/src/components/AI/Chat/__tests__/AIChat.test.tsx
index 92f8cf6978..9edbe0404b 100644
--- a/frontend-modern/src/components/AI/Chat/__tests__/AIChat.test.tsx
+++ b/frontend-modern/src/components/AI/Chat/__tests__/AIChat.test.tsx
@@ -283,6 +283,18 @@ function setViewportWidth(width: number) {
window.dispatchEvent(new Event('resize'));
}
+async function waitForComposerSendReady() {
+ await waitFor(() => {
+ expect(mockAIAPI.testProvider).toHaveBeenCalled();
+ });
+ await waitFor(() => {
+ expect(screen.queryByText('Checking OpenAI provider')).not.toBeInTheDocument();
+ });
+ await waitFor(() => {
+ expect(screen.getByRole('button', { name: 'Send message' })).not.toBeDisabled();
+ });
+}
+
// ── Setup / teardown ───────────────────────────────────────────────────────
beforeEach(() => {
@@ -397,6 +409,102 @@ describe('AIChat', () => {
);
});
+ it('keeps user input queued while the selected provider check is still running', async () => {
+ mockAIAPI.getSettings.mockResolvedValue({
+ model: 'openai:gpt-4',
+ chat_model: '',
+ control_level: 'read_only',
+ autonomous_mode: false,
+ discovery_enabled: true,
+ });
+ mockAIAPI.testProvider.mockReturnValue(new Promise(() => {}));
+
+ renderChat();
+
+ await screen.findByText('Checking OpenAI provider');
+ const textarea = screen.getByPlaceholderText(
+ 'Ask about your infrastructure...',
+ ) as HTMLTextAreaElement;
+ fireEvent.input(textarea, { target: { value: 'summarize the cluster' } });
+
+ expect(screen.getByRole('button', { name: 'Send message' })).toBeDisabled();
+ fireEvent.keyDown(textarea, { key: 'Enter' });
+
+ expect(mockChat.sendMessage).not.toHaveBeenCalled();
+ expect(textarea.value).toBe('summarize the cluster');
+ expect(document.activeElement).toBe(textarea);
+ });
+
+ it('keeps user input queued while a selected provider issue is unresolved', async () => {
+ mockAIAPI.getSettings.mockResolvedValue({
+ model: 'deepseek:deepseek-v4-pro',
+ chat_model: '',
+ control_level: 'read_only',
+ autonomous_mode: false,
+ discovery_enabled: true,
+ });
+ mockAIAPI.testProvider.mockResolvedValueOnce({
+ success: false,
+ message: 'Provider connection issue',
+ provider: 'deepseek',
+ model: 'deepseek:deepseek-v4-pro',
+ cause: 'provider_connection',
+ summary: 'Pulse could not maintain a healthy connection to this provider.',
+ recommendation: 'Check provider reachability.',
+ action: 'open_provider_settings',
+ });
+
+ renderChat();
+
+ await screen.findByText('DeepSeek provider issue');
+ const textarea = screen.getByPlaceholderText(
+ 'Ask about your infrastructure...',
+ ) as HTMLTextAreaElement;
+ fireEvent.input(textarea, { target: { value: 'summarize the cluster' } });
+
+ expect(screen.getByRole('button', { name: 'Send message' })).toBeDisabled();
+ fireEvent.keyDown(textarea, { key: 'Enter' });
+
+ expect(mockChat.sendMessage).not.toHaveBeenCalled();
+ expect(textarea.value).toBe('summarize the cluster');
+ expect(document.activeElement).toBe(textarea);
+ });
+
+ it('keeps user input queued when the readiness issue reports a provider-qualified model', async () => {
+ mockAIAPI.getSettings.mockResolvedValue({
+ model: 'gpt-4',
+ chat_model: '',
+ control_level: 'read_only',
+ autonomous_mode: false,
+ discovery_enabled: true,
+ });
+ mockAIAPI.testProvider.mockResolvedValueOnce({
+ success: false,
+ message: 'Selected model unavailable',
+ provider: 'openai',
+ model: 'openai:gpt-4',
+ cause: 'model_unavailable',
+ summary: 'Pulse could not find the selected model on this provider route.',
+ recommendation: 'Choose another OpenAI model.',
+ action: 'open_provider_settings',
+ });
+
+ renderChat();
+
+ await screen.findByText('OpenAI provider issue');
+ const textarea = screen.getByPlaceholderText(
+ 'Ask about your infrastructure...',
+ ) as HTMLTextAreaElement;
+ fireEvent.input(textarea, { target: { value: 'summarize the cluster' } });
+
+ expect(screen.getByRole('button', { name: 'Send message' })).toBeDisabled();
+ fireEvent.keyDown(textarea, { key: 'Enter' });
+
+ expect(mockChat.sendMessage).not.toHaveBeenCalled();
+ expect(textarea.value).toBe('summarize the cluster');
+ expect(document.activeElement).toBe(textarea);
+ });
+
it('offers an equivalent configured-provider route when the selected provider fails', async () => {
mockAIAPI.getSettings.mockResolvedValue({
model: 'deepseek:deepseek-v4-pro',
@@ -1966,6 +2074,7 @@ describe('AIChat', () => {
expect(textarea.value).toBe('@redacted by policy ');
});
+ await waitForComposerSendReady();
fireEvent.keyDown(textarea, { key: 'Enter' });
expect(mockChat.sendMessage).toHaveBeenCalledWith(
'@redacted by policy',
@@ -2171,6 +2280,7 @@ describe('AIChat', () => {
const textarea = screen.getByPlaceholderText('Ask about your infrastructure...');
fireEvent.input(textarea, { target: { value: 'what happened here?' } });
+ await waitForComposerSendReady();
fireEvent.keyDown(textarea, { key: 'Enter' });
expect(mockChat.sendMessage).toHaveBeenCalledWith(
@@ -2251,6 +2361,7 @@ describe('AIChat', () => {
expect(mockAiChatStore.context.briefing?.title).toBe('Patrol finding on web-server');
fireEvent.input(textarea, { target: { value: 'what changed next?' } });
+ await waitForComposerSendReady();
fireEvent.keyDown(textarea, { key: 'Enter' });
await waitFor(() => {
diff --git a/frontend-modern/src/components/AI/Chat/index.tsx b/frontend-modern/src/components/AI/Chat/index.tsx
index 52dac282d4..07425c4a33 100644
--- a/frontend-modern/src/components/AI/Chat/index.tsx
+++ b/frontend-modern/src/components/AI/Chat/index.tsx
@@ -543,6 +543,23 @@ export const AIChat: Component<AIChatProps> = (props) => {
});
});
+ const providerReadinessMatchesSelection = (readiness: ChatProviderReadinessState) => {
+ const selectedProvider = selectedChatProvider().trim();
+ const selectedModel = selectedChatModel().trim();
+ if (!selectedProvider || !selectedModel) return false;
+ if (readiness.provider.trim() !== selectedProvider) return false;
+ return (
+ !readiness.model ||
+ normalizeComparableModelKey(readiness.model) === normalizeComparableModelKey(selectedModel)
+ );
+ };
+
+ const providerReadinessBlocksSend = createMemo(() => {
+ const readiness = providerReadiness();
+ if (readiness.status !== 'checking' && readiness.status !== 'error') return false;
+ return providerReadinessMatchesSelection(readiness);
+ });
+
let providerReadinessRequestId = 0;
let lastProviderReadinessKey = '';
@@ -1157,6 +1174,10 @@ export const AIChat: Component<AIChatProps> = (props) => {
const handleSubmit = () => {
const prompt = input().trim();
if (!prompt) return;
+ if (providerReadinessBlocksSend()) {
+ focusComposer();
+ return;
+ }
const mentions = accumulatedMentions();
const mentionsForAPI =
mentions.length > 0
@@ -2020,7 +2041,7 @@ export const AIChat: Component<AIChatProps> = (props) => {
</Show>
<button
type="submit"
- disabled={!input().trim()}
+ disabled={!input().trim() || providerReadinessBlocksSend()}
class="flex h-9 w-9 items-center justify-center rounded-md bg-blue-600 text-white shadow-sm transition-colors hover:bg-blue-700 disabled:cursor-not-allowed disabled:opacity-45"
title="Send"
aria-label="Send message"