moi-computer 0.5.2-next.0 → 0.6.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 (89) hide show
  1. package/client/AGENTS.md +9 -0
  2. package/client/api/app-ui-keys.ts +4 -0
  3. package/client/api/workspace-keys.ts +2 -2
  4. package/client/app/routes/WorkspaceRoute.tsx +8 -28
  5. package/client/app/shell/SidebarLayout.tsx +1 -1
  6. package/client/components/shared/Composer.tsx +15 -9
  7. package/client/components/shared/IconGhost.tsx +130 -0
  8. package/client/components/ui/dropdown-menu.tsx +2 -5
  9. package/client/components/ui/popover.tsx +11 -4
  10. package/client/components/ui/slider.tsx +70 -0
  11. package/client/components/ui/spinner.tsx +18 -0
  12. package/client/components/ui/toast.tsx +220 -0
  13. package/client/components/ui/tooltip.tsx +1 -1
  14. package/client/features/chat/ChatComposer.tsx +11 -14
  15. package/client/features/chat/ChatPanel.tsx +15 -14
  16. package/client/features/chat/ChatPopup.tsx +10 -4
  17. package/client/features/chat/ChatSelector.tsx +263 -48
  18. package/client/features/chat/ModelPicker.tsx +295 -121
  19. package/client/features/chat/TurnView.tsx +1 -1
  20. package/client/features/chat/api.ts +36 -9
  21. package/client/features/chat/chat-frames.ts +35 -6
  22. package/client/features/chat/chat-send.ts +40 -6
  23. package/client/features/chat/chat-store.ts +52 -40
  24. package/client/features/chat/model-order.ts +50 -28
  25. package/client/features/chat/useChat.ts +71 -60
  26. package/client/features/chat/useSelectedSession.ts +151 -0
  27. package/client/features/chat/useStickToBottom.ts +3 -3
  28. package/client/features/home/api.ts +0 -2
  29. package/client/features/scratchpad/ScratchpadControls.tsx +2 -2
  30. package/client/features/settings/IconPicker.tsx +2 -2
  31. package/client/features/settings/WorkspaceSettings.tsx +6 -6
  32. package/client/features/views/ViewBuilderTab.tsx +3 -4
  33. package/client/features/views/api.ts +1 -0
  34. package/client/features/views/useViewBuilderActions.ts +7 -3
  35. package/client/features/workspace/WorkspaceScreen.tsx +40 -19
  36. package/client/features/workspace/WorkspaceSkillUpdateBanner.tsx +2 -2
  37. package/client/features/workspace/WorkspaceTabs.tsx +10 -1
  38. package/client/index.css +5 -3
  39. package/client/main.tsx +2 -0
  40. package/client/runtime/useWorkspaceEvents.ts +1 -0
  41. package/client/store/ui.ts +13 -3
  42. package/dist/{chunk-m9qja0nx.js → chunk-0pcdwjkp.js} +1 -1
  43. package/dist/chunk-55sh4dty.js +2 -0
  44. package/dist/{chunk-h3evrtyp.js → chunk-9y2zbzqz.js} +1 -1
  45. package/dist/{chunk-7bzpmtxp.js → chunk-afgbg75t.js} +1 -1
  46. package/dist/chunk-agtetn7n.css +1 -0
  47. package/dist/chunk-bv6vrvqf.js +27 -0
  48. package/dist/chunk-dfs36zgc.js +1 -0
  49. package/dist/chunk-exj6hr30.js +9 -0
  50. package/dist/{chunk-v797g6ap.js → chunk-m11ckkxd.js} +1 -1
  51. package/dist/chunk-n6t40enm.js +1 -0
  52. package/dist/{chunk-jg6ezptn.js → chunk-rxvx4ta9.js} +3 -3
  53. package/dist/index.html +1 -1
  54. package/lib/attachment-note.ts +18 -0
  55. package/lib/chat-title.ts +6 -0
  56. package/lib/types.ts +33 -10
  57. package/package.json +1 -1
  58. package/server/api.ts +100 -10
  59. package/server/app-settings.ts +1 -1
  60. package/server/data-dir.ts +1 -1
  61. package/server/harness/README.md +6 -0
  62. package/server/harness/claude-code/adapter.ts +2 -2
  63. package/server/harness/claude-code/index.ts +7 -1
  64. package/server/harness/claude-code/models.ts +25 -2
  65. package/server/harness/claude-code/session-title.ts +106 -0
  66. package/server/harness/claude-code/session.ts +114 -17
  67. package/server/harness/claude-code/sessions.ts +35 -4
  68. package/server/harness/codex/adapter.ts +27 -2
  69. package/server/harness/codex/client.ts +56 -9
  70. package/server/harness/codex/index.ts +2 -0
  71. package/server/harness/codex/session-title.ts +149 -0
  72. package/server/harness/codex/session.ts +96 -14
  73. package/server/harness/openclaw/adapter.ts +4 -2
  74. package/server/harness/openclaw/discovery.ts +2 -0
  75. package/server/harness/openclaw/session.ts +15 -7
  76. package/server/harness/session-title.ts +96 -0
  77. package/server/harness/types.ts +5 -2
  78. package/server/selected-session.ts +132 -0
  79. package/server/session-config.ts +146 -0
  80. package/server/web.ts +15 -1
  81. package/workspace/.claude/skills/moi-workspace/DESIGN.md +54 -68
  82. package/workspace/.claude/skills/moi-workspace/SKILL.md +8 -2
  83. package/dist/chunk-5vaevt8z.js +0 -2
  84. package/dist/chunk-fhhv99bd.js +0 -1
  85. package/dist/chunk-h0hk61pm.js +0 -9
  86. package/dist/chunk-k5sjx9s5.js +0 -1
  87. package/dist/chunk-rs9nb0fr.js +0 -27
  88. package/dist/chunk-s7za1qsv.css +0 -1
  89. package/server/thread-config.ts +0 -124
package/dist/index.html CHANGED
@@ -21,7 +21,7 @@
21
21
  }
22
22
  </script>
23
23
 
24
- <link rel="stylesheet" crossorigin href="/chunk-s7za1qsv.css"><script type="module" crossorigin src="/chunk-fhhv99bd.js"></script></head>
24
+ <link rel="stylesheet" crossorigin href="/chunk-agtetn7n.css"><script type="module" crossorigin src="/chunk-n6t40enm.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
@@ -231,6 +231,9 @@ export type ClientMessage =
231
231
  // Omitted means the SDK default. Unlike model, the SDK has no live setter,
232
232
  // so a change forces the live session to resume (see server/cc-session.ts).
233
233
  effort?: string
234
+ // Opt into the selected model's faster processing mode. Omitted inherits
235
+ // the provider configuration; false explicitly disables a stored default.
236
+ fastMode?: boolean
234
237
  // Opt into live token-by-token streaming for this turn. Omitted/false runs
235
238
  // the current whole-block behavior. Only honored for providers that report
236
239
  // `supportsStreaming` (Claude Code); ignored otherwise. Like effort, a
@@ -255,14 +258,19 @@ export type SessionInfo = {
255
258
  cwd?: string
256
259
  }
257
260
 
258
- // 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
259
262
  // data dir (NOT in the workspace), exposed via GET/PUT
260
- // /api/workspaces/:id/sessions/:sessionId/config. A thread reopens with the same
261
- // model/effort it last ran with; a brand-new thread is seeded from the workspace
262
- // defaults (`WorkspaceLayout.selectedModel`/`selectedEffort`).
263
- export type ThreadConfig = {
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
+ // corresponding workspace defaults.
266
+ export type SessionConfig = {
264
267
  model?: string
265
268
  effort?: string
269
+ fastMode?: boolean
270
+ }
271
+
272
+ export type SelectedSessionState = {
273
+ sessionId: string | null
266
274
  }
267
275
 
268
276
  // App-wide settings, persisted server-side as `settings.json` in moi's data
@@ -304,6 +312,7 @@ export type ServerMessage =
304
312
  | PreviewFrame
305
313
  | StatusMessage
306
314
  | SessionRenamedMessage
315
+ | SessionsChangedMessage
307
316
  | WorkspaceSwitchMessage
308
317
  | ErrorFrame
309
318
  | StoppedFrame
@@ -347,6 +356,7 @@ export type BroadcastFrame =
347
356
  | Omit<PreviewFrame, 'workspaceId'>
348
357
  | Omit<StatusMessage, 'workspaceId'>
349
358
  | Omit<SessionRenamedMessage, 'workspaceId'>
359
+ | Omit<SessionsChangedMessage, 'workspaceId'>
350
360
  | Omit<ErrorFrame, 'workspaceId'>
351
361
  | Omit<StoppedFrame, 'workspaceId'>
352
362
 
@@ -433,6 +443,12 @@ export type SessionRenamedMessage = {
433
443
  to: string
434
444
  }
435
445
 
446
+ export type SessionsChangedMessage = {
447
+ type: 'sessions_changed'
448
+ workspaceId: string
449
+ sessionId: string
450
+ }
451
+
436
452
  export type ErrorFrame = {
437
453
  kind: 'error'
438
454
  workspaceId: string
@@ -508,12 +524,15 @@ export type WorkspaceLayout = {
508
524
  // the transcript records the *resolved* id (e.g. `claude-sonnet-4-6`), which
509
525
  // doesn't map back to these aliases — hence we persist the pick here.
510
526
  //
511
- // This (and `selectedEffort`) is the *workspace default*: the value the picker
512
- // edits when no thread is open, and the seed a brand-new thread copies. Once a
513
- // thread exists it carries its own per-thread override (see `ThreadConfig`).
527
+ // This (with `selectedEffort` and `selectedFastMode`) is the *workspace
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`).
514
531
  selectedModel?: string
515
- // Reasoning-effort default for new threads (a `supportedEffortLevels` value).
532
+ // Reasoning-effort default for new sessions (a `supportedEffortLevels` value).
516
533
  selectedEffort?: string
534
+ // Fast-mode default for new sessions. Undefined inherits the provider setting.
535
+ selectedFastMode?: boolean
517
536
  theme?: {
518
537
  font: import('./themes').FontTheme
519
538
  primary?: string
@@ -543,7 +562,7 @@ export type WidgetThumbnails = {
543
562
  // Home-screen workspace card preview: a few captured widget thumbnails (WebP
544
563
  // data URLs) from the stored layout, rendered as a loose stack, plus the latest
545
564
  // provider session activity. A workspace with no widgets may instead carry its
546
- // oldest thread's first user message.
565
+ // oldest session's first user message.
547
566
  export type WorkspacePreview = {
548
567
  thumbnails: string[]
549
568
  firstUserMessage?: string
@@ -599,6 +618,8 @@ export type Model = {
599
618
  supportedEffortLevels?: string[]
600
619
  supportsAdaptiveThinking?: boolean
601
620
  supportsFastMode?: boolean
621
+ // Provider-resolved default when moi has no stored Fast-mode preference.
622
+ defaultFastMode?: boolean
602
623
  supportsAutoMode?: boolean
603
624
  }
604
625
 
@@ -611,4 +632,6 @@ export type WorkspaceModels = {
611
632
  // shows the "Live typing" toggle only when true). Provider-wide, not per-model
612
633
  // — Claude Code streams uniformly via `includePartialMessages`.
613
634
  supportsStreaming?: boolean
635
+ // Whether the provider can archive chats from the chat selector.
636
+ supportsArchiving?: boolean
614
637
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "moi-computer",
3
- "version": "0.5.2-next.0",
3
+ "version": "0.6.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",
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,
@@ -229,6 +247,7 @@ one.post('/view-builders/:builderId/submit', async c => {
229
247
  optimisticId?: string
230
248
  model?: string
231
249
  effort?: string
250
+ fastMode?: boolean
232
251
  stream?: boolean
233
252
  availableIcons?: unknown
234
253
  }>()
@@ -257,6 +276,7 @@ one.post('/view-builders/:builderId/submit', async c => {
257
276
  directives: viewBuilderDirectives(builder.id, availableIcons)
258
277
  }
259
278
  try {
279
+ publishSelectedSession(ws.id, await saveSelectedSession(ws.path, builder.sessionId))
260
280
  await harnessFor(ws).sendMessage({
261
281
  workspaceId: ws.id,
262
282
  workspacePath: ws.path,
@@ -267,6 +287,7 @@ one.post('/view-builders/:builderId/submit', async c => {
267
287
  optimisticId: body.optimisticId,
268
288
  model: typeof body.model === 'string' ? body.model : undefined,
269
289
  effort: typeof body.effort === 'string' ? body.effort : undefined,
290
+ fastMode: typeof body.fastMode === 'boolean' ? body.fastMode : undefined,
270
291
  stream: body.stream === true ? true : undefined,
271
292
  agentId: ws.agentId
272
293
  })
@@ -439,17 +460,78 @@ one.get('/sessions', async c => {
439
460
  return c.json(await harnessFor(ws).listSessions(ws))
440
461
  })
441
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
+
442
524
  one.get('/sessions/:sessionId/events', async c => {
443
525
  const ws = c.get('ws')
444
526
  return c.json(await harnessFor(ws).sessionEvents(ws, c.req.param('sessionId')))
445
527
  })
446
528
 
447
- // Per-thread agent settings (model + reasoning effort). GET returns the stored
448
- // config ({} for threads that never overrode the workspace defaults); PUT patches
449
- // it (a field as `null` clears it, omitted leaves it). The change takes effect on
450
- // the thread's next message — see ClientMessage/effort handling in cc-session.
529
+ // Per-session agent settings (model, reasoning effort, and Fast mode). GET
530
+ // returns the stored config ({} for sessions that never overrode the workspace
531
+ // defaults); PUT patches it (a field as `null` clears it, omitted leaves it).
532
+ // The change takes effect on the session's next message.
451
533
  one.get('/sessions/:sessionId/config', async c => {
452
- 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')))
453
535
  })
454
536
 
455
537
  one.put('/sessions/:sessionId/config', async c => {
@@ -457,7 +539,7 @@ one.put('/sessions/:sessionId/config', async c => {
457
539
  if (typeof body !== 'object' || body === null) {
458
540
  return c.text('Expected a JSON object', 400)
459
541
  }
460
- const patch: ThreadConfigPatch = {}
542
+ const patch: SessionConfigPatch = {}
461
543
  const record = body as Record<string, unknown>
462
544
  for (const key of ['model', 'effort'] as const) {
463
545
  if (!(key in record)) continue
@@ -467,7 +549,14 @@ one.put('/sessions/:sessionId/config', async c => {
467
549
  }
468
550
  patch[key] = value
469
551
  }
470
- return c.json(await saveThreadConfig(c.get('ws').path, c.req.param('sessionId'), patch))
552
+ if ('fastMode' in record) {
553
+ const value = record.fastMode
554
+ if (value !== null && typeof value !== 'boolean') {
555
+ return c.text('fastMode must be a boolean or null', 400)
556
+ }
557
+ patch.fastMode = value
558
+ }
559
+ return c.json(await saveSessionConfig(c.get('ws').path, c.req.param('sessionId'), patch))
471
560
  })
472
561
 
473
562
  one.get('/mcp', async c => {
@@ -585,7 +674,8 @@ one.get('/models', async c => {
585
674
  return c.json({
586
675
  provider: harness.id,
587
676
  models,
588
- supportsStreaming: harness.capabilities.supportsStreaming
677
+ supportsStreaming: harness.capabilities.supportsStreaming,
678
+ supportsArchiving: Boolean(harness.archiveSession)
589
679
  } satisfies WorkspaceModels)
590
680
  })
591
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
@@ -1,5 +1,5 @@
1
1
  // Single source of truth for the OS data dir holding moi's global state
2
- // (workspaces.json, settings.json, thread-config.json, workspace-env.json, …).
2
+ // (workspaces.json, settings.json, session-config.json, selected-sessions.json, …).
3
3
  //
4
4
  // MOI_DATA_DIR overrides it wholesale. This is the isolation seam for CLI
5
5
  // e2e tests: env-paths only honors XDG_DATA_HOME on Linux, so on macOS a
@@ -34,6 +34,8 @@ Socket-protocol notes the layers rely on (all defined in `lib/types.ts`):
34
34
 
35
35
  - **`session_renamed`** — a new thread is created under the client's temporary
36
36
  uuid, then rekeyed to the backend's real session/thread id.
37
+ - **`sessions_changed`** — a provider changed session-list metadata such as a
38
+ generated session title; clients refresh that workspace's session list.
37
39
  - **Optimistic-id rendezvous** — the client sends `optimisticId` with each
38
40
  chat; the user's bubble must upsert under that id. Backends differ: Codex
39
41
  echoes it natively (`clientUserMessageId` → `clientId`), Claude Code never
@@ -69,6 +71,10 @@ server/harness/
69
71
  ```
70
72
 
71
73
  - Nothing inside one harness folder imports from a sibling harness.
74
+ - Internal harness metadata and helpers use session naming, including
75
+ `sessionTitle`, `generateSessionTitle`, and `session-title.ts`. Chat naming is
76
+ for client and UI labels. Thread naming stays at provider wire and RPC
77
+ boundaries.
72
78
  - Outside code imports only this folder's top level. Documented exceptions:
73
79
  `cli.ts` (`moi openclaw init` provisioning) imports
74
80
  `harness/openclaw/discovery.ts`; tests may import harness internals.
@@ -14,7 +14,7 @@ import type {
14
14
  TurnOrigin
15
15
  } from '@/lib/format'
16
16
 
17
- import { ATTACHMENT_ONLY_PLACEHOLDER, splitAttachmentNote } from '@/lib/attachment-note'
17
+ import { isAttachmentOnlyPlaceholder, splitAttachmentNote } from '@/lib/attachment-note'
18
18
  import { stripMoiContext } from '@/lib/moi-context'
19
19
 
20
20
  // Loose SDK message shape — we don't pull in the full SDK type tree; the
@@ -532,7 +532,7 @@ export class ClaudeAdapter {
532
532
  }
533
533
  // An attachment-only message carries a synthesized placeholder
534
534
  // prompt; the bubble should show just the attachments.
535
- if (text === ATTACHMENT_ONLY_PLACEHOLDER && parts.some(p => p.type === 'file')) {
535
+ if (isAttachmentOnlyPlaceholder(text) && parts.some(p => p.type === 'file')) {
536
536
  text = ''
537
537
  }
538
538
  }
@@ -18,7 +18,12 @@ import {
18
18
  restartWorkspaceSessions,
19
19
  sendCCMessage
20
20
  } from './session'
21
- import { getSessionEvents, getSessions, getSessionWorkspacePreview } from './sessions'
21
+ import {
22
+ archiveClaudeSession,
23
+ getSessionEvents,
24
+ getSessions,
25
+ getSessionWorkspacePreview
26
+ } from './sessions'
22
27
 
23
28
  function fmtDuration(ms: number): string {
24
29
  const s = Math.floor(ms / 1000)
@@ -79,6 +84,7 @@ export const claudeCodeHarness: Harness = {
79
84
 
80
85
  sendMessage: input => sendCCMessage(input),
81
86
  interrupt: (workspaceId, sessionId) => interruptCCSession(workspaceId, sessionId),
87
+ archiveSession: (ws, sessionId) => archiveClaudeSession(sessionId, ws.path),
82
88
  activeSessions: () => getCCActiveSessions(),
83
89
 
84
90
  listSessions: ws => getSessions(ws.path),
@@ -1,6 +1,8 @@
1
- import { query } from '@anthropic-ai/claude-agent-sdk'
1
+ import { query, resolveSettings } from '@anthropic-ai/claude-agent-sdk'
2
2
  import type { ModelInfo } from '@anthropic-ai/claude-agent-sdk'
3
3
 
4
+ import type { Model } from '@/lib/types'
5
+
4
6
  import { requireHarnessExecutable } from '../executable'
5
7
 
6
8
  // Chat runs live in `cc-session.ts` (streaming-input sessions held per thread).
@@ -31,7 +33,7 @@ async function fetchClaudeModels(cwd: string): Promise<ModelInfo[]> {
31
33
  // it so a later request can retry instead of caching the rejection forever.
32
34
  let claudeModelsPromise: Promise<ModelInfo[]> | null = null
33
35
 
34
- export function getClaudeModels(cwd: string): Promise<ModelInfo[]> {
36
+ function getCachedClaudeModels(cwd: string): Promise<ModelInfo[]> {
35
37
  if (!claudeModelsPromise) {
36
38
  claudeModelsPromise = fetchClaudeModels(cwd).catch(err => {
37
39
  claudeModelsPromise = null
@@ -40,3 +42,24 @@ export function getClaudeModels(cwd: string): Promise<ModelInfo[]> {
40
42
  }
41
43
  return claudeModelsPromise
42
44
  }
45
+
46
+ export function withClaudeFastModeDefault(
47
+ models: readonly ModelInfo[],
48
+ defaultFastMode: boolean
49
+ ): Model[] {
50
+ return models.map(model =>
51
+ model.supportsFastMode ? { ...model, defaultFastMode } : { ...model }
52
+ )
53
+ }
54
+
55
+ export async function getClaudeModels(cwd: string): Promise<Model[]> {
56
+ const [models, settings] = await Promise.all([
57
+ getCachedClaudeModels(cwd),
58
+ resolveSettings({ cwd, settingSources: ['user', 'project'] })
59
+ ])
60
+ const defaultFastMode =
61
+ settings.effective.fastModePerSessionOptIn === true
62
+ ? false
63
+ : settings.effective.fastMode === true
64
+ return withClaudeFastModeDefault(models, defaultFastMode)
65
+ }
@@ -0,0 +1,106 @@
1
+ import { getSessionInfo, renameSession, type SDKSessionInfo } from '@anthropic-ai/claude-agent-sdk'
2
+
3
+ import {
4
+ SESSION_TITLE_SCHEMA,
5
+ SESSION_TITLE_SYSTEM_PROMPT,
6
+ SESSION_TITLE_TIMEOUT_MS,
7
+ createSessionTitleTempDir,
8
+ parseGeneratedSessionTitle,
9
+ removeSessionTitleTempDir,
10
+ runSessionTitleCommand
11
+ } from '../session-title'
12
+ import { requireHarnessExecutable } from '../executable'
13
+
14
+ export function claudeSessionTitleCommand(executable: string): string[] {
15
+ return [
16
+ executable,
17
+ '-p',
18
+ '--model',
19
+ 'haiku',
20
+ '--effort',
21
+ 'low',
22
+ '--max-turns',
23
+ '1',
24
+ '--tools',
25
+ '',
26
+ '--safe-mode',
27
+ '--no-session-persistence',
28
+ '--disable-slash-commands',
29
+ '--strict-mcp-config',
30
+ '--setting-sources',
31
+ '',
32
+ '--permission-mode',
33
+ 'dontAsk',
34
+ '--system-prompt',
35
+ SESSION_TITLE_SYSTEM_PROMPT,
36
+ '--output-format',
37
+ 'json',
38
+ '--json-schema',
39
+ JSON.stringify(SESSION_TITLE_SCHEMA)
40
+ ]
41
+ }
42
+
43
+ export function parseClaudeSessionTitleOutput(value: string): string | null {
44
+ try {
45
+ const result = JSON.parse(value) as { structured_output?: unknown }
46
+ return parseGeneratedSessionTitle(result.structured_output)
47
+ } catch {
48
+ return null
49
+ }
50
+ }
51
+
52
+ export async function generateClaudeSessionTitle(input: {
53
+ source: string
54
+ abortController: AbortController
55
+ timeoutMs?: number
56
+ }): Promise<string | null> {
57
+ if (!input.source || input.abortController.signal.aborted) return null
58
+ const timer = setTimeout(
59
+ () => input.abortController.abort(),
60
+ input.timeoutMs ?? SESSION_TITLE_TIMEOUT_MS
61
+ )
62
+ let tempDir: string | undefined
63
+ try {
64
+ tempDir = await createSessionTitleTempDir()
65
+ const output = await runSessionTitleCommand({
66
+ command: claudeSessionTitleCommand(requireHarnessExecutable('claude-code')),
67
+ cwd: tempDir,
68
+ stdin: JSON.stringify({ sessionTitleSource: input.source }),
69
+ signal: input.abortController.signal,
70
+ env: { ...process.env, CLAUDECODE: undefined, DISABLE_AUTOUPDATER: '1' }
71
+ })
72
+ return output ? parseClaudeSessionTitleOutput(output) : null
73
+ } finally {
74
+ clearTimeout(timer)
75
+ if (tempDir) await removeSessionTitleTempDir(tempDir).catch(() => {})
76
+ }
77
+ }
78
+
79
+ type ClaudeSessionTitleRenameTransport = {
80
+ getSessionInfo: (sessionId: string, workspacePath: string) => Promise<SDKSessionInfo | undefined>
81
+ renameSession: (sessionId: string, title: string, workspacePath: string) => Promise<void>
82
+ }
83
+
84
+ const defaultSessionTitleRenameTransport: ClaudeSessionTitleRenameTransport = {
85
+ getSessionInfo: (sessionId, workspacePath) => getSessionInfo(sessionId, { dir: workspacePath }),
86
+ renameSession: (sessionId, title, workspacePath) =>
87
+ renameSession(sessionId, title, { dir: workspacePath })
88
+ }
89
+
90
+ export async function renameClaudeSessionIfUnchanged(
91
+ input: {
92
+ sessionId: string
93
+ workspacePath: string
94
+ title: string
95
+ isCurrent?: () => boolean
96
+ },
97
+ transport: ClaudeSessionTitleRenameTransport = defaultSessionTitleRenameTransport
98
+ ): Promise<boolean> {
99
+ const info = await transport.getSessionInfo(input.sessionId, input.workspacePath)
100
+ if (!info || info.customTitle || !info.firstPrompt || info.summary !== info.firstPrompt) {
101
+ return false
102
+ }
103
+ if (input.isCurrent && !input.isCurrent()) return false
104
+ await transport.renameSession(input.sessionId, input.title, input.workspacePath)
105
+ return true
106
+ }