moi-computer 0.3.1-next.0 → 0.3.1-next.1

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 (92) hide show
  1. package/client/api/workspace-keys.ts +2 -2
  2. package/client/app/AppRouter.tsx +0 -2
  3. package/client/app/shell/SidebarLayout.tsx +3 -16
  4. package/client/assets/openai.svg +1 -3
  5. package/client/components/shared/Composer.tsx +53 -2
  6. package/client/components/ui/button.tsx +1 -1
  7. package/client/components/ui/tooltip.tsx +12 -15
  8. package/client/features/chat/ChatComposer.tsx +25 -15
  9. package/client/features/chat/ChatPanel.tsx +5 -2
  10. package/client/features/chat/MarkdownContent.tsx +20 -2
  11. package/client/features/chat/ModelPicker.tsx +5 -3
  12. package/client/features/chat/TurnView.tsx +2 -2
  13. package/client/features/chat/chat-frames.ts +13 -6
  14. package/client/features/chat/chat-send.ts +1 -1
  15. package/client/features/chat/chat-store.ts +22 -17
  16. package/client/features/chat/tool-group/ToolOutput.tsx +4 -12
  17. package/client/features/chat/tool-group/format.ts +0 -6
  18. package/client/features/chat/useChat.ts +11 -2
  19. package/client/features/connectors/McpServerCards.tsx +95 -0
  20. package/client/features/connectors/api.ts +0 -11
  21. package/client/features/home/HomePage.tsx +33 -28
  22. package/client/features/home/api.ts +24 -12
  23. package/client/features/home/workspace-presentation.tsx +17 -15
  24. package/client/features/home/workspace-setup/CreateWorkspaceDialog.tsx +243 -0
  25. package/client/features/home/workspace-setup/ImportWorkspaceDialog.tsx +95 -0
  26. package/client/features/home/workspace-setup/WorkspaceAgentStep.tsx +230 -0
  27. package/client/features/home/workspace-setup/WorkspaceDialogContent.tsx +35 -0
  28. package/client/features/home/workspace-setup/useWorkspaceImport.ts +61 -0
  29. package/client/features/settings/ConnectorsSettings.tsx +89 -0
  30. package/client/features/settings/SettingsLayout.tsx +2 -2
  31. package/client/features/settings/WorkspaceSettings.tsx +8 -4
  32. package/client/features/views/ViewBuilderTab.tsx +19 -15
  33. package/client/features/views/useViewBuilderActions.ts +1 -1
  34. package/client/features/workspace/WorkspaceLayoutContext.tsx +3 -4
  35. package/client/features/workspace/WorkspaceScreen.tsx +11 -3
  36. package/client/features/workspace/api.ts +19 -1
  37. package/client/features/workspace/moi-context.ts +85 -0
  38. package/client/main.tsx +7 -4
  39. package/dist/{chunk-cs8vbert.js → chunk-1dfbr7n2.js} +2 -2
  40. package/dist/chunk-339jds4x.js +15 -0
  41. package/dist/chunk-3xsvsnhr.css +1 -0
  42. package/dist/{chunk-zpxrb1ce.js → chunk-anqmsbjt.js} +2 -2
  43. package/dist/chunk-hbvfb6sk.js +63 -0
  44. package/dist/{chunk-kxmvv1ax.js → chunk-qwm5f6qk.js} +1 -1
  45. package/dist/{chunk-axszxe4c.js → chunk-sxbfh73c.js} +1 -1
  46. package/dist/chunk-yp4srgqt.js +10 -0
  47. package/dist/index.html +1 -1
  48. package/dist/openai-ep9ht2pq.svg +1 -0
  49. package/lib/ids.ts +15 -0
  50. package/lib/moi-context.ts +170 -0
  51. package/lib/types.ts +29 -11
  52. package/lib/view-builder-directives.ts +16 -0
  53. package/lib/workspace-types.ts +12 -0
  54. package/package.json +2 -1
  55. package/server/api.ts +92 -30
  56. package/server/harness/README.md +25 -9
  57. package/server/harness/claude-code/NOTES.md +20 -6
  58. package/server/harness/claude-code/adapter.ts +2 -2
  59. package/server/harness/claude-code/git-worktree.ts +32 -0
  60. package/server/harness/claude-code/index.ts +32 -12
  61. package/server/harness/claude-code/mcp.ts +16 -65
  62. package/server/harness/claude-code/models.ts +3 -0
  63. package/server/harness/claude-code/session.ts +196 -61
  64. package/server/harness/codex/NOTES.md +41 -11
  65. package/server/harness/codex/adapter.ts +21 -7
  66. package/server/harness/codex/client.ts +33 -17
  67. package/server/harness/codex/discovery.ts +114 -0
  68. package/server/harness/codex/index.ts +9 -5
  69. package/server/harness/codex/probe.ts +4 -2
  70. package/server/harness/codex/session.ts +57 -5
  71. package/server/harness/executable.ts +82 -0
  72. package/server/harness/openclaw/adapter.ts +8 -1
  73. package/server/harness/openclaw/index.ts +8 -14
  74. package/server/harness/openclaw/session.ts +50 -10
  75. package/server/harness/openclaw/strip.ts +2 -2
  76. package/server/harness/shell-path.ts +79 -0
  77. package/server/harness/types.ts +22 -5
  78. package/server/registry.ts +57 -12
  79. package/server/view-builders.ts +3 -2
  80. package/server/web.ts +24 -8
  81. package/server/workspace-import.ts +45 -0
  82. package/workspace/.claude/skills/moi-workspace/SKILL.md +3 -3
  83. package/client/features/connectors/ConnectorsPage.tsx +0 -92
  84. package/client/features/connectors/McpMenu.tsx +0 -145
  85. package/client/features/home/CreateWorkspaceDialog.tsx +0 -130
  86. package/client/features/home/CreateWorkspaceDialogSteps.tsx +0 -234
  87. package/dist/chunk-4vf1t6v1.js +0 -10
  88. package/dist/chunk-b3ynfk4g.js +0 -62
  89. package/dist/chunk-b4b276wx.js +0 -15
  90. package/dist/chunk-npwq6jmr.css +0 -1
  91. package/dist/openai-h13pza4b.svg +0 -3
  92. package/lib/view-builder-meta.ts +0 -35
@@ -1,7 +1,7 @@
1
1
  export const workspaceKeys = {
2
2
  all: ['workspaces'] as const,
3
3
  discover: ['workspaces', 'discover'] as const,
4
- createInfo: ['workspaces', 'create-info'] as const,
4
+ setupInfo: ['workspaces', 'setup-info'] as const,
5
5
  preview: (id: string) => ['workspaces', 'preview', id] as const,
6
6
  layout: (id: string) => ['workspaces', 'layout', id] as const,
7
7
  widgets: (id: string) => ['workspaces', 'widgets', id] as const,
@@ -11,8 +11,8 @@ export const workspaceKeys = {
11
11
  events: (id: string, sessionId: string) => ['workspaces', 'events', id, sessionId] as const,
12
12
  threadConfig: (id: string, sessionId: string) =>
13
13
  ['workspaces', 'threadConfig', id, sessionId] as const,
14
- userMcp: ['mcp', 'user'] as const,
15
14
  mcp: (id: string) => ['workspaces', 'mcp', id] as const,
16
15
  models: (id: string) => ['workspaces', 'models', id] as const,
16
+ availability: (id: string) => ['workspaces', 'availability', id] as const,
17
17
  env: (id: string) => ['workspaces', 'env', id] as const
18
18
  }
@@ -3,7 +3,6 @@ import { Suspense, lazy, useEffect } from 'react'
3
3
  import { Route, Switch, useLocation } from 'wouter'
4
4
 
5
5
  import { setWorkspaceSwitchHandler } from '@/client/features/chat/chat-connection'
6
- import { ConnectorsPage } from '@/client/features/connectors/ConnectorsPage'
7
6
 
8
7
  import { HomeRoute } from './routes/HomeRoute'
9
8
  import { WorkspaceRoute } from './routes/WorkspaceRoute'
@@ -34,7 +33,6 @@ export function AppRouter() {
34
33
  return (
35
34
  <Switch>
36
35
  <Route path="/" component={HomeRoute} />
37
- <Route path="/connectors" component={ConnectorsPage} />
38
36
  <Route path="/dev/*?" component={DevLazy} />
39
37
  <Route path="/workspace/:id">
40
38
  {(params: { id: string }) => <WorkspaceRoute key={params.id} id={params.id} />}
@@ -1,13 +1,13 @@
1
1
  import { type ReactNode } from 'react'
2
2
 
3
- import { IconPlugConnected, IconPlus, IconSmartHome } from '@tabler/icons-react'
3
+ import { IconPlus, IconSmartHome } from '@tabler/icons-react'
4
4
  import { useQueryClient } from '@tanstack/react-query'
5
5
  import { Link, useLocation } from 'wouter'
6
6
 
7
7
  import { useReorderWorkspaces, useWorkspaces } from '@/client/features/home/api'
8
8
  import { workspaceKeys } from '@/client/api/workspace-keys'
9
9
  import { useWorkspaceEvent } from '@/client/runtime/useWorkspaceEvents'
10
- import { CreateWorkspaceDialog } from '@/client/features/home/CreateWorkspaceDialog'
10
+ import { CreateWorkspaceDialog } from '@/client/features/home/workspace-setup/CreateWorkspaceDialog'
11
11
  import { ReorderableList } from '@/client/components/shared/ReorderableList'
12
12
  import type { ReorderableRenderState } from '@/client/components/shared/ReorderableList'
13
13
  import { Button, buttonVariants } from '@/client/components/ui/button'
@@ -119,24 +119,11 @@ function Sidebar({ workspaces }: SidebarProps) {
119
119
  )}
120
120
  </nav>
121
121
 
122
- <ConnectorsNavLink />
122
+ <div aria-hidden="true" className="size-8 shrink-0" />
123
123
  </aside>
124
124
  )
125
125
  }
126
126
 
127
- function ConnectorsNavLink() {
128
- return (
129
- <Link
130
- href="/connectors"
131
- aria-label="Connectors"
132
- title="Connectors"
133
- className={sidebarNavButtonClass}
134
- >
135
- <IconPlugConnected stroke={1.5} />
136
- </Link>
137
- )
138
- }
139
-
140
127
  type WorkspaceButtonProps = {
141
128
  workspace: WorkspaceEntry
142
129
  dragOverlay?: boolean
@@ -1,3 +1 @@
1
- <svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
2
- <path fill="#10A37F" d="M22.2819 9.8211a5.9847 5.9847 0 0 0-.5157-4.9108 6.0462 6.0462 0 0 0-6.5098-2.9A6.0651 6.0651 0 0 0 4.9807 4.1818a5.9847 5.9847 0 0 0-3.9977 2.9 6.0462 6.0462 0 0 0 .7427 7.0966 5.98 5.98 0 0 0 .511 4.9107 6.051 6.051 0 0 0 6.5146 2.9001A5.9847 5.9847 0 0 0 13.2599 24a6.0557 6.0557 0 0 0 5.7718-4.2058 5.9894 5.9894 0 0 0 3.9977-2.9001 6.0557 6.0557 0 0 0-.7475-7.073zm-9.022 12.6081a4.4755 4.4755 0 0 1-2.8764-1.0408l.1419-.0804 4.7783-2.7582a.7948.7948 0 0 0 .3927-.6813v-6.7369l2.02 1.1686a.071.071 0 0 1 .038.052v5.5826a4.504 4.504 0 0 1-4.4945 4.4944zm-9.6607-4.1254a4.4708 4.4708 0 0 1-.5346-3.0137l.142.0852 4.783 2.7582a.7712.7712 0 0 0 .7806 0l5.8428-3.3685v2.3324a.0804.0804 0 0 1-.0332.0615L9.74 19.9502a4.4992 4.4992 0 0 1-6.1408-1.6464zM2.3408 7.8956a4.485 4.485 0 0 1 2.3655-1.9728V11.6a.7664.7664 0 0 0 .3879.6765l5.8144 3.3543-2.0201 1.1685a.0757.0757 0 0 1-.071 0l-4.8303-2.7865A4.504 4.504 0 0 1 2.3408 7.8956zm16.5963 3.8558L13.1038 8.364 15.1192 7.2a.0757.0757 0 0 1 .071 0l4.8303 2.7913a4.4944 4.4944 0 0 1-.6765 8.1042v-5.6772a.79.79 0 0 0-.407-.667zm2.0107-3.0231l-.142-.0852-4.7735-2.7818a.7759.7759 0 0 0-.7854 0L9.409 9.2297V6.8974a.0662.0662 0 0 1 .0284-.0615l4.8303-2.7866a4.4992 4.4992 0 0 1 6.6802 4.66zM8.3065 12.863l-2.02-1.1638a.0804.0804 0 0 1-.038-.0567V6.0742a4.4992 4.4992 0 0 1 7.3757-3.4537l-.142.0805L8.704 5.459a.7948.7948 0 0 0-.3927.6813zm1.0976-2.3654l2.602-1.4998 2.6069 1.4998v2.9994l-2.5974 1.4997-2.6067-1.4997z"/>
3
- </svg>
1
+ <svg fill="none" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><title>OpenAI</title><path d="M9.205 8.658v-2.26c0-.19.072-.333.238-.428l4.543-2.616c.619-.357 1.356-.523 2.117-.523 2.854 0 4.662 2.212 4.662 4.566 0 .167 0 .357-.024.547l-4.71-2.759a.797.797 0 00-.856 0l-5.97 3.473zm10.609 8.8V12.06c0-.333-.143-.57-.429-.737l-5.97-3.473 1.95-1.118a.433.433 0 01.476 0l4.543 2.617c1.309.76 2.189 2.378 2.189 3.948 0 1.808-1.07 3.473-2.76 4.163zM7.802 12.703l-1.95-1.142c-.167-.095-.239-.238-.239-.428V5.899c0-2.545 1.95-4.472 4.591-4.472 1 0 1.927.333 2.712.928L8.23 5.067c-.285.166-.428.404-.428.737v6.898zM12 15.128l-2.795-1.57v-3.33L12 8.658l2.795 1.57v3.33L12 15.128zm1.796 7.23c-1 0-1.927-.332-2.712-.927l4.686-2.712c.285-.166.428-.404.428-.737v-6.898l1.974 1.142c.167.095.238.238.238.428v5.233c0 2.545-1.974 4.472-4.614 4.472zm-5.637-5.303l-4.544-2.617c-1.308-.761-2.188-2.378-2.188-3.948A4.482 4.482 0 014.21 6.327v5.423c0 .333.143.571.428.738l5.947 3.449-1.95 1.118a.432.432 0 01-.476 0zm-.262 3.9c-2.688 0-4.662-2.021-4.662-4.519 0-.19.024-.38.047-.57l4.686 2.71c.286.167.571.167.856 0l5.97-3.448v2.26c0 .19-.07.333-.237.428l-4.543 2.616c-.619.357-1.356.523-2.117.523zm5.899 2.83a5.947 5.947 0 005.827-4.756C22.287 18.339 24 15.84 24 13.296c0-1.665-.713-3.282-1.998-4.448.119-.5.19-.999.19-1.498 0-3.401-2.759-5.947-5.946-5.947-.642 0-1.26.095-1.88.31A5.962 5.962 0 0010.205 0a5.947 5.947 0 00-5.827 4.757C1.713 5.447 0 7.945 0 10.49c0 1.666.713 3.283 1.998 4.448-.119.5-.19 1-.19 1.499 0 3.401 2.759 5.946 5.946 5.946.642 0 1.26-.095 1.88-.309a5.96 5.96 0 004.162 1.713z" fill="#111111"></path></svg>
@@ -1,5 +1,9 @@
1
1
  import type { ComponentProps, RefObject } from 'react'
2
2
 
3
+ import { IconArrowUp, IconLoader2 } from '@tabler/icons-react'
4
+
5
+ import { Button } from '@/client/components/ui/button'
6
+ import { Tooltip, TooltipContent, TooltipTrigger } from '@/client/components/ui/tooltip'
3
7
  import { cn } from '@/client/lib/cn'
4
8
 
5
9
  type ComposerProps = Omit<ComponentProps<'form'>, 'ref'> & {
@@ -19,8 +23,11 @@ export function Composer({
19
23
  onMouseDown={event => {
20
24
  onMouseDown?.(event)
21
25
  if (event.defaultPrevented) return
22
- if (event.target instanceof HTMLElement && event.target.closest('button')) return
23
- event.preventDefault()
26
+ if (
27
+ event.target instanceof Element &&
28
+ event.target.closest('button, input, textarea, select, a, [contenteditable="true"]')
29
+ )
30
+ return
24
31
  composerRef.current?.focus()
25
32
  }}
26
33
  className={cn(
@@ -59,3 +66,47 @@ export function ComposerFooter({ className, children, ...props }: ComposerFooter
59
66
  </div>
60
67
  )
61
68
  }
69
+
70
+ export function canSubmitComposerAction(
71
+ hasContent: boolean,
72
+ busy: boolean,
73
+ unavailableReason: string | null | undefined
74
+ ): boolean {
75
+ return hasContent && !busy && unavailableReason === null
76
+ }
77
+
78
+ type ComposerSubmitButtonProps = {
79
+ label: string
80
+ hasContent: boolean
81
+ busy?: boolean
82
+ loading?: boolean
83
+ unavailableReason: string | null | undefined
84
+ }
85
+
86
+ export function ComposerSubmitButton({
87
+ label,
88
+ hasContent,
89
+ busy = false,
90
+ loading = false,
91
+ unavailableReason
92
+ }: ComposerSubmitButtonProps) {
93
+ const canSubmit = canSubmitComposerAction(hasContent, busy || loading, unavailableReason)
94
+ const button = (
95
+ <Button type="submit" size="icon" disabled={!canSubmit} aria-label={label}>
96
+ {loading ? (
97
+ <IconLoader2 stroke={1.5} className="animate-spin" />
98
+ ) : (
99
+ <IconArrowUp stroke={1.5} />
100
+ )}
101
+ </Button>
102
+ )
103
+
104
+ if (loading || !unavailableReason) return button
105
+
106
+ return (
107
+ <Tooltip>
108
+ <TooltipTrigger render={<span className="inline-flex">{button}</span>} />
109
+ <TooltipContent className="max-w-64 text-center">{unavailableReason}</TooltipContent>
110
+ </Tooltip>
111
+ )
112
+ }
@@ -4,7 +4,7 @@ import { type VariantProps, cva } from 'class-variance-authority'
4
4
  import { cn } from '@/client/lib/cn'
5
5
 
6
6
  const buttonVariants = cva(
7
- 'inline-flex shrink-0 cursor-pointer items-center justify-center gap-2 rounded-sm text-sm font-medium whitespace-nowrap transition-all outline-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0',
7
+ 'inline-flex shrink-0 cursor-pointer items-center justify-center gap-1.5 rounded-sm text-sm font-medium whitespace-nowrap transition-all outline-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0',
8
8
  {
9
9
  variants: {
10
10
  variant: {
@@ -2,18 +2,12 @@ import { Tooltip as TooltipPrimitive } from '@base-ui/react/tooltip'
2
2
 
3
3
  import { cn } from '@/client/lib/cn'
4
4
 
5
- // Self-contained: each Tooltip wraps its own provider so `delay` can be set
6
- // per-instance (Base UI exposes delay/closeDelay on the provider, not the root).
7
- function Tooltip({
8
- delay,
9
- closeDelay,
10
- ...props
11
- }: TooltipPrimitive.Root.Props & { delay?: number; closeDelay?: number }) {
12
- return (
13
- <TooltipPrimitive.Provider delay={delay} closeDelay={closeDelay}>
14
- <TooltipPrimitive.Root data-slot="tooltip" {...props} />
15
- </TooltipPrimitive.Provider>
16
- )
5
+ function TooltipProvider({ delay = 100, ...props }: TooltipPrimitive.Provider.Props) {
6
+ return <TooltipPrimitive.Provider data-slot="tooltip-provider" delay={delay} {...props} />
7
+ }
8
+
9
+ function Tooltip({ ...props }: TooltipPrimitive.Root.Props) {
10
+ return <TooltipPrimitive.Root data-slot="tooltip" {...props} />
17
11
  }
18
12
 
19
13
  function TooltipTrigger({ ...props }: TooltipPrimitive.Trigger.Props) {
@@ -26,6 +20,7 @@ function TooltipContent({
26
20
  sideOffset = 6,
27
21
  align = 'center',
28
22
  alignOffset = 0,
23
+ children,
29
24
  ...props
30
25
  }: TooltipPrimitive.Popup.Props &
31
26
  Pick<TooltipPrimitive.Positioner.Props, 'align' | 'alignOffset' | 'side' | 'sideOffset'>) {
@@ -41,14 +36,16 @@ function TooltipContent({
41
36
  <TooltipPrimitive.Popup
42
37
  data-slot="tooltip-content"
43
38
  className={cn(
44
- 'z-50 origin-(--transform-origin) rounded-sm bg-popover px-2 py-1 text-xs font-medium text-popover-foreground shadow-md ring-1 ring-border outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-1 data-[side=left]:slide-in-from-right-1 data-[side=right]:slide-in-from-left-1 data-[side=top]:slide-in-from-bottom-1 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95',
39
+ 'z-50 w-fit max-w-xs origin-(--transform-origin) items-center gap-1.5 rounded-sm bg-popover px-2.5 py-1.5 text-xs font-medium text-popover-foreground shadow-md has-data-[slot=kbd]:pr-1.5 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 **:data-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-sm data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95',
45
40
  className
46
41
  )}
47
42
  {...props}
48
- />
43
+ >
44
+ {children}
45
+ </TooltipPrimitive.Popup>
49
46
  </TooltipPrimitive.Positioner>
50
47
  </TooltipPrimitive.Portal>
51
48
  )
52
49
  }
53
50
 
54
- export { Tooltip, TooltipContent, TooltipTrigger }
51
+ export { Tooltip, TooltipContent, TooltipTrigger, TooltipProvider }
@@ -1,15 +1,15 @@
1
1
  import { type RefObject, useRef, useState } from 'react'
2
2
 
3
+ import { IconFile, IconLoader2, IconPaperclip, IconPlayerStop, IconX } from '@tabler/icons-react'
4
+
3
5
  import {
4
- IconArrowUp,
5
- IconFile,
6
- IconLoader2,
7
- IconPaperclip,
8
- IconPlayerStop,
9
- IconX
10
- } from '@tabler/icons-react'
11
-
12
- import { Composer, ComposerFooter, ComposerTextarea } from '@/client/components/shared/Composer'
6
+ canSubmitComposerAction,
7
+ Composer,
8
+ ComposerFooter,
9
+ ComposerSubmitButton,
10
+ ComposerTextarea
11
+ } from '@/client/components/shared/Composer'
12
+ import { Button } from '@/client/components/ui/button'
13
13
  import { cn } from '@/client/lib/cn'
14
14
  import { useWorkspaceId } from '@/client/features/workspace/WorkspaceContext'
15
15
  import { uploadFiles } from '@/client/features/chat/uploads'
@@ -21,13 +21,13 @@ import {
21
21
  } from '@/client/features/chat/chat-store'
22
22
 
23
23
  import { ModelPicker } from './ModelPicker'
24
- import { Button } from '@/client/components/ui/button'
25
24
 
26
25
  type ChatComposerProps = {
27
26
  composerRef: RefObject<HTMLTextAreaElement | null>
28
27
  onSend: (text: string) => void
29
28
  onStop: () => void
30
29
  processing: boolean
30
+ unavailableReason: string | null | undefined
31
31
  }
32
32
 
33
33
  // The composer owns the draft: it reads/writes the per-thread draft in the live
@@ -35,7 +35,13 @@ type ChatComposerProps = {
35
35
  // panel, message list, or surrounding workspace. The draft is keyed by the
36
36
  // active thread, so switching threads swaps the unsent text with you. Attachments
37
37
  // (drag/drop, paste, attach button) are tracked the same way and cleared on send.
38
- export function ChatComposer({ composerRef, onSend, onStop, processing }: ChatComposerProps) {
38
+ export function ChatComposer({
39
+ composerRef,
40
+ onSend,
41
+ onStop,
42
+ processing,
43
+ unavailableReason
44
+ }: ChatComposerProps) {
39
45
  const fileRef = useRef<HTMLInputElement>(null)
40
46
  const workspaceId = useWorkspaceId()
41
47
  const sessionId = useLive(s => s.activeByWorkspace[workspaceId] ?? null)
@@ -45,7 +51,8 @@ export function ChatComposer({ composerRef, onSend, onStop, processing }: ChatCo
45
51
 
46
52
  const uploading = attachments.some(a => a.status === 'uploading')
47
53
  const hasReady = attachments.some(a => a.status === 'ready')
48
- const canSend = (value.trim().length > 0 || hasReady) && !uploading
54
+ const hasContent = value.trim().length > 0 || hasReady
55
+ const canSend = canSubmitComposerAction(hasContent, uploading, unavailableReason)
49
56
 
50
57
  const onChange = (next: string) => liveStore.getState().setDraft(workspaceId, sessionId, next)
51
58
 
@@ -176,9 +183,12 @@ export function ChatComposer({ composerRef, onSend, onStop, processing }: ChatCo
176
183
  <IconPlayerStop stroke={1.5} />
177
184
  </Button>
178
185
  ) : (
179
- <Button type="submit" size="icon" disabled={!canSend} aria-label="Send message">
180
- <IconArrowUp stroke={1.5} />
181
- </Button>
186
+ <ComposerSubmitButton
187
+ label="Send message"
188
+ hasContent={hasContent}
189
+ busy={uploading}
190
+ unavailableReason={unavailableReason}
191
+ />
182
192
  )}
183
193
  </ComposerFooter>
184
194
  </Composer>
@@ -25,6 +25,7 @@ type ChatPanelProps = {
25
25
  processing: boolean
26
26
  error?: string | null
27
27
  onDismissError?: () => void
28
+ unavailableReason: string | null | undefined
28
29
  send: (text: string) => void
29
30
  stop: () => void
30
31
  onSwitchThread: (sessionId: string | null) => void
@@ -48,6 +49,7 @@ export function ChatPanel({
48
49
  processing,
49
50
  error,
50
51
  onDismissError,
52
+ unavailableReason,
51
53
  send,
52
54
  stop,
53
55
  onSwitchThread,
@@ -141,9 +143,9 @@ export function ChatPanel({
141
143
  )}
142
144
  </div>
143
145
 
144
- <div className="mx-auto flex w-full justify-center px-3">
146
+ <div className="mx-auto flex w-full flex-col items-center px-3">
145
147
  {error && (
146
- <div className="mb-2 flex items-start gap-2 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-destructive">
148
+ <div className="mb-2 flex w-full max-w-(--chat-max-container) items-start gap-2 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-destructive">
147
149
  <span className="flex-1 wrap-break-word">{error}</span>
148
150
  {onDismissError && (
149
151
  <Button
@@ -164,6 +166,7 @@ export function ChatPanel({
164
166
  onSend={handleSend}
165
167
  onStop={stop}
166
168
  processing={processing}
169
+ unavailableReason={unavailableReason}
167
170
  />
168
171
  </div>
169
172
  </div>
@@ -10,10 +10,23 @@ const remarkPlugins = [remarkGfm]
10
10
  const rehypePlugins = [rehypeHighlight]
11
11
 
12
12
  const components = {
13
+ code({ className, children, ...props }: ComponentProps<'code'>) {
14
+ return (
15
+ <code
16
+ className={cn(
17
+ 'rounded-[4px] bg-accent px-1 py-0.5 font-mono font-normal before:content-none after:content-none',
18
+ className
19
+ )}
20
+ {...props}
21
+ >
22
+ {children}
23
+ </code>
24
+ )
25
+ },
13
26
  pre({ children }: ComponentProps<'pre'>) {
14
27
  return (
15
28
  <div className="not-prose my-2 rounded-md border border-border bg-muted px-3 py-2.5">
16
- <pre className="max-h-[300px] overflow-auto font-mono text-xs leading-relaxed whitespace-pre text-foreground">
29
+ <pre className="max-h-[300px] overflow-auto font-mono text-xs leading-relaxed whitespace-pre text-foreground [&>code]:rounded-none [&>code]:bg-transparent [&>code]:p-0">
17
30
  {children}
18
31
  </pre>
19
32
  </div>
@@ -28,7 +41,12 @@ type MarkdownContentProps = {
28
41
 
29
42
  export function MarkdownContent({ size = 'sm', content }: MarkdownContentProps) {
30
43
  return (
31
- <div className={cn('prose prose-inherit', size === 'sm' && 'prose-sm')}>
44
+ <div
45
+ className={cn(
46
+ 'prose max-w-full min-w-0 wrap-anywhere prose-inherit',
47
+ size === 'sm' && 'prose-sm'
48
+ )}
49
+ >
32
50
  <ReactMarkdown
33
51
  remarkPlugins={remarkPlugins}
34
52
  rehypePlugins={rehypePlugins}
@@ -122,13 +122,15 @@ export const ModelPicker = memo(function ModelPicker({ scope = 'active-chat' }:
122
122
  <DropdownMenuTrigger
123
123
  render={
124
124
  <Button variant="ghost">
125
- <span className="text-foreground">
125
+ <span className="font-normal text-foreground">
126
126
  {headline(model.description) || model.displayName}
127
127
  </span>
128
128
  {currentEffort && (
129
- <span className="text-muted-foreground">{effortLabel(currentEffort)}</span>
129
+ <span className="font-normal text-muted-foreground">
130
+ {effortLabel(currentEffort)}
131
+ </span>
130
132
  )}
131
- <IconChevronDown stroke={1.5} />
133
+ <IconChevronDown stroke={1.5} className="text-muted-foreground" />
132
134
  </Button>
133
135
  }
134
136
  />
@@ -119,12 +119,12 @@ export const TurnView = memo(function TurnView({ turn, processing = false }: Tur
119
119
  .join('\n')
120
120
  if (!text && fileParts.length === 0) return null
121
121
  return (
122
- <div className="ml-8 flex flex-col items-end gap-1.5">
122
+ <div className="ml-8 flex min-w-0 flex-col items-end gap-1.5">
123
123
  {fileParts.map((p, i) => (
124
124
  <FilePart key={i} mediaType={p.mediaType} url={p.url} filename={p.filename} />
125
125
  ))}
126
126
  {text && (
127
- <p className="rounded-md bg-accent px-4 py-2 text-sm leading-normal whitespace-pre-wrap text-accent-foreground">
127
+ <p className="max-w-full min-w-0 rounded-md bg-accent px-4 py-2 text-sm leading-normal wrap-anywhere whitespace-pre-wrap text-accent-foreground">
128
128
  {text}
129
129
  </p>
130
130
  )}
@@ -8,6 +8,7 @@ import type {
8
8
  ClientMessage,
9
9
  PreviewFrame,
10
10
  ScratchOp,
11
+ SessionActivity,
11
12
  StreamEvent,
12
13
  ThreadConfig,
13
14
  ViewState
@@ -24,17 +25,19 @@ export function reduceChatFrame(data: Record<string, unknown>, context: ChatFram
24
25
  const store = liveStore.getState()
25
26
 
26
27
  if (data.type === 'status_snapshot') {
27
- store.reconcileProcessing(
28
- (data.running as { workspaceId: string; sessionId: string }[] | undefined) ?? []
28
+ store.reconcileActivity(
29
+ (data.sessions as
30
+ | { workspaceId: string; sessionId: string; activity: SessionActivity }[]
31
+ | undefined) ?? []
29
32
  )
30
33
  return
31
34
  }
32
35
  if (data.type === 'status') {
33
36
  const workspaceId = data.workspaceId as string
34
37
  const sessionId = data.sessionId as string
35
- const processing = data.processing as boolean
36
- store.setProcessing(workspaceId, sessionId, processing)
37
- if (!processing) store.clearPreviewsForSession(workspaceId, sessionId)
38
+ const activity = data.activity as SessionActivity
39
+ store.setActivity(workspaceId, sessionId, activity)
40
+ if (activity !== 'running') store.clearPreviewsForSession(workspaceId, sessionId)
38
41
  return
39
42
  }
40
43
  if (data.type === 'preview') {
@@ -111,10 +114,14 @@ export function reduceChatFrame(data: Record<string, unknown>, context: ChatFram
111
114
  }
112
115
  if (kind === 'error' && typeof data.content === 'string') {
113
116
  store.setError(workspaceId, sessionId, data.content)
117
+ // Servers only emit `error` terminally, so it also ends the busy state —
118
+ // relying solely on a separate status frame left the spinner stuck when
119
+ // that frame was lost.
120
+ store.setActivity(workspaceId, sessionId, 'idle')
114
121
  store.clearPreviewsForSession(workspaceId, sessionId)
115
122
  }
116
123
  if (kind === 'stopped') {
117
- store.setProcessing(workspaceId, sessionId, false)
124
+ store.setActivity(workspaceId, sessionId, 'idle')
118
125
  store.clearPreviewsForSession(workspaceId, sessionId)
119
126
  }
120
127
  }
@@ -32,7 +32,7 @@ export function startOptimisticTurn({
32
32
  }
33
33
  })
34
34
  )
35
- liveStore.getState().setProcessing(workspaceId, sessionId, true)
35
+ liveStore.getState().setActivity(workspaceId, sessionId, 'running')
36
36
  liveStore.getState().setError(workspaceId, sessionId, null)
37
37
  return optimisticId
38
38
  }
@@ -1,7 +1,7 @@
1
1
  import { useStore } from 'zustand'
2
2
  import { createStore } from 'zustand/vanilla'
3
3
 
4
- import type { PreviewBlock, PreviewFrame, UploadInfo } from '@/lib/types'
4
+ import type { PreviewBlock, PreviewFrame, SessionActivity, UploadInfo } from '@/lib/types'
5
5
 
6
6
  // One composer attachment, tracked per thread until the message is sent. It is
7
7
  // uploaded as soon as it's added (drop/paste/pick); `status` reflects that
@@ -20,7 +20,7 @@ export type ChatAttachment = {
20
20
  // App-level ephemeral chat state — the bits that are *pushed* from the server
21
21
  // over the WebSocket and can't be re-fetched as request/response data:
22
22
  // - which thread is active per workspace (a UI selection),
23
- // - per-session `processing` (spinner) flags,
23
+ // - per-session `activity` (spinner) state,
24
24
  // - per-session error banners.
25
25
  //
26
26
  // The durable message transcripts live in the React Query cache (see
@@ -56,7 +56,10 @@ export type LivePreview = {
56
56
 
57
57
  export type LiveStore = {
58
58
  activeByWorkspace: Record<string, string | null>
59
- processing: Record<string, boolean>
59
+ // Per-session activity mirrored from server `status` frames. Only `running`
60
+ // shows the loader/Stop; `requires-action` is tracked but not rendered yet.
61
+ // Missing key = idle.
62
+ activity: Record<string, SessionActivity>
60
63
  errors: Record<string, string | null>
61
64
  // Live token-streaming previews, keyed by `messageId` (the API `msg_...` id)
62
65
  // so concurrent streams never collide. Reconciled against the durable
@@ -73,11 +76,13 @@ export type LiveStore = {
73
76
  attachments: Record<string, ChatAttachment[]>
74
77
 
75
78
  setActive: (workspaceId: string, sessionId: string | null) => void
76
- setProcessing: (workspaceId: string, sessionId: string, value: boolean) => void
79
+ setActivity: (workspaceId: string, sessionId: string, value: SessionActivity) => void
77
80
  // Authoritative reconcile from a server `status_snapshot`: exactly the listed
78
- // sessions are processing; everything else is cleared (fixes a spinner whose
79
- // terminal status was emitted while we were disconnected).
80
- reconcileProcessing: (running: { workspaceId: string; sessionId: string }[]) => void
81
+ // sessions are active; everything else is cleared to idle (fixes a spinner
82
+ // whose terminal status frame was lost while we were disconnected).
83
+ reconcileActivity: (
84
+ sessions: { workspaceId: string; sessionId: string; activity: SessionActivity }[]
85
+ ) => void
81
86
  setError: (workspaceId: string, sessionId: string, message: string | null) => void
82
87
  setDraft: (workspaceId: string, sessionId: string | null, value: string) => void
83
88
  addAttachments: (workspaceId: string, sessionId: string | null, items: ChatAttachment[]) => void
@@ -107,7 +112,7 @@ export type LiveStore = {
107
112
 
108
113
  export const liveStore = createStore<LiveStore>()(set => ({
109
114
  activeByWorkspace: {},
110
- processing: {},
115
+ activity: {},
111
116
  errors: {},
112
117
  drafts: {},
113
118
  previews: {},
@@ -116,12 +121,12 @@ export const liveStore = createStore<LiveStore>()(set => ({
116
121
  setActive: (workspaceId, sessionId) =>
117
122
  set(s => ({ activeByWorkspace: { ...s.activeByWorkspace, [workspaceId]: sessionId } })),
118
123
 
119
- setProcessing: (workspaceId, sessionId, value) =>
120
- set(s => ({ processing: { ...s.processing, [key(workspaceId, sessionId)]: value } })),
124
+ setActivity: (workspaceId, sessionId, value) =>
125
+ set(s => ({ activity: { ...s.activity, [key(workspaceId, sessionId)]: value } })),
121
126
 
122
- reconcileProcessing: running =>
127
+ reconcileActivity: sessions =>
123
128
  set(() => ({
124
- processing: Object.fromEntries(running.map(r => [key(r.workspaceId, r.sessionId), true]))
129
+ activity: Object.fromEntries(sessions.map(r => [key(r.workspaceId, r.sessionId), r.activity]))
125
130
  })),
126
131
 
127
132
  setError: (workspaceId, sessionId, message) =>
@@ -219,11 +224,11 @@ export const liveStore = createStore<LiveStore>()(set => ({
219
224
  set(s => {
220
225
  const fromKey = key(workspaceId, from)
221
226
  const toKey = key(workspaceId, to)
222
- const processing = { ...s.processing }
227
+ const activity = { ...s.activity }
223
228
  const errors = { ...s.errors }
224
- if (fromKey in processing) {
225
- processing[toKey] = processing[fromKey]
226
- delete processing[fromKey]
229
+ if (fromKey in activity) {
230
+ activity[toKey] = activity[fromKey]
231
+ delete activity[fromKey]
227
232
  }
228
233
  if (fromKey in errors) {
229
234
  errors[toKey] = errors[fromKey]
@@ -246,7 +251,7 @@ export const liveStore = createStore<LiveStore>()(set => ({
246
251
  previews[id] = { ...p, sessionId: to }
247
252
  }
248
253
  }
249
- return { processing, errors, activeByWorkspace, previews }
254
+ return { activity, errors, activeByWorkspace, previews }
250
255
  })
251
256
  }))
252
257
 
@@ -8,7 +8,6 @@ import type { ToolCall } from '@/lib/types'
8
8
  import { Button } from '@/client/components/ui/button'
9
9
  import { CodeBlock } from './CodeBlock'
10
10
  import { detectOutput } from './detect'
11
- import { formatBytes } from './format'
12
11
 
13
12
  type ToolOutputProps = { call: ToolCall; output: string; isError: boolean }
14
13
 
@@ -49,13 +48,7 @@ export function ToolOutput({ call, output, isError }: ToolOutputProps) {
49
48
  return (
50
49
  <div className="overflow-hidden rounded-md border border-border bg-muted">
51
50
  {/* Size is always the raw output; copy grabs whatever's currently shown. */}
52
- <Header
53
- raw={raw}
54
- onRaw={setRaw}
55
- label={view.label}
56
- size={formatBytes(output)}
57
- copyText={raw ? output : view.code}
58
- />
51
+ <Header raw={raw} onRaw={setRaw} label={view.label} copyText={raw ? output : view.code} />
59
52
  {raw ? (
60
53
  <pre className={cn(PRE, 'break-all whitespace-pre-wrap text-muted-foreground')}>
61
54
  {output || '(empty)'}
@@ -71,19 +64,18 @@ type HeaderProps = {
71
64
  raw: boolean
72
65
  onRaw: (raw: boolean) => void
73
66
  label: string
74
- size: string
75
67
  copyText: string
76
68
  }
77
69
 
78
70
  // Output toolbar: a left outline switch (<label> | raw), and on the right the
79
71
  // raw byte size + a copy button.
80
- function Header({ raw, onRaw, label, size, copyText }: HeaderProps) {
72
+ function Header({ raw, onRaw, label, copyText }: HeaderProps) {
81
73
  const options: [boolean, string][] = [
82
74
  [false, label],
83
75
  [true, 'raw']
84
76
  ]
85
77
  return (
86
- <div className="flex items-center gap-1 border-b border-border px-2 py-1">
78
+ <div className="flex items-center gap-1 border-b border-border p-2">
87
79
  {options.map(([value, text]) => (
88
80
  <Button
89
81
  key={text}
@@ -91,12 +83,12 @@ function Header({ raw, onRaw, label, size, copyText }: HeaderProps) {
91
83
  variant={raw === value ? 'outline' : 'ghost'}
92
84
  size="sm"
93
85
  onClick={() => onRaw(value)}
86
+ className="rounded-full text-xs uppercase"
94
87
  >
95
88
  {text}
96
89
  </Button>
97
90
  ))}
98
91
  <div className="flex-1" />
99
- <span className="text-[10px] font-medium text-muted-foreground tabular-nums">{size}</span>
100
92
  <CopyButton text={copyText} />
101
93
  </div>
102
94
  )
@@ -68,12 +68,6 @@ function getInputValue(input: Record<string, unknown>, key: string): string {
68
68
  return typeof value === 'string' ? value : ''
69
69
  }
70
70
 
71
- // Human byte size of a string (UTF-8): `124B`, `2.5KB`.
72
- export function formatBytes(text: string): string {
73
- const n = new TextEncoder().encode(text).length
74
- return n < 1024 ? `${n}B` : `${(n / 1024).toFixed(1)}KB`
75
- }
76
-
77
71
  // Compact wall-clock duration: sub-second → "850ms", under a minute → "3.2s" /
78
72
  // "11s", longer → "1m 5s". Used on the subagent card's duration badge.
79
73
  export function formatDuration(ms: number): string {