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,560 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useCallback, useState } from 'react';
|
|
4
|
+
import { SUBJECTS } from '../../../../lib/subjects';
|
|
5
|
+
import { useNatsAction } from '../hooks/useNatsAction';
|
|
6
|
+
import { useNatsRequest } from '../hooks/useNatsRequest';
|
|
7
|
+
|
|
8
|
+
// --- Types matching service responses ---
|
|
9
|
+
|
|
10
|
+
interface TeamListItem {
|
|
11
|
+
name: string;
|
|
12
|
+
slug?: string;
|
|
13
|
+
status?: string;
|
|
14
|
+
members?: number;
|
|
15
|
+
repo?: string;
|
|
16
|
+
branch?: string;
|
|
17
|
+
wish?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
interface TeamsListResponse {
|
|
21
|
+
teams: TeamListItem[];
|
|
22
|
+
error?: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
interface TeamMember {
|
|
26
|
+
name: string;
|
|
27
|
+
role?: string;
|
|
28
|
+
status?: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
interface TeamConfig {
|
|
32
|
+
name: string;
|
|
33
|
+
repo?: string;
|
|
34
|
+
branch?: string;
|
|
35
|
+
wish?: string;
|
|
36
|
+
status?: string;
|
|
37
|
+
members?: TeamMember[];
|
|
38
|
+
agents?: TeamMember[];
|
|
39
|
+
[key: string]: unknown;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
interface TeamGetResponse {
|
|
43
|
+
team: TeamConfig;
|
|
44
|
+
error?: string;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
interface ActionResponse {
|
|
48
|
+
ok: boolean;
|
|
49
|
+
error?: string;
|
|
50
|
+
output?: string;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// --- Status badge colors ---
|
|
54
|
+
|
|
55
|
+
const STATUS_COLORS: Record<string, { bg: string; text: string }> = {
|
|
56
|
+
done: { bg: 'bg-green-500/20', text: 'text-green-400' },
|
|
57
|
+
completed: { bg: 'bg-green-500/20', text: 'text-green-400' },
|
|
58
|
+
in_progress: { bg: 'bg-yellow-500/20', text: 'text-yellow-400' },
|
|
59
|
+
active: { bg: 'bg-yellow-500/20', text: 'text-yellow-400' },
|
|
60
|
+
working: { bg: 'bg-yellow-500/20', text: 'text-yellow-400' },
|
|
61
|
+
blocked: { bg: 'bg-red-500/20', text: 'text-red-400' },
|
|
62
|
+
error: { bg: 'bg-red-500/20', text: 'text-red-400' },
|
|
63
|
+
idle: { bg: 'bg-gray-500/20', text: 'text-gray-400' },
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
function getStatusStyle(status?: string) {
|
|
67
|
+
if (!status) return { bg: 'bg-gray-500/20', text: 'text-gray-400' };
|
|
68
|
+
return STATUS_COLORS[status.toLowerCase()] ?? { bg: 'bg-gray-500/20', text: 'text-gray-400' };
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// --- Confirmation dialog ---
|
|
72
|
+
|
|
73
|
+
function ConfirmDialog({
|
|
74
|
+
message,
|
|
75
|
+
onConfirm,
|
|
76
|
+
onCancel,
|
|
77
|
+
}: {
|
|
78
|
+
message: string;
|
|
79
|
+
onConfirm: () => void;
|
|
80
|
+
onCancel: () => void;
|
|
81
|
+
}) {
|
|
82
|
+
return (
|
|
83
|
+
<div className="fixed inset-0 z-50 flex items-center justify-center bg-black/60">
|
|
84
|
+
<div className="w-72 rounded-lg border border-white/10 bg-[#1a1a2e] p-4 shadow-xl">
|
|
85
|
+
<p className="mb-4 text-xs text-[var(--os-text-primary)]">{message}</p>
|
|
86
|
+
<div className="flex justify-end gap-2">
|
|
87
|
+
<button
|
|
88
|
+
type="button"
|
|
89
|
+
onClick={onCancel}
|
|
90
|
+
className="rounded px-3 py-1 text-xs text-[var(--os-text-secondary)] hover:bg-white/10"
|
|
91
|
+
>
|
|
92
|
+
Cancel
|
|
93
|
+
</button>
|
|
94
|
+
<button
|
|
95
|
+
type="button"
|
|
96
|
+
onClick={onConfirm}
|
|
97
|
+
className="rounded bg-red-500/20 px-3 py-1 text-xs text-red-400 hover:bg-red-500/30"
|
|
98
|
+
>
|
|
99
|
+
Confirm
|
|
100
|
+
</button>
|
|
101
|
+
</div>
|
|
102
|
+
</div>
|
|
103
|
+
</div>
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// --- Create team dialog ---
|
|
108
|
+
|
|
109
|
+
function CreateTeamDialog({ onClose, onCreated }: { onClose: () => void; onCreated: () => void }) {
|
|
110
|
+
const [name, setName] = useState('');
|
|
111
|
+
const [repo, setRepo] = useState('');
|
|
112
|
+
const [branch, setBranch] = useState('');
|
|
113
|
+
const [wish, setWish] = useState('');
|
|
114
|
+
const [resultMsg, setResultMsg] = useState<string | null>(null);
|
|
115
|
+
|
|
116
|
+
const { execute, loading, error } = useNatsAction<ActionResponse>(SUBJECTS.teams.create());
|
|
117
|
+
|
|
118
|
+
const handleSubmit = useCallback(async () => {
|
|
119
|
+
if (!name.trim() || !repo.trim()) return;
|
|
120
|
+
try {
|
|
121
|
+
const payload: Record<string, string> = { name: name.trim(), repo: repo.trim() };
|
|
122
|
+
if (branch.trim()) payload.branch = branch.trim();
|
|
123
|
+
if (wish.trim()) payload.wish = wish.trim();
|
|
124
|
+
const res = await execute(payload);
|
|
125
|
+
if (res.ok) {
|
|
126
|
+
setResultMsg('Team created successfully');
|
|
127
|
+
setTimeout(() => {
|
|
128
|
+
onCreated();
|
|
129
|
+
onClose();
|
|
130
|
+
}, 800);
|
|
131
|
+
} else {
|
|
132
|
+
setResultMsg(res.error ?? 'Create failed');
|
|
133
|
+
}
|
|
134
|
+
} catch {
|
|
135
|
+
// error state handled by hook
|
|
136
|
+
}
|
|
137
|
+
}, [name, repo, branch, wish, execute, onCreated, onClose]);
|
|
138
|
+
|
|
139
|
+
return (
|
|
140
|
+
<div className="fixed inset-0 z-50 flex items-center justify-center bg-black/60">
|
|
141
|
+
<div className="w-80 rounded-lg border border-white/10 bg-[#1a1a2e] p-4 shadow-xl">
|
|
142
|
+
<h3 className="mb-3 text-xs font-semibold text-[var(--os-text-primary)]">Create Team</h3>
|
|
143
|
+
|
|
144
|
+
<div className="flex flex-col gap-2">
|
|
145
|
+
<input
|
|
146
|
+
type="text"
|
|
147
|
+
placeholder="Team name *"
|
|
148
|
+
value={name}
|
|
149
|
+
onChange={(e) => setName(e.target.value)}
|
|
150
|
+
className="rounded border border-white/10 bg-white/5 px-2 py-1.5 text-xs text-[var(--os-text-primary)] placeholder:text-[var(--os-text-muted)] focus:border-white/20 focus:outline-none"
|
|
151
|
+
/>
|
|
152
|
+
<input
|
|
153
|
+
type="text"
|
|
154
|
+
placeholder="Repo path *"
|
|
155
|
+
value={repo}
|
|
156
|
+
onChange={(e) => setRepo(e.target.value)}
|
|
157
|
+
className="rounded border border-white/10 bg-white/5 px-2 py-1.5 text-xs text-[var(--os-text-primary)] placeholder:text-[var(--os-text-muted)] focus:border-white/20 focus:outline-none"
|
|
158
|
+
/>
|
|
159
|
+
<input
|
|
160
|
+
type="text"
|
|
161
|
+
placeholder="Branch (optional)"
|
|
162
|
+
value={branch}
|
|
163
|
+
onChange={(e) => setBranch(e.target.value)}
|
|
164
|
+
className="rounded border border-white/10 bg-white/5 px-2 py-1.5 text-xs text-[var(--os-text-primary)] placeholder:text-[var(--os-text-muted)] focus:border-white/20 focus:outline-none"
|
|
165
|
+
/>
|
|
166
|
+
<input
|
|
167
|
+
type="text"
|
|
168
|
+
placeholder="Wish slug (optional)"
|
|
169
|
+
value={wish}
|
|
170
|
+
onChange={(e) => setWish(e.target.value)}
|
|
171
|
+
className="rounded border border-white/10 bg-white/5 px-2 py-1.5 text-xs text-[var(--os-text-primary)] placeholder:text-[var(--os-text-muted)] focus:border-white/20 focus:outline-none"
|
|
172
|
+
/>
|
|
173
|
+
</div>
|
|
174
|
+
|
|
175
|
+
{error && <p className="mt-2 text-[10px] text-red-400">{error}</p>}
|
|
176
|
+
{resultMsg && <p className="mt-2 text-[10px] text-green-400">{resultMsg}</p>}
|
|
177
|
+
|
|
178
|
+
<div className="mt-3 flex justify-end gap-2">
|
|
179
|
+
<button
|
|
180
|
+
type="button"
|
|
181
|
+
onClick={onClose}
|
|
182
|
+
disabled={loading}
|
|
183
|
+
className="rounded px-3 py-1 text-xs text-[var(--os-text-secondary)] hover:bg-white/10"
|
|
184
|
+
>
|
|
185
|
+
Cancel
|
|
186
|
+
</button>
|
|
187
|
+
<button
|
|
188
|
+
type="button"
|
|
189
|
+
onClick={handleSubmit}
|
|
190
|
+
disabled={loading || !name.trim() || !repo.trim()}
|
|
191
|
+
className="rounded bg-white/10 px-3 py-1 text-xs text-[var(--os-text-primary)] hover:bg-white/15 disabled:opacity-40"
|
|
192
|
+
>
|
|
193
|
+
{loading ? 'Creating...' : 'Create'}
|
|
194
|
+
</button>
|
|
195
|
+
</div>
|
|
196
|
+
</div>
|
|
197
|
+
</div>
|
|
198
|
+
);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// --- Expanded team row (member list) ---
|
|
202
|
+
|
|
203
|
+
function TeamMembers({ teamName, onRefreshList }: { teamName: string; onRefreshList: () => void }) {
|
|
204
|
+
const { data, loading, error } = useNatsRequest<TeamGetResponse>(
|
|
205
|
+
SUBJECTS.teams.get(),
|
|
206
|
+
{ name: teamName },
|
|
207
|
+
0 // no polling, one-shot fetch
|
|
208
|
+
);
|
|
209
|
+
|
|
210
|
+
const { execute: hireAgent, loading: hiringLoading } = useNatsAction<ActionResponse>(SUBJECTS.teams.hire());
|
|
211
|
+
const { execute: fireAgent, loading: firingLoading } = useNatsAction<ActionResponse>(SUBJECTS.teams.fire());
|
|
212
|
+
|
|
213
|
+
const [hireInput, setHireInput] = useState('');
|
|
214
|
+
const [actionMsg, setActionMsg] = useState<string | null>(null);
|
|
215
|
+
const [confirmFire, setConfirmFire] = useState<string | null>(null);
|
|
216
|
+
|
|
217
|
+
const members = data?.team?.members ?? data?.team?.agents ?? [];
|
|
218
|
+
|
|
219
|
+
const handleHire = useCallback(async () => {
|
|
220
|
+
if (!hireInput.trim()) return;
|
|
221
|
+
try {
|
|
222
|
+
const res = await hireAgent({ agent: hireInput.trim(), team: teamName });
|
|
223
|
+
if (res.ok) {
|
|
224
|
+
setHireInput('');
|
|
225
|
+
setActionMsg('Agent hired');
|
|
226
|
+
onRefreshList();
|
|
227
|
+
setTimeout(() => setActionMsg(null), 2000);
|
|
228
|
+
} else {
|
|
229
|
+
setActionMsg(res.error ?? 'Hire failed');
|
|
230
|
+
}
|
|
231
|
+
} catch {
|
|
232
|
+
// error state from hook
|
|
233
|
+
}
|
|
234
|
+
}, [hireInput, teamName, hireAgent, onRefreshList]);
|
|
235
|
+
|
|
236
|
+
const handleFire = useCallback(
|
|
237
|
+
async (agentName: string) => {
|
|
238
|
+
try {
|
|
239
|
+
const res = await fireAgent({ agent: agentName, team: teamName });
|
|
240
|
+
if (res.ok) {
|
|
241
|
+
setConfirmFire(null);
|
|
242
|
+
setActionMsg('Agent fired');
|
|
243
|
+
onRefreshList();
|
|
244
|
+
setTimeout(() => setActionMsg(null), 2000);
|
|
245
|
+
} else {
|
|
246
|
+
setActionMsg(res.error ?? 'Fire failed');
|
|
247
|
+
}
|
|
248
|
+
} catch {
|
|
249
|
+
// error state from hook
|
|
250
|
+
}
|
|
251
|
+
},
|
|
252
|
+
[teamName, fireAgent, onRefreshList]
|
|
253
|
+
);
|
|
254
|
+
|
|
255
|
+
if (loading) {
|
|
256
|
+
return <p className="px-3 py-2 text-[10px] text-[var(--os-text-muted)]">Loading members...</p>;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
if (error) {
|
|
260
|
+
return <p className="px-3 py-2 text-[10px] text-red-400">{error}</p>;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
return (
|
|
264
|
+
<div className="border-t border-white/5 bg-white/[0.02] px-3 py-2">
|
|
265
|
+
{/* Member list */}
|
|
266
|
+
{members.length === 0 ? (
|
|
267
|
+
<p className="text-[10px] text-[var(--os-text-muted)]">No members</p>
|
|
268
|
+
) : (
|
|
269
|
+
<div className="flex flex-col gap-1">
|
|
270
|
+
{members.map((member) => {
|
|
271
|
+
const m = typeof member === 'string' ? { name: member } : member;
|
|
272
|
+
return (
|
|
273
|
+
<div key={m.name} className="flex items-center justify-between gap-2">
|
|
274
|
+
<div className="flex items-center gap-1.5 min-w-0">
|
|
275
|
+
<span className="truncate text-[11px] text-[var(--os-text-primary)]">{m.name}</span>
|
|
276
|
+
{m.role && (
|
|
277
|
+
<span className="shrink-0 rounded bg-white/10 px-1 py-0.5 text-[9px] text-[var(--os-text-secondary)]">
|
|
278
|
+
{m.role}
|
|
279
|
+
</span>
|
|
280
|
+
)}
|
|
281
|
+
</div>
|
|
282
|
+
<button
|
|
283
|
+
type="button"
|
|
284
|
+
onClick={() => setConfirmFire(m.name)}
|
|
285
|
+
disabled={firingLoading}
|
|
286
|
+
className="shrink-0 rounded px-1.5 py-0.5 text-[9px] text-red-400 hover:bg-red-500/10"
|
|
287
|
+
>
|
|
288
|
+
Fire
|
|
289
|
+
</button>
|
|
290
|
+
</div>
|
|
291
|
+
);
|
|
292
|
+
})}
|
|
293
|
+
</div>
|
|
294
|
+
)}
|
|
295
|
+
|
|
296
|
+
{/* Hire input */}
|
|
297
|
+
<div className="mt-2 flex items-center gap-1">
|
|
298
|
+
<input
|
|
299
|
+
type="text"
|
|
300
|
+
placeholder="Agent name"
|
|
301
|
+
value={hireInput}
|
|
302
|
+
onChange={(e) => setHireInput(e.target.value)}
|
|
303
|
+
onKeyDown={(e) => e.key === 'Enter' && handleHire()}
|
|
304
|
+
className="min-w-0 flex-1 rounded border border-white/10 bg-white/5 px-2 py-1 text-[10px] text-[var(--os-text-primary)] placeholder:text-[var(--os-text-muted)] focus:border-white/20 focus:outline-none"
|
|
305
|
+
/>
|
|
306
|
+
<button
|
|
307
|
+
type="button"
|
|
308
|
+
onClick={handleHire}
|
|
309
|
+
disabled={hiringLoading || !hireInput.trim()}
|
|
310
|
+
className="shrink-0 rounded bg-white/10 px-2 py-1 text-[10px] text-[var(--os-text-primary)] hover:bg-white/15 disabled:opacity-40"
|
|
311
|
+
>
|
|
312
|
+
Hire
|
|
313
|
+
</button>
|
|
314
|
+
</div>
|
|
315
|
+
|
|
316
|
+
{actionMsg && <p className="mt-1 text-[10px] text-green-400">{actionMsg}</p>}
|
|
317
|
+
|
|
318
|
+
{confirmFire && (
|
|
319
|
+
<ConfirmDialog
|
|
320
|
+
message={`Fire agent "${confirmFire}" from team "${teamName}"?`}
|
|
321
|
+
onConfirm={() => handleFire(confirmFire)}
|
|
322
|
+
onCancel={() => setConfirmFire(null)}
|
|
323
|
+
/>
|
|
324
|
+
)}
|
|
325
|
+
</div>
|
|
326
|
+
);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
// --- Team row ---
|
|
330
|
+
|
|
331
|
+
function TeamRow({
|
|
332
|
+
team,
|
|
333
|
+
isExpanded,
|
|
334
|
+
onToggle,
|
|
335
|
+
onRefreshList,
|
|
336
|
+
}: {
|
|
337
|
+
team: TeamListItem;
|
|
338
|
+
isExpanded: boolean;
|
|
339
|
+
onToggle: () => void;
|
|
340
|
+
onRefreshList: () => void;
|
|
341
|
+
}) {
|
|
342
|
+
const { execute: disbandTeam, loading: disbandLoading } = useNatsAction<ActionResponse>(SUBJECTS.teams.disband());
|
|
343
|
+
const { execute: markDone, loading: doneLoading } = useNatsAction<ActionResponse>(SUBJECTS.teams.done());
|
|
344
|
+
const { execute: markBlocked, loading: blockedLoading } = useNatsAction<ActionResponse>(SUBJECTS.teams.blocked());
|
|
345
|
+
|
|
346
|
+
const [confirmAction, setConfirmAction] = useState<{ type: string; fn: () => void } | null>(null);
|
|
347
|
+
|
|
348
|
+
const statusStyle = getStatusStyle(team.status);
|
|
349
|
+
|
|
350
|
+
const handleDisband = useCallback(async () => {
|
|
351
|
+
try {
|
|
352
|
+
await disbandTeam({ name: team.name });
|
|
353
|
+
onRefreshList();
|
|
354
|
+
} catch {
|
|
355
|
+
// error from hook
|
|
356
|
+
}
|
|
357
|
+
}, [team.name, disbandTeam, onRefreshList]);
|
|
358
|
+
|
|
359
|
+
const handleDone = useCallback(async () => {
|
|
360
|
+
try {
|
|
361
|
+
await markDone({ name: team.name });
|
|
362
|
+
onRefreshList();
|
|
363
|
+
} catch {
|
|
364
|
+
// error from hook
|
|
365
|
+
}
|
|
366
|
+
}, [team.name, markDone, onRefreshList]);
|
|
367
|
+
|
|
368
|
+
const handleBlocked = useCallback(async () => {
|
|
369
|
+
try {
|
|
370
|
+
await markBlocked({ name: team.name });
|
|
371
|
+
onRefreshList();
|
|
372
|
+
} catch {
|
|
373
|
+
// error from hook
|
|
374
|
+
}
|
|
375
|
+
}, [team.name, markBlocked, onRefreshList]);
|
|
376
|
+
|
|
377
|
+
const actionLoading = disbandLoading || doneLoading || blockedLoading;
|
|
378
|
+
|
|
379
|
+
return (
|
|
380
|
+
<div className="border-b border-white/5">
|
|
381
|
+
{/* Main row */}
|
|
382
|
+
<div
|
|
383
|
+
className="flex cursor-pointer items-center gap-2 px-3 py-2 hover:bg-white/5"
|
|
384
|
+
onClick={onToggle}
|
|
385
|
+
onKeyDown={(e) => e.key === 'Enter' && onToggle()}
|
|
386
|
+
role="button"
|
|
387
|
+
tabIndex={0}
|
|
388
|
+
>
|
|
389
|
+
{/* Expand chevron */}
|
|
390
|
+
<span
|
|
391
|
+
className="shrink-0 text-[10px] text-[var(--os-text-muted)] transition-transform"
|
|
392
|
+
style={{ transform: isExpanded ? 'rotate(90deg)' : 'rotate(0deg)' }}
|
|
393
|
+
>
|
|
394
|
+
▶
|
|
395
|
+
</span>
|
|
396
|
+
|
|
397
|
+
{/* Team name */}
|
|
398
|
+
<span className="min-w-0 flex-1 truncate text-[11px] font-medium text-[var(--os-text-primary)]">
|
|
399
|
+
{team.name}
|
|
400
|
+
</span>
|
|
401
|
+
|
|
402
|
+
{/* Status badge */}
|
|
403
|
+
{team.status && (
|
|
404
|
+
<span className={`shrink-0 rounded px-1.5 py-0.5 text-[9px] ${statusStyle.bg} ${statusStyle.text}`}>
|
|
405
|
+
{team.status}
|
|
406
|
+
</span>
|
|
407
|
+
)}
|
|
408
|
+
|
|
409
|
+
{/* Member count */}
|
|
410
|
+
{team.members != null && (
|
|
411
|
+
<span className="shrink-0 text-[10px] text-[var(--os-text-muted)]">{team.members}m</span>
|
|
412
|
+
)}
|
|
413
|
+
</div>
|
|
414
|
+
|
|
415
|
+
{/* Info row (repo) */}
|
|
416
|
+
{isExpanded && team.repo && (
|
|
417
|
+
<div className="px-3 pb-1 pl-7">
|
|
418
|
+
<span className="text-[10px] text-[var(--os-text-muted)]">{team.repo}</span>
|
|
419
|
+
</div>
|
|
420
|
+
)}
|
|
421
|
+
|
|
422
|
+
{/* Action buttons */}
|
|
423
|
+
{isExpanded && (
|
|
424
|
+
<div className="flex items-center gap-1 px-3 pb-2 pl-7">
|
|
425
|
+
<button
|
|
426
|
+
type="button"
|
|
427
|
+
onClick={(e) => {
|
|
428
|
+
e.stopPropagation();
|
|
429
|
+
handleDone();
|
|
430
|
+
}}
|
|
431
|
+
disabled={actionLoading}
|
|
432
|
+
className="rounded bg-green-500/10 px-2 py-0.5 text-[9px] text-green-400 hover:bg-green-500/20 disabled:opacity-40"
|
|
433
|
+
>
|
|
434
|
+
Done
|
|
435
|
+
</button>
|
|
436
|
+
<button
|
|
437
|
+
type="button"
|
|
438
|
+
onClick={(e) => {
|
|
439
|
+
e.stopPropagation();
|
|
440
|
+
handleBlocked();
|
|
441
|
+
}}
|
|
442
|
+
disabled={actionLoading}
|
|
443
|
+
className="rounded bg-yellow-500/10 px-2 py-0.5 text-[9px] text-yellow-400 hover:bg-yellow-500/20 disabled:opacity-40"
|
|
444
|
+
>
|
|
445
|
+
Blocked
|
|
446
|
+
</button>
|
|
447
|
+
<button
|
|
448
|
+
type="button"
|
|
449
|
+
onClick={(e) => {
|
|
450
|
+
e.stopPropagation();
|
|
451
|
+
setConfirmAction({ type: 'disband', fn: handleDisband });
|
|
452
|
+
}}
|
|
453
|
+
disabled={actionLoading}
|
|
454
|
+
className="rounded bg-red-500/10 px-2 py-0.5 text-[9px] text-red-400 hover:bg-red-500/20 disabled:opacity-40"
|
|
455
|
+
>
|
|
456
|
+
Disband
|
|
457
|
+
</button>
|
|
458
|
+
</div>
|
|
459
|
+
)}
|
|
460
|
+
|
|
461
|
+
{/* Expanded member list */}
|
|
462
|
+
{isExpanded && <TeamMembers teamName={team.name} onRefreshList={onRefreshList} />}
|
|
463
|
+
|
|
464
|
+
{/* Confirm dialog */}
|
|
465
|
+
{confirmAction && (
|
|
466
|
+
<ConfirmDialog
|
|
467
|
+
message={`Are you sure you want to ${confirmAction.type} team "${team.name}"?`}
|
|
468
|
+
onConfirm={() => {
|
|
469
|
+
confirmAction.fn();
|
|
470
|
+
setConfirmAction(null);
|
|
471
|
+
}}
|
|
472
|
+
onCancel={() => setConfirmAction(null)}
|
|
473
|
+
/>
|
|
474
|
+
)}
|
|
475
|
+
</div>
|
|
476
|
+
);
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
// --- Main TeamsPanel ---
|
|
480
|
+
|
|
481
|
+
export function TeamsPanel() {
|
|
482
|
+
const { data, loading, error, refetch } = useNatsRequest<TeamsListResponse>(SUBJECTS.teams.list(), undefined, 5000);
|
|
483
|
+
|
|
484
|
+
const [expandedTeam, setExpandedTeam] = useState<string | null>(null);
|
|
485
|
+
const [showCreateDialog, setShowCreateDialog] = useState(false);
|
|
486
|
+
|
|
487
|
+
const teams = data?.teams ?? [];
|
|
488
|
+
|
|
489
|
+
const handleToggle = useCallback((teamName: string) => {
|
|
490
|
+
setExpandedTeam((prev) => (prev === teamName ? null : teamName));
|
|
491
|
+
}, []);
|
|
492
|
+
|
|
493
|
+
// Loading state
|
|
494
|
+
if (loading && !data) {
|
|
495
|
+
return (
|
|
496
|
+
<div className="flex h-32 items-center justify-center">
|
|
497
|
+
<p className="text-xs text-[var(--os-text-secondary)]">Loading teams...</p>
|
|
498
|
+
</div>
|
|
499
|
+
);
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
// Error state
|
|
503
|
+
if (error && !data) {
|
|
504
|
+
return (
|
|
505
|
+
<div className="flex flex-col items-center justify-center gap-2 p-4">
|
|
506
|
+
<p className="text-xs text-red-400">{error}</p>
|
|
507
|
+
<button type="button" onClick={refetch} className="rounded bg-white/10 px-3 py-1 text-xs hover:bg-white/20">
|
|
508
|
+
Retry
|
|
509
|
+
</button>
|
|
510
|
+
</div>
|
|
511
|
+
);
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
return (
|
|
515
|
+
<div className="flex h-full flex-col">
|
|
516
|
+
{/* Header with create button */}
|
|
517
|
+
<div className="flex items-center justify-between border-b border-white/10 px-3 py-1.5">
|
|
518
|
+
<span className="text-[10px] text-[var(--os-text-muted)]">
|
|
519
|
+
{teams.length} team{teams.length !== 1 ? 's' : ''}
|
|
520
|
+
</span>
|
|
521
|
+
<button
|
|
522
|
+
type="button"
|
|
523
|
+
onClick={() => setShowCreateDialog(true)}
|
|
524
|
+
className="rounded bg-white/10 px-2 py-0.5 text-[10px] text-[var(--os-text-primary)] hover:bg-white/15"
|
|
525
|
+
>
|
|
526
|
+
+ New
|
|
527
|
+
</button>
|
|
528
|
+
</div>
|
|
529
|
+
|
|
530
|
+
{/* Team list */}
|
|
531
|
+
<div className="min-h-0 flex-1 overflow-y-auto">
|
|
532
|
+
{teams.length === 0 ? (
|
|
533
|
+
<div className="flex h-24 items-center justify-center">
|
|
534
|
+
<p className="text-xs text-[var(--os-text-muted)]">No teams found</p>
|
|
535
|
+
</div>
|
|
536
|
+
) : (
|
|
537
|
+
teams.map((team) => (
|
|
538
|
+
<TeamRow
|
|
539
|
+
key={team.name}
|
|
540
|
+
team={team}
|
|
541
|
+
isExpanded={expandedTeam === team.name}
|
|
542
|
+
onToggle={() => handleToggle(team.name)}
|
|
543
|
+
onRefreshList={refetch}
|
|
544
|
+
/>
|
|
545
|
+
))
|
|
546
|
+
)}
|
|
547
|
+
</div>
|
|
548
|
+
|
|
549
|
+
{/* Error banner (when we have data but polling failed) */}
|
|
550
|
+
{error && data && (
|
|
551
|
+
<div className="shrink-0 border-t border-red-500/20 bg-red-500/5 px-3 py-1">
|
|
552
|
+
<p className="text-[10px] text-red-400">{error}</p>
|
|
553
|
+
</div>
|
|
554
|
+
)}
|
|
555
|
+
|
|
556
|
+
{/* Create dialog */}
|
|
557
|
+
{showCreateDialog && <CreateTeamDialog onClose={() => setShowCreateDialog(false)} onCreated={refetch} />}
|
|
558
|
+
</div>
|
|
559
|
+
);
|
|
560
|
+
}
|