Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: bound pending briefing generation state (#6949)

[._.]/ Adam Eivy18c64720b927
diff --git a/client/src/components/EmptyState.jsx b/client/src/components/EmptyState.jsx
index 72a8373469..ac0645433a 100644
--- a/client/src/components/EmptyState.jsx
+++ b/client/src/components/EmptyState.jsx
@@ -15,6 +15,7 @@ import { Info } from 'lucide-react';
* actionTo — internal route for the call-to-action Link
* actionLabel — text for the call-to-action
* onAction — render a <button> instead of a Link (in-page action)
+ * actionDisabled — disable the in-page action while it is processing
*/
export default function EmptyState({
icon: Icon = Info,
@@ -34,7 +35,13 @@ export default function EmptyState({
{title && <h3 className="text-white font-semibold mb-1">{title}</h3>}
{message && <p className="text-gray-400 text-sm max-w-xs">{message}</p>}
{actionLabel && (onAction ? (
- <button type="button" onClick={onAction} disabled={actionDisabled} className={actionClass}>
+ <button
+ type="button"
+ onClick={onAction}
+ disabled={actionDisabled}
+ aria-busy={actionDisabled || undefined}
+ className={`${actionClass} disabled:cursor-not-allowed disabled:opacity-50`}
+ >
{actionLabel}
</button>
) : actionTo ? (
diff --git a/client/src/components/cos/tabs/BriefingTab.jsx b/client/src/components/cos/tabs/BriefingTab.jsx
index 96c17192b7..970b3fa08e 100644
--- a/client/src/components/cos/tabs/BriefingTab.jsx
+++ b/client/src/components/cos/tabs/BriefingTab.jsx
@@ -1,4 +1,4 @@
-import { useState, useEffect } from 'react';
+import { useState, useEffect, useRef } from 'react';
import { Link } from 'react-router';
import {
Newspaper,
@@ -20,6 +20,7 @@ import { formatWeekdayDate } from '../../../utils/formatters';
import EmptyState from '../../EmptyState';
import { useAsyncAction } from '../../../hooks/useAsyncAction';
import { useAutoRefetch } from '../../../hooks/useAutoRefetch';
+import toast from '../../ui/Toast';
const SECTION_ICONS = {
'Task Queue': CheckCircle,
@@ -163,16 +164,22 @@ export default function BriefingTab() {
const [loading, setLoading] = useState(true);
const [expandedSections, setExpandedSections] = useState({});
const [generationPending, setGenerationPending] = useState(false);
+ const generationInFlightRef = useRef(false);
const [generateBriefing, generatingBriefing] = useAsyncAction(async () => {
- if (generationPending || generatingBriefing) return;
- const result = await api.triggerCosJob('job-daily-briefing', { silent: true });
- if (!result || result.success === false) {
- throw new Error(result?.reason || 'The briefing could not be generated');
+ if (generationPending || generatingBriefing || generationInFlightRef.current) return;
+ generationInFlightRef.current = true;
+ try {
+ const result = await api.triggerCosJob('job-daily-briefing', { silent: true });
+ if (!result || result.success === false) {
+ throw new Error(result?.reason || 'The briefing could not be generated');
+ }
+ setGenerationPending(true);
+ const latest = await loadData({ showLoading: false });
+ if (latest) setGenerationPending(false);
+ } finally {
+ generationInFlightRef.current = false;
}
- setGenerationPending(true);
- const latest = await loadData({ showLoading: false });
- if (latest) setGenerationPending(false);
});
useEffect(() => {
@@ -205,10 +212,19 @@ export default function BriefingTab() {
if (latest) setGenerationPending(false);
return latest;
},
- 2000,
+ 5000,
{ enabled: generationPending, immediate: false, pollOnly: true },
);
+ useEffect(() => {
+ if (!generationPending) return undefined;
+ const timeoutId = setTimeout(() => {
+ setGenerationPending(false);
+ toast.error('Briefing generation is taking longer than expected. Try again or check the Daily Briefing job.');
+ }, 60000);
+ return () => clearTimeout(timeoutId);
+ }, [generationPending]);
+
const loadBriefing = async (date) => {
setLoading(true);
setSelectedDate(date);
diff --git a/client/src/components/cos/tabs/BriefingTab.test.jsx b/client/src/components/cos/tabs/BriefingTab.test.jsx
index 186bdffc9a..f0bdd65a34 100644
--- a/client/src/components/cos/tabs/BriefingTab.test.jsx
+++ b/client/src/components/cos/tabs/BriefingTab.test.jsx
@@ -66,7 +66,7 @@ describe('BriefingTab empty state', () => {
await act(async () => {});
expect(screen.getByRole('button', { name: 'Generating today’s briefing…' })).toBeDisabled();
- await act(async () => { await vi.advanceTimersByTimeAsync(2000); });
+ await act(async () => { await vi.advanceTimersByTimeAsync(5000); });
expect(screen.getByText('Today')).toBeInTheDocument();
});