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,212 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useCallback, useState } from 'react';
|
|
4
|
+
import { AgentsPanel } from './panels/AgentsPanel';
|
|
5
|
+
import { ChatPanel } from './panels/ChatPanel';
|
|
6
|
+
import { SystemPanel } from './panels/SystemPanel';
|
|
7
|
+
import { TeamsPanel } from './panels/TeamsPanel';
|
|
8
|
+
import { WishesPanel } from './panels/WishesPanel';
|
|
9
|
+
|
|
10
|
+
// --- Panel definitions ---
|
|
11
|
+
|
|
12
|
+
export type PanelId = 'teams' | 'agents' | 'wishes' | 'chat' | 'system';
|
|
13
|
+
|
|
14
|
+
interface PanelDef {
|
|
15
|
+
id: PanelId;
|
|
16
|
+
label: string;
|
|
17
|
+
icon: React.ReactNode;
|
|
18
|
+
component: React.ComponentType;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// SVG icons (16x16) matching the existing design language
|
|
22
|
+
function UsersIcon() {
|
|
23
|
+
return (
|
|
24
|
+
<svg
|
|
25
|
+
width="16"
|
|
26
|
+
height="16"
|
|
27
|
+
viewBox="0 0 16 16"
|
|
28
|
+
fill="none"
|
|
29
|
+
stroke="currentColor"
|
|
30
|
+
strokeWidth="1.5"
|
|
31
|
+
strokeLinecap="round"
|
|
32
|
+
strokeLinejoin="round"
|
|
33
|
+
>
|
|
34
|
+
<title>Teams</title>
|
|
35
|
+
<circle cx="6" cy="5" r="2.5" />
|
|
36
|
+
<path d="M2 13.5c0-2.5 1.8-4 4-4s4 1.5 4 4" />
|
|
37
|
+
<circle cx="11" cy="4.5" r="1.8" />
|
|
38
|
+
<path d="M11.5 9.5c1.5.3 2.5 1.5 2.5 3" />
|
|
39
|
+
</svg>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function BotIcon() {
|
|
44
|
+
return (
|
|
45
|
+
<svg
|
|
46
|
+
width="16"
|
|
47
|
+
height="16"
|
|
48
|
+
viewBox="0 0 16 16"
|
|
49
|
+
fill="none"
|
|
50
|
+
stroke="currentColor"
|
|
51
|
+
strokeWidth="1.5"
|
|
52
|
+
strokeLinecap="round"
|
|
53
|
+
strokeLinejoin="round"
|
|
54
|
+
>
|
|
55
|
+
<title>Agents</title>
|
|
56
|
+
<rect x="2" y="4" width="12" height="9" rx="2" />
|
|
57
|
+
<circle cx="5.5" cy="8.5" r="1" />
|
|
58
|
+
<circle cx="10.5" cy="8.5" r="1" />
|
|
59
|
+
<path d="M8 1v3" />
|
|
60
|
+
<circle cx="8" cy="1" r="0.8" fill="currentColor" />
|
|
61
|
+
</svg>
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function WandIcon() {
|
|
66
|
+
return (
|
|
67
|
+
<svg
|
|
68
|
+
width="16"
|
|
69
|
+
height="16"
|
|
70
|
+
viewBox="0 0 16 16"
|
|
71
|
+
fill="none"
|
|
72
|
+
stroke="currentColor"
|
|
73
|
+
strokeWidth="1.5"
|
|
74
|
+
strokeLinecap="round"
|
|
75
|
+
strokeLinejoin="round"
|
|
76
|
+
>
|
|
77
|
+
<title>Wishes</title>
|
|
78
|
+
<path d="M9 2l1 2.5L12.5 5l-2 1.8.5 2.7L9 8.3 6.5 9.5l.5-2.7-2-1.8L7.5 4.5z" />
|
|
79
|
+
<path d="M5 11l-3 3" />
|
|
80
|
+
</svg>
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function ChatIcon() {
|
|
85
|
+
return (
|
|
86
|
+
<svg
|
|
87
|
+
width="16"
|
|
88
|
+
height="16"
|
|
89
|
+
viewBox="0 0 16 16"
|
|
90
|
+
fill="none"
|
|
91
|
+
stroke="currentColor"
|
|
92
|
+
strokeWidth="1.5"
|
|
93
|
+
strokeLinecap="round"
|
|
94
|
+
strokeLinejoin="round"
|
|
95
|
+
>
|
|
96
|
+
<title>Chat</title>
|
|
97
|
+
<path d="M2 3h12a1 1 0 011 1v7a1 1 0 01-1 1H5l-3 2.5V4a1 1 0 011-1z" />
|
|
98
|
+
</svg>
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function HeartPulseIcon() {
|
|
103
|
+
return (
|
|
104
|
+
<svg
|
|
105
|
+
width="16"
|
|
106
|
+
height="16"
|
|
107
|
+
viewBox="0 0 16 16"
|
|
108
|
+
fill="none"
|
|
109
|
+
stroke="currentColor"
|
|
110
|
+
strokeWidth="1.5"
|
|
111
|
+
strokeLinecap="round"
|
|
112
|
+
strokeLinejoin="round"
|
|
113
|
+
>
|
|
114
|
+
<title>System</title>
|
|
115
|
+
<path d="M1 8h3l1.5-3 2 6 1.5-3H12" />
|
|
116
|
+
<path d="M13.5 6.5a2.5 2.5 0 00-4.2-1.8L8 6l-1.3-1.3a2.5 2.5 0 00-4.2 1.8" />
|
|
117
|
+
</svg>
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const PANELS: PanelDef[] = [
|
|
122
|
+
{ id: 'teams', label: 'Teams', icon: <UsersIcon />, component: TeamsPanel },
|
|
123
|
+
{ id: 'agents', label: 'Agents', icon: <BotIcon />, component: AgentsPanel },
|
|
124
|
+
{ id: 'wishes', label: 'Wishes', icon: <WandIcon />, component: WishesPanel },
|
|
125
|
+
{ id: 'chat', label: 'Chat', icon: <ChatIcon />, component: ChatPanel },
|
|
126
|
+
{ id: 'system', label: 'System', icon: <HeartPulseIcon />, component: SystemPanel },
|
|
127
|
+
];
|
|
128
|
+
|
|
129
|
+
const COLLAPSED_WIDTH = 48;
|
|
130
|
+
const EXPANDED_WIDTH = 280;
|
|
131
|
+
|
|
132
|
+
// --- Sidebar component ---
|
|
133
|
+
|
|
134
|
+
export function Sidebar() {
|
|
135
|
+
const [activePanel, setActivePanel] = useState<PanelId | null>(null);
|
|
136
|
+
// Track which panels have been opened at least once (lazy mount)
|
|
137
|
+
const [mounted, setMounted] = useState<Set<PanelId>>(new Set());
|
|
138
|
+
|
|
139
|
+
const expanded = activePanel !== null;
|
|
140
|
+
|
|
141
|
+
const handleIconClick = useCallback((panelId: PanelId) => {
|
|
142
|
+
setActivePanel((prev) => (prev === panelId ? null : panelId));
|
|
143
|
+
setMounted((prev) => {
|
|
144
|
+
if (prev.has(panelId)) return prev;
|
|
145
|
+
const next = new Set(prev);
|
|
146
|
+
next.add(panelId);
|
|
147
|
+
return next;
|
|
148
|
+
});
|
|
149
|
+
}, []);
|
|
150
|
+
|
|
151
|
+
return (
|
|
152
|
+
<div
|
|
153
|
+
className="flex h-full shrink-0 border-r border-white/10 bg-black/30 overflow-hidden"
|
|
154
|
+
style={{
|
|
155
|
+
width: expanded ? EXPANDED_WIDTH : COLLAPSED_WIDTH,
|
|
156
|
+
transition: 'width 200ms cubic-bezier(0.4, 0, 0.2, 1)',
|
|
157
|
+
}}
|
|
158
|
+
>
|
|
159
|
+
{/* Icon rail */}
|
|
160
|
+
<div className="flex w-12 shrink-0 flex-col items-center gap-1 py-2">
|
|
161
|
+
{PANELS.map((panel) => {
|
|
162
|
+
const isActive = activePanel === panel.id;
|
|
163
|
+
return (
|
|
164
|
+
<button
|
|
165
|
+
key={panel.id}
|
|
166
|
+
type="button"
|
|
167
|
+
onClick={() => handleIconClick(panel.id)}
|
|
168
|
+
className={`flex h-9 w-9 items-center justify-center rounded-md transition-colors ${
|
|
169
|
+
isActive
|
|
170
|
+
? 'bg-white/15 text-[var(--os-text-primary)]'
|
|
171
|
+
: 'text-[var(--os-text-secondary)] hover:bg-white/10 hover:text-[var(--os-text-primary)]'
|
|
172
|
+
}`}
|
|
173
|
+
title={panel.label}
|
|
174
|
+
>
|
|
175
|
+
{panel.icon}
|
|
176
|
+
</button>
|
|
177
|
+
);
|
|
178
|
+
})}
|
|
179
|
+
</div>
|
|
180
|
+
|
|
181
|
+
{/* Panel content area — always rendered when expanded to preserve state */}
|
|
182
|
+
{expanded && (
|
|
183
|
+
<div className="flex min-w-0 flex-1 flex-col overflow-hidden border-l border-white/5">
|
|
184
|
+
{/* Panel header */}
|
|
185
|
+
<div className="flex shrink-0 items-center px-3 py-2 border-b border-white/10">
|
|
186
|
+
<span className="text-xs font-semibold text-[var(--os-text-primary)]">
|
|
187
|
+
{PANELS.find((p) => p.id === activePanel)?.label}
|
|
188
|
+
</span>
|
|
189
|
+
</div>
|
|
190
|
+
|
|
191
|
+
{/* Panel bodies — render all mounted panels, show only active */}
|
|
192
|
+
<div className="min-h-0 flex-1 relative">
|
|
193
|
+
{PANELS.map((panel) => {
|
|
194
|
+
if (!mounted.has(panel.id)) return null;
|
|
195
|
+
const isActive = activePanel === panel.id;
|
|
196
|
+
const PanelComponent = panel.component;
|
|
197
|
+
return (
|
|
198
|
+
<div
|
|
199
|
+
key={panel.id}
|
|
200
|
+
className="absolute inset-0 overflow-y-auto"
|
|
201
|
+
style={{ display: isActive ? 'block' : 'none' }}
|
|
202
|
+
>
|
|
203
|
+
<PanelComponent />
|
|
204
|
+
</div>
|
|
205
|
+
);
|
|
206
|
+
})}
|
|
207
|
+
</div>
|
|
208
|
+
</div>
|
|
209
|
+
)}
|
|
210
|
+
</div>
|
|
211
|
+
);
|
|
212
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
interface SessionTab {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
paneCount: number;
|
|
7
|
+
color: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
interface TabBarProps {
|
|
11
|
+
tabs: SessionTab[];
|
|
12
|
+
activeSessionId: string | null;
|
|
13
|
+
onSelectSession: (sessionId: string) => void;
|
|
14
|
+
onResetLayout?: () => void;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function TabBar({ tabs, activeSessionId, onSelectSession, onResetLayout }: TabBarProps) {
|
|
18
|
+
if (tabs.length === 0) return null;
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<div className="flex items-center gap-0.5 overflow-x-auto border-b border-white/10 bg-black/30 px-1">
|
|
22
|
+
{tabs.map((tab) => {
|
|
23
|
+
const isActive = tab.id === activeSessionId;
|
|
24
|
+
return (
|
|
25
|
+
<button
|
|
26
|
+
key={tab.id}
|
|
27
|
+
type="button"
|
|
28
|
+
onClick={() => onSelectSession(tab.id)}
|
|
29
|
+
className={`group flex shrink-0 items-center gap-2 border-b-2 px-3 py-2 text-xs transition-colors ${
|
|
30
|
+
isActive
|
|
31
|
+
? 'border-current text-[var(--os-text-primary)]'
|
|
32
|
+
: 'border-transparent text-[var(--os-text-secondary)] hover:text-[var(--os-text-primary)]'
|
|
33
|
+
}`}
|
|
34
|
+
style={{
|
|
35
|
+
borderLeftWidth: 3,
|
|
36
|
+
borderLeftStyle: 'solid',
|
|
37
|
+
borderLeftColor: tab.color,
|
|
38
|
+
}}
|
|
39
|
+
>
|
|
40
|
+
<span className="font-medium">{tab.name}</span>
|
|
41
|
+
<span
|
|
42
|
+
className={`rounded-full px-1.5 py-0.5 text-[10px] leading-none ${
|
|
43
|
+
isActive ? 'bg-white/10 text-[var(--os-text-primary)]' : 'bg-white/5 text-[var(--os-text-secondary)]'
|
|
44
|
+
}`}
|
|
45
|
+
>
|
|
46
|
+
{tab.paneCount}
|
|
47
|
+
</span>
|
|
48
|
+
</button>
|
|
49
|
+
);
|
|
50
|
+
})}
|
|
51
|
+
|
|
52
|
+
{/* Spacer */}
|
|
53
|
+
<div className="flex-1" />
|
|
54
|
+
|
|
55
|
+
{/* Reset layout button */}
|
|
56
|
+
{onResetLayout && (
|
|
57
|
+
<button
|
|
58
|
+
type="button"
|
|
59
|
+
onClick={onResetLayout}
|
|
60
|
+
className="shrink-0 rounded px-2 py-1 text-[10px] text-[var(--os-text-secondary)] hover:bg-white/10 hover:text-[var(--os-text-primary)]"
|
|
61
|
+
title="Reset layout to auto-grid"
|
|
62
|
+
>
|
|
63
|
+
Reset Layout
|
|
64
|
+
</button>
|
|
65
|
+
)}
|
|
66
|
+
</div>
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export type { SessionTab };
|
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import type React from 'react';
|
|
4
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
5
|
+
import type { Layout } from 'react-grid-layout';
|
|
6
|
+
import RGL, { WidthProvider } from 'react-grid-layout';
|
|
7
|
+
import 'react-grid-layout/css/styles.css';
|
|
8
|
+
import { getNatsClient } from '@/lib/nats-client';
|
|
9
|
+
import { SUBJECTS } from '../../../lib/subjects';
|
|
10
|
+
import { PaneCard } from './PaneCard';
|
|
11
|
+
import { Sidebar } from './Sidebar';
|
|
12
|
+
import { type SessionTab, TabBar } from './TabBar';
|
|
13
|
+
|
|
14
|
+
// --- Types ---
|
|
15
|
+
|
|
16
|
+
interface PaneData {
|
|
17
|
+
id: string;
|
|
18
|
+
windowId: string;
|
|
19
|
+
active: boolean;
|
|
20
|
+
pid: number;
|
|
21
|
+
command: string;
|
|
22
|
+
title: string;
|
|
23
|
+
left: number;
|
|
24
|
+
top: number;
|
|
25
|
+
width: number;
|
|
26
|
+
height: number;
|
|
27
|
+
dead: boolean;
|
|
28
|
+
agent: { name: string; color: string; state: string; role: string } | null;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
interface WindowData {
|
|
32
|
+
id: string;
|
|
33
|
+
name: string;
|
|
34
|
+
panes: PaneData[];
|
|
35
|
+
active: boolean;
|
|
36
|
+
sessionId: string;
|
|
37
|
+
width: number;
|
|
38
|
+
height: number;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
interface SessionData {
|
|
42
|
+
id: string;
|
|
43
|
+
name: string;
|
|
44
|
+
windows: WindowData[];
|
|
45
|
+
attached: number;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
interface AgentsResponse {
|
|
49
|
+
sessions: SessionData[];
|
|
50
|
+
error?: string;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// --- Constants ---
|
|
54
|
+
|
|
55
|
+
const SESSION_COLORS = ['#a855f7', '#3b82f6', '#22c55e', '#f97316', '#ec4899', '#06b6d4', '#eab308', '#ef4444'];
|
|
56
|
+
const GRID_COLS = 12;
|
|
57
|
+
const ROW_HEIGHT = 75;
|
|
58
|
+
const LAYOUT_KEY_PREFIX = 'genie-canvas-layout-';
|
|
59
|
+
|
|
60
|
+
// --- Grid Layout ---
|
|
61
|
+
|
|
62
|
+
const GridLayout = WidthProvider(RGL);
|
|
63
|
+
|
|
64
|
+
function storageKey(sessionName: string): string {
|
|
65
|
+
return `${LAYOUT_KEY_PREFIX}${sessionName}`;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function computeAutoLayout(panes: PaneData[], offset = 0): Layout[] {
|
|
69
|
+
const total = panes.length + offset;
|
|
70
|
+
const gridCols = total <= 4 ? 2 : total <= 9 ? 3 : 4;
|
|
71
|
+
const w = GRID_COLS / gridCols;
|
|
72
|
+
const h = 4; // 4 * 75px = 300px
|
|
73
|
+
|
|
74
|
+
return panes.map((pane, i) => {
|
|
75
|
+
const idx = i + offset;
|
|
76
|
+
return {
|
|
77
|
+
i: pane.id,
|
|
78
|
+
x: (idx % gridCols) * w,
|
|
79
|
+
y: Math.floor(idx / gridCols) * h,
|
|
80
|
+
w,
|
|
81
|
+
h,
|
|
82
|
+
minH: 3,
|
|
83
|
+
minW: 2,
|
|
84
|
+
};
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function loadSavedLayout(sessionName: string): Layout[] | null {
|
|
89
|
+
try {
|
|
90
|
+
const stored = localStorage.getItem(storageKey(sessionName));
|
|
91
|
+
if (!stored) return null;
|
|
92
|
+
return JSON.parse(stored);
|
|
93
|
+
} catch {
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function mergeLayout(saved: Layout[] | null, panes: PaneData[]): Layout[] {
|
|
99
|
+
if (!saved || saved.length === 0) return computeAutoLayout(panes);
|
|
100
|
+
|
|
101
|
+
const paneIds = new Set(panes.map((p) => p.id));
|
|
102
|
+
|
|
103
|
+
// Keep saved positions for panes that still exist
|
|
104
|
+
const kept = saved.filter((item) => paneIds.has(item.i));
|
|
105
|
+
const keptIds = new Set(kept.map((item) => item.i));
|
|
106
|
+
|
|
107
|
+
// Auto-place new panes at the end of the grid
|
|
108
|
+
const newPanes = panes.filter((p) => !keptIds.has(p.id));
|
|
109
|
+
if (newPanes.length === 0) return kept;
|
|
110
|
+
|
|
111
|
+
const autoPlaced = computeAutoLayout(newPanes, kept.length);
|
|
112
|
+
return [...kept, ...autoPlaced];
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function paneIdKey(panes: PaneData[]): string {
|
|
116
|
+
return panes
|
|
117
|
+
.map((p) => p.id)
|
|
118
|
+
.sort()
|
|
119
|
+
.join(',');
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// --- Canvas: renders all panes as a grid ---
|
|
123
|
+
|
|
124
|
+
function Canvas({
|
|
125
|
+
panes,
|
|
126
|
+
sessionName,
|
|
127
|
+
onResetRef,
|
|
128
|
+
}: {
|
|
129
|
+
panes: PaneData[];
|
|
130
|
+
sessionName: string;
|
|
131
|
+
onResetRef: React.RefObject<(() => void) | null>;
|
|
132
|
+
}) {
|
|
133
|
+
const [maximizedPaneId, setMaximizedPaneId] = useState<string | null>(null);
|
|
134
|
+
const [layout, setLayout] = useState<Layout[]>(() => mergeLayout(loadSavedLayout(sessionName), panes));
|
|
135
|
+
const prevPaneKeyRef = useRef(paneIdKey(panes));
|
|
136
|
+
const saveTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
137
|
+
|
|
138
|
+
// Recompute layout only when pane set changes (add/remove), not on every poll
|
|
139
|
+
useEffect(() => {
|
|
140
|
+
const key = paneIdKey(panes);
|
|
141
|
+
if (key === prevPaneKeyRef.current) return;
|
|
142
|
+
prevPaneKeyRef.current = key;
|
|
143
|
+
setLayout((prev) => mergeLayout(prev.length > 0 ? prev : loadSavedLayout(sessionName), panes));
|
|
144
|
+
}, [panes, sessionName]);
|
|
145
|
+
|
|
146
|
+
// Expose reset function to parent
|
|
147
|
+
useEffect(() => {
|
|
148
|
+
onResetRef.current = () => {
|
|
149
|
+
localStorage.removeItem(storageKey(sessionName));
|
|
150
|
+
setLayout(computeAutoLayout(panes));
|
|
151
|
+
};
|
|
152
|
+
return () => {
|
|
153
|
+
onResetRef.current = null;
|
|
154
|
+
};
|
|
155
|
+
}, [sessionName, panes, onResetRef]);
|
|
156
|
+
|
|
157
|
+
// Persist layout to localStorage on change (debounced)
|
|
158
|
+
const handleLayoutChange = useCallback(
|
|
159
|
+
(newLayout: Layout[]) => {
|
|
160
|
+
setLayout(newLayout);
|
|
161
|
+
if (saveTimerRef.current) clearTimeout(saveTimerRef.current);
|
|
162
|
+
saveTimerRef.current = setTimeout(() => {
|
|
163
|
+
localStorage.setItem(storageKey(sessionName), JSON.stringify(newLayout));
|
|
164
|
+
}, 500);
|
|
165
|
+
},
|
|
166
|
+
[sessionName]
|
|
167
|
+
);
|
|
168
|
+
|
|
169
|
+
// Cleanup save timer
|
|
170
|
+
useEffect(() => {
|
|
171
|
+
return () => {
|
|
172
|
+
if (saveTimerRef.current) clearTimeout(saveTimerRef.current);
|
|
173
|
+
};
|
|
174
|
+
}, []);
|
|
175
|
+
|
|
176
|
+
if (panes.length === 0) {
|
|
177
|
+
return (
|
|
178
|
+
<div className="flex h-full items-center justify-center">
|
|
179
|
+
<p className="text-sm text-[var(--os-text-secondary)]">No panes in this session</p>
|
|
180
|
+
</div>
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
const hasMaximized = maximizedPaneId !== null;
|
|
185
|
+
|
|
186
|
+
return (
|
|
187
|
+
<div className="genie-canvas relative h-full overflow-auto">
|
|
188
|
+
<GridLayout
|
|
189
|
+
layout={layout}
|
|
190
|
+
cols={GRID_COLS}
|
|
191
|
+
rowHeight={ROW_HEIGHT}
|
|
192
|
+
draggableHandle=".pane-card-header"
|
|
193
|
+
onLayoutChange={handleLayoutChange}
|
|
194
|
+
isDraggable={!hasMaximized}
|
|
195
|
+
isResizable={!hasMaximized}
|
|
196
|
+
compactType="vertical"
|
|
197
|
+
margin={[4, 4]}
|
|
198
|
+
containerPadding={[4, 4]}
|
|
199
|
+
>
|
|
200
|
+
{panes.map((pane) => (
|
|
201
|
+
<div key={pane.id} className="h-full">
|
|
202
|
+
<PaneCard
|
|
203
|
+
pane={pane}
|
|
204
|
+
isMaximized={maximizedPaneId === pane.id}
|
|
205
|
+
onMaximize={() => setMaximizedPaneId(pane.id)}
|
|
206
|
+
onRestore={() => setMaximizedPaneId(null)}
|
|
207
|
+
/>
|
|
208
|
+
</div>
|
|
209
|
+
))}
|
|
210
|
+
</GridLayout>
|
|
211
|
+
</div>
|
|
212
|
+
);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// --- Main Component ---
|
|
216
|
+
|
|
217
|
+
export function WorkspaceCanvas(_props: { windowId: string; meta?: Record<string, unknown> }) {
|
|
218
|
+
const [sessions, setSessions] = useState<SessionData[]>([]);
|
|
219
|
+
const [loading, setLoading] = useState(true);
|
|
220
|
+
const [error, setError] = useState<string | null>(null);
|
|
221
|
+
const [activeSessionId, setActiveSessionId] = useState<string | null>(null);
|
|
222
|
+
const intervalRef = useRef<ReturnType<typeof setInterval> | null>(null);
|
|
223
|
+
const resetLayoutRef = useRef<(() => void) | null>(null);
|
|
224
|
+
|
|
225
|
+
const fetchData = useCallback(async () => {
|
|
226
|
+
try {
|
|
227
|
+
const client = getNatsClient();
|
|
228
|
+
const response = await client.request(SUBJECTS.agents.list(), {}, 5000);
|
|
229
|
+
const data = response as AgentsResponse;
|
|
230
|
+
if (data.error) {
|
|
231
|
+
setError(data.error);
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
setSessions(data.sessions || []);
|
|
235
|
+
setError(null);
|
|
236
|
+
} catch (err) {
|
|
237
|
+
setError(String(err));
|
|
238
|
+
} finally {
|
|
239
|
+
setLoading(false);
|
|
240
|
+
}
|
|
241
|
+
}, []);
|
|
242
|
+
|
|
243
|
+
// Polling
|
|
244
|
+
useEffect(() => {
|
|
245
|
+
fetchData();
|
|
246
|
+
intervalRef.current = setInterval(fetchData, 5000);
|
|
247
|
+
return () => {
|
|
248
|
+
if (intervalRef.current) clearInterval(intervalRef.current);
|
|
249
|
+
};
|
|
250
|
+
}, [fetchData]);
|
|
251
|
+
|
|
252
|
+
// Auto-select first session if none selected or current selection is gone
|
|
253
|
+
useEffect(() => {
|
|
254
|
+
if (sessions.length === 0) return;
|
|
255
|
+
const currentExists = sessions.some((s) => s.id === activeSessionId);
|
|
256
|
+
if (!activeSessionId || !currentExists) {
|
|
257
|
+
const sorted = [...sessions].sort((a, b) => a.name.localeCompare(b.name));
|
|
258
|
+
setActiveSessionId(sorted[0].id);
|
|
259
|
+
}
|
|
260
|
+
}, [sessions, activeSessionId]);
|
|
261
|
+
|
|
262
|
+
// Build sorted tabs
|
|
263
|
+
const tabs: SessionTab[] = useMemo(() => {
|
|
264
|
+
return [...sessions]
|
|
265
|
+
.sort((a, b) => a.name.localeCompare(b.name))
|
|
266
|
+
.map((session, i) => ({
|
|
267
|
+
id: session.id,
|
|
268
|
+
name: session.name,
|
|
269
|
+
paneCount: session.windows.reduce((sum, w) => sum + w.panes.length, 0),
|
|
270
|
+
color: SESSION_COLORS[i % SESSION_COLORS.length],
|
|
271
|
+
}));
|
|
272
|
+
}, [sessions]);
|
|
273
|
+
|
|
274
|
+
// Collect all panes for the active session
|
|
275
|
+
const activePanes: PaneData[] = useMemo(() => {
|
|
276
|
+
const session = sessions.find((s) => s.id === activeSessionId);
|
|
277
|
+
if (!session) return [];
|
|
278
|
+
return session.windows.flatMap((w) => w.panes);
|
|
279
|
+
}, [sessions, activeSessionId]);
|
|
280
|
+
|
|
281
|
+
// Get session name for layout persistence key
|
|
282
|
+
const activeSessionName = useMemo(() => {
|
|
283
|
+
const session = sessions.find((s) => s.id === activeSessionId);
|
|
284
|
+
return session?.name ?? '';
|
|
285
|
+
}, [sessions, activeSessionId]);
|
|
286
|
+
|
|
287
|
+
const handleResetLayout = useCallback(() => {
|
|
288
|
+
resetLayoutRef.current?.();
|
|
289
|
+
}, []);
|
|
290
|
+
|
|
291
|
+
// Main content area (loading / error / empty / canvas)
|
|
292
|
+
let content: React.ReactNode;
|
|
293
|
+
if (loading) {
|
|
294
|
+
content = (
|
|
295
|
+
<div className="flex h-full items-center justify-center">
|
|
296
|
+
<p className="text-sm text-[var(--os-text-secondary)]">Connecting to tmux...</p>
|
|
297
|
+
</div>
|
|
298
|
+
);
|
|
299
|
+
} else if (error) {
|
|
300
|
+
content = (
|
|
301
|
+
<div className="flex h-full flex-col items-center justify-center gap-2">
|
|
302
|
+
<p className="text-sm text-red-400">Error: {error}</p>
|
|
303
|
+
<button type="button" onClick={fetchData} className="rounded bg-white/10 px-3 py-1 text-xs hover:bg-white/20">
|
|
304
|
+
Retry
|
|
305
|
+
</button>
|
|
306
|
+
</div>
|
|
307
|
+
);
|
|
308
|
+
} else if (sessions.length === 0) {
|
|
309
|
+
content = (
|
|
310
|
+
<div className="flex h-full items-center justify-center">
|
|
311
|
+
<p className="text-sm text-[var(--os-text-secondary)]">No tmux sessions found</p>
|
|
312
|
+
</div>
|
|
313
|
+
);
|
|
314
|
+
} else {
|
|
315
|
+
content = (
|
|
316
|
+
<div className="flex h-full flex-col">
|
|
317
|
+
<TabBar
|
|
318
|
+
tabs={tabs}
|
|
319
|
+
activeSessionId={activeSessionId}
|
|
320
|
+
onSelectSession={setActiveSessionId}
|
|
321
|
+
onResetLayout={handleResetLayout}
|
|
322
|
+
/>
|
|
323
|
+
<div className="min-h-0 flex-1">
|
|
324
|
+
<Canvas
|
|
325
|
+
key={activeSessionId}
|
|
326
|
+
panes={activePanes}
|
|
327
|
+
sessionName={activeSessionName}
|
|
328
|
+
onResetRef={resetLayoutRef}
|
|
329
|
+
/>
|
|
330
|
+
</div>
|
|
331
|
+
</div>
|
|
332
|
+
);
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
return (
|
|
336
|
+
<div className="flex h-full">
|
|
337
|
+
<Sidebar />
|
|
338
|
+
<div className="min-w-0 flex-1">{content}</div>
|
|
339
|
+
</div>
|
|
340
|
+
);
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
export type { AgentsResponse, PaneData, SessionData, WindowData };
|