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
address review (claude): unique column ids + extract kanbanColumns + tests
Adam Eivy80d70656a680
diff --git a/client/src/components/KanbanBoard.jsx b/client/src/components/KanbanBoard.jsxindex ef6748d2ad..0fe0457a5c 100644--- a/client/src/components/KanbanBoard.jsx+++ b/client/src/components/KanbanBoard.jsx@@ -3,68 +3,7 @@ import { DndContext, DragOverlay, useDraggable, useDroppable, PointerSensor, useimport { GripVertical, Play } from 'lucide-react';import toast from './ui/Toast';import * as api from '../services/api';--// 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 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()];-}+import { FALLBACK_COLUMNS, ticketInColumn, bucketTickets } from '../lib/kanbanColumns.js';function TicketCard({ ticket, isDragOverlay }) {return (@@ -157,7 +96,7 @@ function DraggableTicket({ ticket, disabled, appId, canQueue }) {}function DroppableColumn({ column, isOver, disabled, appId }) {- const { setNodeRef } = useDroppable({ id: column.name, disabled });+ const { setNodeRef } = useDroppable({ id: column.id, 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@@ -229,7 +168,7 @@ export default function KanbanBoard({ tickets: initialTickets = [], instanceId,const handleDragOver = useCallback((event) => {const { over } = event;- setOverColumn(over?.id && columns.some(c => c.name === over.id) ? over.id : null);+ setOverColumn(over?.id && columns.some(c => c.id === over.id) ? over.id : null);}, [columns]);const handleDragEnd = useCallback(async (event) => {@@ -239,7 +178,7 @@ export default function KanbanBoard({ tickets: initialTickets = [], instanceId,if (!over) return;- const targetColumn = columns.find(c => c.name === over.id);+ const targetColumn = columns.find(c => c.id === over.id);if (!targetColumn) return;const ticket = active.data.current?.ticket;@@ -316,9 +255,9 @@ export default function KanbanBoard({ tickets: initialTickets = [], instanceId,<div className="flex gap-3 overflow-x-auto pb-2">{columns.map(column => (<DroppableColumn- key={column.name}+ key={column.id}column={column}- isOver={overColumn === column.name}+ isOver={overColumn === column.id}disabled={!!transitioning}appId={appId}/>diff --git a/client/src/lib/README.md b/client/src/lib/README.mdindex 36dcae57bb..9cba899deb 100644--- a/client/src/lib/README.md+++ b/client/src/lib/README.md@@ -80,6 +80,7 @@ grep -i "what you want to do" client/src/lib/README.md| `genUtils.js` | Shared bits between Image Gen and Video Gen pages. || `healthProvenance.js` | `PROVENANCE_LEVELS` / `getProvenanceLevel(level)` — the `data-backed`/`inferred`/`experimental`/`speculative` trust taxonomy (label, tone, description, "what would change this?" copy) behind the `ProvenanceChip` source-style chips on MeatSpace / genome / death-clock / longevity views. Pure data; the chip component maps tone→color and id→icon. || `joinInfluenceList.js` | Mirror of `joinInfluenceList` in server universe builder. |+| `kanbanColumns.js` | `bucketTickets` / `ticketInColumn` / `columnConfig` / `FALLBACK_COLUMNS` — pure column logic for the Jira Kanban board (`components/KanbanBoard.jsx`). Buckets tickets into resolved workflow columns (by status name, or statusCategory for the fallback board), assigns each column a stable unique `id` (Jira `name` is not unique — same-named columns map to different statuses), appends an orphan column for any unmatched status, and precomputes per-column Tailwind color config (Blocked→red, Review/QA→purple, else by category). || `localLlmTargetKey.js` | `localLlmTargetKey({ backend, modelId })` — stable string key for a local-LLM compare target. Shared by the LocalLlmTab checkbox grid and the LocalLlmPlayground compare URL so a delimiter change can't desync the round-trip. || `letteringDensity.js` | `analyzeComicLettering` / `panelLetteringMetrics` / `countWords` / `overflowSeverity` / `DEFAULT_LETTERING_THRESHOLDS` — comic lettering-density accounting over parsed comic pages, powering the comic-script stage's inline over-stuffed-panel warnings (#1313). Byte-for-byte mirror of `server/lib/editorial/letteringDensity.js` (the server `comic.lettering-density` check is authoritative). Pure/DOM-free. || `loopbackHost.js` | `isLoopbackHost(host)` / `isLoopbackOrigin()` / `describeMicAvailability()` — Secure Context / loopback-origin heuristics. Use these in any new mic, clipboard, or `getUserMedia`-gated surface; matches the full `127.0.0.0/8` range, IPv6 `::1`, and the browser-bracketed `[::1]` form. |diff --git a/client/src/lib/index.js b/client/src/lib/index.jsindex a085baf152..e04149d76f 100644--- a/client/src/lib/index.js+++ b/client/src/lib/index.js@@ -52,6 +52,7 @@ export * from './downloadBlob.js';export * from './genUtils.js';export * from './healthProvenance.js';export * from './joinInfluenceList.js';+export * from './kanbanColumns.js';export * from './localLlmTargetKey.js';export * from './loopbackHost.js';export * from './manuscriptAnchors.js';diff --git a/client/src/lib/kanbanColumns.js b/client/src/lib/kanbanColumns.jsnew file mode 100644index 0000000000..82a12ec710--- /dev/null+++ b/client/src/lib/kanbanColumns.js@@ -0,0 +1,69 @@+// Pure column logic for the Jira Kanban board (client/src/components/KanbanBoard.jsx).+// Extracted so the bucketing / matching / coloring rules are unit-testable+// without React or dnd-kit. No side effects, no imports.++// 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 ticketInColumn().+export const FALLBACK_COLUMNS = [+ { name: 'To Do', category: 'To Do', statuses: [] },+ { name: 'In Progress', category: 'In Progress', statuses: [] },+ { name: 'Done', category: 'Done', statuses: [] }+];++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' } }+];++export 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).+export 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:+// - a stable unique `id` — Jira boards may have two columns with the same+// display name (mapped to different statuses), so `name` is NOT unique and+// must not be used as a React key / droppable id / drop-target lookup;+// callers route drops by `id`.+// - its precomputed color `config` so render doesn't re-test the regexes.+export function bucketTickets(columns, tickets) {+ const result = columns.map((c, i) => ({ ...c, id: `col-${i}`, 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 = { id: `orphan-${name}`, 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()];+}diff --git a/client/src/lib/kanbanColumns.test.js b/client/src/lib/kanbanColumns.test.jsnew file mode 100644index 0000000000..099f54f278--- /dev/null+++ b/client/src/lib/kanbanColumns.test.js@@ -0,0 +1,117 @@+import { describe, it, expect } from 'vitest';+import { FALLBACK_COLUMNS, ticketInColumn, bucketTickets, columnConfig } from './kanbanColumns.js';++const ticket = (key, status, statusCategory, extra = {}) => ({ key, status, statusCategory, ...extra });++describe('ticketInColumn', () => {+ it('matches by status name when the column lists statuses', () => {+ const col = { name: 'Blocked', category: 'In Progress', statuses: ['Blocked', 'Impeded'] };+ expect(ticketInColumn(ticket('A', 'Blocked', 'In Progress'), col)).toBe(true);+ expect(ticketInColumn(ticket('B', 'In Review', 'In Progress'), col)).toBe(false);+ });++ it('matches by statusCategory when the column has no statuses (fallback board)', () => {+ const col = { name: 'In Progress', category: 'In Progress', statuses: [] };+ // A ticket whose real status is "Blocked" but category "In Progress" lands here.+ expect(ticketInColumn(ticket('A', 'Blocked', 'In Progress'), col)).toBe(true);+ expect(ticketInColumn(ticket('B', 'Done', 'Done'), col)).toBe(false);+ });+});++describe('bucketTickets', () => {+ const columns = [+ { name: 'To Do', category: 'To Do', statuses: ['To Do'] },+ { name: 'In Progress', category: 'In Progress', statuses: ['In Progress'] },+ { name: 'In Review', category: 'In Progress', statuses: ['In Review'] },+ { name: 'Done', category: 'Done', statuses: ['Done'] }+ ];++ it('buckets each ticket into its status-named column', () => {+ const result = bucketTickets(columns, [+ ticket('A', 'To Do', 'To Do'),+ ticket('B', 'In Review', 'In Progress'),+ ticket('C', 'Done', 'Done')+ ]);+ expect(result.find(c => c.name === 'To Do').tickets.map(t => t.key)).toEqual(['A']);+ expect(result.find(c => c.name === 'In Review').tickets.map(t => t.key)).toEqual(['B']);+ expect(result.find(c => c.name === 'Done').tickets.map(t => t.key)).toEqual(['C']);+ expect(result.find(c => c.name === 'In Progress').tickets).toEqual([]);+ });++ it('assigns every column a stable unique id even when display names collide', () => {+ // Jira boards may have two columns with the same display name mapped to+ // different statuses — name must NOT be the routing key.+ const dupNamed = [+ { name: 'Done', category: 'Done', statuses: ['Released'] },+ { name: 'Done', category: 'Done', statuses: ['Closed'] }+ ];+ const result = bucketTickets(dupNamed, [+ ticket('A', 'Released', 'Done'),+ ticket('B', 'Closed', 'Done')+ ]);+ const ids = result.map(c => c.id);+ expect(new Set(ids).size).toBe(ids.length); // all ids unique+ // Each ticket lands in the correct same-named column, by status.+ expect(result[0].tickets.map(t => t.key)).toEqual(['A']);+ expect(result[1].tickets.map(t => t.key)).toEqual(['B']);+ });++ it('appends an orphan column for a status that maps to no column', () => {+ const result = bucketTickets(columns, [ticket('A', 'Waiting on Customer', 'In Progress')]);+ const orphan = result.find(c => c.name === 'Waiting on Customer');+ expect(orphan).toBeTruthy();+ expect(orphan.tickets.map(t => t.key)).toEqual(['A']);+ expect(orphan.statuses).toEqual(['Waiting on Customer']);+ // Orphan id is unique and distinct from the resolved columns.+ const ids = result.map(c => c.id);+ expect(new Set(ids).size).toBe(ids.length);+ });++ it('collapses multiple tickets of the same orphan status into one column', () => {+ const result = bucketTickets(columns, [+ ticket('A', 'Waiting', 'In Progress'),+ ticket('B', 'Waiting', 'In Progress')+ ]);+ const orphans = result.filter(c => c.name === 'Waiting');+ expect(orphans).toHaveLength(1);+ expect(orphans[0].tickets.map(t => t.key)).toEqual(['A', 'B']);+ });++ it('uses the statusCategory fallback for the built-in three-category board', () => {+ const result = bucketTickets(FALLBACK_COLUMNS, [+ ticket('A', 'Blocked', 'In Progress'),+ ticket('B', 'Backlog', 'To Do'),+ ticket('C', 'Released', 'Done')+ ]);+ expect(result.find(c => c.name === 'In Progress').tickets.map(t => t.key)).toEqual(['A']);+ expect(result.find(c => c.name === 'To Do').tickets.map(t => t.key)).toEqual(['B']);+ expect(result.find(c => c.name === 'Done').tickets.map(t => t.key)).toEqual(['C']);+ });++ it('precomputes a color config on every column', () => {+ const result = bucketTickets(columns, []);+ for (const col of result) expect(col.config).toBeTruthy();+ });+});++describe('columnConfig', () => {+ it('colors Blocked-like columns with the error palette regardless of category', () => {+ expect(columnConfig({ name: 'Blocked', category: 'In Progress' }).dot).toBe('bg-port-error');+ expect(columnConfig({ name: 'Impeded', category: 'In Progress' }).dot).toBe('bg-port-error');+ });++ it('colors Review/QA columns with the purple palette', () => {+ expect(columnConfig({ name: 'In Review', category: 'In Progress' }).dot).toBe('bg-purple-500');+ expect(columnConfig({ name: 'QA', category: 'In Progress' }).dot).toBe('bg-purple-500');+ });++ it('falls back to the category palette for ordinary columns', () => {+ expect(columnConfig({ name: 'To Do', category: 'To Do' }).dot).toBe('bg-gray-500');+ expect(columnConfig({ name: 'In Progress', category: 'In Progress' }).dot).toBe('bg-port-accent');+ expect(columnConfig({ name: 'Done', category: 'Done' }).dot).toBe('bg-port-success');+ });++ it('defaults an unknown category to the In Progress palette', () => {+ expect(columnConfig({ name: 'Mystery', category: 'Weird' }).dot).toBe('bg-port-accent');+ });+});