moi-computer 0.7.0 → 0.8.1-next.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.
Files changed (123) hide show
  1. package/README.md +2 -2
  2. package/client/api/workspace-keys.ts +1 -2
  3. package/client/app/AppRouter.tsx +10 -3
  4. package/client/app/routes/HomeRoute.tsx +1 -1
  5. package/client/app/shell/SidebarLayout.tsx +2 -14
  6. package/client/components/shared/BottomPanel.tsx +2 -1
  7. package/client/components/shared/Composer.tsx +20 -7
  8. package/client/components/shared/PanelHeader.tsx +8 -1
  9. package/client/components/ui/button.tsx +3 -3
  10. package/client/components/ui/dialog.tsx +1 -1
  11. package/client/components/ui/dropdown-menu.tsx +2 -2
  12. package/client/components/ui/hover-card.tsx +1 -1
  13. package/client/components/ui/popover.tsx +1 -1
  14. package/client/components/ui/resizable.tsx +40 -0
  15. package/client/features/applets/AppletMount.tsx +9 -22
  16. package/client/features/applets/applet-cache.ts +7 -0
  17. package/client/features/applets/applet-styles.ts +21 -1
  18. package/client/features/applets/useApplet.ts +1 -1
  19. package/client/features/chat/ChatEmptyState.tsx +9 -11
  20. package/client/features/chat/ChatPanel.tsx +76 -48
  21. package/client/features/chat/ChatPopup.tsx +16 -2
  22. package/client/features/chat/ChatPromptBubbles.tsx +6 -8
  23. package/client/features/chat/ChatSelector.tsx +25 -8
  24. package/client/features/chat/ModelPicker.tsx +5 -4
  25. package/client/features/chat/TurnView.tsx +108 -13
  26. package/client/features/chat/api.ts +1 -18
  27. package/client/features/chat/chat-send.ts +2 -2
  28. package/client/features/chat/{ChatComposer.tsx → composer/ChatComposer.tsx} +24 -9
  29. package/client/features/chat/composer/banners/ChatErrorBanner.tsx +28 -0
  30. package/client/features/chat/composer/banners/ComposerBanner.tsx +30 -0
  31. package/client/features/chat/composer/banners/WorkspaceAgentAvailabilityBanner.tsx +91 -0
  32. package/client/features/{workspace → chat/composer/banners}/WorkspaceSkillUpdateBanner.tsx +9 -7
  33. package/client/features/chat/composer/useWorkspaceComposerState.tsx +74 -0
  34. package/client/features/{workspace → chat/composer}/useWorkspaceSkillUpdates.ts +1 -1
  35. package/client/features/chat/group-turns.ts +46 -28
  36. package/client/features/chat/interleave-notices.ts +84 -0
  37. package/client/features/chat/model-order.ts +9 -3
  38. package/client/features/chat/tool-group/TimelineRow.tsx +23 -11
  39. package/client/features/chat/tool-group/ToolCallGroup.tsx +38 -3
  40. package/client/features/chat/tool-group/format.ts +23 -7
  41. package/client/features/chat/useAppletChatMessage.ts +11 -16
  42. package/client/features/chat/useChat.ts +3 -7
  43. package/client/features/dev/ChatStatesPage.tsx +428 -0
  44. package/client/features/dev/DevIndexPage.tsx +52 -0
  45. package/client/features/dev/DevRoutes.tsx +6 -3
  46. package/client/features/dev/HarnessDebugPage.tsx +3 -3
  47. package/client/features/dev/chat-states-fixtures.ts +744 -0
  48. package/client/features/home/api.ts +0 -10
  49. package/client/features/home/workspace-setup/CreateWorkspaceDialog.tsx +21 -64
  50. package/client/features/home/workspace-setup/ImportWorkspaceDialog.tsx +1 -1
  51. package/client/features/scratchpad/Scratchpad.tsx +5 -3
  52. package/client/features/scratchpad/scratch-session.ts +71 -0
  53. package/client/features/views/ViewBuilderTab.tsx +5 -4
  54. package/client/features/views/ViewManager.tsx +258 -0
  55. package/client/features/views/useViewBuilderActions.ts +2 -2
  56. package/client/features/views/view-residency.ts +77 -0
  57. package/client/features/widgets/WidgetFrame.tsx +6 -2
  58. package/client/features/workspace/CustomizePanel.tsx +40 -24
  59. package/client/features/workspace/WorkspaceLayoutContext.tsx +12 -2
  60. package/client/features/workspace/WorkspaceScreen.tsx +131 -201
  61. package/client/features/workspace/WorkspaceSplitLayout.tsx +111 -0
  62. package/client/features/workspace/WorkspaceTabs.tsx +1 -1
  63. package/client/features/workspace/api.ts +33 -8
  64. package/client/features/workspace/useFitsSplitLayout.ts +31 -5
  65. package/client/index.css +5 -2
  66. package/client/lib/flags.ts +4 -3
  67. package/client/runtime/useWorkspaceEvents.ts +18 -1
  68. package/client/runtime/workspace-theme.ts +29 -10
  69. package/client/store/ui.ts +5 -1
  70. package/client/theme.css +96 -6
  71. package/dist/{chunk-0pcdwjkp.js → chunk-2vaafjp4.js} +1 -1
  72. package/dist/{chunk-9y2zbzqz.js → chunk-35fq49qa.js} +1 -1
  73. package/dist/chunk-gny990qx.css +1 -0
  74. package/dist/chunk-gt7n06ef.js +1 -0
  75. package/dist/{chunk-rxvx4ta9.js → chunk-kkj86722.js} +75 -75
  76. package/dist/chunk-n7pga5x3.js +80 -0
  77. package/dist/chunk-xeyxk7ep.js +10 -0
  78. package/dist/{chunk-w3tnv51j.js → chunk-xzx7c9hq.js} +1 -1
  79. package/dist/index.html +1 -1
  80. package/lib/format.ts +17 -1
  81. package/lib/themes.ts +123 -51
  82. package/lib/types.ts +40 -13
  83. package/lib/workspace-layout.ts +2 -2
  84. package/package.json +6 -4
  85. package/server/agent.ts +199 -0
  86. package/server/api.ts +38 -90
  87. package/server/bundler/build-applet.ts +7 -4
  88. package/server/cli.ts +46 -15
  89. package/server/control.ts +13 -6
  90. package/server/env-apply.ts +4 -0
  91. package/server/harness/README.md +28 -12
  92. package/server/harness/claude-code/auth.ts +54 -0
  93. package/server/harness/claude-code/index.ts +6 -1
  94. package/server/harness/codex/adapter.ts +9 -1
  95. package/server/harness/codex/auth.ts +50 -0
  96. package/server/harness/codex/index.ts +6 -1
  97. package/server/harness/codex/session.ts +33 -14
  98. package/server/harness/openclaw/NOTES.md +518 -187
  99. package/server/harness/openclaw/adapter.ts +125 -31
  100. package/server/harness/openclaw/compat.ts +99 -0
  101. package/server/harness/openclaw/cron-view.ts +78 -0
  102. package/server/harness/openclaw/discovery.ts +145 -52
  103. package/server/harness/openclaw/gateway.ts +224 -36
  104. package/server/harness/openclaw/index.ts +56 -21
  105. package/server/harness/openclaw/session.ts +971 -55
  106. package/server/harness/openclaw/strip.ts +87 -15
  107. package/server/harness/openclaw/thinking.ts +198 -0
  108. package/server/harness/types.ts +10 -5
  109. package/server/layout.ts +5 -2
  110. package/server/moi-scaffold.ts +1 -1
  111. package/server/registry.ts +0 -20
  112. package/server/theme.ts +24 -27
  113. package/workspace/.claude/skills/moi-workspace/DESIGN.md +100 -53
  114. package/workspace/.claude/skills/moi-workspace/SKILL.md +10 -12
  115. package/client/features/dev/PixelPainter.tsx +0 -94
  116. package/client/features/dev/PlaygroundPage.tsx +0 -69
  117. package/dist/chunk-175bm057.js +0 -27
  118. package/dist/chunk-55sh4dty.js +0 -2
  119. package/dist/chunk-afgbg75t.js +0 -50
  120. package/dist/chunk-agtetn7n.css +0 -1
  121. package/dist/chunk-dfs36zgc.js +0 -1
  122. package/dist/chunk-exj6hr30.js +0 -9
  123. package/dist/chunk-m11ckkxd.js +0 -51
@@ -2,6 +2,7 @@
2
2
  // ../types.ts for the contract and ../README.md for the architecture.
3
3
  import type { Harness } from '../types'
4
4
  import { findHarnessExecutable, pathHarnessAvailability } from '../executable'
5
+ import { getCodexAuthReadiness, startCodexLogin } from './auth'
5
6
  import {
6
7
  archiveCodexSession,
7
8
  getCodexMcpStatus,
@@ -59,7 +60,11 @@ export const codexHarness: Harness = {
59
60
  listModels: ws => getCodexModels(ws.path),
60
61
  mcpStatus: ws => getCodexMcpStatus(ws.path),
61
62
  discoverWorkspaces: registeredPaths => discoverCodexWorkspaces(registeredPaths),
62
- availability: async () => pathHarnessAvailability('codex'),
63
+ availability: async ws => {
64
+ const runtime = await pathHarnessAvailability('codex')
65
+ return runtime.available && ws ? getCodexAuthReadiness(ws.path) : runtime
66
+ },
67
+ startLogin: ws => startCodexLogin(ws.path),
63
68
 
64
69
  onEnvChanged: workspacePath => killCodexWorkspace(workspacePath),
65
70
  shutdown: () => killAllCodexClients(),
@@ -35,10 +35,12 @@ import {
35
35
  codexServiceTierForFastMode,
36
36
  codexItemToNotice,
37
37
  codexItemToTurn,
38
- codexThreadToEvents
38
+ codexThreadToEvents,
39
+ withCodexTurnDuration
39
40
  } from './adapter'
40
41
  import { type CodexClient, getCodexClient, interruptCodexTurn, readSubagentRecords } from './client'
41
42
  import { generateCodexSessionTitle, renameCodexSessionIfUnchanged } from './session-title'
43
+ import { agentStore } from '../../agent'
42
44
  import { debug } from '../../debug'
43
45
  import { broadcast } from '../../state'
44
46
  import { renameSelectedSession } from '../../selected-session'
@@ -243,30 +245,43 @@ function forwardPreview(
243
245
  })
244
246
  }
245
247
 
246
- // Fold the thread's latest per-turn usage into the newest assistant turn so
247
- // the meta strip can show tokens. Re-emits that turn (upsert-by-id).
248
- function applyUsage(rec: SessionRecord) {
248
+ // Fold native completion metadata into the newest assistant turn so replay and
249
+ // live rendering use the same display shape. Re-emits that turn (upsert-by-id).
250
+ function applyCompletionMeta(rec: SessionRecord, durationMs: number | null | undefined) {
249
251
  const last = rec.lastUsage?.last
250
- if (!last) return
251
252
  for (let i = rec.view.turns.length - 1; i >= 0; i--) {
252
253
  const t = rec.view.turns[i]
254
+ if (t.role === 'user' && t.origin.kind === 'user-input') return
253
255
  if (t.role !== 'assistant') continue
254
- const updated = {
255
- ...t,
256
- meta: {
257
- ...t.meta,
258
- usage: {
259
- inputTokens: last.inputTokens,
260
- outputTokens: last.outputTokens,
261
- totalTokens: last.totalTokens
256
+ let updated = withCodexTurnDuration(t, durationMs)
257
+ if (last) {
258
+ updated = {
259
+ ...updated,
260
+ meta: {
261
+ ...updated.meta,
262
+ usage: {
263
+ inputTokens: last.inputTokens,
264
+ outputTokens: last.outputTokens,
265
+ totalTokens: last.totalTokens
266
+ }
262
267
  }
263
268
  }
264
269
  }
270
+ if (updated === t) return
265
271
  emitTurnEvent(rec, { kind: 'turn', turn: updated })
266
272
  return
267
273
  }
268
274
  }
269
275
 
276
+ // A send/turn failure can mean the account was signed out from outside moi —
277
+ // a `codex logout` in a terminal, say — which the cached availability
278
+ // snapshot won't reflect until its TTL expires. Force a fresh probe so the
279
+ // composer's availability banner flips right away instead of the next send
280
+ // failing the same way.
281
+ function refreshAvailability(workspaceId: string, workspacePath: string) {
282
+ void agentStore.refresh({ id: workspaceId, path: workspacePath, type: 'codex' })
283
+ }
284
+
270
285
  function handleNotification(rec: SessionRecord, method: string, params: Record<string, unknown>) {
271
286
  if (method === '__exit') {
272
287
  // The app-server died (crash or env-change restart). Drop the record so
@@ -325,7 +340,7 @@ function handleNotification(rec: SessionRecord, method: string, params: Record<s
325
340
  case 'turn/completed': {
326
341
  const turn = params.turn as CodexTurn | undefined
327
342
  rec.previews.clear()
328
- applyUsage(rec)
343
+ applyCompletionMeta(rec, turn?.durationMs)
329
344
  setProcessing(rec, false, null)
330
345
  if (rec.refreshSessionsOnTurnComplete) {
331
346
  rec.refreshSessionsOnTurnComplete = false
@@ -337,6 +352,7 @@ function handleNotification(rec: SessionRecord, method: string, params: Record<s
337
352
  sessionId: rec.sessionId,
338
353
  content: turn.error.message
339
354
  })
355
+ refreshAvailability(rec.workspaceId, rec.workspacePath)
340
356
  }
341
357
  // An externally-interrupted turn otherwise ends silently, identical to a
342
358
  // clean completion — surface the stop so the client can render it.
@@ -350,6 +366,7 @@ function handleNotification(rec: SessionRecord, method: string, params: Record<s
350
366
  const message = err?.message ?? (typeof params.message === 'string' ? params.message : '')
351
367
  if (message) {
352
368
  broadcast(rec.workspaceId, { kind: 'error', sessionId: rec.sessionId, content: message })
369
+ refreshAvailability(rec.workspaceId, rec.workspacePath)
353
370
  }
354
371
  // A top-level error without a following turn/completed would otherwise
355
372
  // leave the session busy forever — the error is terminal for the turn.
@@ -642,6 +659,7 @@ export async function sendCodexMessage(input: {
642
659
  sessionId: input.sessionId,
643
660
  content: err instanceof Error ? err.message : 'failed to start codex session'
644
661
  })
662
+ refreshAvailability(input.workspaceId, input.workspacePath)
645
663
  return
646
664
  }
647
665
 
@@ -723,6 +741,7 @@ export async function sendCodexMessage(input: {
723
741
  sessionId: rec.sessionId,
724
742
  content: err instanceof Error ? err.message : 'send failed'
725
743
  })
744
+ refreshAvailability(rec.workspaceId, rec.workspacePath)
726
745
  }
727
746
  }
728
747