moi-computer 0.5.2-next.1 → 0.6.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 (83) hide show
  1. package/README.md +39 -0
  2. package/client/AGENTS.md +9 -0
  3. package/client/api/app-ui-keys.ts +4 -0
  4. package/client/api/workspace-keys.ts +2 -2
  5. package/client/app/routes/WorkspaceRoute.tsx +8 -28
  6. package/client/components/shared/Composer.tsx +3 -6
  7. package/client/components/shared/IconGhost.tsx +130 -0
  8. package/client/components/ui/dropdown-menu.tsx +1 -1
  9. package/client/components/ui/spinner.tsx +18 -0
  10. package/client/components/ui/toast.tsx +220 -0
  11. package/client/features/chat/ChatComposer.tsx +3 -2
  12. package/client/features/chat/ChatPanel.tsx +7 -6
  13. package/client/features/chat/ChatPopup.tsx +10 -4
  14. package/client/features/chat/ChatSelector.tsx +263 -48
  15. package/client/features/chat/ModelPicker.tsx +13 -18
  16. package/client/features/chat/api.ts +36 -9
  17. package/client/features/chat/chat-frames.ts +35 -6
  18. package/client/features/chat/chat-send.ts +25 -1
  19. package/client/features/chat/chat-store.ts +43 -18
  20. package/client/features/chat/useChat.ts +54 -52
  21. package/client/features/chat/useSelectedSession.ts +151 -0
  22. package/client/features/chat/useStickToBottom.ts +3 -3
  23. package/client/features/home/api.ts +0 -2
  24. package/client/features/scratchpad/ScratchpadControls.tsx +2 -2
  25. package/client/features/settings/WorkspaceSettings.tsx +6 -6
  26. package/client/features/views/ViewBuilderTab.tsx +3 -4
  27. package/client/features/views/useViewBuilderActions.ts +3 -1
  28. package/client/features/workspace/WorkspaceScreen.tsx +38 -17
  29. package/client/features/workspace/WorkspaceTabs.tsx +10 -1
  30. package/client/main.tsx +2 -0
  31. package/client/runtime/useWorkspaceEvents.ts +1 -0
  32. package/client/store/ui.ts +2 -2
  33. package/dist/{chunk-zs4mte79.js → chunk-0pcdwjkp.js} +1 -1
  34. package/dist/chunk-175bm057.js +27 -0
  35. package/dist/chunk-55sh4dty.js +2 -0
  36. package/dist/{chunk-tzz101ea.js → chunk-9y2zbzqz.js} +1 -1
  37. package/dist/{chunk-jvhvme3z.js → chunk-afgbg75t.js} +1 -1
  38. package/dist/chunk-agtetn7n.css +1 -0
  39. package/dist/chunk-dfs36zgc.js +1 -0
  40. package/dist/chunk-exj6hr30.js +9 -0
  41. package/dist/{chunk-bcrkdhwe.js → chunk-m11ckkxd.js} +1 -1
  42. package/dist/{chunk-kfw1qwqe.js → chunk-rxvx4ta9.js} +3 -3
  43. package/dist/{chunk-xwhya7kb.js → chunk-w3tnv51j.js} +1 -1
  44. package/dist/index.html +1 -1
  45. package/lib/attachment-note.ts +18 -0
  46. package/lib/chat-title.ts +6 -0
  47. package/lib/types.ts +24 -10
  48. package/package.json +1 -1
  49. package/server/agent-caller.ts +16 -0
  50. package/server/api.ts +90 -9
  51. package/server/app-settings.ts +1 -1
  52. package/server/cli.ts +628 -45
  53. package/server/control.ts +18 -1
  54. package/server/data-dir.ts +1 -1
  55. package/server/harness/README.md +6 -0
  56. package/server/harness/claude-code/adapter.ts +2 -2
  57. package/server/harness/claude-code/index.ts +7 -1
  58. package/server/harness/claude-code/session-title.ts +106 -0
  59. package/server/harness/claude-code/session.ts +107 -17
  60. package/server/harness/claude-code/sessions.ts +63 -4
  61. package/server/harness/codex/client.ts +33 -13
  62. package/server/harness/codex/index.ts +2 -0
  63. package/server/harness/codex/session-title.ts +149 -0
  64. package/server/harness/codex/session.ts +84 -11
  65. package/server/harness/openclaw/adapter.ts +4 -2
  66. package/server/harness/openclaw/discovery.ts +2 -0
  67. package/server/harness/openclaw/session.ts +15 -7
  68. package/server/harness/session-title.ts +96 -0
  69. package/server/harness/types.ts +2 -0
  70. package/server/selected-session.ts +132 -0
  71. package/server/service.ts +786 -0
  72. package/server/{thread-config.ts → session-config.ts} +57 -39
  73. package/server/status.ts +2 -0
  74. package/server/update.ts +141 -0
  75. package/server/version.ts +41 -0
  76. package/server/web.ts +17 -1
  77. package/workspace/.claude/skills/moi-workspace/DESIGN.md +16 -26
  78. package/workspace/.claude/skills/moi-workspace/SKILL.md +8 -2
  79. package/dist/chunk-94m3q9ce.js +0 -1
  80. package/dist/chunk-k9dcnd73.js +0 -27
  81. package/dist/chunk-pk11vfzs.js +0 -9
  82. package/dist/chunk-r2bqaege.js +0 -2
  83. package/dist/chunk-y4g8j7mv.css +0 -1
@@ -1 +1 @@
1
- import{Qc as t}from"/chunk-tzz101ea.js";if(typeof globalThis.structuredClone==="function")globalThis.structuredClone=globalThis.structuredClone.bind(globalThis);async function e(r){let{mount:a}=await import("/chunk-k9dcnd73.js");a(r)}globalThis.__init=e;
1
+ import{Xc as t}from"/chunk-9y2zbzqz.js";if(typeof globalThis.structuredClone==="function")globalThis.structuredClone=globalThis.structuredClone.bind(globalThis);async function e(r){let{mount:a}=await import("/chunk-175bm057.js");a(r)}globalThis.__init=e;
package/dist/index.html CHANGED
@@ -21,7 +21,7 @@
21
21
  }
22
22
  </script>
23
23
 
24
- <link rel="stylesheet" crossorigin href="/chunk-y4g8j7mv.css"><script type="module" crossorigin src="/chunk-xwhya7kb.js"></script></head>
24
+ <link rel="stylesheet" crossorigin href="/chunk-agtetn7n.css"><script type="module" crossorigin src="/chunk-w3tnv51j.js"></script></head>
25
25
  <body>
26
26
  <div id="root"></div>
27
27
 
@@ -16,6 +16,24 @@ export const ATTACHMENT_ONLY_PLACEHOLDER = '(see attached files)'
16
16
 
17
17
  export type AttachmentNoteFile = { filename: string; path: string }
18
18
 
19
+ export function attachmentOnlyPlaceholder(filenames: readonly string[]): string {
20
+ return filenames.length > 0
21
+ ? `${ATTACHMENT_ONLY_PLACEHOLDER} ${filenames.join(', ')}`
22
+ : ATTACHMENT_ONLY_PLACEHOLDER
23
+ }
24
+
25
+ export function attachmentOnlyFilenames(text: string): string[] {
26
+ if (!text.startsWith(`${ATTACHMENT_ONLY_PLACEHOLDER} `)) return []
27
+ return text
28
+ .slice(ATTACHMENT_ONLY_PLACEHOLDER.length + 1)
29
+ .split(', ')
30
+ .filter(Boolean)
31
+ }
32
+
33
+ export function isAttachmentOnlyPlaceholder(text: string): boolean {
34
+ return text === ATTACHMENT_ONLY_PLACEHOLDER || text.startsWith(`${ATTACHMENT_ONLY_PLACEHOLDER} `)
35
+ }
36
+
19
37
  // `text` plus the note listing each attachment as `- <filename>: <path>`.
20
38
  // Filenames are sanitized at upload time (no colons/newlines), so the line
21
39
  // format is unambiguous for `splitAttachmentNote`.
@@ -0,0 +1,6 @@
1
+ const MAX_CHAT_TITLE_LENGTH = 64
2
+
3
+ export function formatChatTitle(text: string, filenames: readonly string[] = []): string {
4
+ const source = text.trim() || filenames.filter(Boolean).join(', ')
5
+ return source.replace(/\s+/gu, ' ').trim().slice(0, MAX_CHAT_TITLE_LENGTH).trimEnd()
6
+ }
package/lib/types.ts CHANGED
@@ -258,17 +258,21 @@ export type SessionInfo = {
258
258
  cwd?: string
259
259
  }
260
260
 
261
- // Per-thread agent settings, persisted server-side in one global file in moi's
261
+ // Per-session agent settings, persisted server-side in one global file in moi's
262
262
  // data dir (NOT in the workspace), exposed via GET/PUT
263
- // /api/workspaces/:id/sessions/:sessionId/config. A thread reopens with the same
264
- // model/effort/Fast mode it last ran with; a brand-new thread is seeded from the
263
+ // /api/workspaces/:id/sessions/:sessionId/config. A session reopens with the same
264
+ // model/effort/Fast mode it last ran with; a brand-new session is seeded from the
265
265
  // corresponding workspace defaults.
266
- export type ThreadConfig = {
266
+ export type SessionConfig = {
267
267
  model?: string
268
268
  effort?: string
269
269
  fastMode?: boolean
270
270
  }
271
271
 
272
+ export type SelectedSessionState = {
273
+ sessionId: string | null
274
+ }
275
+
272
276
  // App-wide settings, persisted server-side as `settings.json` in moi's data
273
277
  // dir and exposed via GET/PATCH /api/settings. Every key has a default, so
274
278
  // GET always returns a complete object.
@@ -308,6 +312,7 @@ export type ServerMessage =
308
312
  | PreviewFrame
309
313
  | StatusMessage
310
314
  | SessionRenamedMessage
315
+ | SessionsChangedMessage
311
316
  | WorkspaceSwitchMessage
312
317
  | ErrorFrame
313
318
  | StoppedFrame
@@ -351,6 +356,7 @@ export type BroadcastFrame =
351
356
  | Omit<PreviewFrame, 'workspaceId'>
352
357
  | Omit<StatusMessage, 'workspaceId'>
353
358
  | Omit<SessionRenamedMessage, 'workspaceId'>
359
+ | Omit<SessionsChangedMessage, 'workspaceId'>
354
360
  | Omit<ErrorFrame, 'workspaceId'>
355
361
  | Omit<StoppedFrame, 'workspaceId'>
356
362
 
@@ -437,6 +443,12 @@ export type SessionRenamedMessage = {
437
443
  to: string
438
444
  }
439
445
 
446
+ export type SessionsChangedMessage = {
447
+ type: 'sessions_changed'
448
+ workspaceId: string
449
+ sessionId: string
450
+ }
451
+
440
452
  export type ErrorFrame = {
441
453
  kind: 'error'
442
454
  workspaceId: string
@@ -513,13 +525,13 @@ export type WorkspaceLayout = {
513
525
  // doesn't map back to these aliases — hence we persist the pick here.
514
526
  //
515
527
  // This (with `selectedEffort` and `selectedFastMode`) is the *workspace
516
- // default*: the value the picker edits when no thread is open, and the seed a
517
- // brand-new thread copies. Once a thread exists it carries its own per-thread
518
- // override (see `ThreadConfig`).
528
+ // default*: the value the picker edits when no session is open, and the seed a
529
+ // brand-new session copies. Once a session exists it carries its own per-session
530
+ // override (see `SessionConfig`).
519
531
  selectedModel?: string
520
- // Reasoning-effort default for new threads (a `supportedEffortLevels` value).
532
+ // Reasoning-effort default for new sessions (a `supportedEffortLevels` value).
521
533
  selectedEffort?: string
522
- // Fast-mode default for new threads. Undefined inherits the provider setting.
534
+ // Fast-mode default for new sessions. Undefined inherits the provider setting.
523
535
  selectedFastMode?: boolean
524
536
  theme?: {
525
537
  font: import('./themes').FontTheme
@@ -550,7 +562,7 @@ export type WidgetThumbnails = {
550
562
  // Home-screen workspace card preview: a few captured widget thumbnails (WebP
551
563
  // data URLs) from the stored layout, rendered as a loose stack, plus the latest
552
564
  // provider session activity. A workspace with no widgets may instead carry its
553
- // oldest thread's first user message.
565
+ // oldest session's first user message.
554
566
  export type WorkspacePreview = {
555
567
  thumbnails: string[]
556
568
  firstUserMessage?: string
@@ -620,4 +632,6 @@ export type WorkspaceModels = {
620
632
  // shows the "Live typing" toggle only when true). Provider-wide, not per-model
621
633
  // — Claude Code streams uniformly via `includePartialMessages`.
622
634
  supportsStreaming?: boolean
635
+ // Whether the provider can archive chats from the chat selector.
636
+ supportsArchiving?: boolean
623
637
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "moi-computer",
3
- "version": "0.5.2-next.1",
3
+ "version": "0.6.1-next.0",
4
4
  "description": "Local AI workspace powered by the Claude Agent SDK, Bun, React, and Tailwind. Requires Bun.",
5
5
  "license": "Elastic-2.0",
6
6
  "type": "module",
@@ -0,0 +1,16 @@
1
+ // Is the `moi` CLI being run by a coding agent rather than a human at a
2
+ // terminal? Two tiers, following the sentry-cli SENTRY_PIPELINE lesson —
3
+ // announcement over sniffing:
4
+ //
5
+ // - MOI_AGENT=1 is moi's own announcement, injected into every agent session
6
+ // the server spawns (Claude Code and Codex harnesses). Exact for
7
+ // first-party agents — and necessary, because the Claude Code harness
8
+ // deliberately strips CLAUDECODE from its children.
9
+ // - The rest are third-party markers set by agent runtimes in the shells
10
+ // they spawn: Claude Code (CLAUDECODE), OpenAI Codex (CODEX_SANDBOX),
11
+ // Cursor (CURSOR_TRACE_ID). Best-effort — absence proves nothing.
12
+ const AGENT_ENV_MARKERS = ['MOI_AGENT', 'CLAUDECODE', 'CODEX_SANDBOX', 'CURSOR_TRACE_ID']
13
+
14
+ export function isAgentCaller(env: Record<string, string | undefined> = process.env): boolean {
15
+ return AGENT_ENV_MARKERS.some(marker => !!env[marker])
16
+ }
package/server/api.ts CHANGED
@@ -8,6 +8,7 @@ import type {
8
8
  AppletKind,
9
9
  AppSettings,
10
10
  HarnessAvailability,
11
+ SessionInfo,
11
12
  UploadInfo,
12
13
  ViewBuilderInput,
13
14
  WorkspaceEntry,
@@ -33,6 +34,7 @@ import {
33
34
  } from './layout'
34
35
  import { getClientFrameLog, getWireLog } from './harness/debug'
35
36
  import { allHarnesses, harnessFor, isHarnessType } from './harness/registry'
37
+ import { broadcast } from './state'
36
38
  import {
37
39
  discoverWorkspace,
38
40
  discoverWorkspaces,
@@ -45,10 +47,17 @@ import {
45
47
  } from './registry'
46
48
  import { loadScratchpadDoc, saveScratchpadDoc } from './scratchpad'
47
49
  import { MAX_ASSET_BYTES, scratchpadAssetFile, storeScratchpadAsset } from './scratchpad-assets'
50
+ import {
51
+ clearSelectedSession,
52
+ getSelectedSession,
53
+ initializeSelectedSession,
54
+ saveSelectedSession
55
+ } from './selected-session'
56
+ import type { SelectedSessionUpdate } from './selected-session'
57
+ import { getSessionConfig, saveSessionConfig } from './session-config'
58
+ import type { SessionConfigPatch } from './session-config'
48
59
  import { DIST_DIR, prebuilt } from './static'
49
60
  import { getWorkspaceSkillsStatus, updateWorkspaceSkills } from './skill-update'
50
- import { getThreadConfig, saveThreadConfig } from './thread-config'
51
- import type { ThreadConfigPatch } from './thread-config'
52
61
  import { serveWorkspaceImagePreview } from './preview'
53
62
  import { MAX_UPLOAD_BYTES, addUpload, getUpload } from './uploads'
54
63
  import { requiredEnvFor } from './required-env'
@@ -78,6 +87,15 @@ import type { EnvUpdate } from './workspace-env'
78
87
  // `/api/workspaces/:id/*` handler can read it without re-querying the registry.
79
88
  type ApiEnv = { Variables: { ws: WorkspaceEntry } }
80
89
 
90
+ function publishSelectedSession(workspaceId: string, update: SelectedSessionUpdate): void {
91
+ if (!update.changed) return
92
+ publishEvent({
93
+ type: 'selected-session:updated',
94
+ workspaceId,
95
+ sessionId: update.sessionId
96
+ })
97
+ }
98
+
81
99
  async function handleFunctionCall(
82
100
  req: Request,
83
101
  tail: string,
@@ -258,6 +276,7 @@ one.post('/view-builders/:builderId/submit', async c => {
258
276
  directives: viewBuilderDirectives(builder.id, availableIcons)
259
277
  }
260
278
  try {
279
+ publishSelectedSession(ws.id, await saveSelectedSession(ws.path, builder.sessionId))
261
280
  await harnessFor(ws).sendMessage({
262
281
  workspaceId: ws.id,
263
282
  workspacePath: ws.path,
@@ -441,17 +460,78 @@ one.get('/sessions', async c => {
441
460
  return c.json(await harnessFor(ws).listSessions(ws))
442
461
  })
443
462
 
463
+ one.get('/selected-session', async c => {
464
+ const ws = c.get('ws')
465
+ let sessionId = await getSelectedSession(ws.path)
466
+ if (sessionId === undefined) {
467
+ const sessions = await harnessFor(ws).listSessions(ws)
468
+ const latest = sessions.reduce<SessionInfo | undefined>(
469
+ (current, session) =>
470
+ !current ||
471
+ session.lastModified > current.lastModified ||
472
+ (session.lastModified === current.lastModified &&
473
+ session.sessionId.localeCompare(current.sessionId) < 0)
474
+ ? session
475
+ : current,
476
+ undefined
477
+ )
478
+ sessionId = await initializeSelectedSession(ws.path, latest?.sessionId ?? null)
479
+ }
480
+ return c.json({ sessionId })
481
+ })
482
+
483
+ one.put('/selected-session', async c => {
484
+ const ws = c.get('ws')
485
+ const body: unknown = await c.req.json().catch(() => null)
486
+ if (!body || typeof body !== 'object') return c.text('Bad request', 400)
487
+
488
+ const input = body as { sessionId?: unknown; previousSessionId?: unknown }
489
+ const validSessionId = input.sessionId === null || typeof input.sessionId === 'string'
490
+ const hasPreviousSessionId = Object.prototype.hasOwnProperty.call(input, 'previousSessionId')
491
+ const validPreviousSessionId =
492
+ !hasPreviousSessionId ||
493
+ input.previousSessionId === null ||
494
+ typeof input.previousSessionId === 'string'
495
+ if (!validSessionId || !validPreviousSessionId) return c.text('Bad request', 400)
496
+
497
+ const update = await saveSelectedSession(
498
+ ws.path,
499
+ input.sessionId as string | null,
500
+ hasPreviousSessionId ? (input.previousSessionId as string | null) : undefined
501
+ )
502
+ publishSelectedSession(ws.id, update)
503
+ return c.json({ sessionId: update.sessionId })
504
+ })
505
+
506
+ one.post('/sessions/:sessionId/archive', async c => {
507
+ const ws = c.get('ws')
508
+ const harness = harnessFor(ws)
509
+ const sessionId = c.req.param('sessionId')
510
+ if (!harness.archiveSession) return c.text('Chat archiving is not supported', 501)
511
+
512
+ try {
513
+ await harness.interrupt(ws.id, sessionId)
514
+ await harness.archiveSession(ws, sessionId)
515
+ publishSelectedSession(ws.id, await clearSelectedSession(ws.path, sessionId))
516
+ broadcast(ws.id, { type: 'sessions_changed', sessionId })
517
+ return c.body(null, 204)
518
+ } catch (error) {
519
+ console.error(`[api] archive chat failed for ${harness.id}`, error)
520
+ return c.text('Couldn’t archive chat', 500)
521
+ }
522
+ })
523
+
444
524
  one.get('/sessions/:sessionId/events', async c => {
445
525
  const ws = c.get('ws')
446
526
  return c.json(await harnessFor(ws).sessionEvents(ws, c.req.param('sessionId')))
447
527
  })
448
528
 
449
- // Per-thread agent settings (model, reasoning effort, and Fast mode). GET
450
- // returns the stored config ({} for threads that never overrode the workspace
529
+ // Per-session agent settings (model, reasoning effort, and Fast mode). GET
530
+ // returns the stored config ({} for sessions that never overrode the workspace
451
531
  // defaults); PUT patches it (a field as `null` clears it, omitted leaves it).
452
- // The change takes effect on the thread's next message.
532
+ // The change takes effect on the session's next message.
453
533
  one.get('/sessions/:sessionId/config', async c => {
454
- return c.json(await getThreadConfig(c.get('ws').path, c.req.param('sessionId')))
534
+ return c.json(await getSessionConfig(c.get('ws').path, c.req.param('sessionId')))
455
535
  })
456
536
 
457
537
  one.put('/sessions/:sessionId/config', async c => {
@@ -459,7 +539,7 @@ one.put('/sessions/:sessionId/config', async c => {
459
539
  if (typeof body !== 'object' || body === null) {
460
540
  return c.text('Expected a JSON object', 400)
461
541
  }
462
- const patch: ThreadConfigPatch = {}
542
+ const patch: SessionConfigPatch = {}
463
543
  const record = body as Record<string, unknown>
464
544
  for (const key of ['model', 'effort'] as const) {
465
545
  if (!(key in record)) continue
@@ -476,7 +556,7 @@ one.put('/sessions/:sessionId/config', async c => {
476
556
  }
477
557
  patch.fastMode = value
478
558
  }
479
- return c.json(await saveThreadConfig(c.get('ws').path, c.req.param('sessionId'), patch))
559
+ return c.json(await saveSessionConfig(c.get('ws').path, c.req.param('sessionId'), patch))
480
560
  })
481
561
 
482
562
  one.get('/mcp', async c => {
@@ -594,7 +674,8 @@ one.get('/models', async c => {
594
674
  return c.json({
595
675
  provider: harness.id,
596
676
  models,
597
- supportsStreaming: harness.capabilities.supportsStreaming
677
+ supportsStreaming: harness.capabilities.supportsStreaming,
678
+ supportsArchiving: Boolean(harness.archiveSession)
598
679
  } satisfies WorkspaceModels)
599
680
  })
600
681
 
@@ -33,7 +33,7 @@ export function pickAppSettingsPatch(body: Record<string, unknown>): AppSettings
33
33
  let _dir = DATA_DIR
34
34
  let _store: Conf<AppSettings> | null = null
35
35
 
36
- // Test seam: point the store at a scratch dir (mirrors setThreadConfigPath).
36
+ // Test seam: point the store at a scratch dir (mirrors setSessionConfigPath).
37
37
  export function setAppSettingsDir(dir: string): void {
38
38
  _dir = dir
39
39
  _store = null