khal-os 1.260324.2
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/.env.example +23 -0
- package/.genie/mailbox/cli-sent.jsonl +3 -0
- package/.genie/mailbox/ds1-wave2-engineer-1.json +15 -0
- package/.genie/mailbox/ds1-wave2-engineer-2.json +15 -0
- package/.genie/mailbox/ds1-wave2-engineer-3.json +15 -0
- package/.genie/state/os-observability.json +39 -0
- package/.genie/state/tmux-control-mode-terminal.json +28 -0
- package/.genie/wishes/genieos-one-theme/WISH.md +417 -0
- package/.genie/wishes/workos-prod-rbac/WISH.md +345 -0
- package/.github/workflows/ci.yml +39 -0
- package/.github/workflows/release.yml +78 -0
- package/.github/workflows/version.yml +122 -0
- package/.husky/pre-commit +1 -0
- package/.pnpm-approve-builds.json +1 -0
- package/CLAUDE.md +117 -0
- package/LICENSE +21 -0
- package/README.md +38 -0
- package/biome.json +124 -0
- package/bun.lock +1249 -0
- package/docs/workos-setup.md +116 -0
- package/ecosystem.config.cjs +26 -0
- package/instrumentation.ts +8 -0
- package/knip.json +35 -0
- package/nats.conf +7 -0
- package/next.config.ts +25 -0
- package/package.json +78 -0
- package/packages/dev3000-app/components.ts +12 -0
- package/packages/dev3000-app/manifest.ts +19 -0
- package/packages/dev3000-app/package.json +23 -0
- package/packages/dev3000-app/views/dev3000/Dev3000App.tsx +758 -0
- package/packages/dev3000-app/views/dev3000/ErrorsPanel.tsx +160 -0
- package/packages/dev3000-app/views/dev3000/dev3000-context.tsx +21 -0
- package/packages/dev3000-app/views/dev3000/index.ts +4 -0
- package/packages/dev3000-app/views/dev3000/schema.ts +55 -0
- package/packages/dev3000-app/views/dev3000/service/index.ts +358 -0
- package/packages/dev3000-app/views/dev3000/service/runtime +1 -0
- package/packages/dev3000-app/views/dev3000/subjects.ts +9 -0
- package/packages/dev3000-app/views/dev3000/types.ts +77 -0
- package/packages/files-app/components.ts +12 -0
- package/packages/files-app/manifest.ts +19 -0
- package/packages/files-app/package.json +23 -0
- package/packages/files-app/views/files/ContextMenu.tsx +151 -0
- package/packages/files-app/views/files/DeleteConfirmDialog.tsx +39 -0
- package/packages/files-app/views/files/FileItem.tsx +128 -0
- package/packages/files-app/views/files/FilesApp.tsx +509 -0
- package/packages/files-app/views/files/FilesListView.tsx +201 -0
- package/packages/files-app/views/files/FilesToolbar.tsx +117 -0
- package/packages/files-app/views/files/GridView.tsx +90 -0
- package/packages/files-app/views/files/InlineInput.tsx +131 -0
- package/packages/files-app/views/files/UploadOverlay.tsx +61 -0
- package/packages/files-app/views/files/schema.ts +49 -0
- package/packages/files-app/views/files/service/index.ts +184 -0
- package/packages/files-app/views/files/service/runtime +1 -0
- package/packages/files-app/views/files/use-files.ts +201 -0
- package/packages/files-app/views/files/use-upload.ts +105 -0
- package/packages/genie-app/components.ts +12 -0
- package/packages/genie-app/lib/subjects.ts +87 -0
- package/packages/genie-app/manifest.ts +19 -0
- package/packages/genie-app/package.json +29 -0
- package/packages/genie-app/views/genie/service/agent-lifecycle.ts +136 -0
- package/packages/genie-app/views/genie/service/cli.ts +114 -0
- package/packages/genie-app/views/genie/service/comms.ts +141 -0
- package/packages/genie-app/views/genie/service/directory.ts +167 -0
- package/packages/genie-app/views/genie/service/index.ts +219 -0
- package/packages/genie-app/views/genie/service/system.ts +123 -0
- package/packages/genie-app/views/genie/service/teams.ts +191 -0
- package/packages/genie-app/views/genie/service/terminal-proxy.ts +184 -0
- package/packages/genie-app/views/genie/service/tmux-control.ts +318 -0
- package/packages/genie-app/views/genie/service/wishes.ts +270 -0
- package/packages/genie-app/views/genie/ui/GenieApp.tsx +5 -0
- package/packages/genie-app/views/genie/ui/PaneCard.tsx +307 -0
- package/packages/genie-app/views/genie/ui/Sidebar.tsx +212 -0
- package/packages/genie-app/views/genie/ui/TabBar.tsx +70 -0
- package/packages/genie-app/views/genie/ui/WorkspaceCanvas.tsx +343 -0
- package/packages/genie-app/views/genie/ui/XTermPane.tsx +306 -0
- package/packages/genie-app/views/genie/ui/hooks/useNatsAction.ts +54 -0
- package/packages/genie-app/views/genie/ui/hooks/useNatsRequest.ts +68 -0
- package/packages/genie-app/views/genie/ui/panels/AgentsPanel.tsx +399 -0
- package/packages/genie-app/views/genie/ui/panels/ChatPanel.tsx +351 -0
- package/packages/genie-app/views/genie/ui/panels/SystemPanel.tsx +195 -0
- package/packages/genie-app/views/genie/ui/panels/TeamsPanel.tsx +560 -0
- package/packages/genie-app/views/genie/ui/panels/WishesPanel.tsx +424 -0
- package/packages/nats-viewer-app/components.ts +12 -0
- package/packages/nats-viewer-app/manifest.ts +18 -0
- package/packages/nats-viewer-app/package.json +14 -0
- package/packages/nats-viewer-app/views/nats-viewer/ActiveSubs.tsx +34 -0
- package/packages/nats-viewer-app/views/nats-viewer/MessageLog.tsx +247 -0
- package/packages/nats-viewer-app/views/nats-viewer/NatsViewer.tsx +209 -0
- package/packages/nats-viewer-app/views/nats-viewer/PublishPanel.tsx +111 -0
- package/packages/nats-viewer-app/views/nats-viewer/RequestPanel.tsx +165 -0
- package/packages/nats-viewer-app/views/nats-viewer/Sidebar.tsx +59 -0
- package/packages/nats-viewer-app/views/nats-viewer/SubjectCatalog.tsx +63 -0
- package/packages/nats-viewer-app/views/nats-viewer/SubscribeInput.tsx +59 -0
- package/packages/nats-viewer-app/views/nats-viewer/index.ts +5 -0
- package/packages/nats-viewer-app/views/nats-viewer/nats-viewer-context.tsx +31 -0
- package/packages/nats-viewer-app/views/nats-viewer/types.ts +7 -0
- package/packages/nats-viewer-app/views/nats-viewer/use-message-buffer.ts +55 -0
- package/packages/os-cli/package.json +18 -0
- package/packages/os-cli/src/commands/events.ts +176 -0
- package/packages/os-cli/src/commands/logs.ts +96 -0
- package/packages/os-cli/src/commands/status.ts +53 -0
- package/packages/os-cli/src/commands/traces.ts +115 -0
- package/packages/os-cli/src/index.ts +15 -0
- package/packages/os-cli/src/lib/formatter.ts +123 -0
- package/packages/os-cli/src/lib/nats.ts +16 -0
- package/packages/os-cli/src/lib/trace-tree.ts +144 -0
- package/packages/os-cli/tsconfig.json +12 -0
- package/packages/os-sdk/package.json +27 -0
- package/packages/os-sdk/src/api/handler.ts +67 -0
- package/packages/os-sdk/src/config.ts +68 -0
- package/packages/os-sdk/src/db/factory.test.ts +42 -0
- package/packages/os-sdk/src/db/factory.ts +72 -0
- package/packages/os-sdk/src/db/migrate.ts +140 -0
- package/packages/os-sdk/src/db/provision.ts +44 -0
- package/packages/os-sdk/src/index.ts +36 -0
- package/packages/os-sdk/src/service/console-intercept.ts +60 -0
- package/packages/os-sdk/src/service/logger.ts +88 -0
- package/packages/os-sdk/src/service/o11y-streams.ts +88 -0
- package/packages/os-sdk/src/service/runtime.ts +259 -0
- package/packages/os-sdk/src/service/trace.ts +71 -0
- package/packages/os-sdk/tsconfig.json +16 -0
- package/packages/os-ui/package.json +13 -0
- package/packages/os-ui/src/index.ts +29 -0
- package/packages/os-ui/src/server.ts +4 -0
- package/packages/os-ui/tsconfig.json +19 -0
- package/packages/settings-app/components.ts +12 -0
- package/packages/settings-app/manifest.ts +18 -0
- package/packages/settings-app/package.json +14 -0
- package/packages/settings-app/views/settings/Settings.tsx +492 -0
- package/packages/terminal-app/components.ts +12 -0
- package/packages/terminal-app/manifest.ts +20 -0
- package/packages/terminal-app/package.json +23 -0
- package/packages/terminal-app/views/terminal/schema.ts +82 -0
- package/packages/terminal-app/views/terminal/service/index.ts +133 -0
- package/packages/terminal-app/views/terminal/service/runtime +1 -0
- package/packages/terminal-app/views/terminal/service/session.ts +290 -0
- package/packages/terminal-app/views/terminal/service/shell-hooks/bashrc-hook.sh +21 -0
- package/packages/terminal-app/views/terminal/types.ts +26 -0
- package/packages/terminal-app/views/terminal/ui/MultiTerminalApp.tsx +615 -0
- package/packages/terminal-app/views/terminal/ui/SplitDragHandle.tsx +91 -0
- package/packages/terminal-app/views/terminal/ui/SplitPaneRenderer.tsx +112 -0
- package/packages/terminal-app/views/terminal/ui/TerminalPane.tsx +478 -0
- package/packages/terminal-app/views/terminal/ui/TerminalTabBar.tsx +131 -0
- package/pnpm-workspace.yaml +9 -0
- package/postcss.config.mjs +7 -0
- package/public/file.svg +1 -0
- package/public/globe.svg +1 -0
- package/public/icons/code-server.svg +6 -0
- package/public/icons/default.svg +5 -0
- package/public/icons/dusk/1password.svg +1 -0
- package/public/icons/dusk/activity_monitor.svg +1 -0
- package/public/icons/dusk/app_store.svg +1 -0
- package/public/icons/dusk/atom.svg +1 -0
- package/public/icons/dusk/brave.svg +1 -0
- package/public/icons/dusk/calculator.svg +1 -0
- package/public/icons/dusk/calendar.svg +1 -0
- package/public/icons/dusk/chrome.svg +1 -0
- package/public/icons/dusk/chrome2.svg +1 -0
- package/public/icons/dusk/dashboard.svg +13 -0
- package/public/icons/dusk/discord.svg +1 -0
- package/public/icons/dusk/dropbox.svg +1 -0
- package/public/icons/dusk/electron.svg +1 -0
- package/public/icons/dusk/figma.svg +1 -0
- package/public/icons/dusk/finder.svg +1 -0
- package/public/icons/dusk/finder2.svg +1 -0
- package/public/icons/dusk/finder3.svg +1 -0
- package/public/icons/dusk/firefox.svg +1 -0
- package/public/icons/dusk/framer.svg +1 -0
- package/public/icons/dusk/gimp.svg +1 -0
- package/public/icons/dusk/github_desktop.svg +1 -0
- package/public/icons/dusk/hyper.svg +1 -0
- package/public/icons/dusk/hyper3.svg +1 -0
- package/public/icons/dusk/intellij.svg +1 -0
- package/public/icons/dusk/iterm2.svg +1 -0
- package/public/icons/dusk/itunes.svg +1 -0
- package/public/icons/dusk/mail.svg +1 -0
- package/public/icons/dusk/messenger.svg +1 -0
- package/public/icons/dusk/mongodb.svg +1 -0
- package/public/icons/dusk/notes.svg +1 -0
- package/public/icons/dusk/notion.svg +1 -0
- package/public/icons/dusk/obs.svg +1 -0
- package/public/icons/dusk/pages.svg +1 -0
- package/public/icons/dusk/photos.svg +1 -0
- package/public/icons/dusk/postman.svg +1 -0
- package/public/icons/dusk/preview.svg +1 -0
- package/public/icons/dusk/reminders.svg +1 -0
- package/public/icons/dusk/safari.svg +1 -0
- package/public/icons/dusk/sequel_pro.svg +1 -0
- package/public/icons/dusk/sketch.svg +1 -0
- package/public/icons/dusk/skype.svg +1 -0
- package/public/icons/dusk/slack.svg +1 -0
- package/public/icons/dusk/slack2.svg +1 -0
- package/public/icons/dusk/spotify.svg +1 -0
- package/public/icons/dusk/steam.svg +1 -0
- package/public/icons/dusk/system_preferences.svg +1 -0
- package/public/icons/dusk/tableplus.svg +1 -0
- package/public/icons/dusk/teams.svg +1 -0
- package/public/icons/dusk/telegram.svg +1 -0
- package/public/icons/dusk/terminal.svg +1 -0
- package/public/icons/dusk/todoist.svg +1 -0
- package/public/icons/dusk/trash.svg +1 -0
- package/public/icons/dusk/trello.svg +1 -0
- package/public/icons/dusk/vivaldi.svg +1 -0
- package/public/icons/dusk/vlc.svg +1 -0
- package/public/icons/dusk/vscode.svg +1 -0
- package/public/icons/dusk/whatsapp.svg +1 -0
- package/public/icons/dusk/xeyes.svg +1 -0
- package/public/icons/dusk/zoom.svg +1 -0
- package/public/icons/files.svg +5 -0
- package/public/icons/pwa/icon-192.png +0 -0
- package/public/icons/pwa/icon-512.png +0 -0
- package/public/icons/settings.svg +14 -0
- package/public/icons/terminal.svg +5 -0
- package/public/icons/text-editor.svg +7 -0
- package/public/manifest.json +38 -0
- package/public/next.svg +1 -0
- package/public/sw.js +41 -0
- package/public/vercel.svg +1 -0
- package/public/wallpapers/default.svg +10 -0
- package/public/window.svg +1 -0
- package/scripts/generate-pwa-icons.mjs +33 -0
- package/scripts/install-nats.sh +37 -0
- package/sentry.client.config.ts +21 -0
- package/sentry.edge.config.ts +12 -0
- package/sentry.server.config.ts +12 -0
- package/src/app/api/files/download/route.ts +81 -0
- package/src/app/api/files/download-zip/route.ts +102 -0
- package/src/app/api/files/upload/route.ts +58 -0
- package/src/app/api/webhooks/workos/route.ts +98 -0
- package/src/app/auth/callback/route.ts +16 -0
- package/src/app/auth/logout/route.ts +15 -0
- package/src/app/desktop/desktop-shell.tsx +110 -0
- package/src/app/desktop/layout.tsx +8 -0
- package/src/app/desktop/page.tsx +24 -0
- package/src/app/favicon.ico +0 -0
- package/src/app/globals.css +7 -0
- package/src/app/layout.tsx +64 -0
- package/src/app/offline/page.tsx +83 -0
- package/src/app/page.tsx +5 -0
- package/src/app/standalone/[appId]/page.tsx +28 -0
- package/src/app/standalone/layout.tsx +10 -0
- package/src/components/app-icon.tsx +55 -0
- package/src/components/apps/_echo/schema.ts +14 -0
- package/src/components/apps/_echo/service/index.ts +42 -0
- package/src/components/apps/app-manifest.ts +97 -0
- package/src/components/apps/app-registry.ts +55 -0
- package/src/components/apps/dev3000/Dev3000App.tsx +224 -0
- package/src/components/apps/dev3000/ErrorsPanel.tsx +160 -0
- package/src/components/apps/dev3000/Sidebar.tsx +41 -0
- package/src/components/apps/dev3000/TimelineLog.tsx +173 -0
- package/src/components/apps/dev3000/dev3000-context.tsx +29 -0
- package/src/components/apps/dev3000/index.ts +4 -0
- package/src/components/apps/dev3000/schema.ts +48 -0
- package/src/components/apps/dev3000/service/index.ts +520 -0
- package/src/components/apps/dev3000/service/runtime +1 -0
- package/src/components/apps/dev3000/types.ts +15 -0
- package/src/components/apps/dev3000/use-message-buffer.ts +46 -0
- package/src/components/apps/files/ContextMenu.tsx +151 -0
- package/src/components/apps/files/DeleteConfirmDialog.tsx +78 -0
- package/src/components/apps/files/FileItem.tsx +128 -0
- package/src/components/apps/files/FilesApp.tsx +509 -0
- package/src/components/apps/files/FilesListView.tsx +201 -0
- package/src/components/apps/files/FilesToolbar.tsx +117 -0
- package/src/components/apps/files/GridView.tsx +90 -0
- package/src/components/apps/files/InlineInput.tsx +131 -0
- package/src/components/apps/files/UploadOverlay.tsx +61 -0
- package/src/components/apps/files/schema.ts +49 -0
- package/src/components/apps/files/service/index.ts +227 -0
- package/src/components/apps/files/service/runtime +1 -0
- package/src/components/apps/files/use-files.ts +201 -0
- package/src/components/apps/files/use-upload.ts +105 -0
- package/src/components/apps/nats-viewer/ActiveSubs.tsx +34 -0
- package/src/components/apps/nats-viewer/MessageLog.tsx +247 -0
- package/src/components/apps/nats-viewer/NatsViewer.tsx +209 -0
- package/src/components/apps/nats-viewer/PublishPanel.tsx +113 -0
- package/src/components/apps/nats-viewer/RequestPanel.tsx +167 -0
- package/src/components/apps/nats-viewer/Sidebar.tsx +62 -0
- package/src/components/apps/nats-viewer/SubjectCatalog.tsx +64 -0
- package/src/components/apps/nats-viewer/SubscribeInput.tsx +59 -0
- package/src/components/apps/nats-viewer/index.ts +5 -0
- package/src/components/apps/nats-viewer/nats-viewer-context.tsx +31 -0
- package/src/components/apps/nats-viewer/types.ts +7 -0
- package/src/components/apps/nats-viewer/use-message-buffer.ts +55 -0
- package/src/components/apps/settings/Settings.tsx +492 -0
- package/src/components/apps/terminal/schema.ts +82 -0
- package/src/components/apps/terminal/service/index.ts +189 -0
- package/src/components/apps/terminal/service/runtime +1 -0
- package/src/components/apps/terminal/service/session.ts +296 -0
- package/src/components/apps/terminal/service/shell-hooks/bashrc-hook.sh +21 -0
- package/src/components/apps/terminal/types.ts +26 -0
- package/src/components/apps/terminal/ui/MultiTerminalApp.tsx +617 -0
- package/src/components/apps/terminal/ui/SplitDragHandle.tsx +91 -0
- package/src/components/apps/terminal/ui/SplitPaneRenderer.tsx +112 -0
- package/src/components/apps/terminal/ui/TerminalPane.tsx +476 -0
- package/src/components/apps/terminal/ui/TerminalTabBar.tsx +131 -0
- package/src/components/desktop/AnimatedBackground.tsx +69 -0
- package/src/components/desktop/Desktop.tsx +79 -0
- package/src/components/desktop/DesktopBackground.tsx +16 -0
- package/src/components/desktop/DesktopIcon.tsx +49 -0
- package/src/components/desktop/ShortcutViewer.tsx +136 -0
- package/src/components/desktop/WindowRenderer.tsx +34 -0
- package/src/components/desktop/WindowSwitcher.tsx +42 -0
- package/src/components/notifications/NotificationCenter.tsx +153 -0
- package/src/components/notifications/NotificationToasts.tsx +66 -0
- package/src/components/notifications/OrphanSessionToast.tsx +293 -0
- package/src/components/os-primitives/collapsible-sidebar.tsx +226 -0
- package/src/components/os-primitives/dialog.tsx +76 -0
- package/src/components/os-primitives/empty-state.tsx +43 -0
- package/src/components/os-primitives/index.ts +21 -0
- package/src/components/os-primitives/list-view.tsx +155 -0
- package/src/components/os-primitives/property-panel.tsx +108 -0
- package/src/components/os-primitives/section-header.tsx +19 -0
- package/src/components/os-primitives/sidebar-nav.tsx +110 -0
- package/src/components/os-primitives/split-pane.tsx +146 -0
- package/src/components/os-primitives/status-badge.tsx +10 -0
- package/src/components/os-primitives/status-bar.tsx +100 -0
- package/src/components/os-primitives/toolbar.tsx +152 -0
- package/src/components/taskbar/AppLauncher.tsx +114 -0
- package/src/components/taskbar/RunningApps.tsx +71 -0
- package/src/components/taskbar/SystemTray.tsx +134 -0
- package/src/components/taskbar/Taskbar.tsx +45 -0
- package/src/components/taskbar/UserMenu.tsx +138 -0
- package/src/components/taskbar/WorkspaceSwitcher.tsx +9 -0
- package/src/components/ui/ContextMenu.tsx +130 -0
- package/src/components/ui/badge.tsx +39 -0
- package/src/components/ui/button.tsx +102 -0
- package/src/components/ui/command.tsx +165 -0
- package/src/components/ui/dropdown-menu.tsx +233 -0
- package/src/components/ui/input.tsx +48 -0
- package/src/components/ui/note.tsx +55 -0
- package/src/components/ui/separator.tsx +25 -0
- package/src/components/ui/spinner.tsx +42 -0
- package/src/components/ui/switch.tsx +36 -0
- package/src/components/ui/theme-provider.tsx +24 -0
- package/src/components/ui/theme-switcher.tsx +51 -0
- package/src/components/ui/tooltip.tsx +62 -0
- package/src/components/window/MobileWindowStack.tsx +218 -0
- package/src/components/window/SnapPreview.tsx +37 -0
- package/src/components/window/StandaloneFrame.tsx +170 -0
- package/src/components/window/Window.tsx +423 -0
- package/src/components/window/WindowContent.tsx +14 -0
- package/src/components/window/WindowControlsOverlay.tsx +89 -0
- package/src/components/window/WindowFrame.tsx +124 -0
- package/src/lib/auth/index.ts +27 -0
- package/src/lib/auth/roles.ts +50 -0
- package/src/lib/auth/types.ts +32 -0
- package/src/lib/auth/use-auth.ts +53 -0
- package/src/lib/auth/webhook-handler.ts +87 -0
- package/src/lib/auth/workos.ts +67 -0
- package/src/lib/constants.ts +1 -0
- package/src/lib/desktop/dedup.ts +57 -0
- package/src/lib/desktop/schema.ts +55 -0
- package/src/lib/files/filename-validation.ts +41 -0
- package/src/lib/files/safe-path.ts +49 -0
- package/src/lib/hooks/use-desktop-nats.ts +438 -0
- package/src/lib/hooks/use-is-mobile.ts +23 -0
- package/src/lib/hooks/use-launch-app.ts +79 -0
- package/src/lib/hooks/use-nats-notifications.ts +84 -0
- package/src/lib/hooks/use-nats.ts +60 -0
- package/src/lib/hooks/use-visual-viewport.ts +72 -0
- package/src/lib/icons/resolve-window-icon.ts +10 -0
- package/src/lib/keyboard/defaults.ts +146 -0
- package/src/lib/keyboard/types.ts +52 -0
- package/src/lib/keyboard/use-global-keybinds.ts +231 -0
- package/src/lib/nats-client.ts +255 -0
- package/src/lib/nats.ts +35 -0
- package/src/lib/notifications/schema.ts +12 -0
- package/src/lib/service-loader.ts +171 -0
- package/src/lib/subjects.ts +64 -0
- package/src/lib/utils.ts +6 -0
- package/src/lib/ws-bridge.ts +288 -0
- package/src/lib/ws-protocol.ts +53 -0
- package/src/lib/ws-server.ts +167 -0
- package/src/middleware.ts +57 -0
- package/src/stores/desktop-store.ts +112 -0
- package/src/stores/keybind-store.ts +66 -0
- package/src/stores/notification-store.ts +271 -0
- package/src/stores/theme-store.ts +25 -0
- package/src/stores/window-store.ts +294 -0
- package/src/theme/animations.css +68 -0
- package/src/theme/base.css +123 -0
- package/src/theme/controls.css +35 -0
- package/src/theme/design-tokens.css +276 -0
- package/src/theme/index.css +23 -0
- package/src/theme/menus.css +45 -0
- package/src/theme/status.css +41 -0
- package/src/theme/surfaces.css +94 -0
- package/src/theme/tailwind-map.css +138 -0
- package/src/theme/taskbar.css +25 -0
- package/src/theme/terminal.css +55 -0
- package/src/theme/typography.css +26 -0
- package/src/theme/utilities.css +156 -0
- package/src/theme/window.css +103 -0
- package/src/types/desktop-entry.ts +12 -0
- package/src/types/use-descendants.d.ts +13 -0
- package/src/types/window.ts +28 -0
- package/src/types.d.ts +9 -0
- package/tauri/Cargo.lock +5464 -0
- package/tauri/Cargo.toml +19 -0
- package/tauri/build.rs +3 -0
- package/tauri/capabilities/default.json +36 -0
- package/tauri/icons/128x128.png +0 -0
- package/tauri/icons/128x128@2x.png +0 -0
- package/tauri/icons/32x32.png +0 -0
- package/tauri/icons/icon.png +0 -0
- package/tauri/src/main.rs +396 -0
- package/tauri/tauri.conf.json +23 -0
- package/tsconfig.json +43 -0
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
4
|
+
import { SUBJECTS } from '../../../../lib/subjects';
|
|
5
|
+
import { useNatsAction } from '../hooks/useNatsAction';
|
|
6
|
+
import { useNatsRequest } from '../hooks/useNatsRequest';
|
|
7
|
+
|
|
8
|
+
// --- Types ---
|
|
9
|
+
|
|
10
|
+
interface ChatMessage {
|
|
11
|
+
sender: string;
|
|
12
|
+
timestamp: string;
|
|
13
|
+
content: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
interface ChatReadResponse {
|
|
17
|
+
messages: ChatMessage[];
|
|
18
|
+
error?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface InboxMessage {
|
|
22
|
+
from: string;
|
|
23
|
+
timestamp: string;
|
|
24
|
+
body: string;
|
|
25
|
+
read?: boolean;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
interface InboxResponse {
|
|
29
|
+
messages: InboxMessage[];
|
|
30
|
+
error?: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// --- Sub-tabs ---
|
|
34
|
+
|
|
35
|
+
type ChatTab = 'chat' | 'inbox';
|
|
36
|
+
|
|
37
|
+
// --- Team Chat Tab ---
|
|
38
|
+
|
|
39
|
+
function TeamChatTab() {
|
|
40
|
+
const { data, loading, error, refetch } = useNatsRequest<ChatReadResponse>(
|
|
41
|
+
SUBJECTS.comms.chat.read(),
|
|
42
|
+
undefined,
|
|
43
|
+
5000
|
|
44
|
+
);
|
|
45
|
+
const postAction = useNatsAction(SUBJECTS.comms.chat.post());
|
|
46
|
+
const [input, setInput] = useState('');
|
|
47
|
+
const messagesEndRef = useRef<HTMLDivElement>(null);
|
|
48
|
+
const prevCountRef = useRef(0);
|
|
49
|
+
|
|
50
|
+
const messages = data?.messages ?? [];
|
|
51
|
+
|
|
52
|
+
// Auto-scroll when new messages arrive
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
if (messages.length > prevCountRef.current) {
|
|
55
|
+
messagesEndRef.current?.scrollIntoView({ behavior: 'smooth' });
|
|
56
|
+
}
|
|
57
|
+
prevCountRef.current = messages.length;
|
|
58
|
+
}, [messages.length]);
|
|
59
|
+
|
|
60
|
+
const handleSend = useCallback(async () => {
|
|
61
|
+
const trimmed = input.trim();
|
|
62
|
+
if (!trimmed || postAction.loading) return;
|
|
63
|
+
setInput('');
|
|
64
|
+
try {
|
|
65
|
+
await postAction.execute({ message: trimmed });
|
|
66
|
+
refetch();
|
|
67
|
+
} catch {
|
|
68
|
+
// error is surfaced via postAction.error
|
|
69
|
+
}
|
|
70
|
+
}, [input, postAction, refetch]);
|
|
71
|
+
|
|
72
|
+
const handleKeyDown = useCallback(
|
|
73
|
+
(e: React.KeyboardEvent) => {
|
|
74
|
+
if (e.key === 'Enter' && !e.shiftKey) {
|
|
75
|
+
e.preventDefault();
|
|
76
|
+
handleSend();
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
[handleSend]
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
if (loading && messages.length === 0) {
|
|
83
|
+
return <LoadingState />;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (error && messages.length === 0) {
|
|
87
|
+
return <ErrorState message={error} onRetry={refetch} />;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return (
|
|
91
|
+
<div className="flex h-full flex-col">
|
|
92
|
+
{/* Messages */}
|
|
93
|
+
<div className="min-h-0 flex-1 overflow-y-auto px-3 py-2">
|
|
94
|
+
{messages.length === 0 ? (
|
|
95
|
+
<EmptyState text="No messages yet" />
|
|
96
|
+
) : (
|
|
97
|
+
<div className="flex flex-col gap-2">
|
|
98
|
+
{messages.map((msg, i) => (
|
|
99
|
+
<div key={`${msg.timestamp}-${i}`} className="flex flex-col gap-0.5">
|
|
100
|
+
<div className="flex items-baseline gap-1.5">
|
|
101
|
+
<span className="text-[11px] font-medium text-[var(--os-text-primary)]">{msg.sender}</span>
|
|
102
|
+
<span className="text-[9px] text-[var(--os-text-secondary)]">{formatTime(msg.timestamp)}</span>
|
|
103
|
+
</div>
|
|
104
|
+
<p className="text-[11px] leading-relaxed text-[var(--os-text-secondary)] break-words whitespace-pre-wrap">
|
|
105
|
+
{msg.content}
|
|
106
|
+
</p>
|
|
107
|
+
</div>
|
|
108
|
+
))}
|
|
109
|
+
<div ref={messagesEndRef} />
|
|
110
|
+
</div>
|
|
111
|
+
)}
|
|
112
|
+
</div>
|
|
113
|
+
|
|
114
|
+
{/* Send input */}
|
|
115
|
+
<div className="shrink-0 border-t border-white/10 p-2">
|
|
116
|
+
{postAction.error && <p className="mb-1 text-[9px] text-red-400 truncate">{postAction.error}</p>}
|
|
117
|
+
<div className="flex gap-1.5">
|
|
118
|
+
<input
|
|
119
|
+
type="text"
|
|
120
|
+
value={input}
|
|
121
|
+
onChange={(e) => setInput(e.target.value)}
|
|
122
|
+
onKeyDown={handleKeyDown}
|
|
123
|
+
placeholder="Send a message..."
|
|
124
|
+
className="min-w-0 flex-1 rounded bg-white/5 px-2 py-1.5 text-[11px] text-[var(--os-text-primary)] placeholder:text-[var(--os-text-secondary)] outline-none focus:bg-white/10"
|
|
125
|
+
/>
|
|
126
|
+
<button
|
|
127
|
+
type="button"
|
|
128
|
+
onClick={handleSend}
|
|
129
|
+
disabled={!input.trim() || postAction.loading}
|
|
130
|
+
className="shrink-0 rounded bg-white/10 px-2.5 py-1.5 text-[11px] text-[var(--os-text-primary)] hover:bg-white/20 disabled:opacity-40 disabled:cursor-not-allowed"
|
|
131
|
+
>
|
|
132
|
+
Send
|
|
133
|
+
</button>
|
|
134
|
+
</div>
|
|
135
|
+
</div>
|
|
136
|
+
</div>
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// --- Inbox Tab ---
|
|
141
|
+
|
|
142
|
+
function InboxTab() {
|
|
143
|
+
const [unreadOnly, setUnreadOnly] = useState(false);
|
|
144
|
+
const payload = useMemo(() => (unreadOnly ? { unread: true } : {}), [unreadOnly]);
|
|
145
|
+
const { data, loading, error, refetch } = useNatsRequest<InboxResponse>(SUBJECTS.comms.inbox(), payload, 5000);
|
|
146
|
+
|
|
147
|
+
const messages = data?.messages ?? [];
|
|
148
|
+
|
|
149
|
+
if (loading && messages.length === 0) {
|
|
150
|
+
return <LoadingState />;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (error && messages.length === 0) {
|
|
154
|
+
return <ErrorState message={error} onRetry={refetch} />;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
return (
|
|
158
|
+
<div className="flex h-full flex-col">
|
|
159
|
+
{/* Filter bar */}
|
|
160
|
+
<div className="flex shrink-0 items-center gap-2 border-b border-white/5 px-3 py-1.5">
|
|
161
|
+
<button
|
|
162
|
+
type="button"
|
|
163
|
+
onClick={() => setUnreadOnly(false)}
|
|
164
|
+
className={`rounded px-2 py-0.5 text-[10px] transition-colors ${
|
|
165
|
+
!unreadOnly
|
|
166
|
+
? 'bg-white/15 text-[var(--os-text-primary)]'
|
|
167
|
+
: 'text-[var(--os-text-secondary)] hover:text-[var(--os-text-primary)]'
|
|
168
|
+
}`}
|
|
169
|
+
>
|
|
170
|
+
All
|
|
171
|
+
</button>
|
|
172
|
+
<button
|
|
173
|
+
type="button"
|
|
174
|
+
onClick={() => setUnreadOnly(true)}
|
|
175
|
+
className={`rounded px-2 py-0.5 text-[10px] transition-colors ${
|
|
176
|
+
unreadOnly
|
|
177
|
+
? 'bg-white/15 text-[var(--os-text-primary)]'
|
|
178
|
+
: 'text-[var(--os-text-secondary)] hover:text-[var(--os-text-primary)]'
|
|
179
|
+
}`}
|
|
180
|
+
>
|
|
181
|
+
Unread
|
|
182
|
+
</button>
|
|
183
|
+
</div>
|
|
184
|
+
|
|
185
|
+
{/* Messages */}
|
|
186
|
+
<div className="min-h-0 flex-1 overflow-y-auto px-3 py-2">
|
|
187
|
+
{messages.length === 0 ? (
|
|
188
|
+
<EmptyState text={unreadOnly ? 'No unread messages' : 'Inbox is empty'} />
|
|
189
|
+
) : (
|
|
190
|
+
<div className="flex flex-col gap-1.5">
|
|
191
|
+
{messages.map((msg, i) => (
|
|
192
|
+
<div
|
|
193
|
+
key={`${msg.timestamp}-${i}`}
|
|
194
|
+
className={`rounded px-2 py-1.5 ${msg.read === false ? 'bg-white/10' : 'bg-white/5'}`}
|
|
195
|
+
>
|
|
196
|
+
<div className="flex items-baseline gap-1.5">
|
|
197
|
+
<span className="text-[11px] font-medium text-[var(--os-text-primary)]">{msg.from}</span>
|
|
198
|
+
<span className="text-[9px] text-[var(--os-text-secondary)]">{formatTime(msg.timestamp)}</span>
|
|
199
|
+
{msg.read === false && <span className="ml-auto h-1.5 w-1.5 shrink-0 rounded-full bg-blue-400" />}
|
|
200
|
+
</div>
|
|
201
|
+
<p className="mt-0.5 text-[11px] leading-relaxed text-[var(--os-text-secondary)] break-words whitespace-pre-wrap">
|
|
202
|
+
{msg.body}
|
|
203
|
+
</p>
|
|
204
|
+
</div>
|
|
205
|
+
))}
|
|
206
|
+
</div>
|
|
207
|
+
)}
|
|
208
|
+
</div>
|
|
209
|
+
</div>
|
|
210
|
+
);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
// --- Send Direct Message Section ---
|
|
214
|
+
|
|
215
|
+
function DirectMessageSection() {
|
|
216
|
+
const sendAction = useNatsAction(SUBJECTS.comms.send());
|
|
217
|
+
const [to, setTo] = useState('');
|
|
218
|
+
const [body, setBody] = useState('');
|
|
219
|
+
|
|
220
|
+
const handleSend = useCallback(async () => {
|
|
221
|
+
const trimmedTo = to.trim();
|
|
222
|
+
const trimmedBody = body.trim();
|
|
223
|
+
if (!trimmedTo || !trimmedBody || sendAction.loading) return;
|
|
224
|
+
try {
|
|
225
|
+
await sendAction.execute({ to: trimmedTo, body: trimmedBody });
|
|
226
|
+
setBody('');
|
|
227
|
+
} catch {
|
|
228
|
+
// error is surfaced via sendAction.error
|
|
229
|
+
}
|
|
230
|
+
}, [to, body, sendAction]);
|
|
231
|
+
|
|
232
|
+
return (
|
|
233
|
+
<div className="shrink-0 border-t border-white/10 px-3 py-2">
|
|
234
|
+
<span className="text-[10px] font-medium text-[var(--os-text-secondary)]">Direct Message</span>
|
|
235
|
+
{sendAction.error && <p className="mt-0.5 text-[9px] text-red-400 truncate">{sendAction.error}</p>}
|
|
236
|
+
<div className="mt-1 flex flex-col gap-1.5">
|
|
237
|
+
<input
|
|
238
|
+
type="text"
|
|
239
|
+
value={to}
|
|
240
|
+
onChange={(e) => setTo(e.target.value)}
|
|
241
|
+
placeholder="Recipient (agent name)"
|
|
242
|
+
className="rounded bg-white/5 px-2 py-1 text-[11px] text-[var(--os-text-primary)] placeholder:text-[var(--os-text-secondary)] outline-none focus:bg-white/10"
|
|
243
|
+
/>
|
|
244
|
+
<div className="flex gap-1.5">
|
|
245
|
+
<input
|
|
246
|
+
type="text"
|
|
247
|
+
value={body}
|
|
248
|
+
onChange={(e) => setBody(e.target.value)}
|
|
249
|
+
onKeyDown={(e) => {
|
|
250
|
+
if (e.key === 'Enter' && !e.shiftKey) {
|
|
251
|
+
e.preventDefault();
|
|
252
|
+
handleSend();
|
|
253
|
+
}
|
|
254
|
+
}}
|
|
255
|
+
placeholder="Message..."
|
|
256
|
+
className="min-w-0 flex-1 rounded bg-white/5 px-2 py-1 text-[11px] text-[var(--os-text-primary)] placeholder:text-[var(--os-text-secondary)] outline-none focus:bg-white/10"
|
|
257
|
+
/>
|
|
258
|
+
<button
|
|
259
|
+
type="button"
|
|
260
|
+
onClick={handleSend}
|
|
261
|
+
disabled={!to.trim() || !body.trim() || sendAction.loading}
|
|
262
|
+
className="shrink-0 rounded bg-white/10 px-2 py-1 text-[11px] text-[var(--os-text-primary)] hover:bg-white/20 disabled:opacity-40 disabled:cursor-not-allowed"
|
|
263
|
+
>
|
|
264
|
+
Send
|
|
265
|
+
</button>
|
|
266
|
+
</div>
|
|
267
|
+
</div>
|
|
268
|
+
</div>
|
|
269
|
+
);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
// --- Shared utilities ---
|
|
273
|
+
|
|
274
|
+
function formatTime(ts: string): string {
|
|
275
|
+
try {
|
|
276
|
+
const date = new Date(ts);
|
|
277
|
+
if (Number.isNaN(date.getTime())) return ts;
|
|
278
|
+
return date.toLocaleTimeString(undefined, { hour: '2-digit', minute: '2-digit' });
|
|
279
|
+
} catch {
|
|
280
|
+
return ts;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
function LoadingState() {
|
|
285
|
+
return (
|
|
286
|
+
<div className="flex h-full items-center justify-center p-4">
|
|
287
|
+
<p className="text-[11px] text-[var(--os-text-secondary)]">Loading...</p>
|
|
288
|
+
</div>
|
|
289
|
+
);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
function ErrorState({ message, onRetry }: { message: string; onRetry: () => void }) {
|
|
293
|
+
return (
|
|
294
|
+
<div className="flex h-full flex-col items-center justify-center gap-2 p-4">
|
|
295
|
+
<p className="text-[11px] text-red-400 text-center">{message}</p>
|
|
296
|
+
<button type="button" onClick={onRetry} className="rounded bg-white/10 px-2.5 py-1 text-[10px] hover:bg-white/20">
|
|
297
|
+
Retry
|
|
298
|
+
</button>
|
|
299
|
+
</div>
|
|
300
|
+
);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
function EmptyState({ text }: { text: string }) {
|
|
304
|
+
return (
|
|
305
|
+
<div className="flex h-full items-center justify-center p-4">
|
|
306
|
+
<p className="text-[11px] text-[var(--os-text-secondary)]">{text}</p>
|
|
307
|
+
</div>
|
|
308
|
+
);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
// --- Main ChatPanel ---
|
|
312
|
+
|
|
313
|
+
export function ChatPanel() {
|
|
314
|
+
const [activeTab, setActiveTab] = useState<ChatTab>('chat');
|
|
315
|
+
|
|
316
|
+
return (
|
|
317
|
+
<div className="flex h-full flex-col">
|
|
318
|
+
{/* Tab bar */}
|
|
319
|
+
<div className="flex shrink-0 items-center gap-1 border-b border-white/10 px-3 py-1.5">
|
|
320
|
+
<button
|
|
321
|
+
type="button"
|
|
322
|
+
onClick={() => setActiveTab('chat')}
|
|
323
|
+
className={`rounded px-2 py-0.5 text-[10px] font-medium transition-colors ${
|
|
324
|
+
activeTab === 'chat'
|
|
325
|
+
? 'bg-white/15 text-[var(--os-text-primary)]'
|
|
326
|
+
: 'text-[var(--os-text-secondary)] hover:text-[var(--os-text-primary)]'
|
|
327
|
+
}`}
|
|
328
|
+
>
|
|
329
|
+
Team Chat
|
|
330
|
+
</button>
|
|
331
|
+
<button
|
|
332
|
+
type="button"
|
|
333
|
+
onClick={() => setActiveTab('inbox')}
|
|
334
|
+
className={`rounded px-2 py-0.5 text-[10px] font-medium transition-colors ${
|
|
335
|
+
activeTab === 'inbox'
|
|
336
|
+
? 'bg-white/15 text-[var(--os-text-primary)]'
|
|
337
|
+
: 'text-[var(--os-text-secondary)] hover:text-[var(--os-text-primary)]'
|
|
338
|
+
}`}
|
|
339
|
+
>
|
|
340
|
+
Inbox
|
|
341
|
+
</button>
|
|
342
|
+
</div>
|
|
343
|
+
|
|
344
|
+
{/* Tab content */}
|
|
345
|
+
<div className="min-h-0 flex-1">{activeTab === 'chat' ? <TeamChatTab /> : <InboxTab />}</div>
|
|
346
|
+
|
|
347
|
+
{/* Direct message — always visible */}
|
|
348
|
+
<DirectMessageSection />
|
|
349
|
+
</div>
|
|
350
|
+
);
|
|
351
|
+
}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { SUBJECTS } from '../../../../lib/subjects';
|
|
4
|
+
import { useNatsRequest } from '../hooks/useNatsRequest';
|
|
5
|
+
|
|
6
|
+
// --- Types matching service/system.ts responses ---
|
|
7
|
+
|
|
8
|
+
interface DoctorCheck {
|
|
9
|
+
name: string;
|
|
10
|
+
status: 'pass' | 'warn' | 'fail';
|
|
11
|
+
detail: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
interface DoctorResult {
|
|
15
|
+
prerequisites: DoctorCheck[];
|
|
16
|
+
configuration: DoctorCheck[];
|
|
17
|
+
tmux: DoctorCheck[];
|
|
18
|
+
workerProfiles: DoctorCheck[];
|
|
19
|
+
error?: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
interface VersionResult {
|
|
23
|
+
version: string;
|
|
24
|
+
error?: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// --- Section config ---
|
|
28
|
+
|
|
29
|
+
const SECTION_LABELS: Record<keyof Omit<DoctorResult, 'error'>, string> = {
|
|
30
|
+
prerequisites: 'Prerequisites',
|
|
31
|
+
configuration: 'Configuration',
|
|
32
|
+
tmux: 'Tmux',
|
|
33
|
+
workerProfiles: 'Worker Profiles',
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const SECTION_KEYS = Object.keys(SECTION_LABELS) as (keyof typeof SECTION_LABELS)[];
|
|
37
|
+
|
|
38
|
+
// --- Status helpers ---
|
|
39
|
+
|
|
40
|
+
function statusIcon(status: 'pass' | 'warn' | 'fail') {
|
|
41
|
+
switch (status) {
|
|
42
|
+
case 'pass':
|
|
43
|
+
return <span className="text-green-400">✓</span>;
|
|
44
|
+
case 'warn':
|
|
45
|
+
return <span className="text-yellow-400">!</span>;
|
|
46
|
+
case 'fail':
|
|
47
|
+
return <span className="text-red-400">✗</span>;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function statusColor(status: 'pass' | 'warn' | 'fail') {
|
|
52
|
+
switch (status) {
|
|
53
|
+
case 'pass':
|
|
54
|
+
return 'text-green-400';
|
|
55
|
+
case 'warn':
|
|
56
|
+
return 'text-yellow-400';
|
|
57
|
+
case 'fail':
|
|
58
|
+
return 'text-red-400';
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function summarize(doctor: DoctorResult): { warnings: number; failures: number; total: number } {
|
|
63
|
+
let warnings = 0;
|
|
64
|
+
let failures = 0;
|
|
65
|
+
let total = 0;
|
|
66
|
+
|
|
67
|
+
for (const key of SECTION_KEYS) {
|
|
68
|
+
const checks = doctor[key];
|
|
69
|
+
if (!checks) continue;
|
|
70
|
+
for (const check of checks) {
|
|
71
|
+
total++;
|
|
72
|
+
if (check.status === 'warn') warnings++;
|
|
73
|
+
if (check.status === 'fail') failures++;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return { warnings, failures, total };
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// --- Components ---
|
|
81
|
+
|
|
82
|
+
function CheckRow({ check }: { check: DoctorCheck }) {
|
|
83
|
+
return (
|
|
84
|
+
<div className="flex items-start gap-2 py-1 px-2">
|
|
85
|
+
<span className="mt-0.5 shrink-0 w-4 text-center font-mono text-xs">{statusIcon(check.status)}</span>
|
|
86
|
+
<span className={`text-xs ${statusColor(check.status)} break-all`}>{check.detail}</span>
|
|
87
|
+
</div>
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function DoctorSection({ label, checks }: { label: string; checks: DoctorCheck[] }) {
|
|
92
|
+
if (checks.length === 0) return null;
|
|
93
|
+
|
|
94
|
+
return (
|
|
95
|
+
<div className="mb-3">
|
|
96
|
+
<h4 className="text-xs font-semibold text-[var(--os-text-primary)] px-2 mb-1">{label}</h4>
|
|
97
|
+
{checks.map((check, i) => (
|
|
98
|
+
<CheckRow key={`${check.name}-${i}`} check={check} />
|
|
99
|
+
))}
|
|
100
|
+
</div>
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function DoctorSummary({ doctor }: { doctor: DoctorResult }) {
|
|
105
|
+
const { warnings, failures } = summarize(doctor);
|
|
106
|
+
|
|
107
|
+
if (failures === 0 && warnings === 0) {
|
|
108
|
+
return <p className="text-xs text-green-400">All checks passed</p>;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return (
|
|
112
|
+
<p className="text-xs text-[var(--os-text-secondary)]">
|
|
113
|
+
{warnings > 0 && (
|
|
114
|
+
<span className="text-yellow-400">
|
|
115
|
+
{warnings} warning{warnings !== 1 ? 's' : ''}
|
|
116
|
+
</span>
|
|
117
|
+
)}
|
|
118
|
+
{warnings > 0 && failures > 0 && ', '}
|
|
119
|
+
{failures > 0 && (
|
|
120
|
+
<span className="text-red-400">
|
|
121
|
+
{failures} failure{failures !== 1 ? 's' : ''}
|
|
122
|
+
</span>
|
|
123
|
+
)}
|
|
124
|
+
</p>
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function VersionCard() {
|
|
129
|
+
const { data, loading, error } = useNatsRequest<VersionResult>(
|
|
130
|
+
SUBJECTS.system.version(),
|
|
131
|
+
undefined,
|
|
132
|
+
0 // no polling — version doesn't change
|
|
133
|
+
);
|
|
134
|
+
|
|
135
|
+
return (
|
|
136
|
+
<div className="rounded-md bg-white/5 p-3">
|
|
137
|
+
<h3 className="text-xs font-semibold text-[var(--os-text-secondary)] mb-1">Version</h3>
|
|
138
|
+
{loading && <p className="text-xs text-[var(--os-text-secondary)]">Loading...</p>}
|
|
139
|
+
{!loading && error && <p className="text-xs text-red-400">{error}</p>}
|
|
140
|
+
{!loading && !error && data?.error && <p className="text-xs text-red-400">{data.error}</p>}
|
|
141
|
+
{!loading && !error && !data?.error && (
|
|
142
|
+
<p className="text-sm font-mono text-[var(--os-text-primary)]">{data?.version ?? 'unknown'}</p>
|
|
143
|
+
)}
|
|
144
|
+
</div>
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function DoctorCard() {
|
|
149
|
+
const { data, loading, error, refetch } = useNatsRequest<DoctorResult>(
|
|
150
|
+
SUBJECTS.system.doctor(),
|
|
151
|
+
undefined,
|
|
152
|
+
0 // manual refresh only — doctor is expensive
|
|
153
|
+
);
|
|
154
|
+
|
|
155
|
+
return (
|
|
156
|
+
<div className="rounded-md bg-white/5 p-3">
|
|
157
|
+
<div className="flex items-center justify-between mb-2">
|
|
158
|
+
<h3 className="text-xs font-semibold text-[var(--os-text-secondary)]">Health Checks</h3>
|
|
159
|
+
<button
|
|
160
|
+
type="button"
|
|
161
|
+
onClick={refetch}
|
|
162
|
+
disabled={loading}
|
|
163
|
+
className="rounded px-2 py-0.5 text-xs bg-white/10 text-[var(--os-text-secondary)] hover:bg-white/20 hover:text-[var(--os-text-primary)] disabled:opacity-50 transition-colors"
|
|
164
|
+
>
|
|
165
|
+
{loading ? 'Checking...' : 'Refresh'}
|
|
166
|
+
</button>
|
|
167
|
+
</div>
|
|
168
|
+
|
|
169
|
+
{loading && <p className="text-xs text-[var(--os-text-secondary)]">Running doctor checks...</p>}
|
|
170
|
+
{!loading && error && <p className="text-xs text-red-400">{error}</p>}
|
|
171
|
+
{!loading && !error && data?.error && <p className="text-xs text-red-400">{data.error}</p>}
|
|
172
|
+
{!loading && !error && data && !data.error && (
|
|
173
|
+
<>
|
|
174
|
+
{SECTION_KEYS.map((key) => (
|
|
175
|
+
<DoctorSection key={key} label={SECTION_LABELS[key]} checks={data[key] ?? []} />
|
|
176
|
+
))}
|
|
177
|
+
<div className="mt-2 border-t border-white/10 pt-2 px-2">
|
|
178
|
+
<DoctorSummary doctor={data} />
|
|
179
|
+
</div>
|
|
180
|
+
</>
|
|
181
|
+
)}
|
|
182
|
+
</div>
|
|
183
|
+
);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// --- Main panel ---
|
|
187
|
+
|
|
188
|
+
export function SystemPanel() {
|
|
189
|
+
return (
|
|
190
|
+
<div className="flex flex-col gap-4 p-3">
|
|
191
|
+
<VersionCard />
|
|
192
|
+
<DoctorCard />
|
|
193
|
+
</div>
|
|
194
|
+
);
|
|
195
|
+
}
|