Nyk commited on
Commit
f59451c
·
1 Parent(s): 75f351a

fix(office): hide inactive local sessions by default

Browse files
src/components/panels/office-panel.tsx CHANGED
@@ -107,6 +107,7 @@ interface PersistedOfficePrefs {
107
  version: 1
108
  viewMode: ViewMode
109
  sidebarFilter: SidebarFilter
 
110
  mapZoom: number
111
  mapPan: { x: number; y: number }
112
  timeTheme: TimeTheme
@@ -217,6 +218,10 @@ function inferLocalRole(row: SessionAgentRow): string {
217
  return row.kind || 'local-session'
218
  }
219
 
 
 
 
 
220
  const MAP_COLS = 24
221
  const MAP_ROWS = 16
222
 
@@ -471,6 +476,7 @@ export function OfficePanel() {
471
  const [showSidebar, setShowSidebar] = useState(true)
472
  const [showMinimap, setShowMinimap] = useState(true)
473
  const [showEvents, setShowEvents] = useState(true)
 
474
  const [loading, setLoading] = useState(true)
475
  const [localBootstrapping, setLocalBootstrapping] = useState(isLocalMode)
476
  const [sidebarFilter, setSidebarFilter] = useState<SidebarFilter>('all')
@@ -628,23 +634,28 @@ export function OfficePanel() {
628
  return []
629
  }, [agents, isLocalMode, localAgents, sessionAgents])
630
 
 
 
 
 
 
631
  const counts = useMemo(() => {
632
  const c = { idle: 0, busy: 0, error: 0, offline: 0 }
633
- for (const a of displayAgents) c[a.status] = (c[a.status] || 0) + 1
634
  return c
635
- }, [displayAgents])
636
 
637
  const roleGroups = useMemo(() => {
638
  const groups = new Map<string, Agent[]>()
639
- for (const a of displayAgents) {
640
  const role = a.role || 'Unassigned'
641
  if (!groups.has(role)) groups.set(role, [])
642
  groups.get(role)!.push(a)
643
  }
644
  return groups
645
- }, [displayAgents])
646
 
647
- const officeLayout = useMemo(() => buildOfficeLayout(displayAgents), [displayAgents])
648
 
649
  const currentSeatMap = useMemo(() => {
650
  const seatMap = new Map<number, SeatPosition>()
@@ -790,6 +801,7 @@ export function OfficePanel() {
790
  if (!prefs || prefs.version !== 1) return
791
  setViewMode(prefs.viewMode || 'office')
792
  setSidebarFilter(prefs.sidebarFilter || 'all')
 
793
  setMapZoom(Number.isFinite(prefs.mapZoom) ? clamp(prefs.mapZoom, 0.8, 2.2) : 1)
794
  setMapPan({
795
  x: Number.isFinite(prefs.mapPan?.x) ? prefs.mapPan.x : 0,
@@ -816,6 +828,7 @@ export function OfficePanel() {
816
  version: 1,
817
  viewMode,
818
  sidebarFilter,
 
819
  mapZoom,
820
  mapPan,
821
  timeTheme,
@@ -837,6 +850,7 @@ export function OfficePanel() {
837
  mapZoom,
838
  roomLayoutState,
839
  showEvents,
 
840
  showMinimap,
841
  showSidebar,
842
  sidebarFilter,
@@ -1381,7 +1395,7 @@ export function OfficePanel() {
1381
  return 'Other'
1382
  }
1383
 
1384
- for (const a of displayAgents) {
1385
  const category = getCategory(a)
1386
  if (!groups.has(category)) groups.set(category, [])
1387
  groups.get(category)!.push(a)
@@ -1398,11 +1412,11 @@ export function OfficePanel() {
1398
  return a.localeCompare(b)
1399
  })
1400
  )
1401
- }, [displayAgents])
1402
 
1403
  const statusGroups = useMemo(() => {
1404
  const groups = new Map<string, Agent[]>()
1405
- for (const a of displayAgents) {
1406
  const key = statusLabel[a.status] || a.status
1407
  if (!groups.has(key)) groups.set(key, [])
1408
  groups.get(key)!.push(a)
@@ -1419,7 +1433,7 @@ export function OfficePanel() {
1419
  return a.localeCompare(b)
1420
  })
1421
  )
1422
- }, [displayAgents])
1423
 
1424
  const orgGroups = useMemo(() => {
1425
  if (orgSegmentMode === 'role') return roleGroups
@@ -1427,7 +1441,7 @@ export function OfficePanel() {
1427
  return categoryGroups
1428
  }, [categoryGroups, orgSegmentMode, roleGroups, statusGroups])
1429
 
1430
- if ((loading || (isLocalMode && localBootstrapping)) && displayAgents.length === 0) {
1431
  return (
1432
  <div className="flex items-center justify-center h-64">
1433
  <div className="animate-spin rounded-full h-6 w-6 border-b-2 border-primary" />
@@ -1474,7 +1488,7 @@ export function OfficePanel() {
1474
  </div>
1475
  </div>
1476
 
1477
- {displayAgents.length === 0 ? (
1478
  <div className="text-center py-16 text-muted-foreground">
1479
  <div className="text-5xl mb-3">🏢</div>
1480
  <p className="text-lg">The office is empty</p>
@@ -1486,7 +1500,7 @@ export function OfficePanel() {
1486
  <div className="rounded-xl border border-border bg-[#1a1f2d] text-slate-100 p-3 h-fit">
1487
  <div className="flex items-center justify-between mb-2">
1488
  <div className="text-xs font-semibold tracking-wider">TEAMY</div>
1489
- <div className="text-[10px] text-slate-300">{displayAgents.length} online</div>
1490
  </div>
1491
  <div className="mb-2 flex flex-wrap gap-1.5">
1492
  {([
@@ -1508,6 +1522,18 @@ export function OfficePanel() {
1508
  </button>
1509
  ))}
1510
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
1511
  <div className="space-y-2 max-h-[560px] overflow-y-auto pr-1">
1512
  {filteredRosterRows.map(({ agent, minutesIdle, needsAttention }) => (
1513
  <button
 
107
  version: 1
108
  viewMode: ViewMode
109
  sidebarFilter: SidebarFilter
110
+ showInactiveSessions: boolean
111
  mapZoom: number
112
  mapPan: { x: number; y: number }
113
  timeTheme: TimeTheme
 
218
  return row.kind || 'local-session'
219
  }
220
 
221
+ function isInactiveLocalSession(agent: Agent): boolean {
222
+ return Boolean((agent.config as any)?.localSession) && agent.status !== 'busy'
223
+ }
224
+
225
  const MAP_COLS = 24
226
  const MAP_ROWS = 16
227
 
 
476
  const [showSidebar, setShowSidebar] = useState(true)
477
  const [showMinimap, setShowMinimap] = useState(true)
478
  const [showEvents, setShowEvents] = useState(true)
479
+ const [showInactiveSessions, setShowInactiveSessions] = useState(false)
480
  const [loading, setLoading] = useState(true)
481
  const [localBootstrapping, setLocalBootstrapping] = useState(isLocalMode)
482
  const [sidebarFilter, setSidebarFilter] = useState<SidebarFilter>('all')
 
634
  return []
635
  }, [agents, isLocalMode, localAgents, sessionAgents])
636
 
637
+ const visibleDisplayAgents = useMemo(() => {
638
+ if (!isLocalMode || showInactiveSessions) return displayAgents
639
+ return displayAgents.filter((agent) => !isInactiveLocalSession(agent))
640
+ }, [displayAgents, isLocalMode, showInactiveSessions])
641
+
642
  const counts = useMemo(() => {
643
  const c = { idle: 0, busy: 0, error: 0, offline: 0 }
644
+ for (const a of visibleDisplayAgents) c[a.status] = (c[a.status] || 0) + 1
645
  return c
646
+ }, [visibleDisplayAgents])
647
 
648
  const roleGroups = useMemo(() => {
649
  const groups = new Map<string, Agent[]>()
650
+ for (const a of visibleDisplayAgents) {
651
  const role = a.role || 'Unassigned'
652
  if (!groups.has(role)) groups.set(role, [])
653
  groups.get(role)!.push(a)
654
  }
655
  return groups
656
+ }, [visibleDisplayAgents])
657
 
658
+ const officeLayout = useMemo(() => buildOfficeLayout(visibleDisplayAgents), [visibleDisplayAgents])
659
 
660
  const currentSeatMap = useMemo(() => {
661
  const seatMap = new Map<number, SeatPosition>()
 
801
  if (!prefs || prefs.version !== 1) return
802
  setViewMode(prefs.viewMode || 'office')
803
  setSidebarFilter(prefs.sidebarFilter || 'all')
804
+ setShowInactiveSessions(Boolean(prefs.showInactiveSessions))
805
  setMapZoom(Number.isFinite(prefs.mapZoom) ? clamp(prefs.mapZoom, 0.8, 2.2) : 1)
806
  setMapPan({
807
  x: Number.isFinite(prefs.mapPan?.x) ? prefs.mapPan.x : 0,
 
828
  version: 1,
829
  viewMode,
830
  sidebarFilter,
831
+ showInactiveSessions,
832
  mapZoom,
833
  mapPan,
834
  timeTheme,
 
850
  mapZoom,
851
  roomLayoutState,
852
  showEvents,
853
+ showInactiveSessions,
854
  showMinimap,
855
  showSidebar,
856
  sidebarFilter,
 
1395
  return 'Other'
1396
  }
1397
 
1398
+ for (const a of visibleDisplayAgents) {
1399
  const category = getCategory(a)
1400
  if (!groups.has(category)) groups.set(category, [])
1401
  groups.get(category)!.push(a)
 
1412
  return a.localeCompare(b)
1413
  })
1414
  )
1415
+ }, [visibleDisplayAgents])
1416
 
1417
  const statusGroups = useMemo(() => {
1418
  const groups = new Map<string, Agent[]>()
1419
+ for (const a of visibleDisplayAgents) {
1420
  const key = statusLabel[a.status] || a.status
1421
  if (!groups.has(key)) groups.set(key, [])
1422
  groups.get(key)!.push(a)
 
1433
  return a.localeCompare(b)
1434
  })
1435
  )
1436
+ }, [visibleDisplayAgents])
1437
 
1438
  const orgGroups = useMemo(() => {
1439
  if (orgSegmentMode === 'role') return roleGroups
 
1441
  return categoryGroups
1442
  }, [categoryGroups, orgSegmentMode, roleGroups, statusGroups])
1443
 
1444
+ if ((loading || (isLocalMode && localBootstrapping)) && visibleDisplayAgents.length === 0) {
1445
  return (
1446
  <div className="flex items-center justify-center h-64">
1447
  <div className="animate-spin rounded-full h-6 w-6 border-b-2 border-primary" />
 
1488
  </div>
1489
  </div>
1490
 
1491
+ {visibleDisplayAgents.length === 0 ? (
1492
  <div className="text-center py-16 text-muted-foreground">
1493
  <div className="text-5xl mb-3">🏢</div>
1494
  <p className="text-lg">The office is empty</p>
 
1500
  <div className="rounded-xl border border-border bg-[#1a1f2d] text-slate-100 p-3 h-fit">
1501
  <div className="flex items-center justify-between mb-2">
1502
  <div className="text-xs font-semibold tracking-wider">TEAMY</div>
1503
+ <div className="text-[10px] text-slate-300">{visibleDisplayAgents.length} online</div>
1504
  </div>
1505
  <div className="mb-2 flex flex-wrap gap-1.5">
1506
  {([
 
1522
  </button>
1523
  ))}
1524
  </div>
1525
+ {isLocalMode && (
1526
+ <button
1527
+ onClick={() => setShowInactiveSessions((current) => !current)}
1528
+ className={`mb-2 w-full rounded-md border px-2 py-1 text-[10px] transition-smooth ${
1529
+ showInactiveSessions
1530
+ ? 'border-amber-500/60 bg-amber-500/15 text-amber-200'
1531
+ : 'border-white/10 bg-black/20 text-slate-300 hover:bg-black/35'
1532
+ }`}
1533
+ >
1534
+ {showInactiveSessions ? 'Hide Not Running Sessions' : 'Show Not Running Sessions'}
1535
+ </button>
1536
+ )}
1537
  <div className="space-y-2 max-h-[560px] overflow-y-auto pr-1">
1538
  {filteredRosterRows.map(({ agent, minutesIdle, needsAttention }) => (
1539
  <button