moi-computer 0.3.0-next.0 → 0.3.0-next.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bunfig.toml +5 -1
- package/client/AGENTS.md +15 -0
- 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 +17 -0
- package/client/app/AppRouter.tsx +35 -0
- package/client/app/routes/HomeRoute.tsx +13 -0
- package/client/app/routes/WorkspaceRoute.tsx +89 -0
- package/client/app/shell/SidebarLayout.tsx +191 -0
- package/client/assets.d.ts +9 -0
- package/client/components/playground/PixelPainter.tsx +10 -21
- package/client/components/playground/PlaygroundPage.tsx +9 -11
- package/client/components/playground/ToolCallsPage.tsx +9 -11
- package/client/components/{BottomPanel.tsx → shared/BottomPanel.tsx} +1 -1
- package/client/components/shared/PanelHeader.tsx +9 -0
- package/client/components/shared/ReorderableList.tsx +199 -0
- package/client/components/ui/button.tsx +10 -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/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/{components → features/applets}/WidgetErrorBoundary.tsx +1 -1
- package/client/{components → features/applets}/WidgetShell.tsx +1 -1
- package/client/{hooks → features/applets}/useApplet.ts +6 -7
- package/client/{components/ChatInput.tsx → features/chat/ChatComposer.tsx} +29 -23
- package/client/features/chat/ChatPanel.tsx +188 -0
- package/client/{components → features/chat}/ChatPopup.tsx +23 -12
- package/client/{components → features/chat}/MarkdownContent.tsx +1 -1
- package/client/{components → features/chat}/ModelPicker.tsx +68 -17
- package/client/{components → features/chat}/ThreadSelector.tsx +11 -9
- package/client/{components → features/chat}/TurnView.tsx +16 -9
- 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/{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 +12 -4
- package/client/{components → features/chat}/tool-group/ToolOutput.tsx +12 -18
- package/client/{hooks → features/chat}/useChat.ts +7 -11
- package/client/features/connectors/ConnectorsPage.tsx +92 -0
- package/client/features/connectors/McpMenu.tsx +162 -0
- package/client/features/connectors/api.ts +28 -0
- package/client/features/home/CreateWorkspaceDialog.tsx +224 -0
- package/client/features/home/HomePage.tsx +220 -0
- package/client/{components → features/home}/WorkspacePreview.tsx +2 -2
- package/client/features/home/api.ts +148 -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 +73 -222
- 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 +161 -0
- package/client/{hooks → features/settings}/useEnvVars.ts +4 -4
- 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 +2 -9
- package/client/features/widgets/Widgets.tsx +215 -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 +15 -8
- package/client/features/workspace/WorkspaceScreen.tsx +536 -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 -10
- package/client/index.html +1 -1
- package/client/index.tsx +14 -31
- package/client/lib/ws-url.ts +10 -0
- package/client/main.tsx +2 -2
- package/client/runtime/hmr-watchdog.ts +39 -0
- package/client/{hooks/useMeiEvents.ts → runtime/useWorkspaceEvents.ts} +11 -7
- package/client/store/ui.ts +5 -1
- package/client/theme.css +0 -2
- package/dist/chunk-11cab5dq.css +1 -0
- package/dist/chunk-23cgr1tz.css +1 -0
- package/dist/chunk-3hy3qy6d.js +10 -0
- package/dist/chunk-c4j722at.js +546 -0
- package/dist/chunk-dyfaffyz.js +119 -0
- package/dist/chunk-kpe40hm8.js +1 -0
- package/dist/chunk-p68fnz3q.js +2 -0
- package/dist/chunk-pcnahct1.js +5 -0
- package/dist/chunk-tqd3pkg8.css +1 -0
- package/dist/chunk-ty6dvda0.js +1 -0
- package/dist/index.html +2 -2
- package/lib/types.ts +18 -7
- package/lib/workspace-name.ts +14 -0
- package/package.json +3 -2
- package/server/api.ts +127 -17
- package/server/applets.ts +84 -8
- package/server/cli.ts +11 -5
- package/server/layout.ts +38 -7
- package/server/mcp.ts +72 -15
- package/server/moi-scaffold.ts +55 -10
- package/server/registry.ts +16 -0
- package/server/views.ts +0 -0
- package/server/web.ts +1 -0
- package/server/widgets.ts +3 -2
- package/server/workspace-init.ts +5 -19
- package/tsconfig.json +1 -1
- package/workspace/.claude/skills/moi-workspace/DESIGN.md +1 -1
- package/workspace/.claude/skills/moi-workspace/VIEW-DESIGN.md +1 -1
- package/client/api/workspaces.ts +0 -427
- 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/lib/connection.ts +0 -237
- package/dist/chunk-07qf2tv1.css +0 -1
- package/dist/chunk-c3zjp9ez.js +0 -672
- /package/client/components/{playground → shared}/LedLogo.tsx +0 -0
- /package/client/{lib → features/applets}/applet-cache.ts +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/format.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/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,5 +1,9 @@
|
|
|
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
9
|
- **Space** — Top-level container. Has a name and contains widgets and a chat. One space is active at a time.
|
|
@@ -10,3 +14,14 @@ React SPA connecting to the server via WebSocket (`useChat` hook).
|
|
|
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', 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,17 @@
|
|
|
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
|
+
sessions: (id: string) => ['workspaces', 'sessions', id] as const,
|
|
10
|
+
events: (id: string, sessionId: string) => ['workspaces', 'events', id, sessionId] as const,
|
|
11
|
+
threadConfig: (id: string, sessionId: string) =>
|
|
12
|
+
['workspaces', 'threadConfig', id, sessionId] as const,
|
|
13
|
+
userMcp: ['mcp', 'user'] as const,
|
|
14
|
+
mcp: (id: string) => ['workspaces', 'mcp', id] as const,
|
|
15
|
+
models: (id: string) => ['workspaces', 'models', id] as const,
|
|
16
|
+
env: (id: string) => ['workspaces', 'env', id] as const
|
|
17
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { useEffect } from 'react'
|
|
2
|
+
|
|
3
|
+
import { Route, Switch, useLocation } from 'wouter'
|
|
4
|
+
|
|
5
|
+
import { PlaygroundPage } from '@/client/components/playground/PlaygroundPage'
|
|
6
|
+
import { ToolCallsPage } from '@/client/components/playground/ToolCallsPage'
|
|
7
|
+
import { setWorkspaceSwitchHandler } from '@/client/features/chat/chat-connection'
|
|
8
|
+
import { ConnectorsPage } from '@/client/features/connectors/ConnectorsPage'
|
|
9
|
+
|
|
10
|
+
import { HomeRoute } from './routes/HomeRoute'
|
|
11
|
+
import { WorkspaceRoute } from './routes/WorkspaceRoute'
|
|
12
|
+
|
|
13
|
+
// Top-level router — sets up all client-side routes
|
|
14
|
+
export function AppRouter() {
|
|
15
|
+
const [, navigate] = useLocation()
|
|
16
|
+
|
|
17
|
+
// When the server broadcasts a workspace:switch (e.g. from `moi start`),
|
|
18
|
+
// navigate to that workspace
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
setWorkspaceSwitchHandler(id => navigate(`/workspace/${id}`))
|
|
21
|
+
return () => setWorkspaceSwitchHandler(null)
|
|
22
|
+
}, [navigate])
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<Switch>
|
|
26
|
+
<Route path="/" component={HomeRoute} />
|
|
27
|
+
<Route path="/connectors" component={ConnectorsPage} />
|
|
28
|
+
<Route path="/playground/tool-calls" component={ToolCallsPage} />
|
|
29
|
+
<Route path="/playground" component={PlaygroundPage} />
|
|
30
|
+
<Route path="/workspace/:id">
|
|
31
|
+
{(params: { id: string }) => <WorkspaceRoute key={params.id} id={params.id} />}
|
|
32
|
+
</Route>
|
|
33
|
+
</Switch>
|
|
34
|
+
)
|
|
35
|
+
}
|
|
@@ -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">
|
|
8
|
+
<div className="min-h-0 flex-1 overflow-y-auto">
|
|
9
|
+
<HomePage />
|
|
10
|
+
</div>
|
|
11
|
+
</SidebarLayout>
|
|
12
|
+
)
|
|
13
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
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 { useGridReconcile } from '@/client/features/widgets/useGridReconcile'
|
|
19
|
+
import { useWorkspaceEvent } from '@/client/runtime/useWorkspaceEvents'
|
|
20
|
+
import type { SessionInfo } from '@/lib/types'
|
|
21
|
+
|
|
22
|
+
type WorkspaceRouteProps = {
|
|
23
|
+
id: string
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function WorkspaceRoute({ id }: WorkspaceRouteProps) {
|
|
27
|
+
return (
|
|
28
|
+
<Workspace id={id}>
|
|
29
|
+
<WorkspaceLayoutProvider id={id}>
|
|
30
|
+
<WorkspaceLoader id={id} />
|
|
31
|
+
</WorkspaceLayoutProvider>
|
|
32
|
+
</Workspace>
|
|
33
|
+
)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function WorkspaceLoader({ id }: WorkspaceRouteProps) {
|
|
37
|
+
const queryClient = useQueryClient()
|
|
38
|
+
const { layout, setLayout, isLoading: layoutLoading } = useWorkspaceLayoutCtx()
|
|
39
|
+
const widgets = useWorkspaceWidgets(id)
|
|
40
|
+
const views = useWorkspaceViews(id)
|
|
41
|
+
const sessions = useWorkspaceSessions(id)
|
|
42
|
+
|
|
43
|
+
useGridReconcile(id, widgets.data, layout, setLayout)
|
|
44
|
+
useAppletCacheInvalidation()
|
|
45
|
+
|
|
46
|
+
useWorkspaceEvent(event => {
|
|
47
|
+
if (event.type === 'theme:updated' || event.type === 'workspace:updated') {
|
|
48
|
+
queryClient.invalidateQueries({ queryKey: workspaceKeys.layout(id) })
|
|
49
|
+
} else if (event.type === 'widget-layout:updated') {
|
|
50
|
+
queryClient.invalidateQueries({ queryKey: workspaceKeys.widgets(id) })
|
|
51
|
+
} else if (event.type === 'view-layout:updated') {
|
|
52
|
+
queryClient.invalidateQueries({ queryKey: workspaceKeys.views(id) })
|
|
53
|
+
}
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
const fresh = layoutLoading || widgets.isLoading
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<>
|
|
60
|
+
<SeedActiveSession workspaceId={id} sessions={sessions.data} />
|
|
61
|
+
<SidebarLayout>
|
|
62
|
+
{fresh ? (
|
|
63
|
+
<div className="flex h-full items-center justify-center">
|
|
64
|
+
<LedLogo sprite="moi" effect="chaos" />
|
|
65
|
+
</div>
|
|
66
|
+
) : (
|
|
67
|
+
<WorkspaceScreen widgets={widgets.data ?? []} views={views.data ?? []} />
|
|
68
|
+
)}
|
|
69
|
+
</SidebarLayout>
|
|
70
|
+
</>
|
|
71
|
+
)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
type SeedActiveSessionProps = {
|
|
75
|
+
workspaceId: string
|
|
76
|
+
sessions: SessionInfo[] | undefined
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function SeedActiveSession({ workspaceId, sessions }: SeedActiveSessionProps) {
|
|
80
|
+
useEffect(() => {
|
|
81
|
+
if (!sessions) return
|
|
82
|
+
const active = liveStore.getState().activeByWorkspace[workspaceId] ?? null
|
|
83
|
+
const stillValid = active && sessions.some(session => session.sessionId === active)
|
|
84
|
+
if (!stillValid) {
|
|
85
|
+
liveStore.getState().setActive(workspaceId, sessions[0]?.sessionId ?? null)
|
|
86
|
+
}
|
|
87
|
+
}, [workspaceId, sessions])
|
|
88
|
+
return null
|
|
89
|
+
}
|
|
@@ -0,0 +1,191 @@
|
|
|
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
|
+
}
|
|
34
|
+
|
|
35
|
+
// App shell: a slim icon rail beside the page content. The page owns the panel's
|
|
36
|
+
// header and body.
|
|
37
|
+
export function SidebarLayout({ children, panel = 'default' }: SidebarLayoutProps) {
|
|
38
|
+
const { data: workspaces } = useWorkspaces()
|
|
39
|
+
|
|
40
|
+
// `moi config` / the settings modal broadcast `workspace:updated` (identity
|
|
41
|
+
// changes) and reorder/create broadcast `workspaces-list:updated`; refetch the
|
|
42
|
+
// list so the sidebar reflects it live. Exact: `workspaceKeys.all` is the
|
|
43
|
+
// prefix of every workspace query — a prefix invalidation would refetch
|
|
44
|
+
// transcripts, widgets, and MCP probes in every connected client.
|
|
45
|
+
const qc = useQueryClient()
|
|
46
|
+
useWorkspaceEvent(e => {
|
|
47
|
+
if (e.type === 'workspace:updated' || e.type === 'workspaces-list:updated') {
|
|
48
|
+
qc.invalidateQueries({ queryKey: workspaceKeys.all, exact: true })
|
|
49
|
+
}
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<div className="flex h-dvh bg-muted">
|
|
54
|
+
<Sidebar workspaces={workspaces ?? []} />
|
|
55
|
+
<main
|
|
56
|
+
className={cn(
|
|
57
|
+
'flex min-w-0 flex-1 flex-col overflow-hidden',
|
|
58
|
+
panel === 'default' &&
|
|
59
|
+
'rounded-l-md border-l border-border bg-background shadow-[1px_0_3px_0_var(--border)]'
|
|
60
|
+
)}
|
|
61
|
+
>
|
|
62
|
+
{children}
|
|
63
|
+
</main>
|
|
64
|
+
</div>
|
|
65
|
+
)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
type SidebarProps = {
|
|
69
|
+
workspaces: WorkspaceEntry[]
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function Sidebar({ workspaces }: SidebarProps) {
|
|
73
|
+
const reorder = useReorderWorkspaces()
|
|
74
|
+
|
|
75
|
+
return (
|
|
76
|
+
<aside className="flex h-full shrink-0 flex-col items-center gap-4 px-2 py-5">
|
|
77
|
+
<Link href="/" aria-label="Home" title="Home" className={sidebarNavButtonClass}>
|
|
78
|
+
<IconSmartHome stroke={1.5} />
|
|
79
|
+
</Link>
|
|
80
|
+
|
|
81
|
+
<nav className="flex max-h-full min-h-0 w-14 flex-1 flex-col items-center justify-center gap-4">
|
|
82
|
+
{workspaces.length > 0 && (
|
|
83
|
+
<>
|
|
84
|
+
<div className="scrollbar-none min-h-0 scroll-fade overflow-y-auto [--scroll-fade-reveal:16px]">
|
|
85
|
+
<ReorderableList
|
|
86
|
+
items={workspaces}
|
|
87
|
+
getId={ws => ws.id}
|
|
88
|
+
className="flex flex-col gap-4"
|
|
89
|
+
onReorder={ids => reorder.mutate(ids)}
|
|
90
|
+
renderPlaceholder={() => (
|
|
91
|
+
<div className="pointer-events-none absolute top-0 left-1 size-10 rounded-lg bg-accent" />
|
|
92
|
+
)}
|
|
93
|
+
renderOverlay={ws => <WorkspaceButton workspace={ws} dragOverlay />}
|
|
94
|
+
renderItem={(ws, state) => <WorkspaceButton workspace={ws} dragState={state} />}
|
|
95
|
+
/>
|
|
96
|
+
</div>
|
|
97
|
+
<div className="shrink-0">
|
|
98
|
+
<CreateWorkspaceDialog
|
|
99
|
+
trigger={
|
|
100
|
+
<Button
|
|
101
|
+
type="button"
|
|
102
|
+
variant="ghost"
|
|
103
|
+
size="icon-lg"
|
|
104
|
+
aria-label="Create new space"
|
|
105
|
+
title="Create new space"
|
|
106
|
+
className="text-muted-foreground hover:text-foreground"
|
|
107
|
+
>
|
|
108
|
+
<IconPlus data-icon="inline-start" stroke={1.5} />
|
|
109
|
+
</Button>
|
|
110
|
+
}
|
|
111
|
+
/>
|
|
112
|
+
</div>
|
|
113
|
+
</>
|
|
114
|
+
)}
|
|
115
|
+
</nav>
|
|
116
|
+
|
|
117
|
+
<ConnectorsNavLink />
|
|
118
|
+
</aside>
|
|
119
|
+
)
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function ConnectorsNavLink() {
|
|
123
|
+
return (
|
|
124
|
+
<Link
|
|
125
|
+
href="/connectors"
|
|
126
|
+
aria-label="Connectors"
|
|
127
|
+
title="Connectors"
|
|
128
|
+
className={sidebarNavButtonClass}
|
|
129
|
+
>
|
|
130
|
+
<IconPlugConnected stroke={1.5} />
|
|
131
|
+
</Link>
|
|
132
|
+
)
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
type WorkspaceButtonProps = {
|
|
136
|
+
workspace: WorkspaceEntry
|
|
137
|
+
dragOverlay?: boolean
|
|
138
|
+
dragState?: ReorderableRenderState
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function WorkspaceButton({ workspace, dragOverlay = false, dragState }: WorkspaceButtonProps) {
|
|
142
|
+
const [location] = useLocation()
|
|
143
|
+
const href = `/workspace/${workspace.id}`
|
|
144
|
+
const label = workspaceDisplayName(workspace)
|
|
145
|
+
const active = location === href
|
|
146
|
+
const content = (
|
|
147
|
+
<>
|
|
148
|
+
<div
|
|
149
|
+
className={cn(
|
|
150
|
+
buttonVariants({ variant: 'ghost', size: 'icon-lg' }),
|
|
151
|
+
'pointer-events-none size-12',
|
|
152
|
+
dragOverlay
|
|
153
|
+
? 'bg-background shadow-lg'
|
|
154
|
+
: 'group-hover:bg-accent group-hover:text-accent-foreground group-focus-visible:ring-3 group-focus-visible:ring-ring/50',
|
|
155
|
+
active && !dragOverlay && 'bg-accent text-accent-foreground'
|
|
156
|
+
)}
|
|
157
|
+
>
|
|
158
|
+
<img
|
|
159
|
+
src={workspace.icon ?? workspaceProviderIcon[workspace.type ?? 'claude-code']}
|
|
160
|
+
alt=""
|
|
161
|
+
className="size-7 shrink-0 rounded-[4px]"
|
|
162
|
+
/>
|
|
163
|
+
</div>
|
|
164
|
+
<span className="mt-0.5 line-clamp-2 w-full text-center text-[11px] leading-snug font-medium text-ellipsis text-foreground">
|
|
165
|
+
{label}
|
|
166
|
+
</span>
|
|
167
|
+
</>
|
|
168
|
+
)
|
|
169
|
+
|
|
170
|
+
if (dragOverlay) {
|
|
171
|
+
return <span className="flex w-14 flex-col items-center">{content}</span>
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
return (
|
|
175
|
+
<Link
|
|
176
|
+
href={href}
|
|
177
|
+
aria-label={label}
|
|
178
|
+
title={label}
|
|
179
|
+
onClick={event => {
|
|
180
|
+
if (dragState?.isDragging) event.preventDefault()
|
|
181
|
+
}}
|
|
182
|
+
className={cn(
|
|
183
|
+
'group flex w-14 flex-col items-center rounded-sm outline-none',
|
|
184
|
+
dragState?.isDragging && 'invisible'
|
|
185
|
+
)}
|
|
186
|
+
{...dragState?.dragHandleProps}
|
|
187
|
+
>
|
|
188
|
+
{content}
|
|
189
|
+
</Link>
|
|
190
|
+
)
|
|
191
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useEffect, useRef, useState } from 'react'
|
|
2
2
|
|
|
3
|
+
import { Button } from '@/client/components/ui/button'
|
|
3
4
|
import { cn } from '@/client/lib/cn'
|
|
4
5
|
|
|
5
6
|
const COLS = 5
|
|
@@ -60,45 +61,33 @@ export function PixelPainter() {
|
|
|
60
61
|
|
|
61
62
|
return (
|
|
62
63
|
<div className="flex flex-col items-center gap-4">
|
|
63
|
-
<div className="grid w-fit grid-cols-[repeat(5,28px)] gap-px bg-
|
|
64
|
+
<div className="grid w-fit grid-cols-[repeat(5,28px)] gap-px bg-border p-px select-none">
|
|
64
65
|
{grid.map((row, r) =>
|
|
65
66
|
row.map((on, c) => (
|
|
66
67
|
<div
|
|
67
68
|
key={`${r}-${c}`}
|
|
68
69
|
onMouseDown={() => handleDown(r, c)}
|
|
69
70
|
onMouseEnter={() => handleEnter(r, c)}
|
|
70
|
-
className={cn('size-7 cursor-pointer', on ? 'bg-
|
|
71
|
+
className={cn('size-7 cursor-pointer', on ? 'bg-foreground' : 'bg-background')}
|
|
71
72
|
/>
|
|
72
73
|
))
|
|
73
74
|
)}
|
|
74
75
|
</div>
|
|
75
76
|
|
|
76
|
-
<pre className="rounded-md border border-border bg-
|
|
77
|
+
<pre className="rounded-md border border-border bg-card px-3 py-2 text-center font-mono text-sm leading-snug text-card-foreground">
|
|
77
78
|
{ascii}
|
|
78
79
|
</pre>
|
|
79
80
|
|
|
80
81
|
<div className="flex gap-2">
|
|
81
|
-
<button
|
|
82
|
-
type="button"
|
|
83
|
-
onClick={copy}
|
|
84
|
-
className="rounded-md bg-neutral-900 px-3 py-1 text-xs font-medium text-white"
|
|
85
|
-
>
|
|
82
|
+
<Button type="button" size="sm" onClick={copy}>
|
|
86
83
|
{copied ? 'Copied!' : 'Copy'}
|
|
87
|
-
</
|
|
88
|
-
<button
|
|
89
|
-
type="button"
|
|
90
|
-
onClick={() => setGrid(emptyGrid())}
|
|
91
|
-
className="rounded-md bg-black/[0.06] px-3 py-1 text-xs font-medium text-black/60 hover:text-black/80"
|
|
92
|
-
>
|
|
84
|
+
</Button>
|
|
85
|
+
<Button type="button" variant="secondary" size="sm" onClick={() => setGrid(emptyGrid())}>
|
|
93
86
|
Clear
|
|
94
|
-
</
|
|
95
|
-
<button
|
|
96
|
-
type="button"
|
|
97
|
-
onClick={() => setGrid(fromRows(SEED))}
|
|
98
|
-
className="rounded-md bg-black/[0.06] px-3 py-1 text-xs font-medium text-black/60 hover:text-black/80"
|
|
99
|
-
>
|
|
87
|
+
</Button>
|
|
88
|
+
<Button type="button" variant="secondary" size="sm" onClick={() => setGrid(fromRows(SEED))}>
|
|
100
89
|
Reset
|
|
101
|
-
</
|
|
90
|
+
</Button>
|
|
102
91
|
</div>
|
|
103
92
|
</div>
|
|
104
93
|
)
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { useState } from 'react'
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { Button } from '@/client/components/ui/button'
|
|
4
4
|
|
|
5
|
-
import { type Effect, LedLogo, type Sprite } from '
|
|
5
|
+
import { type Effect, LedLogo, type Sprite } from '@/client/components/shared/LedLogo'
|
|
6
6
|
import { PixelPainter } from './PixelPainter'
|
|
7
7
|
|
|
8
8
|
const SPRITES: { value: Sprite; label: string }[] = [
|
|
@@ -24,19 +24,17 @@ type SegmentedProps<T extends string | number> = {
|
|
|
24
24
|
|
|
25
25
|
function Segmented<T extends string | number>({ options, value, onChange }: SegmentedProps<T>) {
|
|
26
26
|
return (
|
|
27
|
-
<div className="flex gap-1 rounded-lg bg-
|
|
27
|
+
<div className="flex gap-1 rounded-lg bg-accent p-1">
|
|
28
28
|
{options.map(o => (
|
|
29
|
-
<
|
|
29
|
+
<Button
|
|
30
30
|
key={String(o.value)}
|
|
31
31
|
type="button"
|
|
32
|
+
variant={value === o.value ? 'default' : 'ghost'}
|
|
33
|
+
size="sm"
|
|
32
34
|
onClick={() => onChange(o.value)}
|
|
33
|
-
className={cn(
|
|
34
|
-
'rounded-md px-3 py-1 text-xs transition-colors',
|
|
35
|
-
value === o.value ? 'bg-neutral-900 text-white' : 'text-black/50 hover:text-black/80'
|
|
36
|
-
)}
|
|
37
35
|
>
|
|
38
36
|
{o.label}
|
|
39
|
-
</
|
|
37
|
+
</Button>
|
|
40
38
|
))}
|
|
41
39
|
</div>
|
|
42
40
|
)
|
|
@@ -48,8 +46,8 @@ export function PlaygroundPage() {
|
|
|
48
46
|
const [effect, setEffect] = useState<Effect | 'none'>('none')
|
|
49
47
|
|
|
50
48
|
return (
|
|
51
|
-
<div className="relative flex min-h-dvh flex-col items-center justify-center gap-8 bg-
|
|
52
|
-
<span className="absolute top-5 left-5 text-[11px] font-medium tracking-widest text-
|
|
49
|
+
<div className="relative flex min-h-dvh flex-col items-center justify-center gap-8 bg-muted">
|
|
50
|
+
<span className="absolute top-5 left-5 text-[11px] font-medium tracking-widest text-muted-foreground uppercase">
|
|
53
51
|
Playground
|
|
54
52
|
</span>
|
|
55
53
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useState } from 'react'
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { Button } from '@/client/components/ui/button'
|
|
4
4
|
import {
|
|
5
5
|
FIXTURE_CWD,
|
|
6
6
|
liveToolCalls,
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
subagentDoneTrace,
|
|
10
10
|
subagentTrace,
|
|
11
11
|
ToolCallGroup
|
|
12
|
-
} from '@/client/
|
|
12
|
+
} from '@/client/features/chat/tool-group'
|
|
13
13
|
|
|
14
14
|
const VARIANTS = [
|
|
15
15
|
{ value: 'single', label: 'Single' },
|
|
@@ -28,19 +28,17 @@ type SegmentedProps = {
|
|
|
28
28
|
|
|
29
29
|
function Segmented({ value, onChange }: SegmentedProps) {
|
|
30
30
|
return (
|
|
31
|
-
<div className="flex gap-1 rounded-lg bg-
|
|
31
|
+
<div className="flex gap-1 rounded-lg bg-accent p-1">
|
|
32
32
|
{VARIANTS.map(o => (
|
|
33
|
-
<
|
|
33
|
+
<Button
|
|
34
34
|
key={o.value}
|
|
35
35
|
type="button"
|
|
36
|
+
variant={value === o.value ? 'default' : 'ghost'}
|
|
37
|
+
size="sm"
|
|
36
38
|
onClick={() => onChange(o.value)}
|
|
37
|
-
className={cn(
|
|
38
|
-
'rounded-md px-3 py-1 text-xs transition-colors',
|
|
39
|
-
value === o.value ? 'bg-neutral-900 text-white' : 'text-black/50 hover:text-black/80'
|
|
40
|
-
)}
|
|
41
39
|
>
|
|
42
40
|
{o.label}
|
|
43
|
-
</
|
|
41
|
+
</Button>
|
|
44
42
|
))}
|
|
45
43
|
</div>
|
|
46
44
|
)
|
|
@@ -60,8 +58,8 @@ export function ToolCallsPage() {
|
|
|
60
58
|
const [variant, setVariant] = useState<Variant>('multiple')
|
|
61
59
|
|
|
62
60
|
return (
|
|
63
|
-
<div className="flex min-h-dvh flex-col items-center gap-6 bg-
|
|
64
|
-
<span className="text-[11px] font-medium tracking-widest text-
|
|
61
|
+
<div className="flex min-h-dvh flex-col items-center gap-6 bg-muted px-4 py-16">
|
|
62
|
+
<span className="text-[11px] font-medium tracking-widest text-muted-foreground uppercase">
|
|
65
63
|
Playground / Tool calls
|
|
66
64
|
</span>
|
|
67
65
|
|
|
@@ -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-[var(--page-pad)] text-card-foreground shadow-xl"
|
|
18
18
|
variants={{
|
|
19
19
|
hidden: { opacity: 0, y: 40, filter: 'blur(4px)' },
|
|
20
20
|
visible: { opacity: 1, y: 0, filter: 'blur(0px)' }
|