moi-computer 0.11.1-next.1 → 0.11.1-next.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/client/features/chat/chat-frames.ts +4 -5
  2. package/client/features/chat/chat-send.ts +13 -2
  3. package/client/features/chat/chat-store.ts +1 -3
  4. package/client/features/chat/composer/ModelPicker.tsx +40 -41
  5. package/client/features/chat/composer/model-order.ts +15 -0
  6. package/client/features/chat/group-turns.ts +1 -0
  7. package/client/features/chat/interleave-notices.ts +7 -11
  8. package/client/features/chat/tool-group/ToolCallGroup.tsx +1 -4
  9. package/client/features/chat/tool-group/format/codex.ts +4 -1
  10. package/client/features/chat/useChat.ts +5 -8
  11. package/dist/chunk-245wt82v.css +1 -0
  12. package/dist/{chunk-yc471zah.js → chunk-j7hh2ab4.js} +48 -48
  13. package/dist/{chunk-vwjeezeb.js → chunk-y8eyahwx.js} +1 -1
  14. package/dist/index.html +1 -1
  15. package/lib/format.ts +6 -5
  16. package/lib/types.ts +5 -2
  17. package/package.json +1 -1
  18. package/server/api.ts +1 -1
  19. package/server/bundler/applet-css.ts +1 -106
  20. package/server/harness/README.md +28 -39
  21. package/server/harness/codex/NOTES.md +222 -350
  22. package/server/harness/codex/adapter.ts +94 -45
  23. package/server/harness/codex/auth.ts +1 -3
  24. package/server/harness/codex/client.ts +169 -249
  25. package/server/harness/codex/discovery.ts +9 -17
  26. package/server/harness/codex/index.ts +2 -1
  27. package/server/harness/codex/pagination.ts +24 -0
  28. package/server/harness/codex/permissions.ts +31 -7
  29. package/server/harness/codex/probe.ts +10 -13
  30. package/server/harness/codex/session.ts +549 -136
  31. package/server/harness/codex/transport.ts +184 -0
  32. package/server/harness/debug.ts +1 -1
  33. package/server/web.ts +3 -0
  34. package/ui-components/alert-dialog.tsx +1 -1
  35. package/ui-components/alert.tsx +1 -1
  36. package/ui-components/avatar.tsx +1 -1
  37. package/ui-components/checkbox.tsx +2 -1
  38. package/ui-components/combobox.tsx +3 -1
  39. package/ui-components/field.tsx +1 -1
  40. package/ui-components/input-group.tsx +2 -2
  41. package/ui-components/radio-group.tsx +2 -1
  42. package/ui-components/switch.tsx +2 -1
  43. package/dist/chunk-6664vxpk.css +0 -1
@@ -144,11 +144,10 @@ export function reduceChatFrame(data: Record<string, unknown>, context: ChatFram
144
144
  }
145
145
  if (kind === 'error' && typeof data.content === 'string') {
146
146
  store.setError(workspaceId, sessionId, data.content)
147
- // Servers only emit `error` terminally, so it also ends the busy state —
148
- // relying solely on a separate status frame left the spinner stuck when
149
- // that frame was lost.
150
- store.setActivity(workspaceId, sessionId, 'idle')
151
- store.clearPreviewsForSession(workspaceId, sessionId)
147
+ if (data.terminal !== false) {
148
+ store.setActivity(workspaceId, sessionId, 'idle')
149
+ store.clearPreviewsForSession(workspaceId, sessionId)
150
+ }
152
151
  }
153
152
  if (kind === 'stopped') {
154
153
  store.setActivity(workspaceId, sessionId, 'idle')
@@ -2,6 +2,7 @@ import type { QueryClient } from '@tanstack/react-query'
2
2
 
3
3
  import { workspaceKeys } from '@/client/api/workspace-keys'
4
4
  import { attachmentKey, type ChatAttachment, liveStore } from '@/client/features/chat/chat-store'
5
+ import { resolveSelectedModel } from '@/client/features/chat/composer/model-order'
5
6
  import type { MoiUserMessageOptions } from '@/client/features/workspace/moi-context'
6
7
  import { STREAM_RESPONSES } from '@/client/lib/flags'
7
8
  import { formatChatTitle } from '@/lib/chat-title'
@@ -148,11 +149,21 @@ export function resolveChatRunOptions(
148
149
  pickedFastMode?: boolean
149
150
  ): { model?: string; effort?: string; fastMode?: boolean; stream?: true } {
150
151
  const models = modelsData?.models
151
- const model =
152
+ const savedModel =
152
153
  !pickedModel || !models || models.some(candidate => candidate.value === pickedModel)
153
154
  ? pickedModel
154
155
  : undefined
155
- const modelInfo = models?.find(candidate => candidate.value === model)
156
+ const modelInfo =
157
+ modelsData?.provider === 'codex'
158
+ ? resolveSelectedModel(modelsData.models, pickedModel)
159
+ : models?.find(candidate => candidate.value === (savedModel ?? 'default'))
160
+ // Omitting Codex's model inherits config.toml (or the resumed thread's
161
+ // model), which can be unavailable even though the picker shows a supported
162
+ // fallback. Always send the concrete model the Codex picker displays.
163
+ const model =
164
+ modelsData?.provider === 'codex' && modelInfo
165
+ ? (modelInfo.resolvedModel ?? modelInfo.value)
166
+ : savedModel
156
167
  const effort =
157
168
  pickedEffort && (!modelInfo || (modelInfo.supportedEffortLevels ?? []).includes(pickedEffort))
158
169
  ? pickedEffort
@@ -112,9 +112,7 @@ export type LivePreview = {
112
112
  }
113
113
 
114
114
  export type LiveStore = {
115
- // Per-session activity mirrored from server `status` frames. Only `running`
116
- // shows the loader/Stop; `requires-action` is tracked but not rendered yet.
117
- // Missing key = idle.
115
+ // Per-session activity mirrored from server `status` frames. Missing key = idle.
118
116
  activity: Record<string, SessionActivity>
119
117
  errors: Record<string, string | null>
120
118
  // Live token-streaming previews, keyed by `messageId` (the API `msg_...` id)
@@ -12,6 +12,7 @@ import {
12
12
  resolveDisplayedEffort,
13
13
  resolveEffortIndex,
14
14
  resolveFastMode,
15
+ resolveSelectedModel,
15
16
  sortModelsByProviderOrder
16
17
  } from './model-order'
17
18
  import { Button } from '@/client/components/ui/button'
@@ -125,6 +126,38 @@ function ModelDropdown({ current, model, models, onValueChange }: ModelDropdownP
125
126
  )
126
127
  }
127
128
 
129
+ type FastModeToggleProps = { fastMode: boolean; onChange: (value: boolean) => void }
130
+
131
+ function FastModeToggle({ fastMode, onChange }: FastModeToggleProps) {
132
+ return (
133
+ <Tooltip>
134
+ <TooltipTrigger
135
+ render={
136
+ <Button
137
+ type="button"
138
+ variant="ghost"
139
+ size="icon-sm"
140
+ aria-label={fastMode ? 'Turn off fast mode' : 'Turn on fast mode'}
141
+ aria-pressed={fastMode}
142
+ onClick={() => onChange(!fastMode)}
143
+ className="-my-1 -mr-1"
144
+ >
145
+ {fastMode ? (
146
+ <IconBoltFilled className="text-primary" stroke={1.75} />
147
+ ) : (
148
+ <IconBolt className="text-muted-foreground" stroke={1.75} />
149
+ )}
150
+ </Button>
151
+ }
152
+ />
153
+ <TooltipContent align="center" className="flex-col gap-0">
154
+ <span>Fast mode</span>
155
+ <span className="font-normal text-muted-foreground">More usage</span>
156
+ </TooltipContent>
157
+ </Tooltip>
158
+ )
159
+ }
160
+
128
161
  type EffortPickerProps = {
129
162
  currentEffort: string
130
163
  effortLevels: readonly string[]
@@ -203,33 +236,7 @@ function EffortPicker({
203
236
  <span className="text-muted-foreground">Effort</span>
204
237
  <output aria-live="polite">{displayedLabel}</output>
205
238
  </div>
206
- {showFastMode && (
207
- <Tooltip>
208
- <TooltipTrigger
209
- render={
210
- <Button
211
- type="button"
212
- variant="ghost"
213
- size="icon-sm"
214
- aria-label={fastMode ? 'Turn off Fast mode' : 'Turn on Fast mode'}
215
- aria-pressed={fastMode}
216
- onClick={() => onFastModeChange(!fastMode)}
217
- className="-my-1 -mr-1"
218
- >
219
- {fastMode ? (
220
- <IconBoltFilled className="text-primary" />
221
- ) : (
222
- <IconBolt className="text-muted-foreground" stroke={1.5} />
223
- )}
224
- </Button>
225
- }
226
- />
227
- <TooltipContent align="center" className="flex-col gap-0">
228
- <span>Fast mode</span>
229
- <span className="font-normal text-muted-foreground">More usage</span>
230
- </TooltipContent>
231
- </Tooltip>
232
- )}
239
+ {showFastMode && <FastModeToggle fastMode={fastMode} onChange={onFastModeChange} />}
233
240
  </motion.div>
234
241
  )}
235
242
  </AnimatePresence>
@@ -324,19 +331,8 @@ export const ModelPicker = memo(function ModelPicker({ sessionId }: ModelPickerP
324
331
  else setLayout({ selectedFastMode: value })
325
332
  }
326
333
 
327
- if (models.length === 0) return null
328
-
329
- // Show a persisted pick when it still exists. Otherwise name the concrete
330
- // model behind the SDK default, or fall back to the first available model.
331
- const persistedModel = models.some(model => model.value === selectedModel)
332
- ? selectedModel
333
- : undefined
334
- const defaultModel =
335
- models.find(
336
- model => defaultEntry?.resolvedModel && model.resolvedModel === defaultEntry.resolvedModel
337
- ) ?? models[0]
338
- const currentModelValue = persistedModel ?? defaultModel.value
339
- const model = models.find(item => item.value === currentModelValue) ?? models[0]
334
+ const model = resolveSelectedModel(models, selectedModel, defaultEntry?.resolvedModel)
335
+ if (!model) return null
340
336
  const effortLevels = model.supportsEffort ? (model.supportedEffortLevels ?? []) : []
341
337
  const currentEffort = resolveDisplayedEffort(effortLevels, selectedEffort, model.defaultEffort)
342
338
  const showEffort = hasEffortChoice(effortLevels) && currentEffort !== undefined
@@ -345,11 +341,14 @@ export const ModelPicker = memo(function ModelPicker({ sessionId }: ModelPickerP
345
341
  return (
346
342
  <div className="flex min-w-0 items-center gap-1">
347
343
  <ModelDropdown
348
- current={currentModelValue}
344
+ current={model.value}
349
345
  model={model}
350
346
  models={models}
351
347
  onValueChange={setSelectedModel}
352
348
  />
349
+ {!showEffort && model.supportsFastMode && (
350
+ <FastModeToggle fastMode={fastMode} onChange={setSelectedFastMode} />
351
+ )}
353
352
  {showEffort && (
354
353
  <EffortPicker
355
354
  key={model.value}
@@ -6,6 +6,21 @@ const ANTHROPIC_MODEL_FAMILY_ORDER = ['fable', 'opus', 'sonnet', 'haiku'] as con
6
6
 
7
7
  type ModelComparator = (a: Model, b: Model) => number
8
8
 
9
+ // Resolve the same concrete row for the picker and the outgoing chat request.
10
+ // Unavailable selections fall back to the resolved default, then the first row.
11
+ export function resolveSelectedModel(
12
+ models: readonly Model[],
13
+ selectedModel: string | undefined,
14
+ defaultModel = models.find(model => model.value === 'default')?.resolvedModel
15
+ ): Model | undefined {
16
+ const choices = models.filter(model => model.value !== 'default')
17
+ return (
18
+ choices.find(model => model.value === selectedModel) ??
19
+ choices.find(model => (model.resolvedModel ?? model.value) === defaultModel) ??
20
+ choices[0]
21
+ )
22
+ }
23
+
9
24
  function anthropicModelFamilyRank(model: Model): number | undefined {
10
25
  const key = model.resolvedModel ?? model.value
11
26
  const rank = ANTHROPIC_MODEL_FAMILY_ORDER.findIndex(
@@ -54,6 +54,7 @@ export function groupTurns(turns: Turn[]): Turn[] {
54
54
  const previous = out[index - 1]
55
55
  if (
56
56
  turn.role !== 'assistant' ||
57
+ turn.meta?.durationMs !== undefined ||
57
58
  previous?.role !== 'user' ||
58
59
  previous.origin.kind !== 'user-input' ||
59
60
  !previous.timestamp ||
@@ -1,9 +1,7 @@
1
1
  // Weaves transcript notices (context compaction, mid-session model switches)
2
2
  // into the turn list so each one reads at the moment it happened.
3
3
  //
4
- // Only 'compact' and 'model-change' render today. Every other SystemNotice
5
- // kind is claude-code-specific plumbing with no designed chat treatment yet,
6
- // so `chatNoticeLabel` skips it explicitly.
4
+ // Only notices with a chat label enter the timeline.
7
5
  import type { SystemNotice, Turn } from '@/lib/types'
8
6
 
9
7
  export type ChatTimelineItem =
@@ -13,16 +11,19 @@ export type ChatTimelineItem =
13
11
  // One-line copy for a notice row; null = this kind does not render in chat.
14
12
  export function chatNoticeLabel(notice: SystemNotice): string | null {
15
13
  switch (notice.kind) {
14
+ case 'warning':
15
+ return notice.message
16
16
  case 'compact':
17
17
  return 'Context compacted'
18
18
  case 'model-change':
19
19
  return notice.prev
20
20
  ? `Model changed to ${notice.model} (was ${notice.prev})`
21
21
  : `Model changed to ${notice.model}`
22
+ case 'api-retry':
23
+ return notice.error ? `Retrying: ${notice.error}` : 'Retrying the connection'
22
24
  // Claude-code-specific notices without a designed chat treatment yet —
23
25
  // skipped on purpose. New kinds stay hidden until designed.
24
26
  case 'rate-limit':
25
- case 'api-retry':
26
27
  case 'hook':
27
28
  case 'session-state':
28
29
  case 'files-persisted':
@@ -44,13 +45,8 @@ function parseTime(value: string | undefined): number | undefined {
44
45
  // notices never jump ahead of undated turns. Notices with no parseable `at`
45
46
  // have no comparable anchor and go after the last turn.
46
47
  //
47
- // Known limitation — a transcript whose turns are ALL undated gives nothing to
48
- // compare against, so every dated notice lands after the last turn. That is
49
- // right while a session is live (compaction happens at the current end of the
50
- // conversation) but drifts on replay: the notice follows the new end instead of
51
- // staying where it happened. Codex hits this today — `codexItemToTurn` sets no
52
- // `timestamp` and `codexItemToNotice` stamps `at` with replay-time `new Date()`
53
- // — so fixing it means giving those rows a real anchor, not changing the merge.
48
+ // Entirely undated transcripts cannot anchor notices. Adapters must supply
49
+ // native timestamps when available; otherwise dated notices follow all turns.
54
50
  export function interleaveNotices(turns: Turn[], notices: SystemNotice[]): ChatTimelineItem[] {
55
51
  const shown = notices.filter(notice => chatNoticeLabel(notice) !== null)
56
52
  if (shown.length === 0) return turns.map((turn): ChatTimelineItem => ({ kind: 'turn', turn }))
@@ -152,10 +152,7 @@ function ToolRow({ isFirst, isLast, call, leading, marker, name, brief, preview
152
152
  // anything follows it (a text/tool row makes it no longer the last row, so
153
153
  // `inProgress` goes false and it reverts to the user's collapsed default).
154
154
  //
155
- // Some backends report that the model reasoned without handing over the text
156
- // (Anthropic `redacted_thinking`; the OpenClaw codex app-server, which sends a
157
- // Reasoning item with timing only). Those rows have nothing to expand, so they
158
- // render as a bare label — "Thought for 1.2s" — with no chevron.
155
+ // Reasoning without visible text renders as a duration label with no chevron.
159
156
  type ReasoningRowProps = RowPosition & {
160
157
  text: string
161
158
  inProgress?: boolean
@@ -103,7 +103,10 @@ function brief(call: ToolCall, shorten: Shorten): string {
103
103
  if (Array.isArray(queries) && queries.length > 0) {
104
104
  return queries.filter((q): q is string => typeof q === 'string').join(' · ')
105
105
  }
106
- return getInputValue(input, 'query')
106
+ return (
107
+ getInputValue(input, 'query') ||
108
+ [getInputValue(input, 'url'), getInputValue(input, 'pattern')].filter(Boolean).join(' · ')
109
+ )
107
110
  }
108
111
  if (tool === 'update_plan') {
109
112
  const plan = input.plan
@@ -66,8 +66,7 @@ export function useChat(address: WorkspaceTabAddress) {
66
66
  const activity = useLive(s =>
67
67
  selectedSessionId ? (s.activity[`${workspaceId}:${selectedSessionId}`] ?? 'idle') : 'idle'
68
68
  )
69
- // Only `running` shows the loader/Stop. `requires-action` (agent blocked on
70
- // user input) deliberately renders like idle until it gets its own UI.
69
+ // Only running shows the loader/Stop.
71
70
  const processing = isRunningActivity(activity)
72
71
  const error = useLive(s =>
73
72
  selectedSessionId ? (s.errors[`${workspaceId}:${selectedSessionId}`] ?? null) : null
@@ -138,12 +137,10 @@ export function useChat(address: WorkspaceTabAddress) {
138
137
  parts
139
138
  })
140
139
 
141
- // The session's persisted choice (workspace defaults for a new chat). Drop a
142
- // model the loaded list no longer offers (stale alias) so the SDK doesn't
143
- // reject model_not_found. Drop an effort the resolved model doesn't
144
- // support and explicitly disable Fast mode on a known unsupported model.
145
- // When the model is unknown/default we can't validate either capability,
146
- // so pass the stored choices through.
140
+ // Resolve the session/workspace choice against the catalog. Codex sends
141
+ // the picker's concrete model even for an implicit or stale selection;
142
+ // otherwise its config or resumed thread can choose a different model.
143
+ // Validate effort and Fast mode against that same resolved row.
147
144
  const pickedModel = sessionConfig?.model ?? layout.selectedModel
148
145
  const pickedEffort = sessionConfig?.effort ?? layout.selectedEffort
149
146
  const pickedFastMode = sessionConfig?.fastMode ?? layout.selectedFastMode