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

Refresh CoS insights banner on task deletion

Adam Eivy02b57a5f554c
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 0d784e7506..9cd39c310d 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -37,6 +37,8 @@
## Fixed
+- **Deleting a blocked CoS task now clears the "N blocked tasks" alert bar immediately.** On the Chief of Staff → Tasks page, the `ActionableInsightsBanner` (which owns its own `/cos/actionable-insights` fetch, decoupled from the task list) kept showing a stale blocked-tasks alert after a blocked task was deleted, until its 60s poll fired or the user manually dismissed it. The page now bumps an `insightsRefreshKey` on every task-list mutation, which the banner watches (via a mount-skipping effect) to `refetch()` its server-derived insights — so a delete (or any task mutation through the tasks list) re-derives the banner right away. Follow-up #2654 tracks lifting the insights fetch into the page's `fetchData` to also cover socket/health-driven staleness.
+
- **claim-issue no longer reports "no open issues" when an author filter is hiding a full queue.** The perpetual `claim-issue` / `claim-issue-gitlab` work-detector runs `gh`/`glab issue list` with an author filter (`self`→`@me`, or `owner`→the repo owner), and an empty *filtered* result was flattened to the reason `no-open-issues` — so a repo with open issues that simply don't match the filter parked for a full recheck cadence claiming there was nothing to do. The two failure modes this hid: `owner` resolves to an **org** (e.g. a GHE repo owned by a team), which is never an issue author, so the filter matches nothing; and `self`/`@me` is the wrong identity when the forge session differs from whoever filed the issues. The detector now re-probes without the author filter when the filtered list is empty, and if open issues exist it parks with a new `no-authored-issues` reason carrying the real open count. The on-demand "Run" toast now says *"open issues exist, but none match the author filter — set it to \"any\" (0 of N open)"* instead of the misleading "no open issues", pointing the user at the fix. A genuinely empty repo still reports `no-open-issues`, and the `any` filter is unaffected (no wasted re-probe). New private helper `countOpenIssuesUnfiltered`; covered by `perpetualWork.test.js` and `useOnDemandTaskToast.test.jsx`.
- **claim-issue distinguishes the "owner filter matches an org" trap from a personal-username mismatch.** Building on the fix above: when the `owner` author filter resolves to an **organization** login (the common case for team/enterprise repos), `--author <org>` can only ever match zero issues — an org is never an issue author. The detector now recognizes an org owner up front (`gh repo view --json owner,isInOrganization`), skips the guaranteed-empty query entirely, and parks with a distinct `owner-is-org` reason carrying the real open count. The toast now reads *"the \"owner\" filter matches an org, which can't author issues — set it to \"self\" or \"any\" (0 of N open)"* instead of the generic "set it to any", so the user isn't left thinking their own username is mismatched. `owner` mode on a user-owned repo is unchanged. Covered by `perpetualWork.test.js` and `useOnDemandTaskToast.test.jsx`.
- **pr-watcher now works on GitHub Enterprise hosts and resolves "self" against the repo's actual host.** The `pr-watcher` task gated on `getOriginInfo().isGithub`, which is github.com-only, so it silently no-op'd (`not-a-github-repo`) on self-hosted GitHub Enterprise (`github.*`) repos. Worse, its self/others author gate resolved the operator login via `gh api user` with no `--hostname` — which always targets github.com regardless of the repo — and cached one login process-wide, so on an enterprise repo it compared PR authors against the wrong identity (a user is commonly a different login per host). The gate now classifies GitHub-family hosts via the shared `hostToWorkTracker` (the same rule the claim-issue router uses; `gitlab.*` still falls through as not-a-github-repo), the default-branch and PR-list `gh` calls pass a host-qualified `--repo HOST/OWNER/REPO` selector (enterprise-correct, and deterministic on a fork+upstream multi-remote checkout where cwd-based detection would ambiguously resolve to the parent), and `getSelfLogin(host)` resolves identity with an explicit `--hostname` and caches per host. Covered by `prWatcher.test.js`.
diff --git a/client/src/components/cos/ActionableInsightsBanner.jsx b/client/src/components/cos/ActionableInsightsBanner.jsx
index c4f2315c1e..beb5a814a2 100644
--- a/client/src/components/cos/ActionableInsightsBanner.jsx
+++ b/client/src/components/cos/ActionableInsightsBanner.jsx
@@ -1,4 +1,4 @@
-import { useState } from 'react';
+import { useState, useEffect, useRef } from 'react';
import { useNavigate } from 'react-router-dom';
import { useAutoRefetch } from '../../hooks/useAutoRefetch';
import toast from '../ui/Toast';
@@ -89,7 +89,7 @@ const PRIORITY_STYLES = {
}
};
-export default function ActionableInsightsBanner({ onTaskUnblocked }) {
+export default function ActionableInsightsBanner({ onTaskUnblocked, refreshKey = 0 }) {
const [dismissed, setDismissed] = useState([]);
const [expanded, setExpanded] = useState({});
const navigate = useNavigate();
@@ -101,6 +101,21 @@ export default function ActionableInsightsBanner({ onTaskUnblocked }) {
60_000,
);
+ // Insights (blocked count, approvals, etc.) are derived server-side from the
+ // task list, so a task-list mutation in the parent must re-derive them here —
+ // otherwise deleting a blocked task leaves a stale "N blocked tasks" alert up
+ // until the 60s poll or a manual dismiss. The parent bumps `refreshKey` on
+ // every task mutation; skip the initial mount since the hook fetches then.
+ // `refetch` is stable, so this only fires on a real key change.
+ const didMountRef = useRef(false);
+ useEffect(() => {
+ if (!didMountRef.current) {
+ didMountRef.current = true;
+ return;
+ }
+ refetch();
+ }, [refreshKey, refetch]);
+
const handleDismiss = (type) => {
setDismissed(prev => [...prev, type]);
};
diff --git a/client/src/components/cos/ActionableInsightsBanner.test.jsx b/client/src/components/cos/ActionableInsightsBanner.test.jsx
index 6cef8845d7..8e9043b5b8 100644
--- a/client/src/components/cos/ActionableInsightsBanner.test.jsx
+++ b/client/src/components/cos/ActionableInsightsBanner.test.jsx
@@ -1,4 +1,6 @@
-import { describe, it, expect } from 'vitest';
+import { describe, it, expect, vi, beforeEach } from 'vitest';
+import { render, waitFor } from '@testing-library/react';
+import { MemoryRouter } from 'react-router-dom';
import { insightProvenance } from './ActionableInsightsBanner';
// The banner stamps each surfaced insight with a provenance chip. The honesty
@@ -27,3 +29,64 @@ describe('ActionableInsightsBanner insightProvenance', () => {
expect(insightProvenance('some-future-type').level).toBe('data-backed');
});
});
+
+// Regression: deleting a blocked task from the tasks page used to leave the
+// "N blocked tasks" alert bar up until the 60s poll or a manual dismiss, because
+// the banner owns its own insights fetch (decoupled from the task list). The
+// parent now bumps `refreshKey` on every task mutation so the banner
+// re-derives immediately. These tests pin that bridge.
+const api = vi.hoisted(() => ({ getCosActionableInsights: vi.fn() }));
+vi.mock('../../services/api', () => api);
+vi.mock('../ui/Toast', () => ({ default: { success: vi.fn(), error: vi.fn() } }));
+
+const ActionableInsightsBanner = (await import('./ActionableInsightsBanner')).default;
+
+const renderBanner = (refreshKey) =>
+ render(
+ <MemoryRouter>
+ <ActionableInsightsBanner refreshKey={refreshKey} />
+ </MemoryRouter>,
+ );
+
+describe('ActionableInsightsBanner refreshKey', () => {
+ beforeEach(() => {
+ vi.clearAllMocks();
+ api.getCosActionableInsights.mockResolvedValue({
+ insights: [
+ { type: 'blocked', priority: 'warning', icon: 'AlertTriangle', title: '2 blocked tasks', description: 'blocked', tasks: [] },
+ ],
+ });
+ });
+
+ it('refetches insights when refreshKey changes (a task was deleted)', async () => {
+ const { rerender } = renderBanner(0);
+ await waitFor(() => expect(api.getCosActionableInsights).toHaveBeenCalled());
+ const before = api.getCosActionableInsights.mock.calls.length;
+
+ rerender(
+ <MemoryRouter>
+ <ActionableInsightsBanner refreshKey={1} />
+ </MemoryRouter>,
+ );
+
+ await waitFor(() =>
+ expect(api.getCosActionableInsights.mock.calls.length).toBeGreaterThan(before),
+ );
+ });
+
+ it('does not refetch when re-rendered without a key change', async () => {
+ const { rerender } = renderBanner(3);
+ await waitFor(() => expect(api.getCosActionableInsights).toHaveBeenCalled());
+ const before = api.getCosActionableInsights.mock.calls.length;
+
+ // Same key → the refetch effect's deps are unchanged, so no extra fetch.
+ rerender(
+ <MemoryRouter>
+ <ActionableInsightsBanner refreshKey={3} />
+ </MemoryRouter>,
+ );
+ await new Promise((r) => setTimeout(r, 0));
+
+ expect(api.getCosActionableInsights.mock.calls.length).toBe(before);
+ });
+});
diff --git a/client/src/pages/ChiefOfStaff.jsx b/client/src/pages/ChiefOfStaff.jsx
index a7c56379ef..0d5bb50fe3 100644
--- a/client/src/pages/ChiefOfStaff.jsx
+++ b/client/src/pages/ChiefOfStaff.jsx
@@ -85,6 +85,12 @@ export default function ChiefOfStaff() {
);
const [activeAgentMeta, setActiveAgentMeta] = useState(null);
const [learningSummary, setLearningSummary] = useState(null);
+ // Bumped on every task-list mutation so the ActionableInsightsBanner (a
+ // decoupled sibling that owns its own insights fetch) re-derives "N blocked
+ // tasks" etc. immediately instead of lingering until its 60s poll. This covers
+ // only the TasksTab mutation path; socket/health-driven insight changes still
+ // rely on the banner's own poll.
+ const [insightsRefreshKey, setInsightsRefreshKey] = useState(0);
const [canScrollLeft, setCanScrollLeft] = useState(false);
const [canScrollRight, setCanScrollRight] = useState(false);
const tabsRef = useRef(null);
@@ -149,6 +155,16 @@ export default function ChiefOfStaff() {
setActiveAgentMeta(runningAgent?.metadata || null);
}, [deriveAgentState]);
+ // Task-mutation refresh: refetch the task list AND signal the insights banner
+ // to re-derive. Deleting a blocked task, for example, must drop it from both
+ // the list and the banner's "N blocked tasks" alert — the banner owns its own
+ // fetch, so bumping the signal is how the delete reaches it. The background
+ // 30s poll calls fetchData directly (not this), so it doesn't over-refetch.
+ const refreshTasks = useCallback(() => {
+ setInsightsRefreshKey(v => v + 1);
+ return fetchData();
+ }, [fetchData]);
+
// Redirect unknown tab IDs to the default tab — `activeTab !== tab` only
// when the param failed validation and fell back.
useEffect(() => {
@@ -856,9 +872,9 @@ export default function ChiefOfStaff() {
<div role="tabpanel" id="tabpanel-tasks" aria-labelledby="tab-tasks">
{/* Tasks-only widgets live under the tab nav so they don't stretch above
tabs that don't surface this data. */}
- <ActionableInsightsBanner onTaskUnblocked={handleTaskUnblocked} />
+ <ActionableInsightsBanner onTaskUnblocked={handleTaskUnblocked} refreshKey={insightsRefreshKey} />
<QuickSummary />
- <TasksTab tasks={tasks} onRefresh={fetchData} providers={providers} apps={apps} />
+ <TasksTab tasks={tasks} onRefresh={refreshTasks} providers={providers} apps={apps} />
</div>
)}
{activeTab === 'agents' && (