nyk commited on
Commit
bd33753
·
unverified ·
2 Parent(s): a2188352aff45a

Merge branch 'main' into feat/39-structured-logging

Browse files
Dockerfile CHANGED
@@ -3,19 +3,21 @@ RUN corepack enable && corepack prepare pnpm@latest --activate
3
  WORKDIR /app
4
 
5
  FROM base AS deps
 
6
  COPY package.json ./
7
- COPY . .
8
  # better-sqlite3 requires native compilation tools
9
  RUN apt-get update && apt-get install -y python3 make g++ --no-install-recommends && rm -rf /var/lib/apt/lists/*
10
  RUN if [ -f pnpm-lock.yaml ]; then \
11
  pnpm install --frozen-lockfile; \
12
  else \
13
- echo "WARN: pnpm-lock.yaml not found in build context; running non-frozen install"; \
14
  pnpm install --no-frozen-lockfile; \
15
  fi
16
 
17
  FROM base AS build
18
- COPY --from=deps /app ./
 
19
  RUN pnpm build
20
 
21
  FROM node:20-slim AS runtime
@@ -24,8 +26,8 @@ ENV NODE_ENV=production
24
  RUN addgroup --system --gid 1001 nodejs && adduser --system --uid 1001 nextjs
25
  COPY --from=build /app/.next/standalone ./
26
  COPY --from=build /app/.next/static ./.next/static
27
- # Copy public directory if it exists (may not exist in all setups)
28
- COPY --from=build /app/public* ./public/
29
  # Create data directory with correct ownership for SQLite
30
  RUN mkdir -p .data && chown nextjs:nodejs .data
31
  RUN apt-get update && apt-get install -y curl --no-install-recommends && rm -rf /var/lib/apt/lists/*
 
3
  WORKDIR /app
4
 
5
  FROM base AS deps
6
+ # Copy only dependency manifests first for better layer caching
7
  COPY package.json ./
8
+ COPY pnpm-lock.yaml* ./
9
  # better-sqlite3 requires native compilation tools
10
  RUN apt-get update && apt-get install -y python3 make g++ --no-install-recommends && rm -rf /var/lib/apt/lists/*
11
  RUN if [ -f pnpm-lock.yaml ]; then \
12
  pnpm install --frozen-lockfile; \
13
  else \
14
+ echo "WARN: pnpm-lock.yaml not found in build context; running non-frozen install" && \
15
  pnpm install --no-frozen-lockfile; \
16
  fi
17
 
18
  FROM base AS build
19
+ COPY --from=deps /app/node_modules ./node_modules
20
+ COPY . .
21
  RUN pnpm build
22
 
23
  FROM node:20-slim AS runtime
 
26
  RUN addgroup --system --gid 1001 nodejs && adduser --system --uid 1001 nextjs
27
  COPY --from=build /app/.next/standalone ./
28
  COPY --from=build /app/.next/static ./.next/static
29
+ # Copy schema.sql needed by migration 001_init at runtime
30
+ COPY --from=build /app/src/lib/schema.sql ./src/lib/schema.sql
31
  # Create data directory with correct ownership for SQLite
32
  RUN mkdir -p .data && chown nextjs:nodejs .data
33
  RUN apt-get update && apt-get install -y curl --no-install-recommends && rm -rf /var/lib/apt/lists/*
docker-compose.yml CHANGED
@@ -1,9 +1,12 @@
1
  services:
2
  mission-control:
3
  build: .
 
4
  ports:
5
- - "3000:3000"
6
- env_file: .env
 
 
7
  volumes:
8
  - mc-data:/app/.data
9
  restart: unless-stopped
 
1
  services:
2
  mission-control:
3
  build: .
4
+ container_name: mission-control
5
  ports:
6
+ - "${MC_PORT:-3000}:3000"
7
+ env_file:
8
+ - path: .env
9
+ required: false
10
  volumes:
11
  - mc-data:/app/.data
12
  restart: unless-stopped
next.config.js CHANGED
@@ -2,6 +2,8 @@
2
  const nextConfig = {
3
  output: 'standalone',
4
  turbopack: {},
 
 
5
 
6
  // Security headers
7
  async headers() {
 
2
  const nextConfig = {
3
  output: 'standalone',
4
  turbopack: {},
5
+ // Transpile ESM-only packages so they resolve correctly in all environments
6
+ transpilePackages: ['react-markdown', 'remark-gfm'],
7
 
8
  // Security headers
9
  async headers() {
src/app/[[...panel]]/page.tsx CHANGED
@@ -140,6 +140,9 @@ export default function Home() {
140
 
141
  return (
142
  <div className="flex h-screen bg-background overflow-hidden">
 
 
 
143
  {/* Left: Icon rail navigation (hidden on mobile, shown as bottom bar instead) */}
144
  <NavRail />
145
 
@@ -149,7 +152,7 @@ export default function Home() {
149
  <LocalModeBanner />
150
  <UpdateBanner />
151
  <PromoBanner />
152
- <main className="flex-1 overflow-auto pb-16 md:pb-0" role="main">
153
  <div aria-live="polite">
154
  <ErrorBoundary key={activeTab}>
155
  <ContentRouter tab={activeTab} />
 
140
 
141
  return (
142
  <div className="flex h-screen bg-background overflow-hidden">
143
+ <a href="#main-content" className="sr-only focus:not-sr-only focus:absolute focus:z-50 focus:top-2 focus:left-2 focus:px-4 focus:py-2 focus:bg-primary focus:text-primary-foreground focus:rounded-md focus:text-sm focus:font-medium">
144
+ Skip to main content
145
+ </a>
146
  {/* Left: Icon rail navigation (hidden on mobile, shown as bottom bar instead) */}
147
  <NavRail />
148
 
 
152
  <LocalModeBanner />
153
  <UpdateBanner />
154
  <PromoBanner />
155
+ <main id="main-content" className="flex-1 overflow-auto pb-16 md:pb-0" role="main">
156
  <div aria-live="polite">
157
  <ErrorBoundary key={activeTab}>
158
  <ContentRouter tab={activeTab} />
src/components/panels/agent-detail-tabs.tsx CHANGED
@@ -1244,6 +1244,8 @@ export function ConfigTab({
1244
  const [jsonInput, setJsonInput] = useState('')
1245
  const [availableModels, setAvailableModels] = useState<string[]>([])
1246
  const [newFallbackModel, setNewFallbackModel] = useState('')
 
 
1247
 
1248
  useEffect(() => {
1249
  setConfig(agent.config || {})
@@ -1292,6 +1294,40 @@ export function ConfigTab({
1292
  setNewFallbackModel('')
1293
  }
1294
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1295
  const handleSave = async (writeToGateway: boolean = false) => {
1296
  setSaving(true)
1297
  setError(null)
@@ -1479,60 +1515,205 @@ export function ConfigTab({
1479
  {/* Identity */}
1480
  <div className="bg-surface-1/50 rounded-lg p-4">
1481
  <h5 className="text-sm font-medium text-foreground mb-2">Identity</h5>
1482
- <div className="flex items-center gap-3 text-sm">
1483
- <span className="text-2xl">{identityEmoji}</span>
1484
- <div>
1485
- <div className="text-foreground font-medium">{identityName}</div>
1486
- <div className="text-muted-foreground">{identityTheme}</div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1487
  </div>
1488
- </div>
1489
- {identityPreview && (
1490
- <pre className="mt-3 text-xs text-muted-foreground bg-surface-1 rounded p-2 overflow-auto whitespace-pre-wrap">
1491
- {identityPreview}
1492
- </pre>
 
 
 
 
 
 
 
 
 
 
1493
  )}
1494
  </div>
1495
 
1496
  {/* Sandbox */}
1497
  <div className="bg-surface-1/50 rounded-lg p-4">
1498
  <h5 className="text-sm font-medium text-foreground mb-2">Sandbox</h5>
1499
- <div className="grid grid-cols-3 gap-2 text-sm">
1500
- <div><span className="text-muted-foreground">Mode:</span> <span className="text-foreground">{sandboxMode}</span></div>
1501
- <div><span className="text-muted-foreground">Workspace:</span> <span className="text-foreground">{sandboxWorkspace}</span></div>
1502
- <div><span className="text-muted-foreground">Network:</span> <span className="text-foreground">{sandboxNetwork}</span></div>
1503
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1504
  </div>
1505
 
1506
  {/* Tools */}
1507
  <div className="bg-surface-1/50 rounded-lg p-4">
1508
  <h5 className="text-sm font-medium text-foreground mb-2">Tools</h5>
1509
- {toolAllow.length > 0 && (
1510
- <div className="mb-2">
1511
- <span className="text-xs text-green-400 font-medium">Allow ({toolAllow.length}):</span>
1512
- <div className="flex flex-wrap gap-1 mt-1">
1513
- {toolAllow.map((tool: string) => (
1514
- <span key={tool} className="px-2 py-0.5 text-xs bg-green-500/10 text-green-400 rounded border border-green-500/20">{tool}</span>
1515
- ))}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1516
  </div>
1517
- </div>
1518
- )}
1519
- {toolDeny.length > 0 && (
1520
- <div>
1521
- <span className="text-xs text-red-400 font-medium">Deny ({toolDeny.length}):</span>
1522
- <div className="flex flex-wrap gap-1 mt-1">
1523
- {toolDeny.map((tool: string) => (
1524
- <span key={tool} className="px-2 py-0.5 text-xs bg-red-500/10 text-red-400 rounded border border-red-500/20">{tool}</span>
1525
- ))}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1526
  </div>
1527
  </div>
1528
- )}
1529
- {toolAllow.length === 0 && toolDeny.length === 0 && !toolRawPreview && (
1530
- <div className="text-xs text-muted-foreground">No tools configured</div>
1531
- )}
1532
- {toolRawPreview && (
1533
- <pre className="mt-3 text-xs text-muted-foreground bg-surface-1 rounded p-2 overflow-auto whitespace-pre-wrap">
1534
- {toolRawPreview}
1535
- </pre>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1536
  )}
1537
  </div>
1538
 
 
1244
  const [jsonInput, setJsonInput] = useState('')
1245
  const [availableModels, setAvailableModels] = useState<string[]>([])
1246
  const [newFallbackModel, setNewFallbackModel] = useState('')
1247
+ const [newAllowTool, setNewAllowTool] = useState('')
1248
+ const [newDenyTool, setNewDenyTool] = useState('')
1249
 
1250
  useEffect(() => {
1251
  setConfig(agent.config || {})
 
1294
  setNewFallbackModel('')
1295
  }
1296
 
1297
+ const updateIdentityField = (field: string, value: string) => {
1298
+ setConfig((prev: any) => ({
1299
+ ...prev,
1300
+ identity: { ...(prev.identity || {}), [field]: value },
1301
+ }))
1302
+ }
1303
+
1304
+ const updateSandboxField = (field: string, value: string) => {
1305
+ setConfig((prev: any) => ({
1306
+ ...prev,
1307
+ sandbox: { ...(prev.sandbox || {}), [field]: value },
1308
+ }))
1309
+ }
1310
+
1311
+ const addTool = (list: 'allow' | 'deny', value: string) => {
1312
+ const trimmed = value.trim()
1313
+ if (!trimmed) return
1314
+ setConfig((prev: any) => {
1315
+ const tools = prev.tools || {}
1316
+ const existing = Array.isArray(tools[list]) ? tools[list] : []
1317
+ if (existing.includes(trimmed)) return prev
1318
+ return { ...prev, tools: { ...tools, [list]: [...existing, trimmed] } }
1319
+ })
1320
+ }
1321
+
1322
+ const removeTool = (list: 'allow' | 'deny', index: number) => {
1323
+ setConfig((prev: any) => {
1324
+ const tools = prev.tools || {}
1325
+ const existing = Array.isArray(tools[list]) ? [...tools[list]] : []
1326
+ existing.splice(index, 1)
1327
+ return { ...prev, tools: { ...tools, [list]: existing } }
1328
+ })
1329
+ }
1330
+
1331
  const handleSave = async (writeToGateway: boolean = false) => {
1332
  setSaving(true)
1333
  setError(null)
 
1515
  {/* Identity */}
1516
  <div className="bg-surface-1/50 rounded-lg p-4">
1517
  <h5 className="text-sm font-medium text-foreground mb-2">Identity</h5>
1518
+ {editing ? (
1519
+ <div className="space-y-3">
1520
+ <div className="grid grid-cols-3 gap-3">
1521
+ <div>
1522
+ <label className="block text-xs text-muted-foreground mb-1">Emoji</label>
1523
+ <input
1524
+ value={identityEmoji}
1525
+ onChange={(e) => updateIdentityField('emoji', e.target.value)}
1526
+ className="w-full bg-surface-1 text-foreground rounded px-3 py-2 text-sm text-center focus:outline-none focus:ring-1 focus:ring-primary/50"
1527
+ placeholder="🤖"
1528
+ />
1529
+ </div>
1530
+ <div>
1531
+ <label className="block text-xs text-muted-foreground mb-1">Name</label>
1532
+ <input
1533
+ value={identity.name || ''}
1534
+ onChange={(e) => updateIdentityField('name', e.target.value)}
1535
+ className="w-full bg-surface-1 text-foreground rounded px-3 py-2 text-sm focus:outline-none focus:ring-1 focus:ring-primary/50"
1536
+ placeholder="Agent name"
1537
+ />
1538
+ </div>
1539
+ <div>
1540
+ <label className="block text-xs text-muted-foreground mb-1">Theme / Role</label>
1541
+ <input
1542
+ value={identity.theme || ''}
1543
+ onChange={(e) => updateIdentityField('theme', e.target.value)}
1544
+ className="w-full bg-surface-1 text-foreground rounded px-3 py-2 text-sm focus:outline-none focus:ring-1 focus:ring-primary/50"
1545
+ placeholder="e.g. backend engineer"
1546
+ />
1547
+ </div>
1548
+ </div>
1549
+ <div>
1550
+ <label className="block text-xs text-muted-foreground mb-1">Identity content</label>
1551
+ <textarea
1552
+ value={identity.content || ''}
1553
+ onChange={(e) => updateIdentityField('content', e.target.value)}
1554
+ rows={4}
1555
+ className="w-full bg-surface-1 text-foreground border border-border rounded-md px-3 py-2 font-mono text-xs focus:outline-none focus:ring-1 focus:ring-primary/50"
1556
+ placeholder="Describe the agent's identity and personality..."
1557
+ />
1558
+ </div>
1559
  </div>
1560
+ ) : (
1561
+ <>
1562
+ <div className="flex items-center gap-3 text-sm">
1563
+ <span className="text-2xl">{identityEmoji}</span>
1564
+ <div>
1565
+ <div className="text-foreground font-medium">{identityName}</div>
1566
+ <div className="text-muted-foreground">{identityTheme}</div>
1567
+ </div>
1568
+ </div>
1569
+ {identityPreview && (
1570
+ <pre className="mt-3 text-xs text-muted-foreground bg-surface-1 rounded p-2 overflow-auto whitespace-pre-wrap">
1571
+ {identityPreview}
1572
+ </pre>
1573
+ )}
1574
+ </>
1575
  )}
1576
  </div>
1577
 
1578
  {/* Sandbox */}
1579
  <div className="bg-surface-1/50 rounded-lg p-4">
1580
  <h5 className="text-sm font-medium text-foreground mb-2">Sandbox</h5>
1581
+ {editing ? (
1582
+ <div className="grid grid-cols-3 gap-3">
1583
+ <div>
1584
+ <label className="block text-xs text-muted-foreground mb-1">Mode</label>
1585
+ <select
1586
+ value={sandbox.mode || ''}
1587
+ onChange={(e) => updateSandboxField('mode', e.target.value)}
1588
+ className="w-full bg-surface-1 text-foreground rounded px-3 py-2 text-sm focus:outline-none focus:ring-1 focus:ring-primary/50"
1589
+ >
1590
+ <option value="">Not configured</option>
1591
+ <option value="all">All</option>
1592
+ <option value="non-main">Non-main</option>
1593
+ <option value="none">None</option>
1594
+ </select>
1595
+ </div>
1596
+ <div>
1597
+ <label className="block text-xs text-muted-foreground mb-1">Workspace Access</label>
1598
+ <select
1599
+ value={sandbox.workspaceAccess || ''}
1600
+ onChange={(e) => updateSandboxField('workspaceAccess', e.target.value)}
1601
+ className="w-full bg-surface-1 text-foreground rounded px-3 py-2 text-sm focus:outline-none focus:ring-1 focus:ring-primary/50"
1602
+ >
1603
+ <option value="">Not configured</option>
1604
+ <option value="rw">Read-write</option>
1605
+ <option value="ro">Read-only</option>
1606
+ <option value="none">None</option>
1607
+ </select>
1608
+ </div>
1609
+ <div>
1610
+ <label className="block text-xs text-muted-foreground mb-1">Network</label>
1611
+ <input
1612
+ value={sandbox.network || ''}
1613
+ onChange={(e) => updateSandboxField('network', e.target.value)}
1614
+ className="w-full bg-surface-1 text-foreground rounded px-3 py-2 text-sm focus:outline-none focus:ring-1 focus:ring-primary/50"
1615
+ placeholder="none"
1616
+ />
1617
+ </div>
1618
+ </div>
1619
+ ) : (
1620
+ <div className="grid grid-cols-3 gap-2 text-sm">
1621
+ <div><span className="text-muted-foreground">Mode:</span> <span className="text-foreground">{sandboxMode}</span></div>
1622
+ <div><span className="text-muted-foreground">Workspace:</span> <span className="text-foreground">{sandboxWorkspace}</span></div>
1623
+ <div><span className="text-muted-foreground">Network:</span> <span className="text-foreground">{sandboxNetwork}</span></div>
1624
+ </div>
1625
+ )}
1626
  </div>
1627
 
1628
  {/* Tools */}
1629
  <div className="bg-surface-1/50 rounded-lg p-4">
1630
  <h5 className="text-sm font-medium text-foreground mb-2">Tools</h5>
1631
+ {editing ? (
1632
+ <div className="space-y-3">
1633
+ <div>
1634
+ <label className="block text-xs text-green-400 font-medium mb-1">Allow list</label>
1635
+ <div className="flex flex-wrap gap-1 mb-2">
1636
+ {toolAllow.map((tool: string, i: number) => (
1637
+ <span key={`${tool}-${i}`} className="px-2 py-0.5 text-xs bg-green-500/10 text-green-400 rounded border border-green-500/20 flex items-center gap-1">
1638
+ {tool}
1639
+ <button onClick={() => removeTool('allow', i)} className="text-green-400/60 hover:text-green-400 ml-1">&times;</button>
1640
+ </span>
1641
+ ))}
1642
+ </div>
1643
+ <div className="flex gap-2">
1644
+ <input
1645
+ value={newAllowTool}
1646
+ onChange={(e) => setNewAllowTool(e.target.value)}
1647
+ onKeyDown={(e) => { if (e.key === 'Enter') { e.preventDefault(); addTool('allow', newAllowTool); setNewAllowTool('') } }}
1648
+ placeholder="Add allowed tool name"
1649
+ className="flex-1 bg-surface-1 text-foreground rounded px-3 py-2 text-xs focus:outline-none focus:ring-1 focus:ring-primary/50"
1650
+ />
1651
+ <button
1652
+ onClick={() => { addTool('allow', newAllowTool); setNewAllowTool('') }}
1653
+ className="px-3 py-2 text-xs bg-green-500/20 text-green-400 border border-green-500/30 rounded hover:bg-green-500/30 transition-smooth"
1654
+ >
1655
+ Add
1656
+ </button>
1657
+ </div>
1658
  </div>
1659
+ <div>
1660
+ <label className="block text-xs text-red-400 font-medium mb-1">Deny list</label>
1661
+ <div className="flex flex-wrap gap-1 mb-2">
1662
+ {toolDeny.map((tool: string, i: number) => (
1663
+ <span key={`${tool}-${i}`} className="px-2 py-0.5 text-xs bg-red-500/10 text-red-400 rounded border border-red-500/20 flex items-center gap-1">
1664
+ {tool}
1665
+ <button onClick={() => removeTool('deny', i)} className="text-red-400/60 hover:text-red-400 ml-1">&times;</button>
1666
+ </span>
1667
+ ))}
1668
+ </div>
1669
+ <div className="flex gap-2">
1670
+ <input
1671
+ value={newDenyTool}
1672
+ onChange={(e) => setNewDenyTool(e.target.value)}
1673
+ onKeyDown={(e) => { if (e.key === 'Enter') { e.preventDefault(); addTool('deny', newDenyTool); setNewDenyTool('') } }}
1674
+ placeholder="Add denied tool name"
1675
+ className="flex-1 bg-surface-1 text-foreground rounded px-3 py-2 text-xs focus:outline-none focus:ring-1 focus:ring-primary/50"
1676
+ />
1677
+ <button
1678
+ onClick={() => { addTool('deny', newDenyTool); setNewDenyTool('') }}
1679
+ className="px-3 py-2 text-xs bg-red-500/20 text-red-400 border border-red-500/30 rounded hover:bg-red-500/30 transition-smooth"
1680
+ >
1681
+ Add
1682
+ </button>
1683
+ </div>
1684
  </div>
1685
  </div>
1686
+ ) : (
1687
+ <>
1688
+ {toolAllow.length > 0 && (
1689
+ <div className="mb-2">
1690
+ <span className="text-xs text-green-400 font-medium">Allow ({toolAllow.length}):</span>
1691
+ <div className="flex flex-wrap gap-1 mt-1">
1692
+ {toolAllow.map((tool: string) => (
1693
+ <span key={tool} className="px-2 py-0.5 text-xs bg-green-500/10 text-green-400 rounded border border-green-500/20">{tool}</span>
1694
+ ))}
1695
+ </div>
1696
+ </div>
1697
+ )}
1698
+ {toolDeny.length > 0 && (
1699
+ <div>
1700
+ <span className="text-xs text-red-400 font-medium">Deny ({toolDeny.length}):</span>
1701
+ <div className="flex flex-wrap gap-1 mt-1">
1702
+ {toolDeny.map((tool: string) => (
1703
+ <span key={tool} className="px-2 py-0.5 text-xs bg-red-500/10 text-red-400 rounded border border-red-500/20">{tool}</span>
1704
+ ))}
1705
+ </div>
1706
+ </div>
1707
+ )}
1708
+ {toolAllow.length === 0 && toolDeny.length === 0 && !toolRawPreview && (
1709
+ <div className="text-xs text-muted-foreground">No tools configured</div>
1710
+ )}
1711
+ {toolRawPreview && (
1712
+ <pre className="mt-3 text-xs text-muted-foreground bg-surface-1 rounded p-2 overflow-auto whitespace-pre-wrap">
1713
+ {toolRawPreview}
1714
+ </pre>
1715
+ )}
1716
+ </>
1717
  )}
1718
  </div>
1719
 
src/components/panels/task-board-panel.tsx CHANGED
@@ -3,7 +3,11 @@
3
  import { useState, useEffect, useCallback, useRef } from 'react'
4
  import { useMissionControl } from '@/store'
5
  import { useSmartPoll } from '@/lib/use-smart-poll'
 
6
  import { createClientLogger } from '@/lib/client-logger'
 
 
 
7
  import { AgentAvatar } from '@/components/ui/agent-avatar'
8
  import { MarkdownRenderer } from '@/components/markdown-renderer'
9
 
@@ -271,8 +275,8 @@ export function TaskBoardPanel() {
271
 
272
  if (loading) {
273
  return (
274
- <div className="flex items-center justify-center h-64">
275
- <div className="animate-spin rounded-full h-8 w-8 border-b-2 border-primary"></div>
276
  <span className="ml-2 text-muted-foreground">Loading tasks...</span>
277
  </div>
278
  )
@@ -301,11 +305,12 @@ export function TaskBoardPanel() {
301
 
302
  {/* Error Display */}
303
  {error && (
304
- <div className="bg-red-500/10 border border-red-500/20 text-red-400 p-3 m-4 rounded-lg text-sm flex items-center justify-between">
305
  <span>{error}</span>
306
  <button
307
  onClick={() => setError(null)}
308
  className="text-red-400/60 hover:text-red-400 ml-2"
 
309
  >
310
  ×
311
  </button>
@@ -313,10 +318,12 @@ export function TaskBoardPanel() {
313
  )}
314
 
315
  {/* Kanban Board */}
316
- <div className="flex-1 flex gap-4 p-4 overflow-x-auto">
317
  {statusColumns.map(column => (
318
  <div
319
  key={column.key}
 
 
320
  className="flex-1 min-w-80 bg-card border border-border rounded-lg flex flex-col"
321
  onDragEnter={(e) => handleDragEnter(e, column.key)}
322
  onDragLeave={handleDragLeave}
@@ -337,8 +344,12 @@ export function TaskBoardPanel() {
337
  <div
338
  key={task.id}
339
  draggable
 
 
 
340
  onDragStart={(e) => handleDragStart(e, task)}
341
  onClick={() => setSelectedTask(task)}
 
342
  className={`bg-surface-1 rounded-lg p-3 cursor-pointer hover:bg-surface-2 transition-smooth border-l-4 ${priorityColors[task.priority]} ${
343
  draggedTask?.id === task.id ? 'opacity-50' : ''
344
  }`}
@@ -613,12 +624,14 @@ function TaskDetailModal({
613
  </div>
614
  )
615
 
 
 
616
  return (
617
- <div className="fixed inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center z-50 p-4">
618
- <div className="bg-card border border-border rounded-lg max-w-2xl w-full max-h-[90vh] overflow-y-auto">
619
  <div className="p-6">
620
  <div className="flex justify-between items-start mb-4">
621
- <h3 className="text-xl font-bold text-foreground">{task.title}</h3>
622
  <div className="flex gap-2">
623
  <button
624
  onClick={() => onEdit(task)}
@@ -628,6 +641,7 @@ function TaskDetailModal({
628
  </button>
629
  <button
630
  onClick={onClose}
 
631
  className="text-muted-foreground hover:text-foreground text-2xl transition-smooth"
632
  >
633
  ×
@@ -641,10 +655,13 @@ function TaskDetailModal({
641
  ) : (
642
  <p className="text-foreground/80 mb-4">No description</p>
643
  )}
644
- <div className="flex gap-2 mt-4">
645
  {(['details', 'comments', 'quality'] as const).map(tab => (
646
  <button
647
  key={tab}
 
 
 
648
  onClick={() => setActiveTab(tab)}
649
  className={`px-3 py-2 text-sm rounded-md transition-smooth ${
650
  activeTab === tab ? 'bg-primary text-primary-foreground' : 'bg-secondary text-muted-foreground hover:bg-surface-2'
@@ -656,7 +673,7 @@ function TaskDetailModal({
656
  </div>
657
 
658
  {activeTab === 'details' && (
659
- <div className="grid grid-cols-2 gap-4 text-sm mt-4">
660
  <div>
661
  <span className="text-muted-foreground">Status:</span>
662
  <span className="text-foreground ml-2">{task.status}</span>
@@ -686,7 +703,7 @@ function TaskDetailModal({
686
  )}
687
 
688
  {activeTab === 'comments' && (
689
- <div className="mt-6">
690
  <div className="flex items-center justify-between mb-3">
691
  <h4 className="text-lg font-semibold text-foreground">Comments</h4>
692
  <button
@@ -769,7 +786,7 @@ function TaskDetailModal({
769
  )}
770
 
771
  {activeTab === 'quality' && (
772
- <div className="mt-6">
773
  <h5 className="text-sm font-medium text-foreground mb-2">Aegis Quality Review</h5>
774
  {reviewError && (
775
  <div className="text-xs text-red-400 mb-2">{reviewError}</div>
@@ -876,16 +893,19 @@ function CreateTaskModal({
876
  }
877
  }
878
 
 
 
879
  return (
880
- <div className="fixed inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center z-50 p-4">
881
- <div className="bg-card border border-border rounded-lg max-w-md w-full">
882
  <form onSubmit={handleSubmit} className="p-6">
883
- <h3 className="text-xl font-bold text-foreground mb-4">Create New Task</h3>
884
 
885
  <div className="space-y-4">
886
  <div>
887
- <label className="block text-sm text-muted-foreground mb-1">Title</label>
888
  <input
 
889
  type="text"
890
  value={formData.title}
891
  onChange={(e) => setFormData(prev => ({ ...prev, title: e.target.value }))}
@@ -895,8 +915,9 @@ function CreateTaskModal({
895
  </div>
896
 
897
  <div>
898
- <label className="block text-sm text-muted-foreground mb-1">Description</label>
899
  <textarea
 
900
  value={formData.description}
901
  onChange={(e) => setFormData(prev => ({ ...prev, description: e.target.value }))}
902
  className="w-full bg-surface-1 text-foreground border border-border rounded-md px-3 py-2 focus:outline-none focus:ring-1 focus:ring-primary/50"
@@ -906,8 +927,9 @@ function CreateTaskModal({
906
 
907
  <div className="grid grid-cols-2 gap-4">
908
  <div>
909
- <label className="block text-sm text-muted-foreground mb-1">Priority</label>
910
  <select
 
911
  value={formData.priority}
912
  onChange={(e) => setFormData(prev => ({ ...prev, priority: e.target.value as Task['priority'] }))}
913
  className="w-full bg-surface-1 text-foreground border border-border rounded-md px-3 py-2 focus:outline-none focus:ring-1 focus:ring-primary/50"
@@ -920,8 +942,9 @@ function CreateTaskModal({
920
  </div>
921
 
922
  <div>
923
- <label className="block text-sm text-muted-foreground mb-1">Assign to</label>
924
  <select
 
925
  value={formData.assigned_to}
926
  onChange={(e) => setFormData(prev => ({ ...prev, assigned_to: e.target.value }))}
927
  className="w-full bg-surface-1 text-foreground border border-border rounded-md px-3 py-2 focus:outline-none focus:ring-1 focus:ring-primary/50"
@@ -937,8 +960,9 @@ function CreateTaskModal({
937
  </div>
938
 
939
  <div>
940
- <label className="block text-sm text-muted-foreground mb-1">Tags (comma-separated)</label>
941
  <input
 
942
  type="text"
943
  value={formData.tags}
944
  onChange={(e) => setFormData(prev => ({ ...prev, tags: e.target.value }))}
@@ -1018,16 +1042,19 @@ function EditTaskModal({
1018
  }
1019
  }
1020
 
 
 
1021
  return (
1022
- <div className="fixed inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center z-50 p-4">
1023
- <div className="bg-card border border-border rounded-lg max-w-md w-full">
1024
  <form onSubmit={handleSubmit} className="p-6">
1025
- <h3 className="text-xl font-bold text-foreground mb-4">Edit Task</h3>
1026
 
1027
  <div className="space-y-4">
1028
  <div>
1029
- <label className="block text-sm text-muted-foreground mb-1">Title</label>
1030
  <input
 
1031
  type="text"
1032
  value={formData.title}
1033
  onChange={(e) => setFormData(prev => ({ ...prev, title: e.target.value }))}
@@ -1037,8 +1064,9 @@ function EditTaskModal({
1037
  </div>
1038
 
1039
  <div>
1040
- <label className="block text-sm text-muted-foreground mb-1">Description</label>
1041
  <textarea
 
1042
  value={formData.description}
1043
  onChange={(e) => setFormData(prev => ({ ...prev, description: e.target.value }))}
1044
  className="w-full bg-surface-1 text-foreground border border-border rounded-md px-3 py-2 focus:outline-none focus:ring-1 focus:ring-primary/50"
@@ -1048,8 +1076,9 @@ function EditTaskModal({
1048
 
1049
  <div className="grid grid-cols-2 gap-4">
1050
  <div>
1051
- <label className="block text-sm text-muted-foreground mb-1">Status</label>
1052
  <select
 
1053
  value={formData.status}
1054
  onChange={(e) => setFormData(prev => ({ ...prev, status: e.target.value as Task['status'] }))}
1055
  className="w-full bg-surface-1 text-foreground border border-border rounded-md px-3 py-2 focus:outline-none focus:ring-1 focus:ring-primary/50"
@@ -1064,8 +1093,9 @@ function EditTaskModal({
1064
  </div>
1065
 
1066
  <div>
1067
- <label className="block text-sm text-muted-foreground mb-1">Priority</label>
1068
  <select
 
1069
  value={formData.priority}
1070
  onChange={(e) => setFormData(prev => ({ ...prev, priority: e.target.value as Task['priority'] }))}
1071
  className="w-full bg-surface-1 text-foreground border border-border rounded-md px-3 py-2 focus:outline-none focus:ring-1 focus:ring-primary/50"
@@ -1079,8 +1109,9 @@ function EditTaskModal({
1079
  </div>
1080
 
1081
  <div>
1082
- <label className="block text-sm text-muted-foreground mb-1">Assign to</label>
1083
  <select
 
1084
  value={formData.assigned_to}
1085
  onChange={(e) => setFormData(prev => ({ ...prev, assigned_to: e.target.value }))}
1086
  className="w-full bg-surface-1 text-foreground border border-border rounded-md px-3 py-2 focus:outline-none focus:ring-1 focus:ring-primary/50"
@@ -1095,8 +1126,9 @@ function EditTaskModal({
1095
  </div>
1096
 
1097
  <div>
1098
- <label className="block text-sm text-muted-foreground mb-1">Tags (comma-separated)</label>
1099
  <input
 
1100
  type="text"
1101
  value={formData.tags}
1102
  onChange={(e) => setFormData(prev => ({ ...prev, tags: e.target.value }))}
 
3
  import { useState, useEffect, useCallback, useRef } from 'react'
4
  import { useMissionControl } from '@/store'
5
  import { useSmartPoll } from '@/lib/use-smart-poll'
6
+
7
  import { createClientLogger } from '@/lib/client-logger'
8
+
9
+ import { useFocusTrap } from '@/lib/use-focus-trap'
10
+
11
  import { AgentAvatar } from '@/components/ui/agent-avatar'
12
  import { MarkdownRenderer } from '@/components/markdown-renderer'
13
 
 
275
 
276
  if (loading) {
277
  return (
278
+ <div className="flex items-center justify-center h-64" role="status" aria-live="polite">
279
+ <div className="animate-spin rounded-full h-8 w-8 border-b-2 border-primary" aria-hidden="true"></div>
280
  <span className="ml-2 text-muted-foreground">Loading tasks...</span>
281
  </div>
282
  )
 
305
 
306
  {/* Error Display */}
307
  {error && (
308
+ <div role="alert" className="bg-red-500/10 border border-red-500/20 text-red-400 p-3 m-4 rounded-lg text-sm flex items-center justify-between">
309
  <span>{error}</span>
310
  <button
311
  onClick={() => setError(null)}
312
  className="text-red-400/60 hover:text-red-400 ml-2"
313
+ aria-label="Dismiss error"
314
  >
315
  ×
316
  </button>
 
318
  )}
319
 
320
  {/* Kanban Board */}
321
+ <div className="flex-1 flex gap-4 p-4 overflow-x-auto" role="region" aria-label="Task board">
322
  {statusColumns.map(column => (
323
  <div
324
  key={column.key}
325
+ role="region"
326
+ aria-label={`${column.title} column, ${tasksByStatus[column.key]?.length || 0} tasks`}
327
  className="flex-1 min-w-80 bg-card border border-border rounded-lg flex flex-col"
328
  onDragEnter={(e) => handleDragEnter(e, column.key)}
329
  onDragLeave={handleDragLeave}
 
344
  <div
345
  key={task.id}
346
  draggable
347
+ role="button"
348
+ tabIndex={0}
349
+ aria-label={`${task.title}, ${task.priority} priority, ${task.status}`}
350
  onDragStart={(e) => handleDragStart(e, task)}
351
  onClick={() => setSelectedTask(task)}
352
+ onKeyDown={(e) => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); setSelectedTask(task) } }}
353
  className={`bg-surface-1 rounded-lg p-3 cursor-pointer hover:bg-surface-2 transition-smooth border-l-4 ${priorityColors[task.priority]} ${
354
  draggedTask?.id === task.id ? 'opacity-50' : ''
355
  }`}
 
624
  </div>
625
  )
626
 
627
+ const dialogRef = useFocusTrap(onClose)
628
+
629
  return (
630
+ <div className="fixed inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center z-50 p-4" onClick={(e) => { if (e.target === e.currentTarget) onClose() }}>
631
+ <div ref={dialogRef} role="dialog" aria-modal="true" aria-labelledby="task-detail-title" className="bg-card border border-border rounded-lg max-w-2xl w-full max-h-[90vh] overflow-y-auto">
632
  <div className="p-6">
633
  <div className="flex justify-between items-start mb-4">
634
+ <h3 id="task-detail-title" className="text-xl font-bold text-foreground">{task.title}</h3>
635
  <div className="flex gap-2">
636
  <button
637
  onClick={() => onEdit(task)}
 
641
  </button>
642
  <button
643
  onClick={onClose}
644
+ aria-label="Close task details"
645
  className="text-muted-foreground hover:text-foreground text-2xl transition-smooth"
646
  >
647
  ×
 
655
  ) : (
656
  <p className="text-foreground/80 mb-4">No description</p>
657
  )}
658
+ <div className="flex gap-2 mt-4" role="tablist" aria-label="Task detail tabs">
659
  {(['details', 'comments', 'quality'] as const).map(tab => (
660
  <button
661
  key={tab}
662
+ role="tab"
663
+ aria-selected={activeTab === tab}
664
+ aria-controls={`tabpanel-${tab}`}
665
  onClick={() => setActiveTab(tab)}
666
  className={`px-3 py-2 text-sm rounded-md transition-smooth ${
667
  activeTab === tab ? 'bg-primary text-primary-foreground' : 'bg-secondary text-muted-foreground hover:bg-surface-2'
 
673
  </div>
674
 
675
  {activeTab === 'details' && (
676
+ <div id="tabpanel-details" role="tabpanel" aria-label="Details" className="grid grid-cols-2 gap-4 text-sm mt-4">
677
  <div>
678
  <span className="text-muted-foreground">Status:</span>
679
  <span className="text-foreground ml-2">{task.status}</span>
 
703
  )}
704
 
705
  {activeTab === 'comments' && (
706
+ <div id="tabpanel-comments" role="tabpanel" aria-label="Comments" className="mt-6">
707
  <div className="flex items-center justify-between mb-3">
708
  <h4 className="text-lg font-semibold text-foreground">Comments</h4>
709
  <button
 
786
  )}
787
 
788
  {activeTab === 'quality' && (
789
+ <div id="tabpanel-quality" role="tabpanel" aria-label="Quality Review" className="mt-6">
790
  <h5 className="text-sm font-medium text-foreground mb-2">Aegis Quality Review</h5>
791
  {reviewError && (
792
  <div className="text-xs text-red-400 mb-2">{reviewError}</div>
 
893
  }
894
  }
895
 
896
+ const dialogRef = useFocusTrap(onClose)
897
+
898
  return (
899
+ <div className="fixed inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center z-50 p-4" onClick={(e) => { if (e.target === e.currentTarget) onClose() }}>
900
+ <div ref={dialogRef} role="dialog" aria-modal="true" aria-labelledby="create-task-title" className="bg-card border border-border rounded-lg max-w-md w-full">
901
  <form onSubmit={handleSubmit} className="p-6">
902
+ <h3 id="create-task-title" className="text-xl font-bold text-foreground mb-4">Create New Task</h3>
903
 
904
  <div className="space-y-4">
905
  <div>
906
+ <label htmlFor="create-title" className="block text-sm text-muted-foreground mb-1">Title</label>
907
  <input
908
+ id="create-title"
909
  type="text"
910
  value={formData.title}
911
  onChange={(e) => setFormData(prev => ({ ...prev, title: e.target.value }))}
 
915
  </div>
916
 
917
  <div>
918
+ <label htmlFor="create-description" className="block text-sm text-muted-foreground mb-1">Description</label>
919
  <textarea
920
+ id="create-description"
921
  value={formData.description}
922
  onChange={(e) => setFormData(prev => ({ ...prev, description: e.target.value }))}
923
  className="w-full bg-surface-1 text-foreground border border-border rounded-md px-3 py-2 focus:outline-none focus:ring-1 focus:ring-primary/50"
 
927
 
928
  <div className="grid grid-cols-2 gap-4">
929
  <div>
930
+ <label htmlFor="create-priority" className="block text-sm text-muted-foreground mb-1">Priority</label>
931
  <select
932
+ id="create-priority"
933
  value={formData.priority}
934
  onChange={(e) => setFormData(prev => ({ ...prev, priority: e.target.value as Task['priority'] }))}
935
  className="w-full bg-surface-1 text-foreground border border-border rounded-md px-3 py-2 focus:outline-none focus:ring-1 focus:ring-primary/50"
 
942
  </div>
943
 
944
  <div>
945
+ <label htmlFor="create-assignee" className="block text-sm text-muted-foreground mb-1">Assign to</label>
946
  <select
947
+ id="create-assignee"
948
  value={formData.assigned_to}
949
  onChange={(e) => setFormData(prev => ({ ...prev, assigned_to: e.target.value }))}
950
  className="w-full bg-surface-1 text-foreground border border-border rounded-md px-3 py-2 focus:outline-none focus:ring-1 focus:ring-primary/50"
 
960
  </div>
961
 
962
  <div>
963
+ <label htmlFor="create-tags" className="block text-sm text-muted-foreground mb-1">Tags (comma-separated)</label>
964
  <input
965
+ id="create-tags"
966
  type="text"
967
  value={formData.tags}
968
  onChange={(e) => setFormData(prev => ({ ...prev, tags: e.target.value }))}
 
1042
  }
1043
  }
1044
 
1045
+ const dialogRef = useFocusTrap(onClose)
1046
+
1047
  return (
1048
+ <div className="fixed inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center z-50 p-4" onClick={(e) => { if (e.target === e.currentTarget) onClose() }}>
1049
+ <div ref={dialogRef} role="dialog" aria-modal="true" aria-labelledby="edit-task-title" className="bg-card border border-border rounded-lg max-w-md w-full">
1050
  <form onSubmit={handleSubmit} className="p-6">
1051
+ <h3 id="edit-task-title" className="text-xl font-bold text-foreground mb-4">Edit Task</h3>
1052
 
1053
  <div className="space-y-4">
1054
  <div>
1055
+ <label htmlFor="edit-title" className="block text-sm text-muted-foreground mb-1">Title</label>
1056
  <input
1057
+ id="edit-title"
1058
  type="text"
1059
  value={formData.title}
1060
  onChange={(e) => setFormData(prev => ({ ...prev, title: e.target.value }))}
 
1064
  </div>
1065
 
1066
  <div>
1067
+ <label htmlFor="edit-description" className="block text-sm text-muted-foreground mb-1">Description</label>
1068
  <textarea
1069
+ id="edit-description"
1070
  value={formData.description}
1071
  onChange={(e) => setFormData(prev => ({ ...prev, description: e.target.value }))}
1072
  className="w-full bg-surface-1 text-foreground border border-border rounded-md px-3 py-2 focus:outline-none focus:ring-1 focus:ring-primary/50"
 
1076
 
1077
  <div className="grid grid-cols-2 gap-4">
1078
  <div>
1079
+ <label htmlFor="edit-status" className="block text-sm text-muted-foreground mb-1">Status</label>
1080
  <select
1081
+ id="edit-status"
1082
  value={formData.status}
1083
  onChange={(e) => setFormData(prev => ({ ...prev, status: e.target.value as Task['status'] }))}
1084
  className="w-full bg-surface-1 text-foreground border border-border rounded-md px-3 py-2 focus:outline-none focus:ring-1 focus:ring-primary/50"
 
1093
  </div>
1094
 
1095
  <div>
1096
+ <label htmlFor="edit-priority" className="block text-sm text-muted-foreground mb-1">Priority</label>
1097
  <select
1098
+ id="edit-priority"
1099
  value={formData.priority}
1100
  onChange={(e) => setFormData(prev => ({ ...prev, priority: e.target.value as Task['priority'] }))}
1101
  className="w-full bg-surface-1 text-foreground border border-border rounded-md px-3 py-2 focus:outline-none focus:ring-1 focus:ring-primary/50"
 
1109
  </div>
1110
 
1111
  <div>
1112
+ <label htmlFor="edit-assignee" className="block text-sm text-muted-foreground mb-1">Assign to</label>
1113
  <select
1114
+ id="edit-assignee"
1115
  value={formData.assigned_to}
1116
  onChange={(e) => setFormData(prev => ({ ...prev, assigned_to: e.target.value }))}
1117
  className="w-full bg-surface-1 text-foreground border border-border rounded-md px-3 py-2 focus:outline-none focus:ring-1 focus:ring-primary/50"
 
1126
  </div>
1127
 
1128
  <div>
1129
+ <label htmlFor="edit-tags" className="block text-sm text-muted-foreground mb-1">Tags (comma-separated)</label>
1130
  <input
1131
+ id="edit-tags"
1132
  type="text"
1133
  value={formData.tags}
1134
  onChange={(e) => setFormData(prev => ({ ...prev, tags: e.target.value }))}
src/lib/use-focus-trap.ts ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { useEffect, useRef, useCallback } from 'react'
2
+
3
+ const FOCUSABLE_SELECTOR = [
4
+ 'a[href]',
5
+ 'button:not([disabled])',
6
+ 'input:not([disabled])',
7
+ 'select:not([disabled])',
8
+ 'textarea:not([disabled])',
9
+ '[tabindex]:not([tabindex="-1"])',
10
+ ].join(', ')
11
+
12
+ /**
13
+ * Traps keyboard focus within a container element.
14
+ * Handles Tab/Shift+Tab cycling and Escape to close.
15
+ */
16
+ export function useFocusTrap(onClose?: () => void) {
17
+ const containerRef = useRef<HTMLDivElement>(null)
18
+ const previousFocusRef = useRef<HTMLElement | null>(null)
19
+
20
+ const handleKeyDown = useCallback(
21
+ (e: KeyboardEvent) => {
22
+ if (e.key === 'Escape' && onClose) {
23
+ e.stopPropagation()
24
+ onClose()
25
+ return
26
+ }
27
+
28
+ if (e.key !== 'Tab') return
29
+
30
+ const container = containerRef.current
31
+ if (!container) return
32
+
33
+ const focusable = Array.from(
34
+ container.querySelectorAll<HTMLElement>(FOCUSABLE_SELECTOR)
35
+ )
36
+
37
+ if (focusable.length === 0) return
38
+
39
+ const first = focusable[0]
40
+ const last = focusable[focusable.length - 1]
41
+
42
+ if (e.shiftKey) {
43
+ if (document.activeElement === first) {
44
+ e.preventDefault()
45
+ last.focus()
46
+ }
47
+ } else {
48
+ if (document.activeElement === last) {
49
+ e.preventDefault()
50
+ first.focus()
51
+ }
52
+ }
53
+ },
54
+ [onClose]
55
+ )
56
+
57
+ useEffect(() => {
58
+ previousFocusRef.current = document.activeElement as HTMLElement
59
+
60
+ const container = containerRef.current
61
+ if (container) {
62
+ const focusable = container.querySelectorAll<HTMLElement>(FOCUSABLE_SELECTOR)
63
+ if (focusable.length > 0) {
64
+ focusable[0].focus()
65
+ }
66
+ }
67
+
68
+ document.addEventListener('keydown', handleKeyDown)
69
+
70
+ return () => {
71
+ document.removeEventListener('keydown', handleKeyDown)
72
+ previousFocusRef.current?.focus()
73
+ }
74
+ }, [handleKeyDown])
75
+
76
+ return containerRef
77
+ }