moi-computer 0.12.0 → 0.12.1-next.1
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/README.md +27 -27
- package/bin/moi.mjs +2 -2
- package/client/AGENTS.md +7 -4
- package/client/api/app-config.ts +3 -2
- package/client/api/app-ui-keys.ts +1 -1
- package/client/api/workspace-keys.ts +2 -4
- package/client/app/{AppRouter.tsx → app-router.tsx} +4 -4
- package/client/app/routes/{HomeRoute.tsx → home-route.tsx} +2 -2
- package/client/app/routes/{WorkspaceRoute.tsx → workspace-route.tsx} +20 -31
- package/client/app/shell/{SidebarLayout.tsx → sidebar-layout.tsx} +10 -10
- package/client/dev/index.html +43 -0
- package/client/dev/index.ts +15 -0
- package/client/features/applets/{AppletContainer.tsx → applet-container.tsx} +1 -1
- package/client/features/applets/applet-runtime.ts +11 -13
- package/client/features/applets/applet-thumbnail.ts +1 -1
- package/client/features/applets/{useApplet.ts → use-applet.ts} +2 -2
- package/client/features/applets/{WidgetShell.tsx → widget-shell.tsx} +4 -4
- package/client/features/chat/applet-chat-intents.ts +33 -14
- package/client/features/chat/{ChatPanel.tsx → chat-panel.tsx} +80 -59
- package/client/features/chat/chat-popup.tsx +171 -0
- package/client/features/chat/chat-send.ts +33 -1
- package/client/features/chat/chat-store.ts +10 -0
- package/client/features/chat/composer/attachments/{DrawingAttachmentChip.tsx → drawing-attachment-chip.tsx} +1 -1
- package/client/features/chat/composer/attachments/{FileAttachmentChip.tsx → file-attachment-chip.tsx} +1 -1
- package/client/features/chat/composer/attachments/{TextAttachmentChip.tsx → text-attachment-chip.tsx} +1 -1
- package/client/features/chat/composer/banners/{ComposerBanner.tsx → composer-banner.tsx} +0 -14
- package/client/features/chat/composer/banners/{ErrorBanner.tsx → error-banner.tsx} +1 -1
- package/client/features/chat/composer/banners/{SkillUpdateBanner.tsx → skill-update-banner.tsx} +3 -3
- package/client/features/chat/composer/{ChatComposer.tsx → chat-composer.tsx} +31 -33
- package/client/features/chat/composer/{ModelPicker.tsx → model-picker.tsx} +4 -4
- package/client/features/chat/composer/{useWorkspaceComposerState.tsx → use-workspace-composer-state.tsx} +14 -30
- package/client/features/chat/composer/{useWorkspaceSkillUpdates.ts → use-workspace-skill-updates.ts} +1 -1
- package/client/features/chat/connection/chat-frames.ts +15 -8
- package/client/features/chat/messages/{ChatEmptyState.tsx → chat-empty-state.tsx} +37 -23
- package/client/features/chat/messages/fork-history.ts +14 -0
- package/client/features/chat/messages/{MarkdownContent.tsx → markdown-content.tsx} +4 -4
- package/client/features/chat/messages/tool-group/index.ts +1 -1
- package/client/features/chat/messages/tool-group/{ReadImagePreview.tsx → read-image-preview.tsx} +2 -2
- package/client/features/chat/messages/tool-group/{SubagentCard.tsx → subagent-card.tsx} +3 -3
- package/client/features/chat/messages/tool-group/{TimelineRow.tsx → timeline-row.tsx} +1 -1
- package/client/features/chat/messages/tool-group/{ToolCallGroup.tsx → tool-call-group.tsx} +8 -8
- package/client/features/chat/messages/tool-group/{ToolOutput.tsx → tool-output.tsx} +1 -1
- package/client/features/chat/messages/{TurnView.tsx → turn-view.tsx} +4 -4
- package/client/features/chat/sessions/api.ts +109 -19
- package/client/features/chat/sessions/browser-tab-state.ts +30 -7
- package/client/features/chat/sessions/{ChatSelector.tsx → chat-selector.tsx} +139 -80
- package/client/features/chat/sessions/use-selected-session.ts +351 -0
- package/client/features/chat/{useChat.ts → use-chat.ts} +46 -48
- package/client/features/collab/client.ts +10 -11
- package/client/features/collab/hooks.tsx +6 -11
- package/client/features/collab/host-state.ts +57 -128
- package/client/features/collab/provider.tsx +3 -3
- package/client/features/collab/proxy-user.ts +1 -1
- package/client/features/collab/testing/fake-engine.ts +6 -27
- package/client/features/collab/workspace-users-menu.tsx +3 -7
- package/client/features/connectors/mcp-icons.ts +1 -1
- package/client/features/connectors/{McpServerCards.tsx → mcp-server-cards.tsx} +1 -1
- package/client/features/{home/workspace-setup/DemoDialog.tsx → demo/demo-dialog.tsx} +6 -6
- package/client/features/dev/chat-states-fixtures.ts +4 -4
- package/client/features/dev/{ChatStatesPage.tsx → chat-states-page.tsx} +6 -6
- package/client/features/dev/collab/local-user-settings.tsx +4 -4
- package/client/features/dev/{DevIndexPage.tsx → dev-index-page.tsx} +7 -1
- package/client/features/dev/{DevRoutes.tsx → dev-routes.tsx} +8 -6
- package/client/features/dev/workspace-setup-mocks.ts +102 -0
- package/client/features/dev/workspace-setup-page.tsx +11 -0
- package/client/features/dev/workspace-setup-preview.tsx +226 -0
- package/client/features/drawings/{DrawingToolbar.tsx → drawing-toolbar.tsx} +1 -1
- package/client/features/drawings/{useChatAnnotation.ts → use-chat-annotation.ts} +29 -23
- package/client/features/drawings/{useDrawingLayer.ts → use-drawing-layer.ts} +1 -1
- package/client/features/drawings/{useViewBuilderSketch.ts → use-view-sketch.ts} +8 -8
- package/client/features/harness/api.ts +36 -0
- package/client/features/harness/device-login-steps.tsx +97 -0
- package/client/features/home/api.ts +1 -81
- package/client/features/home/{HomeLogo.tsx → home-logo.tsx} +1 -1
- package/client/features/home/{HomePage.tsx → home-page.tsx} +16 -20
- package/client/features/overview/api.ts +2 -2
- package/client/features/overview/default/registry.tsx +3 -5
- package/client/features/overview/default/{ViewsWidget.tsx → views-widget.tsx} +6 -13
- package/client/features/overview/{HiddenPanel.tsx → hidden-panel.tsx} +2 -2
- package/client/features/overview/{Overview.tsx → overview.tsx} +9 -12
- package/client/features/overview/{WidgetCanvas.tsx → widget-canvas.tsx} +1 -1
- package/client/features/overview/{WidgetFrame.tsx → widget-frame.tsx} +1 -1
- package/client/features/overview/workspace-name.tsx +55 -0
- package/client/features/scratchpad/{Scratchpad.tsx → scratchpad.tsx} +7 -7
- package/client/features/scratchpad/{useScratchpadSnapshot.tsx → use-scratchpad-snapshot.tsx} +3 -3
- package/client/features/settings/api.ts +1 -1
- package/client/features/settings/{ConnectorsSettings.tsx → connectors-settings.tsx} +3 -3
- package/client/features/settings/{EnvironmentSettings.tsx → environment-settings.tsx} +3 -3
- package/client/features/settings/{GeneralSettings.tsx → general-settings.tsx} +5 -5
- package/client/features/settings/{useEnvVars.ts → use-env-vars.ts} +1 -1
- package/client/features/settings/{WorkspaceIconPicker.tsx → workspace-icon-picker.tsx} +1 -1
- package/client/features/settings/{WorkspaceSettingsDialog.tsx → workspace-settings-dialog.tsx} +3 -3
- package/client/features/update/api.ts +1 -1
- package/client/features/views/api.ts +64 -131
- package/client/features/views/pending-view-screen.tsx +282 -0
- package/client/features/views/use-view-actions.ts +151 -0
- package/client/features/views/use-view-drafts.ts +88 -0
- package/client/features/views/{ViewManager.tsx → view-manager.tsx} +13 -13
- package/client/features/views/view-presentation.ts +4 -5
- package/client/features/views/view-submission.ts +88 -0
- package/client/features/workspace/add/api.ts +80 -0
- package/client/features/{home/workspace-setup/CreateWorkspaceDialog.tsx → workspace/add/create-workspace-dialog.tsx} +56 -42
- package/client/features/workspace/add/import-workspace-dialog.tsx +81 -0
- package/client/features/{home/workspace-setup/useWorkspaceImport.ts → workspace/add/use-workspace-import.ts} +1 -1
- package/client/features/workspace/add/workspace-agent-options.ts +53 -0
- package/client/features/{home/workspace-setup/WorkspaceAgentStep.tsx → workspace/add/workspace-agent-selector.tsx} +59 -98
- package/client/features/{home/workspace-setup/WorkspaceDialogContent.tsx → workspace/add/workspace-dialog-content.tsx} +1 -1
- package/client/features/workspace/api.ts +24 -15
- package/client/features/workspace/browser-tab-state.ts +16 -9
- package/client/features/workspace/moi-context.ts +14 -16
- package/client/features/workspace/setup/workspace-login-state.tsx +175 -0
- package/client/features/workspace/setup/workspace-recovery-states.tsx +125 -0
- package/client/features/workspace/setup/workspace-setup-panel.tsx +18 -0
- package/client/features/workspace/setup/workspace-setup.tsx +77 -0
- package/client/features/workspace/setup/workspace-welcome-state.tsx +81 -0
- package/client/features/workspace/tab-resolution.ts +16 -29
- package/client/features/workspace/{ThemePanel.tsx → theme-panel.tsx} +3 -3
- package/client/features/workspace/use-workspace-navigation.ts +245 -0
- package/client/features/workspace/workspace-content.tsx +641 -0
- package/client/features/workspace/workspace-identity.tsx +40 -0
- package/client/features/workspace/workspace-menu.tsx +63 -0
- package/client/features/{home → workspace}/workspace-presentation.tsx +10 -3
- package/client/features/workspace/workspace-screen.tsx +28 -0
- package/client/features/workspace/{WorkspaceSplitLayout.tsx → workspace-split-layout.tsx} +1 -1
- package/client/features/workspace/{WorkspaceTabs.tsx → workspace-tabs.tsx} +2 -2
- package/client/index.css +2 -2
- package/client/index.html +1 -1
- package/client/index.tsx +5 -1
- package/client/lib/agent-availability.ts +0 -5
- package/client/main.tsx +1 -1
- package/client/runtime/{useWorkspaceEvents.ts → use-workspace-events.ts} +10 -18
- package/client/store/ui.ts +25 -29
- package/dist/chunk-08ndj2rg.js +2 -0
- package/dist/chunk-2x040tmg.js +68 -0
- package/dist/chunk-3smxq0ts.js +1 -0
- package/dist/chunk-68ch5hs8.js +2 -0
- package/dist/{chunk-z3byfve5.js → chunk-9vg3xa81.js} +2 -2
- package/dist/chunk-c2p00p9j.css +1 -0
- package/dist/chunk-cs833y9j.js +1 -0
- package/dist/{chunk-97eg9mjn.js → chunk-d7cbm65e.js} +1 -1
- package/dist/{chunk-efdyz6xp.js → chunk-hvh9f5h0.js} +1 -1
- package/dist/{chunk-vfpsc75k.js → chunk-jvyvwwv3.js} +1 -1
- package/dist/chunk-nwevqe86.js +10 -0
- package/dist/{chunk-3a48fyf7.js → chunk-q0gbdts4.js} +4 -4
- package/dist/chunk-rt30jbcm.js +1 -0
- package/dist/chunk-y5y3kj67.js +1 -0
- package/dist/index.html +2 -2
- package/lib/format.ts +1 -1
- package/lib/harness-instructions.ts +30 -0
- package/lib/ids.ts +3 -6
- package/lib/moi-context.ts +102 -75
- package/lib/navigation.ts +48 -87
- package/lib/scratchpad-skew.ts +3 -3
- package/lib/session-drafts.ts +10 -0
- package/lib/types.ts +92 -51
- package/lib/update.ts +1 -1
- package/lib/view-build-directives.ts +12 -0
- package/lib/workspace-layout.ts +1 -1
- package/lib/workspace-tabs.ts +12 -7
- package/package.json +7 -2
- package/server/AGENTS.md +10 -4
- package/server/README.md +102 -0
- package/server/agent-launcher.ts +27 -0
- package/server/api/harnesses.ts +56 -0
- package/server/{api.ts → api/index.ts} +197 -299
- package/server/app-config.ts +45 -14
- package/server/app-settings.ts +1 -1
- package/server/applets/applet-css.ts +1 -1
- package/server/applets/build-applet.ts +4 -4
- package/server/applets/build-worker.ts +3 -2
- package/server/applets/config.ts +1 -1
- package/server/{functions-worker.ts → applets/functions-worker.ts} +1 -1
- package/server/{functions.ts → applets/functions.ts} +3 -2
- package/server/applets/index.ts +2 -2
- package/server/{thumbnails.ts → applets/thumbnails.ts} +1 -1
- package/server/{applet-typecheck.ts → applets/typecheck.ts} +4 -4
- package/server/{ui-components.ts → applets/ui-components.ts} +2 -2
- package/server/applets/view-source.ts +7 -1
- package/server/{views.ts → applets/views.ts} +35 -46
- package/server/{widgets.ts → applets/widgets.ts} +2 -2
- package/server/cli/applet-selector.ts +19 -0
- package/server/cli/args.ts +5 -0
- package/server/{cli-colors.ts → cli/colors.ts} +1 -1
- package/server/cli/commands/bundle.ts +119 -0
- package/server/cli/commands/call-server-fn.ts +42 -0
- package/server/cli/commands/check.ts +53 -0
- package/server/cli/commands/config.ts +132 -0
- package/server/cli/commands/debug.ts +119 -0
- package/server/cli/commands/env.ts +162 -0
- package/server/cli/commands/hermes.ts +149 -0
- package/server/cli/commands/init.ts +286 -0
- package/server/cli/commands/navigate.ts +35 -0
- package/server/cli/commands/openclaw.ts +168 -0
- package/server/cli/commands/refresh.ts +39 -0
- package/server/cli/commands/scratch.ts +496 -0
- package/server/cli/commands/service.ts +298 -0
- package/server/cli/commands/skill.ts +122 -0
- package/server/cli/commands/start.ts +138 -0
- package/server/cli/commands/status.ts +80 -0
- package/server/cli/commands/tabs.ts +43 -0
- package/server/cli/commands/theme.ts +192 -0
- package/server/cli/commands/ui-components.ts +15 -0
- package/server/cli/commands/update.ts +192 -0
- package/server/cli/commands/version.ts +9 -0
- package/server/cli/commands/views.ts +87 -0
- package/server/cli/control.ts +89 -0
- package/server/{cli-env.ts → cli/env.ts} +78 -56
- package/server/cli/index.ts +171 -0
- package/server/{cli-pc.ts → cli/pc.ts} +1 -1
- package/server/cli/provider.ts +25 -0
- package/server/cli/server-version.ts +16 -0
- package/server/cli/server.ts +81 -0
- package/server/{cli-ui-components.ts → cli/ui-components.ts} +5 -5
- package/server/cli.ts +2 -3215
- package/server/collab/manager.ts +3 -3
- package/server/collab/skill/index.ts +2 -2
- package/server/control.ts +97 -78
- package/server/data-dir.ts +13 -0
- package/server/harness/README.md +55 -25
- package/server/harness/acp/NOTES.md +11 -11
- package/server/harness/acp/adapter.ts +2 -2
- package/server/harness/acp/archived.ts +3 -3
- package/server/harness/acp/client.ts +4 -3
- package/server/harness/acp/discovery.ts +3 -3
- package/server/harness/acp/run-durations.ts +1 -1
- package/server/harness/acp/session.ts +9 -12
- package/server/harness/auth.ts +303 -0
- package/server/harness/claude-code/NOTES.md +9 -7
- package/server/harness/claude-code/adapter.ts +13 -8
- package/server/harness/claude-code/auth.ts +127 -18
- package/server/harness/claude-code/cli.ts +3 -1
- package/server/harness/claude-code/git-worktree.ts +5 -2
- package/server/harness/claude-code/index.ts +7 -1
- package/server/harness/claude-code/mcp.ts +3 -1
- package/server/harness/claude-code/models.ts +2 -0
- package/server/harness/claude-code/session.ts +13 -39
- package/server/harness/claude-code/sessions.ts +8 -12
- package/server/harness/codex/NOTES.md +35 -16
- package/server/harness/codex/adapter.ts +5 -3
- package/server/harness/codex/auth.ts +86 -19
- package/server/harness/codex/client.ts +30 -34
- package/server/harness/codex/index.ts +20 -1
- package/server/harness/codex/permissions.ts +3 -3
- package/server/harness/codex/probe.ts +3 -5
- package/server/harness/codex/session.ts +20 -25
- package/server/harness/codex/thread-list.ts +74 -0
- package/server/harness/codex/transport.ts +5 -5
- package/server/harness/executable.ts +42 -18
- package/server/harness/fork.ts +12 -0
- package/server/harness/hermes/NOTES.md +70 -70
- package/server/harness/hermes/discovery.ts +1 -1
- package/server/harness/openclaw/NOTES.md +24 -24
- package/server/harness/openclaw/adapter.ts +4 -4
- package/server/harness/openclaw/compat.ts +1 -1
- package/server/harness/openclaw/session.ts +6 -31
- package/server/harness/registry.ts +1 -1
- package/server/harness/session-title.ts +12 -3
- package/server/harness/shell-path.ts +31 -21
- package/server/harness/types.ts +17 -5
- package/server/navigation-relay.ts +1 -1
- package/server/open-browser.ts +7 -0
- package/server/{scratchpad-assets.ts → scratchpad/assets.ts} +4 -4
- package/server/{scratchpad.ts → scratchpad/document.ts} +8 -8
- package/server/{scratchpad-executor.ts → scratchpad/executor.ts} +7 -7
- package/server/{scratchpad-relay.ts → scratchpad/relay.ts} +4 -5
- package/server/{scratchpad-shape-defaults.ts → scratchpad/shape-defaults.ts} +2 -2
- package/server/server-cwd.ts +1 -1
- package/server/service.ts +18 -4
- package/server/sessions/archive.ts +32 -0
- package/server/{attachment-message.ts → sessions/attachment-message.ts} +1 -1
- package/server/sessions/config.ts +41 -0
- package/server/sessions/lifecycle.ts +17 -0
- package/server/sessions/pending-views.ts +164 -0
- package/server/sessions/selected.ts +199 -0
- package/server/sessions/store.ts +127 -0
- package/server/sessions/view-sessions.ts +267 -0
- package/server/{skills-template.ts → skills/template.ts} +1 -1
- package/server/{skill-update.ts → skills/update.ts} +5 -5
- package/server/{skill-version.ts → skills/version.ts} +4 -4
- package/server/static.ts +1 -1
- package/server/status.ts +6 -4
- package/server/web.ts +58 -49
- package/server/{env-apply.ts → workspaces/env-apply.ts} +5 -5
- package/server/{workspace-env.ts → workspaces/env.ts} +30 -3
- package/server/{workspace-import.ts → workspaces/import.ts} +4 -4
- package/server/{workspace-init.ts → workspaces/init.ts} +10 -6
- package/server/{layout.ts → workspaces/layout.ts} +2 -2
- package/server/{preview.ts → workspaces/preview.ts} +1 -1
- package/server/{registry.ts → workspaces/registry.ts} +17 -7
- package/server/{required-env.ts → workspaces/required-env.ts} +3 -3
- package/server/{moi-scaffold.ts → workspaces/scaffold.ts} +4 -3
- package/server/{tabs.ts → workspaces/tabs.ts} +7 -10
- package/ui-components/button.tsx +1 -1
- package/ui-components/docs/attachment.md +2 -2
- package/ui-components/docs/button.md +1 -1
- package/ui-components/docs/calendar.md +1 -1
- package/ui-components/docs/chart.md +4 -4
- package/ui-components/docs/data-table.md +1 -1
- package/ui-components/docs/drawer.md +1 -1
- package/ui-components/docs/field.md +1 -1
- package/ui-components/docs/input.md +2 -2
- package/ui-components/docs/label.md +2 -2
- package/ui-components/docs/table.md +2 -2
- package/workspace/.claude/skills/moi-workspace/SKILL.md +61 -32
- package/workspace/.claude/skills/moi-workspace/references/COLLAB.md +4 -7
- package/workspace/.claude/skills/moi-workspace/references/DESIGN.md +2 -2
- package/workspace/.claude/skills/moi-workspace/references/INTENTS.md +2 -2
- package/client/features/chat/ChatPopup.tsx +0 -98
- package/client/features/chat/composer/banners/AgentAvailabilityBanner.tsx +0 -101
- package/client/features/chat/sessions/useSelectedSession.ts +0 -185
- package/client/features/home/workspace-setup/ImportWorkspaceDialog.tsx +0 -92
- package/client/features/overview/WorkspaceName.tsx +0 -60
- package/client/features/views/ViewBuilder.tsx +0 -239
- package/client/features/views/useViewBuilderActions.ts +0 -103
- package/client/features/views/useViewBuilderDrafts.ts +0 -68
- package/client/features/workspace/WorkspaceScreen.tsx +0 -839
- package/client/features/workspace/useWorkspaceNavigation.ts +0 -203
- package/dist/chunk-2jncyq65.js +0 -1
- package/dist/chunk-e2q5ken7.js +0 -68
- package/dist/chunk-h2kj1ysj.js +0 -1
- package/dist/chunk-jf6czgrz.js +0 -2
- package/dist/chunk-nez8sdta.js +0 -1
- package/dist/chunk-nzwgm8vc.css +0 -1
- package/dist/chunk-ph0h6h86.js +0 -1
- package/dist/chunk-ryg9z3kn.js +0 -10
- package/dist/chunk-tpn177bt.js +0 -2
- package/lib/view-builder-directives.ts +0 -16
- package/server/agent.ts +0 -223
- package/server/chat-selection.ts +0 -22
- package/server/selected-session.ts +0 -152
- package/server/session-config.ts +0 -136
- package/server/view-builders.ts +0 -453
- /package/client/components/shared/{AgentBlobatar.tsx → agent-blobatar.tsx} +0 -0
- /package/client/components/shared/{BottomPanel.tsx → bottom-panel.tsx} +0 -0
- /package/client/components/shared/{Composer.tsx → composer.tsx} +0 -0
- /package/client/components/shared/{LedLogo.tsx → led-logo.tsx} +0 -0
- /package/client/components/shared/{PanelHeader.tsx → panel-header.tsx} +0 -0
- /package/client/components/shared/{ReorderableList.tsx → reorderable-list.tsx} +0 -0
- /package/client/components/shared/{WorkspaceIcon.tsx → workspace-icon.tsx} +0 -0
- /package/client/features/applets/{WidgetErrorBoundary.tsx → widget-error-boundary.tsx} +0 -0
- /package/client/features/chat/composer/attachments/{AttachmentChip.tsx → attachment-chip.tsx} +0 -0
- /package/client/features/chat/messages/{ChatPromptBubbles.tsx → chat-prompt-bubbles.tsx} +0 -0
- /package/client/features/chat/messages/{ShimmerText.tsx → shimmer-text.tsx} +0 -0
- /package/client/features/chat/messages/tool-group/{CodeBlock.tsx → code-block.tsx} +0 -0
- /package/client/features/chat/messages/tool-group/{Collapse.tsx → collapse.tsx} +0 -0
- /package/client/features/chat/messages/{useStickToBottom.ts → use-stick-to-bottom.ts} +0 -0
- /package/client/features/connectors/{IconMcp.tsx → icon-mcp.tsx} +0 -0
- /package/client/features/dev/{BlobatarShapesPage.tsx → blobatar-shapes-page.tsx} +0 -0
- /package/client/features/dev/{HarnessDebugPage.tsx → harness-debug-page.tsx} +0 -0
- /package/client/features/dev/{TextureLabPage.tsx → texture-lab-page.tsx} +0 -0
- /package/client/features/dev/{ToolCallsPage.tsx → tool-calls-page.tsx} +0 -0
- /package/client/features/drawings/{DrawingLayer.tsx → drawing-layer.tsx} +0 -0
- /package/client/features/home/{WorkspacePreview.tsx → workspace-preview.tsx} +0 -0
- /package/client/features/overview/{useGridReconcile.ts → use-grid-reconcile.ts} +0 -0
- /package/client/features/scratchpad/{ScratchpadControls.tsx → scratchpad-controls.tsx} +0 -0
- /package/client/features/settings/{SettingsLayout.tsx → settings-layout.tsx} +0 -0
- /package/client/features/update/{UpdateControl.tsx → update-control.tsx} +0 -0
- /package/client/features/workspace/{UnavailablePage.tsx → unavailable-page.tsx} +0 -0
- /package/client/features/workspace/{useFitsSplitLayout.ts → use-fits-split-layout.ts} +0 -0
- /package/client/features/workspace/{WorkspaceContext.tsx → workspace-context.tsx} +0 -0
- /package/client/features/workspace/{WorkspaceLayoutContext.tsx → workspace-layout-context.tsx} +0 -0
- /package/server/{bundle-queue.ts → applets/bundle-queue.ts} +0 -0
- /package/server/{applet-log.ts → applets/log.ts} +0 -0
- /package/server/{cli-ui.ts → cli/ui.ts} +0 -0
- /package/server/{workspace-config.ts → workspaces/config.ts} +0 -0
- /package/server/{icon.ts → workspaces/icon.ts} +0 -0
- /package/server/{theme.ts → workspaces/theme.ts} +0 -0
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef } from 'react'
|
|
2
|
+
import { toast } from '@/client/components/ui/toast'
|
|
3
|
+
import { useLatestRef } from '@/client/lib/use-latest-ref'
|
|
4
|
+
import { useUiStore } from '@/client/store/ui'
|
|
5
|
+
import { composerDraftKey, draftSessionId } from '@/lib/session-drafts'
|
|
6
|
+
import { viewTabId } from '@/lib/workspace-tabs'
|
|
7
|
+
import type { PendingView } from '@/lib/types'
|
|
8
|
+
|
|
9
|
+
type UseViewDraftsOptions = {
|
|
10
|
+
workspaceId: string
|
|
11
|
+
pendingViews: PendingView[]
|
|
12
|
+
onSave: (viewId: string, requirements: string) => Promise<unknown>
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// The composer owns local text. This hook seeds server-saved requirements and
|
|
16
|
+
// autosaves changes without subscribing the workspace screen to keystrokes.
|
|
17
|
+
export function useViewDrafts({ workspaceId, pendingViews, onSave }: UseViewDraftsOptions) {
|
|
18
|
+
const initializedRef = useRef(new Set<string>())
|
|
19
|
+
const timersRef = useRef(new Map<string, ReturnType<typeof setTimeout>>())
|
|
20
|
+
const pendingViewsRef = useLatestRef(pendingViews)
|
|
21
|
+
const onSaveRef = useLatestRef(onSave)
|
|
22
|
+
const clear = useCallback(
|
|
23
|
+
(viewId: string) => {
|
|
24
|
+
clearTimeout(timersRef.current.get(viewId))
|
|
25
|
+
timersRef.current.delete(viewId)
|
|
26
|
+
useUiStore
|
|
27
|
+
.getState()
|
|
28
|
+
.setComposerDraft(composerDraftKey(workspaceId, draftSessionId(viewTabId(viewId))), null)
|
|
29
|
+
},
|
|
30
|
+
[workspaceId]
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
for (const view of pendingViews) {
|
|
35
|
+
const draftId = draftSessionId(viewTabId(view.id))
|
|
36
|
+
const key = composerDraftKey(workspaceId, draftId)
|
|
37
|
+
useUiStore.getState().moveComposerDraft(draftId, key)
|
|
38
|
+
if (view.status !== 'draft') clear(view.id)
|
|
39
|
+
else if (!initializedRef.current.has(key)) {
|
|
40
|
+
initializedRef.current.add(key)
|
|
41
|
+
if (useUiStore.getState().composerDrafts[key] === undefined)
|
|
42
|
+
useUiStore.getState().setComposerDraft(key, view.requirements)
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}, [workspaceId, pendingViews, clear])
|
|
46
|
+
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
const timers = timersRef.current
|
|
49
|
+
const saveDraft = (viewId: string) => {
|
|
50
|
+
if (pendingViewsRef.current.find(view => view.id === viewId)?.status !== 'draft') return
|
|
51
|
+
const key = composerDraftKey(workspaceId, draftSessionId(viewTabId(viewId)))
|
|
52
|
+
const value = useUiStore.getState().composerDrafts[key]
|
|
53
|
+
if (value === undefined) return
|
|
54
|
+
void onSaveRef.current(viewId, value).catch(() => {
|
|
55
|
+
toast.add({ title: 'Couldn’t save view description', type: 'error' })
|
|
56
|
+
})
|
|
57
|
+
}
|
|
58
|
+
const unsubscribe = useUiStore.subscribe((state, previous) => {
|
|
59
|
+
for (const view of pendingViewsRef.current) {
|
|
60
|
+
if (view.status !== 'draft') continue
|
|
61
|
+
const key = composerDraftKey(workspaceId, draftSessionId(viewTabId(view.id)))
|
|
62
|
+
const value = state.composerDrafts[key]
|
|
63
|
+
if (value === previous.composerDrafts[key]) continue
|
|
64
|
+
clearTimeout(timers.get(view.id))
|
|
65
|
+
timers.delete(view.id)
|
|
66
|
+
if (value === undefined) continue
|
|
67
|
+
timers.set(
|
|
68
|
+
view.id,
|
|
69
|
+
setTimeout(() => {
|
|
70
|
+
timers.delete(view.id)
|
|
71
|
+
saveDraft(view.id)
|
|
72
|
+
}, 500)
|
|
73
|
+
)
|
|
74
|
+
}
|
|
75
|
+
})
|
|
76
|
+
return () => {
|
|
77
|
+
unsubscribe()
|
|
78
|
+
// Recovery unmounts the workspace. Flush edits still in the debounce window.
|
|
79
|
+
for (const [viewId, timer] of timers) {
|
|
80
|
+
clearTimeout(timer)
|
|
81
|
+
saveDraft(viewId)
|
|
82
|
+
}
|
|
83
|
+
timers.clear()
|
|
84
|
+
}
|
|
85
|
+
}, [workspaceId, pendingViewsRef, onSaveRef])
|
|
86
|
+
|
|
87
|
+
return { clear }
|
|
88
|
+
}
|
|
@@ -23,13 +23,13 @@ import {
|
|
|
23
23
|
type AppletComponentProps,
|
|
24
24
|
type AppletState,
|
|
25
25
|
useView
|
|
26
|
-
} from '@/client/features/applets/
|
|
27
|
-
import { WidgetErrorBoundary } from '@/client/features/applets/
|
|
26
|
+
} from '@/client/features/applets/use-applet'
|
|
27
|
+
import { WidgetErrorBoundary } from '@/client/features/applets/widget-error-boundary'
|
|
28
28
|
import { AppletPresenceProvider } from '@/client/features/collab'
|
|
29
|
-
import { useWorkspaceId } from '@/client/features/workspace/
|
|
29
|
+
import { useWorkspaceId } from '@/client/features/workspace/workspace-context'
|
|
30
30
|
import { cn } from '@/client/lib/cn'
|
|
31
31
|
import { useLatestRef } from '@/client/lib/use-latest-ref'
|
|
32
|
-
import type {
|
|
32
|
+
import type { CompiledView } from '@/lib/types'
|
|
33
33
|
|
|
34
34
|
import {
|
|
35
35
|
nextEvictionDelay,
|
|
@@ -39,10 +39,10 @@ import {
|
|
|
39
39
|
} from './view-residency'
|
|
40
40
|
|
|
41
41
|
type ViewManagerProps = {
|
|
42
|
-
views:
|
|
42
|
+
views: CompiledView[]
|
|
43
43
|
// The view the active tab names, or null when another tab is on screen. The
|
|
44
44
|
// manager stays mounted either way — that is what makes coming back from the
|
|
45
|
-
//
|
|
45
|
+
// Overview or Scratchpad tab instant too.
|
|
46
46
|
activeViewId: string | null
|
|
47
47
|
// The active view's URL query params. Parked views retain their last values.
|
|
48
48
|
params: Record<string, string>
|
|
@@ -83,7 +83,7 @@ export const ViewManager = memo(function ViewManager({
|
|
|
83
83
|
|
|
84
84
|
// The views mounted right now: the active one, plus the recently-visited ones
|
|
85
85
|
// parked offscreen. The policy (and its timing) lives in view-residency.ts.
|
|
86
|
-
function useResidentViews(activeId: string | null, views:
|
|
86
|
+
function useResidentViews(activeId: string | null, views: CompiledView[]): ResidentView[] {
|
|
87
87
|
const [residents, setResidents] = useState<ResidentView[]>([])
|
|
88
88
|
// A workspace refetch hands us a new array on every event; residency only
|
|
89
89
|
// cares whether a view appeared or disappeared. So the effect keys off the id
|
|
@@ -119,7 +119,7 @@ function useResidentViews(activeId: string | null, views: ViewInfo[]): ResidentV
|
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
type ViewSlotProps = {
|
|
122
|
-
view:
|
|
122
|
+
view: CompiledView
|
|
123
123
|
active: boolean
|
|
124
124
|
params: Record<string, string>
|
|
125
125
|
}
|
|
@@ -191,8 +191,8 @@ function ViewSlot({ view, active, params }: ViewSlotProps) {
|
|
|
191
191
|
}
|
|
192
192
|
|
|
193
193
|
type ViewFrameProps = {
|
|
194
|
-
view:
|
|
195
|
-
build:
|
|
194
|
+
view: CompiledView
|
|
195
|
+
build: LoadedViewVersion
|
|
196
196
|
params: Record<string, string>
|
|
197
197
|
// Play the rebuild dissolve. Set on the incoming build only, and only while
|
|
198
198
|
// the build it replaced is still rendered underneath it.
|
|
@@ -237,7 +237,7 @@ function ViewFrame({ view, build, params, entering, current = false }: ViewFrame
|
|
|
237
237
|
)
|
|
238
238
|
}
|
|
239
239
|
|
|
240
|
-
type
|
|
240
|
+
type LoadedViewVersion = {
|
|
241
241
|
Component: ComponentType<AppletComponentProps>
|
|
242
242
|
version: number
|
|
243
243
|
}
|
|
@@ -248,11 +248,11 @@ type LoadedBundle = {
|
|
|
248
248
|
// spinner every time the agent edits it is worse than showing the previous
|
|
249
249
|
// build for that moment. The splash is for a view with nothing to show yet —
|
|
250
250
|
// the first time it is opened.
|
|
251
|
-
current:
|
|
251
|
+
current: LoadedViewVersion | null
|
|
252
252
|
// The build `current` just replaced, kept underneath for the length of the
|
|
253
253
|
// dissolve so the new one fades in over the view instead of over an empty
|
|
254
254
|
// panel. Null except during a rebuild swap on screen.
|
|
255
|
-
outgoing:
|
|
255
|
+
outgoing: LoadedViewVersion | null
|
|
256
256
|
}
|
|
257
257
|
|
|
258
258
|
// How long the outgoing build stays underneath. Matches the `duration-200` the
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { IconArticle, type TablerIcon } from '@tabler/icons-react'
|
|
2
2
|
|
|
3
3
|
import { resolveAppIcon } from '@/client/lib/app-icon-registry'
|
|
4
|
-
import type {
|
|
4
|
+
import type { ViewInfo } from '@/lib/types'
|
|
5
5
|
|
|
6
6
|
export function getViewLabel(view: ViewInfo): string {
|
|
7
|
-
return view.
|
|
7
|
+
return view.title || (view.status === 'compiled' ? view.id : 'New view')
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
export function getViewIcon(view: ViewInfo
|
|
11
|
-
|
|
12
|
-
return resolveAppIcon(view.config.icon) ?? resolveAppIcon(builder?.icon) ?? IconArticle
|
|
10
|
+
export function getViewIcon(view: ViewInfo): TablerIcon {
|
|
11
|
+
return resolveAppIcon(view.icon) ?? IconArticle
|
|
13
12
|
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { QueryClient } from '@tanstack/react-query'
|
|
2
|
+
import { requestJson } from '@/client/api/http'
|
|
3
|
+
import { workspaceKeys } from '@/client/api/workspace-keys'
|
|
4
|
+
import { appUiKeys } from '@/client/api/app-ui-keys'
|
|
5
|
+
import {
|
|
6
|
+
readSelectedSession,
|
|
7
|
+
writeSelectedSession
|
|
8
|
+
} from '@/client/features/chat/sessions/browser-tab-state'
|
|
9
|
+
import { selectedSessionKey } from '@/client/features/chat/sessions/use-selected-session'
|
|
10
|
+
import { moveChatDraft } from '@/client/features/chat/chat-send'
|
|
11
|
+
import { liveStore } from '@/client/features/chat/chat-store'
|
|
12
|
+
import { useUiStore } from '@/client/store/ui'
|
|
13
|
+
import { composerDraftKey, draftSessionId } from '@/lib/session-drafts'
|
|
14
|
+
import { viewTabId } from '@/lib/workspace-tabs'
|
|
15
|
+
import type {
|
|
16
|
+
PendingView,
|
|
17
|
+
SelectedSessionScope,
|
|
18
|
+
SessionInfo,
|
|
19
|
+
ViewInfo,
|
|
20
|
+
WorkspaceSessionSelection
|
|
21
|
+
} from '@/lib/types'
|
|
22
|
+
|
|
23
|
+
function pendingView(view: ViewInfo | undefined): PendingView | undefined {
|
|
24
|
+
return view?.status === 'compiled' ? undefined : view
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// A failed HTTP response does not prove startup failed. Refresh the server's
|
|
28
|
+
// state before restoring the fresh composer; never replay the request.
|
|
29
|
+
export async function recoverViewSubmission(
|
|
30
|
+
queryClient: QueryClient,
|
|
31
|
+
workspaceId: string,
|
|
32
|
+
viewId: string,
|
|
33
|
+
sessionId: string,
|
|
34
|
+
text: string,
|
|
35
|
+
pinned: boolean,
|
|
36
|
+
selectionScope: SelectedSessionScope = 'shared'
|
|
37
|
+
) {
|
|
38
|
+
const cachedView = pendingView(
|
|
39
|
+
queryClient
|
|
40
|
+
.getQueryData<ViewInfo[]>(workspaceKeys.views(workspaceId))
|
|
41
|
+
?.find(view => view.id === viewId)
|
|
42
|
+
)
|
|
43
|
+
let target = cachedView?.executionSessionId ?? sessionId
|
|
44
|
+
try {
|
|
45
|
+
const [{ views }, selection] = await Promise.all([
|
|
46
|
+
requestJson<{ views: ViewInfo[] }>(`/api/workspaces/${workspaceId}/views`),
|
|
47
|
+
requestJson<WorkspaceSessionSelection>(`/api/workspaces/${workspaceId}/selected-session`)
|
|
48
|
+
])
|
|
49
|
+
const view = pendingView(views.find(view => view.id === viewId))
|
|
50
|
+
if (!pinned && view?.status === 'draft') {
|
|
51
|
+
target = draftSessionId(viewTabId(viewId))
|
|
52
|
+
queryClient.setQueryData<SessionInfo[]>(workspaceKeys.sessions(workspaceId), sessions =>
|
|
53
|
+
sessions?.filter(session => session.sessionId !== sessionId)
|
|
54
|
+
)
|
|
55
|
+
queryClient.removeQueries({ queryKey: workspaceKeys.events(workspaceId, sessionId) })
|
|
56
|
+
} else {
|
|
57
|
+
target =
|
|
58
|
+
view?.executionSessionId ??
|
|
59
|
+
(pinned ? selection.pinned : selection.selected[viewTabId(viewId)]) ??
|
|
60
|
+
sessionId
|
|
61
|
+
}
|
|
62
|
+
moveChatDraft(workspaceId, sessionId, target)
|
|
63
|
+
if (view?.status === 'draft' || view?.status === 'failed')
|
|
64
|
+
liveStore.getState().setActivity(workspaceId, target, 'idle')
|
|
65
|
+
queryClient.setQueryData(workspaceKeys.views(workspaceId), views)
|
|
66
|
+
queryClient.setQueryData(appUiKeys.sessionSelection(workspaceId), selection)
|
|
67
|
+
if (selectionScope === 'browser-tab' && !pinned) {
|
|
68
|
+
const local =
|
|
69
|
+
queryClient.getQueryData<WorkspaceSessionSelection>(
|
|
70
|
+
selectedSessionKey(workspaceId, 'browser-tab')
|
|
71
|
+
) ?? readSelectedSession(workspaceId)
|
|
72
|
+
const selected = { ...local.selected }
|
|
73
|
+
if (view?.status === 'draft') delete selected[viewTabId(viewId)]
|
|
74
|
+
else selected[viewTabId(viewId)] = target
|
|
75
|
+
const next = { selected, pinned: null }
|
|
76
|
+
queryClient.setQueryData(selectedSessionKey(workspaceId, 'browser-tab'), next)
|
|
77
|
+
writeSelectedSession(workspaceId, next)
|
|
78
|
+
}
|
|
79
|
+
} catch {
|
|
80
|
+
moveChatDraft(workspaceId, sessionId, target)
|
|
81
|
+
// Offline: retain the draft at its current identity until state can refresh.
|
|
82
|
+
void queryClient.invalidateQueries({ queryKey: workspaceKeys.views(workspaceId) })
|
|
83
|
+
void queryClient.invalidateQueries({ queryKey: appUiKeys.sessionSelection(workspaceId) })
|
|
84
|
+
}
|
|
85
|
+
const draftKey = composerDraftKey(workspaceId, target)
|
|
86
|
+
const ui = useUiStore.getState()
|
|
87
|
+
ui.setComposerDraft(draftKey, ui.composerDrafts[draftKey] ?? text)
|
|
88
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
|
|
2
|
+
|
|
3
|
+
import { jsonRequest, requestJson } from '@/client/api/http'
|
|
4
|
+
import { workspaceKeys } from '@/client/api/workspace-keys'
|
|
5
|
+
import { useUiStore } from '@/client/store/ui'
|
|
6
|
+
import type {
|
|
7
|
+
DiscoveredWorkspace,
|
|
8
|
+
HarnessInstallations,
|
|
9
|
+
WorkspaceEntry,
|
|
10
|
+
WorkspaceType
|
|
11
|
+
} from '@/lib/types'
|
|
12
|
+
|
|
13
|
+
export function upsertWorkspaceEntry(
|
|
14
|
+
entries: WorkspaceEntry[] | undefined,
|
|
15
|
+
entry: WorkspaceEntry
|
|
16
|
+
): WorkspaceEntry[] {
|
|
17
|
+
const current = entries ?? []
|
|
18
|
+
const existing = current.findIndex(item => item.id === entry.id || item.path === entry.path)
|
|
19
|
+
if (existing === -1) return [entry, ...current]
|
|
20
|
+
return current.map((item, index) => (index === existing ? { ...item, ...entry } : item))
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function useImportWorkspace() {
|
|
24
|
+
const queryClient = useQueryClient()
|
|
25
|
+
return useMutation<WorkspaceEntry, Error, ImportWorkspaceInput>({
|
|
26
|
+
mutationFn: input =>
|
|
27
|
+
requestJson('/api/workspaces', jsonRequest('POST', input), 'Failed to add workspace'),
|
|
28
|
+
onSuccess: (entry, input) => {
|
|
29
|
+
useUiStore.getState().markWorkspacePendingAnalysis(entry.id)
|
|
30
|
+
queryClient.setQueryData<WorkspaceEntry[]>(workspaceKeys.all, previous =>
|
|
31
|
+
upsertWorkspaceEntry(previous, entry)
|
|
32
|
+
)
|
|
33
|
+
queryClient.setQueryData<DiscoveredWorkspace[]>(workspaceKeys.discover, previous =>
|
|
34
|
+
(previous ?? []).filter(item => item.path !== input.path)
|
|
35
|
+
)
|
|
36
|
+
}
|
|
37
|
+
})
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export type ImportWorkspaceInput = {
|
|
41
|
+
path: string
|
|
42
|
+
type: WorkspaceType
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export type WorkspaceCreationInfo = {
|
|
46
|
+
installed: HarnessInstallations
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function useWorkspaceCreationInfo() {
|
|
50
|
+
return useQuery<WorkspaceCreationInfo>({
|
|
51
|
+
queryKey: workspaceKeys.creationInfo,
|
|
52
|
+
// Installations can change while the app is open (the user installs the
|
|
53
|
+
// agent CLI) — refetch on mount instead of caching forever.
|
|
54
|
+
queryFn: () => requestJson('/api/workspaces/create'),
|
|
55
|
+
staleTime: 30_000,
|
|
56
|
+
refetchOnMount: 'always'
|
|
57
|
+
})
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export type CreateWorkspaceInput = {
|
|
61
|
+
name: string
|
|
62
|
+
type: WorkspaceType
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function useCreateWorkspace() {
|
|
66
|
+
const queryClient = useQueryClient()
|
|
67
|
+
return useMutation<WorkspaceEntry, Error, CreateWorkspaceInput>({
|
|
68
|
+
mutationFn: input =>
|
|
69
|
+
requestJson(
|
|
70
|
+
'/api/workspaces/create',
|
|
71
|
+
jsonRequest('POST', input),
|
|
72
|
+
'Failed to create workspace'
|
|
73
|
+
),
|
|
74
|
+
onSuccess: entry => {
|
|
75
|
+
queryClient.setQueryData<WorkspaceEntry[]>(workspaceKeys.all, previous =>
|
|
76
|
+
upsertWorkspaceEntry(previous, entry)
|
|
77
|
+
)
|
|
78
|
+
}
|
|
79
|
+
})
|
|
80
|
+
}
|
|
@@ -2,7 +2,7 @@ import { type FormEvent, type ReactElement, useState } from 'react'
|
|
|
2
2
|
|
|
3
3
|
import { useLocation } from 'wouter'
|
|
4
4
|
|
|
5
|
-
import { useCreateWorkspace,
|
|
5
|
+
import { useCreateWorkspace, useWorkspaceCreationInfo } from '@/client/features/workspace/add/api'
|
|
6
6
|
import { useAppConfig } from '@/client/api/app-config'
|
|
7
7
|
import { Button } from '@/client/components/ui/button'
|
|
8
8
|
import {
|
|
@@ -17,9 +17,11 @@ import { validateWorkspaceFolderName } from '@/lib/workspace-name'
|
|
|
17
17
|
import { WORKSPACE_TYPE_ORDER } from '@/lib/workspace-types'
|
|
18
18
|
import type { WorkspaceType } from '@/lib/types'
|
|
19
19
|
|
|
20
|
-
import { DemoDialog } from '
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
20
|
+
import { DemoDialog } from '@/client/features/demo/demo-dialog'
|
|
21
|
+
import { welcomeNewWorkspace } from '../setup/workspace-welcome-state'
|
|
22
|
+
import { WorkspaceAgentSelector } from './workspace-agent-selector'
|
|
23
|
+
import { getWorkspaceAgentOptions } from './workspace-agent-options'
|
|
24
|
+
import { WorkspaceDialogContent } from './workspace-dialog-content'
|
|
23
25
|
|
|
24
26
|
type CreateWorkspaceDialogProps = {
|
|
25
27
|
trigger: ReactElement
|
|
@@ -32,43 +34,51 @@ const DEFAULT_WORKSPACE_TYPE = WORKSPACE_TYPE_ORDER[0]
|
|
|
32
34
|
export function CreateWorkspaceDialog({ trigger }: CreateWorkspaceDialogProps) {
|
|
33
35
|
const [, navigate] = useLocation()
|
|
34
36
|
const appConfig = useAppConfig()
|
|
35
|
-
const info =
|
|
37
|
+
const info = useWorkspaceCreationInfo()
|
|
36
38
|
const createMutation = useCreateWorkspace()
|
|
37
39
|
|
|
38
40
|
const [open, setOpen] = useState(false)
|
|
39
|
-
const [step, setStep] = useState<CreateWorkspaceStep>('
|
|
41
|
+
const [step, setStep] = useState<CreateWorkspaceStep>('name')
|
|
40
42
|
const [type, setType] = useState<WorkspaceType>(DEFAULT_WORKSPACE_TYPE)
|
|
41
43
|
const [name, setName] = useState('')
|
|
42
44
|
|
|
43
45
|
const trimmedName = name.trim()
|
|
44
46
|
const nameError = trimmedName ? validateWorkspaceFolderName(trimmedName) : null
|
|
45
47
|
const isCreating = createMutation.isPending
|
|
48
|
+
const isChecking = info.isPending || info.isFetching
|
|
49
|
+
const installed = info.isError ? undefined : info.data?.installed
|
|
50
|
+
const options = getWorkspaceAgentOptions(installed)
|
|
51
|
+
const selectedAvailable = options.some(option => option.type === type && !option.disabled)
|
|
52
|
+
const detectionError = !isChecking && !installed ? 'Could not check installed agents.' : undefined
|
|
53
|
+
const canUseAgent = !isChecking && !detectionError && selectedAvailable
|
|
46
54
|
|
|
47
55
|
// Cloud demo: creating workspaces is off — the same trigger opens the
|
|
48
56
|
// cloud-demo promo dialog instead. After every hook so the hook order is stable.
|
|
49
|
-
if (appConfig.
|
|
57
|
+
if (appConfig.demo) {
|
|
50
58
|
return <DemoDialog trigger={trigger} />
|
|
51
59
|
}
|
|
52
60
|
|
|
53
61
|
function finish(workspaceId: string) {
|
|
62
|
+
welcomeNewWorkspace(workspaceId)
|
|
54
63
|
setOpen(false)
|
|
55
64
|
navigate(`/workspace/${workspaceId}`)
|
|
56
65
|
}
|
|
57
66
|
|
|
58
67
|
function resetDialog() {
|
|
59
|
-
setStep('
|
|
68
|
+
setStep('name')
|
|
60
69
|
setType(DEFAULT_WORKSPACE_TYPE)
|
|
61
70
|
setName('')
|
|
62
71
|
createMutation.reset()
|
|
63
72
|
}
|
|
64
73
|
|
|
65
|
-
function
|
|
74
|
+
function continueToAgent() {
|
|
75
|
+
if (!trimmedName || nameError) return
|
|
66
76
|
createMutation.reset()
|
|
67
|
-
setStep('
|
|
77
|
+
setStep('agent')
|
|
68
78
|
}
|
|
69
79
|
|
|
70
80
|
function createWorkspace() {
|
|
71
|
-
if (!trimmedName || nameError || isCreating) return
|
|
81
|
+
if (!trimmedName || nameError || isCreating || !canUseAgent) return
|
|
72
82
|
createMutation.reset()
|
|
73
83
|
createMutation.mutate({ name: trimmedName, type }, { onSuccess: entry => finish(entry.id) })
|
|
74
84
|
}
|
|
@@ -76,31 +86,41 @@ export function CreateWorkspaceDialog({ trigger }: CreateWorkspaceDialogProps) {
|
|
|
76
86
|
return (
|
|
77
87
|
<Dialog
|
|
78
88
|
open={open}
|
|
79
|
-
onOpenChange={
|
|
89
|
+
onOpenChange={nextOpen => {
|
|
90
|
+
if (!nextOpen && isCreating) return
|
|
91
|
+
setOpen(nextOpen)
|
|
92
|
+
if (nextOpen) void info.refetch({ cancelRefetch: false })
|
|
93
|
+
}}
|
|
80
94
|
onOpenChangeComplete={nextOpen => {
|
|
81
95
|
if (!nextOpen) resetDialog()
|
|
82
96
|
}}
|
|
83
97
|
>
|
|
84
98
|
<DialogTrigger render={trigger} />
|
|
85
|
-
<WorkspaceDialogContent>
|
|
86
|
-
{step === '
|
|
87
|
-
<WorkspaceAgentStep
|
|
88
|
-
title="Create new workspace"
|
|
89
|
-
selectedType={type}
|
|
90
|
-
availability={info.data?.availability}
|
|
91
|
-
isPending={false}
|
|
92
|
-
secondaryAction={<ExistingFolderButton />}
|
|
93
|
-
primaryLabel="Next"
|
|
94
|
-
onTypeChange={setType}
|
|
95
|
-
onSubmit={continueToName}
|
|
96
|
-
/>
|
|
97
|
-
) : (
|
|
99
|
+
<WorkspaceDialogContent showCloseButton={!isCreating}>
|
|
100
|
+
{step === 'name' ? (
|
|
98
101
|
<WorkspaceNameStep
|
|
99
102
|
name={name}
|
|
100
103
|
validationError={nameError}
|
|
101
|
-
requestError={createMutation.error?.message}
|
|
102
|
-
isPending={isCreating}
|
|
103
104
|
onNameChange={setName}
|
|
105
|
+
onSubmit={continueToAgent}
|
|
106
|
+
/>
|
|
107
|
+
) : (
|
|
108
|
+
<WorkspaceAgentSelector
|
|
109
|
+
title="Create new workspace"
|
|
110
|
+
selectedType={type}
|
|
111
|
+
options={options}
|
|
112
|
+
isLoading={isChecking && !installed}
|
|
113
|
+
errorMessage={detectionError ?? createMutation.error?.message}
|
|
114
|
+
emptyMessage="Install at least one agent to create a new workspace"
|
|
115
|
+
isPending={isCreating || isChecking || Boolean(detectionError)}
|
|
116
|
+
secondaryAction={
|
|
117
|
+
<Button variant="secondary" disabled={isCreating} onClick={() => setStep('name')}>
|
|
118
|
+
Back
|
|
119
|
+
</Button>
|
|
120
|
+
}
|
|
121
|
+
primaryLabel="Create workspace"
|
|
122
|
+
pendingLabel={isCreating ? 'Creating…' : undefined}
|
|
123
|
+
onTypeChange={setType}
|
|
104
124
|
onSubmit={createWorkspace}
|
|
105
125
|
/>
|
|
106
126
|
)}
|
|
@@ -112,8 +132,6 @@ export function CreateWorkspaceDialog({ trigger }: CreateWorkspaceDialogProps) {
|
|
|
112
132
|
type WorkspaceNameStepProps = {
|
|
113
133
|
name: string
|
|
114
134
|
validationError: string | null
|
|
115
|
-
requestError?: string
|
|
116
|
-
isPending: boolean
|
|
117
135
|
onNameChange: (name: string) => void
|
|
118
136
|
onSubmit: () => void
|
|
119
137
|
}
|
|
@@ -121,8 +139,6 @@ type WorkspaceNameStepProps = {
|
|
|
121
139
|
function WorkspaceNameStep({
|
|
122
140
|
name,
|
|
123
141
|
validationError,
|
|
124
|
-
requestError,
|
|
125
|
-
isPending,
|
|
126
142
|
onNameChange,
|
|
127
143
|
onSubmit
|
|
128
144
|
}: WorkspaceNameStepProps) {
|
|
@@ -132,7 +148,10 @@ function WorkspaceNameStep({
|
|
|
132
148
|
}
|
|
133
149
|
|
|
134
150
|
return (
|
|
135
|
-
<form
|
|
151
|
+
<form
|
|
152
|
+
className="flex min-w-[min(22rem,calc(100vw-5rem))] flex-col gap-5"
|
|
153
|
+
onSubmit={handleSubmit}
|
|
154
|
+
>
|
|
136
155
|
<div className="flex flex-col gap-0.5 pr-8">
|
|
137
156
|
<DialogTitle>Create new workspace</DialogTitle>
|
|
138
157
|
<DialogDescription>Give it a short and recognizable name</DialogDescription>
|
|
@@ -146,7 +165,7 @@ function WorkspaceNameStep({
|
|
|
146
165
|
id="workspace-name"
|
|
147
166
|
value={name}
|
|
148
167
|
onChange={event => onNameChange(event.target.value)}
|
|
149
|
-
placeholder="
|
|
168
|
+
placeholder="Workspace name"
|
|
150
169
|
autoFocus
|
|
151
170
|
aria-invalid={Boolean(validationError)}
|
|
152
171
|
aria-describedby={validationError ? 'workspace-name-error' : undefined}
|
|
@@ -160,15 +179,10 @@ function WorkspaceNameStep({
|
|
|
160
179
|
)}
|
|
161
180
|
</div>
|
|
162
181
|
|
|
163
|
-
{requestError && (
|
|
164
|
-
<p role="alert" className="text-xs text-destructive">
|
|
165
|
-
{requestError}
|
|
166
|
-
</p>
|
|
167
|
-
)}
|
|
168
|
-
|
|
169
182
|
<div className="flex items-center justify-end gap-2">
|
|
170
|
-
<
|
|
171
|
-
|
|
183
|
+
<ExistingFolderButton />
|
|
184
|
+
<Button type="submit" disabled={!name.trim() || Boolean(validationError)}>
|
|
185
|
+
Next
|
|
172
186
|
</Button>
|
|
173
187
|
</div>
|
|
174
188
|
</form>
|
|
@@ -184,7 +198,7 @@ function ExistingFolderButton() {
|
|
|
184
198
|
variant="secondary"
|
|
185
199
|
aria-disabled
|
|
186
200
|
onClick={event => event.preventDefault()}
|
|
187
|
-
className="cursor-not-allowed
|
|
201
|
+
className="cursor-not-allowed bg-accent text-muted-foreground hover:bg-accent"
|
|
188
202
|
>
|
|
189
203
|
Use existing folder
|
|
190
204
|
</Button>
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { useState } from 'react'
|
|
2
|
+
|
|
3
|
+
import { Button } from '@/client/components/ui/button'
|
|
4
|
+
import { Dialog, DialogClose } from '@/client/components/ui/dialog'
|
|
5
|
+
import { workspaceDisplayName } from '@/client/features/workspace/workspace-presentation'
|
|
6
|
+
import type { WorkspaceType } from '@/lib/types'
|
|
7
|
+
|
|
8
|
+
import { WorkspaceAgentSelector } from './workspace-agent-selector'
|
|
9
|
+
import { useWorkspaceCreationInfo } from './api'
|
|
10
|
+
import { getWorkspaceAgentOptions } from './workspace-agent-options'
|
|
11
|
+
import { WorkspaceDialogContent } from './workspace-dialog-content'
|
|
12
|
+
import type { WorkspaceImportChoice } from './use-workspace-import'
|
|
13
|
+
|
|
14
|
+
type ImportWorkspaceDialogProps = {
|
|
15
|
+
choice: WorkspaceImportChoice
|
|
16
|
+
isPending: boolean
|
|
17
|
+
errorMessage?: string
|
|
18
|
+
onTypeChange: (type: WorkspaceType) => void
|
|
19
|
+
onSubmit: () => void
|
|
20
|
+
onReset: () => void
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function ImportWorkspaceDialog({
|
|
24
|
+
choice,
|
|
25
|
+
isPending,
|
|
26
|
+
errorMessage,
|
|
27
|
+
onTypeChange,
|
|
28
|
+
onSubmit,
|
|
29
|
+
onReset
|
|
30
|
+
}: ImportWorkspaceDialogProps) {
|
|
31
|
+
const [open, setOpen] = useState(true)
|
|
32
|
+
const info = useWorkspaceCreationInfo()
|
|
33
|
+
const isChecking = info.isPending || info.isFetching
|
|
34
|
+
const installed = info.isError ? undefined : info.data?.installed
|
|
35
|
+
const options = getWorkspaceAgentOptions(installed, choice.workspace.types)
|
|
36
|
+
const detectionError = !isChecking && !installed ? 'Could not check installed agents.' : undefined
|
|
37
|
+
const canImport =
|
|
38
|
+
!isPending &&
|
|
39
|
+
!isChecking &&
|
|
40
|
+
!detectionError &&
|
|
41
|
+
options.some(option => option.type === choice.selectedType && !option.disabled)
|
|
42
|
+
|
|
43
|
+
function handleOpenChange(nextOpen: boolean) {
|
|
44
|
+
if (!nextOpen && isPending) return
|
|
45
|
+
setOpen(nextOpen)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function handleOpenChangeComplete(nextOpen: boolean) {
|
|
49
|
+
if (!nextOpen) onReset()
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<Dialog
|
|
54
|
+
open={open}
|
|
55
|
+
onOpenChange={handleOpenChange}
|
|
56
|
+
onOpenChangeComplete={handleOpenChangeComplete}
|
|
57
|
+
>
|
|
58
|
+
<WorkspaceDialogContent showCloseButton={!isPending}>
|
|
59
|
+
<WorkspaceAgentSelector
|
|
60
|
+
title={`Import ${workspaceDisplayName(choice.workspace)}`}
|
|
61
|
+
selectedType={choice.selectedType}
|
|
62
|
+
options={options}
|
|
63
|
+
isLoading={isChecking && !installed}
|
|
64
|
+
isPending={isPending || isChecking || Boolean(detectionError)}
|
|
65
|
+
errorMessage={detectionError ?? errorMessage}
|
|
66
|
+
secondaryAction={
|
|
67
|
+
<DialogClose render={<Button variant="secondary" />} disabled={isPending}>
|
|
68
|
+
Cancel
|
|
69
|
+
</DialogClose>
|
|
70
|
+
}
|
|
71
|
+
primaryLabel="Add workspace"
|
|
72
|
+
pendingLabel={isPending ? 'Adding…' : undefined}
|
|
73
|
+
onTypeChange={onTypeChange}
|
|
74
|
+
onSubmit={() => {
|
|
75
|
+
if (canImport) onSubmit()
|
|
76
|
+
}}
|
|
77
|
+
/>
|
|
78
|
+
</WorkspaceDialogContent>
|
|
79
|
+
</Dialog>
|
|
80
|
+
)
|
|
81
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useState } from 'react'
|
|
2
2
|
|
|
3
|
-
import { useImportWorkspace } from '
|
|
3
|
+
import { useImportWorkspace } from '@/client/features/workspace/add/api'
|
|
4
4
|
import { WORKSPACE_TYPE_ORDER } from '@/lib/workspace-types'
|
|
5
5
|
import type { DiscoveredWorkspace, WorkspaceEntry, WorkspaceType } from '@/lib/types'
|
|
6
6
|
|