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

feat([issue-2293]): surface filed-proposal counts/links per app on the Layered Intelligence overview

Adam Eivy33f33d3351eb
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index ebd81e97df..7e7920240f 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -35,6 +35,7 @@
## Layered Intelligence
+- **[issue-2293] The overview page can now show how many proposals the loop has actually filed per app, with links.** The `/layered-intelligence` page was deliberately deterministic (config + scheduler bookkeeping only, no LLM/forge I/O), so it couldn't tell you whether the loop had filed one issue or fifty for a given app. A new opt-in "Load filed-proposal counts" button on the page fires a separate `GET /api/apps/layered-intelligence/proposals` endpoint that does the per-app tracker read on demand — counting the `layered-intelligence`-labelled items each enabled app has filed and surfacing open/closed totals plus clickable links to the actual GitHub/GitLab issues (Jira and PLAN.md apps show counts without per-item links). Splitting it into its own endpoint keeps the base overview fast and I/O-free: the counts only cost a `gh`/`glab` shell-out (or Jira REST call, or PLAN.md scan) when the user asks for them, and only enabled-loop apps are swept so the fan-out is bounded. Each app resolves and reads concurrently and independently — one failing tracker read surfaces as that app's "couldn't read the tracker" rather than aborting the batch, and a failed read never collapses into a misleading zero (the sentinel rule). No LLM calls (forge reads only), so it's outside the no-cold-bootstrap policy. `listForgeIssues` now also surfaces each issue's `url` (`gh url` / `glab web_url`). (`server/services/layeredIntelligence.js` `summarizeFiledProposals`/`normalizeProposalSummary`, `server/routes/apps.js`, `client/src/services/apiApps.js`, `client/src/pages/LayeredIntelligence.jsx`)
- **[issue-2262] The loop can now hand a trivial, safe fix straight to a coding agent instead of only filing it.** Each app's Intelligence config gains an opt-in "Auto hand-off" toggle (off by default, on top of enabling the loop). When it's on and the reasoner marks its single proposal both `trivial` and `safe`, the loop still files the tracker issue for the audit trail, then also queues an approval-gated CoS coding-agent task to implement that exact issue end-to-end (read → fix → test → PR that closes it, or stop and comment if it turns out non-trivial). The reasoner's JSON now carries `complexity` (`trivial`/`moderate`/`complex`) and `safe` fields, and the prompt only mentions the hand-off path when the app enabled it — so a hand-off-off app's reasoning is unchanged. The hand-off only fires for a concretely-filed forge issue or Jira ticket (a plan-tracked app has no issue number, so it stays file-only and its PLAN item is drained by the normal claim-work scheduler), the enqueued task requires user approval before any code is written, and it's deduped per app so a re-run won't double-queue while the fix is still pending. No cold-bootstrap risk — it only runs inside the already user-enabled scheduled sweep. (`server/services/layeredIntelligence.js` `isHandoffEligible`/`buildHandoffTask`, `server/services/autonomousJobs/layeredIntelligenceHandler.js`, `server/lib/validation.js`, `server/services/apps.js`, `client/src/components/apps/LayeredIntelligenceTab.jsx`)
- **[issue-2262] A dedicated Layered Intelligence page now surfaces the self-improvement loop's status across every app.** The perpetual per-app loop was previously visible only inside each app's Edit-App → Intelligence drawer tab, so there was no single place to see which apps had it enabled, when each last ran / is next due, or whether the global sweep job is even on. The new `/layered-intelligence` route (Chief of Staff → Layered Intelligence, `⌘K`/voice-navigable) reads a deterministic cross-app overview — each active app's effective config plus scheduler bookkeeping (`lastRunAt`/`nextDueAt`/due) and the global job's on/off state — with no LLM or forge I/O. It warns when the global job is disabled (per-app configs are inert until it's on), lists enabled apps with their interval, telemetry sources, allowed scopes, and provider, and deep-links each app's "Configure" action straight into its Intelligence tab (`/apps/:id?edit=1&appTab=intelligence`, via a new auto-open trigger on the app-detail drawer). (`server/routes/apps.js`, `server/services/layeredIntelligence.js` `summarizeLoopStatus`, `client/src/pages/LayeredIntelligence.jsx`, `client/src/components/apps/AppDetailView.jsx`, `server/lib/navManifest.js`)
- **[issue-2262] The loop now catches near-duplicate proposals worded differently, not just exact-slug repeats.** The DECIDE layer's dedup was purely the reasoner-chosen slug (plus label) — so if the model proposed the same work under a fresh slug ("introduce-widget" vs an open "add-widget"), it slipped past and filed a second tracker issue. A semantic guard now runs *after* the slug guard passes: it embeds the proposal's title+body and each open (or recently-closed, within the same 30-day window) tracker issue via the local embeddings provider, and suppresses the proposal when a candidate's cosine similarity meets a conservative floor (`SEMANTIC_DEDUP_THRESHOLD = 0.9`). It's strictly best-effort and self-gating: when no embeddings provider is configured (or the proposal embed is skipped/fails) the check reports `available:false` and filing proceeds — slug dedup already guarded the exact case, so an unavailable semantic layer only restores prior behavior, never files a slug-duplicate. No cold-bootstrap risk (embeddings degrade to a no-op with no provider, and this only runs inside the user-enabled scheduled sweep), no new config field, and plan-tracked slug-only issues are simply not embeddable so they're skipped. Candidate embedding is capped per run (`SEMANTIC_DEDUP_MAX_CANDIDATES = 50`) so a large backlog can't fan out unboundedly, and the shared `isIssueWithinDedupWindow` helper keeps the semantic and slug guards agreeing on which issues still count. (`server/services/layeredIntelligence.js` `checkSemanticDuplicate`/`findSemanticDuplicate`/`cosineSimilarity`, `server/services/autonomousJobs/layeredIntelligenceHandler.js`)
diff --git a/client/src/pages/LayeredIntelligence.jsx b/client/src/pages/LayeredIntelligence.jsx
index 0d27a2b36e..8a41643e8e 100644
--- a/client/src/pages/LayeredIntelligence.jsx
+++ b/client/src/pages/LayeredIntelligence.jsx
@@ -1,6 +1,6 @@
import { useState, useEffect, useCallback } from 'react';
import { Link } from 'react-router-dom';
-import { Brain, Settings, Clock, CheckCircle2, PauseCircle, Sparkles } from 'lucide-react';
+import { Brain, Settings, Clock, CheckCircle2, PauseCircle, Sparkles, FileText, ExternalLink, RefreshCw } from 'lucide-react';
import BrailleSpinner from '../components/BrailleSpinner';
import Banner from '../components/ui/Banner';
import * as api from '../services/api';
@@ -45,7 +45,67 @@ function Chip({ children, tone = 'default' }) {
);
}
-function AppLoopCard({ app }) {
+// Human label for a resolved work tracker (matches server workTracker.js values).
+const TRACKER_LABEL = {
+ github: 'GitHub Issues', gitlab: 'GitLab Issues', jira: 'Jira', plan: 'PLAN.md'
+};
+
+// Muted reason text for an app whose filed-proposal read didn't succeed.
+const PROPOSAL_REASON_TEXT = {
+ 'read-failed': 'Couldn’t read the tracker',
+ 'jira-not-configured': 'Jira not configured for this app',
+ 'no-repo': 'No repo path set',
+ error: 'Couldn’t read filed proposals'
+};
+
+// Filed-proposal counts + links for one app (issue #2293). Rendered only after
+// the user loads counts (the base overview stays I/O-free). `summary` is the
+// per-app entry from GET /apps/layered-intelligence/proposals, or undefined
+// before the counts are loaded.
+function ProposalSummary({ summary, loading }) {
+ if (loading && !summary) {
+ return <div className="text-xs text-gray-500 flex items-center gap-1"><RefreshCw size={11} className="animate-spin" /> Reading filed proposals…</div>;
+ }
+ if (!summary) return null;
+ const trackerLabel = TRACKER_LABEL[summary.tracker] || summary.tracker;
+ if (!summary.ok) {
+ return <div className="text-xs text-gray-500 flex items-center gap-1"><FileText size={11} /> {PROPOSAL_REASON_TEXT[summary.reason] || 'No proposal data'}</div>;
+ }
+ if (summary.total === 0) {
+ return <div className="text-xs text-gray-500 flex items-center gap-1"><FileText size={11} /> No filed proposals yet ({trackerLabel})</div>;
+ }
+ const linked = (summary.issues || []).filter(i => i.url);
+ return (
+ <div className="flex flex-col gap-1.5">
+ <div className="text-xs text-gray-300 flex items-center gap-1.5 flex-wrap">
+ <FileText size={11} className="text-port-accent shrink-0" />
+ <span className="font-medium text-white">{summary.total}</span> filed proposal{summary.total === 1 ? '' : 's'}
+ <span className="text-gray-500">
+ ({summary.open} open{summary.closed > 0 ? `, ${summary.closed} closed` : ''} · {trackerLabel})
+ </span>
+ </div>
+ {linked.length > 0 && (
+ <div className="flex flex-wrap gap-1.5">
+ {linked.map(i => (
+ <a
+ key={i.number ?? i.url}
+ href={i.url}
+ target="_blank"
+ rel="noopener noreferrer"
+ title={i.title}
+ className={`inline-flex items-center gap-1 px-2 py-0.5 rounded border text-xs hover:border-port-accent/50 ${i.state === 'open' ? 'bg-port-accent/10 text-port-accent border-port-accent/30' : 'bg-port-bg text-gray-500 border-port-border line-through'}`}
+ >
+ {i.number != null ? `#${i.number}` : 'issue'}
+ <ExternalLink size={10} />
+ </a>
+ ))}
+ </div>
+ )}
+ </div>
+ );
+}
+
+function AppLoopCard({ app, proposals, proposalsLoading }) {
const scopes = (app.allowedScopes || []).map(id => SCOPE_LABEL[id] || id);
const chips = sourceChips(app.sources);
return (
@@ -107,6 +167,7 @@ function AppLoopCard({ app }) {
</div>
)}
{app.hasRules && <div className="text-xs text-gray-500 flex items-center gap-1"><Sparkles size={11} /> Custom guidance rules set</div>}
+ <ProposalSummary summary={proposals} loading={proposalsLoading} />
</div>
)}
</div>
@@ -117,6 +178,10 @@ export default function LayeredIntelligence() {
const [data, setData] = useState(null);
const [loading, setLoading] = useState(true);
const [error, setError] = useState(false);
+ // Filed-proposal counts (issue #2293) — loaded on demand so the base overview
+ // stays I/O-free. `proposals` is a map of appId → summary once fetched.
+ const [proposals, setProposals] = useState(null);
+ const [proposalsLoading, setProposalsLoading] = useState(false);
const load = useCallback(async () => {
setError(false);
@@ -126,6 +191,15 @@ export default function LayeredIntelligence() {
setLoading(false);
}, []);
+ const loadProposals = useCallback(async () => {
+ setProposalsLoading(true);
+ const res = await api.getLayeredIntelligenceProposals().catch(() => null);
+ if (res?.apps) {
+ setProposals(Object.fromEntries(res.apps.map(a => [a.id, a])));
+ }
+ setProposalsLoading(false);
+ }, []);
+
useEffect(() => { load(); }, [load]);
const apps = data?.apps || [];
@@ -170,13 +244,29 @@ export default function LayeredIntelligence() {
</Banner>
)}
- <div className="text-sm text-gray-400">
- {enabledApps.length} of {apps.length} app{apps.length === 1 ? '' : 's'} have the loop enabled.
+ <div className="flex items-center justify-between gap-3 flex-wrap">
+ <div className="text-sm text-gray-400">
+ {enabledApps.length} of {apps.length} app{apps.length === 1 ? '' : 's'} have the loop enabled.
+ </div>
+ {enabledApps.length > 0 && (
+ <button
+ type="button"
+ onClick={loadProposals}
+ disabled={proposalsLoading}
+ title="Read each enabled app's tracker for the layered-intelligence proposals the loop has filed"
+ className="flex items-center gap-1.5 text-xs px-3 py-1.5 bg-port-accent/20 text-port-accent hover:bg-port-accent/30 rounded disabled:opacity-50"
+ >
+ <RefreshCw size={12} className={proposalsLoading ? 'animate-spin' : ''} />
+ {proposals ? 'Refresh filed counts' : 'Load filed-proposal counts'}
+ </button>
+ )}
</div>
{enabledApps.length > 0 ? (
<div className="grid gap-3 md:grid-cols-2">
- {enabledApps.map(app => <AppLoopCard key={app.id} app={app} />)}
+ {enabledApps.map(app => (
+ <AppLoopCard key={app.id} app={app} proposals={proposals?.[app.id]} proposalsLoading={proposalsLoading} />
+ ))}
</div>
) : (
<Banner tone="info" size="md">
diff --git a/client/src/pages/LayeredIntelligence.test.jsx b/client/src/pages/LayeredIntelligence.test.jsx
index d2a232f942..e127d1551a 100644
--- a/client/src/pages/LayeredIntelligence.test.jsx
+++ b/client/src/pages/LayeredIntelligence.test.jsx
@@ -1,11 +1,13 @@
import { describe, it, expect, vi, beforeEach } from 'vitest';
import { render, screen, waitFor } from '@testing-library/react';
+import userEvent from '@testing-library/user-event';
import { MemoryRouter } from 'react-router-dom';
import LayeredIntelligence from './LayeredIntelligence';
import * as api from '../services/api';
vi.mock('../services/api', () => ({
- getLayeredIntelligenceOverview: vi.fn()
+ getLayeredIntelligenceOverview: vi.fn(),
+ getLayeredIntelligenceProposals: vi.fn()
}));
const renderPage = () => render(
@@ -69,4 +71,27 @@ describe('LayeredIntelligence page', () => {
await waitFor(() => expect(screen.getByText(/Couldn't load/)).toBeInTheDocument());
expect(screen.getByRole('button', { name: 'Retry' })).toBeInTheDocument();
});
+
+ it('loads filed-proposal counts + links on demand and merges them into the enabled card', async () => {
+ api.getLayeredIntelligenceOverview.mockResolvedValue(overview());
+ api.getLayeredIntelligenceProposals.mockResolvedValue({
+ apps: [{
+ id: 'app-on', name: 'Alpha', ok: true, tracker: 'github', open: 2, closed: 1, total: 3,
+ issues: [{ number: 5, title: 'Add widget', state: 'open', url: 'https://github.com/o/r/issues/5' }]
+ }]
+ });
+ renderPage();
+
+ await waitFor(() => expect(screen.getByText('Alpha')).toBeInTheDocument());
+ const btn = screen.getByRole('button', { name: /Load filed-proposal counts/ });
+ await userEvent.click(btn);
+
+ await waitFor(() => expect(screen.getByText(/filed proposals/)).toBeInTheDocument());
+ expect(screen.getByText('3')).toBeInTheDocument();
+ expect(screen.getByText(/2 open, 1 closed · GitHub Issues/)).toBeInTheDocument();
+ const link = screen.getByRole('link', { name: /#5/ });
+ expect(link).toHaveAttribute('href', 'https://github.com/o/r/issues/5');
+ // Button flips to "Refresh" once counts are loaded.
+ expect(screen.getByRole('button', { name: /Refresh filed counts/ })).toBeInTheDocument();
+ });
});
diff --git a/client/src/services/apiApps.js b/client/src/services/apiApps.js
index dd8d8467db..762e4a5696 100644
--- a/client/src/services/apiApps.js
+++ b/client/src/services/apiApps.js
@@ -20,6 +20,13 @@ export const getAppLayeredIntelligence = (id, options) =>
// lastRunAt, nextDueAt, due, allowedScopes, sources, ... }] }. Read-only.
export const getLayeredIntelligenceOverview = (options) =>
request('/apps/layered-intelligence/overview', options);
+// Opt-in filed-proposal counts + links for the overview page: does per-app
+// forge/Jira/PLAN I/O (gh/glab shell-outs), so it's fired on demand rather than
+// baked into the base overview. Returns { apps: [{ id, name, ok, tracker, open,
+// closed, total, issues: [{ number, title, state, url }], reason? }] }. Caller
+// owns its own error UI, so default to silent.
+export const getLayeredIntelligenceProposals = (options) =>
+ request('/apps/layered-intelligence/proposals', { silent: true, ...options });
export const createApp = (data) => request('/apps', {
method: 'POST',
body: JSON.stringify(data)
diff --git a/server/routes/apps.js b/server/routes/apps.js
index d2de61fd06..798b129a5c 100644
--- a/server/routes/apps.js
+++ b/server/routes/apps.js
@@ -21,7 +21,8 @@ import { detectAppIcon, getIconContentType, isUsableSvg } from '../services/appI
import { hasDeployScript } from '../services/appDeployer.js';
import { checkScripts, installScripts, XCODE_SCRIPT_NAMES } from '../services/xcodeScripts.js';
import { SELF_IMPROVEMENT_TASK_TYPES } from '../services/taskSchedule.js';
-import { summarizeLoopStatus, LI_JOB_ID } from '../services/layeredIntelligence.js';
+import { summarizeLoopStatus, summarizeFiledProposals, LI_JOB_ID } from '../services/layeredIntelligence.js';
+import { resolveAppWorkTracker } from '../lib/workTracker.js';
import * as autonomousJobs from '../services/autonomousJobs.js';
import { certPaths } from '../../lib/certPaths.js';
@@ -739,9 +740,11 @@ router.get('/:id/work-tracker', loadApp, asyncHandler(async (req, res) => {
// effective config + scheduler bookkeeping (lastRunAt/nextDueAt/due) plus the
// global autonomous-job on/off state (a per-app config is inert while the job is
// disabled). NO LLM and NO forge I/O — filed-proposal counts stay off this
-// surface deliberately (they'd require per-app `gh`/`glab` shell-outs). This
-// two-segment static path can't collide with `/:id` (one segment) or
-// `/:id/layered-intelligence` (literal second segment), so ordering is safe.
+// surface deliberately (they'd require per-app `gh`/`glab` shell-outs); those
+// are served by the separate opt-in `/layered-intelligence/proposals` endpoint
+// below so this base overview stays fast. This two-segment static path can't
+// collide with `/:id` (one segment) or `/:id/layered-intelligence` (literal
+// second segment), so ordering is safe.
router.get('/layered-intelligence/overview', asyncHandler(async (req, res) => {
const [apps, job] = await Promise.all([
appsService.getActiveApps(),
@@ -765,6 +768,33 @@ router.get('/layered-intelligence/overview', asyncHandler(async (req, res) => {
});
}));
+// GET /api/apps/layered-intelligence/proposals - Cross-app filed-proposal counts
+// + links for the overview page (issue #2293). Deliberately SPLIT from the base
+// overview: this one DOES per-app forge/Jira/PLAN I/O (gh/glab shell-outs, Jira
+// REST, PLAN.md scan) to count the layered-intelligence-labelled items the loop
+// has actually filed, so it's an opt-in "refresh counts" action the client fires
+// on demand rather than baking network/CLI latency into the base overview. Only
+// enabled-loop apps are swept so the I/O fan-out is bounded. Each app resolves +
+// summarizes concurrently and independently — one failing tracker read surfaces
+// as that app's `ok:false` without aborting the batch. NO LLM calls (forge reads
+// only), so it's outside the no-cold-bootstrap policy. Static two-segment path,
+// registered before `/:id/...`, so no route collision.
+router.get('/layered-intelligence/proposals', asyncHandler(async (req, res) => {
+ const apps = await appsService.getActiveApps();
+ // Bound the I/O fan-out to apps whose loop is actually enabled — a disabled
+ // app has filed nothing this config cares about, and sweeping every managed
+ // app would shell out `gh`/`glab` needlessly.
+ const enabled = apps.filter(app => summarizeLoopStatus({ app, isPortos: app.id === PORTOS_APP_ID }).enabled);
+ const results = await Promise.all(enabled.map(async (app) => {
+ const tracker = await resolveAppWorkTracker(app).catch(() => ({ resolved: 'plan', forge: null }));
+ const summary = await summarizeFiledProposals({ app, tracker })
+ .catch(() => ({ ok: false, tracker: tracker?.resolved || 'plan', reason: 'error', open: 0, closed: 0, total: 0, issues: [] }));
+ return { id: app.id, name: app.name || app.id, ...summary };
+ }));
+ console.log(`🧠 Layered Intelligence: filed-proposal counts read for ${results.length} enabled app(s)`);
+ res.json({ apps: results });
+}));
+
// GET /api/apps/:id/layered-intelligence - Effective Layered Intelligence config
// for this app (the self-improvement loop). Merges the app's stored partial
// config over the shipped defaults so the UI always renders a complete, safe
diff --git a/server/routes/apps.test.js b/server/routes/apps.test.js
index 1c8004b9bb..9143647a2d 100644
--- a/server/routes/apps.test.js
+++ b/server/routes/apps.test.js
@@ -42,6 +42,22 @@ vi.mock('../services/autonomousJobs.js', () => ({
getJob: vi.fn()
}));
+// Partial-mock layeredIntelligence: keep the real pure helpers (summarizeLoopStatus,
+// LI_JOB_ID) the overview route relies on, but stub the I/O summarizeFiledProposals
+// so the proposals route test never shells out to gh/glab.
+vi.mock('../services/layeredIntelligence.js', async (importActual) => {
+ const actual = await importActual();
+ return { ...actual, summarizeFiledProposals: vi.fn() };
+});
+
+// Stub the git-shelling tracker resolver so the proposals route test is I/O-free,
+// but keep the real pure exports (WORK_TRACKERS is consumed by validation.js at
+// module load — dropping it would break the whole route module).
+vi.mock('../lib/workTracker.js', async (importActual) => {
+ const actual = await importActual();
+ return { ...actual, resolveAppWorkTracker: vi.fn() };
+});
+
vi.mock('../services/streamingDetect.js', () => ({
parseEcosystemFromPath: vi.fn(),
writeEcosystemPortEdits: vi.fn().mockResolvedValue({ file: 'ecosystem.config.cjs', changed: true, remapApplied: true, applied: [], unapplied: [] }),
@@ -93,6 +109,8 @@ import * as history from '../services/history.js';
import * as streamingDetect from '../services/streamingDetect.js';
import * as cos from '../services/cos.js';
import * as autonomousJobs from '../services/autonomousJobs.js';
+import { summarizeFiledProposals } from '../services/layeredIntelligence.js';
+import { resolveAppWorkTracker } from '../lib/workTracker.js';
import { detectAppIcon, getIconContentType, isUsableSvg } from '../services/appIconDetect.js';
import { installScripts } from '../services/xcodeScripts.js';
import { writeFileSync, readFileSync, mkdirSync, rmSync } from 'fs';
@@ -354,6 +372,45 @@ describe('Apps Routes', () => {
expect(response.body.enabledCount).toBe(0);
});
+ it('GET /layered-intelligence/proposals sweeps only enabled apps and returns counts + links', async () => {
+ appsService.getActiveApps.mockResolvedValue([
+ { id: 'off-app', name: 'Off', layeredIntelligence: { enabled: false }, repoPath: '/off' },
+ { id: 'on-app', name: 'On', layeredIntelligence: { enabled: true }, repoPath: '/on' }
+ ]);
+ resolveAppWorkTracker.mockResolvedValue({ resolved: 'github', forge: 'gh' });
+ summarizeFiledProposals.mockResolvedValue({
+ ok: true, tracker: 'github', open: 2, closed: 1, total: 3,
+ issues: [{ number: 5, title: 'X', state: 'open', url: 'https://github.com/o/r/issues/5' }]
+ });
+
+ const response = await request(app).get('/api/apps/layered-intelligence/proposals');
+
+ expect(response.status).toBe(200);
+ // Only the enabled app is swept (the disabled one files nothing this cares about).
+ expect(response.body.apps).toHaveLength(1);
+ expect(response.body.apps[0]).toMatchObject({ id: 'on-app', name: 'On', ok: true, total: 3, open: 2, closed: 1 });
+ expect(response.body.apps[0].issues[0].url).toContain('/issues/5');
+ expect(summarizeFiledProposals).toHaveBeenCalledTimes(1);
+ });
+
+ it('GET /layered-intelligence/proposals degrades one failing app without aborting the batch', async () => {
+ appsService.getActiveApps.mockResolvedValue([
+ { id: 'a', name: 'A', layeredIntelligence: { enabled: true }, repoPath: '/a' },
+ { id: 'b', name: 'B', layeredIntelligence: { enabled: true }, repoPath: '/b' }
+ ]);
+ resolveAppWorkTracker.mockResolvedValue({ resolved: 'github', forge: 'gh' });
+ summarizeFiledProposals
+ .mockResolvedValueOnce({ ok: true, tracker: 'github', open: 1, closed: 0, total: 1, issues: [] })
+ .mockRejectedValueOnce(new Error('boom'));
+
+ const response = await request(app).get('/api/apps/layered-intelligence/proposals');
+
+ expect(response.status).toBe(200);
+ expect(response.body.apps).toHaveLength(2);
+ const b = response.body.apps.find(a => a.id === 'b');
+ expect(b).toMatchObject({ ok: false, reason: 'error', total: 0 });
+ });
+
it('writes changed ports back to the ecosystem config (source of truth)', async () => {
// repoPath must exist on disk so the pathExists guard passes.
const mockApp = { id: 'app-001', name: 'App', type: 'node', repoPath: process.cwd(), apiPort: 5173, uiPort: 5174 };
diff --git a/server/services/layeredIntelligence.js b/server/services/layeredIntelligence.js
index 261e5f5fc1..2c5cbf199e 100644
--- a/server/services/layeredIntelligence.js
+++ b/server/services/layeredIntelligence.js
@@ -709,7 +709,7 @@ export function normalizeIssueState(state) {
export async function listForgeIssues({ cli, cwd, env, exec = runCli } = {}) {
const args = cli === 'glab'
? ['issue', 'list', '--label', LI_LABEL, '--all', '-P', '100', '-F', 'json']
- : ['issue', 'list', '--label', LI_LABEL, '--state', 'all', '--limit', '100', '--json', 'number,title,body,state,closedAt'];
+ : ['issue', 'list', '--label', LI_LABEL, '--state', 'all', '--limit', '100', '--json', 'number,title,body,state,closedAt,url'];
const { code, stdout } = await exec(cli, args, { cwd, env });
if (code !== 0) return { ok: false, issues: [] };
if (!stdout.trim()) return { ok: true, issues: [] };
@@ -723,6 +723,10 @@ export async function listForgeIssues({ cli, cwd, env, exec = runCli } = {}) {
body: i.body || i.description || '',
state: normalizeIssueState(i.state),
closedAt: i.closedAt || i.closed_at || null,
+ // gh reports `url`; glab reports `web_url`. Null when neither is present so
+ // the overview's proposal links degrade to a plain count rather than a
+ // dead href.
+ url: i.url || i.web_url || null,
slug: extractSlugFromBody(i.body || i.description || '') || extractSlugFromBody(i.title || '')
}))
};
@@ -940,3 +944,90 @@ export function extractPlanSlugs(planContent) {
while ((m = re.exec(planContent))) slugs.push(m[1].toLowerCase());
return slugs;
}
+
+// ---------------------------------------------------------------------------
+// Filed-proposal counts + links (issue #2293). The base overview endpoint stays
+// deterministic + I/O-free; THIS function does the per-app forge/Jira/PLAN read
+// behind an explicit "refresh counts" action so the count/link surface is opt-in.
+// ---------------------------------------------------------------------------
+
+// A ceiling on the number of proposal issues surfaced back to the UI per app so a
+// repo with a large layered-intelligence backlog can't return an unbounded list;
+// the count itself is still the full total, only the linked list is capped.
+export const PROPOSAL_LINKS_MAX = 25;
+
+/**
+ * Normalize a forge/Jira lister's `{ ok, issues }` into the overview's
+ * filed-proposal summary shape: `{ ok, tracker, open, closed, total, issues }`,
+ * where each surfaced issue is `{ number, title, state, url }` (link-ready).
+ * A FAILED read (`ok:false`) surfaces as `{ ok:false, reason:'read-failed' }`
+ * rather than a misleading `total:0` — the CLAUDE.md sentinel rule (a failed
+ * fetch must not collapse into "legitimately zero").
+ */
+export function normalizeProposalSummary(listed, tracker) {
+ if (!listed?.ok) {
+ return { ok: false, tracker, reason: 'read-failed', open: 0, closed: 0, total: 0, issues: [] };
+ }
+ const all = Array.isArray(listed.issues) ? listed.issues : [];
+ const open = all.filter(i => i.state === 'open').length;
+ const issues = all.slice(0, PROPOSAL_LINKS_MAX).map(i => ({
+ number: i.number ?? null,
+ title: i.title || '',
+ state: i.state,
+ url: i.url || null
+ }));
+ return { ok: true, tracker, open, closed: all.length - open, total: all.length, issues };
+}
+
+/**
+ * Summarize the filed layered-intelligence proposals for ONE app — count + links,
+ * resolved through whatever tracker the app files to. I/O function (shells out to
+ * gh/glab or hits the Jira REST service); the listers it delegates to are
+ * catch-safe so this never throws — a failed read surfaces as `ok:false`.
+ *
+ * `tracker` is the app's resolved work tracker (`resolveAppWorkTracker(app)`),
+ * passed in so the caller can resolve every app's tracker concurrently. Deps are
+ * injectable so tests drive the dispatch without a live forge/Jira/filesystem.
+ */
+export async function summarizeFiledProposals({ app, tracker, deps = {} } = {}) {
+ const {
+ listForge = listForgeIssues,
+ listJira = listJiraIssues,
+ readPlan = tryReadFile
+ } = deps;
+ const resolved = tracker?.resolved || 'plan';
+ const filer = filerForTracker(resolved);
+ const cwd = app?.repoPath;
+
+ if (filer === 'forge') {
+ if (!tracker?.forge || !cwd) {
+ return { ok: false, tracker: resolved, reason: 'no-repo', open: 0, closed: 0, total: 0, issues: [] };
+ }
+ const listed = await listForge({ cli: tracker.forge, cwd });
+ return normalizeProposalSummary(listed, resolved);
+ }
+
+ if (filer === 'jira') {
+ // Jira coordinates come from the app's explicit per-app config (never
+ // auto-detected), mirroring the sweep handler's gate.
+ const jira = (app?.jira?.enabled && app.jira?.instanceId && app.jira?.projectKey)
+ ? { instanceId: app.jira.instanceId, projectKey: app.jira.projectKey }
+ : null;
+ if (!jira) {
+ return { ok: false, tracker: 'jira', reason: 'jira-not-configured', open: 0, closed: 0, total: 0, issues: [] };
+ }
+ const listed = await listJira({ instanceId: jira.instanceId, projectKey: jira.projectKey });
+ // Jira issues carry a key (PROJ-123) but no browse URL from the lister, so
+ // they surface as counts without per-item links.
+ return normalizeProposalSummary(listed, 'jira');
+ }
+
+ // plan tracker — count slug-tagged checklist items in PLAN.md. All PLAN items
+ // are "open" (the plan filer has no closed-state), and have no per-item URL.
+ if (!cwd) {
+ return { ok: false, tracker: 'plan', reason: 'no-repo', open: 0, closed: 0, total: 0, issues: [] };
+ }
+ const planContent = await readPlan(join(cwd, 'PLAN.md'));
+ const slugs = extractPlanSlugs(planContent || '');
+ return { ok: true, tracker: 'plan', open: slugs.length, closed: 0, total: slugs.length, issues: [] };
+}
diff --git a/server/services/layeredIntelligence.test.js b/server/services/layeredIntelligence.test.js
index cdc2d9b337..0474844981 100644
--- a/server/services/layeredIntelligence.test.js
+++ b/server/services/layeredIntelligence.test.js
@@ -51,7 +51,10 @@ import {
LI_BLOCKING_LABEL,
LI_JIRA_BLOCKING_LABEL,
LI_JOB_ID,
- summarizeLoopStatus
+ summarizeLoopStatus,
+ summarizeFiledProposals,
+ normalizeProposalSummary,
+ PROPOSAL_LINKS_MAX
} from './layeredIntelligence.js';
describe('defaultLayeredIntelligenceConfig', () => {
@@ -1029,3 +1032,106 @@ describe('checkSemanticDuplicate — I/O wrapper', () => {
expect(SEMANTIC_DEDUP_THRESHOLD).toBeLessThanOrEqual(1);
});
});
+
+describe('listForgeIssues url surfacing (issue #2293)', () => {
+ it('surfaces gh `url` on each issue', async () => {
+ const exec = vi.fn().mockResolvedValue({
+ code: 0,
+ stdout: JSON.stringify([{ number: 12, title: 'A', body: 'x', state: 'OPEN', url: 'https://github.com/o/r/issues/12' }])
+ });
+ const { issues } = await listForgeIssues({ cli: 'gh', cwd: '/x', exec });
+ expect(issues[0].url).toBe('https://github.com/o/r/issues/12');
+ });
+
+ it('maps GitLab `web_url` to url', async () => {
+ const exec = vi.fn().mockResolvedValue({
+ code: 0,
+ stdout: JSON.stringify([{ iid: 9, title: 'G', description: 'd', state: 'opened', web_url: 'https://gitlab.com/o/r/-/issues/9' }])
+ });
+ const { issues } = await listForgeIssues({ cli: 'glab', cwd: '/x', exec });
+ expect(issues[0].url).toBe('https://gitlab.com/o/r/-/issues/9');
+ });
+
+ it('defaults url to null when neither field is present', async () => {
+ const exec = vi.fn().mockResolvedValue({ code: 0, stdout: JSON.stringify([{ number: 1, title: 'A', body: 'x', state: 'OPEN' }]) });
+ const { issues } = await listForgeIssues({ cli: 'gh', cwd: '/x', exec });
+ expect(issues[0].url).toBeNull();
+ });
+});
+
+describe('normalizeProposalSummary (issue #2293)', () => {
+ it('distinguishes a failed read from a legitimately empty one', () => {
+ expect(normalizeProposalSummary({ ok: false }, 'github')).toMatchObject({ ok: false, reason: 'read-failed', total: 0 });
+ expect(normalizeProposalSummary({ ok: true, issues: [] }, 'github')).toMatchObject({ ok: true, total: 0, open: 0, closed: 0 });
+ });
+
+ it('counts open vs closed and surfaces link-ready issues', () => {
+ const listed = { ok: true, issues: [
+ { number: 1, title: 'A', state: 'open', url: 'u1' },
+ { number: 2, title: 'B', state: 'closed', url: 'u2' }
+ ] };
+ const s = normalizeProposalSummary(listed, 'github');
+ expect(s).toMatchObject({ ok: true, total: 2, open: 1, closed: 1 });
+ expect(s.issues).toEqual([
+ { number: 1, title: 'A', state: 'open', url: 'u1' },
+ { number: 2, title: 'B', state: 'closed', url: 'u2' }
+ ]);
+ });
+
+ it('caps the surfaced link list at PROPOSAL_LINKS_MAX but keeps the full total', () => {
+ const issues = Array.from({ length: PROPOSAL_LINKS_MAX + 10 }, (_, i) => ({ number: i, title: `t${i}`, state: 'open', url: `u${i}` }));
+ const s = normalizeProposalSummary({ ok: true, issues }, 'github');
+ expect(s.total).toBe(PROPOSAL_LINKS_MAX + 10);
+ expect(s.issues.length).toBe(PROPOSAL_LINKS_MAX);
+ });
+});
+
+describe('summarizeFiledProposals (issue #2293)', () => {
+ it('forge: delegates to the forge lister and normalizes', async () => {
+ const listForge = vi.fn().mockResolvedValue({ ok: true, issues: [{ number: 3, title: 'X', state: 'open', url: 'u' }] });
+ const s = await summarizeFiledProposals({
+ app: { id: 'a', repoPath: '/repo' },
+ tracker: { resolved: 'github', forge: 'gh' },
+ deps: { listForge }
+ });
+ expect(listForge).toHaveBeenCalledWith({ cli: 'gh', cwd: '/repo' });
+ expect(s).toMatchObject({ ok: true, tracker: 'github', total: 1, open: 1 });
+ });
+
+ it('forge: reports no-repo when the app has no repoPath', async () => {
+ const s = await summarizeFiledProposals({ app: { id: 'a' }, tracker: { resolved: 'github', forge: 'gh' } });
+ expect(s).toMatchObject({ ok: false, reason: 'no-repo', total: 0 });
+ });
+
+ it('jira: reports jira-not-configured without an instance/project', async () => {
+ const s = await summarizeFiledProposals({ app: { id: 'a', repoPath: '/r' }, tracker: { resolved: 'jira', forge: null } });
+ expect(s).toMatchObject({ ok: false, tracker: 'jira', reason: 'jira-not-configured' });
+ });
+
+ it('jira: delegates to the jira lister when configured', async () => {
+ const listJira = vi.fn().mockResolvedValue({ ok: true, issues: [{ number: 'PROJ-1', title: 'J', state: 'open' }] });
+ const s = await summarizeFiledProposals({
+ app: { id: 'a', repoPath: '/r', jira: { enabled: true, instanceId: 'i1', projectKey: 'PROJ' } },
+ tracker: { resolved: 'jira', forge: null },
+ deps: { listJira }
+ });
+ expect(listJira).toHaveBeenCalledWith({ instanceId: 'i1', projectKey: 'PROJ' });
+ expect(s).toMatchObject({ ok: true, tracker: 'jira', total: 1, open: 1 });
+ expect(s.issues[0].url).toBeNull(); // jira issues surface without per-item links
+ });
+
+ it('plan: counts slug tags in PLAN.md (all open, no links)', async () => {
+ const readPlan = vi.fn().mockResolvedValue('- [ ] [lil-foo] a\n- [ ] [lil-bar] b\n');
+ const s = await summarizeFiledProposals({
+ app: { id: 'a', repoPath: '/r' },
+ tracker: { resolved: 'plan', forge: null },
+ deps: { readPlan }
+ });
+ expect(s).toMatchObject({ ok: true, tracker: 'plan', total: 2, open: 2, closed: 0, issues: [] });
+ });
+
+ it('plan: reports no-repo without a repoPath', async () => {
+ const s = await summarizeFiledProposals({ app: { id: 'a' }, tracker: { resolved: 'plan', forge: null } });
+ expect(s).toMatchObject({ ok: false, tracker: 'plan', reason: 'no-repo' });
+ });
+});