moi-computer 0.10.1-next.2 → 0.10.1-next.4

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.
Files changed (71) hide show
  1. package/client/app/shell/SidebarLayout.tsx +53 -14
  2. package/client/components/shared/AgentBlobatar.tsx +3 -3
  3. package/client/components/shared/Composer.tsx +4 -10
  4. package/client/features/chat/ChatEmptyState.tsx +2 -9
  5. package/client/features/chat/ChatPanel.tsx +21 -23
  6. package/client/features/chat/ChatPopup.tsx +1 -2
  7. package/client/features/chat/composer/ChatComposer.tsx +2 -2
  8. package/client/features/chat/composer/banners/AgentAvailabilityBanner.tsx +101 -0
  9. package/client/features/chat/composer/banners/{ChatErrorBanner.tsx → ErrorBanner.tsx} +2 -2
  10. package/client/features/chat/composer/banners/{WorkspaceSkillUpdateBanner.tsx → SkillUpdateBanner.tsx} +3 -3
  11. package/client/features/chat/composer/useWorkspaceComposerState.tsx +14 -24
  12. package/client/features/chat/composer/useWorkspaceSkillUpdates.ts +6 -6
  13. package/client/features/chat/useAppletChatMessage.ts +9 -5
  14. package/client/features/dev/BlobatarShapesPage.tsx +344 -0
  15. package/client/features/dev/ChatStatesPage.tsx +3 -4
  16. package/client/features/dev/DevIndexPage.tsx +5 -0
  17. package/client/features/dev/DevRoutes.tsx +2 -0
  18. package/client/features/home/HomePage.tsx +47 -5
  19. package/client/features/home/WorkspacePreview.tsx +4 -4
  20. package/client/features/home/workspace-setup/WorkspaceAgentStep.tsx +1 -1
  21. package/client/features/update/{Update.tsx → UpdateControl.tsx} +33 -9
  22. package/client/features/workspace/CustomizePanel.tsx +1 -1
  23. package/client/features/workspace/WorkspaceScreen.tsx +5 -5
  24. package/client/features/workspace/api.ts +10 -1
  25. package/client/index.css +6 -1
  26. package/client/index.html +15 -0
  27. package/client/lib/agent-availability.ts +19 -0
  28. package/client/runtime/useWorkspaceEvents.ts +16 -2
  29. package/client/runtime/workspace-theme.ts +2 -8
  30. package/dist/chunk-104m57qw.js +2 -0
  31. package/dist/chunk-4vyggdzq.css +1 -0
  32. package/dist/chunk-bj3akjs2.js +1 -0
  33. package/dist/{chunk-0pcdwjkp.js → chunk-c9pjqx9m.js} +1 -1
  34. package/dist/chunk-gbp4m9p2.js +1 -0
  35. package/dist/{chunk-8jh75pjg.js → chunk-j2w2vak4.js} +2 -2
  36. package/dist/chunk-jpdn7nx7.js +83 -0
  37. package/dist/chunk-k2r9c95m.js +10 -0
  38. package/dist/chunk-kmbxhgwv.js +1 -0
  39. package/dist/{chunk-yt2qjn3m.js → chunk-tny85yt2.js} +2 -2
  40. package/dist/{chunk-9y2zbzqz.js → chunk-v7wr1df4.js} +1 -1
  41. package/dist/index.html +16 -1
  42. package/lib/themes.ts +31 -7
  43. package/lib/types.ts +9 -8
  44. package/package.json +1 -1
  45. package/server/AGENTS.md +1 -1
  46. package/server/agent.ts +46 -22
  47. package/server/api.ts +6 -6
  48. package/server/cli-ui-components.ts +63 -22
  49. package/server/harness/README.md +21 -12
  50. package/server/harness/claude-code/auth.ts +38 -23
  51. package/server/harness/claude-code/index.ts +1 -1
  52. package/server/harness/claude-code/permissions.ts +34 -0
  53. package/server/harness/claude-code/session.ts +7 -15
  54. package/server/harness/codex/auth.ts +31 -21
  55. package/server/harness/codex/client.ts +5 -14
  56. package/server/harness/codex/index.ts +1 -1
  57. package/server/harness/codex/permissions.ts +56 -0
  58. package/server/harness/codex/session.ts +25 -20
  59. package/server/harness/executable.ts +2 -2
  60. package/server/harness/hermes/index.ts +4 -5
  61. package/server/ui-components.ts +29 -0
  62. package/workspace/.claude/skills/moi-workspace/SKILL.md +10 -8
  63. package/workspace/.claude/skills/moi-workspace/references/UI-COMPONENTS.md +24 -21
  64. package/client/features/chat/composer/banners/WorkspaceAgentAvailabilityBanner.tsx +0 -82
  65. package/dist/chunk-4xmcsjjv.js +0 -1
  66. package/dist/chunk-dfs36zgc.js +0 -1
  67. package/dist/chunk-e4e993yf.js +0 -83
  68. package/dist/chunk-ek8w9tsp.css +0 -1
  69. package/dist/chunk-vq8ga42s.js +0 -1
  70. package/dist/chunk-yhj9bg1s.js +0 -2
  71. package/dist/chunk-yz743a75.js +0 -10
@@ -1,12 +1,17 @@
1
1
  import { type ReactNode } from 'react'
2
2
 
3
- import { IconAlertSquareRoundedFilled, IconPlus, IconSmartHome } from '@tabler/icons-react'
3
+ import {
4
+ IconAlertSquareRoundedFilled,
5
+ IconMessage2Share,
6
+ IconPlus,
7
+ IconSmartHome
8
+ } from '@tabler/icons-react'
4
9
  import { useQueryClient } from '@tanstack/react-query'
5
10
  import { Link, useLocation } from 'wouter'
6
11
 
7
12
  import { useAppConfig } from '@/client/api/app-config'
8
13
  import { useReorderWorkspaces, useWorkspaces } from '@/client/features/home/api'
9
- import { Update } from '@/client/features/update/Update'
14
+ import { UpdateButton, useUpdateControl } from '@/client/features/update/UpdateControl'
10
15
  import { workspaceKeys } from '@/client/api/workspace-keys'
11
16
  import { useWorkspaceEvent } from '@/client/runtime/useWorkspaceEvents'
12
17
  import { CreateWorkspaceDialog } from '@/client/features/home/workspace-setup/CreateWorkspaceDialog'
@@ -27,6 +32,8 @@ import {
27
32
  import { cn } from '@/client/lib/cn'
28
33
  import type { WorkspaceEntry } from '@/lib/types'
29
34
 
35
+ const FEEDBACK_URL = 'https://mlfrg.notion.site/3c678a44b6788042b734d775dd2e935e?pvs=105'
36
+
30
37
  function sidebarNavButtonClass(active: boolean): string {
31
38
  return cn(
32
39
  buttonVariants({ variant: 'ghost', size: 'icon' }),
@@ -72,7 +79,6 @@ type SidebarProps = {
72
79
 
73
80
  function Sidebar({ workspaces }: SidebarProps) {
74
81
  const reorder = useReorderWorkspaces()
75
- const { cloudDemo } = useAppConfig()
76
82
 
77
83
  return (
78
84
  <TooltipProvider delay={500}>
@@ -131,23 +137,56 @@ function Sidebar({ workspaces }: SidebarProps) {
131
137
  </nav>
132
138
 
133
139
  <div className="size-8 shrink-0">
134
- {cloudDemo ? (
135
- <DemoDialog
136
- trigger={
137
- <Button size="icon" aria-label="Unlock all features" title="Unlock all features">
138
- <IconAlertSquareRoundedFilled stroke={1.5} />
139
- </Button>
140
- }
141
- />
142
- ) : (
143
- <Update />
144
- )}
140
+ <SidebarFooterAction />
145
141
  </div>
146
142
  </aside>
147
143
  </TooltipProvider>
148
144
  )
149
145
  }
150
146
 
147
+ function SidebarFooterAction() {
148
+ const { cloudDemo } = useAppConfig()
149
+ const updateControl = useUpdateControl()
150
+
151
+ if (cloudDemo) {
152
+ return (
153
+ <DemoDialog
154
+ trigger={
155
+ <Button size="icon" aria-label="Unlock all features" title="Unlock all features">
156
+ <IconAlertSquareRoundedFilled stroke={1.5} />
157
+ </Button>
158
+ }
159
+ />
160
+ )
161
+ }
162
+
163
+ if (updateControl.status === 'loading') return null
164
+ if (updateControl.status === 'available') return <UpdateButton {...updateControl.button} />
165
+
166
+ return <FeedbackLink />
167
+ }
168
+
169
+ function FeedbackLink() {
170
+ return (
171
+ <Tooltip>
172
+ <TooltipTrigger
173
+ render={
174
+ <Button
175
+ render={<a href={FEEDBACK_URL} target="_blank" rel="noreferrer" />}
176
+ variant="ghost"
177
+ size="icon"
178
+ aria-label="Leave feedback"
179
+ className="text-muted-foreground hover:text-foreground"
180
+ >
181
+ <IconMessage2Share stroke={1.5} />
182
+ </Button>
183
+ }
184
+ />
185
+ <TooltipContent side="right">Leave feedback</TooltipContent>
186
+ </Tooltip>
187
+ )
188
+ }
189
+
151
190
  type WorkspaceButtonProps = {
152
191
  workspace: WorkspaceEntry
153
192
  dragOverlay?: boolean
@@ -61,7 +61,7 @@ const AGENT_EXPRESSIONS = {
61
61
  } satisfies Record<AgentBlobatarExpression, Expression>
62
62
 
63
63
  type AgentBlobatarProps = {
64
- size: number
64
+ size?: number
65
65
  preset?: AgentTheme
66
66
  animated?: boolean
67
67
  color?: AgentBlobatarColor
@@ -70,7 +70,7 @@ type AgentBlobatarProps = {
70
70
  }
71
71
 
72
72
  function AgentBlobatar({
73
- size,
73
+ size = 56,
74
74
  preset = DEFAULT_WORKSPACE_THEME.agent,
75
75
  animated = false,
76
76
  color = 'default',
@@ -85,7 +85,7 @@ function AgentBlobatar({
85
85
  palette={AGENT_PALETTES[color]}
86
86
  expression={expression ? AGENT_EXPRESSIONS[expression] : undefined}
87
87
  className={cn('shrink-0', className)}
88
- traits={{ shape: AGENT_THEMES[preset].shape }}
88
+ traits={AGENT_THEMES[preset].traits}
89
89
  />
90
90
  )
91
91
  }
@@ -5,6 +5,7 @@ import { IconArrowUp } from '@tabler/icons-react'
5
5
  import { Button } from '@/client/components/ui/button'
6
6
  import { Tooltip, TooltipContent, TooltipTrigger } from '@/client/components/ui/tooltip'
7
7
  import { cn } from '@/client/lib/cn'
8
+ import type { AgentAvailability } from '@/client/lib/agent-availability'
8
9
  import { Spinner } from '../ui/spinner'
9
10
 
10
11
  type ComposerProps = Omit<ComponentProps<'form'>, 'ref'> & {
@@ -77,14 +78,7 @@ export function ComposerFooter({ className, children, ...props }: ComposerFooter
77
78
  )
78
79
  }
79
80
 
80
- export type ComposerAvailability =
81
- | { status: 'checking' }
82
- | { status: 'available' }
83
- | { status: 'unavailable' }
84
-
85
- export function composerAvailabilityTooltip(
86
- availability: ComposerAvailability
87
- ): string | undefined {
81
+ export function composerAvailabilityTooltip(availability: AgentAvailability): string | undefined {
88
82
  if (availability.status === 'checking') return 'Checking agent status…'
89
83
  return undefined
90
84
  }
@@ -92,7 +86,7 @@ export function composerAvailabilityTooltip(
92
86
  export function canSubmitComposerAction(
93
87
  hasContent: boolean,
94
88
  busy: boolean,
95
- availability: ComposerAvailability
89
+ availability: AgentAvailability
96
90
  ): boolean {
97
91
  return hasContent && !busy && availability.status === 'available'
98
92
  }
@@ -102,7 +96,7 @@ type ComposerSubmitButtonProps = {
102
96
  hasContent: boolean
103
97
  busy?: boolean
104
98
  loading?: boolean
105
- availability: ComposerAvailability
99
+ availability: AgentAvailability
106
100
  }
107
101
 
108
102
  export function ComposerSubmitButton({
@@ -150,14 +150,7 @@ type EmptyStateFrameProps = {
150
150
  function EmptyStateFrame({ agent, children, className }: EmptyStateFrameProps) {
151
151
  return (
152
152
  <div className={cn('flex flex-1 flex-col items-center justify-center self-center', className)}>
153
- <AgentBlobatar
154
- preset={agent}
155
- color="secondary"
156
- expression="idle"
157
- size={64}
158
- className="mb-2"
159
- animated
160
- />
153
+ <AgentBlobatar preset={agent} color="secondary" expression="idle" className="mb-2" animated />
161
154
 
162
155
  {children}
163
156
  </div>
@@ -205,7 +198,7 @@ function WelcomeState({
205
198
  you're doing.
206
199
  </p>
207
200
  <p>
208
- Ask your agent to build{' '}
201
+ Ask agent to build{' '}
209
202
  <WelcomeTerm Icon={IconLayout2} destination="widgets" onNavigate={onNavigate}>
210
203
  Widgets
211
204
  </WelcomeTerm>{' '}
@@ -2,11 +2,7 @@ import { useCallback, useEffect, useLayoutEffect, useMemo, useRef } from 'react'
2
2
 
3
3
  import { IconChevronDown, IconChevronsRight, IconX } from '@tabler/icons-react'
4
4
 
5
- import {
6
- canSubmitComposerAction,
7
- type ComposerAvailability,
8
- focusComposer
9
- } from '@/client/components/shared/Composer'
5
+ import { canSubmitComposerAction, focusComposer } from '@/client/components/shared/Composer'
10
6
  import { AgentBlobatar } from '@/client/components/shared/AgentBlobatar'
11
7
  import { useStickToBottom } from '@/client/features/chat/useStickToBottom'
12
8
  import { groupTurns } from '@/client/features/chat/group-turns'
@@ -25,6 +21,7 @@ import { TurnView } from './TurnView'
25
21
  import { Button } from '@/client/components/ui/button'
26
22
  import { Tooltip, TooltipContent, TooltipTrigger } from '@/client/components/ui/tooltip'
27
23
  import { cn } from '@/client/lib/cn'
24
+ import type { AgentAvailability } from '@/client/lib/agent-availability'
28
25
  import { useUiStore } from '@/client/store/ui'
29
26
 
30
27
  export type ViewBuilderChatDraft = {
@@ -56,7 +53,7 @@ type ChatPanelProps = {
56
53
  sessionId?: string | null
57
54
  processing: boolean
58
55
  composerBanner?: ComposerBanner
59
- composerAvailability: ComposerAvailability
56
+ agentAvailability: AgentAvailability
60
57
  annotation?: ComposerAnnotationControls
61
58
  send: (text: string, options?: ChatSendOptions) => void
62
59
  stop: () => void
@@ -81,7 +78,7 @@ export function ChatPanel({
81
78
  sessionId,
82
79
  processing,
83
80
  composerBanner,
84
- composerAvailability,
81
+ agentAvailability,
85
82
  annotation,
86
83
  send,
87
84
  stop,
@@ -104,7 +101,7 @@ export function ChatPanel({
104
101
  attachment => attachment.status === 'uploading'
105
102
  )
106
103
  )
107
- const promptDisabled = !canSubmitComposerAction(true, attachmentsUploading, composerAvailability)
104
+ const promptDisabled = !canSubmitComposerAction(true, attachmentsUploading, agentAvailability)
108
105
  // Visual grouping: fold consecutive tool-only assistant turns into one
109
106
  // synthetic turn so OpenAI Codex–style traces (which serialize one
110
107
  // assistant message per agent step) don't render with the wider
@@ -125,6 +122,7 @@ export function ChatPanel({
125
122
  const effectiveProcessing = builderDraft ? false : processing
126
123
  const showEmptyState =
127
124
  !!builderDraft || (chatLoaded && timeline.length === 0 && !effectiveProcessing)
125
+ const showTranscript = chatLoaded && !showEmptyState
128
126
  const emptyStateKind = resolveChatEmptyState({
129
127
  isViewBuilderDraft: !!builderDraft,
130
128
  hasSentMessageFromMoi,
@@ -202,23 +200,23 @@ export function ChatPanel({
202
200
  onNavigate={onNavigateFromWelcome}
203
201
  />
204
202
  )}
205
- {timeline.map(item =>
206
- item.kind === 'notice' ? (
207
- <ChatNoticeRow key={`notice:${item.notice.id}`} notice={item.notice} />
208
- ) : (
209
- <TurnView
210
- key={item.turn.id}
211
- turn={item.turn}
212
- processing={effectiveProcessing && item.turn.id === lastTurnId}
213
- />
214
- )
215
- )}
216
- {!showEmptyState && (
203
+ {showTranscript &&
204
+ timeline.map(item =>
205
+ item.kind === 'notice' ? (
206
+ <ChatNoticeRow key={`notice:${item.notice.id}`} notice={item.notice} />
207
+ ) : (
208
+ <TurnView
209
+ key={item.turn.id}
210
+ turn={item.turn}
211
+ processing={effectiveProcessing && item.turn.id === lastTurnId}
212
+ />
213
+ )
214
+ )}
215
+ {showTranscript && (
217
216
  <div className="mt-auto -ml-3 pt-2">
218
217
  <AgentBlobatar
219
218
  preset={agent}
220
219
  color="primary"
221
- size={64}
222
220
  animated={effectiveProcessing}
223
221
  expression={effectiveProcessing ? 'thinking' : undefined}
224
222
  />
@@ -229,7 +227,7 @@ export function ChatPanel({
229
227
 
230
228
  {/* Jump to latest — shown only when scrolled up, so following the tail
231
229
  never yanks the user while they read history. */}
232
- {!atBottom && turns.length > 0 && (
230
+ {showTranscript && !atBottom && turns.length > 0 && (
233
231
  <Button
234
232
  type="button"
235
233
  variant="outline"
@@ -260,7 +258,7 @@ export function ChatPanel({
260
258
  processing={effectiveProcessing}
261
259
  sessionId={effectiveSessionId}
262
260
  modelSessionId={modelSessionId}
263
- availability={composerAvailability}
261
+ availability={agentAvailability}
264
262
  annotation={builderDraft ? undefined : annotation}
265
263
  onRemoveDrawing={builderDraft?.onRemoveDrawing ?? annotation?.onRemove}
266
264
  allowFiles={!builderDraft}
@@ -65,11 +65,10 @@ export function ChatPopup({
65
65
  <AgentBlobatar
66
66
  preset={agent}
67
67
  color="primary"
68
- size={56}
69
68
  animated={loading}
70
69
  expression={loading ? 'thinking' : undefined}
71
70
  className={cn(
72
- 'drop-shadow-md drop-shadow-primary/30',
71
+ 'drop-shadow-md drop-shadow-primary/25',
73
72
  'group-hover:drop-shadow-lg group-hover:drop-shadow-primary/40',
74
73
  'transition-[filter] duration-400 ease-in-out motion-reduce:transition-none'
75
74
  )}
@@ -11,7 +11,6 @@ import {
11
11
 
12
12
  import {
13
13
  canSubmitComposerAction,
14
- type ComposerAvailability,
15
14
  Composer,
16
15
  ComposerFooter,
17
16
  ComposerSubmitButton,
@@ -22,6 +21,7 @@ import { HoverCard, HoverCardContent, HoverCardTrigger } from '@/client/componen
22
21
  import { Tooltip, TooltipContent, TooltipTrigger } from '@/client/components/ui/tooltip'
23
22
  import { stageComposerFiles } from '@/client/features/chat/attachment-staging'
24
23
  import { cn } from '@/client/lib/cn'
24
+ import type { AgentAvailability } from '@/client/lib/agent-availability'
25
25
  import { useWorkspaceId } from '@/client/features/workspace/WorkspaceContext'
26
26
  import {
27
27
  type ChatAttachment,
@@ -56,7 +56,7 @@ type ChatComposerProps = {
56
56
  processing: boolean
57
57
  sessionId: string | null
58
58
  modelSessionId: string | null
59
- availability: ComposerAvailability
59
+ availability: AgentAvailability
60
60
  annotation?: ComposerAnnotationControls
61
61
  onRemoveDrawing?: (localId: string) => void
62
62
  allowFiles?: boolean
@@ -0,0 +1,101 @@
1
+ import { type ReactNode, useState } from 'react'
2
+
3
+ import {
4
+ IconAlertCircle,
5
+ IconLoader2,
6
+ IconLogin,
7
+ IconPlugConnectedX,
8
+ type TablerIcon
9
+ } from '@tabler/icons-react'
10
+
11
+ import { Button } from '@/client/components/ui/button'
12
+ import type { AgentUnavailable } from '@/client/lib/agent-availability'
13
+ import type { AgentLoginState, HarnessLogin } from '@/lib/types'
14
+
15
+ import { ComposerBannerShell } from './ComposerBanner'
16
+
17
+ type AgentAvailabilityBannerProps = {
18
+ availability: AgentUnavailable
19
+ // The server-owned ceremony. `pending` means some tab (maybe this one)
20
+ // started a login and the server is watching for it to land; `failed` means
21
+ // the last ceremony timed out or errored.
22
+ login?: AgentLoginState
23
+ onStartLogin: () => Promise<HarnessLogin>
24
+ }
25
+
26
+ export function AgentAvailabilityBanner({
27
+ availability,
28
+ login,
29
+ onStartLogin
30
+ }: AgentAvailabilityBannerProps) {
31
+ switch (availability.status) {
32
+ case 'login-required':
33
+ return <LoginRequiredBanner login={login} onStartLogin={onStartLogin} />
34
+ case 'disconnected':
35
+ return (
36
+ <AvailabilityMessage icon={IconPlugConnectedX}>Reconnecting to moi…</AvailabilityMessage>
37
+ )
38
+ case 'unavailable':
39
+ return <AvailabilityMessage icon={IconAlertCircle}>{availability.reason}</AvailabilityMessage>
40
+ }
41
+ }
42
+
43
+ type LoginRequiredBannerProps = Pick<AgentAvailabilityBannerProps, 'login' | 'onStartLogin'>
44
+
45
+ function LoginRequiredBanner({ login, onStartLogin }: LoginRequiredBannerProps) {
46
+ const [starting, setStarting] = useState(false)
47
+ const [error, setError] = useState<string | null>(null)
48
+
49
+ const failure = login?.state === 'failed' ? login.reason : null
50
+ const loginError = error ?? failure
51
+
52
+ const startLogin = async () => {
53
+ const authWindow = window.open('about:blank', 'moi-agent-login')
54
+ if (authWindow) authWindow.opener = null
55
+ setStarting(true)
56
+ setError(null)
57
+ try {
58
+ const result = await onStartLogin()
59
+ if (result.url) {
60
+ if (!authWindow) throw new Error('Allow pop-ups, then try again')
61
+ authWindow.location.href = result.url
62
+ } else {
63
+ authWindow?.close()
64
+ }
65
+ } catch (err) {
66
+ authWindow?.close()
67
+ setError(err instanceof Error ? err.message : 'Could not start sign-in')
68
+ } finally {
69
+ setStarting(false)
70
+ }
71
+ }
72
+
73
+ return (
74
+ <ComposerBannerShell role="alert" className="flex items-center gap-2">
75
+ <IconLogin size={20} stroke={1.5} />
76
+ <div className="min-w-0 flex-1 space-y-1">
77
+ <div className="wrap-break-word">Log in to your agent to send messages</div>
78
+ {loginError && <div className="wrap-break-word text-destructive">{loginError}</div>}
79
+ </div>
80
+
81
+ <Button type="button" size="sm" onClick={() => void startLogin()} disabled={starting}>
82
+ {starting && <IconLoader2 stroke={1.75} className="animate-spin" />}
83
+ Log in
84
+ </Button>
85
+ </ComposerBannerShell>
86
+ )
87
+ }
88
+
89
+ type AvailabilityMessageProps = {
90
+ icon: TablerIcon
91
+ children: ReactNode
92
+ }
93
+
94
+ function AvailabilityMessage({ icon: Icon, children }: AvailabilityMessageProps) {
95
+ return (
96
+ <ComposerBannerShell role="alert" className="flex items-center gap-2">
97
+ <Icon size={20} stroke={1.5} />
98
+ <div className="min-w-0 flex-1 wrap-break-word">{children}</div>
99
+ </ComposerBannerShell>
100
+ )
101
+ }
@@ -4,12 +4,12 @@ import { Button } from '@/client/components/ui/button'
4
4
 
5
5
  import { ComposerBannerShell } from './ComposerBanner'
6
6
 
7
- type ChatErrorBannerProps = {
7
+ type ErrorBannerProps = {
8
8
  error: string
9
9
  onDismiss: () => void
10
10
  }
11
11
 
12
- export function ChatErrorBanner({ error, onDismiss }: ChatErrorBannerProps) {
12
+ export function ErrorBanner({ error, onDismiss }: ErrorBannerProps) {
13
13
  return (
14
14
  <ComposerBannerShell role="alert" className="flex items-center gap-2 text-destructive">
15
15
  <span className="flex-1 wrap-break-word">{error}</span>
@@ -7,19 +7,19 @@ import { ComposerBannerShell } from './ComposerBanner'
7
7
 
8
8
  export type WorkspaceSkillUpdateAction = 'auto' | 'once'
9
9
 
10
- export type WorkspaceSkillUpdateBannerProps = {
10
+ export type SkillUpdateBannerProps = {
11
11
  error: string | null
12
12
  pendingAction: WorkspaceSkillUpdateAction | null
13
13
  onUpdate: (action: WorkspaceSkillUpdateAction) => void
14
14
  onDismiss: () => void
15
15
  }
16
16
 
17
- export function WorkspaceSkillUpdateBanner({
17
+ export function SkillUpdateBanner({
18
18
  error,
19
19
  pendingAction,
20
20
  onUpdate,
21
21
  onDismiss
22
- }: WorkspaceSkillUpdateBannerProps) {
22
+ }: SkillUpdateBannerProps) {
23
23
  if (!error && pendingAction === 'auto') {
24
24
  return (
25
25
  <ComposerBannerShell
@@ -1,10 +1,10 @@
1
- import type { ComposerAvailability } from '@/client/components/shared/Composer'
2
1
  import { startWorkspaceLogin, useWorkspaceAgent } from '@/client/features/workspace/api'
2
+ import { resolveAgentAvailability, type AgentAvailability } from '@/client/lib/agent-availability'
3
3
 
4
- import { ChatErrorBanner } from './banners/ChatErrorBanner'
4
+ import { ErrorBanner } from './banners/ErrorBanner'
5
5
  import { resolveComposerBanner, type ComposerBanner } from './banners/ComposerBanner'
6
- import { WorkspaceAgentAvailabilityBanner } from './banners/WorkspaceAgentAvailabilityBanner'
7
- import { WorkspaceSkillUpdateBanner } from './banners/WorkspaceSkillUpdateBanner'
6
+ import { AgentAvailabilityBanner } from './banners/AgentAvailabilityBanner'
7
+ import { SkillUpdateBanner } from './banners/SkillUpdateBanner'
8
8
  import { useWorkspaceSkillUpdates } from './useWorkspaceSkillUpdates'
9
9
 
10
10
  type WorkspaceComposerStateOptions = {
@@ -15,7 +15,7 @@ type WorkspaceComposerStateOptions = {
15
15
  type WorkspaceComposerState = {
16
16
  composerBanner?: ComposerBanner
17
17
  builderComposerBanner?: ComposerBanner
18
- composerAvailability: ComposerAvailability
18
+ agentAvailability: AgentAvailability
19
19
  }
20
20
 
21
21
  export function useWorkspaceComposerState(
@@ -25,27 +25,17 @@ export function useWorkspaceComposerState(
25
25
  const { data: agent, error } = useWorkspaceAgent(workspaceId)
26
26
  const availability = agent?.availability
27
27
  const { bannerProps: skillUpdateBanner } = useWorkspaceSkillUpdates(workspaceId)
28
-
29
- let unavailable = availability?.available === false ? availability : undefined
30
- if (error) {
31
- unavailable = {
32
- available: false,
33
- reason: `Could not check agent status: ${error.message}`
34
- }
35
- }
36
-
37
- let composerAvailability: ComposerAvailability = { status: 'checking' }
38
- if (unavailable) {
39
- composerAvailability = { status: 'unavailable' }
40
- } else if (availability) {
41
- composerAvailability = { status: 'available' }
42
- }
28
+ const agentAvailability = resolveAgentAvailability(availability, Boolean(error))
29
+ const unavailable =
30
+ agentAvailability.status === 'checking' || agentAvailability.status === 'available'
31
+ ? undefined
32
+ : agentAvailability
43
33
 
44
34
  const agentUnavailableBanner: ComposerBanner | undefined = unavailable
45
35
  ? {
46
36
  tone: 'default',
47
37
  content: (
48
- <WorkspaceAgentAvailabilityBanner
38
+ <AgentAvailabilityBanner
49
39
  availability={unavailable}
50
40
  login={agent?.login}
51
41
  onStartLogin={() => startWorkspaceLogin(workspaceId)}
@@ -56,13 +46,13 @@ export function useWorkspaceComposerState(
56
46
  const chatErrorBanner: ComposerBanner | undefined = chatError
57
47
  ? {
58
48
  tone: 'error',
59
- content: <ChatErrorBanner error={chatError} onDismiss={onDismissChatError} />
49
+ content: <ErrorBanner error={chatError} onDismiss={onDismissChatError} />
60
50
  }
61
51
  : undefined
62
52
  const skillUpdate: ComposerBanner | undefined = skillUpdateBanner
63
53
  ? {
64
54
  tone: 'default',
65
- content: <WorkspaceSkillUpdateBanner {...skillUpdateBanner} />
55
+ content: <SkillUpdateBanner {...skillUpdateBanner} />
66
56
  }
67
57
  : undefined
68
58
  const composerBanner = resolveComposerBanner({
@@ -75,5 +65,5 @@ export function useWorkspaceComposerState(
75
65
  skillUpdate
76
66
  })
77
67
 
78
- return { composerAvailability, composerBanner, builderComposerBanner }
68
+ return { agentAvailability, composerBanner, builderComposerBanner }
79
69
  }
@@ -4,9 +4,9 @@ import { useAppSettings, useSaveAppSettings } from '@/client/features/settings/a
4
4
  import { useUpdateWorkspaceSkills, useWorkspaceSkills } from '@/client/features/workspace/api'
5
5
 
6
6
  import type {
7
- WorkspaceSkillUpdateAction,
8
- WorkspaceSkillUpdateBannerProps
9
- } from './banners/WorkspaceSkillUpdateBanner'
7
+ SkillUpdateBannerProps,
8
+ WorkspaceSkillUpdateAction
9
+ } from './banners/SkillUpdateBanner'
10
10
 
11
11
  type VisitPhase = 'idle' | 'active' | 'dismissed'
12
12
 
@@ -18,7 +18,7 @@ type VisitState = {
18
18
  }
19
19
 
20
20
  export type WorkspaceSkillUpdates = {
21
- bannerProps: WorkspaceSkillUpdateBannerProps | null
21
+ bannerProps: SkillUpdateBannerProps | null
22
22
  }
23
23
 
24
24
  function initialVisitState(workspaceId: string): VisitState {
@@ -30,7 +30,7 @@ function initialVisitState(workspaceId: string): VisitState {
30
30
  }
31
31
  }
32
32
 
33
- export function shouldShowWorkspaceSkillUpdateBanner(input: {
33
+ export function shouldShowSkillUpdateBanner(input: {
34
34
  updateAvailable: boolean
35
35
  autoUpdateEnabled: boolean
36
36
  phase: VisitPhase
@@ -136,7 +136,7 @@ export function useWorkspaceSkillUpdates(workspaceId: string): WorkspaceSkillUpd
136
136
 
137
137
  const visible =
138
138
  settingsReady &&
139
- shouldShowWorkspaceSkillUpdateBanner({
139
+ shouldShowSkillUpdateBanner({
140
140
  updateAvailable,
141
141
  autoUpdateEnabled,
142
142
  phase: currentVisit.phase
@@ -13,8 +13,8 @@
13
13
  import { reportAppletError } from '@/client/features/applets/applet-log'
14
14
  import { type AppletChatMessage, useAppletEvent } from '@/client/features/applets/applet-runtime'
15
15
  import type { ChatSendOptions } from '@/client/features/chat/chat-send'
16
- import type { ComposerAvailability } from '@/client/components/shared/Composer'
17
16
  import { useWorkspaceId } from '@/client/features/workspace/WorkspaceContext'
17
+ import type { AgentAvailability } from '@/client/lib/agent-availability'
18
18
 
19
19
  type UseAppletChatMessageOptions = {
20
20
  send: (draft: string, options?: ChatSendOptions) => void
@@ -23,29 +23,33 @@ type UseAppletChatMessageOptions = {
23
23
  // without this the agent would start working somewhere the user can't see.
24
24
  revealChat: () => void
25
25
  // Same explicit availability state the composer's send button uses.
26
- composerAvailability: ComposerAvailability
26
+ agentAvailability: AgentAvailability
27
27
  }
28
28
 
29
29
  // Why an applet message can't go out right now, or null when it can. The gate
30
30
  // is exactly the composer's. Starting a run the visible UI would have refused
31
31
  // is worse than dropping a click the user can repeat a moment later.
32
- export function appletSendBlockedReason(availability: ComposerAvailability): string | null {
32
+ export function appletSendBlockedReason(availability: AgentAvailability): string | null {
33
33
  if (availability.status === 'available') return null
34
34
  if (availability.status === 'checking') {
35
35
  return "this workspace's agent availability has not resolved yet"
36
36
  }
37
+ if (availability.status === 'disconnected') return 'this workspace is disconnected from moi'
38
+ if (availability.status === 'login-required') {
39
+ return "this workspace's agent needs a login"
40
+ }
37
41
  return "this workspace's agent is unavailable"
38
42
  }
39
43
 
40
44
  export function useAppletChatMessage({
41
45
  send,
42
46
  revealChat,
43
- composerAvailability
47
+ agentAvailability
44
48
  }: UseAppletChatMessageOptions): void {
45
49
  const workspaceId = useWorkspaceId()
46
50
 
47
51
  useAppletEvent(workspaceId, 'sendChatMessage', (event: AppletChatMessage) => {
48
- const blocked = appletSendBlockedReason(composerAvailability)
52
+ const blocked = appletSendBlockedReason(agentAvailability)
49
53
  if (blocked) {
50
54
  // Journaled rather than dropped quietly: from the applet's side the
51
55
  // button did nothing, and this is the only place that says why.