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-705]): CyberCity JIRA sprint district — sprint tickets as a construction yard

[._.]/ Adam Eivy8ec9861fd1c7
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 8fef8eba82..81532f2c5f 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -50,6 +50,7 @@
- **[issue-705] CyberCity memory district** — your long-term memory now crystallizes into a quiet quarter northwest of downtown: each memory category becomes a cluster of glowing crystals, taller and brighter the more (and more important) the memories it holds, and categories that link to each other arc together with light bridges — so the shape of how your knowledge connects is legible at a glance. A glowing well at the district's heart pulses with your Brain inbox backlog, brightening and beating faster the more captures are waiting to be sorted, and calming once the inbox is clear. The district stays hidden until you've recorded your first memory.
- **[issue-705] CyberCity photo mode** — a new camera button drops the city into a cinematic photo mode: the HUD clears, letterbox bars frame the view, and you can cycle through framing presets (establishing shot, downtown, skyline, overhead, horizon, low angle) with the on-screen arrows or ←/→ keys, each a smooth camera fly. Hit Capture to grab a "city postcard" — your screenshot with a CYBERCITY title and a snapshot of your headline stats (systems online, active agents, linked peers, level, streak) baked along the bottom — then preview it and save it as a PNG. Press Esc to fly back out.
- **[issue-705] CyberCity ambient soundscape** — the city's background music now responds to what's happening in your system (when music is enabled in the city settings). A healthy, quiet system stays calm and bright; as CPU/memory climb or health degrades the music darkens to a tenser chord set with a muffled, anxious tone; and the more agents are actively working, the livelier and busier the lead becomes. A bright chime plays whenever a Chief-of-Staff task completes, so finishing work is something you can hear.
+- **[issue-705] CyberCity JIRA sprint district** — if you've connected JIRA to any of your apps, your current-sprint tickets now build a construction yard in the city: each ticket is a structure that reads its workflow state at a glance — to-do tickets are dim stacked crates waiting to be built, in-progress tickets are under-construction frames with a breathing scaffold, and done tickets are finished, lit buildings. Bigger tickets (more story points) stand taller, tickets are gathered across every JIRA-enabled app and deduped, and the district label shows your sprint progress (done / total). It only appears when you have JIRA wired up.
## Changed
diff --git a/client/src/components/city/CityJiraDistrict.jsx b/client/src/components/city/CityJiraDistrict.jsx
new file mode 100644
index 0000000000..e8210503fd
--- /dev/null
+++ b/client/src/components/city/CityJiraDistrict.jsx
@@ -0,0 +1,115 @@
+import { useMemo, useRef } from 'react';
+import { useFrame } from '@react-three/fiber';
+import { Text } from '@react-three/drei';
+import { PIXEL_FONT_URL } from './cityConstants';
+import { computeJiraDistrict, JIRA_DISTRICT } from '../../utils/cityJiraDistrict';
+
+// CyberCity's JIRA sprint district (roadmap 3.7): the current sprint's tickets become a small
+// construction yard. To-Do tickets are stacked crates (unbuilt), In-Progress tickets are
+// under-construction wireframe frames (scaffold), and Done tickets are finished, lit buildings.
+// Tickets are gathered across every JIRA-enabled app and deduped by key in the pure helper; this
+// component only renders + animates. Mirrors CityTaskQueue / CityGoalMonuments.
+
+// One ticket structure. The mesh form is chosen by workflow state so the yard reads as work
+// progressing from crates → scaffolds → finished buildings.
+function SprintStructure({ structure, pulseRef, isPulse }) {
+ const { position, color, height, state } = structure;
+ const size = JIRA_DISTRICT.crateSize;
+
+ if (state === 'done') {
+ // Finished building — solid, emissive, the in-progress pulse never lands here.
+ return (
+ <group position={position}>
+ <mesh position={[0, height / 2, 0]}>
+ <boxGeometry args={[size, height, size]} />
+ <meshStandardMaterial color="#0d1a12" emissive={color} emissiveIntensity={0.7} metalness={0.6} roughness={0.4} toneMapped={false} />
+ </mesh>
+ </group>
+ );
+ }
+
+ if (state === 'inProgress') {
+ // Under construction — a built lower portion topped by a translucent scaffold cage that
+ // breathes (the pulse target). Reads as "actively being worked".
+ const builtH = Math.max(0.4, height * 0.45);
+ const scaffoldH = Math.max(0.3, height - builtH);
+ return (
+ <group position={position}>
+ <mesh position={[0, builtH / 2, 0]}>
+ <boxGeometry args={[size, builtH, size]} />
+ <meshStandardMaterial color="#1a1206" emissive={color} emissiveIntensity={0.5} metalness={0.4} roughness={0.6} toneMapped={false} />
+ </mesh>
+ <mesh ref={isPulse ? pulseRef : undefined} position={[0, builtH + scaffoldH / 2, 0]}>
+ <boxGeometry args={[size * 1.05, scaffoldH, size * 1.05]} />
+ <meshStandardMaterial color={color} emissive={color} emissiveIntensity={0.5} wireframe transparent opacity={0.7} toneMapped={false} />
+ </mesh>
+ </group>
+ );
+ }
+
+ // To-Do — a stack of dim crates waiting to be built.
+ const crateH = size * 0.7;
+ const crates = Math.max(1, Math.round(height / crateH));
+ return (
+ <group position={position}>
+ {Array.from({ length: crates }, (_, i) => (
+ <mesh key={i} position={[0, crateH * (i + 0.5), 0]}>
+ <boxGeometry args={[size * 0.9, crateH * 0.9, size * 0.9]} />
+ <meshStandardMaterial color="#161a22" emissive={color} emissiveIntensity={0.18} metalness={0.5} roughness={0.7} />
+ </mesh>
+ ))}
+ </group>
+ );
+}
+
+export default function CityJiraDistrict({ jiraTickets, settings }) {
+ const district = useMemo(() => computeJiraDistrict(jiraTickets), [jiraTickets]);
+ const pulseRef = useRef();
+
+ const animate = (settings?.particleDensity ?? 1) >= 0.5;
+
+ // The first in-progress structure carries a breathing scaffold glow (one ref mutation/frame).
+ const pulseKey = useMemo(
+ () => district.structures.find(s => s.state === 'inProgress')?.key ?? null,
+ [district.structures]
+ );
+
+ useFrame(({ clock }) => {
+ if (!pulseRef.current) return;
+ if (!animate) { pulseRef.current.material.emissiveIntensity = 0.5; return; }
+ const pulse = (Math.sin(clock.getElapsedTime() * 2.2) + 1) / 2;
+ pulseRef.current.material.emissiveIntensity = 0.4 + pulse * 0.5;
+ });
+
+ if (district.empty) return null;
+
+ const { base, structures, counts, total, overflow, overflowPosition } = district;
+
+ return (
+ <group>
+ {structures.map((structure) => (
+ <SprintStructure
+ key={structure.key}
+ structure={structure}
+ pulseRef={pulseRef}
+ isPulse={structure.key === pulseKey}
+ />
+ ))}
+
+ {/* Overflow marker — tickets past the render cap */}
+ {overflow > 0 && overflowPosition && (
+ <Text position={[overflowPosition[0], 1.4, overflowPosition[2]]} fontSize={0.5} color="#94a3b8" anchorX="center" anchorY="middle" font={PIXEL_FONT_URL} maxWidth={9}>
+ {`+${overflow} MORE`}
+ </Text>
+ )}
+
+ {/* District title + sprint progress */}
+ <Text position={[base[0], 12, base[2] - 2]} fontSize={1.2} color="#3b82f6" anchorX="center" anchorY="middle" font={PIXEL_FONT_URL} maxWidth={30}>
+ SPRINT
+ </Text>
+ <Text position={[base[0], 11.1, base[2] - 2]} fontSize={0.72} color="#94a3b8" anchorX="center" anchorY="middle" font={PIXEL_FONT_URL} maxWidth={30}>
+ {`${counts.done}/${total} DONE · ${counts.inProgress} IN PROGRESS`}
+ </Text>
+ </group>
+ );
+}
diff --git a/client/src/components/city/CityScene.jsx b/client/src/components/city/CityScene.jsx
index 11a1e6271a..6c06f0b792 100644
--- a/client/src/components/city/CityScene.jsx
+++ b/client/src/components/city/CityScene.jsx
@@ -27,6 +27,7 @@ import CitySeasonalDecor from './CitySeasonalDecor';
import CityEasterEggs from './CityEasterEggs';
import CityVoiceMarker from './CityVoiceMarker';
import CityMemoryDistrict from './CityMemoryDistrict';
+import CityJiraDistrict from './CityJiraDistrict';
import CityAiCore from './CityAiCore';
import CityDataRain from './CityDataRain';
import CityNeonSigns from './CityNeonSigns';
@@ -40,7 +41,7 @@ import PlayerController from './PlayerController';
import CameraTransition from './CameraTransition';
import CityPhotoCamera from './CityPhotoCamera';
-export default function CityScene({ apps, agentMap, onBuildingClick, cosStatus, reviewCounts, instances, backupStatus, cosTasks, healthMetrics, voiceState, aiActivity, productivityData, activityCalendar, goals, character, chronotype, memoryGraph, inboxDepth, photoMode, photoPresetId, onPhotoCaptureReady, settings, playSfx, keysRef, dimmedAppIds }) {
+export default function CityScene({ apps, agentMap, onBuildingClick, cosStatus, reviewCounts, instances, backupStatus, cosTasks, healthMetrics, voiceState, aiActivity, productivityData, activityCalendar, goals, character, chronotype, memoryGraph, inboxDepth, jiraTickets, photoMode, photoPresetId, onPhotoCaptureReady, settings, playSfx, keysRef, dimmedAppIds }) {
const [positions, setPositions] = useState(null);
const [proximityApp, setProximityApp] = useState(null);
const [transitioning, setTransitioning] = useState(false);
@@ -106,6 +107,7 @@ export default function CityScene({ apps, agentMap, onBuildingClick, cosStatus,
<CityEasterEggs character={character} goals={goals} productivityData={productivityData} settings={settings} />
<CityVoiceMarker voiceState={voiceState} settings={settings} />
<CityMemoryDistrict memoryGraph={memoryGraph} inboxDepth={inboxDepth} settings={settings} />
+ <CityJiraDistrict jiraTickets={jiraTickets} settings={settings} />
<CityAiCore aiActivity={aiActivity} positions={positions} apps={apps} settings={settings} />
<CityGround settings={settings} />
diff --git a/client/src/pages/CyberCity.jsx b/client/src/pages/CyberCity.jsx
index 0da8ea893d..c5d4c45726 100644
--- a/client/src/pages/CyberCity.jsx
+++ b/client/src/pages/CyberCity.jsx
@@ -171,6 +171,34 @@ function CyberCityInner() {
60_000,
);
+ // JIRA sprint district: the set of apps with JIRA wired up (each carries instanceId+projectKey),
+ // collapsed to a stable signature that gates and re-triggers the poll only when that set changes.
+ const jiraAppsKey = useMemo(
+ () => (apps || [])
+ .filter(a => a?.jira?.enabled && a.jira.instanceId && a.jira.projectKey)
+ .map(a => `${a.jira.instanceId}/${a.jira.projectKey}`)
+ .sort().join(','),
+ [apps]
+ );
+ // Fetch each enabled app's current-sprint tickets and merge; the helper dedupes by key. Skip
+ // the poll entirely when no app has JIRA configured. Keyed on `jiraAppsKey` so the closure (and
+ // poll) refresh when JIRA apps appear/disappear.
+ const fetchSprintTickets = useCallback(async () => {
+ const specs = (apps || [])
+ .filter(a => a?.jira?.enabled && a.jira.instanceId && a.jira.projectKey)
+ .map(a => ({ instanceId: a.jira.instanceId, projectKey: a.jira.projectKey }));
+ if (specs.length === 0) return [];
+ const batches = await Promise.all(
+ specs.map(j => api.getMySprintTickets(j.instanceId, j.projectKey, { silent: true }).catch(() => []))
+ );
+ return batches.flat();
+ }, [apps]);
+ const { data: jiraTickets } = useAutoRefetch(
+ fetchSprintTickets,
+ 120_000,
+ { enabled: jiraAppsKey.length > 0 },
+ );
+
const handleBuildingClick = useCallback((app) => {
if (app?.id) {
navigate(`/apps/${app.id}`);
@@ -235,6 +263,7 @@ function CyberCityInner() {
chronotype={chronotypeData}
memoryGraph={memoryGraph}
inboxDepth={inboxData?.counts?.needs_review ?? 0}
+ jiraTickets={jiraTickets}
photoMode={photoMode}
photoPresetId={photoPresetId}
onPhotoCaptureReady={handlePhotoCaptureReady}
diff --git a/client/src/services/apiSystem.js b/client/src/services/apiSystem.js
index 23cc0df9d5..96e5816e14 100644
--- a/client/src/services/apiSystem.js
+++ b/client/src/services/apiSystem.js
@@ -227,7 +227,7 @@ export const searchDatadogErrors = (instanceId, serviceName, environment, fromTi
// JIRA
export const getJiraInstances = () => request('/jira/instances');
export const getJiraProjects = (instanceId) => request(`/jira/instances/${instanceId}/projects`);
-export const getMySprintTickets = (instanceId, projectKey) => request(`/jira/instances/${instanceId}/my-sprint-tickets/${projectKey}`);
+export const getMySprintTickets = (instanceId, projectKey, options) => request(`/jira/instances/${instanceId}/my-sprint-tickets/${projectKey}`, options);
export const getJiraTicketTransitions = (instanceId, ticketId, options) => request(`/jira/instances/${instanceId}/tickets/${ticketId}/transitions`, options);
export const transitionJiraTicket = (instanceId, ticketId, transitionId, options) => request(`/jira/instances/${instanceId}/tickets/${ticketId}/transition`, {
method: 'POST',
diff --git a/client/src/utils/cityJiraDistrict.js b/client/src/utils/cityJiraDistrict.js
new file mode 100644
index 0000000000..b442be911c
--- /dev/null
+++ b/client/src/utils/cityJiraDistrict.js
@@ -0,0 +1,113 @@
+// Pure, deterministic helpers for CyberCity's JIRA sprint district (roadmap 3.7): the current
+// sprint's tickets become a small construction yard southeast-north of downtown. Each ticket is
+// a structure whose form reads its workflow state — To-Do tickets are stacked crates waiting to
+// be built, In-Progress tickets are under-construction frames (scaffold), and Done tickets are
+// finished, lit buildings. Tickets are gathered across every JIRA-enabled app, deduped by key.
+// No three.js / React imports so the topology is unit-testable (mirrors cityTaskQueue.js etc.).
+
+export const JIRA_DISTRICT = {
+ // North-east-of-north: a yard between the goal monuments (NE, +30,-40) and downtown, on the
+ // -X side so it doesn't collide with the artifact hall (+44,-28) or memory district (-44,-30).
+ base: [-20, 0, -44],
+ columns: 6, // structures per row before wrapping toward -Z
+ spacing: 3.2, // distance between adjacent structures
+ maxStructures: 24, // cap; overflow folds into a "+N MORE" marker
+ crateSize: 1.1,
+ maxHeight: 4.5,
+};
+
+// JIRA's three status categories. We normalize the API's statusCategory name to one of these
+// buckets; an unrecognized/blank category is treated as 'todo' (safest — it shows as unbuilt).
+export const SPRINT_STATES = {
+ todo: { key: 'todo', label: 'TO DO', color: '#64748b' }, // slate — not started
+ inProgress: { key: 'inProgress', label: 'IN PROGRESS', color: '#f59e0b' }, // amber — building
+ done: { key: 'done', label: 'DONE', color: '#22c55e' }, // green — complete
+};
+
+// Map a ticket's JIRA statusCategory to one of our three buckets. JIRA uses the category names
+// "To Do" / "In Progress" / "Done" (and the key forms new/indeterminate/done); accept both.
+export function ticketState(ticket) {
+ const raw = String(ticket?.statusCategory || '').toLowerCase().trim();
+ if (raw === 'done' || raw === 'complete') return 'done';
+ if (raw === 'in progress' || raw === 'indeterminate') return 'inProgress';
+ return 'todo'; // "to do" / "new" / unknown / blank
+}
+
+// Story-point-driven height so a chunky ticket reads as a taller structure; defaults to a 1-point
+// floor when the ticket carries no estimate so every ticket is at least a visible crate.
+export function structureHeight(storyPoints) {
+ const pts = Number.isFinite(storyPoints) && storyPoints > 0 ? storyPoints : 1;
+ return Math.min(JIRA_DISTRICT.maxHeight, 0.9 + Math.log2(1 + pts) * 1.1);
+}
+
+// Dedupe tickets across apps by key (the same JIRA ticket can surface under two apps that share a
+// project) and sort into a stable render order: done → in-progress → to-do, then by key, so the
+// yard reads left-to-right as "finished work piling up" with active work in the middle.
+const STATE_ORDER = { done: 0, inProgress: 1, todo: 2 };
+export function dedupeAndSort(tickets) {
+ const byKey = new Map();
+ for (const t of Array.isArray(tickets) ? tickets : []) {
+ if (!t?.key || byKey.has(t.key)) continue;
+ byKey.set(t.key, t);
+ }
+ return [...byKey.values()].sort((a, b) => {
+ const sa = STATE_ORDER[ticketState(a)] ?? 3;
+ const sb = STATE_ORDER[ticketState(b)] ?? 3;
+ return sa - sb || String(a.key).localeCompare(String(b.key));
+ });
+}
+
+// Grid position for the i-th structure in the yard: rows wrap toward -Z, centered on the base X.
+export function structurePosition(index, opts = {}) {
+ const base = opts.base || JIRA_DISTRICT.base;
+ const columns = opts.columns ?? JIRA_DISTRICT.columns;
+ const spacing = opts.spacing ?? JIRA_DISTRICT.spacing;
+ const col = index % columns;
+ const row = Math.floor(index / columns);
+ const offsetX = ((columns - 1) * spacing) / 2;
+ return [base[0] + col * spacing - offsetX, base[1], base[2] - row * spacing];
+}
+
+// Tally tickets by bucket — drives the district label ("3/8 DONE") and per-state counts.
+export function tallyStates(tickets) {
+ const counts = { todo: 0, inProgress: 0, done: 0 };
+ for (const t of Array.isArray(tickets) ? tickets : []) counts[ticketState(t)] += 1;
+ return counts;
+}
+
+// Full derived view-model for the component: positioned structures (capped, overflow summarized)
+// + per-state tallies. `tickets` is the merged sprint-ticket list across all JIRA-enabled apps.
+// Pure + deterministic — same tickets in, same yard out — so the whole thing is headless-testable.
+export function computeJiraDistrict(tickets, opts = {}) {
+ const sorted = dedupeAndSort(tickets);
+ const counts = tallyStates(sorted);
+ const total = sorted.length;
+ const maxStructures = opts.maxStructures ?? JIRA_DISTRICT.maxStructures;
+
+ const shown = sorted.slice(0, maxStructures);
+ const structures = shown.map((t, i) => {
+ const state = ticketState(t);
+ return {
+ key: t.key,
+ summary: t.summary || t.key,
+ state,
+ color: SPRINT_STATES[state].color,
+ height: structureHeight(t.storyPoints),
+ position: structurePosition(i, opts),
+ url: t.url || null,
+ };
+ });
+
+ const overflow = total > maxStructures ? total - maxStructures : 0;
+
+ return {
+ base: opts.base || JIRA_DISTRICT.base,
+ structures,
+ counts,
+ total,
+ overflow,
+ // Overflow marker sits just past the last rendered structure.
+ overflowPosition: overflow > 0 ? structurePosition(maxStructures, opts) : null,
+ empty: total === 0,
+ };
+}
diff --git a/client/src/utils/cityJiraDistrict.test.js b/client/src/utils/cityJiraDistrict.test.js
new file mode 100644
index 0000000000..9efdc8d8d1
--- /dev/null
+++ b/client/src/utils/cityJiraDistrict.test.js
@@ -0,0 +1,132 @@
+import { describe, it, expect } from 'vitest';
+import {
+ JIRA_DISTRICT,
+ SPRINT_STATES,
+ ticketState,
+ structureHeight,
+ dedupeAndSort,
+ structurePosition,
+ tallyStates,
+ computeJiraDistrict,
+} from './cityJiraDistrict';
+
+describe('ticketState', () => {
+ it('maps JIRA category names', () => {
+ expect(ticketState({ statusCategory: 'Done' })).toBe('done');
+ expect(ticketState({ statusCategory: 'In Progress' })).toBe('inProgress');
+ expect(ticketState({ statusCategory: 'To Do' })).toBe('todo');
+ });
+ it('maps JIRA category key forms', () => {
+ expect(ticketState({ statusCategory: 'indeterminate' })).toBe('inProgress');
+ expect(ticketState({ statusCategory: 'new' })).toBe('todo');
+ });
+ it('defaults unknown/blank to todo', () => {
+ expect(ticketState({ statusCategory: '' })).toBe('todo');
+ expect(ticketState({})).toBe('todo');
+ expect(ticketState(null)).toBe('todo');
+ });
+});
+
+describe('structureHeight', () => {
+ it('floors a point-less ticket to a visible crate', () => {
+ expect(structureHeight(undefined)).toBeGreaterThan(0.5);
+ expect(structureHeight(0)).toBe(structureHeight(undefined));
+ });
+ it('grows with story points and clamps', () => {
+ expect(structureHeight(8)).toBeGreaterThan(structureHeight(2));
+ expect(structureHeight(1000)).toBeLessThanOrEqual(JIRA_DISTRICT.maxHeight);
+ });
+});
+
+describe('dedupeAndSort', () => {
+ it('dedupes by key (first wins)', () => {
+ const out = dedupeAndSort([
+ { key: 'A-1', statusCategory: 'To Do' },
+ { key: 'A-1', statusCategory: 'Done' },
+ ]);
+ expect(out).toHaveLength(1);
+ expect(ticketState(out[0])).toBe('todo'); // first occurrence kept
+ });
+ it('orders done → in-progress → to-do, then by key', () => {
+ const out = dedupeAndSort([
+ { key: 'A-3', statusCategory: 'To Do' },
+ { key: 'A-2', statusCategory: 'Done' },
+ { key: 'A-1', statusCategory: 'In Progress' },
+ ]);
+ expect(out.map(t => t.key)).toEqual(['A-2', 'A-1', 'A-3']);
+ });
+ it('handles non-array input', () => {
+ expect(dedupeAndSort(undefined)).toEqual([]);
+ });
+});
+
+describe('structurePosition', () => {
+ it('wraps rows toward -Z at the column count', () => {
+ const p0 = structurePosition(0);
+ const pWrap = structurePosition(JIRA_DISTRICT.columns);
+ expect(pWrap[2]).toBeLessThan(p0[2]); // next row is further -Z
+ expect(pWrap[0]).toBeCloseTo(p0[0], 5); // back to the first column's X
+ });
+ it('centers the row on base X', () => {
+ const cols = JIRA_DISTRICT.columns;
+ const xs = Array.from({ length: cols }, (_, i) => structurePosition(i)[0]);
+ const mean = xs.reduce((a, b) => a + b, 0) / xs.length;
+ expect(mean).toBeCloseTo(JIRA_DISTRICT.base[0], 5);
+ });
+});
+
+describe('tallyStates', () => {
+ it('counts each bucket', () => {
+ const counts = tallyStates([
+ { statusCategory: 'Done' },
+ { statusCategory: 'Done' },
+ { statusCategory: 'In Progress' },
+ { statusCategory: 'To Do' },
+ ]);
+ expect(counts).toEqual({ todo: 1, inProgress: 1, done: 2 });
+ });
+});
+
+describe('SPRINT_STATES', () => {
+ it('has a color + label for each bucket', () => {
+ for (const k of ['todo', 'inProgress', 'done']) {
+ expect(SPRINT_STATES[k].color).toMatch(/^#/);
+ expect(typeof SPRINT_STATES[k].label).toBe('string');
+ }
+ });
+});
+
+describe('computeJiraDistrict', () => {
+ it('is empty with no tickets', () => {
+ const d = computeJiraDistrict([]);
+ expect(d.empty).toBe(true);
+ expect(d.structures).toEqual([]);
+ expect(d.total).toBe(0);
+ });
+ it('handles undefined input', () => {
+ expect(computeJiraDistrict(undefined).empty).toBe(true);
+ });
+ it('builds positioned, colored structures with counts', () => {
+ const d = computeJiraDistrict([
+ { key: 'P-1', summary: 'Build login', statusCategory: 'In Progress', storyPoints: 3, url: 'http://x/P-1' },
+ { key: 'P-2', summary: 'Ship it', statusCategory: 'Done' },
+ ]);
+ expect(d.total).toBe(2);
+ expect(d.counts.done).toBe(1);
+ expect(d.structures[0].state).toBe('done'); // done sorts first
+ expect(d.structures[0].position).toHaveLength(3);
+ expect(d.structures.find(s => s.key === 'P-1').color).toBe(SPRINT_STATES.inProgress.color);
+ });
+ it('folds the tail into an overflow count', () => {
+ const tickets = [];
+ for (let i = 0; i < 30; i++) tickets.push({ key: `P-${i}`, statusCategory: 'To Do' });
+ const d = computeJiraDistrict(tickets, { maxStructures: 10 });
+ expect(d.structures).toHaveLength(10);
+ expect(d.overflow).toBe(20);
+ expect(d.overflowPosition).toHaveLength(3);
+ });
+ it('falls back summary to key', () => {
+ const d = computeJiraDistrict([{ key: 'P-9', statusCategory: 'To Do' }]);
+ expect(d.structures[0].summary).toBe('P-9');
+ });
+});