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: distinguish a failed JIRA sprint fetch from an empty sprint (#3437)

[._.]/ Adam Eivy13bc9b85050e
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 3c43983a09..b6e8f31ba6 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -8,6 +8,7 @@
## Fixed
+- **[issue-3437] A failed JIRA sprint-ticket fetch no longer reads as "No tickets assigned to you".** Expanding a JIRA-enabled app row substituted `[]` for a thrown request and cached it, so an unreachable instance, an expired token, or a wrong project key all rendered as an authoritative empty sprint — and because the `!jiraTickets[id]` guard was satisfied by that cached empty array, the page never retried for the rest of its life. Failure now records a message in a parallel `ticketErrors` map and leaves the ticket entry unset (the `null = not fetched` vs `[] = fetched-and-empty` sentinel rule), so the panel renders three distinct states — loading, "Couldn't load sprint tickets — <message>" with a **Retry** button, and the genuine empty case — and both Retry and a re-expand re-issue the request. A successful empty result is still cached, since JIRA calls are slow and rate-limited. The fetch passes `{ silent: true }` now that this path owns its error UI. The app-detail Overview tab ran the same swallow-into-`[]` fetch on mount and gets the same treatment.
- **[issue-3436] Archiving an app no longer reports success when the request failed.** `handleArchive` / `handleUnarchive` on `/apps` swallowed the failure with `.catch(() => null)` and then fired their success toast unconditionally — so a failed archive showed the red "Request failed" toast from `request()` immediately followed by a green "<app> archived", and the last one read won. The user was told an app was excluded from CoS scheduling when it was not. Both handlers now gate the toast on a response, matching `handleBuild` in the same file, and update the row's archived state locally on success instead of waiting for the `apps:changed` round-trip. The app-detail Overview tab carried the identical bug and is fixed with it.
- **[issue-3435] A running app Update no longer vanishes when you collapse the row or leave `/apps`, and can't be dispatched twice.** The Update / Standardize flow (git pull → npm install → setup → PM2 restart, minutes long) rendered its step log *inside* the expanded row, and the hook tracking it held `isOperating` / `steps` in page state whose unmount tore down the socket listeners — so collapsing the row or navigating away left a long-running operation with no indicator anywhere, and the second dispatch that invited ran a concurrent `npm install` against the same checkout. The server now owns the in-flight set: a module-level map keyed by app id rejects a second `app:update` / `app:standardize` for an app already operating (a re-entrancy guard, not a lock), buffers the steps emitted so far, and broadcasts progress with `io.emit` instead of replying only to the socket that dispatched. Clients rehydrate from `app:operations:active` — pushed on connect and on demand via `app:operations:list` — so a page that mounts mid-operation restores the whole log. `/apps` renders that state in a sticky page-level banner naming the app (`Updating <app>…`) above the list instead of inside the row, and a row blocked only by another app's operation now reads `Update (busy)` rather than being silently greyed out. Operations are tracked per app id, so two apps operating from different tabs each get their own banner instead of one shadowing the other, and the app-detail Overview tab passes its own `appId` so it still reports only its own operation. The guard also matches on `repoPath`, since two app records can point at the same checkout; a refused dispatch is flagged `duplicate` so the client toasts it without marking the healthy run failed; and a completion carrying `success: false` now reads as a failure instead of "Operation complete".
- **A successful `branch-cleanup` run is no longer recorded as a failure.** The task deletes merged branches in the app's live checkout — its prompt `cd`s to the repo path and runs `git branch -d` / `git push --delete` — but it was the only git/gh coordinator type shipping with no `taskMetadata` at all, so `applyAppWorktreeDefault` filled `useWorktree`/`openPR` from the app's `defaultOpenPR: true`. Every run got a CoS-managed worktree it never touched (one that holds the very refs it was trying to delete) and a PR expectation it could never satisfy, and finalization scored the completed run `pr-missing`. The four non-committing coordinator types — `branch-cleanup`, `branch-reconcile`, `issue-reconcile`, `jira-status-report` — now share one documented `taskMetadata` posture: `useWorktree`/`openPR` explicitly `false` (not merely absent, which is what let the app defaults in) *and* locked via `MANAGED_AGENT_OPTIONS` so a per-app override can't re-attach them, plus `worktreeChangesExpected: false`, because a clean tree is the success shape for a branch deletion or a posted report and the TUI idle-complete gate must not read it as "the model produced no work". `jira-status-report` was hit by the same bug for a subtler reason: its `readOnly: true` skips worktree *creation* but the finalize-time PR-claim check reads `metadata.openPR` directly, so a posted report still scored `pr-missing`. A guard test now iterates `NON_COMMITTING_COORDINATOR_TASK_TYPES` — the set that already grants these types their commit-criterion exemption — so a future coordinator type can't be added to one list and not the other. Existing installs pick all of this up on the next schedule load: the taskMetadata deep-merge backfills the new keys and `enforceManagedAgentOptions` rewrites any stored `true`.
diff --git a/client/src/components/apps/tabs/OverviewTab.jsx b/client/src/components/apps/tabs/OverviewTab.jsx
index d401199877..a7435321f6 100644
--- a/client/src/components/apps/tabs/OverviewTab.jsx
+++ b/client/src/components/apps/tabs/OverviewTab.jsx
@@ -1,4 +1,4 @@
-import { useState, useEffect, useMemo } from 'react';
+import { useState, useEffect, useMemo, useCallback } from 'react';
import { Link } from 'react-router';
import { FolderOpen, Gamepad2, Terminal, Code, RefreshCw, Wrench, Archive, ArchiveRestore, Ticket, Download, Tag, AlertTriangle, Rocket, Camera, Image, Sparkles } from 'lucide-react';
import toast from '../../ui/Toast';
@@ -23,6 +23,7 @@ export default function OverviewTab({ app, onRefresh }) {
const [archiving, setArchiving] = useState(false);
const [jiraTickets, setJiraTickets] = useState(null);
const [loadingTickets, setLoadingTickets] = useState(false);
+ const [ticketError, setTicketError] = useState(null);
const [installingScripts, setInstallingScripts] = useState(false);
const [detectingIcon, setDetectingIcon] = useState(false);
// Reverse lookup (#2991): sprite records that publish assets into this app.
@@ -35,16 +36,21 @@ export default function OverviewTab({ app, onRefresh }) {
const updating = isOperating && operationType === 'update';
const standardizing = isOperating && operationType === 'standardize';
- useEffect(() => {
- if (app?.jira?.enabled && app.jira.instanceId && app.jira.projectKey) {
- setLoadingTickets(true);
- api.getMySprintTickets(app.jira.instanceId, app.jira.projectKey)
- .then(setJiraTickets)
- .catch(() => setJiraTickets([]))
- .finally(() => setLoadingTickets(false));
- }
+ // Same sentinel contract as the /apps list (#3437): a failed fetch records a
+ // message instead of collapsing into `[]`, which read as "you have no sprint
+ // tickets" and offered no way to retry.
+ const loadSprintTickets = useCallback(() => {
+ if (!app?.jira?.enabled || !app.jira.instanceId || !app.jira.projectKey) return;
+ setLoadingTickets(true);
+ setTicketError(null);
+ api.getMySprintTickets(app.jira.instanceId, app.jira.projectKey, { silent: true })
+ .then(tickets => setJiraTickets(Array.isArray(tickets) ? tickets : []))
+ .catch(err => setTicketError(err?.message || 'Request failed'))
+ .finally(() => setLoadingTickets(false));
}, [app?.jira?.enabled, app?.jira?.instanceId, app?.jira?.projectKey]);
+ useEffect(() => { loadSprintTickets(); }, [loadSprintTickets]);
+
// Load the sprite records bound to this app (empty for an app with none).
useEffect(() => {
if (!app?.id) return;
@@ -308,6 +314,18 @@ export default function OverviewTab({ app, onRefresh }) {
<BrailleSpinner text="" />
<span>Loading tickets...</span>
</div>
+ ) : ticketError ? (
+ <div className="flex flex-wrap items-center gap-3 px-3 py-2 bg-port-card border border-port-error/30 rounded-lg max-w-5xl">
+ <AlertTriangle size={16} className="text-port-error shrink-0" />
+ <span className="text-sm text-gray-300 min-w-0">Couldn&apos;t load sprint tickets — {ticketError}</span>
+ <button
+ onClick={loadSprintTickets}
+ className="px-3 py-1.5 bg-port-border hover:bg-port-border/80 text-white rounded-lg text-xs flex items-center gap-1"
+ aria-label={`Retry loading sprint tickets for ${app.name}`}
+ >
+ <RefreshCw size={14} /> Retry
+ </button>
+ </div>
) : jiraTickets?.length > 0 ? (
<KanbanBoard tickets={jiraTickets} instanceId={app.jira?.instanceId} onTicketsChange={setJiraTickets} appId={app.id} projectKey={app.jira?.projectKey} boardId={app.jira?.boardId} />
) : (
diff --git a/client/src/pages/Apps.jsx b/client/src/pages/Apps.jsx
index b1199a6407..66900c28b9 100644
--- a/client/src/pages/Apps.jsx
+++ b/client/src/pages/Apps.jsx
@@ -1,6 +1,6 @@
import { useState, useEffect, useCallback, useRef } from 'react';
import { Link } from 'react-router';
-import { ExternalLink, Gamepad2, Play, Square, RotateCcw, FolderOpen, Terminal, Code, RefreshCw, Wrench, Archive, ArchiveRestore, Ticket, Download, Hammer, Smartphone, Trash2 } from 'lucide-react';
+import { ExternalLink, Gamepad2, Play, Square, RotateCcw, FolderOpen, Terminal, Code, RefreshCw, Wrench, Archive, ArchiveRestore, Ticket, Download, Hammer, Smartphone, Trash2, AlertTriangle } from 'lucide-react';
import toast from '../components/ui/Toast';
import InlineConfirmRow from '../components/ui/InlineConfirmRow';
import OverflowMenu from '../components/ui/OverflowMenu';
@@ -36,6 +36,9 @@ export default function Apps() {
const setShowArchived = (next) => updateParams({ view: next ? 'archived' : null });
const [jiraTickets, setJiraTickets] = useState({});
const [loadingTickets, setLoadingTickets] = useState({});
+ // Parallel to jiraTickets: `undefined` tickets + a message here means "the
+ // fetch failed", which is a different thing from a fetched empty sprint.
+ const [ticketErrors, setTicketErrors] = useState({});
// Per-row "…" trigger refs, so dismissing a row's delete confirmation hands
// focus back to the control that opened it instead of dropping it on <body>.
const menuTriggerRefs = useRef({});
@@ -118,22 +121,33 @@ export default function Apps() {
const handleStandardize = (app) => startStandardize(app.id, app.name);
- const toggleExpand = async (id) => {
+ // A failed fetch must NOT be cached as `[]` — that read as "you have no
+ // sprint tickets" and, because the `!jiraTickets[id]` guard was satisfied by
+ // the cached empty array, never retried for the life of the page (#3437).
+ // Failure records a message and leaves `jiraTickets[id]` undefined, so both
+ // Retry and a re-expand re-issue the request; a genuine `[]` is still cached.
+ const loadSprintTickets = useCallback(async (app) => {
+ setLoadingTickets(prev => ({ ...prev, [app.id]: true }));
+ setTicketErrors(prev => ({ ...prev, [app.id]: null }));
+ const tickets = await api
+ .getMySprintTickets(app.jira.instanceId, app.jira.projectKey, { silent: true })
+ .catch(err => {
+ setTicketErrors(prev => ({ ...prev, [app.id]: err?.message || 'Request failed' }));
+ return null;
+ });
+ if (Array.isArray(tickets)) setJiraTickets(prev => ({ ...prev, [app.id]: tickets }));
+ setLoadingTickets(prev => ({ ...prev, [app.id]: false }));
+ }, []);
+
+ const toggleExpand = (id) => {
const newExpandedId = expandedId === id ? null : id;
setExpandedId(newExpandedId);
// Fetch JIRA tickets when expanding an app with JIRA enabled
- if (newExpandedId) {
- const app = apps.find(a => a.id === newExpandedId);
- if (app?.jira?.enabled && app.jira.instanceId && app.jira.projectKey) {
- if (!jiraTickets[id]) {
- setLoadingTickets(prev => ({ ...prev, [id]: true }));
- const tickets = await api.getMySprintTickets(app.jira.instanceId, app.jira.projectKey).catch(() => []);
- setJiraTickets(prev => ({ ...prev, [id]: tickets }));
- setLoadingTickets(prev => ({ ...prev, [id]: false }));
- }
- }
- }
+ if (!newExpandedId) return;
+ const app = apps.find(a => a.id === newExpandedId);
+ if (!app?.jira?.enabled || !app.jira.instanceId || !app.jira.projectKey) return;
+ if (!jiraTickets[id]) loadSprintTickets(app);
};
// Archive/unarchive gate their success toast on a response, the way
@@ -586,6 +600,20 @@ export default function Apps() {
<BrailleSpinner text="" />
<span>Loading tickets...</span>
</div>
+ ) : ticketErrors[app.id] ? (
+ <div className="flex flex-wrap items-center gap-3 px-3 py-2 bg-port-card border border-port-error/30 rounded-lg">
+ <AlertTriangle size={16} aria-hidden="true" className="text-port-error shrink-0" />
+ <span className="text-sm text-gray-300 min-w-0">
+ Couldn&apos;t load sprint tickets — {ticketErrors[app.id]}
+ </span>
+ <button
+ onClick={() => loadSprintTickets(app)}
+ className="px-3 py-1.5 min-h-[40px] sm:min-h-0 bg-port-border hover:bg-port-border/80 text-white rounded-lg text-xs flex items-center gap-1 focus:outline-hidden focus:ring-2 focus:ring-port-accent"
+ aria-label={`Retry loading sprint tickets for ${app.name}`}
+ >
+ <RefreshCw size={14} aria-hidden="true" /> Retry
+ </button>
+ </div>
) : jiraTickets[app.id]?.length > 0 ? (
<KanbanBoard
tickets={jiraTickets[app.id]}
diff --git a/client/src/pages/Apps.test.jsx b/client/src/pages/Apps.test.jsx
index dba46808a7..3033c52934 100644
--- a/client/src/pages/Apps.test.jsx
+++ b/client/src/pages/Apps.test.jsx
@@ -29,6 +29,8 @@ vi.mock('../services/api', () => ({
buildApp: vi.fn(() => Promise.resolve({})),
refreshAppConfig: vi.fn(() => Promise.resolve({})),
getMySprintTickets: vi.fn(() => Promise.resolve([])),
+ getJiraBoardColumns: vi.fn(() => Promise.resolve({ columns: [] })),
+ updateJiraTicketStatus: vi.fn(() => Promise.resolve({})),
openAppInEditor: vi.fn(() => Promise.resolve({})),
openAppFolder: vi.fn(() => Promise.resolve({})),
openAppInXcode: vi.fn(() => Promise.resolve({ success: true, path: '/srv/example-ios/ExampleIos.xcodeproj' })),
@@ -400,3 +402,76 @@ describe('Apps archive result reporting (#3436)', () => {
expect(await screen.findByRole('button', { name: /Archived \(1\)/ })).toBeTruthy();
});
});
+
+describe('Apps sprint-ticket fetch failures (#3437)', () => {
+ const JIRA_APP = {
+ ...APPS[0],
+ jira: { enabled: true, instanceId: 'jira-1', projectKey: 'EX', issueType: 'Task' }
+ };
+
+ beforeEach(() => {
+ vi.clearAllMocks();
+ api.getApps.mockResolvedValue([JIRA_APP]);
+ });
+
+ // The toggle relabels itself once open, so match either direction.
+ const toggleRow = async (user) => {
+ await user.click(screen.getByRole('button', { name: /(Expand|Collapse) Example App details/ }));
+ };
+
+ it('reports a failed fetch instead of claiming the sprint is empty, and retries on demand', async () => {
+ api.getMySprintTickets.mockRejectedValue(new Error('JIRA instance unreachable'));
+ const user = userEvent.setup();
+ await renderApps();
+
+ await toggleRow(user);
+ await screen.findByText(/Couldn't load sprint tickets/);
+ expect(screen.getByText(/JIRA instance unreachable/)).toBeTruthy();
+ expect(screen.queryByText('No tickets assigned to you in the current sprint')).toBeNull();
+
+ // Retry re-issues the request, and a now-healthy JIRA renders the board.
+ api.getMySprintTickets.mockResolvedValue([
+ { key: 'EX-1', summary: 'Example ticket', status: 'To Do' }
+ ]);
+ await user.click(screen.getByRole('button', { name: 'Retry loading sprint tickets for Example App' }));
+
+ await waitFor(() => expect(api.getMySprintTickets).toHaveBeenCalledTimes(2));
+ await waitFor(() => expect(screen.queryByText(/Couldn't load sprint tickets/)).toBeNull());
+ });
+
+ it('re-issues the request on the next expand after a failure instead of caching it', async () => {
+ api.getMySprintTickets.mockRejectedValue(new Error('JIRA instance unreachable'));
+ const user = userEvent.setup();
+ await renderApps();
+
+ await toggleRow(user);
+ await screen.findByText(/Couldn't load sprint tickets/);
+
+ await toggleRow(user); // collapse
+ await toggleRow(user); // re-expand
+ await waitFor(() => expect(api.getMySprintTickets).toHaveBeenCalledTimes(2));
+ });
+
+ it('still reports a genuinely empty sprint as empty, and caches it', async () => {
+ api.getMySprintTickets.mockResolvedValue([]);
+ const user = userEvent.setup();
+ await renderApps();
+
+ await toggleRow(user);
+ expect(await screen.findByText('No tickets assigned to you in the current sprint')).toBeTruthy();
+
+ await toggleRow(user); // collapse
+ await toggleRow(user); // re-expand — the cached [] is authoritative
+ expect(api.getMySprintTickets).toHaveBeenCalledTimes(1);
+ });
+
+ it('renders its own error UI, so the request stays silent', async () => {
+ api.getMySprintTickets.mockRejectedValue(new Error('JIRA instance unreachable'));
+ const user = userEvent.setup();
+ await renderApps();
+
+ await toggleRow(user);
+ await screen.findByText(/Couldn't load sprint tickets/);
+ expect(api.getMySprintTickets).toHaveBeenCalledWith('jira-1', 'EX', { silent: true });
+ });
+});