orbital-command 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +396 -0
- package/bin/orbital.js +362 -0
- package/dist/assets/WorkflowVisualizer-BZ21PIIF.js +84 -0
- package/dist/assets/WorkflowVisualizer-BZV40eAE.css +1 -0
- package/dist/assets/charts-D__PA1zp.js +72 -0
- package/dist/assets/index-D1G6i0nS.css +1 -0
- package/dist/assets/index-DpItvKpf.js +419 -0
- package/dist/assets/ui-BvF022GT.js +53 -0
- package/dist/assets/vendor-Dzv9lrRc.js +59 -0
- package/dist/index.html +19 -0
- package/dist/scanner-sweep.png +0 -0
- package/dist/server/server/adapters/index.js +34 -0
- package/dist/server/server/adapters/iterm2-adapter.js +29 -0
- package/dist/server/server/adapters/subprocess-adapter.js +21 -0
- package/dist/server/server/adapters/terminal-adapter.js +1 -0
- package/dist/server/server/config.js +156 -0
- package/dist/server/server/database.js +90 -0
- package/dist/server/server/index.js +372 -0
- package/dist/server/server/init.js +811 -0
- package/dist/server/server/parsers/event-parser.js +64 -0
- package/dist/server/server/parsers/scope-parser.js +188 -0
- package/dist/server/server/routes/config-routes.js +163 -0
- package/dist/server/server/routes/data-routes.js +461 -0
- package/dist/server/server/routes/dispatch-routes.js +215 -0
- package/dist/server/server/routes/git-routes.js +92 -0
- package/dist/server/server/routes/scope-routes.js +215 -0
- package/dist/server/server/routes/sprint-routes.js +116 -0
- package/dist/server/server/routes/version-routes.js +130 -0
- package/dist/server/server/routes/workflow-routes.js +185 -0
- package/dist/server/server/schema.js +90 -0
- package/dist/server/server/services/batch-orchestrator.js +253 -0
- package/dist/server/server/services/claude-session-service.js +352 -0
- package/dist/server/server/services/config-service.js +132 -0
- package/dist/server/server/services/deploy-service.js +51 -0
- package/dist/server/server/services/event-service.js +63 -0
- package/dist/server/server/services/gate-service.js +83 -0
- package/dist/server/server/services/git-service.js +309 -0
- package/dist/server/server/services/github-service.js +145 -0
- package/dist/server/server/services/readiness-service.js +184 -0
- package/dist/server/server/services/scope-cache.js +72 -0
- package/dist/server/server/services/scope-service.js +424 -0
- package/dist/server/server/services/sprint-orchestrator.js +312 -0
- package/dist/server/server/services/sprint-service.js +293 -0
- package/dist/server/server/services/workflow-service.js +397 -0
- package/dist/server/server/utils/cc-hooks-parser.js +49 -0
- package/dist/server/server/utils/dispatch-utils.js +305 -0
- package/dist/server/server/utils/logger.js +86 -0
- package/dist/server/server/utils/terminal-launcher.js +388 -0
- package/dist/server/server/utils/worktree-manager.js +98 -0
- package/dist/server/server/watchers/event-watcher.js +81 -0
- package/dist/server/server/watchers/scope-watcher.js +33 -0
- package/dist/server/shared/api-types.js +5 -0
- package/dist/server/shared/default-workflow.json +616 -0
- package/dist/server/shared/workflow-config.js +44 -0
- package/dist/server/shared/workflow-engine.js +353 -0
- package/index.html +15 -0
- package/package.json +110 -0
- package/postcss.config.js +6 -0
- package/schemas/orbital.config.schema.json +83 -0
- package/scripts/postinstall.js +24 -0
- package/scripts/start.sh +20 -0
- package/server/adapters/index.ts +41 -0
- package/server/adapters/iterm2-adapter.ts +37 -0
- package/server/adapters/subprocess-adapter.ts +25 -0
- package/server/adapters/terminal-adapter.ts +24 -0
- package/server/config.ts +234 -0
- package/server/database.ts +107 -0
- package/server/index.ts +452 -0
- package/server/init.ts +891 -0
- package/server/parsers/event-parser.ts +74 -0
- package/server/parsers/scope-parser.ts +240 -0
- package/server/routes/config-routes.ts +182 -0
- package/server/routes/data-routes.ts +548 -0
- package/server/routes/dispatch-routes.ts +275 -0
- package/server/routes/git-routes.ts +112 -0
- package/server/routes/scope-routes.ts +262 -0
- package/server/routes/sprint-routes.ts +142 -0
- package/server/routes/version-routes.ts +156 -0
- package/server/routes/workflow-routes.ts +198 -0
- package/server/schema.ts +90 -0
- package/server/services/batch-orchestrator.ts +286 -0
- package/server/services/claude-session-service.ts +441 -0
- package/server/services/config-service.ts +151 -0
- package/server/services/deploy-service.ts +98 -0
- package/server/services/event-service.ts +98 -0
- package/server/services/gate-service.ts +126 -0
- package/server/services/git-service.ts +391 -0
- package/server/services/github-service.ts +183 -0
- package/server/services/readiness-service.ts +250 -0
- package/server/services/scope-cache.ts +81 -0
- package/server/services/scope-service.ts +476 -0
- package/server/services/sprint-orchestrator.ts +361 -0
- package/server/services/sprint-service.ts +415 -0
- package/server/services/workflow-service.ts +461 -0
- package/server/utils/cc-hooks-parser.ts +70 -0
- package/server/utils/dispatch-utils.ts +395 -0
- package/server/utils/logger.ts +109 -0
- package/server/utils/terminal-launcher.ts +462 -0
- package/server/utils/worktree-manager.ts +104 -0
- package/server/watchers/event-watcher.ts +100 -0
- package/server/watchers/scope-watcher.ts +38 -0
- package/shared/api-types.ts +20 -0
- package/shared/default-workflow.json +616 -0
- package/shared/workflow-config.ts +170 -0
- package/shared/workflow-engine.ts +427 -0
- package/src/App.tsx +33 -0
- package/src/components/AgentBadge.tsx +40 -0
- package/src/components/BatchPreflightModal.tsx +115 -0
- package/src/components/CardDisplayToggle.tsx +74 -0
- package/src/components/ColumnHeaderActions.tsx +55 -0
- package/src/components/ColumnMenu.tsx +99 -0
- package/src/components/DeployHistory.tsx +141 -0
- package/src/components/DispatchModal.tsx +164 -0
- package/src/components/DispatchPopover.tsx +139 -0
- package/src/components/DragOverlay.tsx +25 -0
- package/src/components/DriftSidebar.tsx +140 -0
- package/src/components/EnvironmentStrip.tsx +88 -0
- package/src/components/ErrorBoundary.tsx +62 -0
- package/src/components/FilterChip.tsx +105 -0
- package/src/components/GateIndicator.tsx +33 -0
- package/src/components/IdeaDetailModal.tsx +190 -0
- package/src/components/IdeaFormDialog.tsx +113 -0
- package/src/components/KanbanColumn.tsx +201 -0
- package/src/components/MarkdownRenderer.tsx +114 -0
- package/src/components/NeonGrid.tsx +128 -0
- package/src/components/PromotionQueue.tsx +89 -0
- package/src/components/ScopeCard.tsx +234 -0
- package/src/components/ScopeDetailModal.tsx +255 -0
- package/src/components/ScopeFilterBar.tsx +152 -0
- package/src/components/SearchInput.tsx +102 -0
- package/src/components/SessionPanel.tsx +335 -0
- package/src/components/SprintContainer.tsx +303 -0
- package/src/components/SprintDependencyDialog.tsx +78 -0
- package/src/components/SprintPreflightModal.tsx +138 -0
- package/src/components/StatusBar.tsx +168 -0
- package/src/components/SwimCell.tsx +67 -0
- package/src/components/SwimLaneRow.tsx +94 -0
- package/src/components/SwimlaneBoardView.tsx +108 -0
- package/src/components/VersionBadge.tsx +139 -0
- package/src/components/ViewModeSelector.tsx +114 -0
- package/src/components/config/AgentChip.tsx +53 -0
- package/src/components/config/AgentCreateDialog.tsx +321 -0
- package/src/components/config/AgentEditor.tsx +175 -0
- package/src/components/config/DirectoryTree.tsx +582 -0
- package/src/components/config/FileEditor.tsx +550 -0
- package/src/components/config/HookChip.tsx +50 -0
- package/src/components/config/StageCard.tsx +198 -0
- package/src/components/config/TransitionZone.tsx +173 -0
- package/src/components/config/UnifiedWorkflowPipeline.tsx +216 -0
- package/src/components/config/WorkflowPipeline.tsx +161 -0
- package/src/components/source-control/BranchList.tsx +93 -0
- package/src/components/source-control/BranchPanel.tsx +105 -0
- package/src/components/source-control/CommitLog.tsx +100 -0
- package/src/components/source-control/CommitRow.tsx +47 -0
- package/src/components/source-control/GitHubPanel.tsx +110 -0
- package/src/components/source-control/GitHubSetupGuide.tsx +52 -0
- package/src/components/source-control/GitOverviewBar.tsx +101 -0
- package/src/components/source-control/PullRequestList.tsx +69 -0
- package/src/components/source-control/WorktreeList.tsx +80 -0
- package/src/components/ui/badge.tsx +41 -0
- package/src/components/ui/button.tsx +55 -0
- package/src/components/ui/card.tsx +78 -0
- package/src/components/ui/dialog.tsx +94 -0
- package/src/components/ui/popover.tsx +33 -0
- package/src/components/ui/scroll-area.tsx +54 -0
- package/src/components/ui/separator.tsx +28 -0
- package/src/components/ui/tabs.tsx +52 -0
- package/src/components/ui/toggle-switch.tsx +35 -0
- package/src/components/ui/tooltip.tsx +27 -0
- package/src/components/workflow/AddEdgeDialog.tsx +217 -0
- package/src/components/workflow/AddListDialog.tsx +201 -0
- package/src/components/workflow/ChecklistEditor.tsx +239 -0
- package/src/components/workflow/CommandPrefixManager.tsx +118 -0
- package/src/components/workflow/ConfigSettingsPanel.tsx +189 -0
- package/src/components/workflow/DirectionSelector.tsx +133 -0
- package/src/components/workflow/DispatchConfigPanel.tsx +180 -0
- package/src/components/workflow/EdgeDetailPanel.tsx +236 -0
- package/src/components/workflow/EdgePropertyEditor.tsx +251 -0
- package/src/components/workflow/EditToolbar.tsx +138 -0
- package/src/components/workflow/HookDetailPanel.tsx +250 -0
- package/src/components/workflow/HookExecutionLog.tsx +24 -0
- package/src/components/workflow/HookSourceModal.tsx +129 -0
- package/src/components/workflow/HooksDashboard.tsx +363 -0
- package/src/components/workflow/ListPropertyEditor.tsx +251 -0
- package/src/components/workflow/MigrationPreviewDialog.tsx +237 -0
- package/src/components/workflow/MovementRulesPanel.tsx +188 -0
- package/src/components/workflow/NodeDetailPanel.tsx +245 -0
- package/src/components/workflow/PresetSelector.tsx +414 -0
- package/src/components/workflow/SkillCommandBuilder.tsx +174 -0
- package/src/components/workflow/WorkflowEdgeComponent.tsx +145 -0
- package/src/components/workflow/WorkflowNode.tsx +147 -0
- package/src/components/workflow/graphLayout.ts +186 -0
- package/src/components/workflow/mergeHooks.ts +85 -0
- package/src/components/workflow/useEditHistory.ts +88 -0
- package/src/components/workflow/useWorkflowEditor.ts +262 -0
- package/src/components/workflow/validateConfig.ts +70 -0
- package/src/hooks/useActiveDispatches.ts +198 -0
- package/src/hooks/useBoardSettings.ts +170 -0
- package/src/hooks/useCardDisplay.ts +57 -0
- package/src/hooks/useCcHooks.ts +24 -0
- package/src/hooks/useConfigTree.ts +51 -0
- package/src/hooks/useEnforcementRules.ts +46 -0
- package/src/hooks/useEvents.ts +59 -0
- package/src/hooks/useFileEditor.ts +165 -0
- package/src/hooks/useGates.ts +57 -0
- package/src/hooks/useIdeaActions.ts +53 -0
- package/src/hooks/useKanbanDnd.ts +410 -0
- package/src/hooks/useOrbitalConfig.ts +54 -0
- package/src/hooks/usePipeline.ts +47 -0
- package/src/hooks/usePipelineData.ts +338 -0
- package/src/hooks/useReconnect.ts +25 -0
- package/src/hooks/useScopeFilters.ts +125 -0
- package/src/hooks/useScopeSessions.ts +44 -0
- package/src/hooks/useScopes.ts +67 -0
- package/src/hooks/useSearch.ts +67 -0
- package/src/hooks/useSettings.tsx +187 -0
- package/src/hooks/useSocket.ts +25 -0
- package/src/hooks/useSourceControl.ts +105 -0
- package/src/hooks/useSprintPreflight.ts +55 -0
- package/src/hooks/useSprints.ts +154 -0
- package/src/hooks/useStatusBarHighlight.ts +18 -0
- package/src/hooks/useSwimlaneBoardSettings.ts +104 -0
- package/src/hooks/useTheme.ts +9 -0
- package/src/hooks/useTransitionReadiness.ts +53 -0
- package/src/hooks/useVersion.ts +155 -0
- package/src/hooks/useViolations.ts +65 -0
- package/src/hooks/useWorkflow.tsx +125 -0
- package/src/hooks/useZoomModifier.ts +19 -0
- package/src/index.css +797 -0
- package/src/layouts/DashboardLayout.tsx +113 -0
- package/src/lib/collisionDetection.ts +20 -0
- package/src/lib/scope-fields.ts +61 -0
- package/src/lib/swimlane.ts +146 -0
- package/src/lib/utils.ts +15 -0
- package/src/main.tsx +19 -0
- package/src/socket.ts +11 -0
- package/src/types/index.ts +497 -0
- package/src/views/AgentFeed.tsx +339 -0
- package/src/views/DeployPipeline.tsx +59 -0
- package/src/views/EnforcementView.tsx +378 -0
- package/src/views/PrimitivesConfig.tsx +500 -0
- package/src/views/QualityGates.tsx +1012 -0
- package/src/views/ScopeBoard.tsx +454 -0
- package/src/views/SessionTimeline.tsx +516 -0
- package/src/views/Settings.tsx +183 -0
- package/src/views/SourceControl.tsx +95 -0
- package/src/views/WorkflowVisualizer.tsx +382 -0
- package/tailwind.config.js +161 -0
- package/templates/agents/AUTO-INVOKE.md +180 -0
- package/templates/agents/CONFLICT-RESOLUTION.md +128 -0
- package/templates/agents/QUICK-REFERENCE.md +122 -0
- package/templates/agents/README.md +188 -0
- package/templates/agents/SKILL-TRIGGERS.md +100 -0
- package/templates/agents/blue-team/frontend-designer.md +424 -0
- package/templates/agents/green-team/architect.md +526 -0
- package/templates/agents/green-team/rules-enforcer.md +131 -0
- package/templates/agents/red-team/attacker-learned.md +24 -0
- package/templates/agents/red-team/attacker.md +486 -0
- package/templates/agents/red-team/chaos.md +548 -0
- package/templates/agents/reference/component-registry.md +82 -0
- package/templates/agents/workflows/full-mode.md +218 -0
- package/templates/agents/workflows/quick-mode.md +118 -0
- package/templates/agents/workflows/security-mode.md +283 -0
- package/templates/anti-patterns/dangerous-shortcuts.md +427 -0
- package/templates/config/agent-triggers.json +92 -0
- package/templates/hooks/agent-team-gate.sh +31 -0
- package/templates/hooks/agent-trigger.sh +97 -0
- package/templates/hooks/block-push.sh +66 -0
- package/templates/hooks/block-workarounds.sh +61 -0
- package/templates/hooks/blocker-check.sh +28 -0
- package/templates/hooks/completion-checklist.sh +28 -0
- package/templates/hooks/decision-capture.sh +15 -0
- package/templates/hooks/dependency-check.sh +27 -0
- package/templates/hooks/end-session.sh +31 -0
- package/templates/hooks/exploration-logger.sh +37 -0
- package/templates/hooks/files-changed-summary.sh +37 -0
- package/templates/hooks/get-session-id.sh +49 -0
- package/templates/hooks/git-commit-guard.sh +34 -0
- package/templates/hooks/init-session.sh +93 -0
- package/templates/hooks/orbital-emit.sh +79 -0
- package/templates/hooks/orbital-report-deploy.sh +78 -0
- package/templates/hooks/orbital-report-gates.sh +40 -0
- package/templates/hooks/orbital-report-violation.sh +36 -0
- package/templates/hooks/orbital-scope-update.sh +53 -0
- package/templates/hooks/phase-verify-reminder.sh +26 -0
- package/templates/hooks/review-gate-check.sh +82 -0
- package/templates/hooks/scope-commit-logger.sh +37 -0
- package/templates/hooks/scope-create-cleanup.sh +36 -0
- package/templates/hooks/scope-create-gate.sh +80 -0
- package/templates/hooks/scope-create-tracker.sh +17 -0
- package/templates/hooks/scope-file-sync.sh +53 -0
- package/templates/hooks/scope-gate.sh +35 -0
- package/templates/hooks/scope-helpers.sh +188 -0
- package/templates/hooks/scope-lifecycle-gate.sh +139 -0
- package/templates/hooks/scope-prepare.sh +244 -0
- package/templates/hooks/scope-transition.sh +172 -0
- package/templates/hooks/session-enforcer.sh +143 -0
- package/templates/hooks/time-tracker.sh +33 -0
- package/templates/lessons-learned.md +15 -0
- package/templates/orbital.config.json +35 -0
- package/templates/presets/development.json +42 -0
- package/templates/presets/gitflow.json +712 -0
- package/templates/presets/minimal.json +23 -0
- package/templates/quick/rules.md +218 -0
- package/templates/scopes/_template.md +255 -0
- package/templates/settings-hooks.json +98 -0
- package/templates/skills/git-commit/SKILL.md +85 -0
- package/templates/skills/git-dev/SKILL.md +99 -0
- package/templates/skills/git-hotfix/SKILL.md +223 -0
- package/templates/skills/git-main/SKILL.md +84 -0
- package/templates/skills/git-production/SKILL.md +165 -0
- package/templates/skills/git-staging/SKILL.md +112 -0
- package/templates/skills/scope-create/SKILL.md +81 -0
- package/templates/skills/scope-fix-review/SKILL.md +168 -0
- package/templates/skills/scope-implement/SKILL.md +110 -0
- package/templates/skills/scope-post-review/SKILL.md +144 -0
- package/templates/skills/scope-pre-review/SKILL.md +211 -0
- package/templates/skills/scope-verify/SKILL.md +201 -0
- package/templates/skills/session-init/SKILL.md +62 -0
- package/templates/skills/session-resume/SKILL.md +201 -0
- package/templates/skills/test-checks/SKILL.md +171 -0
- package/templates/skills/test-code-review/SKILL.md +252 -0
- package/tsconfig.json +25 -0
- package/vite.config.ts +38 -0
|
@@ -0,0 +1,516 @@
|
|
|
1
|
+
import { useEffect, useState, useCallback, useRef } from 'react';
|
|
2
|
+
import { motion } from 'framer-motion';
|
|
3
|
+
import { Clock, ExternalLink, FileText, Terminal } from 'lucide-react';
|
|
4
|
+
import { format } from 'date-fns';
|
|
5
|
+
import { socket } from '@/socket';
|
|
6
|
+
import { useTheme } from '@/hooks/useTheme';
|
|
7
|
+
import { Badge } from '@/components/ui/badge';
|
|
8
|
+
import { Button } from '@/components/ui/button';
|
|
9
|
+
import { ScrollArea } from '@/components/ui/scroll-area';
|
|
10
|
+
import { Separator } from '@/components/ui/separator';
|
|
11
|
+
import { cn, formatScopeId } from '@/lib/utils';
|
|
12
|
+
import type { Session } from '@/types';
|
|
13
|
+
|
|
14
|
+
const sessionStagger = { show: { transition: { staggerChildren: 0.04 } } };
|
|
15
|
+
const sessionItem = {
|
|
16
|
+
hidden: { opacity: 0, y: 10 },
|
|
17
|
+
show: { opacity: 1, y: 0, transition: { type: 'spring', stiffness: 300, damping: 25 } },
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
interface SessionMeta {
|
|
21
|
+
slug: string;
|
|
22
|
+
branch: string;
|
|
23
|
+
fileSize: number;
|
|
24
|
+
summary: string | null;
|
|
25
|
+
startedAt: string;
|
|
26
|
+
lastActiveAt: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
interface SessionStatsUser {
|
|
30
|
+
totalMessages: number;
|
|
31
|
+
metaMessages: number;
|
|
32
|
+
toolResults: number;
|
|
33
|
+
commands: string[];
|
|
34
|
+
permissionModes: string[];
|
|
35
|
+
cwd: string | null;
|
|
36
|
+
version: string | null;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
interface SessionStatsAssistant {
|
|
40
|
+
totalMessages: number;
|
|
41
|
+
models: string[];
|
|
42
|
+
totalInputTokens: number;
|
|
43
|
+
totalOutputTokens: number;
|
|
44
|
+
totalCacheReadTokens: number;
|
|
45
|
+
totalCacheCreationTokens: number;
|
|
46
|
+
toolsUsed: Record<string, number>;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
interface SessionStatsSystem {
|
|
50
|
+
totalMessages: number;
|
|
51
|
+
subtypes: string[];
|
|
52
|
+
stopReasons: string[];
|
|
53
|
+
totalDurationMs: number;
|
|
54
|
+
hookCount: number;
|
|
55
|
+
hookErrors: number;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
interface SessionStats {
|
|
59
|
+
typeCounts: Record<string, number>;
|
|
60
|
+
user: SessionStatsUser;
|
|
61
|
+
assistant: SessionStatsAssistant;
|
|
62
|
+
system: SessionStatsSystem;
|
|
63
|
+
progress: { totalLines: number };
|
|
64
|
+
timing: { firstTimestamp: string | null; lastTimestamp: string | null; durationMs: number };
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
interface SessionDetail {
|
|
68
|
+
id: string;
|
|
69
|
+
content: string;
|
|
70
|
+
claude_session_id: string | null;
|
|
71
|
+
meta: SessionMeta | null;
|
|
72
|
+
stats: SessionStats | null;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** Session with aggregated scope_ids and actions from deduplicated backend response */
|
|
76
|
+
interface TimelineSession extends Session {
|
|
77
|
+
scope_ids: number[];
|
|
78
|
+
actions: string[];
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const ACTION_LABELS: Record<string, string> = {
|
|
82
|
+
createScope: 'Created',
|
|
83
|
+
reviewScope: 'Reviewed',
|
|
84
|
+
implementScope: 'Implemented',
|
|
85
|
+
verifyScope: 'Verified',
|
|
86
|
+
reviewGate: 'Review Gate',
|
|
87
|
+
fixReview: 'Fix Review',
|
|
88
|
+
commit: 'Committed',
|
|
89
|
+
pushToMain: 'Pushed to Main',
|
|
90
|
+
pushToDev: 'Pushed to Dev',
|
|
91
|
+
pushToStaging: 'PR to Staging',
|
|
92
|
+
pushToProduction: 'PR to Production',
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
function actionLabel(action: string): string {
|
|
96
|
+
return ACTION_LABELS[action] ?? action;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// ─── Main Component ────────────────────────────────────────
|
|
100
|
+
|
|
101
|
+
export function SessionTimeline() {
|
|
102
|
+
const [sessions, setSessions] = useState<TimelineSession[]>([]);
|
|
103
|
+
const [loading, setLoading] = useState(true);
|
|
104
|
+
const [selected, setSelected] = useState<TimelineSession | null>(null);
|
|
105
|
+
const [detail, setDetail] = useState<SessionDetail | null>(null);
|
|
106
|
+
const [detailLoading, setDetailLoading] = useState(false);
|
|
107
|
+
const [resuming, setResuming] = useState(false);
|
|
108
|
+
const { neonGlass } = useTheme();
|
|
109
|
+
const autoSelected = useRef(false);
|
|
110
|
+
|
|
111
|
+
const selectSession = useCallback(async (session: TimelineSession) => {
|
|
112
|
+
setSelected(session);
|
|
113
|
+
setDetail(null);
|
|
114
|
+
setDetailLoading(true);
|
|
115
|
+
try {
|
|
116
|
+
const res = await fetch(`/api/orbital/sessions/${session.id}/content`);
|
|
117
|
+
if (res.ok) setDetail(await res.json());
|
|
118
|
+
} catch { /* silent */ }
|
|
119
|
+
finally { setDetailLoading(false); }
|
|
120
|
+
}, []);
|
|
121
|
+
|
|
122
|
+
const fetchSessions = useCallback(async () => {
|
|
123
|
+
try {
|
|
124
|
+
const res = await fetch('/api/orbital/sessions');
|
|
125
|
+
if (res.ok) setSessions(await res.json());
|
|
126
|
+
} catch { /* silent */ }
|
|
127
|
+
finally { setLoading(false); }
|
|
128
|
+
}, []);
|
|
129
|
+
|
|
130
|
+
useEffect(() => { fetchSessions(); }, [fetchSessions]);
|
|
131
|
+
|
|
132
|
+
// Auto-select first session on initial load
|
|
133
|
+
useEffect(() => {
|
|
134
|
+
if (!autoSelected.current && sessions.length > 0) {
|
|
135
|
+
autoSelected.current = true;
|
|
136
|
+
selectSession(sessions[0]);
|
|
137
|
+
}
|
|
138
|
+
}, [sessions, selectSession]);
|
|
139
|
+
|
|
140
|
+
useEffect(() => {
|
|
141
|
+
const onUpdate = () => fetchSessions();
|
|
142
|
+
socket.on('session:updated', onUpdate);
|
|
143
|
+
return () => { socket.off('session:updated', onUpdate); };
|
|
144
|
+
}, [fetchSessions]);
|
|
145
|
+
|
|
146
|
+
const handleResume = useCallback(async () => {
|
|
147
|
+
const sessionId = detail?.claude_session_id;
|
|
148
|
+
if (!selected || !sessionId) return;
|
|
149
|
+
setResuming(true);
|
|
150
|
+
try {
|
|
151
|
+
await fetch(`/api/orbital/sessions/${selected.id}/resume`, {
|
|
152
|
+
method: 'POST',
|
|
153
|
+
headers: { 'Content-Type': 'application/json' },
|
|
154
|
+
body: JSON.stringify({ claude_session_id: sessionId }),
|
|
155
|
+
});
|
|
156
|
+
} catch { /* silent */ }
|
|
157
|
+
finally { setTimeout(() => setResuming(false), 2000); }
|
|
158
|
+
}, [selected, detail]);
|
|
159
|
+
|
|
160
|
+
if (loading) {
|
|
161
|
+
return (
|
|
162
|
+
<div className="flex h-64 items-center justify-center">
|
|
163
|
+
<div className="h-8 w-8 animate-spin rounded-full border-2 border-primary border-t-transparent" />
|
|
164
|
+
</div>
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
return (
|
|
169
|
+
<div className="flex flex-1 min-h-0 flex-col">
|
|
170
|
+
<div className="mb-4 flex items-center gap-3">
|
|
171
|
+
<Clock className="h-4 w-4 text-primary" />
|
|
172
|
+
<h1 className="text-xl font-light">Sessions</h1>
|
|
173
|
+
<Badge variant="secondary">{sessions.length} sessions</Badge>
|
|
174
|
+
</div>
|
|
175
|
+
|
|
176
|
+
{sessions.length === 0 ? (
|
|
177
|
+
<div className="flex flex-1 items-center justify-center">
|
|
178
|
+
<div className="text-center">
|
|
179
|
+
<Clock className="mx-auto mb-3 h-10 w-10 text-muted-foreground/30" />
|
|
180
|
+
<p className="text-sm text-muted-foreground">
|
|
181
|
+
No session history yet. Sessions are recorded from handoff files.
|
|
182
|
+
</p>
|
|
183
|
+
</div>
|
|
184
|
+
</div>
|
|
185
|
+
) : (
|
|
186
|
+
<div className="flex flex-1 gap-0 overflow-hidden rounded-lg border border-border/50">
|
|
187
|
+
{/* Left: session list */}
|
|
188
|
+
<div className="w-[40%] border-r border-border/50 overflow-hidden">
|
|
189
|
+
<ScrollArea className="h-full">
|
|
190
|
+
<div className="relative p-3">
|
|
191
|
+
<div className="absolute left-6 top-3 bottom-3 w-px bg-border" />
|
|
192
|
+
{neonGlass ? (
|
|
193
|
+
<motion.div className="space-y-1" variants={sessionStagger} initial="hidden" animate="show">
|
|
194
|
+
{sessions.map((s) => (
|
|
195
|
+
<motion.div key={s.id} variants={sessionItem}>
|
|
196
|
+
<SessionListItem session={s} isSelected={selected?.id === s.id} neonGlass onClick={() => selectSession(s)} />
|
|
197
|
+
</motion.div>
|
|
198
|
+
))}
|
|
199
|
+
</motion.div>
|
|
200
|
+
) : (
|
|
201
|
+
<div className="space-y-1">
|
|
202
|
+
{sessions.map((s) => (
|
|
203
|
+
<SessionListItem key={s.id} session={s} isSelected={selected?.id === s.id} neonGlass={false} onClick={() => selectSession(s)} />
|
|
204
|
+
))}
|
|
205
|
+
</div>
|
|
206
|
+
)}
|
|
207
|
+
</div>
|
|
208
|
+
</ScrollArea>
|
|
209
|
+
</div>
|
|
210
|
+
|
|
211
|
+
{/* Right: detail pane */}
|
|
212
|
+
<div className="w-[60%] overflow-hidden">
|
|
213
|
+
{selected ? (
|
|
214
|
+
<DetailPane session={selected} detail={detail} loading={detailLoading} resuming={resuming} onResume={handleResume} />
|
|
215
|
+
) : (
|
|
216
|
+
<div className="flex h-full items-center justify-center">
|
|
217
|
+
<div className="text-center">
|
|
218
|
+
<Clock className="mx-auto mb-3 h-10 w-10 text-muted-foreground/30" />
|
|
219
|
+
<p className="text-sm text-muted-foreground">Select a session to view details</p>
|
|
220
|
+
</div>
|
|
221
|
+
</div>
|
|
222
|
+
)}
|
|
223
|
+
</div>
|
|
224
|
+
</div>
|
|
225
|
+
)}
|
|
226
|
+
</div>
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
// ─── Session List Item ─────────────────────────────────────
|
|
231
|
+
|
|
232
|
+
function SessionListItem({ session, isSelected, neonGlass, onClick }: {
|
|
233
|
+
session: TimelineSession; isSelected: boolean; neonGlass: boolean; onClick: () => void;
|
|
234
|
+
}) {
|
|
235
|
+
const scopeIds = session.scope_ids;
|
|
236
|
+
const discoveries = Array.isArray(session.discoveries) ? session.discoveries : [];
|
|
237
|
+
const nextSteps = Array.isArray(session.next_steps) ? session.next_steps : [];
|
|
238
|
+
|
|
239
|
+
return (
|
|
240
|
+
<div className="relative pl-8 cursor-pointer" onClick={onClick}>
|
|
241
|
+
<div className={cn(
|
|
242
|
+
'absolute left-1.5 top-3 h-2.5 w-2.5 rounded-full border-2',
|
|
243
|
+
isSelected ? 'border-primary bg-primary' : 'border-muted-foreground/40 bg-background',
|
|
244
|
+
neonGlass && 'timeline-dot-glow glow-blue',
|
|
245
|
+
)} />
|
|
246
|
+
<div className={cn(
|
|
247
|
+
'rounded-md px-3 py-2 transition-colors',
|
|
248
|
+
isSelected ? 'bg-primary/10 border border-primary/30' : 'hover:bg-muted/50',
|
|
249
|
+
)}>
|
|
250
|
+
<div className="flex items-center gap-1.5 flex-wrap">
|
|
251
|
+
{session.started_at && (
|
|
252
|
+
<span className="text-xxs text-muted-foreground">{format(new Date(session.started_at), 'MMM d')}</span>
|
|
253
|
+
)}
|
|
254
|
+
{scopeIds.slice(0, 3).map((id) => (
|
|
255
|
+
<Badge key={id} variant="outline" className="font-mono text-xxs px-1 py-0">{formatScopeId(id)}</Badge>
|
|
256
|
+
))}
|
|
257
|
+
{scopeIds.length > 3 && (
|
|
258
|
+
<span className="text-xxs text-muted-foreground">+{scopeIds.length - 3}</span>
|
|
259
|
+
)}
|
|
260
|
+
{session.actions?.slice(0, 2).map((a) => (
|
|
261
|
+
<Badge key={a} variant="secondary" className="text-xxs px-1 py-0 font-light">{actionLabel(a)}</Badge>
|
|
262
|
+
))}
|
|
263
|
+
</div>
|
|
264
|
+
<p className={cn('mt-0.5 text-xs font-normal truncate', isSelected ? 'text-foreground' : 'text-foreground/80')}>
|
|
265
|
+
{session.summary ? truncate(session.summary, 80) : 'Untitled Session'}
|
|
266
|
+
</p>
|
|
267
|
+
<div className="mt-1 flex items-center gap-3 text-xxs text-muted-foreground">
|
|
268
|
+
{discoveries.length > 0 && <span className="text-bid-green">{discoveries.length} completed</span>}
|
|
269
|
+
{nextSteps.length > 0 && <span className="text-accent-blue">{nextSteps.length} next</span>}
|
|
270
|
+
</div>
|
|
271
|
+
</div>
|
|
272
|
+
</div>
|
|
273
|
+
);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
// ─── Detail Pane ───────────────────────────────────────────
|
|
277
|
+
|
|
278
|
+
function DetailPane({ session, detail, loading, resuming, onResume }: {
|
|
279
|
+
session: TimelineSession; detail: SessionDetail | null; loading: boolean; resuming: boolean; onResume: () => void;
|
|
280
|
+
}) {
|
|
281
|
+
const scopeIds = session.scope_ids;
|
|
282
|
+
const discoveries = Array.isArray(session.discoveries) ? session.discoveries : [];
|
|
283
|
+
const nextSteps = Array.isArray(session.next_steps) ? session.next_steps : [];
|
|
284
|
+
const meta = detail?.meta ?? null;
|
|
285
|
+
const canResume = !!detail?.claude_session_id;
|
|
286
|
+
const displayName = meta?.summary ?? session.summary ?? null;
|
|
287
|
+
|
|
288
|
+
// Build metadata rows as [label, value, className?, actionUrl?] tuples
|
|
289
|
+
const rows: [string, string, string?, string?][] = [];
|
|
290
|
+
if (scopeIds.length > 0) rows.push(['Scopes', scopeIds.map((id) => formatScopeId(id)).join(', ')]);
|
|
291
|
+
if (session.actions?.length > 0) rows.push(['Actions', session.actions.map(actionLabel).join(', ')]);
|
|
292
|
+
if (session.summary) rows.push(['Summary', truncate(session.summary, 200)]);
|
|
293
|
+
rows.push(['Started', session.started_at ? format(new Date(session.started_at), 'MMM d, h:mm a') : '—']);
|
|
294
|
+
rows.push(['Ended', session.ended_at ? format(new Date(session.ended_at), 'MMM d, h:mm a') : '—']);
|
|
295
|
+
if (meta?.branch && meta.branch !== 'unknown') rows.push(['Branch', meta.branch, 'font-mono text-xxs']);
|
|
296
|
+
if (meta && meta.fileSize > 0) rows.push(['File size', formatFileSize(meta.fileSize)]);
|
|
297
|
+
if (meta) rows.push(['Plan', meta.slug, 'text-muted-foreground', `/api/orbital/open-file?path=scopes/${meta.slug}.md`]);
|
|
298
|
+
if (session.handoff_file) rows.push(['Handoff', session.handoff_file, 'font-mono text-xxs']);
|
|
299
|
+
if (detail?.claude_session_id) rows.push(['Session ID', detail.claude_session_id, 'font-mono text-xxs text-muted-foreground']);
|
|
300
|
+
|
|
301
|
+
return (
|
|
302
|
+
<div className="flex h-full flex-col">
|
|
303
|
+
<div className="px-5 pt-4 pb-3">
|
|
304
|
+
<p className="text-xxs text-muted-foreground">
|
|
305
|
+
{session.started_at && format(new Date(session.started_at), 'MMM d, yyyy — h:mm a')}
|
|
306
|
+
{scopeIds.length > 0 && scopeIds.slice(0, 4).map((id) => (
|
|
307
|
+
<span key={id} className="ml-1.5">
|
|
308
|
+
<Badge variant="outline" className="font-mono text-xxs">{formatScopeId(id)}</Badge>
|
|
309
|
+
</span>
|
|
310
|
+
))}
|
|
311
|
+
{scopeIds.length > 4 && <span className="ml-1 text-xxs">+{scopeIds.length - 4}</span>}
|
|
312
|
+
</p>
|
|
313
|
+
<h2 className="mt-1 text-sm font-light">{displayName ? truncate(displayName, 120) : 'Untitled Session'}</h2>
|
|
314
|
+
</div>
|
|
315
|
+
|
|
316
|
+
<Separator />
|
|
317
|
+
|
|
318
|
+
<ScrollArea className="flex-1">
|
|
319
|
+
<div className="px-5 py-4">
|
|
320
|
+
{loading ? (
|
|
321
|
+
<div className="flex h-20 items-center justify-center">
|
|
322
|
+
<div className="h-5 w-5 animate-spin rounded-full border-2 border-primary border-t-transparent" />
|
|
323
|
+
</div>
|
|
324
|
+
) : (
|
|
325
|
+
<>
|
|
326
|
+
<table className="w-full table-fixed text-xs">
|
|
327
|
+
<colgroup><col className="w-28" /><col /></colgroup>
|
|
328
|
+
<tbody className="[&_td]:border-b [&_td]:border-border/30 [&_td]:py-2 [&_td]:align-top [&_td:first-child]:pr-3 [&_td:first-child]:text-muted-foreground [&_td:first-child]:whitespace-nowrap [&_td:last-child]:break-all">
|
|
329
|
+
{rows.map(([label, value, cls, action]) => (
|
|
330
|
+
<tr key={label}>
|
|
331
|
+
<td>{label}</td>
|
|
332
|
+
<td className={cls}>
|
|
333
|
+
{action ? (
|
|
334
|
+
<button
|
|
335
|
+
onClick={() => { fetch(action, { method: 'POST' }); }}
|
|
336
|
+
className="inline-flex items-center gap-1.5 hover:text-accent-blue transition-colors"
|
|
337
|
+
title="Open file"
|
|
338
|
+
>
|
|
339
|
+
{value}
|
|
340
|
+
<ExternalLink className="h-3 w-3 opacity-50" />
|
|
341
|
+
</button>
|
|
342
|
+
) : value}
|
|
343
|
+
</td>
|
|
344
|
+
</tr>
|
|
345
|
+
))}
|
|
346
|
+
</tbody>
|
|
347
|
+
</table>
|
|
348
|
+
|
|
349
|
+
<BulletSection title="Completed" items={discoveries} color="text-bid-green" />
|
|
350
|
+
<BulletSection title="Next Steps" items={nextSteps} color="text-accent-blue" />
|
|
351
|
+
|
|
352
|
+
{detail?.stats && <StatsSection stats={detail.stats} />}
|
|
353
|
+
|
|
354
|
+
{session.handoff_file && (
|
|
355
|
+
<div className="mt-4 flex items-center gap-1.5 text-xxs text-muted-foreground/60">
|
|
356
|
+
<FileText className="h-3 w-3" />
|
|
357
|
+
<span className="truncate">{session.handoff_file}</span>
|
|
358
|
+
</div>
|
|
359
|
+
)}
|
|
360
|
+
</>
|
|
361
|
+
)}
|
|
362
|
+
</div>
|
|
363
|
+
</ScrollArea>
|
|
364
|
+
|
|
365
|
+
{!loading && (
|
|
366
|
+
<div className="border-t border-border/50 px-5 py-3">
|
|
367
|
+
<Button className="w-full" disabled={!canResume || resuming} onClick={onResume}
|
|
368
|
+
title={canResume ? 'Open in iTerm' : 'No Claude Code session found'}>
|
|
369
|
+
<Terminal className="mr-2 h-4 w-4" />
|
|
370
|
+
{resuming ? 'Opening iTerm...' : 'Resume Session'}
|
|
371
|
+
</Button>
|
|
372
|
+
{!canResume && <p className="mt-1.5 text-center text-xxs text-muted-foreground">No matching Claude Code session found</p>}
|
|
373
|
+
</div>
|
|
374
|
+
)}
|
|
375
|
+
</div>
|
|
376
|
+
);
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
// ─── Stats Section ─────────────────────────────────────────
|
|
380
|
+
|
|
381
|
+
function StatsSection({ stats }: { stats: SessionStats }) {
|
|
382
|
+
const { user, assistant, system, timing } = stats;
|
|
383
|
+
const toolEntries = Object.entries(assistant.toolsUsed).sort((a, b) => b[1] - a[1]);
|
|
384
|
+
|
|
385
|
+
return (
|
|
386
|
+
<div className="mt-5 space-y-4">
|
|
387
|
+
<Separator />
|
|
388
|
+
|
|
389
|
+
{/* Timing */}
|
|
390
|
+
<StatsGroup title="Timing">
|
|
391
|
+
{timing.durationMs > 0 && <StatsRow label="Duration" value={formatDuration(timing.durationMs)} />}
|
|
392
|
+
{timing.firstTimestamp && <StatsRow label="First event" value={format(new Date(timing.firstTimestamp), 'MMM d, h:mm:ss a')} />}
|
|
393
|
+
{timing.lastTimestamp && <StatsRow label="Last event" value={format(new Date(timing.lastTimestamp), 'MMM d, h:mm:ss a')} />}
|
|
394
|
+
</StatsGroup>
|
|
395
|
+
|
|
396
|
+
{/* User */}
|
|
397
|
+
<StatsGroup title="User">
|
|
398
|
+
<StatsRow label="Messages" value={`${user.totalMessages - user.metaMessages - user.toolResults} direct, ${user.metaMessages} meta, ${user.toolResults} tool results`} />
|
|
399
|
+
{user.commands.length > 0 && <StatsRow label="Commands" value={user.commands.join(', ')} cls="font-mono" />}
|
|
400
|
+
{user.permissionModes.length > 0 && <StatsRow label="Permission modes" value={user.permissionModes.join(', ')} />}
|
|
401
|
+
{user.version && <StatsRow label="Claude Code version" value={user.version} cls="font-mono" />}
|
|
402
|
+
{user.cwd && <StatsRow label="Working directory" value={user.cwd} cls="font-mono text-xxs" />}
|
|
403
|
+
</StatsGroup>
|
|
404
|
+
|
|
405
|
+
{/* Assistant */}
|
|
406
|
+
<StatsGroup title="Assistant">
|
|
407
|
+
<StatsRow label="Responses" value={String(assistant.totalMessages)} />
|
|
408
|
+
{assistant.models.length > 0 && <StatsRow label="Models" value={assistant.models.join(', ')} cls="font-mono" />}
|
|
409
|
+
<StatsRow label="Input tokens" value={formatNumber(assistant.totalInputTokens)} />
|
|
410
|
+
<StatsRow label="Output tokens" value={formatNumber(assistant.totalOutputTokens)} />
|
|
411
|
+
{assistant.totalCacheReadTokens > 0 && <StatsRow label="Cache read tokens" value={formatNumber(assistant.totalCacheReadTokens)} />}
|
|
412
|
+
{assistant.totalCacheCreationTokens > 0 && <StatsRow label="Cache creation tokens" value={formatNumber(assistant.totalCacheCreationTokens)} />}
|
|
413
|
+
{toolEntries.length > 0 && (
|
|
414
|
+
<tr>
|
|
415
|
+
<td className="pr-3 text-muted-foreground whitespace-nowrap align-top">Tools used</td>
|
|
416
|
+
<td>
|
|
417
|
+
<div className="flex flex-wrap gap-1">
|
|
418
|
+
{toolEntries.map(([name, count]) => (
|
|
419
|
+
<Badge key={name} variant="outline" className="font-mono text-xxs px-1.5 py-0">
|
|
420
|
+
{name} <span className="ml-1 text-muted-foreground">{count}</span>
|
|
421
|
+
</Badge>
|
|
422
|
+
))}
|
|
423
|
+
</div>
|
|
424
|
+
</td>
|
|
425
|
+
</tr>
|
|
426
|
+
)}
|
|
427
|
+
</StatsGroup>
|
|
428
|
+
|
|
429
|
+
{/* System */}
|
|
430
|
+
{system.totalMessages > 0 && (
|
|
431
|
+
<StatsGroup title="System">
|
|
432
|
+
<StatsRow label="Events" value={String(system.totalMessages)} />
|
|
433
|
+
{system.subtypes.length > 0 && <StatsRow label="Subtypes" value={system.subtypes.join(', ')} />}
|
|
434
|
+
{system.stopReasons.length > 0 && <StatsRow label="Stop reasons" value={system.stopReasons.join(', ')} />}
|
|
435
|
+
{system.totalDurationMs > 0 && <StatsRow label="Total processing" value={formatDuration(system.totalDurationMs)} />}
|
|
436
|
+
{system.hookCount > 0 && <StatsRow label="Hooks fired" value={`${system.hookCount}${system.hookErrors > 0 ? ` (${system.hookErrors} errors)` : ''}`} />}
|
|
437
|
+
</StatsGroup>
|
|
438
|
+
)}
|
|
439
|
+
|
|
440
|
+
{/* Line counts */}
|
|
441
|
+
<StatsGroup title="Raw Counts">
|
|
442
|
+
{Object.entries(stats.typeCounts).sort((a, b) => b[1] - a[1]).map(([type, count]) => (
|
|
443
|
+
<StatsRow key={type} label={type} value={String(count)} />
|
|
444
|
+
))}
|
|
445
|
+
</StatsGroup>
|
|
446
|
+
</div>
|
|
447
|
+
);
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
function StatsGroup({ title, children }: { title: string; children: React.ReactNode }) {
|
|
451
|
+
return (
|
|
452
|
+
<div>
|
|
453
|
+
<h4 className="mb-2 text-xxs font-medium uppercase tracking-wider text-foreground">{title}</h4>
|
|
454
|
+
<table className="w-full table-fixed text-xs">
|
|
455
|
+
<colgroup><col className="w-40" /><col /></colgroup>
|
|
456
|
+
<tbody className="[&_td]:border-b [&_td]:border-border/20 [&_td]:py-1.5 [&_td]:align-top [&_td:first-child]:pr-3 [&_td:first-child]:text-muted-foreground [&_td:first-child]:whitespace-nowrap">
|
|
457
|
+
{children}
|
|
458
|
+
</tbody>
|
|
459
|
+
</table>
|
|
460
|
+
</div>
|
|
461
|
+
);
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
function StatsRow({ label, value, cls }: { label: string; value: string; cls?: string }) {
|
|
465
|
+
return (
|
|
466
|
+
<tr>
|
|
467
|
+
<td>{label}</td>
|
|
468
|
+
<td className={cls}>{value}</td>
|
|
469
|
+
</tr>
|
|
470
|
+
);
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
// ─── Shared Helpers ────────────────────────────────────────
|
|
474
|
+
|
|
475
|
+
function BulletSection({ title, items, color }: { title: string; items: string[]; color: string }) {
|
|
476
|
+
if (items.length === 0) return null;
|
|
477
|
+
return (
|
|
478
|
+
<div className="mt-5">
|
|
479
|
+
<h4 className="mb-2 text-xxs font-medium uppercase tracking-wider text-foreground">{title}</h4>
|
|
480
|
+
<ul className="space-y-1.5">
|
|
481
|
+
{items.map((item, idx) => (
|
|
482
|
+
<li key={idx} className="flex items-start gap-2 text-xs">
|
|
483
|
+
<span className={cn('mt-0.5', color)}>{'•'}</span>
|
|
484
|
+
<span>{item}</span>
|
|
485
|
+
</li>
|
|
486
|
+
))}
|
|
487
|
+
</ul>
|
|
488
|
+
</div>
|
|
489
|
+
);
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
function truncate(text: string, max: number): string {
|
|
493
|
+
return text.length > max ? text.slice(0, max) + '...' : text;
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
function formatFileSize(bytes: number): string {
|
|
497
|
+
if (bytes < 1024) return `${bytes} B`;
|
|
498
|
+
if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
|
|
499
|
+
return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
function formatDuration(ms: number): string {
|
|
503
|
+
if (ms < 1000) return `${ms}ms`;
|
|
504
|
+
const secs = Math.floor(ms / 1000);
|
|
505
|
+
if (secs < 60) return `${secs}s`;
|
|
506
|
+
const mins = Math.floor(secs / 60);
|
|
507
|
+
const remSecs = secs % 60;
|
|
508
|
+
if (mins < 60) return `${mins}m ${remSecs}s`;
|
|
509
|
+
const hrs = Math.floor(mins / 60);
|
|
510
|
+
const remMins = mins % 60;
|
|
511
|
+
return `${hrs}h ${remMins}m`;
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
function formatNumber(n: number): string {
|
|
515
|
+
return n.toLocaleString();
|
|
516
|
+
}
|