moi-computer 0.9.1-next.5 → 0.10.0
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 +124 -58
- package/client/app/shell/SidebarLayout.tsx +111 -79
- package/client/features/chat/ChatEmptyState.tsx +70 -34
- package/client/features/chat/ChatPanel.tsx +8 -1
- package/client/features/chat/chat-store.ts +4 -0
- package/client/features/home/workspace-setup/WorkspaceAgentStep.tsx +22 -5
- package/client/features/update/Update.tsx +78 -0
- package/client/features/update/api.ts +35 -0
- package/client/features/workspace/WorkspaceScreen.tsx +15 -0
- package/dist/{chunk-yt2qjn3m.js → chunk-0set7tmf.js} +2 -2
- package/dist/chunk-4057kxht.css +1 -0
- package/dist/{chunk-te5sfhvx.js → chunk-5t06zksf.js} +2 -2
- package/dist/{chunk-9y2zbzqz.js → chunk-97eg9mjn.js} +1 -1
- package/dist/chunk-b5c62p8h.js +1 -0
- package/dist/chunk-dfe7qnrp.js +1 -0
- package/dist/{chunk-0pcdwjkp.js → chunk-efdyz6xp.js} +1 -1
- package/dist/chunk-f6xmz3tn.js +83 -0
- package/dist/chunk-h2kj1ysj.js +1 -0
- package/dist/{chunk-yhj9bg1s.js → chunk-ht1f95h9.js} +2 -2
- package/dist/chunk-qtc5a8qa.js +10 -0
- package/dist/index.html +1 -1
- package/lib/types.ts +9 -0
- package/lib/update.ts +2 -0
- package/package.json +1 -1
- package/server/api.ts +46 -0
- package/server/cli.ts +7 -6
- package/server/constants.ts +4 -2
- package/server/update.ts +293 -5
- package/server/web.ts +1 -1
- package/dist/chunk-4xmcsjjv.js +0 -1
- package/dist/chunk-9m59hf8p.js +0 -10
- package/dist/chunk-dfs36zgc.js +0 -1
- package/dist/chunk-hffvjnmj.js +0 -85
- package/dist/chunk-pq93pv5z.js +0 -1
- package/dist/chunk-xtr8kvqx.css +0 -1
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
2
|
IconArticle,
|
|
3
|
-
IconBriefcase,
|
|
4
3
|
IconFileSearch,
|
|
5
4
|
IconGhost,
|
|
6
5
|
IconLayout2,
|
|
@@ -9,6 +8,7 @@ import {
|
|
|
9
8
|
IconSketching,
|
|
10
9
|
IconTableSpark,
|
|
11
10
|
IconUmbrella2,
|
|
11
|
+
IconWallet,
|
|
12
12
|
type TablerIcon
|
|
13
13
|
} from '@tabler/icons-react'
|
|
14
14
|
|
|
@@ -24,7 +24,7 @@ const ONBOARDING_HANDOFF_DIRECTIVE =
|
|
|
24
24
|
|
|
25
25
|
export const CHAT_WELCOME_PROMPTS = [
|
|
26
26
|
{
|
|
27
|
-
label:
|
|
27
|
+
label: 'Check the weather',
|
|
28
28
|
prompt:
|
|
29
29
|
"Build me a set of weather widgets that surface current conditions, today's hourly forecast, and a simple weekly outlook at a glance",
|
|
30
30
|
context: [
|
|
@@ -38,7 +38,23 @@ export const CHAT_WELCOME_PROMPTS = [
|
|
|
38
38
|
icon: IconUmbrella2
|
|
39
39
|
},
|
|
40
40
|
{
|
|
41
|
-
label: '
|
|
41
|
+
label: 'Track my finances',
|
|
42
|
+
prompt:
|
|
43
|
+
'Build me a personal finance view for tracking income, expenses, monthly budgets, spending trends, and savings, with an agent action that can add sample transactions',
|
|
44
|
+
context: [
|
|
45
|
+
"Build this onboarding example immediately without asking follow-up questions, and don't use external services or bank connections.",
|
|
46
|
+
'Create a responsive View with a month selector, income, spending, and savings summaries, an income-versus-spending trend, category breakdowns, budget progress, and recent transactions.',
|
|
47
|
+
'Support adding, editing, and deleting income and expense transactions, categories, and monthly category budgets.',
|
|
48
|
+
'Persist transactions, categories, and budgets in a workspace-local SQLite database accessed through server functions. Store monetary amounts as integer cents and seed realistic sample data only when the database is empty.',
|
|
49
|
+
'Add an “Add with agent” action that imports `sendChatMessage` from `moi` and sends a concise request for the agent to generate and insert a realistic batch of sample transactions into the same database.',
|
|
50
|
+
'Provide a small documented workspace script the agent can use to validate and append transactions safely, then refresh the View data after the agent updates the database.',
|
|
51
|
+
'Include loading, empty, and error states, then bundle the View and smoke-test its SQLite persistence and transaction mutations before finishing.',
|
|
52
|
+
ONBOARDING_HANDOFF_DIRECTIVE
|
|
53
|
+
],
|
|
54
|
+
icon: IconWallet
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
label: 'Build a playful synthesizer',
|
|
42
58
|
prompt:
|
|
43
59
|
'Build me a view with a simple, playful synthesizer featuring a keyboard, five sound controls, and the ability to record, save, and load music files from the workspace',
|
|
44
60
|
context: [
|
|
@@ -50,22 +66,6 @@ export const CHAT_WELCOME_PROMPTS = [
|
|
|
50
66
|
ONBOARDING_HANDOFF_DIRECTIVE
|
|
51
67
|
],
|
|
52
68
|
icon: IconPiano
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
label: 'Make a job tracker',
|
|
56
|
-
prompt:
|
|
57
|
-
'Build me a view with a visual job search board where I can add opportunities by pasting a job link, automatically extract the details, move opportunities through stages, and keep notes and related files in the workspace',
|
|
58
|
-
context: [
|
|
59
|
-
'Build this onboarding example immediately without asking follow-up questions.',
|
|
60
|
-
'Create a visual View with Saved, Applied, Interviewing, Offer, and Closed stages.',
|
|
61
|
-
'Let the user add a job by pasting its URL, and use a server function to parse public metadata for the title, company, and location.',
|
|
62
|
-
'When a page blocks parsing or lacks metadata, keep the URL and provide editable manual fields.',
|
|
63
|
-
'Support moving opportunities between stages, editing their details and notes, and referencing related workspace files.',
|
|
64
|
-
'Persist the board in a workspace-local JSON file and include loading, empty, and error states.',
|
|
65
|
-
'Bundle the View and smoke-test its persistence and parsing functions before finishing.',
|
|
66
|
-
ONBOARDING_HANDOFF_DIRECTIVE
|
|
67
|
-
],
|
|
68
|
-
icon: IconBriefcase
|
|
69
69
|
}
|
|
70
70
|
] satisfies ChatPrompt[]
|
|
71
71
|
|
|
@@ -82,6 +82,7 @@ export const WORKSPACE_ANALYSIS_PROMPT = {
|
|
|
82
82
|
} satisfies ChatPrompt
|
|
83
83
|
|
|
84
84
|
export type ChatEmptyStateKind = 'view-builder' | 'chat-welcome' | 'workspace-welcome' | 'empty'
|
|
85
|
+
export type ChatWelcomeDestination = 'agent' | 'widgets' | 'views' | 'scratchpad'
|
|
85
86
|
|
|
86
87
|
type ResolveChatEmptyStateOptions = {
|
|
87
88
|
isViewBuilderDraft: boolean
|
|
@@ -106,14 +107,22 @@ type ChatEmptyStateProps = {
|
|
|
106
107
|
kind: ChatEmptyStateKind
|
|
107
108
|
disabled?: boolean
|
|
108
109
|
onSelectPrompt: (prompt: ChatPrompt) => void
|
|
110
|
+
onNavigate: (destination: ChatWelcomeDestination) => void
|
|
109
111
|
}
|
|
110
112
|
|
|
111
|
-
export function ChatEmptyState({
|
|
113
|
+
export function ChatEmptyState({
|
|
114
|
+
kind,
|
|
115
|
+
disabled = false,
|
|
116
|
+
onSelectPrompt,
|
|
117
|
+
onNavigate
|
|
118
|
+
}: ChatEmptyStateProps) {
|
|
112
119
|
switch (kind) {
|
|
113
120
|
case 'view-builder':
|
|
114
121
|
return <ViewBuilderChatEmptyState />
|
|
115
122
|
case 'chat-welcome':
|
|
116
|
-
return
|
|
123
|
+
return (
|
|
124
|
+
<ChatWelcome disabled={disabled} onSelectPrompt={onSelectPrompt} onNavigate={onNavigate} />
|
|
125
|
+
)
|
|
117
126
|
case 'workspace-welcome':
|
|
118
127
|
return <ChatWorkspaceWelcome disabled={disabled} onSelectPrompt={onSelectPrompt} />
|
|
119
128
|
case 'empty':
|
|
@@ -137,7 +146,11 @@ type WelcomeProps = {
|
|
|
137
146
|
onSelectPrompt: (prompt: ChatPrompt) => void
|
|
138
147
|
}
|
|
139
148
|
|
|
140
|
-
|
|
149
|
+
type ChatWelcomeProps = WelcomeProps & {
|
|
150
|
+
onNavigate: (destination: ChatWelcomeDestination) => void
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export function ChatWelcome({ disabled = false, onSelectPrompt, onNavigate }: ChatWelcomeProps) {
|
|
141
154
|
return (
|
|
142
155
|
<div className={cn(EMPTY_STATE_STYLES, '@container w-full max-w-md min-w-0')}>
|
|
143
156
|
<div className="prose prose-sm min-w-0 wrap-anywhere prose-inherit">
|
|
@@ -146,13 +159,25 @@ export function ChatWelcome({ disabled = false, onSelectPrompt }: WelcomeProps)
|
|
|
146
159
|
doing.
|
|
147
160
|
</p>
|
|
148
161
|
<p>
|
|
149
|
-
Ask
|
|
150
|
-
<WelcomeTerm Icon={
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
162
|
+
Ask{' '}
|
|
163
|
+
<WelcomeTerm Icon={IconGhost} destination="agent" onNavigate={onNavigate}>
|
|
164
|
+
Agent
|
|
165
|
+
</WelcomeTerm>{' '}
|
|
166
|
+
to build{' '}
|
|
167
|
+
<WelcomeTerm Icon={IconLayout2} destination="widgets" onNavigate={onNavigate}>
|
|
168
|
+
Widgets
|
|
169
|
+
</WelcomeTerm>{' '}
|
|
170
|
+
that surface information and quick actions, or entire{' '}
|
|
171
|
+
<WelcomeTerm Icon={IconArticle} destination="views" onNavigate={onNavigate}>
|
|
172
|
+
Views
|
|
173
|
+
</WelcomeTerm>{' '}
|
|
174
|
+
for more complex tools. Use{' '}
|
|
175
|
+
<WelcomeTerm Icon={IconSketching} destination="scratchpad" onNavigate={onNavigate}>
|
|
176
|
+
Scratchpad
|
|
177
|
+
</WelcomeTerm>{' '}
|
|
178
|
+
for exploring and shaping ideas with your agent.
|
|
154
179
|
</p>
|
|
155
|
-
<p>
|
|
180
|
+
<p>Try an example:</p>
|
|
156
181
|
</div>
|
|
157
182
|
<ChatPromptBubbles
|
|
158
183
|
prompts={CHAT_WELCOME_PROMPTS}
|
|
@@ -166,8 +191,12 @@ export function ChatWelcome({ disabled = false, onSelectPrompt }: WelcomeProps)
|
|
|
166
191
|
export function ChatWorkspaceWelcome({ disabled = false, onSelectPrompt }: WelcomeProps) {
|
|
167
192
|
return (
|
|
168
193
|
<div className={cn(EMPTY_STATE_STYLES, 'gap-2')}>
|
|
169
|
-
<div className="prose prose-sm max-w-
|
|
170
|
-
<p
|
|
194
|
+
<div className="prose prose-sm max-w-xs min-w-0 text-center wrap-anywhere prose-inherit">
|
|
195
|
+
<p className="font-medium text-foreground">Start with what’s already here</p>
|
|
196
|
+
<p className="text-muted-foreground">
|
|
197
|
+
Your agent can explore this workspace and suggest useful widgets and views based on its
|
|
198
|
+
contents.
|
|
199
|
+
</p>
|
|
171
200
|
</div>
|
|
172
201
|
<ChatPromptBubble
|
|
173
202
|
prompt={WORKSPACE_ANALYSIS_PROMPT}
|
|
@@ -192,13 +221,20 @@ function EmptyState() {
|
|
|
192
221
|
type WelcomeTermProps = {
|
|
193
222
|
Icon: TablerIcon
|
|
194
223
|
children: string
|
|
224
|
+
destination: ChatWelcomeDestination
|
|
225
|
+
onNavigate: (destination: ChatWelcomeDestination) => void
|
|
195
226
|
}
|
|
196
227
|
|
|
197
|
-
function WelcomeTerm({ Icon, children }: WelcomeTermProps) {
|
|
228
|
+
function WelcomeTerm({ Icon, children, destination, onNavigate }: WelcomeTermProps) {
|
|
198
229
|
return (
|
|
199
|
-
<
|
|
200
|
-
|
|
230
|
+
<button
|
|
231
|
+
type="button"
|
|
232
|
+
data-welcome-destination={destination}
|
|
233
|
+
onClick={() => onNavigate(destination)}
|
|
234
|
+
className="-mx-0.5 inline-flex cursor-pointer items-center gap-0.5 rounded-xs px-0.5 align-bottom font-medium text-foreground hover:bg-accent focus-visible:bg-accent focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-ring"
|
|
235
|
+
>
|
|
236
|
+
<Icon size={16} stroke={1.75} aria-hidden />
|
|
201
237
|
{children}
|
|
202
|
-
</
|
|
238
|
+
</button>
|
|
203
239
|
)
|
|
204
240
|
}
|
|
@@ -18,7 +18,11 @@ import type { SystemNotice, Turn, ViewState } from '@/lib/types'
|
|
|
18
18
|
|
|
19
19
|
import type { ComposerBanner } from './composer/banners/ComposerBanner'
|
|
20
20
|
import { ChatComposer, type ComposerAnnotationControls } from './composer/ChatComposer'
|
|
21
|
-
import {
|
|
21
|
+
import {
|
|
22
|
+
ChatEmptyState,
|
|
23
|
+
type ChatWelcomeDestination,
|
|
24
|
+
resolveChatEmptyState
|
|
25
|
+
} from './ChatEmptyState'
|
|
22
26
|
import { ChatSelector } from './ChatSelector'
|
|
23
27
|
import { ThinkingIndicator, TurnView } from './TurnView'
|
|
24
28
|
import { Button } from '@/client/components/ui/button'
|
|
@@ -57,6 +61,7 @@ type ChatPanelProps = {
|
|
|
57
61
|
annotation?: ComposerAnnotationControls
|
|
58
62
|
send: (text: string, options?: ChatSendOptions) => void
|
|
59
63
|
stop: () => void
|
|
64
|
+
onNavigateFromWelcome: (destination: ChatWelcomeDestination) => void
|
|
60
65
|
// Chat on a separate tab doesn't have a close button
|
|
61
66
|
onClose?: () => void
|
|
62
67
|
builderDraft?: ViewBuilderChatDraft
|
|
@@ -79,6 +84,7 @@ export function ChatPanel({
|
|
|
79
84
|
annotation,
|
|
80
85
|
send,
|
|
81
86
|
stop,
|
|
87
|
+
onNavigateFromWelcome,
|
|
82
88
|
onClose,
|
|
83
89
|
builderDraft
|
|
84
90
|
}: ChatPanelProps) {
|
|
@@ -190,6 +196,7 @@ export function ChatPanel({
|
|
|
190
196
|
kind={emptyStateKind}
|
|
191
197
|
disabled={promptDisabled}
|
|
192
198
|
onSelectPrompt={handlePromptSelect}
|
|
199
|
+
onNavigate={onNavigateFromWelcome}
|
|
193
200
|
/>
|
|
194
201
|
)}
|
|
195
202
|
{timeline.map(item =>
|
|
@@ -57,6 +57,10 @@ export function isRunningActivity(activity: SessionActivity | undefined): boolea
|
|
|
57
57
|
return activity === 'running'
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
+
export function hasRunningActivity(activity: Record<string, SessionActivity>): boolean {
|
|
61
|
+
return Object.values(activity).some(isRunningActivity)
|
|
62
|
+
}
|
|
63
|
+
|
|
60
64
|
export function isSessionRunning(
|
|
61
65
|
activity: Record<string, SessionActivity>,
|
|
62
66
|
workspaceId: string,
|
|
@@ -18,8 +18,12 @@ const WORKSPACE_AGENT_DESCRIPTION = 'Choose which agent moi will use to build yo
|
|
|
18
18
|
// Backends whose workspaces belong to an agent installed on the machine: moi
|
|
19
19
|
// imports them (via discovery or `moi <provider> init`) and never creates one.
|
|
20
20
|
const IMPORT_ONLY_DESCRIPTION: Partial<Record<WorkspaceType, string>> = {
|
|
21
|
-
openclaw: '
|
|
22
|
-
hermes: '
|
|
21
|
+
openclaw: 'To connect an OpenClaw agent, run',
|
|
22
|
+
hermes: 'To connect a Hermes agent, run'
|
|
23
|
+
}
|
|
24
|
+
const IMPORT_ONLY_COMMAND: Partial<Record<WorkspaceType, string>> = {
|
|
25
|
+
openclaw: 'moi openclaw init',
|
|
26
|
+
hermes: 'moi hermes init'
|
|
23
27
|
}
|
|
24
28
|
|
|
25
29
|
const workspaceAgentDescription: Record<WorkspaceType, string> = {
|
|
@@ -34,6 +38,7 @@ export type WorkspaceAgentOption = {
|
|
|
34
38
|
description: string
|
|
35
39
|
disabled: boolean
|
|
36
40
|
disabledReason?: string
|
|
41
|
+
disabledCommand?: string
|
|
37
42
|
}
|
|
38
43
|
|
|
39
44
|
type WorkspaceAgentOptionsInput = {
|
|
@@ -51,13 +56,15 @@ export function getWorkspaceAgentOptions({
|
|
|
51
56
|
const importOnlyReason = !detectedTypes.includes(type)
|
|
52
57
|
? IMPORT_ONLY_DESCRIPTION[type]
|
|
53
58
|
: undefined
|
|
59
|
+
const importOnlyCommand = !detectedTypes.includes(type) ? IMPORT_ONLY_COMMAND[type] : undefined
|
|
54
60
|
const disabledReason = unavailableReason ?? importOnlyReason
|
|
55
61
|
|
|
56
62
|
return {
|
|
57
63
|
type,
|
|
58
64
|
description: workspaceAgentDescription[type],
|
|
59
65
|
disabled: Boolean(disabledReason),
|
|
60
|
-
...(disabledReason ? { disabledReason } : {})
|
|
66
|
+
...(disabledReason ? { disabledReason } : {}),
|
|
67
|
+
...(!unavailableReason && importOnlyCommand ? { disabledCommand: importOnlyCommand } : {})
|
|
61
68
|
}
|
|
62
69
|
})
|
|
63
70
|
}
|
|
@@ -233,8 +240,18 @@ function WorkspaceAgentOptionButton({
|
|
|
233
240
|
return (
|
|
234
241
|
<Tooltip>
|
|
235
242
|
<TooltipTrigger render={button} />
|
|
236
|
-
<TooltipContent className=
|
|
237
|
-
|
|
243
|
+
<TooltipContent className={cn('max-w-64', option.disabledCommand && 'max-w-none leading-5')}>
|
|
244
|
+
<span className="text-center">
|
|
245
|
+
{option.disabledReason}
|
|
246
|
+
{option.disabledCommand && (
|
|
247
|
+
<>
|
|
248
|
+
<br />
|
|
249
|
+
<code className="rounded-xs bg-accent px-1 py-0.5 font-mono whitespace-nowrap">
|
|
250
|
+
{option.disabledCommand}
|
|
251
|
+
</code>
|
|
252
|
+
</>
|
|
253
|
+
)}
|
|
254
|
+
</span>
|
|
238
255
|
</TooltipContent>
|
|
239
256
|
</Tooltip>
|
|
240
257
|
)
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { useEffect } from 'react'
|
|
2
|
+
|
|
3
|
+
import { IconDownload } from '@tabler/icons-react'
|
|
4
|
+
|
|
5
|
+
import { Button } from '@/client/components/ui/button'
|
|
6
|
+
import { Spinner } from '@/client/components/ui/spinner'
|
|
7
|
+
import { Tooltip, TooltipContent, TooltipTrigger } from '@/client/components/ui/tooltip'
|
|
8
|
+
import { hasRunningActivity, useLive } from '@/client/features/chat/chat-store'
|
|
9
|
+
import { UPDATE_ACTIVE_AGENT_MESSAGE } from '@/lib/update'
|
|
10
|
+
import type { UpdateStatus } from '@/lib/types'
|
|
11
|
+
|
|
12
|
+
import { useUpdate, useUpdateStatus } from './api'
|
|
13
|
+
|
|
14
|
+
export function shouldReloadAfterUpdate(
|
|
15
|
+
status: UpdateStatus | undefined,
|
|
16
|
+
targetVersion: string | null
|
|
17
|
+
): boolean {
|
|
18
|
+
return !!targetVersion && status?.runningVersion === targetVersion
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function getUpdateButtonState(
|
|
22
|
+
agentRunning: boolean,
|
|
23
|
+
updating: boolean,
|
|
24
|
+
restarting: boolean
|
|
25
|
+
) {
|
|
26
|
+
const busy = updating || restarting
|
|
27
|
+
const blocked = agentRunning && !busy
|
|
28
|
+
const label = updating
|
|
29
|
+
? 'Updating'
|
|
30
|
+
: restarting
|
|
31
|
+
? 'Restarting'
|
|
32
|
+
: blocked
|
|
33
|
+
? UPDATE_ACTIVE_AGENT_MESSAGE
|
|
34
|
+
: 'Update'
|
|
35
|
+
return { busy, blocked, label }
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function Update() {
|
|
39
|
+
const update = useUpdate()
|
|
40
|
+
const statusQuery = useUpdateStatus(update.isSuccess)
|
|
41
|
+
const agentRunning = useLive(state => hasRunningActivity(state.activity))
|
|
42
|
+
const status = statusQuery.data
|
|
43
|
+
const restartTarget = update.data?.installedVersion ?? null
|
|
44
|
+
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
if (shouldReloadAfterUpdate(status, restartTarget)) window.location.reload()
|
|
47
|
+
}, [restartTarget, status])
|
|
48
|
+
|
|
49
|
+
if (!status?.availableVersion) return null
|
|
50
|
+
|
|
51
|
+
const restarting = update.isSuccess
|
|
52
|
+
const button = getUpdateButtonState(agentRunning, update.isPending, restarting)
|
|
53
|
+
|
|
54
|
+
// The div gives TooltipTrigger an enabled event target when the button is disabled.
|
|
55
|
+
return (
|
|
56
|
+
<Tooltip>
|
|
57
|
+
<TooltipTrigger
|
|
58
|
+
render={
|
|
59
|
+
<div>
|
|
60
|
+
<Button
|
|
61
|
+
type="button"
|
|
62
|
+
size="icon"
|
|
63
|
+
variant={button.busy ? 'ghost' : 'default'}
|
|
64
|
+
aria-label={button.label}
|
|
65
|
+
disabled={button.blocked || button.busy}
|
|
66
|
+
onClick={() => update.mutate()}
|
|
67
|
+
>
|
|
68
|
+
{button.busy ? <Spinner stroke={1.5} /> : <IconDownload stroke={1.5} />}
|
|
69
|
+
</Button>
|
|
70
|
+
</div>
|
|
71
|
+
}
|
|
72
|
+
/>
|
|
73
|
+
<TooltipContent side="right" className={button.blocked ? 'max-w-56' : undefined}>
|
|
74
|
+
{button.blocked ? UPDATE_ACTIVE_AGENT_MESSAGE : (update.error?.message ?? button.label)}
|
|
75
|
+
</TooltipContent>
|
|
76
|
+
</Tooltip>
|
|
77
|
+
)
|
|
78
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { useMutation, useQuery } from '@tanstack/react-query'
|
|
2
|
+
|
|
3
|
+
import { requestJson } from '@/client/api/http'
|
|
4
|
+
import type { UpdateResult, UpdateStatus } from '@/lib/types'
|
|
5
|
+
|
|
6
|
+
export const updateKey = ['update'] as const
|
|
7
|
+
|
|
8
|
+
// The server decides how often the npm registry is actually consulted and
|
|
9
|
+
// serves a cached answer in between, so polling here is a local memory read.
|
|
10
|
+
// Keep it frequent enough that a tab left open all day stays current — and note
|
|
11
|
+
// React Query pauses intervals while the tab is hidden, so a background window
|
|
12
|
+
// costs nothing and catches up on focus instead.
|
|
13
|
+
const UPDATE_POLL_INTERVAL_MS = 5 * 60 * 1000
|
|
14
|
+
const RESTART_POLL_INTERVAL_MS = 1000
|
|
15
|
+
|
|
16
|
+
export function useUpdateStatus(restarting: boolean) {
|
|
17
|
+
return useQuery<UpdateStatus>({
|
|
18
|
+
queryKey: updateKey,
|
|
19
|
+
queryFn: () => requestJson('/api/update'),
|
|
20
|
+
staleTime: UPDATE_POLL_INTERVAL_MS,
|
|
21
|
+
refetchInterval: restarting ? RESTART_POLL_INTERVAL_MS : UPDATE_POLL_INTERVAL_MS,
|
|
22
|
+
// A tab that sat in the background for days is stale by definition; give it
|
|
23
|
+
// a fresh answer the moment someone looks at it.
|
|
24
|
+
refetchOnWindowFocus: true,
|
|
25
|
+
// While the server is restarting every request fails until it is back. The
|
|
26
|
+
// poll interval is the retry.
|
|
27
|
+
retry: false
|
|
28
|
+
})
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function useUpdate() {
|
|
32
|
+
return useMutation<UpdateResult, Error>({
|
|
33
|
+
mutationFn: () => requestJson('/api/update', { method: 'POST' }, 'Could not update moi')
|
|
34
|
+
})
|
|
35
|
+
}
|
|
@@ -16,6 +16,7 @@ import { DrawingLayer } from '@/client/features/drawings/DrawingLayer'
|
|
|
16
16
|
import { DrawingToolbar } from '@/client/features/drawings/DrawingToolbar'
|
|
17
17
|
import { useChatAnnotation } from '@/client/features/drawings/useChatAnnotation'
|
|
18
18
|
import { ChatPanel } from '@/client/features/chat/ChatPanel'
|
|
19
|
+
import type { ChatWelcomeDestination } from '@/client/features/chat/ChatEmptyState'
|
|
19
20
|
import { ChatPopup } from '@/client/features/chat/ChatPopup'
|
|
20
21
|
import { CustomizePanel } from '@/client/features/workspace/CustomizePanel'
|
|
21
22
|
import { useAppletEvent } from '@/client/features/applets/applet-runtime'
|
|
@@ -392,6 +393,17 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
|
|
|
392
393
|
}
|
|
393
394
|
}
|
|
394
395
|
|
|
396
|
+
const navigateFromWelcome = (destination: ChatWelcomeDestination) => {
|
|
397
|
+
if (destination === 'views') {
|
|
398
|
+
const firstView = views[0]
|
|
399
|
+
if (firstView) openTab(viewTabId(firstView.id))
|
|
400
|
+
else void builderActions.create().then(builder => openTab(viewBuilderTabId(builder.id)))
|
|
401
|
+
} else {
|
|
402
|
+
openTab(destination)
|
|
403
|
+
}
|
|
404
|
+
setFloatingChatOpen(false)
|
|
405
|
+
}
|
|
406
|
+
|
|
395
407
|
// Focus requests from applet bridges arrive here already validated — the
|
|
396
408
|
// applet runtime narrows the untrusted tab id and params shape at the trust
|
|
397
409
|
// boundary (applet-runtime.ts). A well-formed id for a missing view just
|
|
@@ -571,6 +583,7 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
|
|
|
571
583
|
composerAvailability={composerAvailability}
|
|
572
584
|
send={send}
|
|
573
585
|
stop={stop}
|
|
586
|
+
onNavigateFromWelcome={navigateFromWelcome}
|
|
574
587
|
onClose={() => setMode('fullscreen')}
|
|
575
588
|
annotation={annotation.docked}
|
|
576
589
|
builderDraft={builderChatDraft}
|
|
@@ -591,6 +604,7 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
|
|
|
591
604
|
composerAvailability={composerAvailability}
|
|
592
605
|
send={send}
|
|
593
606
|
stop={stop}
|
|
607
|
+
onNavigateFromWelcome={navigateFromWelcome}
|
|
594
608
|
/>
|
|
595
609
|
)
|
|
596
610
|
const workspacePanel = (
|
|
@@ -746,6 +760,7 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
|
|
|
746
760
|
composerAvailability={composerAvailability}
|
|
747
761
|
send={send}
|
|
748
762
|
stop={stop}
|
|
763
|
+
onNavigateFromWelcome={navigateFromWelcome}
|
|
749
764
|
onClose={onClose}
|
|
750
765
|
annotation={annotation.popup}
|
|
751
766
|
builderDraft={builderChatDraft}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
export{u as
|
|
1
|
+
import{Sc as w,Uc as s}from"/chunk-ht1f95h9.js";import{Wc as q}from"/chunk-97eg9mjn.js";var R=q(w(),1);async function i(o,t){let a=await o.text();return Error(a||t)}async function u(o,t,a="Request failed"){let n=await fetch(o,t);if(!n.ok)throw await i(n,a);return n.json()}async function T(o,t,a="Request failed"){let n=await fetch(o,t);if(!n.ok)throw await i(n,a)}function y(o,t){return{method:o,headers:{"Content-Type":"application/json"},body:t===void 0?void 0:JSON.stringify(t)}}var r={cloudDemo:!1,experiments:[],demoInstallUrl:"https://moi.computer"},d=r,e=new Set;function I(o){return e.add(o),()=>{e.delete(o)}}async function f(){try{d=await u("/api/config");for(let o of e)o()}catch{}}async function c(){await f(),s(()=>{f()})}function h(){return R.useSyncExternalStore(I,()=>d)}
|
|
2
|
+
export{u as Nc,T as Oc,y as Pc,c as Qc,h as Rc};
|