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.
- package/client/AGENTS.md +9 -0
- package/client/api/app-ui-keys.ts +4 -0
- package/client/api/workspace-keys.ts +2 -2
- package/client/app/routes/WorkspaceRoute.tsx +8 -28
- package/client/components/shared/Composer.tsx +3 -6
- package/client/components/shared/IconGhost.tsx +130 -0
- package/client/components/ui/dropdown-menu.tsx +1 -1
- package/client/components/ui/spinner.tsx +18 -0
- package/client/components/ui/toast.tsx +220 -0
- package/client/features/chat/ChatComposer.tsx +3 -2
- package/client/features/chat/ChatPanel.tsx +7 -6
- package/client/features/chat/ChatPopup.tsx +10 -4
- package/client/features/chat/ChatSelector.tsx +263 -48
- package/client/features/chat/ModelPicker.tsx +13 -18
- package/client/features/chat/api.ts +36 -9
- package/client/features/chat/chat-frames.ts +35 -6
- package/client/features/chat/chat-send.ts +25 -1
- package/client/features/chat/chat-store.ts +43 -18
- package/client/features/chat/useChat.ts +54 -52
- package/client/features/chat/useSelectedSession.ts +151 -0
- package/client/features/chat/useStickToBottom.ts +3 -3
- package/client/features/home/api.ts +0 -2
- package/client/features/scratchpad/ScratchpadControls.tsx +2 -2
- package/client/features/settings/WorkspaceSettings.tsx +6 -6
- package/client/features/views/ViewBuilderTab.tsx +3 -4
- package/client/features/views/useViewBuilderActions.ts +3 -1
- package/client/features/workspace/WorkspaceScreen.tsx +38 -18
- package/client/features/workspace/WorkspaceTabs.tsx +10 -1
- package/client/main.tsx +2 -0
- package/client/runtime/useWorkspaceEvents.ts +1 -0
- package/client/store/ui.ts +2 -2
- package/dist/{chunk-zs4mte79.js → chunk-0pcdwjkp.js} +1 -1
- package/dist/chunk-55sh4dty.js +2 -0
- package/dist/{chunk-tzz101ea.js → chunk-9y2zbzqz.js} +1 -1
- package/dist/{chunk-jvhvme3z.js → chunk-afgbg75t.js} +1 -1
- package/dist/chunk-agtetn7n.css +1 -0
- package/dist/chunk-bv6vrvqf.js +27 -0
- package/dist/chunk-dfs36zgc.js +1 -0
- package/dist/chunk-exj6hr30.js +9 -0
- package/dist/{chunk-bcrkdhwe.js → chunk-m11ckkxd.js} +1 -1
- package/dist/{chunk-xwhya7kb.js → chunk-n6t40enm.js} +1 -1
- package/dist/{chunk-kfw1qwqe.js → chunk-rxvx4ta9.js} +3 -3
- package/dist/index.html +1 -1
- package/lib/attachment-note.ts +18 -0
- package/lib/chat-title.ts +6 -0
- package/lib/types.ts +24 -10
- package/package.json +1 -1
- package/server/api.ts +90 -9
- package/server/app-settings.ts +1 -1
- package/server/data-dir.ts +1 -1
- package/server/harness/README.md +6 -0
- package/server/harness/claude-code/adapter.ts +2 -2
- package/server/harness/claude-code/index.ts +7 -1
- package/server/harness/claude-code/session-title.ts +106 -0
- package/server/harness/claude-code/session.ts +87 -13
- package/server/harness/claude-code/sessions.ts +35 -4
- package/server/harness/codex/client.ts +30 -12
- package/server/harness/codex/index.ts +2 -0
- package/server/harness/codex/session-title.ts +149 -0
- package/server/harness/codex/session.ts +84 -11
- package/server/harness/openclaw/adapter.ts +4 -2
- package/server/harness/openclaw/discovery.ts +2 -0
- package/server/harness/openclaw/session.ts +15 -7
- package/server/harness/session-title.ts +96 -0
- package/server/harness/types.ts +2 -0
- package/server/selected-session.ts +132 -0
- package/server/{thread-config.ts → session-config.ts} +57 -39
- package/server/web.ts +12 -1
- package/workspace/.claude/skills/moi-workspace/DESIGN.md +16 -26
- package/workspace/.claude/skills/moi-workspace/SKILL.md +8 -2
- package/dist/chunk-94m3q9ce.js +0 -1
- package/dist/chunk-k9dcnd73.js +0 -27
- package/dist/chunk-pk11vfzs.js +0 -9
- package/dist/chunk-r2bqaege.js +0 -2
- 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 {
|
|
4
|
+
import type { SessionConfig } from '@/lib/types'
|
|
5
5
|
|
|
6
6
|
import { DATA_DIR } from './data-dir'
|
|
7
7
|
|
|
8
|
-
// Per-
|
|
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
|
|
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,
|
|
22
|
+
type Store = Record<string, Record<string, SessionConfig>>
|
|
23
23
|
|
|
24
|
-
|
|
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
|
|
28
|
-
|
|
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:
|
|
32
|
-
const out:
|
|
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:
|
|
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
|
|
48
|
+
async function readStoreFile(path: string): Promise<Store | null> {
|
|
44
49
|
try {
|
|
45
|
-
const parsed = JSON.parse(await Bun.file(
|
|
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(
|
|
54
|
-
const 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,
|
|
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
|
|
84
|
+
export async function getSessionConfig(
|
|
69
85
|
workspacePath: string,
|
|
70
86
|
sessionId: string
|
|
71
|
-
): Promise<
|
|
72
|
-
|
|
73
|
-
|
|
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
|
|
77
|
-
return !isEmpty(await
|
|
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
|
|
101
|
+
export async function saveSessionConfig(
|
|
84
102
|
workspacePath: string,
|
|
85
103
|
sessionId: string,
|
|
86
|
-
patch:
|
|
87
|
-
): Promise<
|
|
104
|
+
patch: SessionConfigPatch
|
|
105
|
+
): Promise<SessionConfig> {
|
|
88
106
|
return locked(async () => {
|
|
89
107
|
const store = await readStore()
|
|
90
|
-
const
|
|
91
|
-
const next = clean(
|
|
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
|
|
101
|
-
else
|
|
102
|
-
if (Object.keys(
|
|
103
|
-
else store[workspacePath] =
|
|
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
|
|
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
|
|
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
|
|
121
|
-
const src = clean(
|
|
138
|
+
const sessions = store[workspacePath]
|
|
139
|
+
const src = clean(sessions?.[from])
|
|
122
140
|
if (isEmpty(src)) return
|
|
123
|
-
|
|
124
|
-
delete
|
|
125
|
-
store[workspacePath] =
|
|
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,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
-
|
|
|
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
|
|
128
|
-
|
|
129
|
-
|
|
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
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
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
|
-
|
|
137
|
-
|
|
138
|
-
|
|
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
|
|
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:
|
|
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.
|
|
411
|
+
<moi-skill version="0.10.0" />
|
package/dist/chunk-94m3q9ce.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a}from"/chunk-pcnahct1.js";import"/chunk-tzz101ea.js";export{a as sanitizeSvg};
|