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
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
import { type FormEvent, useState } from 'react'
|
|
2
|
-
|
|
3
|
-
import { IconLoader2, IconPlus } from '@tabler/icons-react'
|
|
4
|
-
import { useLocation } from 'wouter'
|
|
5
|
-
|
|
6
|
-
import { useCreateWorkspace, useCreateWorkspaceInfo } from '@/client/api/workspaces'
|
|
7
|
-
import { TypeIcon, typeLabel } from '@/client/components/WorkspacesPage'
|
|
8
|
-
import { PanelHeader, SidebarLayout, SidebarToggle } from '@/client/components/layout/SidebarLayout'
|
|
9
|
-
import { Button } from '@/client/components/ui/button'
|
|
10
|
-
import { Input } from '@/client/components/ui/input'
|
|
11
|
-
import { cn } from '@/client/lib/cn'
|
|
12
|
-
import type { WorkspaceType } from '@/lib/types'
|
|
13
|
-
|
|
14
|
-
// Mirrors the server's validateWorkspaceFolderName (workspace-init.ts) for
|
|
15
|
-
// instant feedback; the server remains the authority and re-validates.
|
|
16
|
-
function folderNameError(name: string): string | null {
|
|
17
|
-
if (!name) return null // an empty field just disables the submit, no nagging
|
|
18
|
-
if (name.length > 64) return 'Folder name is too long (max 64 characters)'
|
|
19
|
-
if (!/^[A-Za-z0-9][A-Za-z0-9._ -]*$/.test(name)) {
|
|
20
|
-
return 'Use letters, numbers, dots, dashes, underscores and spaces, starting with a letter or number'
|
|
21
|
-
}
|
|
22
|
-
if (name.endsWith('.') || name.endsWith(' ')) return 'Folder name cannot end with a dot or space'
|
|
23
|
-
return null
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
type AgentOption = {
|
|
27
|
-
type: WorkspaceType
|
|
28
|
-
hint: string
|
|
29
|
-
disabled?: boolean
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// Only Claude Code workspaces can be created from scratch for now. OpenClaw
|
|
33
|
-
// workspaces belong to their agents — they arrive via discovery on the home
|
|
34
|
-
// page — and Hermes has no init path yet.
|
|
35
|
-
const AGENT_OPTIONS: AgentOption[] = [
|
|
36
|
-
{ type: 'claude-code', hint: 'Powered by the Claude Agent SDK' },
|
|
37
|
-
{ type: 'openclaw', hint: 'Import a discovered agent from Home', disabled: true },
|
|
38
|
-
{ type: 'hermes', hint: 'Coming soon', disabled: true }
|
|
39
|
-
]
|
|
40
|
-
|
|
41
|
-
// The `/workspace/create` route: name a folder, get a provisioned (skills +
|
|
42
|
-
// `.moi/` scaffold) and registered workspace under the server's workspaces
|
|
43
|
-
// root, then land in it.
|
|
44
|
-
export function CreateWorkspacePage() {
|
|
45
|
-
const [, navigate] = useLocation()
|
|
46
|
-
const info = useCreateWorkspaceInfo()
|
|
47
|
-
const createMutation = useCreateWorkspace()
|
|
48
|
-
|
|
49
|
-
const [name, setName] = useState('')
|
|
50
|
-
const [type, setType] = useState<WorkspaceType>('claude-code')
|
|
51
|
-
|
|
52
|
-
const trimmed = name.trim()
|
|
53
|
-
const nameError = folderNameError(trimmed)
|
|
54
|
-
const canSubmit = trimmed.length > 0 && !nameError && !createMutation.isPending
|
|
55
|
-
const root = info.data?.displayRoot ?? '…'
|
|
56
|
-
|
|
57
|
-
function handleSubmit(e: FormEvent) {
|
|
58
|
-
e.preventDefault()
|
|
59
|
-
if (!canSubmit) return
|
|
60
|
-
createMutation.mutate(
|
|
61
|
-
{ name: trimmed, type },
|
|
62
|
-
{ onSuccess: entry => navigate(`/workspace/${entry.id}`) }
|
|
63
|
-
)
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return (
|
|
67
|
-
<SidebarLayout>
|
|
68
|
-
<PanelHeader>
|
|
69
|
-
<SidebarToggle />
|
|
70
|
-
<span className="text-sm font-medium text-foreground">New workspace</span>
|
|
71
|
-
</PanelHeader>
|
|
72
|
-
<div className="min-h-0 flex-1 overflow-y-auto">
|
|
73
|
-
<form onSubmit={handleSubmit} className="mx-auto w-full max-w-xl px-8 pt-14 pb-16">
|
|
74
|
-
<h1 className="mb-1.5 text-base font-semibold text-foreground">Create a workspace</h1>
|
|
75
|
-
<p className="mb-8 text-sm text-muted-foreground">
|
|
76
|
-
A new folder in <code className="rounded bg-muted px-1 py-0.5 font-mono text-xs">{root}</code>,
|
|
77
|
-
set up with moi skills and widgets, ready to chat.
|
|
78
|
-
</p>
|
|
79
|
-
|
|
80
|
-
<fieldset className="mb-6">
|
|
81
|
-
<legend className="mb-2 text-sm font-medium text-foreground">Agent</legend>
|
|
82
|
-
<div className="grid grid-cols-3 gap-2">
|
|
83
|
-
{AGENT_OPTIONS.map(option => (
|
|
84
|
-
<button
|
|
85
|
-
key={option.type}
|
|
86
|
-
type="button"
|
|
87
|
-
disabled={option.disabled}
|
|
88
|
-
onClick={() => setType(option.type)}
|
|
89
|
-
aria-pressed={type === option.type}
|
|
90
|
-
className={cn(
|
|
91
|
-
'flex flex-col items-start gap-1.5 rounded-lg border p-3 text-left transition-colors',
|
|
92
|
-
type === option.type
|
|
93
|
-
? 'border-ring bg-muted/50 shadow-[inset_0_0_0_1px_var(--ring)]'
|
|
94
|
-
: 'border-border hover:bg-muted/40',
|
|
95
|
-
option.disabled && 'cursor-not-allowed opacity-50 hover:bg-transparent'
|
|
96
|
-
)}
|
|
97
|
-
>
|
|
98
|
-
<span className="flex items-center gap-2">
|
|
99
|
-
<TypeIcon type={option.type} />
|
|
100
|
-
<span className="text-sm font-medium text-foreground">
|
|
101
|
-
{typeLabel[option.type]}
|
|
102
|
-
</span>
|
|
103
|
-
</span>
|
|
104
|
-
<span className="text-xs text-muted-foreground">{option.hint}</span>
|
|
105
|
-
</button>
|
|
106
|
-
))}
|
|
107
|
-
</div>
|
|
108
|
-
</fieldset>
|
|
109
|
-
|
|
110
|
-
<div className="mb-2">
|
|
111
|
-
<label htmlFor="workspace-name" className="mb-2 block text-sm font-medium text-foreground">
|
|
112
|
-
Folder name
|
|
113
|
-
</label>
|
|
114
|
-
<Input
|
|
115
|
-
id="workspace-name"
|
|
116
|
-
value={name}
|
|
117
|
-
onChange={e => setName(e.target.value)}
|
|
118
|
-
placeholder="my-workspace"
|
|
119
|
-
autoFocus
|
|
120
|
-
aria-invalid={!!nameError}
|
|
121
|
-
autoComplete="off"
|
|
122
|
-
spellCheck={false}
|
|
123
|
-
/>
|
|
124
|
-
</div>
|
|
125
|
-
{nameError ? (
|
|
126
|
-
<p className="mb-6 text-xs text-destructive">{nameError}</p>
|
|
127
|
-
) : (
|
|
128
|
-
<p className="mb-6 font-mono text-xs text-muted-foreground">
|
|
129
|
-
{root}/{trimmed || 'my-workspace'}
|
|
130
|
-
</p>
|
|
131
|
-
)}
|
|
132
|
-
|
|
133
|
-
<div className="flex items-center gap-3">
|
|
134
|
-
<Button type="submit" disabled={!canSubmit}>
|
|
135
|
-
{createMutation.isPending ? (
|
|
136
|
-
<IconLoader2 stroke={1.5} className="animate-spin" />
|
|
137
|
-
) : (
|
|
138
|
-
<IconPlus stroke={1.5} />
|
|
139
|
-
)}
|
|
140
|
-
Create workspace
|
|
141
|
-
</Button>
|
|
142
|
-
{createMutation.isPending && (
|
|
143
|
-
<span className="text-xs text-muted-foreground">
|
|
144
|
-
Setting up skills and widgets…
|
|
145
|
-
</span>
|
|
146
|
-
)}
|
|
147
|
-
</div>
|
|
148
|
-
{createMutation.isError && (
|
|
149
|
-
<p className="mt-3 text-xs text-destructive">{createMutation.error.message}</p>
|
|
150
|
-
)}
|
|
151
|
-
</form>
|
|
152
|
-
</div>
|
|
153
|
-
</SidebarLayout>
|
|
154
|
-
)
|
|
155
|
-
}
|
|
@@ -1,255 +0,0 @@
|
|
|
1
|
-
import { type ReactNode, useState } from 'react'
|
|
2
|
-
|
|
3
|
-
import { IconLoader2, IconPlus, IconTrash } from '@tabler/icons-react'
|
|
4
|
-
|
|
5
|
-
import { useSaveWorkspaceName } from '@/client/api/workspaces'
|
|
6
|
-
import { useEnvVars } from '@/client/hooks/useEnvVars'
|
|
7
|
-
import { Button } from '@/client/components/ui/button'
|
|
8
|
-
import { Input } from '@/client/components/ui/input'
|
|
9
|
-
import { Switch } from '@/client/components/ui/switch'
|
|
10
|
-
import { useWorkspaceLayoutCtx } from '@/client/lib/WorkspaceLayoutContext'
|
|
11
|
-
import { cn } from '@/client/lib/cn'
|
|
12
|
-
import type { WorkspaceEnvVar } from '@/lib/types'
|
|
13
|
-
|
|
14
|
-
import { IconPicker } from './IconPicker'
|
|
15
|
-
|
|
16
|
-
// ── Shared page primitives ──────────────────────────────────────────────────
|
|
17
|
-
|
|
18
|
-
type SettingsPageProps = {
|
|
19
|
-
title: string
|
|
20
|
-
description?: string
|
|
21
|
-
children: ReactNode
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function SettingsPage({ title, description, children }: SettingsPageProps) {
|
|
25
|
-
return (
|
|
26
|
-
<div className="flex flex-col gap-6">
|
|
27
|
-
<header className="flex flex-col gap-1">
|
|
28
|
-
<h2 className="text-xl font-semibold tracking-tight">{title}</h2>
|
|
29
|
-
{description && <p className="text-sm text-muted-foreground">{description}</p>}
|
|
30
|
-
</header>
|
|
31
|
-
{children}
|
|
32
|
-
</div>
|
|
33
|
-
)
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
type SettingsSectionProps = {
|
|
37
|
-
label?: string
|
|
38
|
-
children: ReactNode
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
function SettingsSection({ label, children }: SettingsSectionProps) {
|
|
42
|
-
return (
|
|
43
|
-
<section className="flex flex-col gap-2">
|
|
44
|
-
{label && <p className="px-0.5 text-xs font-medium text-muted-foreground">{label}</p>}
|
|
45
|
-
<div className="flex flex-col divide-y divide-dashed divide-border overflow-hidden rounded-lg border border-border bg-card">
|
|
46
|
-
{children}
|
|
47
|
-
</div>
|
|
48
|
-
</section>
|
|
49
|
-
)
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
type SettingsRowProps = {
|
|
53
|
-
title: string
|
|
54
|
-
description?: string
|
|
55
|
-
control?: ReactNode
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function SettingsRow({ title, description, control }: SettingsRowProps) {
|
|
59
|
-
return (
|
|
60
|
-
<div className="flex items-center gap-3 px-3.5 py-3">
|
|
61
|
-
<div className="flex min-w-0 flex-col">
|
|
62
|
-
<span className="text-sm font-medium">{title}</span>
|
|
63
|
-
{description && <span className="text-xs text-muted-foreground">{description}</span>}
|
|
64
|
-
</div>
|
|
65
|
-
{control && <div className="ml-auto flex shrink-0 items-center pl-3">{control}</div>}
|
|
66
|
-
</div>
|
|
67
|
-
)
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// ── General ─────────────────────────────────────────────────────────────────
|
|
71
|
-
|
|
72
|
-
export function GeneralSettings() {
|
|
73
|
-
const { name, icon, workspaceId } = useWorkspaceLayoutCtx()
|
|
74
|
-
const saveName = useSaveWorkspaceName(workspaceId)
|
|
75
|
-
const [draft, setDraft] = useState(name ?? '')
|
|
76
|
-
|
|
77
|
-
// Persist on blur (or Enter): an empty value clears the override so the name
|
|
78
|
-
// falls back to the folder name.
|
|
79
|
-
const commit = () => {
|
|
80
|
-
const next = draft.trim()
|
|
81
|
-
if (next === (name ?? '')) return
|
|
82
|
-
saveName.mutate(next === '' ? null : next)
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
return (
|
|
86
|
-
<SettingsPage title="General" description="Basic details for this workspace.">
|
|
87
|
-
<SettingsSection>
|
|
88
|
-
<SettingsRow
|
|
89
|
-
title="Name"
|
|
90
|
-
description="Shown in the sidebar and the workspace header."
|
|
91
|
-
control={
|
|
92
|
-
<Input
|
|
93
|
-
value={draft}
|
|
94
|
-
onChange={e => setDraft(e.target.value)}
|
|
95
|
-
onBlur={commit}
|
|
96
|
-
onKeyDown={e => {
|
|
97
|
-
if (e.key === 'Enter') e.currentTarget.blur()
|
|
98
|
-
}}
|
|
99
|
-
placeholder="Workspace name"
|
|
100
|
-
className="w-56"
|
|
101
|
-
/>
|
|
102
|
-
}
|
|
103
|
-
/>
|
|
104
|
-
<div className="flex flex-col gap-4 px-3.5 py-3.5">
|
|
105
|
-
<div className="flex flex-col">
|
|
106
|
-
<span className="text-sm font-medium">Icon</span>
|
|
107
|
-
<span className="text-xs text-muted-foreground">
|
|
108
|
-
Pick an emoji or a glyph on a generated background, or upload an image.
|
|
109
|
-
</span>
|
|
110
|
-
</div>
|
|
111
|
-
<IconPicker icon={icon} />
|
|
112
|
-
</div>
|
|
113
|
-
</SettingsSection>
|
|
114
|
-
</SettingsPage>
|
|
115
|
-
)
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
// ── Environment ─────────────────────────────────────────────────────────────
|
|
119
|
-
|
|
120
|
-
// Source badge copy: where the key actually comes from.
|
|
121
|
-
const SOURCE_LABEL: Record<WorkspaceEnvVar['source'], string> = {
|
|
122
|
-
dotenv: '.env',
|
|
123
|
-
custom: 'secret',
|
|
124
|
-
both: 'override'
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
const ENV_KEY_RE = /^[A-Za-z_][A-Za-z0-9_]*$/
|
|
128
|
-
|
|
129
|
-
export function EnvironmentSettings() {
|
|
130
|
-
const { workspaceId } = useWorkspaceLayoutCtx()
|
|
131
|
-
const { env, update } = useEnvVars(workspaceId)
|
|
132
|
-
|
|
133
|
-
const [draftKey, setDraftKey] = useState('')
|
|
134
|
-
const [draftValue, setDraftValue] = useState('')
|
|
135
|
-
|
|
136
|
-
const keyValid = ENV_KEY_RE.test(draftKey)
|
|
137
|
-
const canAdd = keyValid && draftValue.length > 0 && !update.isPending
|
|
138
|
-
|
|
139
|
-
const addVar = () => {
|
|
140
|
-
if (!canAdd) return
|
|
141
|
-
update.mutate(
|
|
142
|
-
{ set: { [draftKey]: draftValue } },
|
|
143
|
-
{
|
|
144
|
-
onSuccess: () => {
|
|
145
|
-
setDraftKey('')
|
|
146
|
-
setDraftValue('')
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
)
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
const vars = env.data?.vars ?? []
|
|
153
|
-
const fileCount = env.data?.files.reduce((n, f) => n + f.count, 0) ?? 0
|
|
154
|
-
const dotenvFiles = env.data?.files.length ?? 0
|
|
155
|
-
|
|
156
|
-
return (
|
|
157
|
-
<SettingsPage
|
|
158
|
-
title="Environment"
|
|
159
|
-
description="Secrets injected into widgets and the agent at run time. Values are write-only — they're never shown again once saved."
|
|
160
|
-
>
|
|
161
|
-
<SettingsSection label="Variables">
|
|
162
|
-
{env.isLoading ? (
|
|
163
|
-
<div className="flex items-center justify-center px-3.5 py-6 text-muted-foreground">
|
|
164
|
-
<IconLoader2 className="size-4 animate-spin" stroke={1.75} />
|
|
165
|
-
</div>
|
|
166
|
-
) : vars.length === 0 ? (
|
|
167
|
-
<p className="px-3.5 py-4 text-sm text-muted-foreground">No variables yet.</p>
|
|
168
|
-
) : (
|
|
169
|
-
vars.map(v => {
|
|
170
|
-
const editable = v.source !== 'dotenv'
|
|
171
|
-
return (
|
|
172
|
-
<div key={v.key} className="flex items-center gap-3 px-3.5 py-2.5">
|
|
173
|
-
<code className="min-w-0 flex-1 truncate font-mono text-xs text-foreground">
|
|
174
|
-
{v.key}
|
|
175
|
-
</code>
|
|
176
|
-
<span className="text-xs tracking-widest text-muted-foreground/60 select-none">
|
|
177
|
-
••••••
|
|
178
|
-
</span>
|
|
179
|
-
<span
|
|
180
|
-
className={cn(
|
|
181
|
-
'rounded-sm px-1.5 py-0.5 text-[11px] font-medium',
|
|
182
|
-
v.source === 'dotenv'
|
|
183
|
-
? 'bg-muted text-muted-foreground'
|
|
184
|
-
: 'bg-primary/10 text-primary'
|
|
185
|
-
)}
|
|
186
|
-
>
|
|
187
|
-
{SOURCE_LABEL[v.source]}
|
|
188
|
-
</span>
|
|
189
|
-
{!editable && (
|
|
190
|
-
<span className="text-right text-[11px] text-muted-foreground/60">from file</span>
|
|
191
|
-
)}
|
|
192
|
-
<button
|
|
193
|
-
type="button"
|
|
194
|
-
onClick={() => update.mutate({ remove: [v.key] })}
|
|
195
|
-
disabled={!editable}
|
|
196
|
-
aria-label={`Delete ${v.key}`}
|
|
197
|
-
className="text-muted-foreground/50 transition-colors not-disabled:hover:text-foreground disabled:invisible [&_svg]:size-4"
|
|
198
|
-
>
|
|
199
|
-
<IconTrash stroke={1.5} />
|
|
200
|
-
</button>
|
|
201
|
-
</div>
|
|
202
|
-
)
|
|
203
|
-
})
|
|
204
|
-
)}
|
|
205
|
-
|
|
206
|
-
{/* Add row */}
|
|
207
|
-
<div className="flex items-center gap-2 px-3.5 py-2.5">
|
|
208
|
-
<Input
|
|
209
|
-
value={draftKey}
|
|
210
|
-
onChange={e => setDraftKey(e.target.value)}
|
|
211
|
-
placeholder="NEW_KEY"
|
|
212
|
-
aria-invalid={draftKey.length > 0 && !keyValid}
|
|
213
|
-
className="h-7 w-40 font-mono text-xs"
|
|
214
|
-
/>
|
|
215
|
-
<Input
|
|
216
|
-
value={draftValue}
|
|
217
|
-
onChange={e => setDraftValue(e.target.value)}
|
|
218
|
-
onKeyDown={e => {
|
|
219
|
-
if (e.key === 'Enter') addVar()
|
|
220
|
-
}}
|
|
221
|
-
type="password"
|
|
222
|
-
placeholder="value"
|
|
223
|
-
className="h-7 flex-1 text-xs"
|
|
224
|
-
/>
|
|
225
|
-
<Button variant="outline" size="sm" className="h-7" onClick={addVar} disabled={!canAdd}>
|
|
226
|
-
{update.isPending ? (
|
|
227
|
-
<IconLoader2 className="animate-spin" />
|
|
228
|
-
) : (
|
|
229
|
-
<IconPlus stroke={1.75} />
|
|
230
|
-
)}
|
|
231
|
-
Add
|
|
232
|
-
</Button>
|
|
233
|
-
</div>
|
|
234
|
-
</SettingsSection>
|
|
235
|
-
|
|
236
|
-
<SettingsSection label="From .env files">
|
|
237
|
-
<SettingsRow
|
|
238
|
-
title="Inherit .env files"
|
|
239
|
-
description={
|
|
240
|
-
dotenvFiles > 0
|
|
241
|
-
? `Discovered ${fileCount} ${fileCount === 1 ? 'key' : 'keys'} across ${dotenvFiles} ${dotenvFiles === 1 ? 'file' : 'files'} in this workspace.`
|
|
242
|
-
: 'No .env files found in this workspace.'
|
|
243
|
-
}
|
|
244
|
-
control={
|
|
245
|
-
<Switch
|
|
246
|
-
checked={env.data?.inheritDotenv ?? true}
|
|
247
|
-
disabled={env.isLoading}
|
|
248
|
-
onCheckedChange={checked => update.mutate({ inheritDotenv: checked })}
|
|
249
|
-
/>
|
|
250
|
-
}
|
|
251
|
-
/>
|
|
252
|
-
</SettingsSection>
|
|
253
|
-
</SettingsPage>
|
|
254
|
-
)
|
|
255
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { useEffect, useRef, useState } from 'react'
|
|
2
|
-
|
|
3
|
-
// Resolve a CSS length token (px or rem) defined on :root to pixels, so the fit
|
|
4
|
-
// math shares the layout tokens in index.css rather than duplicating values.
|
|
5
|
-
function tokenPx(name: string): number {
|
|
6
|
-
const root = document.documentElement
|
|
7
|
-
const raw = getComputedStyle(root).getPropertyValue(name).trim()
|
|
8
|
-
const value = parseFloat(raw)
|
|
9
|
-
return raw.endsWith('rem') ? value * parseFloat(getComputedStyle(root).fontSize) : value
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
// Observe the content row (full panel width — stable regardless of whether the
|
|
13
|
-
// chat is docked) and dock the chat only while the widget area would stay at
|
|
14
|
-
// its content width (--column-w) once the chat takes its minimum (--chat-min).
|
|
15
|
-
// Measuring the widget area element directly would oscillate: docking shrinks
|
|
16
|
-
// it back under the threshold, which would undock it, which would grow it, etc.
|
|
17
|
-
export function useFitsSidebar<T extends HTMLElement>() {
|
|
18
|
-
const ref = useRef<T>(null)
|
|
19
|
-
const [fits, setFits] = useState(false)
|
|
20
|
-
|
|
21
|
-
useEffect(() => {
|
|
22
|
-
const el = ref.current
|
|
23
|
-
if (!el) return
|
|
24
|
-
const minWidget = tokenPx('--column-w')
|
|
25
|
-
const chatMin = tokenPx('--chat-min')
|
|
26
|
-
const ro = new ResizeObserver(([entry]) => {
|
|
27
|
-
if (entry) setFits(entry.contentRect.width - chatMin >= minWidget)
|
|
28
|
-
})
|
|
29
|
-
ro.observe(el)
|
|
30
|
-
return () => ro.disconnect()
|
|
31
|
-
}, [])
|
|
32
|
-
|
|
33
|
-
return { ref, fits }
|
|
34
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { type RefObject, useEffect, useRef, useState } from 'react'
|
|
2
|
-
|
|
3
|
-
type ScrollFadeState = {
|
|
4
|
-
ref: RefObject<HTMLDivElement | null>
|
|
5
|
-
showTopFade: boolean
|
|
6
|
-
showBottomFade: boolean
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export function useScrollFade(): ScrollFadeState {
|
|
10
|
-
const ref = useRef<HTMLDivElement>(null)
|
|
11
|
-
const [showTopFade, setShowTopFade] = useState(false)
|
|
12
|
-
const [showBottomFade, setShowBottomFade] = useState(false)
|
|
13
|
-
|
|
14
|
-
useEffect(() => {
|
|
15
|
-
const el = ref.current
|
|
16
|
-
if (!el) return
|
|
17
|
-
|
|
18
|
-
const updateFades = () => {
|
|
19
|
-
const atTop = el.scrollTop <= 1
|
|
20
|
-
const atBottom = el.scrollTop + el.clientHeight >= el.scrollHeight - 1
|
|
21
|
-
const scrollable = el.scrollHeight > el.clientHeight + 1
|
|
22
|
-
|
|
23
|
-
setShowTopFade(scrollable && !atTop)
|
|
24
|
-
setShowBottomFade(scrollable && !atBottom)
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
updateFades()
|
|
28
|
-
el.addEventListener('scroll', updateFades, { passive: true })
|
|
29
|
-
window.addEventListener('resize', updateFades)
|
|
30
|
-
|
|
31
|
-
return () => {
|
|
32
|
-
el.removeEventListener('scroll', updateFades)
|
|
33
|
-
window.removeEventListener('resize', updateFades)
|
|
34
|
-
}
|
|
35
|
-
}, [])
|
|
36
|
-
|
|
37
|
-
return { ref, showTopFade, showBottomFade }
|
|
38
|
-
}
|