moi-computer 0.12.1-next.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 +26 -26
- package/bin/moi.mjs +2 -2
- package/client/AGENTS.md +5 -2
- package/client/api/app-config.ts +3 -2
- package/client/api/workspace-keys.ts +1 -1
- 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} +18 -23
- 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-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 +4 -4
- package/client/features/chat/{ChatPanel.tsx → chat-panel.tsx} +11 -11
- package/client/features/chat/{ChatPopup.tsx → chat-popup.tsx} +1 -1
- 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} +8 -7
- package/client/features/chat/composer/{ModelPicker.tsx → model-picker.tsx} +1 -1
- package/client/features/chat/composer/{useWorkspaceComposerState.tsx → use-workspace-composer-state.tsx} +12 -28
- package/client/features/chat/composer/{useWorkspaceSkillUpdates.ts → use-workspace-skill-updates.ts} +1 -1
- package/client/features/chat/connection/chat-frames.ts +1 -1
- package/client/features/chat/messages/{ChatEmptyState.tsx → chat-empty-state.tsx} +4 -4
- package/client/features/chat/messages/{MarkdownContent.tsx → markdown-content.tsx} +1 -1
- 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 +2 -2
- package/client/features/chat/sessions/{ChatSelector.tsx → chat-selector.tsx} +2 -2
- package/client/features/chat/sessions/{useSelectedSession.ts → use-selected-session.ts} +2 -2
- package/client/features/chat/{useChat.ts → use-chat.ts} +3 -3
- package/client/features/collab/proxy-user.ts +1 -1
- 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/{useViewSketch.ts → use-view-sketch.ts} +1 -1
- 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} +14 -18
- package/client/features/overview/api.ts +2 -2
- package/client/features/overview/default/registry.tsx +1 -1
- package/client/features/overview/default/{ViewsWidget.tsx → views-widget.tsx} +1 -1
- package/client/features/overview/{HiddenPanel.tsx → hidden-panel.tsx} +2 -2
- package/client/features/overview/{Overview.tsx → overview.tsx} +6 -6
- 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 +1 -1
- package/client/features/views/{PendingViewScreen.tsx → pending-view-screen.tsx} +7 -4
- package/client/features/views/{useViewActions.ts → use-view-actions.ts} +2 -2
- package/client/features/views/{useViewDrafts.ts → use-view-drafts.ts} +15 -6
- package/client/features/views/{ViewManager.tsx → view-manager.tsx} +3 -3
- package/client/features/views/view-submission.ts +1 -1
- 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 +1 -1
- package/client/features/workspace/moi-context.ts +1 -1
- 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/{ThemePanel.tsx → theme-panel.tsx} +3 -3
- package/client/features/workspace/{useWorkspaceNavigation.ts → use-workspace-navigation.ts} +2 -2
- package/client/features/workspace/{WorkspaceScreen.tsx → workspace-content.tsx} +27 -30
- package/client/features/workspace/workspace-identity.tsx +40 -0
- package/client/features/workspace/{WorkspaceMenu.tsx → workspace-menu.tsx} +3 -3
- 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/lib/agent-availability.ts +0 -5
- package/client/main.tsx +1 -1
- package/client/runtime/{useWorkspaceEvents.ts → use-workspace-events.ts} +3 -12
- package/dist/chunk-08ndj2rg.js +2 -0
- package/dist/chunk-2x040tmg.js +68 -0
- package/dist/chunk-3smxq0ts.js +1 -0
- package/dist/{chunk-am1x230f.js → chunk-68ch5hs8.js} +1 -1
- package/dist/{chunk-yvzhwtfa.js → chunk-9vg3xa81.js} +2 -2
- package/dist/chunk-c2p00p9j.css +1 -0
- package/dist/chunk-cs833y9j.js +1 -0
- package/dist/{chunk-gps4qc38.js → chunk-d7cbm65e.js} +1 -1
- package/dist/{chunk-j905va8r.js → chunk-hvh9f5h0.js} +1 -1
- package/dist/{chunk-vqpkqtdr.js → chunk-jvyvwwv3.js} +1 -1
- package/dist/chunk-nwevqe86.js +10 -0
- package/dist/{chunk-hzwr8dp8.js → chunk-q0gbdts4.js} +3 -3
- 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 +1 -1
- package/lib/moi-context.ts +2 -2
- package/lib/scratchpad-skew.ts +3 -3
- package/lib/types.ts +28 -20
- package/lib/update.ts +1 -1
- package/package.json +5 -2
- package/server/AGENTS.md +10 -4
- package/server/README.md +102 -0
- package/server/api/harnesses.ts +56 -0
- package/server/{api.ts → api/index.ts} +85 -97
- package/server/app-config.ts +24 -12
- 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 +1 -1
- 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} +2 -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/{views.ts → applets/views.ts} +7 -7
- 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} +9 -9
- 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 -3252
- package/server/collab/manager.ts +3 -3
- package/server/collab/skill/index.ts +2 -2
- package/server/control.ts +20 -20
- package/server/harness/README.md +47 -25
- package/server/harness/acp/NOTES.md +11 -11
- package/server/harness/acp/archived.ts +3 -3
- package/server/harness/acp/client.ts +2 -2
- package/server/harness/acp/run-durations.ts +1 -1
- package/server/harness/acp/session.ts +5 -5
- package/server/harness/auth.ts +303 -0
- package/server/harness/claude-code/NOTES.md +9 -7
- package/server/harness/claude-code/auth.ts +125 -17
- package/server/harness/claude-code/index.ts +2 -1
- package/server/harness/claude-code/mcp.ts +1 -1
- package/server/harness/claude-code/session.ts +10 -7
- package/server/harness/codex/NOTES.md +12 -12
- package/server/harness/codex/auth.ts +86 -19
- package/server/harness/codex/client.ts +17 -13
- package/server/harness/codex/index.ts +2 -1
- package/server/harness/codex/permissions.ts +3 -3
- package/server/harness/codex/probe.ts +3 -5
- package/server/harness/codex/session.ts +16 -13
- package/server/harness/codex/transport.ts +5 -5
- package/server/harness/executable.ts +42 -18
- 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 +1 -1
- package/server/harness/openclaw/compat.ts +1 -1
- package/server/harness/openclaw/session.ts +5 -2
- package/server/harness/registry.ts +1 -1
- package/server/harness/shell-path.ts +31 -21
- package/server/harness/types.ts +9 -2
- 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 +2 -2
- package/server/{session-archive.ts → sessions/archive.ts} +5 -5
- package/server/{attachment-message.ts → sessions/attachment-message.ts} +1 -1
- package/server/{session-config.ts → sessions/config.ts} +1 -1
- package/server/{session-lifecycle.ts → sessions/lifecycle.ts} +3 -3
- package/server/{pending-views.ts → sessions/pending-views.ts} +3 -3
- package/server/{selected-session.ts → sessions/selected.ts} +1 -1
- package/server/{session-store.ts → sessions/store.ts} +1 -1
- package/server/{view-sessions.ts → sessions/view-sessions.ts} +9 -9
- 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 +3 -3
- package/server/web.ts +14 -7
- package/server/{env-apply.ts → workspaces/env-apply.ts} +5 -5
- package/server/{workspace-env.ts → workspaces/env.ts} +3 -3
- package/server/{workspace-import.ts → workspaces/import.ts} +4 -4
- package/server/{workspace-init.ts → workspaces/init.ts} +5 -5
- 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} +3 -3
- package/server/{required-env.ts → workspaces/required-env.ts} +3 -3
- package/server/{moi-scaffold.ts → workspaces/scaffold.ts} +3 -3
- 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 +12 -12
- package/workspace/.claude/skills/moi-workspace/references/COLLAB.md +2 -2
- 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/composer/banners/AgentAvailabilityBanner.tsx +0 -101
- package/client/features/home/workspace-setup/ImportWorkspaceDialog.tsx +0 -92
- package/client/features/overview/WorkspaceName.tsx +0 -60
- package/dist/chunk-1zhnhy00.js +0 -1
- package/dist/chunk-27501vke.js +0 -1
- package/dist/chunk-9xtv6djt.js +0 -2
- package/dist/chunk-darpsw65.js +0 -1
- package/dist/chunk-n33w9y38.js +0 -10
- package/dist/chunk-r63ks44z.js +0 -68
- package/dist/chunk-wd46nk26.css +0 -1
- package/dist/chunk-xgt7vxt9.js +0 -1
- package/server/agent.ts +0 -223
- /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/{tabs.ts → workspaces/tabs.ts} +0 -0
- /package/server/{theme.ts → workspaces/theme.ts} +0 -0
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { lazy, Suspense } from 'react'
|
|
2
2
|
import { Redirect, Route, Switch } from 'wouter'
|
|
3
3
|
|
|
4
|
-
import { ChatStatesPage } from './
|
|
5
|
-
import { BlobatarShapesPage } from './
|
|
6
|
-
import { DevIndexPage } from './
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
4
|
+
import { ChatStatesPage } from './chat-states-page'
|
|
5
|
+
import { BlobatarShapesPage } from './blobatar-shapes-page'
|
|
6
|
+
import { DevIndexPage } from './dev-index-page'
|
|
7
|
+
import { WorkspaceSetupPage } from './workspace-setup-page'
|
|
8
|
+
import { HarnessDebugPage } from './harness-debug-page'
|
|
9
|
+
import { TextureLabPage } from './texture-lab-page'
|
|
10
|
+
import { ToolCallsPage } from './tool-calls-page'
|
|
10
11
|
import { UiComponentsPage } from './ui-components/ui-components-page'
|
|
11
12
|
|
|
12
13
|
// All /dev/* routes live with their pages here and load only in development;
|
|
@@ -27,6 +28,7 @@ export default function DevRoutes() {
|
|
|
27
28
|
<CollabPage />
|
|
28
29
|
</Suspense>
|
|
29
30
|
</Route>
|
|
31
|
+
<Route path="/dev/workspace-setup" component={WorkspaceSetupPage} />
|
|
30
32
|
<Route path="/dev/harness" component={HarnessDebugPage} />
|
|
31
33
|
<Route path="/dev/blobatar-shapes" component={BlobatarShapesPage} />
|
|
32
34
|
<Route path="/dev/chat-states" component={ChatStatesPage} />
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
AppEnvironment,
|
|
3
|
+
HarnessAvailability,
|
|
4
|
+
HarnessLoginState,
|
|
5
|
+
WorkspaceAgent
|
|
6
|
+
} from '@/lib/types'
|
|
7
|
+
import type { LoginHarness } from '@/client/features/harness/api'
|
|
8
|
+
|
|
9
|
+
export const PREVIEW_WORKSPACE_ID = 'setup-preview'
|
|
10
|
+
export const MOCK_CODE_SIGN_IN_URL = 'https://example.invalid/moi-code-sign-in'
|
|
11
|
+
export const MOCK_SIGN_IN_URL = 'https://example.invalid/moi-sign-in'
|
|
12
|
+
export const SETUP_SCENARIOS = [
|
|
13
|
+
'welcome',
|
|
14
|
+
'login',
|
|
15
|
+
'missing-agent',
|
|
16
|
+
'missing-folder',
|
|
17
|
+
'loading'
|
|
18
|
+
] as const
|
|
19
|
+
export type SetupScenario = (typeof SETUP_SCENARIOS)[number]
|
|
20
|
+
|
|
21
|
+
export function createSetupMocks(
|
|
22
|
+
environment: AppEnvironment,
|
|
23
|
+
harness: LoginHarness,
|
|
24
|
+
scenario: SetupScenario
|
|
25
|
+
) {
|
|
26
|
+
let availability: HarnessAvailability =
|
|
27
|
+
scenario === 'missing-agent'
|
|
28
|
+
? {
|
|
29
|
+
status: 'unavailable',
|
|
30
|
+
code: 'not-installed',
|
|
31
|
+
reason: 'This agent is not installed. Install it, then try again.'
|
|
32
|
+
}
|
|
33
|
+
: { status: 'login-required', reason: 'Sign in to continue.' }
|
|
34
|
+
let login: HarnessLoginState | undefined
|
|
35
|
+
const missingFolder = scenario === 'missing-folder'
|
|
36
|
+
|
|
37
|
+
function complete() {
|
|
38
|
+
availability = { status: 'available' }
|
|
39
|
+
login = undefined
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async function request(input: RequestInfo | URL, init?: RequestInit): Promise<Response> {
|
|
43
|
+
const url = new URL(
|
|
44
|
+
input instanceof Request ? input.url : String(input),
|
|
45
|
+
'http://preview.invalid'
|
|
46
|
+
)
|
|
47
|
+
const method = init?.method ?? (input instanceof Request ? input.method : 'GET')
|
|
48
|
+
const path = url.pathname
|
|
49
|
+
if (url.origin !== 'http://preview.invalid')
|
|
50
|
+
throw new Error('Sandbox blocked an external request')
|
|
51
|
+
if (path === '/api/config' && method === 'GET') {
|
|
52
|
+
return Response.json({
|
|
53
|
+
environment,
|
|
54
|
+
demo: false,
|
|
55
|
+
experimental: { collab: false },
|
|
56
|
+
demoInstallUrl: ''
|
|
57
|
+
})
|
|
58
|
+
}
|
|
59
|
+
if (path === `/api/workspaces/${PREVIEW_WORKSPACE_ID}` && method === 'DELETE')
|
|
60
|
+
return new Response(null, { status: 204 })
|
|
61
|
+
if (path === `/api/workspaces/${PREVIEW_WORKSPACE_ID}/agent` && method === 'GET') {
|
|
62
|
+
return Response.json({
|
|
63
|
+
provider: harness,
|
|
64
|
+
availability,
|
|
65
|
+
models: [],
|
|
66
|
+
supportsStreaming: true,
|
|
67
|
+
supportsArchiving: true,
|
|
68
|
+
workspaceFolderMissing: missingFolder
|
|
69
|
+
} satisfies WorkspaceAgent)
|
|
70
|
+
}
|
|
71
|
+
const authPath = `/api/harnesses/${harness}/auth`
|
|
72
|
+
if (path === authPath && method === 'GET') return Response.json({ availability, login })
|
|
73
|
+
if (path === `${authPath}/login` && method === 'POST') {
|
|
74
|
+
login = { state: 'starting' }
|
|
75
|
+
await new Promise(resolve => setTimeout(resolve, 500))
|
|
76
|
+
login = {
|
|
77
|
+
state: 'pending',
|
|
78
|
+
id: 'mock-login',
|
|
79
|
+
url:
|
|
80
|
+
harness === 'claude-code' && environment === 'cloud'
|
|
81
|
+
? MOCK_CODE_SIGN_IN_URL
|
|
82
|
+
: MOCK_SIGN_IN_URL,
|
|
83
|
+
...(harness === 'claude-code'
|
|
84
|
+
? { codeUrl: MOCK_CODE_SIGN_IN_URL }
|
|
85
|
+
: environment === 'cloud'
|
|
86
|
+
? { userCode: 'MOCK-1234' }
|
|
87
|
+
: {})
|
|
88
|
+
}
|
|
89
|
+
return Response.json(login)
|
|
90
|
+
}
|
|
91
|
+
if (path === `${authPath}/login/mock-login/code` && method === 'POST') {
|
|
92
|
+
const body = JSON.parse(String(init?.body)) as { code: string }
|
|
93
|
+
if (body.code !== 'MOCK-AUTH-CODE')
|
|
94
|
+
return new Response('Use MOCK-AUTH-CODE in this sandbox.', { status: 400 })
|
|
95
|
+
complete()
|
|
96
|
+
return new Response(null, { status: 204 })
|
|
97
|
+
}
|
|
98
|
+
throw new Error(`Sandbox blocked an unexpected request: ${method} ${path}`)
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return { request, complete }
|
|
102
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export function WorkspaceSetupPage() {
|
|
2
|
+
return (
|
|
3
|
+
<iframe
|
|
4
|
+
title="Workspace setup sandbox"
|
|
5
|
+
src="/dev/workspace-setup/preview"
|
|
6
|
+
allow="clipboard-write"
|
|
7
|
+
sandbox="allow-scripts allow-same-origin allow-forms"
|
|
8
|
+
className="h-dvh w-full border-0"
|
|
9
|
+
/>
|
|
10
|
+
)
|
|
11
|
+
}
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import { useState } from 'react'
|
|
2
|
+
import { createRoot } from 'react-dom/client'
|
|
3
|
+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
|
4
|
+
import { Router, useLocation } from 'wouter'
|
|
5
|
+
import { memoryLocation } from 'wouter/memory-location'
|
|
6
|
+
|
|
7
|
+
import { loadAppConfig } from '@/client/api/app-config'
|
|
8
|
+
import { Button } from '@/client/components/ui/button'
|
|
9
|
+
import { Input } from '@/client/components/ui/input'
|
|
10
|
+
import {
|
|
11
|
+
Dialog,
|
|
12
|
+
DialogContent,
|
|
13
|
+
DialogDescription,
|
|
14
|
+
DialogTitle
|
|
15
|
+
} from '@/client/components/ui/dialog'
|
|
16
|
+
import { TooltipProvider } from '@/client/components/ui/tooltip'
|
|
17
|
+
import { Toaster } from '@/client/components/ui/toast'
|
|
18
|
+
import { WorkspaceSetupPanel } from '@/client/features/workspace/setup/workspace-setup-panel'
|
|
19
|
+
import { useWorkspaceSetup } from '@/client/features/workspace/setup/workspace-setup'
|
|
20
|
+
import { WorkspaceWelcomeState } from '@/client/features/workspace/setup/workspace-welcome-state'
|
|
21
|
+
import { WorkspaceLoadingState } from '@/client/features/workspace/setup/workspace-recovery-states'
|
|
22
|
+
import type { AppEnvironment } from '@/lib/types'
|
|
23
|
+
import { workspaceTypeLabel } from '@/client/features/workspace/workspace-presentation'
|
|
24
|
+
import { useHarnessAuth, type LoginHarness } from '@/client/features/harness/api'
|
|
25
|
+
import {
|
|
26
|
+
createSetupMocks,
|
|
27
|
+
MOCK_SIGN_IN_URL,
|
|
28
|
+
MOCK_CODE_SIGN_IN_URL,
|
|
29
|
+
PREVIEW_WORKSPACE_ID,
|
|
30
|
+
SETUP_SCENARIOS
|
|
31
|
+
} from './workspace-setup-mocks'
|
|
32
|
+
import type { SetupScenario } from './workspace-setup-mocks'
|
|
33
|
+
|
|
34
|
+
const scenarioLabels: Record<SetupScenario, string> = {
|
|
35
|
+
welcome: 'Welcome',
|
|
36
|
+
login: 'Login',
|
|
37
|
+
'missing-agent': 'Agent missing',
|
|
38
|
+
'missing-folder': 'Folder missing',
|
|
39
|
+
loading: 'Loading'
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
type SetupPreviewProps = {
|
|
43
|
+
mocks: ReturnType<typeof createSetupMocks>
|
|
44
|
+
client: QueryClient
|
|
45
|
+
environment: AppEnvironment
|
|
46
|
+
harness: LoginHarness
|
|
47
|
+
scenario: SetupScenario
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function SetupPreview({ mocks, client, environment, harness, scenario }: SetupPreviewProps) {
|
|
51
|
+
const [provider, setProvider] = useState<'browser' | 'code' | 'closed'>()
|
|
52
|
+
const [deviceCode, setDeviceCode] = useState('')
|
|
53
|
+
const auth = useHarnessAuth(harness)
|
|
54
|
+
const pendingId = auth.data?.login?.state === 'pending' ? auth.data.login.id : undefined
|
|
55
|
+
// Both local harnesses open the browser automatically.
|
|
56
|
+
const providerPage = provider ?? (environment === 'local' && pendingId ? 'browser' : 'closed')
|
|
57
|
+
|
|
58
|
+
function restart(next: Record<string, string> = {}) {
|
|
59
|
+
const params = new URLSearchParams({ environment, harness, scenario, ...next })
|
|
60
|
+
window.location.assign(`?${params.toString()}`)
|
|
61
|
+
}
|
|
62
|
+
function update(action: () => void) {
|
|
63
|
+
action()
|
|
64
|
+
void client.invalidateQueries()
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return (
|
|
68
|
+
<div
|
|
69
|
+
className="flex h-dvh flex-col bg-background text-foreground"
|
|
70
|
+
onClickCapture={event => {
|
|
71
|
+
const link = (event.target as Element).closest('a')
|
|
72
|
+
if (link?.href === MOCK_SIGN_IN_URL || link?.href === MOCK_CODE_SIGN_IN_URL) {
|
|
73
|
+
event.preventDefault()
|
|
74
|
+
setProvider(link.href === MOCK_CODE_SIGN_IN_URL ? 'code' : 'browser')
|
|
75
|
+
}
|
|
76
|
+
}}
|
|
77
|
+
>
|
|
78
|
+
<header className="flex shrink-0 flex-wrap items-center gap-3 border-b border-border p-3 text-sm">
|
|
79
|
+
<div className="flex flex-wrap gap-2" role="group" aria-label="Environment">
|
|
80
|
+
{(['local', 'cloud'] as const).map(value => (
|
|
81
|
+
<Button
|
|
82
|
+
key={value}
|
|
83
|
+
size="sm"
|
|
84
|
+
variant={environment === value ? 'default' : 'secondary'}
|
|
85
|
+
onClick={() => restart({ environment: value })}
|
|
86
|
+
>
|
|
87
|
+
{value === 'local' ? 'Local' : 'Cloud'}
|
|
88
|
+
</Button>
|
|
89
|
+
))}
|
|
90
|
+
</div>
|
|
91
|
+
<div className="flex flex-wrap gap-2" role="group" aria-label="Agent">
|
|
92
|
+
{(['claude-code', 'codex'] as const).map(value => (
|
|
93
|
+
<Button
|
|
94
|
+
key={value}
|
|
95
|
+
size="sm"
|
|
96
|
+
variant={harness === value ? 'default' : 'secondary'}
|
|
97
|
+
onClick={() => restart({ harness: value })}
|
|
98
|
+
>
|
|
99
|
+
{workspaceTypeLabel[value]}
|
|
100
|
+
</Button>
|
|
101
|
+
))}
|
|
102
|
+
</div>
|
|
103
|
+
<div className="flex flex-wrap gap-2" role="group" aria-label="Scenario">
|
|
104
|
+
{SETUP_SCENARIOS.map(value => (
|
|
105
|
+
<Button
|
|
106
|
+
key={value}
|
|
107
|
+
size="sm"
|
|
108
|
+
variant={scenario === value ? 'default' : 'secondary'}
|
|
109
|
+
onClick={() => restart({ scenario: value })}
|
|
110
|
+
>
|
|
111
|
+
{scenarioLabels[value]}
|
|
112
|
+
</Button>
|
|
113
|
+
))}
|
|
114
|
+
</div>
|
|
115
|
+
</header>
|
|
116
|
+
<main className="flex min-h-0 flex-1 overflow-y-auto">
|
|
117
|
+
{scenario === 'welcome' ? (
|
|
118
|
+
<WorkspaceSetupPanel>
|
|
119
|
+
<WorkspaceWelcomeState name="My workspace" workspaceType={harness} />
|
|
120
|
+
</WorkspaceSetupPanel>
|
|
121
|
+
) : scenario === 'loading' ? (
|
|
122
|
+
<WorkspaceSetupPanel>
|
|
123
|
+
<WorkspaceLoadingState />
|
|
124
|
+
</WorkspaceSetupPanel>
|
|
125
|
+
) : (
|
|
126
|
+
<SetupScreen />
|
|
127
|
+
)}
|
|
128
|
+
</main>
|
|
129
|
+
<Dialog
|
|
130
|
+
open={providerPage !== 'closed'}
|
|
131
|
+
onOpenChange={open => !open && setProvider('closed')}
|
|
132
|
+
>
|
|
133
|
+
<DialogContent>
|
|
134
|
+
<DialogTitle>Mock sign-in page</DialogTitle>
|
|
135
|
+
<DialogDescription>
|
|
136
|
+
This simulates the agent’s browser sign-in. No credentials are needed.
|
|
137
|
+
</DialogDescription>
|
|
138
|
+
{providerPage === 'code' ? (
|
|
139
|
+
<>
|
|
140
|
+
<p className="text-sm">
|
|
141
|
+
Copy this authorization code, close this dialog, and submit it in the login screen:
|
|
142
|
+
</p>
|
|
143
|
+
<code>MOCK-AUTH-CODE</code>
|
|
144
|
+
<Button onClick={() => setProvider('closed')}>Back to Moi</Button>
|
|
145
|
+
</>
|
|
146
|
+
) : (
|
|
147
|
+
<>
|
|
148
|
+
{environment === 'cloud' && (
|
|
149
|
+
<Input
|
|
150
|
+
aria-label="Device code"
|
|
151
|
+
placeholder="Paste MOCK-1234"
|
|
152
|
+
value={deviceCode}
|
|
153
|
+
onChange={event => setDeviceCode(event.target.value)}
|
|
154
|
+
/>
|
|
155
|
+
)}
|
|
156
|
+
<Button
|
|
157
|
+
disabled={environment === 'cloud' && deviceCode !== 'MOCK-1234'}
|
|
158
|
+
onClick={() => {
|
|
159
|
+
update(mocks.complete)
|
|
160
|
+
setProvider('closed')
|
|
161
|
+
}}
|
|
162
|
+
>
|
|
163
|
+
Authorize
|
|
164
|
+
</Button>
|
|
165
|
+
</>
|
|
166
|
+
)}
|
|
167
|
+
</DialogContent>
|
|
168
|
+
</Dialog>
|
|
169
|
+
</div>
|
|
170
|
+
)
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function SetupScreen() {
|
|
174
|
+
const [path] = useLocation()
|
|
175
|
+
const { content, ready } = useWorkspaceSetup(PREVIEW_WORKSPACE_ID)
|
|
176
|
+
if (ready) return null
|
|
177
|
+
return path === '/' ? (
|
|
178
|
+
<div
|
|
179
|
+
role="status"
|
|
180
|
+
className="flex flex-1 items-center justify-center p-6 text-sm text-muted-foreground"
|
|
181
|
+
>
|
|
182
|
+
Workspace removed
|
|
183
|
+
</div>
|
|
184
|
+
) : (
|
|
185
|
+
<WorkspaceSetupPanel>{content}</WorkspaceSetupPanel>
|
|
186
|
+
)
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export async function mountSetupPreview(element: HTMLElement) {
|
|
190
|
+
const params = new URLSearchParams(location.search)
|
|
191
|
+
const environment = params.get('environment') === 'cloud' ? 'cloud' : 'local'
|
|
192
|
+
const harness = params.get('harness') === 'codex' ? 'codex' : 'claude-code'
|
|
193
|
+
const scenario = SETUP_SCENARIOS.find(value => value === params.get('scenario')) ?? 'welcome'
|
|
194
|
+
const mocks = createSetupMocks(environment, harness, scenario)
|
|
195
|
+
// Scoped to this separate document. No fallback to the real fetch or socket.
|
|
196
|
+
window.fetch = Object.assign(mocks.request, { preconnect: fetch.preconnect })
|
|
197
|
+
Object.defineProperty(window, 'WebSocket', {
|
|
198
|
+
value: class extends EventTarget {
|
|
199
|
+
static OPEN = 1
|
|
200
|
+
readyState = 0
|
|
201
|
+
send() {}
|
|
202
|
+
close() {}
|
|
203
|
+
}
|
|
204
|
+
})
|
|
205
|
+
await loadAppConfig()
|
|
206
|
+
const client = new QueryClient({ defaultOptions: { queries: { retry: false } } })
|
|
207
|
+
const locationHook = memoryLocation({
|
|
208
|
+
path: `/workspace/${PREVIEW_WORKSPACE_ID}`
|
|
209
|
+
})
|
|
210
|
+
createRoot(element).render(
|
|
211
|
+
<QueryClientProvider client={client}>
|
|
212
|
+
<TooltipProvider>
|
|
213
|
+
<Router hook={locationHook.hook}>
|
|
214
|
+
<SetupPreview
|
|
215
|
+
mocks={mocks}
|
|
216
|
+
client={client}
|
|
217
|
+
environment={environment}
|
|
218
|
+
harness={harness}
|
|
219
|
+
scenario={scenario}
|
|
220
|
+
/>
|
|
221
|
+
</Router>
|
|
222
|
+
<Toaster />
|
|
223
|
+
</TooltipProvider>
|
|
224
|
+
</QueryClientProvider>
|
|
225
|
+
)
|
|
226
|
+
}
|
|
@@ -5,7 +5,7 @@ import { Button } from '@/client/components/ui/button'
|
|
|
5
5
|
import { Tooltip, TooltipContent, TooltipTrigger } from '@/client/components/ui/tooltip'
|
|
6
6
|
import { cn } from '@/client/lib/cn'
|
|
7
7
|
|
|
8
|
-
import { type DrawingControls, useDrawingHistoryState } from './
|
|
8
|
+
import { type DrawingControls, useDrawingHistoryState } from './use-drawing-layer'
|
|
9
9
|
|
|
10
10
|
type DrawingToolbarProps = {
|
|
11
11
|
controls: DrawingControls
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useCallback, useEffect, useMemo, useRef } from 'react'
|
|
1
|
+
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef } from 'react'
|
|
2
2
|
|
|
3
3
|
import { toast } from '@/client/components/ui/toast'
|
|
4
4
|
import {
|
|
@@ -6,11 +6,11 @@ import {
|
|
|
6
6
|
stageDrawingDraft
|
|
7
7
|
} from '@/client/features/chat/composer/attachments/draft-attachments'
|
|
8
8
|
import { liveStore } from '@/client/features/chat/chat-store'
|
|
9
|
-
import type { ComposerAnnotationControls } from '@/client/features/chat/composer/
|
|
9
|
+
import type { ComposerAnnotationControls } from '@/client/features/chat/composer/chat-composer'
|
|
10
10
|
import { useLatestRef } from '@/client/lib/use-latest-ref'
|
|
11
11
|
import type { LayoutMode, WorkspaceTabId } from '@/lib/types'
|
|
12
12
|
|
|
13
|
-
import { type DrawingController, useDrawingLayer } from './
|
|
13
|
+
import { type DrawingController, useDrawingLayer } from './use-drawing-layer'
|
|
14
14
|
|
|
15
15
|
type AnnotationOrigin = 'docked' | 'popup'
|
|
16
16
|
|
|
@@ -47,7 +47,6 @@ export function useChatAnnotation({
|
|
|
47
47
|
openPopup
|
|
48
48
|
}: UseChatAnnotationOptions): ChatAnnotationController {
|
|
49
49
|
const draftRef = useRef<ChatAnnotationDraft | null>(null)
|
|
50
|
-
const latestBlobRef = useRef<Blob | null>(null)
|
|
51
50
|
const uploadRevisionsRef = useRef(new Map<string, number>())
|
|
52
51
|
const closePopupRef = useLatestRef(closePopup)
|
|
53
52
|
const openPopupRef = useLatestRef(openPopup)
|
|
@@ -59,7 +58,6 @@ export function useChatAnnotation({
|
|
|
59
58
|
const draft = draftRef.current
|
|
60
59
|
if (!draft) return
|
|
61
60
|
|
|
62
|
-
latestBlobRef.current = blob
|
|
63
61
|
if (!blob) {
|
|
64
62
|
liveStore.getState().removeAttachment(draft.workspaceId, draft.attachmentId)
|
|
65
63
|
return
|
|
@@ -75,36 +73,51 @@ export function useChatAnnotation({
|
|
|
75
73
|
})
|
|
76
74
|
}, [])
|
|
77
75
|
|
|
78
|
-
const
|
|
76
|
+
const save = useCallback(async (result: Blob | null | Promise<Blob | null>) => {
|
|
77
|
+
const draft = draftRef.current
|
|
78
|
+
if (!draft) return
|
|
79
|
+
// Claim the draft before awaiting export so finish, cancel, and unmount
|
|
80
|
+
// cannot upload it twice.
|
|
81
|
+
draftRef.current = null
|
|
79
82
|
const revision = (uploadRevisionsRef.current.get(draft.attachmentId) ?? 0) + 1
|
|
80
83
|
uploadRevisionsRef.current.set(draft.attachmentId, revision)
|
|
81
|
-
|
|
84
|
+
const isCurrent = () => uploadRevisionsRef.current.get(draft.attachmentId) === revision
|
|
85
|
+
const blob = await result
|
|
86
|
+
if (!blob || !isCurrent()) return
|
|
87
|
+
await stageDrawing({
|
|
82
88
|
workspaceId: draft.workspaceId,
|
|
83
89
|
sessionId: draft.sourceSessionId,
|
|
84
90
|
localId: draft.attachmentId,
|
|
85
91
|
purpose: 'annotation',
|
|
86
92
|
source: draft.source,
|
|
87
93
|
blob,
|
|
88
|
-
isCurrent
|
|
94
|
+
isCurrent
|
|
89
95
|
})
|
|
90
96
|
}, [])
|
|
91
97
|
|
|
92
98
|
const complete = useCallback(
|
|
93
99
|
async (blob: Blob | null) => {
|
|
94
100
|
const draft = draftRef.current
|
|
95
|
-
draftRef.current = null
|
|
96
|
-
latestBlobRef.current = null
|
|
97
101
|
// Awaited so a send that finishes the drawing only dispatches once the
|
|
98
102
|
// attachment is uploaded and ready.
|
|
99
|
-
|
|
103
|
+
await save(blob)
|
|
100
104
|
if (draft?.origin === 'popup') openPopupRef.current()
|
|
101
105
|
},
|
|
102
|
-
[openPopupRef,
|
|
106
|
+
[openPopupRef, save]
|
|
103
107
|
)
|
|
104
108
|
|
|
105
109
|
const annotation = useDrawingLayer({ onChange: change, onFinish: complete })
|
|
106
110
|
const { controls } = annotation
|
|
107
|
-
const { active, starting, open, finish, cancel: cancelLayer } = controls
|
|
111
|
+
const { active, starting, open, finish, flush, cancel: cancelLayer } = controls
|
|
112
|
+
|
|
113
|
+
useLayoutEffect(
|
|
114
|
+
() => () => {
|
|
115
|
+
// Capture committed strokes before the drawing layer's passive cleanup
|
|
116
|
+
// clears its session. flush() also waits for an export already in progress.
|
|
117
|
+
if (draftRef.current) void save(flush())
|
|
118
|
+
},
|
|
119
|
+
[flush, save]
|
|
120
|
+
)
|
|
108
121
|
|
|
109
122
|
const start = useCallback(
|
|
110
123
|
async (origin: AnnotationOrigin) => {
|
|
@@ -135,16 +148,10 @@ export function useChatAnnotation({
|
|
|
135
148
|
)
|
|
136
149
|
|
|
137
150
|
const cancel = useCallback(async () => {
|
|
138
|
-
const
|
|
151
|
+
const pendingSave = draftRef.current ? save(flush()) : undefined
|
|
139
152
|
await cancelLayer()
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
const blob = latestBlobRef.current
|
|
143
|
-
latestBlobRef.current = null
|
|
144
|
-
// An implicit cancel (tab/session switch) keeps the drawn-so-far
|
|
145
|
-
// annotation as an attachment, so it gets its one deferred upload here.
|
|
146
|
-
if (draft && blob) void upload(draft, blob)
|
|
147
|
-
}, [cancelLayer, upload])
|
|
153
|
+
await pendingSave
|
|
154
|
+
}, [cancelLayer, flush, save])
|
|
148
155
|
|
|
149
156
|
const remove = useCallback(
|
|
150
157
|
(localId: string) => {
|
|
@@ -153,7 +160,6 @@ export function useChatAnnotation({
|
|
|
153
160
|
liveStore.getState().removeAttachment(workspaceId, localId)
|
|
154
161
|
if (draftRef.current?.attachmentId === localId) {
|
|
155
162
|
draftRef.current = null
|
|
156
|
-
latestBlobRef.current = null
|
|
157
163
|
void cancelLayer()
|
|
158
164
|
}
|
|
159
165
|
},
|
|
@@ -16,7 +16,7 @@ import type {
|
|
|
16
16
|
import { toast } from '@/client/components/ui/toast'
|
|
17
17
|
import { useLatestRef } from '@/client/lib/use-latest-ref'
|
|
18
18
|
|
|
19
|
-
import type { DrawingCanvasPointerProps, DrawingLayerProps } from './
|
|
19
|
+
import type { DrawingCanvasPointerProps, DrawingLayerProps } from './drawing-layer'
|
|
20
20
|
import { captureElement, drawingCaptureScale } from './capture-element'
|
|
21
21
|
|
|
22
22
|
export type DrawingPoint = {
|
|
@@ -8,7 +8,7 @@ import { attachmentKey, liveStore } from '@/client/features/chat/chat-store'
|
|
|
8
8
|
import { useLatestRef } from '@/client/lib/use-latest-ref'
|
|
9
9
|
import type { WorkspaceTabId } from '@/lib/types'
|
|
10
10
|
|
|
11
|
-
import { useDrawingLayer } from './
|
|
11
|
+
import { useDrawingLayer } from './use-drawing-layer'
|
|
12
12
|
|
|
13
13
|
type UseViewSketchOptions = {
|
|
14
14
|
active: boolean
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { useQuery } from '@tanstack/react-query'
|
|
2
|
+
import { jsonRequest, requestJson, requestVoid } from '@/client/api/http'
|
|
3
|
+
import type {
|
|
4
|
+
HarnessAvailability,
|
|
5
|
+
HarnessLogin,
|
|
6
|
+
HarnessLoginState,
|
|
7
|
+
WorkspaceType
|
|
8
|
+
} from '@/lib/types'
|
|
9
|
+
|
|
10
|
+
export function startHarnessLogin(type: WorkspaceType): Promise<HarnessLogin> {
|
|
11
|
+
return requestJson(
|
|
12
|
+
`/api/harnesses/${type}/auth/login`,
|
|
13
|
+
{ method: 'POST' },
|
|
14
|
+
'Could not start sign-in'
|
|
15
|
+
)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export type LoginHarness = 'claude-code' | 'codex'
|
|
19
|
+
|
|
20
|
+
export type HarnessAuth = {
|
|
21
|
+
availability: HarnessAvailability
|
|
22
|
+
login?: HarnessLoginState
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function useHarnessAuth(type: WorkspaceType) {
|
|
26
|
+
return useQuery({
|
|
27
|
+
queryKey: ['harness-auth', type],
|
|
28
|
+
queryFn: () => requestJson<HarnessAuth>(`/api/harnesses/${type}/auth`),
|
|
29
|
+
staleTime: 2_000,
|
|
30
|
+
refetchInterval: 2_000
|
|
31
|
+
})
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function submitHarnessLoginCode(type: WorkspaceType, id: string, code: string) {
|
|
35
|
+
return requestVoid(`/api/harnesses/${type}/auth/login/${id}/code`, jsonRequest('POST', { code }))
|
|
36
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react'
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
IconChevronRight,
|
|
5
|
+
IconCopy,
|
|
6
|
+
IconCheck,
|
|
7
|
+
IconCircleNumber1,
|
|
8
|
+
IconCircleNumber2,
|
|
9
|
+
IconCircleNumber3
|
|
10
|
+
} from '@tabler/icons-react'
|
|
11
|
+
|
|
12
|
+
import { buttonVariants } from '@/client/components/ui/button'
|
|
13
|
+
import { cn } from '@/client/lib/cn'
|
|
14
|
+
|
|
15
|
+
type DeviceLoginStepsProps = {
|
|
16
|
+
code: string
|
|
17
|
+
url: string
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function DeviceLoginSteps({ code, url }: DeviceLoginStepsProps) {
|
|
21
|
+
const [copied, setCopied] = useState(false)
|
|
22
|
+
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
if (!copied) return
|
|
25
|
+
const timer = setTimeout(() => setCopied(false), 3000)
|
|
26
|
+
return () => clearTimeout(timer)
|
|
27
|
+
}, [copied])
|
|
28
|
+
|
|
29
|
+
const copyCode = () => {
|
|
30
|
+
navigator.clipboard
|
|
31
|
+
?.writeText(code)
|
|
32
|
+
.then(() => setCopied(true))
|
|
33
|
+
.catch(() => {})
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<ol className="mx-auto grid w-full max-w-64 gap-6 text-left text-sm lg:max-w-3xl lg:grid-cols-3 lg:text-center">
|
|
38
|
+
<li className="flex flex-col items-start gap-3 lg:items-center">
|
|
39
|
+
<IconCircleNumber1 size={24} stroke={1.5} className="shrink-0" />
|
|
40
|
+
<div className="flex min-w-0 flex-col items-start gap-3 lg:items-center">
|
|
41
|
+
<p>Enable device code sign-in for Codex in ChatGPT settings</p>
|
|
42
|
+
<a
|
|
43
|
+
href="https://chatgpt.com/settings/security"
|
|
44
|
+
target="_blank"
|
|
45
|
+
rel="noopener noreferrer"
|
|
46
|
+
className="inline-flex h-8 flex-wrap items-center gap-1 font-semibold focus-visible:ring-3 focus-visible:ring-ring/50"
|
|
47
|
+
>
|
|
48
|
+
Settings
|
|
49
|
+
<IconChevronRight size={16} stroke={2} aria-hidden="true" />
|
|
50
|
+
Security and login
|
|
51
|
+
</a>
|
|
52
|
+
</div>
|
|
53
|
+
</li>
|
|
54
|
+
<li className="flex flex-col items-start gap-3 lg:items-center">
|
|
55
|
+
<IconCircleNumber2 size={24} stroke={1.5} className="shrink-0" />
|
|
56
|
+
<div className="flex min-w-0 flex-col items-start gap-3 lg:items-center">
|
|
57
|
+
<p>Copy the one-time device code provided below</p>
|
|
58
|
+
<div className="flex h-8 items-center gap-2 rounded-lg border border-input bg-accent pr-2 pl-3">
|
|
59
|
+
<code className="cursor-text text-sm font-medium select-text">{code}</code>
|
|
60
|
+
<button
|
|
61
|
+
type="button"
|
|
62
|
+
className="relative size-4 cursor-pointer text-muted-foreground outline-none hover:text-foreground focus-visible:text-foreground"
|
|
63
|
+
aria-label={copied ? 'Code copied' : 'Copy code'}
|
|
64
|
+
onClick={copyCode}
|
|
65
|
+
>
|
|
66
|
+
<IconCopy
|
|
67
|
+
className={cn(
|
|
68
|
+
'absolute inset-0 transition-[opacity,filter] duration-200 motion-reduce:transition-none',
|
|
69
|
+
copied && 'opacity-0 blur-[2px]'
|
|
70
|
+
)}
|
|
71
|
+
stroke={1.75}
|
|
72
|
+
size={16}
|
|
73
|
+
/>
|
|
74
|
+
<IconCheck
|
|
75
|
+
className={cn(
|
|
76
|
+
'absolute inset-0 transition-[opacity,filter] duration-200 motion-reduce:transition-none',
|
|
77
|
+
!copied && 'opacity-0 blur-[2px]'
|
|
78
|
+
)}
|
|
79
|
+
stroke={1.75}
|
|
80
|
+
size={16}
|
|
81
|
+
/>
|
|
82
|
+
</button>
|
|
83
|
+
</div>
|
|
84
|
+
</div>
|
|
85
|
+
</li>
|
|
86
|
+
<li className="flex flex-col items-start gap-3 lg:items-center">
|
|
87
|
+
<IconCircleNumber3 size={24} stroke={1.5} className="shrink-0" />
|
|
88
|
+
<div className="flex min-w-0 flex-col items-start gap-3 lg:items-center">
|
|
89
|
+
<p>Sign-in in browser, paste the code, and then come back to Moi</p>
|
|
90
|
+
<a href={url} target="_blank" rel="noopener noreferrer" className={buttonVariants()}>
|
|
91
|
+
Open browser
|
|
92
|
+
</a>
|
|
93
|
+
</div>
|
|
94
|
+
</li>
|
|
95
|
+
</ol>
|
|
96
|
+
)
|
|
97
|
+
}
|