moi-computer 0.5.2-next.1 → 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 (75) 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/components/shared/Composer.tsx +3 -6
  6. package/client/components/shared/IconGhost.tsx +130 -0
  7. package/client/components/ui/dropdown-menu.tsx +1 -1
  8. package/client/components/ui/spinner.tsx +18 -0
  9. package/client/components/ui/toast.tsx +220 -0
  10. package/client/features/chat/ChatComposer.tsx +3 -2
  11. package/client/features/chat/ChatPanel.tsx +7 -6
  12. package/client/features/chat/ChatPopup.tsx +10 -4
  13. package/client/features/chat/ChatSelector.tsx +263 -48
  14. package/client/features/chat/ModelPicker.tsx +13 -18
  15. package/client/features/chat/api.ts +36 -9
  16. package/client/features/chat/chat-frames.ts +35 -6
  17. package/client/features/chat/chat-send.ts +25 -1
  18. package/client/features/chat/chat-store.ts +43 -18
  19. package/client/features/chat/useChat.ts +54 -52
  20. package/client/features/chat/useSelectedSession.ts +151 -0
  21. package/client/features/chat/useStickToBottom.ts +3 -3
  22. package/client/features/home/api.ts +0 -2
  23. package/client/features/scratchpad/ScratchpadControls.tsx +2 -2
  24. package/client/features/settings/WorkspaceSettings.tsx +6 -6
  25. package/client/features/views/ViewBuilderTab.tsx +3 -4
  26. package/client/features/views/useViewBuilderActions.ts +3 -1
  27. package/client/features/workspace/WorkspaceScreen.tsx +38 -18
  28. package/client/features/workspace/WorkspaceTabs.tsx +10 -1
  29. package/client/main.tsx +2 -0
  30. package/client/runtime/useWorkspaceEvents.ts +1 -0
  31. package/client/store/ui.ts +2 -2
  32. package/dist/{chunk-zs4mte79.js → chunk-0pcdwjkp.js} +1 -1
  33. package/dist/chunk-55sh4dty.js +2 -0
  34. package/dist/{chunk-tzz101ea.js → chunk-9y2zbzqz.js} +1 -1
  35. package/dist/{chunk-jvhvme3z.js → chunk-afgbg75t.js} +1 -1
  36. package/dist/chunk-agtetn7n.css +1 -0
  37. package/dist/chunk-bv6vrvqf.js +27 -0
  38. package/dist/chunk-dfs36zgc.js +1 -0
  39. package/dist/chunk-exj6hr30.js +9 -0
  40. package/dist/{chunk-bcrkdhwe.js → chunk-m11ckkxd.js} +1 -1
  41. package/dist/{chunk-xwhya7kb.js → chunk-n6t40enm.js} +1 -1
  42. package/dist/{chunk-kfw1qwqe.js → chunk-rxvx4ta9.js} +3 -3
  43. package/dist/index.html +1 -1
  44. package/lib/attachment-note.ts +18 -0
  45. package/lib/chat-title.ts +6 -0
  46. package/lib/types.ts +24 -10
  47. package/package.json +1 -1
  48. package/server/api.ts +90 -9
  49. package/server/app-settings.ts +1 -1
  50. package/server/data-dir.ts +1 -1
  51. package/server/harness/README.md +6 -0
  52. package/server/harness/claude-code/adapter.ts +2 -2
  53. package/server/harness/claude-code/index.ts +7 -1
  54. package/server/harness/claude-code/session-title.ts +106 -0
  55. package/server/harness/claude-code/session.ts +87 -13
  56. package/server/harness/claude-code/sessions.ts +35 -4
  57. package/server/harness/codex/client.ts +30 -12
  58. package/server/harness/codex/index.ts +2 -0
  59. package/server/harness/codex/session-title.ts +149 -0
  60. package/server/harness/codex/session.ts +84 -11
  61. package/server/harness/openclaw/adapter.ts +4 -2
  62. package/server/harness/openclaw/discovery.ts +2 -0
  63. package/server/harness/openclaw/session.ts +15 -7
  64. package/server/harness/session-title.ts +96 -0
  65. package/server/harness/types.ts +2 -0
  66. package/server/selected-session.ts +132 -0
  67. package/server/{thread-config.ts → session-config.ts} +57 -39
  68. package/server/web.ts +12 -1
  69. package/workspace/.claude/skills/moi-workspace/DESIGN.md +16 -26
  70. package/workspace/.claude/skills/moi-workspace/SKILL.md +8 -2
  71. package/dist/chunk-94m3q9ce.js +0 -1
  72. package/dist/chunk-k9dcnd73.js +0 -27
  73. package/dist/chunk-pk11vfzs.js +0 -9
  74. package/dist/chunk-r2bqaege.js +0 -2
  75. package/dist/chunk-y4g8j7mv.css +0 -1
@@ -1,11 +1,11 @@
1
- import { mkdir, rename } from 'node:fs/promises'
1
+ import { mkdir, rename, rm } from 'node:fs/promises'
2
2
  import { join } from 'path'
3
3
 
4
- import type { ThreadConfig } from '@/lib/types'
4
+ import type { SessionConfig } from '@/lib/types'
5
5
 
6
6
  import { DATA_DIR } from './data-dir'
7
7
 
8
- // Per-thread model/effort/Fast-mode overrides for chat threads. Stored OUTSIDE
8
+ // Per-session model/effort/Fast-mode overrides. Stored OUTSIDE
9
9
  // the user's workspace (no repo churn) in ONE global JSON file in moi's data
10
10
  // dir, alongside the workspace registry. Keyed by workspace path then sessionId:
11
11
  // { "<workspacePath>": { "<sessionId>": { model?, effort?, fastMode? } } }
@@ -13,47 +13,63 @@ import { DATA_DIR } from './data-dir'
13
13
  // up with the SDK's path-based session storage.
14
14
 
15
15
  // A patch may clear a field with `null` (vs `undefined`, which leaves it alone).
16
- export type ThreadConfigPatch = {
16
+ export type SessionConfigPatch = {
17
17
  model?: string | null
18
18
  effort?: string | null
19
19
  fastMode?: boolean | null
20
20
  }
21
21
 
22
- type Store = Record<string, Record<string, ThreadConfig>>
22
+ type Store = Record<string, Record<string, SessionConfig>>
23
23
 
24
- let _path = join(DATA_DIR, 'thread-config.json')
24
+ export const DEFAULT_SESSION_CONFIG_PATH = join(DATA_DIR, 'session-config.json')
25
+ export const LEGACY_SESSION_CONFIG_PATH = join(DATA_DIR, 'thread-config.json')
26
+
27
+ let storePath = DEFAULT_SESSION_CONFIG_PATH
28
+ let legacyStorePath = LEGACY_SESSION_CONFIG_PATH
25
29
 
26
30
  // Test seam: point the store at a scratch file (mirrors registry.setRegistryPath).
27
- export function setThreadConfigPath(path: string): void {
28
- _path = path
31
+ export function setSessionConfigPath(path: string, legacyPath?: string): void {
32
+ storePath = path
33
+ legacyStorePath = legacyPath ?? join(path, '..', 'thread-config.json')
29
34
  }
30
35
 
31
- function clean(cfg: ThreadConfig | undefined): ThreadConfig {
32
- const out: ThreadConfig = {}
36
+ function clean(cfg: SessionConfig | undefined): SessionConfig {
37
+ const out: SessionConfig = {}
33
38
  if (typeof cfg?.model === 'string') out.model = cfg.model
34
39
  if (typeof cfg?.effort === 'string') out.effort = cfg.effort
35
40
  if (typeof cfg?.fastMode === 'boolean') out.fastMode = cfg.fastMode
36
41
  return out
37
42
  }
38
43
 
39
- function isEmpty(cfg: ThreadConfig): boolean {
44
+ function isEmpty(cfg: SessionConfig): boolean {
40
45
  return cfg.model === undefined && cfg.effort === undefined && cfg.fastMode === undefined
41
46
  }
42
47
 
43
- async function readStore(): Promise<Store> {
48
+ async function readStoreFile(path: string): Promise<Store | null> {
44
49
  try {
45
- const parsed = JSON.parse(await Bun.file(_path).text())
50
+ const parsed = JSON.parse(await Bun.file(path).text())
46
51
  return parsed && typeof parsed === 'object' ? (parsed as Store) : {}
47
52
  } catch {
48
- return {}
53
+ return null
49
54
  }
50
55
  }
51
56
 
52
57
  async function writeStore(store: Store): Promise<void> {
53
- await mkdir(join(_path, '..'), { recursive: true })
54
- const tmp = `${_path}.${process.pid}.tmp`
58
+ await mkdir(join(storePath, '..'), { recursive: true })
59
+ const tmp = `${storePath}.${process.pid}.tmp`
55
60
  await Bun.write(tmp, JSON.stringify(store, null, 2))
56
- await rename(tmp, _path)
61
+ await rename(tmp, storePath)
62
+ }
63
+
64
+ async function readStore(): Promise<Store> {
65
+ const current = await readStoreFile(storePath)
66
+ if (current) return current
67
+
68
+ const legacy = await readStoreFile(legacyStorePath)
69
+ if (!legacy) return {}
70
+ await writeStore(legacy)
71
+ await rm(legacyStorePath, { force: true })
72
+ return legacy
57
73
  }
58
74
 
59
75
  // Serialize read-modify-write so concurrent save/rename calls can't clobber the
@@ -65,30 +81,32 @@ function locked<T>(fn: () => Promise<T>): Promise<T> {
65
81
  return run
66
82
  }
67
83
 
68
- export async function getThreadConfig(
84
+ export async function getSessionConfig(
69
85
  workspacePath: string,
70
86
  sessionId: string
71
- ): Promise<ThreadConfig> {
72
- const store = await readStore()
73
- return clean(store[workspacePath]?.[sessionId])
87
+ ): Promise<SessionConfig> {
88
+ return locked(async () => {
89
+ const store = await readStore()
90
+ return clean(store[workspacePath]?.[sessionId])
91
+ })
74
92
  }
75
93
 
76
- export async function hasThreadConfig(workspacePath: string, sessionId: string): Promise<boolean> {
77
- return !isEmpty(await getThreadConfig(workspacePath, sessionId))
94
+ export async function hasSessionConfig(workspacePath: string, sessionId: string): Promise<boolean> {
95
+ return !isEmpty(await getSessionConfig(workspacePath, sessionId))
78
96
  }
79
97
 
80
98
  // Merge a patch over the stored config and write it back. `null` clears a field,
81
99
  // `undefined` leaves it untouched, and a typed value sets it. An emptied entry
82
100
  // is dropped to keep the file tidy. Returns the merged config.
83
- export async function saveThreadConfig(
101
+ export async function saveSessionConfig(
84
102
  workspacePath: string,
85
103
  sessionId: string,
86
- patch: ThreadConfigPatch
87
- ): Promise<ThreadConfig> {
104
+ patch: SessionConfigPatch
105
+ ): Promise<SessionConfig> {
88
106
  return locked(async () => {
89
107
  const store = await readStore()
90
- const threads = store[workspacePath] ?? {}
91
- const next = clean(threads[sessionId])
108
+ const sessions = store[workspacePath] ?? {}
109
+ const next = clean(sessions[sessionId])
92
110
  for (const key of ['model', 'effort'] as const) {
93
111
  const value = patch[key]
94
112
  if (value === undefined) continue
@@ -97,19 +115,19 @@ export async function saveThreadConfig(
97
115
  }
98
116
  if (patch.fastMode === null) delete next.fastMode
99
117
  else if (patch.fastMode !== undefined) next.fastMode = patch.fastMode
100
- if (isEmpty(next)) delete threads[sessionId]
101
- else threads[sessionId] = next
102
- if (Object.keys(threads).length === 0) delete store[workspacePath]
103
- else store[workspacePath] = threads
118
+ if (isEmpty(next)) delete sessions[sessionId]
119
+ else sessions[sessionId] = next
120
+ if (Object.keys(sessions).length === 0) delete store[workspacePath]
121
+ else store[workspacePath] = sessions
104
122
  await writeStore(store)
105
123
  return next
106
124
  })
107
125
  }
108
126
 
109
- // Move a thread's config from one id to another (temp id → SDK real id on
127
+ // Move a session's config from one id to another (temp id → SDK real id on
110
128
  // rename). Merges onto whatever the destination already holds (destination wins,
111
129
  // so a concurrent write under the real id isn't lost) and removes the source.
112
- export async function renameThreadConfig(
130
+ export async function renameSessionConfig(
113
131
  workspacePath: string,
114
132
  from: string,
115
133
  to: string
@@ -117,12 +135,12 @@ export async function renameThreadConfig(
117
135
  if (from === to) return
118
136
  await locked(async () => {
119
137
  const store = await readStore()
120
- const threads = store[workspacePath]
121
- const src = clean(threads?.[from])
138
+ const sessions = store[workspacePath]
139
+ const src = clean(sessions?.[from])
122
140
  if (isEmpty(src)) return
123
- threads![to] = { ...src, ...clean(threads![to]) }
124
- delete threads![from]
125
- store[workspacePath] = threads!
141
+ sessions![to] = { ...src, ...clean(sessions![to]) }
142
+ delete sessions![from]
143
+ store[workspacePath] = sessions!
126
144
  await writeStore(store)
127
145
  })
128
146
  }
package/server/web.ts CHANGED
@@ -5,12 +5,13 @@ import index from '../client/index.html'
5
5
  import { api } from './api'
6
6
  import { PORT } from './constants'
7
7
  import { control } from './control'
8
- import { EVENTS_TOPIC, setEventServer } from './events'
8
+ import { EVENTS_TOPIC, publishEvent, setEventServer } from './events'
9
9
  import { killAllWorkers } from './functions'
10
10
  import { startScratchpadSweeper } from './scratchpad'
11
11
  import { resolveScratchOp } from './scratchpad-relay'
12
12
  import { allHarnesses, harnessFor } from './harness/registry'
13
13
  import { getWorkspace } from './registry'
14
+ import { saveSelectedSession } from './selected-session'
14
15
  import { addClient, broadcastAll, getClientCount, removeClient, sendToClient } from './state'
15
16
  import { distShell, prebuilt } from './static'
16
17
  import { renderStatus } from './status'
@@ -140,6 +141,16 @@ export const app = Bun.serve<WsData>({
140
141
  if (data.type === 'chat' && (data.content?.trim() || data.attachments?.length)) {
141
142
  const workspace = await getWorkspace(data.workspaceId)
142
143
  if (!workspace) return
144
+ if (data.isNew) {
145
+ const selection = await saveSelectedSession(workspace.path, data.sessionId, null)
146
+ if (selection.changed) {
147
+ publishEvent({
148
+ type: 'selected-session:updated',
149
+ workspaceId: workspace.id,
150
+ sessionId: selection.sessionId
151
+ })
152
+ }
153
+ }
143
154
  // Harnesses ignore fields they don't support (see SendMessageInput);
144
155
  // failures surface as error frames from inside the harness.
145
156
  void harnessFor(workspace)
@@ -14,10 +14,10 @@ Design around the content and the task. Give every applet a clear first reading,
14
14
  proportion to its size and purpose. Dense information is welcome when hierarchy and alignment keep
15
15
  it easy to scan.
16
16
 
17
- An applet may have one expressive focal point: a visualization, strong surface, image, tactile
18
- interaction, or satisfying state change. It is optional. Use it when it helps the content and keep
19
- the rest restrained so it remains meaningful. Avoid decorative clutter, competing effects, and a
20
- different visual system for every section.
17
+ An applet may have one expressive focal point: a visualization, strong surface, image, or satisfying
18
+ state change. It is optional. Use it when it helps the content and keep the rest restrained so it
19
+ remains meaningful. Avoid decorative clutter, competing effects, and a different visual system for
20
+ every section.
21
21
 
22
22
  Every visible element must help the user understand useful content, see a real state, or take an
23
23
  action. Do not add category eyebrows that repeat the title, readiness badges for an obvious default
@@ -58,7 +58,7 @@ Views are separate pages. Their semantic tokens inherit the workspace theme, so
58
58
  | Floating surface | `bg-popover text-popover-foreground` | Menus, tooltips, and other floating content |
59
59
  | Primary action | `bg-primary text-primary-foreground` | The most important action in a local region |
60
60
  | Subdued surface | `bg-muted` | Skeletons, quiet fills, and disabled structure |
61
- | Interaction | `bg-accent text-accent-foreground` | Hover, active, selected, and subtle highlighted states |
61
+ | Control state | `bg-accent text-accent-foreground` | Hover, active, and selected states on interactive controls |
62
62
  | Error or danger | `text-destructive` / `bg-destructive` | Errors, destructive actions, and invalid states |
63
63
  | Structure | `ring-border`, `border-input`, `ring-ring` | Container edges, controls, and visible focus on semantic surfaces |
64
64
 
@@ -124,28 +124,18 @@ must not look capsule-shaped.
124
124
 
125
125
  ## Interaction and motion
126
126
 
127
- Widgets support quick interactions such as a filter, toggle, refresh, or direct action. Multi-step
128
- workflows and deep navigation belong in a view. Views may use tabs, filters, and master-detail
129
- layouts when they organize one coherent screen.
127
+ Widgets may include compact controls such as filters, toggles, refresh actions, and links. Keep
128
+ interaction feedback on the control that performs the action. The widget surface stays unchanged on
129
+ hover. Multi-step workflows and deep navigation belong in a view.
130
130
 
131
- Every interactive area must be obvious, keyboard-operable, and large enough to use comfortably.
132
- Controls need a visible focus state and an accessible name. Use Tabler icons with consistent visual
133
- weight. Do not rely on color alone, and keep charts understandable with labels, legends, patterns,
134
- or direct values where needed.
131
+ Controls must be obvious, keyboard-operable, and large enough to use comfortably. Give them a
132
+ visible focus state and an accessible name. Use Tabler icons with consistent visual weight. Do not
133
+ rely on color alone, and keep charts understandable with labels, legends, patterns, or direct values
134
+ where needed.
135
135
 
136
- Rank motion by purpose:
137
-
138
- 1. Optional entrance motion introduces the applet or a newly revealed region.
139
- 2. Interaction feedback covers hover, active, loading, disabled, and optimistic states.
140
- 3. At most one signature animation may act as the expressive focal point.
141
-
142
- Keep motion short, interruptible, and safe for reduced-motion preferences. Animate transform and
143
- opacity where possible. Do not loop decorative motion or animate frequently updating numbers. Audio
144
- and video must be user-initiated.
145
-
146
- A single interactive surface may use a restrained tactile treatment such as an inset highlight,
147
- ring, or soft shadow. Keep this away from the widget's outer root because the host owns the card
148
- shell.
136
+ Use short, interruptible motion for meaningful state changes and control feedback. Respect
137
+ reduced-motion preferences and animate transform and opacity where possible. Do not loop decorative
138
+ motion or animate frequently updating numbers. Audio and video must be user-initiated.
149
139
 
150
140
  ## States
151
141
 
@@ -259,6 +249,6 @@ Before finishing an applet, confirm:
259
249
  - Numeric UI values use the default font, with `tabular-nums` when alignment helps.
260
250
  - Custom container outlines suit their surface and stay subtle.
261
251
  - The layout handles realistic content and deliberate overflow.
262
- - Every reachable state and interaction is complete and accessible.
252
+ - Every control is necessary, complete, and accessible.
263
253
  - The widget or view follows its frame, sizing, and scrolling rules.
264
254
  - It feels related to the workspace without copying the quieter host shell.
@@ -1,6 +1,12 @@
1
1
  ---
2
2
  name: moi-workspace
3
- description: The moi workspace — the web UI the user chats from, extended with agent-authored applets (widgets, views) plus theme & config. Read this FIRST in two cases. (a) A message carries a hidden <moi-context>…</moi-context> envelope: it was fired from a moi workspace, so you are running inside one even if nothing else says so. (b) The user uses moi vocab — workspace, applet, widget, view, scratchpad, dashboard, or a `moi` command — or asks to build, edit, customize, or theme the workspace UI or its layout.
3
+ description: >-
4
+ The moi workspace — the web UI the user chats from, extended with agent-authored applets
5
+ (widgets, views) plus theme & config. Read this FIRST in two cases. (a) A message carries a hidden
6
+ moi-context envelope: it was fired from a moi workspace, so you are running inside one even if
7
+ nothing else says so. (b) The user uses moi vocab — workspace, applet, widget, view, scratchpad,
8
+ dashboard, or a `moi` command — or asks to build, edit, customize, or theme the workspace UI or
9
+ its layout.
4
10
  ---
5
11
 
6
12
  # Workspace
@@ -402,4 +408,4 @@ This skill is installed with moi (via the CLI or the UI) and can fall behind whe
402
408
  - **Then** — if you updated, mention it.
403
409
 
404
410
  <!-- moi skill version marker — read by `moi skill` to detect drift; do not edit by hand -->
405
- <moi-skill version="0.9.2" />
411
+ <moi-skill version="0.10.0" />
@@ -1 +0,0 @@
1
- import{a}from"/chunk-pcnahct1.js";import"/chunk-tzz101ea.js";export{a as sanitizeSvg};