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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
feat(jira): show full workflow lifecycle on the per-app Kanban board
Adam Eivy9ea1e4ab08dc
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 9d90a48ff4..e8d30cd9d2 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -1,5 +1,9 @@# Unreleased+## Apps++- **The per-app Jira Kanban board now shows your full workflow lifecycle, not just To Do / In Progress / Done.** The board used to collapse every ticket into Jira's three built-in *status categories*, so distinct workflow stages like **Blocked** and **In Review** (both "In Progress" to Jira) were invisible — they all piled into one column. The board now resolves the project's real workflow stages and renders one column per stage. When the app's Jira config has a `boardId`, PortOS reads that agile board's actual column layout from Jira (`/rest/agile/1.0/board/{id}/configuration`), so the columns and their order mirror exactly what you see on the board in Jira — including custom stages. Without a board id it falls back to the project's distinct statuses ordered by category, and if neither can be read it falls back to the original three-category board. Columns are color-cued (Blocked → red, Review/QA → purple, otherwise by category), and drag-to-transition now targets the exact status of the column you drop into (any ticket whose status maps to no column gets its own column so nothing disappears). The board now also spans the **full width** of the app Overview tab (the surrounding details stay capped for readability) so all lifecycle columns are visible across the desktop instead of being clipped at ~1024px, falling back to horizontal scroll only when there are more stages than fit. (`server/services/jira.js`, `server/routes/jira.js`, `client/src/components/KanbanBoard.jsx`, `client/src/components/apps/tabs/OverviewTab.jsx`)+## Chief of Staff- **The CoS → Schedule page is now a scannable card grid instead of a flat expandable list.** Each task type renders as a status card you can read at a glance — a colored status dot (active / on-demand / waiting-on-deps / disabled), a **next-run countdown** ("in 3h", "Mon 9:00") that was previously computed server-side but never shown, an app-coverage bar with the enabled/total count kept front-and-center, and last-run/run-count. Cards sort by status then soonest next run (so what's about to run rises to the top), the All/Enabled toggle is replaced by per-status filters (Active / On-Demand / Waiting / Disabled), and a name filter box jumps to a task quickly. A **Run** button sits on each card — for app-targeting tasks it opens an app picker so the on-demand run carries app context (just like the old per-task controls), and falls back to a plain global run for tasks with no managed apps; **Configure** opens a slide-over drawer with the full per-task settings (interval, provider/model, prompt, agent options, dependencies, pipeline stages, and per-app overrides) — the same controls as before, now in a focused panel that's deep-linkable via `?task=` and closes on Esc/backdrop. Mobile collapses the grid to a single column.diff --git a/client/src/components/KanbanBoard.jsx b/client/src/components/KanbanBoard.jsxindex 0cde09f666..ef6748d2ad 100644--- a/client/src/components/KanbanBoard.jsx+++ b/client/src/components/KanbanBoard.jsx@@ -1,17 +1,71 @@-import { useState, useEffect, useCallback } from 'react';+import { useState, useEffect, useCallback, useMemo } from 'react';import { DndContext, DragOverlay, useDraggable, useDroppable, PointerSensor, useSensor, useSensors } from '@dnd-kit/core';import { GripVertical, Play } from 'lucide-react';import toast from './ui/Toast';import * as api from '../services/api';-const COLUMNS = ['To Do', 'In Progress', 'Done'];+// Built-in fallback board: the three Jira status categories. Used when no+// board columns could be resolved (no boardId / project, or the fetch failed).+// Empty `statuses` means "match by statusCategory" — see bucketTickets().+const FALLBACK_COLUMNS = [+ { name: 'To Do', category: 'To Do', statuses: [] },+ { name: 'In Progress', category: 'In Progress', statuses: [] },+ { name: 'Done', category: 'Done', statuses: [] }+];-const COLUMN_CONFIG = {+const CATEGORY_CONFIG = {'To Do': { bg: 'bg-gray-500/10', border: 'border-gray-500/30', dot: 'bg-gray-500', dropBorder: 'border-gray-400' },'In Progress': { bg: 'bg-port-accent/10', border: 'border-port-accent/30', dot: 'bg-port-accent', dropBorder: 'border-port-accent' },'Done': { bg: 'bg-port-success/10', border: 'border-port-success/30', dot: 'bg-port-success', dropBorder: 'border-port-success' }};+// Name-based accents so common lifecycle stages read at a glance regardless of+// which statusCategory Jira buckets them under (Blocked/In Review are both+// "In Progress" to Jira). First match wins; otherwise fall back to category.+const NAME_CONFIG = [+ { test: /block|impede/i, config: { bg: 'bg-port-error/10', border: 'border-port-error/30', dot: 'bg-port-error', dropBorder: 'border-port-error' } },+ { test: /review|qa|verify|test/i, config: { bg: 'bg-purple-500/10', border: 'border-purple-500/30', dot: 'bg-purple-500', dropBorder: 'border-purple-400' } }+];++function columnConfig(column) {+ const named = NAME_CONFIG.find(n => n.test.test(column.name));+ if (named) return named.config;+ return CATEGORY_CONFIG[column.category] || CATEGORY_CONFIG['In Progress'];+}++// Match a ticket to a column: by explicit status name when the column lists+// statuses, otherwise by statusCategory (the fallback three-category board).+function ticketInColumn(ticket, column) {+ return column.statuses.length+ ? column.statuses.includes(ticket.status)+ : ticket.statusCategory === column.category;+}++// Bucket tickets into the resolved columns. Any ticket whose status maps to no+// column (workflow drift, board misconfiguration) gets its own appended column+// so nothing silently disappears from the board. Each column carries its+// precomputed color `config` so render doesn't re-test the NAME_CONFIG regexes.+function bucketTickets(columns, tickets) {+ const result = columns.map(c => ({ ...c, config: columnConfig(c), tickets: [] }));+ const extra = new Map();+ for (const ticket of tickets) {+ const col = result.find(c => ticketInColumn(ticket, c));+ if (col) {+ col.tickets.push(ticket);+ continue;+ }+ const name = ticket.status || 'Unknown';+ let orphan = extra.get(name);+ if (!orphan) {+ orphan = { name, category: ticket.statusCategory || 'In Progress', statuses: [ticket.status].filter(Boolean), tickets: [] };+ orphan.config = columnConfig(orphan);+ extra.set(name, orphan);+ }+ orphan.tickets.push(ticket);+ }+ return [...result, ...extra.values()];+}+function TicketCard({ ticket, isDragOverlay }) {return (<div className={`p-2 bg-port-card border border-port-border rounded-lg transition-colors ${isDragOverlay ? 'shadow-lg shadow-black/50 border-port-accent/50 rotate-2' : ''}`}>@@ -102,32 +156,32 @@ function DraggableTicket({ ticket, disabled, appId, canQueue }) {);}-function DroppableColumn({ category, tickets, isOver, disabled, appId }) {- const { setNodeRef } = useDroppable({ id: category, disabled });- const config = COLUMN_CONFIG[category];- const totalPoints = tickets.reduce((sum, t) => sum + (Number(t.storyPoints) || 0), 0);+function DroppableColumn({ column, isOver, disabled, appId }) {+ const { setNodeRef } = useDroppable({ id: column.name, disabled });+ const config = column.config;+ const totalPoints = column.tickets.reduce((sum, t) => sum + (Number(t.storyPoints) || 0), 0);// The play button (queue a CoS agent for a ticket) only makes sense for// not-started work, and only when we know which app the board belongs to.- const canQueue = category === 'To Do' && !!appId;+ const canQueue = column.category === 'To Do' && !!appId;return (<divref={setNodeRef}- className={`${config.bg} border ${isOver ? `${config.dropBorder} border-dashed` : config.border} rounded-lg p-3 min-h-[120px] transition-colors`}+ className={`flex-1 min-w-[220px] ${config.bg} border ${isOver ? `${config.dropBorder} border-dashed` : config.border} rounded-lg p-3 min-h-[120px] transition-colors`}><div className="flex items-center gap-2 mb-3"><span className={`w-2 h-2 rounded-full ${config.dot}`} />- <span className="text-sm font-medium text-white">{category}</span>- <span className="text-xs text-gray-500">({tickets.length})</span>+ <span className="text-sm font-medium text-white truncate" title={column.name}>{column.name}</span>+ <span className="text-xs text-gray-500">({column.tickets.length})</span>{totalPoints > 0 && (<span className="text-xs text-cyan-400">{totalPoints}pt</span>)}</div><div className="space-y-2">- {tickets.map(ticket => (+ {column.tickets.map(ticket => (<DraggableTicket key={ticket.key} ticket={ticket} disabled={disabled} appId={appId} canQueue={canQueue} />))}- {tickets.length === 0 && (+ {column.tickets.length === 0 && (<div className={`text-xs text-center py-4 ${isOver ? 'text-gray-300' : 'text-gray-500'}`}>{isOver ? 'Drop here' : 'No tickets'}</div>@@ -137,23 +191,36 @@ function DroppableColumn({ category, tickets, isOver, disabled, appId }) {);}-export default function KanbanBoard({ tickets: initialTickets = [], instanceId, onTicketsChange, appId }) {+export default function KanbanBoard({ tickets: initialTickets = [], instanceId, onTicketsChange, appId, projectKey, boardId }) {const [tickets, setTickets] = useState(initialTickets);const [activeTicket, setActiveTicket] = useState(null);const [transitioning, setTransitioning] = useState(null);const [overColumn, setOverColumn] = useState(null);+ const [boardColumns, setBoardColumns] = useState(null);// Sync if parent re-fetchesuseEffect(() => { setTickets(initialTickets); }, [initialTickets]);+ // Resolve the full workflow lifecycle (Blocked, In Review, custom stages) for+ // this project's board. Silent — on failure we keep the three-category+ // fallback rather than surfacing a toast for a non-critical enhancement.+ useEffect(() => {+ if (!instanceId || !projectKey) {+ setBoardColumns(null);+ return;+ }+ let cancelled = false;+ api.getJiraBoardColumns(instanceId, projectKey, boardId, { silent: true })+ .then(res => { if (!cancelled) setBoardColumns(res?.columns?.length ? res.columns : null); })+ .catch(() => { if (!cancelled) setBoardColumns(null); });+ return () => { cancelled = true; };+ }, [instanceId, projectKey, boardId]);+const sensors = useSensors(useSensor(PointerSensor, { activationConstraint: { distance: 8 } }));- const columns = {};- for (const col of COLUMNS) {- columns[col] = tickets.filter(t => t.statusCategory === col);- }+ const columns = useMemo(() => bucketTickets(boardColumns || FALLBACK_COLUMNS, tickets), [boardColumns, tickets]);const handleDragStart = useCallback((event) => {const ticket = event.active.data.current?.ticket;@@ -162,53 +229,64 @@ export default function KanbanBoard({ tickets: initialTickets = [], instanceId,const handleDragOver = useCallback((event) => {const { over } = event;- setOverColumn(over?.id && COLUMNS.includes(over.id) ? over.id : null);- }, []);+ setOverColumn(over?.id && columns.some(c => c.name === over.id) ? over.id : null);+ }, [columns]);const handleDragEnd = useCallback(async (event) => {const { active, over } = event;setActiveTicket(null);setOverColumn(null);- if (!over || !COLUMNS.includes(over.id)) return;+ if (!over) return;++ const targetColumn = columns.find(c => c.name === over.id);+ if (!targetColumn) return;const ticket = active.data.current?.ticket;if (!ticket) return;- const targetCategory = over.id;- if (ticket.statusCategory === targetCategory) return;+ // Already in this column? Nothing to do.+ if (ticketInColumn(ticket, targetColumn)) return;if (!instanceId) {toast.error('Cannot transition: no JIRA instance configured');return;}- // Optimistic update — notify parent immediately so cache stays in sync+ // Optimistic update — notify parent immediately so cache stays in sync.+ // We know the target category now; the exact status name is corrected once+ // the matching transition is resolved below.const previousTickets = [...tickets];const optimistic = tickets.map(t =>- t.key === ticket.key ? { ...t, statusCategory: targetCategory } : t+ t.key === ticket.key+ ? { ...t, statusCategory: targetColumn.category, status: targetColumn.statuses[0] || t.status }+ : t);setTickets(optimistic);onTicketsChange?.(optimistic);setTransitioning(ticket.key);try {- // Fetch available transitions and find matching one+ // Fetch available transitions and find one that lands in the target column.const transitions = await api.getJiraTicketTransitions(instanceId, ticket.key, { silent: true });- const match = transitions.find(t => t.toCategory === targetCategory);+ const match = transitions.find(t =>+ targetColumn.statuses.length+ ? targetColumn.statuses.includes(t.to)+ : t.toCategory === targetColumn.category+ );if (!match) {// Rollback — sync parent cachesetTickets(previousTickets);onTicketsChange?.(previousTickets);- toast.error(`No transition available to "${targetCategory}" for ${ticket.key}`);+ toast.error(`No transition available to "${targetColumn.name}" for ${ticket.key}`);return;}await api.transitionJiraTicket(instanceId, ticket.key, match.id, { silent: true });- // Update the status name too, derived from the optimistic snapshot+ // Update the status name + category from the resolved transition.const nextTickets = optimistic.map(t =>- t.key === ticket.key ? { ...t, status: match.to, statusCategory: targetCategory } : t+ t.key === ticket.key ? { ...t, status: match.to, statusCategory: match.toCategory } : t);setTickets(nextTickets);onTicketsChange?.(nextTickets);@@ -220,7 +298,7 @@ export default function KanbanBoard({ tickets: initialTickets = [], instanceId,} finally {setTransitioning(null);}- }, [tickets, instanceId, onTicketsChange]);+ }, [columns, tickets, instanceId, onTicketsChange]);const handleDragCancel = useCallback(() => {setActiveTicket(null);@@ -235,13 +313,12 @@ export default function KanbanBoard({ tickets: initialTickets = [], instanceId,onDragEnd={handleDragEnd}onDragCancel={handleDragCancel}>- <div className="grid grid-cols-1 md:grid-cols-3 gap-3">- {COLUMNS.map(category => (+ <div className="flex gap-3 overflow-x-auto pb-2">+ {columns.map(column => (<DroppableColumn- key={category}- category={category}- tickets={columns[category]}- isOver={overColumn === category}+ key={column.name}+ column={column}+ isOver={overColumn === column.name}disabled={!!transitioning}appId={appId}/>diff --git a/client/src/components/apps/tabs/OverviewTab.jsx b/client/src/components/apps/tabs/OverviewTab.jsxindex eb46c40045..08a39c4894 100644--- a/client/src/components/apps/tabs/OverviewTab.jsx+++ b/client/src/components/apps/tabs/OverviewTab.jsx@@ -99,7 +99,9 @@ export default function OverviewTab({ app, onRefresh }) {};return (- <div className="space-y-6 max-w-5xl">+ <div className="space-y-6">+ {/* Readable details/config zone — capped width so key/value pairs stay legible */}+ <div className="space-y-6 max-w-5xl">{/* Details Grid */}<div className="grid grid-cols-1 sm:grid-cols-2 gap-4 sm:gap-6"><div>@@ -238,27 +240,31 @@ export default function OverviewTab({ app, onRefresh }) {<span className="text-xs text-cyan-400">{app.jira.labels.join(', ')}</span>)}</div>+ </div>+ )}+ </div>{/* end readable details/config zone */}- {app.jira.instanceId && app.jira.projectKey && (- <div className="mt-3">- <div className="text-xs text-gray-500 uppercase tracking-wide mb-2">My Sprint Tickets</div>- {loadingTickets ? (- <div className="flex items-center gap-2 px-3 py-2 text-sm text-gray-400">- <BrailleSpinner text="" />- <span>Loading tickets...</span>- </div>- ) : jiraTickets?.length > 0 ? (- <KanbanBoard tickets={jiraTickets} instanceId={app.jira?.instanceId} onTicketsChange={setJiraTickets} appId={app.id} />- ) : (- <div className="px-3 py-2 text-sm text-gray-500 bg-port-card border border-port-border rounded-lg">- No tickets assigned to you in the current sprint- </div>- )}+ {/* My Sprint Tickets — full width so the Kanban lifecycle isn't clipped */}+ {app.jira?.enabled && app.jira.instanceId && app.jira.projectKey && (+ <div>+ <div className="text-xs text-gray-500 uppercase tracking-wide mb-2">My Sprint Tickets</div>+ {loadingTickets ? (+ <div className="flex items-center gap-2 px-3 py-2 text-sm text-gray-400">+ <BrailleSpinner text="" />+ <span>Loading tickets...</span>+ </div>+ ) : jiraTickets?.length > 0 ? (+ <KanbanBoard tickets={jiraTickets} instanceId={app.jira?.instanceId} onTicketsChange={setJiraTickets} appId={app.id} projectKey={app.jira?.projectKey} boardId={app.jira?.boardId} />+ ) : (+ <div className="px-3 py-2 text-sm text-gray-500 bg-port-card border border-port-border rounded-lg max-w-5xl">+ No tickets assigned to you in the current sprint</div>)}</div>)}+ {/* Actions zone — back to capped readable width */}+ <div className="space-y-6 max-w-5xl">{/* Agent Operations */}<SlashDoPanel appId={app.id} appType={app.type} />@@ -329,6 +335,7 @@ export default function OverviewTab({ app, onRefresh }) {{/* Activity Log */}<ActivityLog steps={steps} error={error} completed={completed} />+ </div>{/* end actions zone */}</div>);}diff --git a/client/src/pages/Apps.jsx b/client/src/pages/Apps.jsxindex b2abadddce..b1e6d0a26b 100644--- a/client/src/pages/Apps.jsx+++ b/client/src/pages/Apps.jsx@@ -505,6 +505,9 @@ export default function Apps() {tickets={jiraTickets[app.id]}instanceId={app.jira.instanceId}onTicketsChange={(updated) => setJiraTickets(prev => ({ ...prev, [app.id]: updated }))}+ appId={app.id}+ projectKey={app.jira.projectKey}+ boardId={app.jira.boardId}/>) : (<div className="px-3 py-2 text-sm text-gray-500 bg-port-card border border-port-border rounded-lg">diff --git a/client/src/services/apiSystem.js b/client/src/services/apiSystem.jsindex d3c64cc485..d8d987ebd3 100644--- a/client/src/services/apiSystem.js+++ b/client/src/services/apiSystem.js@@ -243,6 +243,8 @@ export const searchDatadogErrors = (instanceId, serviceName, environment, fromTiexport const getJiraInstances = () => request('/jira/instances');export const getJiraProjects = (instanceId) => request(`/jira/instances/${instanceId}/projects`);export const getMySprintTickets = (instanceId, projectKey, options) => request(`/jira/instances/${instanceId}/my-sprint-tickets/${projectKey}`, options);+export const getJiraBoardColumns = (instanceId, projectKey, boardId, options) =>+ request(`/jira/instances/${instanceId}/board-columns/${projectKey}${boardId ? `?boardId=${encodeURIComponent(boardId)}` : ''}`, 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/server/routes/jira.js b/server/routes/jira.jsindex c7f334206c..b85e710460 100644--- a/server/routes/jira.js+++ b/server/routes/jira.js@@ -228,6 +228,19 @@ router.get('/instances/:instanceId/my-sprint-tickets/:projectKey', asyncHandler(res.json(tickets);}));+/**+ * GET /api/jira/instances/:instanceId/board-columns/:projectKey?boardId=+ * Resolve the ordered workflow columns (full lifecycle) for the Kanban board.+ */+router.get('/instances/:instanceId/board-columns/:projectKey', asyncHandler(async (req, res) => {+ const result = await jiraService.getBoardColumns(+ req.params.instanceId,+ req.params.projectKey,+ req.query.boardId+ );+ res.json(result);+}));+/*** GET /api/jira/instances/:instanceId/boards/:boardId/sprints* Get active sprints for a boarddiff --git a/server/services/jira.js b/server/services/jira.jsindex b26a3d2ee3..b32f71f05b 100644--- a/server/services/jira.js+++ b/server/services/jira.js@@ -376,6 +376,110 @@ export async function getMyCurrentSprintTickets(instanceId, projectKey) {}}+// Canonical lifecycle ordering for the three Jira status categories. Used to+// order the fallback (no-board) column list — board-config columns keep their+// own configured order instead.+const CATEGORY_ORDER = { 'To Do': 0, 'In Progress': 1, 'Done': 2 };++/**+ * Pure: turn an agile board's column config into Kanban columns.+ * @param {Array} boardColumns - `columnConfig.columns` from the board config API+ * (`[{ name, statuses: [{ id }] }]`).+ * @param {Map<string,{name,category}>} statusById - status id → name/category.+ * Returns ordered `[{ name, category, statuses: [statusName] }]`, dropping any+ * column that maps to no known status (e.g. an empty/backlog column).+ */+export function buildColumnsFromBoardConfig(boardColumns, statusById) {+ return (boardColumns || [])+ .map(col => {+ const statuses = (col.statuses || [])+ .map(s => statusById.get(String(s.id)))+ .filter(Boolean);+ return {+ name: col.name,+ category: statuses[0]?.category || 'In Progress',+ statuses: statuses.map(s => s.name)+ };+ })+ .filter(col => col.statuses.length > 0);+}++/**+ * Pure: turn a project's distinct workflow statuses into one column per status,+ * ordered by status category (To Do → In Progress → Done). Used when no board+ * id is available. `statusOrder` preserves discovery order so statuses within a+ * category keep a stable layout (Array.prototype.sort is stable).+ */+export function buildColumnsFromStatuses(statusOrder) {+ return (statusOrder || [])+ .map(s => ({ name: s.name, category: s.category, statuses: [s.name] }))+ .sort((a, b) => (CATEGORY_ORDER[a.category] ?? 1) - (CATEGORY_ORDER[b.category] ?? 1));+}++/**+ * Resolve the ordered workflow columns for a project's board so the Kanban UI+ * can show the full lifecycle (Blocked, In Review, any custom stage) instead of+ * collapsing every status into the three statusCategory buckets.+ *+ * With a boardId we use the agile board's actual column layout — the truest+ * representation of the user's workflow, in board order — mapping each column's+ * status ids to names via the project statuses endpoint. Without a boardId, or+ * if the board config can't be read, we fall back to the project's distinct+ * statuses ordered by category. If even the project statuses can't be read the+ * caller (client) falls back to its built-in three-category board.+ *+ * Returns `{ columns: [{ name, category, statuses: [statusName] }], source }`.+ */+export async function getBoardColumns(instanceId, projectKey, boardId) {+ const config = await getInstances();+ const instance = config.instances[instanceId];++ if (!instance) {+ throw new Error(`JIRA instance ${instanceId} not found`);+ }++ const client = createJiraClient(instance);++ // Project statuses (always) and the board config (only when we have a board)+ // are independent calls — fetch them in parallel to save a round-trip. A+ // board-config failure falls through to project-status columns (null).+ const [statusesRes, boardColumns] = await Promise.all([+ client.get(`/rest/api/2/project/${encodeURIComponent(projectKey)}/statuses`),+ boardId+ ? client+ .get(`/rest/agile/1.0/board/${encodeURIComponent(boardId)}/configuration`)+ .then(res => res.data?.columnConfig?.columns || [])+ .catch(err => {+ console.warn(`⚠️ JIRA board ${boardId} config fetch failed: ${err.message}`);+ return null;+ })+ : Promise.resolve(null)+ ]);++ // status id → { name, category }, plus discovery order for the fallback.+ const statusById = new Map();+ const statusOrder = [];+ for (const issueType of statusesRes.data || []) {+ for (const s of issueType.statuses || []) {+ const id = String(s.id);+ if (!statusById.has(id)) {+ const entry = { name: s.name, category: s.statusCategory?.name || 'To Do' };+ statusById.set(id, entry);+ statusOrder.push(entry);+ }+ }+ }++ if (boardColumns) {+ const columns = buildColumnsFromBoardConfig(boardColumns, statusById);+ if (columns.length > 0) {+ return { columns, source: 'board' };+ }+ }++ return { columns: buildColumnsFromStatuses(statusOrder), source: 'project' };+}+/*** Get active sprints for a JIRA board*/@@ -446,6 +550,9 @@ export default {deleteTicket,transitionTicket,getMyCurrentSprintTickets,+ getBoardColumns,+ buildColumnsFromBoardConfig,+ buildColumnsFromStatuses,getActiveSprints,searchEpics};diff --git a/server/services/jira.test.js b/server/services/jira.test.jsnew file mode 100644index 0000000000..d48dcd291b--- /dev/null+++ b/server/services/jira.test.js@@ -0,0 +1,91 @@+import { describe, it, expect } from 'vitest';+import { buildColumnsFromBoardConfig, buildColumnsFromStatuses } from './jira.js';++describe('buildColumnsFromBoardConfig', () => {+ const statusById = new Map([+ ['1', { name: 'To Do', category: 'To Do' }],+ ['2', { name: 'In Progress', category: 'In Progress' }],+ ['3', { name: 'Blocked', category: 'In Progress' }],+ ['4', { name: 'In Review', category: 'In Progress' }],+ ['5', { name: 'Done', category: 'Done' }]+ ]);++ it('maps board status ids to names and preserves board column order', () => {+ const boardColumns = [+ { name: 'To Do', statuses: [{ id: '1' }] },+ { name: 'In Progress', statuses: [{ id: 2 }] },+ { name: 'Blocked', statuses: [{ id: '3' }] },+ { name: 'In Review', statuses: [{ id: '4' }] },+ { name: 'Done', statuses: [{ id: '5' }] }+ ];+ const result = buildColumnsFromBoardConfig(boardColumns, statusById);+ expect(result.map(c => c.name)).toEqual(['To Do', 'In Progress', 'Blocked', 'In Review', 'Done']);+ expect(result.find(c => c.name === 'Blocked')).toEqual({+ name: 'Blocked',+ category: 'In Progress',+ statuses: ['Blocked']+ });+ });++ it('tolerates numeric and string status ids', () => {+ const result = buildColumnsFromBoardConfig([{ name: 'Go', statuses: [{ id: 2 }, { id: '4' }] }], statusById);+ expect(result[0].statuses).toEqual(['In Progress', 'In Review']);+ });++ it('drops columns that map to no known status (e.g. empty backlog column)', () => {+ const boardColumns = [+ { name: 'Backlog', statuses: [] },+ { name: 'Unknown', statuses: [{ id: '999' }] },+ { name: 'Done', statuses: [{ id: '5' }] }+ ];+ const result = buildColumnsFromBoardConfig(boardColumns, statusById);+ expect(result.map(c => c.name)).toEqual(['Done']);+ });++ it('derives the column category from its first mapped status', () => {+ const result = buildColumnsFromBoardConfig([{ name: 'WIP', statuses: [{ id: '3' }, { id: '5' }] }], statusById);+ expect(result[0].category).toBe('In Progress');+ });++ it('returns [] for empty/missing input', () => {+ expect(buildColumnsFromBoardConfig([], statusById)).toEqual([]);+ expect(buildColumnsFromBoardConfig(undefined, statusById)).toEqual([]);+ });+});++describe('buildColumnsFromStatuses', () => {+ it('produces one single-status column per status, ordered by category', () => {+ const statusOrder = [+ { name: 'In Review', category: 'In Progress' },+ { name: 'Done', category: 'Done' },+ { name: 'To Do', category: 'To Do' },+ { name: 'Blocked', category: 'In Progress' }+ ];+ const result = buildColumnsFromStatuses(statusOrder);+ expect(result.map(c => c.name)).toEqual(['To Do', 'In Review', 'Blocked', 'Done']);+ expect(result[1]).toEqual({ name: 'In Review', category: 'In Progress', statuses: ['In Review'] });+ });++ it('keeps discovery order stable within a category', () => {+ const statusOrder = [+ { name: 'Blocked', category: 'In Progress' },+ { name: 'In Progress', category: 'In Progress' },+ { name: 'In Review', category: 'In Progress' }+ ];+ expect(buildColumnsFromStatuses(statusOrder).map(c => c.name)).toEqual(['Blocked', 'In Progress', 'In Review']);+ });++ it('treats unknown categories as In Progress for ordering', () => {+ const statusOrder = [+ { name: 'Mystery', category: 'Weird' },+ { name: 'To Do', category: 'To Do' },+ { name: 'Done', category: 'Done' }+ ];+ expect(buildColumnsFromStatuses(statusOrder).map(c => c.name)).toEqual(['To Do', 'Mystery', 'Done']);+ });++ it('returns [] for empty/missing input', () => {+ expect(buildColumnsFromStatuses([])).toEqual([]);+ expect(buildColumnsFromStatuses(undefined)).toEqual([]);+ });+});