moi-computer 0.3.0-next.1 → 0.3.0-next.3
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 +1 -1
- package/bunfig.toml +5 -1
- package/client/AGENTS.md +17 -2
- package/client/accept-hmr-dependencies.ts +22 -0
- package/client/api/http.ts +31 -0
- package/client/api/query-options.ts +6 -0
- package/client/api/workspace-keys.ts +18 -0
- package/client/app/AppRouter.tsx +44 -0
- package/client/app/routes/HomeRoute.tsx +13 -0
- package/client/app/routes/WorkspaceRoute.tsx +95 -0
- package/client/app/shell/SidebarLayout.tsx +196 -0
- package/client/assets/openai.svg +3 -0
- package/client/assets.d.ts +9 -0
- package/client/components/{BottomPanel.tsx → shared/BottomPanel.tsx} +2 -2
- package/client/components/shared/PanelHeader.tsx +9 -0
- package/client/components/shared/ReorderableList.tsx +199 -0
- package/client/components/ui/button.tsx +11 -7
- package/client/components/ui/collapsible.tsx +15 -0
- package/client/components/ui/dialog.tsx +2 -2
- package/client/components/ui/dropdown-menu.tsx +5 -5
- package/client/components/ui/hover-card.tsx +1 -1
- package/client/components/ui/input.tsx +1 -1
- package/client/components/ui/popover.tsx +1 -1
- package/client/components/ui/skeleton.tsx +13 -0
- package/client/components/ui/tooltip.tsx +1 -1
- package/client/externalize-react.ts +7 -1
- package/client/features/applets/AppletMount.tsx +44 -0
- package/client/{components → features/applets}/WidgetErrorBoundary.tsx +1 -1
- package/client/{components → features/applets}/WidgetShell.tsx +5 -2
- package/client/{lib → features/applets}/applet-cache.ts +8 -0
- package/client/features/applets/applet-styles.ts +61 -0
- package/client/{hooks → features/applets}/useApplet.ts +6 -7
- package/client/{components/ChatInput.tsx → features/chat/ChatComposer.tsx} +30 -24
- package/client/features/chat/ChatPanel.tsx +171 -0
- package/client/{components → features/chat}/ChatPopup.tsx +24 -13
- package/client/{components/ThreadSelector.tsx → features/chat/ChatSelector.tsx} +15 -13
- package/client/{components → features/chat}/MarkdownContent.tsx +1 -1
- package/client/{components → features/chat}/ModelPicker.tsx +68 -17
- package/client/{components → features/chat}/TurnView.tsx +17 -11
- package/client/features/chat/api.ts +78 -0
- package/client/features/chat/chat-connection.ts +107 -0
- package/client/features/chat/chat-frames.ts +131 -0
- package/client/features/chat/chat-send.ts +57 -0
- package/client/{lib → features/chat}/preview-turn.ts +1 -1
- package/client/{components → features/chat}/tool-group/ReadImagePreview.tsx +1 -1
- package/client/{components → features/chat}/tool-group/SubagentCard.tsx +12 -10
- package/client/{components → features/chat}/tool-group/TimelineRow.tsx +5 -5
- package/client/{components → features/chat}/tool-group/ToolCallGroup.tsx +14 -5
- package/client/{components → features/chat}/tool-group/ToolOutput.tsx +12 -18
- package/client/{components → features/chat}/tool-group/format.ts +117 -0
- package/client/{hooks → features/chat}/useChat.ts +16 -44
- package/client/features/connectors/ConnectorsPage.tsx +92 -0
- package/client/features/connectors/McpMenu.tsx +145 -0
- package/client/features/connectors/api.ts +28 -0
- package/client/features/dev/DevRoutes.tsx +18 -0
- package/client/features/dev/HarnessDebugPage.tsx +468 -0
- package/client/{components/playground → features/dev}/PixelPainter.tsx +10 -21
- package/client/{components/playground → features/dev}/PlaygroundPage.tsx +10 -12
- package/client/{components/playground → features/dev}/ToolCallsPage.tsx +9 -11
- package/client/features/home/CreateWorkspaceDialog.tsx +130 -0
- package/client/features/home/CreateWorkspaceDialogSteps.tsx +234 -0
- package/client/features/home/HomeLogo.tsx +344 -0
- package/client/features/home/HomePage.tsx +214 -0
- package/client/{components → features/home}/WorkspacePreview.tsx +4 -4
- package/client/features/home/api.ts +156 -0
- package/client/features/home/workspace-presentation.tsx +44 -0
- package/client/features/scratchpad/Scratchpad.tsx +312 -0
- package/client/features/scratchpad/ScratchpadControls.tsx +503 -0
- package/client/features/scratchpad/useScratchpadSnapshot.tsx +115 -0
- package/client/features/settings/EnvironmentSettings.tsx +149 -0
- package/client/features/settings/GeneralSettings.tsx +90 -0
- package/client/{components → features}/settings/IconPicker.tsx +76 -224
- package/client/features/settings/SettingsLayout.tsx +53 -0
- package/client/{components → features}/settings/WorkspaceSettings.tsx +12 -16
- package/client/features/settings/api.ts +88 -0
- package/client/features/settings/icon-picker-options.ts +30 -0
- package/client/{hooks → features/settings}/useEnvVars.ts +4 -4
- package/client/features/views/ViewBuilderTab.tsx +153 -0
- package/client/features/views/api.ts +124 -0
- package/client/features/views/useViewBuilderActions.ts +72 -0
- package/client/{components → features/widgets}/HiddenPanel.tsx +3 -3
- package/client/{components → features/widgets}/WidgetFrame.tsx +3 -8
- package/client/{components → features/widgets}/WidgetGrid.tsx +38 -29
- package/client/features/widgets/Widgets.tsx +265 -0
- package/client/{lib/grid-pack.ts → features/widgets/grid.ts} +7 -1
- package/client/{hooks → features/widgets}/useGridReconcile.ts +1 -1
- package/client/{components → features/workspace}/CustomizePanel.tsx +5 -6
- package/client/{lib → features/workspace}/WorkspaceLayoutContext.tsx +16 -15
- package/client/features/workspace/WorkspaceScreen.tsx +675 -0
- package/client/features/workspace/WorkspaceTabs.tsx +205 -0
- package/client/features/workspace/api.ts +56 -0
- package/client/features/workspace/useFitsSplitLayout.ts +37 -0
- package/client/global.d.ts +5 -0
- package/client/index.css +6 -45
- package/client/index.html +2 -2
- package/client/index.tsx +14 -31
- package/client/lib/app-icon-registry.ts +145 -0
- package/client/main.tsx +2 -2
- package/client/runtime/hmr-watchdog.ts +39 -0
- package/client/{hooks/useMeiEvents.ts → runtime/useWorkspaceEvents.ts} +12 -7
- package/client/store/ui.ts +5 -1
- package/client/theme.css +1 -3
- package/dist/chunk-11cab5dq.css +1 -0
- package/dist/chunk-4vf1t6v1.js +10 -0
- package/dist/chunk-6c24yndg.js +61 -0
- package/dist/chunk-6c8cwpzc.js +1 -0
- package/dist/chunk-b4b276wx.js +15 -0
- package/dist/chunk-cs8vbert.js +546 -0
- package/dist/chunk-cwqmay73.css +1 -0
- package/dist/chunk-kxmvv1ax.js +48 -0
- package/dist/chunk-pcnahct1.js +5 -0
- package/dist/chunk-rq0ar7vp.js +1 -0
- package/dist/chunk-tqd3pkg8.css +1 -0
- package/dist/chunk-vkvb3hjm.js +2 -0
- package/dist/chunk-zpxrb1ce.js +2 -0
- package/dist/index.html +3 -3
- package/dist/openai-h13pza4b.svg +3 -0
- package/lib/format.ts +2 -2
- package/lib/types.ts +56 -9
- package/lib/view-builder-meta.ts +35 -0
- package/lib/workspace-layout.ts +14 -0
- package/lib/workspace-name.ts +14 -0
- package/package.json +4 -2
- package/server/AGENTS.md +3 -3
- package/server/api.ts +279 -60
- package/server/applets.ts +1 -1
- package/server/bundle-queue.ts +19 -0
- package/server/bundler/applet-css.ts +50 -0
- package/server/{build-applet.ts → bundler/build-applet.ts} +36 -26
- package/server/cli.ts +90 -7
- package/server/control.ts +106 -8
- package/server/env-apply.ts +2 -2
- package/server/harness/README.md +228 -0
- package/server/harness/claude-code/NOTES.md +578 -0
- package/{lib/claude-adapter.ts → server/harness/claude-code/adapter.ts} +67 -5
- package/server/harness/claude-code/index.ts +124 -0
- package/server/{mcp.ts → harness/claude-code/mcp.ts} +73 -16
- package/server/{cc-session.ts → harness/claude-code/session.ts} +42 -14
- package/server/harness/claude-code/sessions.ts +42 -0
- package/server/harness/codex/NOTES.md +239 -0
- package/server/harness/codex/adapter.ts +414 -0
- package/server/harness/codex/client.ts +343 -0
- package/server/harness/codex/index.ts +68 -0
- package/server/harness/codex/probe.ts +186 -0
- package/server/harness/codex/session.ts +617 -0
- package/server/harness/debug.ts +57 -0
- package/server/harness/openclaw/NOTES.md +316 -0
- package/server/{openclaw-adapter.ts → harness/openclaw/adapter.ts} +2 -2
- package/server/harness/openclaw/index.ts +93 -0
- package/server/{openclaw-session.ts → harness/openclaw/session.ts} +44 -9
- package/server/{openclaw-strip.ts → harness/openclaw/strip.ts} +3 -1
- package/server/harness/registry.ts +36 -0
- package/server/harness/types.ts +87 -0
- package/server/layout.ts +36 -11
- package/server/moi-scaffold.ts +56 -11
- package/server/registry.ts +30 -52
- package/server/state.ts +5 -38
- package/server/status.ts +7 -46
- package/server/vendor.ts +1 -1
- package/server/view-builders.ts +428 -0
- package/server/views.ts +0 -0
- package/server/web.ts +19 -40
- package/server/workspace-init.ts +11 -25
- package/tsconfig.json +1 -1
- package/workspace/.claude/skills/moi-workspace/DESIGN.md +2 -1
- package/workspace/.claude/skills/moi-workspace/SKILL.md +28 -7
- package/workspace/.claude/skills/moi-workspace/VIEW-DESIGN.md +1 -1
- package/client/api/workspaces.ts +0 -427
- package/client/assets/hermes-nous.png +0 -0
- package/client/components/App.tsx +0 -41
- package/client/components/ChatPanel.tsx +0 -275
- package/client/components/HomePage.tsx +0 -17
- package/client/components/McpMenu.tsx +0 -125
- package/client/components/Scratchpad.tsx +0 -935
- package/client/components/Widgets.tsx +0 -132
- package/client/components/WorkspacesPage.tsx +0 -245
- package/client/components/layout/SidebarLayout.tsx +0 -258
- package/client/components/routes/workspace/[id].tsx +0 -675
- package/client/components/routes/workspace/create.tsx +0 -155
- package/client/components/settings/SettingsPages.tsx +0 -255
- package/client/hooks/useFitsSidebar.ts +0 -34
- package/client/hooks/useScrollFade.ts +0 -38
- package/client/lib/connection.ts +0 -238
- package/dist/chunk-07qf2tv1.css +0 -1
- package/dist/chunk-w18801vn.js +0 -672
- package/dist/hermes-nous-pznd63x9.png +0 -0
- /package/client/components/{playground → shared}/LedLogo.tsx +0 -0
- /package/client/{components → features/chat}/ShimmerText.tsx +0 -0
- /package/client/{store/live.ts → features/chat/chat-store.ts} +0 -0
- /package/client/{lib → features/chat}/group-turns.ts +0 -0
- /package/client/{components → features/chat}/tool-group/CodeBlock.tsx +0 -0
- /package/client/{components → features/chat}/tool-group/Collapse.tsx +0 -0
- /package/client/{components → features/chat}/tool-group/detect.ts +0 -0
- /package/client/{components → features/chat}/tool-group/fixtures.ts +0 -0
- /package/client/{components → features/chat}/tool-group/index.ts +0 -0
- /package/client/{lib → features/chat}/uploads.ts +0 -0
- /package/client/{hooks → features/chat}/useStickToBottom.ts +0 -0
- /package/client/{components → features/connectors}/IconMcp.tsx +0 -0
- /package/client/{lib → features/connectors}/mcp-icons.ts +0 -0
- /package/client/{lib → features/scratchpad}/scratch-executor.ts +0 -0
- /package/client/{lib → features/settings}/render-icon.ts +0 -0
- /package/client/{lib → features/workspace}/WorkspaceContext.tsx +0 -0
- /package/client/{hooks → features/workspace}/useWorkspaceTheme.ts +0 -0
- /package/server/{agent.ts → harness/claude-code/models.ts} +0 -0
- /package/server/{openclaw.ts → harness/openclaw/discovery.ts} +0 -0
- /package/server/{openclaw-gateway.ts → harness/openclaw/gateway.ts} +0 -0
package/README.md
CHANGED
|
@@ -31,7 +31,7 @@ bun run dev
|
|
|
31
31
|
|
|
32
32
|
moi also works with OpenClaw agents — `moi openclaw init` installs the moi
|
|
33
33
|
skills into an OpenClaw agent workspace. Integration notes live in
|
|
34
|
-
[
|
|
34
|
+
[server/harness/openclaw/NOTES.md](server/harness/openclaw/NOTES.md).
|
|
35
35
|
|
|
36
36
|
## No crypto token
|
|
37
37
|
|
package/bunfig.toml
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
|
|
2
2
|
[serve.static]
|
|
3
|
-
plugins = [
|
|
3
|
+
plugins = [
|
|
4
|
+
"bun-plugin-tailwind",
|
|
5
|
+
"./client/externalize-react.ts",
|
|
6
|
+
"./client/accept-hmr-dependencies.ts"
|
|
7
|
+
]
|
|
4
8
|
# Inline only PUBLIC_*-prefixed env vars into the client bundle (e.g. the tldraw
|
|
5
9
|
# license key, PUBLIC_TLDRAW_LICENSE_KEY). The prefix keeps private secrets out
|
|
6
10
|
# of the browser bundle. Mirrored for prod builds in scripts/build-client.ts.
|
package/client/AGENTS.md
CHANGED
|
@@ -1,12 +1,27 @@
|
|
|
1
1
|
React SPA connecting to the server via WebSocket (`useChat` hook).
|
|
2
2
|
|
|
3
|
+
Before editing host-app UI, read `../DESIGN.md` and the relevant rules in `../.agents/rules/`. `../DESIGN.md` owns visual direction and semantic choices; topic rules own syntax, component source owns APIs and dimensions, and the theme CSS owns token values. Generic design and shadcn skills may help with craft and component mechanics, but project guidance wins on aesthetics, installed-component policy, and approval requirements.
|
|
4
|
+
|
|
5
|
+
`../DESIGN.md` applies to host chrome and product surfaces. It does not apply to workspace widget/view internals or generated applets; use their workspace-local design guidance.
|
|
6
|
+
|
|
3
7
|
## Entities
|
|
4
8
|
|
|
5
|
-
- **
|
|
6
|
-
- **Widget** — A configurable card inside the
|
|
9
|
+
- **Workspace** — Top-level container. Has a name and contains widgets and a chat. One workspace is active at a time.
|
|
10
|
+
- **Widget** — A configurable card inside the workspace's main area. Displayed in a grid. When there are no widgets, the chat fills the whole panel.
|
|
7
11
|
- **Chat** — The agent conversation. Contains a scrollable message list and an input. Always lives in the panel. Two modes: sidebar (a bounded pane beside the widgets, or the full panel when there are no widgets) and floating (popover). Floating only applies when there are widgets and they need the room.
|
|
8
12
|
|
|
9
13
|
## Conventions
|
|
10
14
|
|
|
11
15
|
- UI components in `components/ui/` are shadcn built on Base UI React.
|
|
12
16
|
- `lib/cn.ts` is `clsx` + `tailwind-merge`.
|
|
17
|
+
|
|
18
|
+
## Frontend boundaries
|
|
19
|
+
|
|
20
|
+
- `app/` owns routes and the app shell. Route files load data and compose features; keep feature UI out of them.
|
|
21
|
+
- `features/<name>/` owns that feature's components, hooks, state, API hooks, and nearby tests.
|
|
22
|
+
- `components/ui/` contains installed shadcn primitives. `components/shared/` contains reusable app components with no feature knowledge.
|
|
23
|
+
- `api/` contains shared request helpers, query keys, and query policies. Feature endpoints stay in the feature's `api.ts`.
|
|
24
|
+
- `runtime/` contains browser-wide lifecycle code such as HMR and shared workspace events.
|
|
25
|
+
- `lib/` contains small feature-neutral utilities. Do not use it as a catch-all for components or feature state.
|
|
26
|
+
- App code may compose features. Shared components and primitives must not import from `features/` or `app/`.
|
|
27
|
+
- Keep tests next to the code they cover. Extract a component, hook, or pure helper when a file starts mixing multiple responsibilities.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { BunPlugin } from 'bun'
|
|
2
|
+
|
|
3
|
+
// Bun's Tailwind rebuild can re-emit these package entrypoints even when their
|
|
4
|
+
// source did not change. Without an HMR boundary the update reaches main.tsx,
|
|
5
|
+
// where TanStack's re-export graph may be observed halfway through replacement.
|
|
6
|
+
// Self-accepting the stable entrypoints keeps the existing QueryClient alive and
|
|
7
|
+
// lets the actual React component update stop at its Fast Refresh boundary.
|
|
8
|
+
const stableDependencyEntry =
|
|
9
|
+
/[\\/]node_modules[\\/]@tanstack[\\/](?:react-query|query-core)[\\/]build[\\/]modern[\\/]index\.js$/
|
|
10
|
+
|
|
11
|
+
const acceptHmrDependencies: BunPlugin = {
|
|
12
|
+
name: 'accept-hmr-dependencies',
|
|
13
|
+
setup(build) {
|
|
14
|
+
build.onLoad({ filter: stableDependencyEntry }, async args => ({
|
|
15
|
+
contents:
|
|
16
|
+
(await Bun.file(args.path).text()) + '\nif (import.meta.hot) import.meta.hot.accept();\n',
|
|
17
|
+
loader: 'js'
|
|
18
|
+
}))
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export default acceptHmrDependencies
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
async function errorFrom(response: Response, fallback: string) {
|
|
2
|
+
const detail = await response.text()
|
|
3
|
+
return new Error(detail || fallback)
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export async function requestJson<T>(
|
|
7
|
+
input: RequestInfo | URL,
|
|
8
|
+
init?: RequestInit,
|
|
9
|
+
error = 'Request failed'
|
|
10
|
+
) {
|
|
11
|
+
const response = await fetch(input, init)
|
|
12
|
+
if (!response.ok) throw await errorFrom(response, error)
|
|
13
|
+
return response.json() as Promise<T>
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export async function requestVoid(
|
|
17
|
+
input: RequestInfo | URL,
|
|
18
|
+
init?: RequestInit,
|
|
19
|
+
error = 'Request failed'
|
|
20
|
+
) {
|
|
21
|
+
const response = await fetch(input, init)
|
|
22
|
+
if (!response.ok) throw await errorFrom(response, error)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function jsonRequest(method: 'POST' | 'PUT' | 'PATCH', body?: unknown): RequestInit {
|
|
26
|
+
return {
|
|
27
|
+
method,
|
|
28
|
+
headers: { 'Content-Type': 'application/json' },
|
|
29
|
+
body: body === undefined ? undefined : JSON.stringify(body)
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export const workspaceKeys = {
|
|
2
|
+
all: ['workspaces'] as const,
|
|
3
|
+
discover: ['workspaces', 'discover'] as const,
|
|
4
|
+
createInfo: ['workspaces', 'create-info'] as const,
|
|
5
|
+
preview: (id: string) => ['workspaces', 'preview', id] as const,
|
|
6
|
+
layout: (id: string) => ['workspaces', 'layout', id] as const,
|
|
7
|
+
widgets: (id: string) => ['workspaces', 'widgets', id] as const,
|
|
8
|
+
views: (id: string) => ['workspaces', 'views', id] as const,
|
|
9
|
+
viewBuilders: (id: string) => ['workspaces', 'view-builders', id] as const,
|
|
10
|
+
sessions: (id: string) => ['workspaces', 'sessions', id] as const,
|
|
11
|
+
events: (id: string, sessionId: string) => ['workspaces', 'events', id, sessionId] as const,
|
|
12
|
+
threadConfig: (id: string, sessionId: string) =>
|
|
13
|
+
['workspaces', 'threadConfig', id, sessionId] as const,
|
|
14
|
+
userMcp: ['mcp', 'user'] as const,
|
|
15
|
+
mcp: (id: string) => ['workspaces', 'mcp', id] as const,
|
|
16
|
+
models: (id: string) => ['workspaces', 'models', id] as const,
|
|
17
|
+
env: (id: string) => ['workspaces', 'env', id] as const
|
|
18
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Suspense, lazy, useEffect } from 'react'
|
|
2
|
+
|
|
3
|
+
import { Route, Switch, useLocation } from 'wouter'
|
|
4
|
+
|
|
5
|
+
import { setWorkspaceSwitchHandler } from '@/client/features/chat/chat-connection'
|
|
6
|
+
import { ConnectorsPage } from '@/client/features/connectors/ConnectorsPage'
|
|
7
|
+
|
|
8
|
+
import { HomeRoute } from './routes/HomeRoute'
|
|
9
|
+
import { WorkspaceRoute } from './routes/WorkspaceRoute'
|
|
10
|
+
|
|
11
|
+
// Dev-only playground routes: colocated in features/dev and loaded as a
|
|
12
|
+
// separate lazy chunk so none of it ships in the main bundle's hot path.
|
|
13
|
+
const DevRoutes = lazy(() => import('@/client/features/dev/DevRoutes'))
|
|
14
|
+
|
|
15
|
+
function DevLazy() {
|
|
16
|
+
return (
|
|
17
|
+
<Suspense fallback={null}>
|
|
18
|
+
<DevRoutes />
|
|
19
|
+
</Suspense>
|
|
20
|
+
)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// Top-level router — sets up all client-side routes
|
|
24
|
+
export function AppRouter() {
|
|
25
|
+
const [, navigate] = useLocation()
|
|
26
|
+
|
|
27
|
+
// When the server broadcasts a workspace:switch (e.g. from `moi start`),
|
|
28
|
+
// navigate to that workspace
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
setWorkspaceSwitchHandler(id => navigate(`/workspace/${id}`))
|
|
31
|
+
return () => setWorkspaceSwitchHandler(null)
|
|
32
|
+
}, [navigate])
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<Switch>
|
|
36
|
+
<Route path="/" component={HomeRoute} />
|
|
37
|
+
<Route path="/connectors" component={ConnectorsPage} />
|
|
38
|
+
<Route path="/dev/*?" component={DevLazy} />
|
|
39
|
+
<Route path="/workspace/:id">
|
|
40
|
+
{(params: { id: string }) => <WorkspaceRoute key={params.id} id={params.id} />}
|
|
41
|
+
</Route>
|
|
42
|
+
</Switch>
|
|
43
|
+
)
|
|
44
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { SidebarLayout } from '@/client/app/shell/SidebarLayout'
|
|
2
|
+
import { HomePage } from '@/client/features/home/HomePage'
|
|
3
|
+
|
|
4
|
+
// The `/` route: the app shell wrapping the workspaces view.
|
|
5
|
+
export function HomeRoute() {
|
|
6
|
+
return (
|
|
7
|
+
<SidebarLayout panel="flat" showWorkspaces={false}>
|
|
8
|
+
<div className="min-h-0 flex-1 overflow-y-auto">
|
|
9
|
+
<HomePage />
|
|
10
|
+
</div>
|
|
11
|
+
</SidebarLayout>
|
|
12
|
+
)
|
|
13
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { useEffect } from 'react'
|
|
2
|
+
|
|
3
|
+
import { useQueryClient } from '@tanstack/react-query'
|
|
4
|
+
|
|
5
|
+
import { workspaceKeys } from '@/client/api/workspace-keys'
|
|
6
|
+
import { LedLogo } from '@/client/components/shared/LedLogo'
|
|
7
|
+
import { SidebarLayout } from '@/client/app/shell/SidebarLayout'
|
|
8
|
+
import { liveStore } from '@/client/features/chat/chat-store'
|
|
9
|
+
import { useWorkspaceSessions } from '@/client/features/chat/api'
|
|
10
|
+
import { useAppletCacheInvalidation } from '@/client/features/applets/useApplet'
|
|
11
|
+
import { Workspace } from '@/client/features/workspace/WorkspaceContext'
|
|
12
|
+
import {
|
|
13
|
+
WorkspaceLayoutProvider,
|
|
14
|
+
useWorkspaceLayoutCtx
|
|
15
|
+
} from '@/client/features/workspace/WorkspaceLayoutContext'
|
|
16
|
+
import { WorkspaceScreen } from '@/client/features/workspace/WorkspaceScreen'
|
|
17
|
+
import { useWorkspaceViews, useWorkspaceWidgets } from '@/client/features/workspace/api'
|
|
18
|
+
import { useViewBuilders } from '@/client/features/views/api'
|
|
19
|
+
import { useGridReconcile } from '@/client/features/widgets/useGridReconcile'
|
|
20
|
+
import { useWorkspaceEvent } from '@/client/runtime/useWorkspaceEvents'
|
|
21
|
+
import type { SessionInfo } from '@/lib/types'
|
|
22
|
+
|
|
23
|
+
type WorkspaceRouteProps = {
|
|
24
|
+
id: string
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function WorkspaceRoute({ id }: WorkspaceRouteProps) {
|
|
28
|
+
return (
|
|
29
|
+
<Workspace id={id}>
|
|
30
|
+
<WorkspaceLayoutProvider id={id}>
|
|
31
|
+
<WorkspaceLoader id={id} />
|
|
32
|
+
</WorkspaceLayoutProvider>
|
|
33
|
+
</Workspace>
|
|
34
|
+
)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function WorkspaceLoader({ id }: WorkspaceRouteProps) {
|
|
38
|
+
const queryClient = useQueryClient()
|
|
39
|
+
const { layout, setLayout, isLoading: layoutLoading } = useWorkspaceLayoutCtx()
|
|
40
|
+
const widgets = useWorkspaceWidgets(id)
|
|
41
|
+
const views = useWorkspaceViews(id)
|
|
42
|
+
const builders = useViewBuilders(id)
|
|
43
|
+
const sessions = useWorkspaceSessions(id)
|
|
44
|
+
|
|
45
|
+
useGridReconcile(id, widgets.data, layout, setLayout)
|
|
46
|
+
useAppletCacheInvalidation()
|
|
47
|
+
|
|
48
|
+
useWorkspaceEvent(event => {
|
|
49
|
+
if (event.type === 'theme:updated' || event.type === 'workspace:updated') {
|
|
50
|
+
queryClient.invalidateQueries({ queryKey: workspaceKeys.layout(id) })
|
|
51
|
+
} else if (event.type === 'widget-layout:updated') {
|
|
52
|
+
queryClient.invalidateQueries({ queryKey: workspaceKeys.widgets(id) })
|
|
53
|
+
} else if (event.type === 'view-layout:updated') {
|
|
54
|
+
queryClient.invalidateQueries({ queryKey: workspaceKeys.views(id) })
|
|
55
|
+
}
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
const fresh = layoutLoading || widgets.isLoading || views.isLoading || builders.isLoading
|
|
59
|
+
|
|
60
|
+
return (
|
|
61
|
+
<>
|
|
62
|
+
<SeedActiveSession workspaceId={id} sessions={sessions.data} />
|
|
63
|
+
<SidebarLayout>
|
|
64
|
+
{fresh ? (
|
|
65
|
+
<div className="flex h-full items-center justify-center">
|
|
66
|
+
<LedLogo sprite="moi" effect="chaos" />
|
|
67
|
+
</div>
|
|
68
|
+
) : (
|
|
69
|
+
<WorkspaceScreen
|
|
70
|
+
widgets={widgets.data ?? []}
|
|
71
|
+
views={views.data ?? []}
|
|
72
|
+
builders={builders.data ?? []}
|
|
73
|
+
/>
|
|
74
|
+
)}
|
|
75
|
+
</SidebarLayout>
|
|
76
|
+
</>
|
|
77
|
+
)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
type SeedActiveSessionProps = {
|
|
81
|
+
workspaceId: string
|
|
82
|
+
sessions: SessionInfo[] | undefined
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function SeedActiveSession({ workspaceId, sessions }: SeedActiveSessionProps) {
|
|
86
|
+
useEffect(() => {
|
|
87
|
+
if (!sessions) return
|
|
88
|
+
const active = liveStore.getState().activeByWorkspace[workspaceId] ?? null
|
|
89
|
+
const stillValid = active && sessions.some(session => session.sessionId === active)
|
|
90
|
+
if (!stillValid) {
|
|
91
|
+
liveStore.getState().setActive(workspaceId, sessions[0]?.sessionId ?? null)
|
|
92
|
+
}
|
|
93
|
+
}, [workspaceId, sessions])
|
|
94
|
+
return null
|
|
95
|
+
}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { type ReactNode } from 'react'
|
|
2
|
+
|
|
3
|
+
import { IconPlugConnected, IconPlus, IconSmartHome } from '@tabler/icons-react'
|
|
4
|
+
import { useQueryClient } from '@tanstack/react-query'
|
|
5
|
+
import { Link, useLocation } from 'wouter'
|
|
6
|
+
|
|
7
|
+
import { useReorderWorkspaces, useWorkspaces } from '@/client/features/home/api'
|
|
8
|
+
import { workspaceKeys } from '@/client/api/workspace-keys'
|
|
9
|
+
import { useWorkspaceEvent } from '@/client/runtime/useWorkspaceEvents'
|
|
10
|
+
import { CreateWorkspaceDialog } from '@/client/features/home/CreateWorkspaceDialog'
|
|
11
|
+
import { ReorderableList } from '@/client/components/shared/ReorderableList'
|
|
12
|
+
import type { ReorderableRenderState } from '@/client/components/shared/ReorderableList'
|
|
13
|
+
import { Button, buttonVariants } from '@/client/components/ui/button'
|
|
14
|
+
import {
|
|
15
|
+
workspaceDisplayName,
|
|
16
|
+
workspaceProviderIcon
|
|
17
|
+
} from '@/client/features/home/workspace-presentation'
|
|
18
|
+
import { cn } from '@/client/lib/cn'
|
|
19
|
+
import type { WorkspaceEntry } from '@/lib/types'
|
|
20
|
+
|
|
21
|
+
function sidebarNavButtonClass(active: boolean): string {
|
|
22
|
+
return cn(
|
|
23
|
+
buttonVariants({ variant: 'ghost', size: 'icon' }),
|
|
24
|
+
active && 'bg-accent text-accent-foreground'
|
|
25
|
+
)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
type SidebarLayoutProps = {
|
|
29
|
+
// Full panel content — the page supplies its own header (compose it with
|
|
30
|
+
// <PanelHeader>) and body.
|
|
31
|
+
children?: ReactNode
|
|
32
|
+
panel?: 'default' | 'flat'
|
|
33
|
+
showWorkspaces?: boolean
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// App shell: a slim icon rail beside the page content. The page owns the panel's
|
|
37
|
+
// header and body.
|
|
38
|
+
export function SidebarLayout({
|
|
39
|
+
children,
|
|
40
|
+
panel = 'default',
|
|
41
|
+
showWorkspaces = true
|
|
42
|
+
}: SidebarLayoutProps) {
|
|
43
|
+
const { data: workspaces } = useWorkspaces()
|
|
44
|
+
|
|
45
|
+
// `moi config` / the settings modal broadcast `workspace:updated` (identity
|
|
46
|
+
// changes) and reorder/create broadcast `workspaces-list:updated`; refetch the
|
|
47
|
+
// list so the sidebar reflects it live. Exact: `workspaceKeys.all` is the
|
|
48
|
+
// prefix of every workspace query — a prefix invalidation would refetch
|
|
49
|
+
// transcripts, widgets, and MCP probes in every connected client.
|
|
50
|
+
const qc = useQueryClient()
|
|
51
|
+
useWorkspaceEvent(e => {
|
|
52
|
+
if (e.type === 'workspace:updated' || e.type === 'workspaces-list:updated') {
|
|
53
|
+
qc.invalidateQueries({ queryKey: workspaceKeys.all, exact: true })
|
|
54
|
+
}
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<div className="flex h-dvh bg-muted">
|
|
59
|
+
<Sidebar workspaces={showWorkspaces ? (workspaces ?? []) : []} />
|
|
60
|
+
<main
|
|
61
|
+
className={cn(
|
|
62
|
+
'flex min-w-0 flex-1 flex-col overflow-hidden',
|
|
63
|
+
panel === 'default' &&
|
|
64
|
+
'rounded-l-md border-l border-border bg-background shadow-[1px_0_3px_0_var(--border)]'
|
|
65
|
+
)}
|
|
66
|
+
>
|
|
67
|
+
{children}
|
|
68
|
+
</main>
|
|
69
|
+
</div>
|
|
70
|
+
)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
type SidebarProps = {
|
|
74
|
+
workspaces: WorkspaceEntry[]
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function Sidebar({ workspaces }: SidebarProps) {
|
|
78
|
+
const reorder = useReorderWorkspaces()
|
|
79
|
+
|
|
80
|
+
return (
|
|
81
|
+
<aside className="flex h-full shrink-0 flex-col items-center gap-4 px-2 py-5">
|
|
82
|
+
<Link href="/" aria-label="Home" title="Home" className={sidebarNavButtonClass}>
|
|
83
|
+
<IconSmartHome stroke={1.5} />
|
|
84
|
+
</Link>
|
|
85
|
+
|
|
86
|
+
<nav className="flex max-h-full min-h-0 w-14 flex-1 flex-col items-center justify-center gap-4">
|
|
87
|
+
{workspaces.length > 0 && (
|
|
88
|
+
<>
|
|
89
|
+
<div className="no-scrollbar min-h-0 scroll-fade overflow-y-auto [--scroll-fade-reveal:16px]">
|
|
90
|
+
<ReorderableList
|
|
91
|
+
items={workspaces}
|
|
92
|
+
getId={ws => ws.id}
|
|
93
|
+
className="flex flex-col gap-4"
|
|
94
|
+
onReorder={ids => reorder.mutate(ids)}
|
|
95
|
+
renderPlaceholder={() => (
|
|
96
|
+
<div className="pointer-events-none absolute top-0 left-1 size-10 rounded-lg bg-accent" />
|
|
97
|
+
)}
|
|
98
|
+
renderOverlay={ws => <WorkspaceButton workspace={ws} dragOverlay />}
|
|
99
|
+
renderItem={(ws, state) => <WorkspaceButton workspace={ws} dragState={state} />}
|
|
100
|
+
/>
|
|
101
|
+
</div>
|
|
102
|
+
<div className="shrink-0">
|
|
103
|
+
<CreateWorkspaceDialog
|
|
104
|
+
trigger={
|
|
105
|
+
<Button
|
|
106
|
+
type="button"
|
|
107
|
+
variant="ghost"
|
|
108
|
+
size="icon-lg"
|
|
109
|
+
aria-label="Create new workspace"
|
|
110
|
+
title="Create new workspace"
|
|
111
|
+
className="text-muted-foreground hover:text-foreground"
|
|
112
|
+
>
|
|
113
|
+
<IconPlus data-icon="inline-start" stroke={1.5} />
|
|
114
|
+
</Button>
|
|
115
|
+
}
|
|
116
|
+
/>
|
|
117
|
+
</div>
|
|
118
|
+
</>
|
|
119
|
+
)}
|
|
120
|
+
</nav>
|
|
121
|
+
|
|
122
|
+
<ConnectorsNavLink />
|
|
123
|
+
</aside>
|
|
124
|
+
)
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function ConnectorsNavLink() {
|
|
128
|
+
return (
|
|
129
|
+
<Link
|
|
130
|
+
href="/connectors"
|
|
131
|
+
aria-label="Connectors"
|
|
132
|
+
title="Connectors"
|
|
133
|
+
className={sidebarNavButtonClass}
|
|
134
|
+
>
|
|
135
|
+
<IconPlugConnected stroke={1.5} />
|
|
136
|
+
</Link>
|
|
137
|
+
)
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
type WorkspaceButtonProps = {
|
|
141
|
+
workspace: WorkspaceEntry
|
|
142
|
+
dragOverlay?: boolean
|
|
143
|
+
dragState?: ReorderableRenderState
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function WorkspaceButton({ workspace, dragOverlay = false, dragState }: WorkspaceButtonProps) {
|
|
147
|
+
const [location] = useLocation()
|
|
148
|
+
const href = `/workspace/${workspace.id}`
|
|
149
|
+
const label = workspaceDisplayName(workspace)
|
|
150
|
+
const active = location === href
|
|
151
|
+
const content = (
|
|
152
|
+
<>
|
|
153
|
+
<div
|
|
154
|
+
className={cn(
|
|
155
|
+
buttonVariants({ variant: 'ghost', size: 'icon-lg' }),
|
|
156
|
+
'pointer-events-none size-12',
|
|
157
|
+
dragOverlay
|
|
158
|
+
? 'bg-background shadow-lg'
|
|
159
|
+
: 'group-hover:bg-accent group-hover:text-accent-foreground group-focus-visible:ring-3 group-focus-visible:ring-ring/50',
|
|
160
|
+
active && !dragOverlay && 'bg-accent text-accent-foreground'
|
|
161
|
+
)}
|
|
162
|
+
>
|
|
163
|
+
<img
|
|
164
|
+
src={workspace.icon ?? workspaceProviderIcon[workspace.type ?? 'claude-code']}
|
|
165
|
+
alt=""
|
|
166
|
+
className="size-7 shrink-0 rounded-[4px]"
|
|
167
|
+
/>
|
|
168
|
+
</div>
|
|
169
|
+
<span className="mt-0.5 line-clamp-2 w-full text-center text-[11px] leading-snug font-medium text-ellipsis text-foreground">
|
|
170
|
+
{label}
|
|
171
|
+
</span>
|
|
172
|
+
</>
|
|
173
|
+
)
|
|
174
|
+
|
|
175
|
+
if (dragOverlay) {
|
|
176
|
+
return <span className="flex w-14 flex-col items-center">{content}</span>
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
return (
|
|
180
|
+
<Link
|
|
181
|
+
href={href}
|
|
182
|
+
aria-label={label}
|
|
183
|
+
title={label}
|
|
184
|
+
onClick={event => {
|
|
185
|
+
if (dragState?.isDragging) event.preventDefault()
|
|
186
|
+
}}
|
|
187
|
+
className={cn(
|
|
188
|
+
'group flex w-14 flex-col items-center rounded-sm outline-none',
|
|
189
|
+
dragState?.isDragging && 'invisible'
|
|
190
|
+
)}
|
|
191
|
+
{...dragState?.dragHandleProps}
|
|
192
|
+
>
|
|
193
|
+
{content}
|
|
194
|
+
</Link>
|
|
195
|
+
)
|
|
196
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path fill="#10A37F" d="M22.2819 9.8211a5.9847 5.9847 0 0 0-.5157-4.9108 6.0462 6.0462 0 0 0-6.5098-2.9A6.0651 6.0651 0 0 0 4.9807 4.1818a5.9847 5.9847 0 0 0-3.9977 2.9 6.0462 6.0462 0 0 0 .7427 7.0966 5.98 5.98 0 0 0 .511 4.9107 6.051 6.051 0 0 0 6.5146 2.9001A5.9847 5.9847 0 0 0 13.2599 24a6.0557 6.0557 0 0 0 5.7718-4.2058 5.9894 5.9894 0 0 0 3.9977-2.9001 6.0557 6.0557 0 0 0-.7475-7.073zm-9.022 12.6081a4.4755 4.4755 0 0 1-2.8764-1.0408l.1419-.0804 4.7783-2.7582a.7948.7948 0 0 0 .3927-.6813v-6.7369l2.02 1.1686a.071.071 0 0 1 .038.052v5.5826a4.504 4.504 0 0 1-4.4945 4.4944zm-9.6607-4.1254a4.4708 4.4708 0 0 1-.5346-3.0137l.142.0852 4.783 2.7582a.7712.7712 0 0 0 .7806 0l5.8428-3.3685v2.3324a.0804.0804 0 0 1-.0332.0615L9.74 19.9502a4.4992 4.4992 0 0 1-6.1408-1.6464zM2.3408 7.8956a4.485 4.485 0 0 1 2.3655-1.9728V11.6a.7664.7664 0 0 0 .3879.6765l5.8144 3.3543-2.0201 1.1685a.0757.0757 0 0 1-.071 0l-4.8303-2.7865A4.504 4.504 0 0 1 2.3408 7.8956zm16.5963 3.8558L13.1038 8.364 15.1192 7.2a.0757.0757 0 0 1 .071 0l4.8303 2.7913a4.4944 4.4944 0 0 1-.6765 8.1042v-5.6772a.79.79 0 0 0-.407-.667zm2.0107-3.0231l-.142-.0852-4.7735-2.7818a.7759.7759 0 0 0-.7854 0L9.409 9.2297V6.8974a.0662.0662 0 0 1 .0284-.0615l4.8303-2.7866a4.4992 4.4992 0 0 1 6.6802 4.66zM8.3065 12.863l-2.02-1.1638a.0804.0804 0 0 1-.038-.0567V6.0742a4.4992 4.4992 0 0 1 7.3757-3.4537l-.142.0805L8.704 5.459a.7948.7948 0 0 0-.3927.6813zm1.0976-2.3654l2.602-1.4998 2.6069 1.4998v2.9994l-2.5974 1.4997-2.6067-1.4997z"/>
|
|
3
|
+
</svg>
|
|
@@ -14,7 +14,7 @@ export function BottomPanel({ title, children, ref }: BottomPanelProps) {
|
|
|
14
14
|
return (
|
|
15
15
|
<motion.div
|
|
16
16
|
ref={ref}
|
|
17
|
-
className="absolute inset-x-6 bottom-0 z-20 flex max-h-[60vh] flex-col rounded-t-2xl bg-
|
|
17
|
+
className="absolute inset-x-6 bottom-0 z-20 flex max-h-[60vh] flex-col rounded-t-2xl bg-card p-(--page-pad) text-card-foreground shadow-md"
|
|
18
18
|
variants={{
|
|
19
19
|
hidden: { opacity: 0, y: 40, filter: 'blur(4px)' },
|
|
20
20
|
visible: { opacity: 1, y: 0, filter: 'blur(0px)' }
|
|
@@ -25,7 +25,7 @@ export function BottomPanel({ title, children, ref }: BottomPanelProps) {
|
|
|
25
25
|
transition={{ type: 'spring', duration: 0.25, bounce: 0 }}
|
|
26
26
|
>
|
|
27
27
|
<p className="mb-4 shrink-0 text-sm font-medium text-muted-foreground">{title}</p>
|
|
28
|
-
<div className="-my-1 [
|
|
28
|
+
<div className="-my-1 mr-[calc(var(--page-pad)*-1)] ml-[calc(var(--page-pad)*-1)] flex-1 overflow-y-auto px-(--page-pad) py-1">
|
|
29
29
|
{children}
|
|
30
30
|
</div>
|
|
31
31
|
</motion.div>
|