moi-computer 0.12.1-next.3 → 0.12.1-next.4
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/bunfig.toml +1 -5
- package/client/api/app-config.ts +1 -2
- package/client/api/app-ui-keys.ts +3 -1
- package/client/api/http.ts +4 -1
- package/client/api/workspace-keys.ts +3 -3
- package/client/app/app-provider.tsx +22 -2
- package/client/app/app-router.tsx +4 -0
- package/client/app/routes/home-route.tsx +14 -0
- package/client/app/routes/onboarding-route.tsx +11 -0
- package/client/app/routes/settings-route.tsx +1 -1
- package/client/app/routes/workspace-route.tsx +21 -19
- package/client/components/shared/screen-shell.tsx +23 -0
- package/client/components/shared/ultrafast-icon.tsx +61 -0
- package/client/components/shared/workspace-icon.tsx +2 -2
- package/client/features/account/account-test-utils.tsx +4 -3
- package/client/features/app-settings/api.ts +33 -0
- package/client/features/app-settings/general-settings.tsx +39 -0
- package/client/features/{settings → app-settings}/settings-page.tsx +5 -1
- package/client/features/chat/applet-chat-intents.ts +4 -20
- package/client/features/chat/chat-send.ts +17 -13
- package/client/features/chat/composer/model-order.ts +8 -4
- package/client/features/chat/composer/model-picker.tsx +88 -34
- package/client/features/chat/composer/use-workspace-composer-state.tsx +11 -3
- package/client/features/chat/composer/use-workspace-skill-updates.ts +1 -1
- package/client/features/chat/connection/chat-frames.ts +3 -15
- package/client/features/chat/messages/chat-empty-state.tsx +1 -4
- package/client/features/chat/messages/fork-history.ts +5 -5
- package/client/features/chat/messages/turn-view.tsx +3 -12
- package/client/features/chat/messages/user-message-bubble.tsx +63 -0
- package/client/features/chat/sessions/api.ts +121 -80
- package/client/features/chat/sessions/browser-tab-state.ts +14 -12
- package/client/features/chat/sessions/chat-selector.tsx +5 -6
- package/client/features/chat/sessions/use-selected-session.ts +172 -257
- package/client/features/chat/use-chat.ts +14 -19
- package/client/features/collab/workspace-users-menu.tsx +1 -1
- package/client/features/demo/demo-dialog.tsx +11 -3
- package/client/features/dev/dev-index-page.tsx +5 -0
- package/client/features/dev/dev-routes.tsx +2 -0
- package/client/features/dev/harness-debug-page.tsx +3 -3
- package/client/features/dev/onboarding-preview-page.tsx +76 -0
- package/client/features/dev/workspace-setup-mocks.ts +16 -14
- package/client/features/dev/workspace-setup-preview.tsx +11 -17
- package/client/features/harness/api.ts +45 -15
- package/client/features/harness/device-login-steps.tsx +9 -3
- package/client/features/harness/harness-login-panel.tsx +228 -0
- package/client/features/harness/harness-presentation.ts +15 -0
- package/client/features/harness/harness-selector.tsx +119 -0
- package/client/features/harness/use-harness-login.ts +77 -0
- package/client/features/home/home-page.tsx +7 -7
- package/client/features/onboarding/agent-setup-step.tsx +57 -0
- package/client/features/onboarding/api.ts +42 -0
- package/client/features/onboarding/onboarding-idea-disk.tsx +129 -0
- package/client/features/onboarding/onboarding-page.tsx +32 -0
- package/client/features/onboarding/onboarding-screen.tsx +20 -0
- package/client/features/onboarding/onboarding-status.tsx +24 -0
- package/client/features/onboarding/workspace-setup-step.tsx +239 -0
- package/client/features/overview/default/registry.tsx +2 -2
- package/client/features/overview/default/views-widget.tsx +6 -5
- package/client/features/overview/overview.tsx +9 -11
- package/client/features/overview/widget-canvas.tsx +1 -1
- package/client/features/overview/workspace-name.tsx +2 -2
- package/client/features/views/api.ts +69 -16
- package/client/features/views/pending-view-screen.tsx +30 -9
- package/client/features/views/use-view-actions.ts +19 -20
- package/client/features/views/view-presentation.ts +2 -2
- package/client/features/views/view-submission.ts +28 -41
- package/client/features/workspace/add/api.ts +3 -23
- package/client/features/workspace/add/create-workspace-dialog.tsx +6 -5
- package/client/features/workspace/add/import-workspace-dialog.tsx +3 -3
- package/client/features/workspace/add/workspace-agent-options.ts +11 -12
- package/client/features/workspace/add/workspace-agent-selector.tsx +3 -132
- package/client/features/workspace/api.ts +32 -36
- package/client/features/workspace/harness-transition.ts +88 -0
- package/client/features/{settings → workspace/settings}/api.ts +1 -34
- package/client/features/{settings → workspace/settings}/general-settings.tsx +76 -2
- package/client/features/{settings → workspace/settings}/use-env-vars.ts +1 -1
- package/client/features/{settings → workspace/settings}/workspace-icon-picker.tsx +3 -3
- package/client/features/workspace/setup/workspace-login-state.tsx +37 -156
- package/client/features/workspace/setup/workspace-recovery-states.tsx +0 -12
- package/client/features/workspace/setup/workspace-setup.tsx +34 -14
- package/client/features/workspace/setup/workspace-welcome-state.tsx +2 -2
- package/client/features/workspace/use-workspace-navigation.ts +25 -9
- package/client/features/workspace/workspace-content.tsx +11 -8
- package/client/features/workspace/workspace-frame.tsx +2 -1
- package/client/features/workspace/workspace-layout-context.tsx +5 -2
- package/client/features/workspace/workspace-menu.tsx +12 -8
- package/client/features/workspace/workspace-pending-screen.tsx +10 -10
- package/client/features/workspace/workspace-presentation.tsx +5 -13
- package/client/features/workspace/workspace-state.ts +169 -0
- package/client/features/workspace/workspace-tabs.tsx +22 -2
- package/client/index.css +2 -0
- package/client/index.tsx +3 -3
- package/client/lib/flags.ts +1 -1
- package/client/lib/{app-icon-registry.ts → identity-icon-registry.ts} +10 -14
- package/client/runtime/workspace-events.ts +21 -4
- package/client/runtime/workspace-theme.ts +9 -0
- package/client/tailwind-config.ts +43 -0
- package/dist/chunk-0mjzg20x.js +2 -0
- package/dist/chunk-2y59vrxg.js +5 -0
- package/dist/chunk-58dyt9bk.js +2 -0
- package/dist/chunk-5aj040e5.css +1 -0
- package/dist/{chunk-tqd3pkg8.css → chunk-60q353jq.css} +1 -1
- package/dist/chunk-71fn6rmj.js +546 -0
- package/dist/chunk-7yg1m8hx.js +2 -0
- package/dist/chunk-825hys3h.js +1 -0
- package/dist/chunk-9bb8m9rx.js +2 -0
- package/dist/{chunk-11cab5dq.css → chunk-cq2r11fg.css} +1 -1
- package/dist/chunk-g0tcwqxc.js +1 -0
- package/dist/chunk-n0nab26d.js +1 -0
- package/dist/chunk-nf2wkvf9.js +14 -0
- package/dist/chunk-v88n1bay.js +74 -0
- package/dist/index.html +1 -1
- package/lib/harness-instructions.ts +1 -1
- package/lib/{app-icons.ts → identity-icons.ts} +6 -7
- package/lib/onboarding.ts +41 -0
- package/lib/speed-mode.ts +5 -0
- package/lib/types.ts +71 -62
- package/lib/view-build-directives.ts +1 -2
- package/lib/workspace-icon.ts +2 -2
- package/lib/workspace-layout.ts +1 -1
- package/lib/workspace-name.ts +15 -12
- package/package.json +9 -8
- package/server/README.md +27 -25
- package/server/api/harnesses.ts +31 -8
- package/server/api/index.ts +163 -126
- package/server/api/onboarding.ts +46 -0
- package/server/app-config.ts +16 -24
- package/server/app-settings.ts +6 -2
- package/server/applets/config.ts +5 -5
- package/server/applets/views.ts +19 -17
- package/server/cli/commands/init.ts +3 -3
- package/server/cli/commands/skill.ts +16 -17
- package/server/cli/commands/start.ts +8 -34
- package/server/cli/server.ts +18 -6
- package/server/collab/config.ts +1 -2
- package/server/collab/manager.ts +4 -1
- package/server/collab/skill/index.ts +1 -1
- package/server/control.ts +3 -3
- package/server/data-dir.ts +1 -1
- package/server/harness/README.md +24 -8
- package/server/harness/acp/session.ts +8 -4
- package/server/harness/auth.ts +14 -17
- package/server/harness/claude-code/NOTES.md +4 -3
- package/server/harness/claude-code/index.ts +2 -0
- package/server/harness/claude-code/models.ts +2 -20
- package/server/harness/claude-code/run-action.ts +123 -0
- package/server/harness/claude-code/session-title.ts +5 -7
- package/server/harness/claude-code/session.ts +24 -16
- package/server/harness/codex/NOTES.md +14 -9
- package/server/harness/codex/adapter.ts +14 -17
- package/server/harness/codex/index.ts +2 -0
- package/server/harness/codex/run-action.ts +93 -0
- package/server/harness/codex/session-title.ts +6 -8
- package/server/harness/codex/session.ts +11 -11
- package/server/harness/command.ts +45 -0
- package/server/harness/executable.ts +5 -0
- package/server/harness/fork.ts +6 -4
- package/server/harness/install.ts +49 -0
- package/server/harness/openclaw/session.ts +1 -2
- package/server/harness/run-action.ts +85 -0
- package/server/harness/session-title.ts +0 -46
- package/server/harness/types.ts +26 -2
- package/server/onboarding/brief.ts +29 -0
- package/server/onboarding/ideas.ts +48 -0
- package/server/onboarding/jobs.ts +291 -0
- package/server/onboarding/prompt.md +49 -0
- package/server/sessions/archive.ts +5 -14
- package/server/sessions/config.ts +17 -16
- package/server/sessions/lifecycle.ts +15 -13
- package/server/sessions/pending-views.ts +79 -108
- package/server/sessions/selected.ts +75 -161
- package/server/sessions/store.ts +40 -113
- package/server/sessions/view-sessions.ts +128 -111
- package/server/skills/locations.ts +82 -0
- package/server/skills/lock.ts +29 -0
- package/server/skills/template.ts +36 -25
- package/server/skills/update.ts +52 -5
- package/server/skills/version.ts +17 -22
- package/server/skills/workspace.ts +121 -0
- package/server/web.ts +22 -8
- package/server/workspace-state/file.ts +177 -0
- package/server/workspace-state/index.ts +162 -0
- package/server/workspace-state/legacy-migration.ts +79 -0
- package/server/workspace-state/lock.ts +42 -0
- package/server/workspace-state/types.ts +16 -0
- package/server/workspaces/change-harness.ts +88 -0
- package/server/workspaces/harness-transition.ts +29 -0
- package/server/workspaces/init.ts +29 -6
- package/server/workspaces/layout.ts +3 -0
- package/server/workspaces/registry.ts +27 -1
- package/{workspace/.claude/skills/moi-workspace → skill}/SKILL.md +7 -5
- package/{workspace/.claude/skills/moi-workspace → skill}/references/COLLAB.md +4 -8
- package/skill/references/DESIGN.md +148 -0
- package/{workspace/.claude/skills/moi-workspace → skill}/references/SCRATCHPAD.md +2 -2
- package/{workspace/.claude/skills/moi-workspace → skill}/references/UI-COMPONENTS.md +3 -0
- package/ui-components/badge.tsx +1 -1
- package/client/accept-hmr-dependencies.ts +0 -22
- package/client/features/workspace/setup/workspace-setup-panel.tsx +0 -18
- package/dist/chunk-20ynagd4.js +0 -2
- package/dist/chunk-42tde9a6.js +0 -1
- package/dist/chunk-9w543s0r.js +0 -2
- package/dist/chunk-a5372n61.js +0 -546
- package/dist/chunk-aja9y1vn.js +0 -68
- package/dist/chunk-fvcvrh3d.css +0 -1
- package/dist/chunk-gtfjw3nx.js +0 -1
- package/dist/chunk-j39y2aky.js +0 -14
- package/dist/chunk-pcnahct1.js +0 -5
- package/dist/chunk-pja30km3.js +0 -1
- package/dist/chunk-rm894bc2.js +0 -2
- package/dist/chunk-tevvtfbk.js +0 -10
- package/dist/chunk-tgt9zd0r.js +0 -2
- package/dist/chunk-tv5k5z00.js +0 -1
- package/dist/chunk-zq2ae5dx.js +0 -2
- package/lib/experimental.ts +0 -14
- package/workspace/.claude/skills/moi-workspace/references/DESIGN.md +0 -157
- /package/client/features/{settings → app-settings}/profile-settings.tsx +0 -0
- /package/client/features/{settings → app-settings}/settings-section.tsx +0 -0
- /package/client/features/{settings → app-settings}/users-settings.tsx +0 -0
- /package/client/features/{settings → workspace/settings}/connectors-settings.tsx +0 -0
- /package/client/features/{settings → workspace/settings}/environment-settings.tsx +0 -0
- /package/client/features/{settings → workspace/settings}/icon-picker-options.ts +0 -0
- /package/client/features/{settings → workspace/settings}/settings-layout.tsx +0 -0
- /package/client/features/{settings → workspace/settings}/workspace-settings-dialog.tsx +0 -0
- /package/{workspace/.claude/skills/moi-workspace → skill}/references/INTENTS.md +0 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// One-time import of the pre-0.13 global stores into per-workspace state,
|
|
2
|
+
// keyed by workspace path. Imports registered workspaces only, then deletes
|
|
3
|
+
// the old files. Delete this file after v0.14.
|
|
4
|
+
import { rm } from 'node:fs/promises'
|
|
5
|
+
import { join } from 'node:path'
|
|
6
|
+
|
|
7
|
+
import { DATA_DIR } from '../data-dir'
|
|
8
|
+
import { normalizeWorkspaceState } from './file'
|
|
9
|
+
import { hasWorkspaceState, updateWorkspaceState } from './index'
|
|
10
|
+
import type { WorkspaceRef } from './types'
|
|
11
|
+
|
|
12
|
+
type LegacySession = {
|
|
13
|
+
tabId?: string
|
|
14
|
+
config?: unknown
|
|
15
|
+
forkedFromSessionId?: string
|
|
16
|
+
forkedThroughMessageId?: string
|
|
17
|
+
forkedNoticeIds?: string[]
|
|
18
|
+
}
|
|
19
|
+
type LegacySelection = { selected?: unknown; pinned?: unknown }
|
|
20
|
+
type LegacyView = { id: string; executionSessionId?: string }
|
|
21
|
+
|
|
22
|
+
export const LEGACY_FILES = [
|
|
23
|
+
'sessions.json',
|
|
24
|
+
'session-config.json',
|
|
25
|
+
'selected-sessions.json',
|
|
26
|
+
'pending-views.json',
|
|
27
|
+
'view-builders.json'
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
function readLegacy<T>(dataDir: string, name: string): Promise<Record<string, T>> {
|
|
31
|
+
return Bun.file(join(dataDir, name))
|
|
32
|
+
.json()
|
|
33
|
+
.catch(() => ({}))
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export async function migrateLegacyWorkspaceState(
|
|
37
|
+
workspaces: readonly WorkspaceRef[],
|
|
38
|
+
dataDir = DATA_DIR
|
|
39
|
+
): Promise<void> {
|
|
40
|
+
const sessions = await readLegacy<Record<string, LegacySession>>(dataDir, 'sessions.json')
|
|
41
|
+
const selections = await readLegacy<LegacySelection>(dataDir, 'selected-sessions.json')
|
|
42
|
+
const pendingViews = await readLegacy<LegacyView[]>(dataDir, 'pending-views.json')
|
|
43
|
+
|
|
44
|
+
for (const ws of workspaces) {
|
|
45
|
+
if (hasWorkspaceState(ws.id)) continue
|
|
46
|
+
const state = normalizeWorkspaceState(
|
|
47
|
+
{
|
|
48
|
+
pinnedSessionId: selections[ws.path]?.pinned,
|
|
49
|
+
selected: selections[ws.path]?.selected,
|
|
50
|
+
sessions: Object.fromEntries(
|
|
51
|
+
Object.entries(sessions[ws.path] ?? {}).map(([id, session]) => [
|
|
52
|
+
id,
|
|
53
|
+
{
|
|
54
|
+
tabId: session.tabId,
|
|
55
|
+
config: session.config,
|
|
56
|
+
fork: session.forkedFromSessionId && {
|
|
57
|
+
fromSessionId: session.forkedFromSessionId,
|
|
58
|
+
throughMessageId: session.forkedThroughMessageId,
|
|
59
|
+
noticeIds: session.forkedNoticeIds
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
])
|
|
63
|
+
),
|
|
64
|
+
pendingViews: Object.fromEntries(
|
|
65
|
+
(pendingViews[ws.path] ?? []).map(({ id, executionSessionId, ...view }) => [
|
|
66
|
+
id,
|
|
67
|
+
{ ...view, buildSessionId: executionSessionId }
|
|
68
|
+
])
|
|
69
|
+
)
|
|
70
|
+
},
|
|
71
|
+
ws.path
|
|
72
|
+
)
|
|
73
|
+
await updateWorkspaceState(ws, draft => {
|
|
74
|
+
Object.assign(draft, state)
|
|
75
|
+
})
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
for (const name of LEGACY_FILES) await rm(join(dataDir, name), { force: true })
|
|
79
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// One holder per key at a time. A holder that runs past the timeout stops
|
|
2
|
+
// blocking the queue: the next waiter starts, and the stale holder's lease
|
|
3
|
+
// reports it is no longer current so it can refuse to commit late.
|
|
4
|
+
|
|
5
|
+
export type Lease = {
|
|
6
|
+
isCurrent(): boolean
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export class LockTimeoutError extends Error {
|
|
10
|
+
constructor(key: string) {
|
|
11
|
+
super(`Lock on ${key} expired before the write could commit`)
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function createKeyedLock(timeoutMs: number) {
|
|
16
|
+
const tails = new Map<string, Promise<void>>()
|
|
17
|
+
const owners = new Map<string, number>()
|
|
18
|
+
let lastToken = 0
|
|
19
|
+
|
|
20
|
+
return async function withLock<T>(key: string, run: (lease: Lease) => Promise<T>): Promise<T> {
|
|
21
|
+
const previous = tails.get(key) ?? Promise.resolve()
|
|
22
|
+
let release!: () => void
|
|
23
|
+
const released = new Promise<void>(resolve => (release = resolve))
|
|
24
|
+
tails.set(key, released)
|
|
25
|
+
await previous
|
|
26
|
+
|
|
27
|
+
const token = ++lastToken
|
|
28
|
+
owners.set(key, token)
|
|
29
|
+
const expiry = setTimeout(release, timeoutMs)
|
|
30
|
+
expiry.unref?.()
|
|
31
|
+
try {
|
|
32
|
+
return await run({ isCurrent: () => owners.get(key) === token })
|
|
33
|
+
} finally {
|
|
34
|
+
clearTimeout(expiry)
|
|
35
|
+
release()
|
|
36
|
+
if (tails.get(key) === released) {
|
|
37
|
+
tails.delete(key)
|
|
38
|
+
owners.delete(key)
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { WorkspaceEntry, WorkspaceState } from '@/lib/types'
|
|
2
|
+
|
|
3
|
+
export const WORKSPACE_STATE_VERSION = 1
|
|
4
|
+
|
|
5
|
+
// What the store needs to find a workspace's file and stamp its folder path.
|
|
6
|
+
export type WorkspaceRef = Pick<WorkspaceEntry, 'id' | 'path'>
|
|
7
|
+
|
|
8
|
+
// `state.json` on disk: the state clients see, plus the file format version
|
|
9
|
+
// and the folder it belongs to. Chat titles and history stay in each
|
|
10
|
+
// harness's transcripts.
|
|
11
|
+
export type StoredWorkspaceState = WorkspaceState & {
|
|
12
|
+
version: typeof WORKSPACE_STATE_VERSION
|
|
13
|
+
// A re-added workspace (new registration) finds its old id through it, and
|
|
14
|
+
// startup prunes state for deleted folders.
|
|
15
|
+
workspacePath: string
|
|
16
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { loadLayout, saveLayout } from './layout'
|
|
2
|
+
import type { WorkspaceEntry, WorkspaceType } from '@/lib/types'
|
|
3
|
+
import { harnessFor } from '../harness/registry'
|
|
4
|
+
import { harnessStore } from '../harness/auth'
|
|
5
|
+
import { getWorkspaceSkillsStatus } from '../skills/update'
|
|
6
|
+
import { publishEvent } from '../events'
|
|
7
|
+
import { updateWorkspaceState } from '../workspace-state'
|
|
8
|
+
import { getWorkspace, updateWorkspaceHarness } from './registry'
|
|
9
|
+
import { HarnessTransitionError, withHarnessTransition } from './harness-transition'
|
|
10
|
+
import { installWorkspaceSkills } from '../skills/workspace'
|
|
11
|
+
|
|
12
|
+
// Keep successful preparation for this server lifetime; failed attempts can retry.
|
|
13
|
+
const preparation = new Map<string, Promise<void>>()
|
|
14
|
+
export function prepareWorkspaceHarness(ws: WorkspaceEntry): Promise<void> {
|
|
15
|
+
const key = `${ws.path}:${ws.type ?? 'claude-code'}`
|
|
16
|
+
let pending = preparation.get(key)
|
|
17
|
+
if (!pending) {
|
|
18
|
+
pending = getWorkspaceSkillsStatus(ws.path, ws.type)
|
|
19
|
+
.then(async status => {
|
|
20
|
+
if (status.skills.some(skill => !skill.installed))
|
|
21
|
+
await installWorkspaceSkills(ws.path, ws.type)
|
|
22
|
+
})
|
|
23
|
+
.catch(error => {
|
|
24
|
+
preparation.delete(key)
|
|
25
|
+
throw error
|
|
26
|
+
})
|
|
27
|
+
preparation.set(key, pending)
|
|
28
|
+
}
|
|
29
|
+
return pending
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export async function changeWorkspaceHarness(ws: WorkspaceEntry, type: WorkspaceType) {
|
|
33
|
+
return withHarnessTransition(ws, async () => {
|
|
34
|
+
const current = await getWorkspace(ws.id)
|
|
35
|
+
if (!current) throw new HarnessTransitionError('Workspace not found')
|
|
36
|
+
const previousType = current.type ?? 'claude-code'
|
|
37
|
+
const harness = harnessFor(current)
|
|
38
|
+
if (
|
|
39
|
+
!['claude-code', 'codex'].includes(previousType) ||
|
|
40
|
+
!['claude-code', 'codex'].includes(type)
|
|
41
|
+
)
|
|
42
|
+
throw new HarnessTransitionError('This workspace’s agent cannot be changed')
|
|
43
|
+
if (type === previousType) return current
|
|
44
|
+
if (harness.activeSessions().some(session => session.workspaceId === ws.id))
|
|
45
|
+
throw new HarnessTransitionError('Wait for the agent to finish before changing it')
|
|
46
|
+
const layoutBefore = await loadLayout(current.path)
|
|
47
|
+
const before = await updateWorkspaceState(current, state => {
|
|
48
|
+
const before = structuredClone(state)
|
|
49
|
+
state.selected = {}
|
|
50
|
+
delete state.pinnedSessionId
|
|
51
|
+
for (const view of Object.values(state.pendingViews)) {
|
|
52
|
+
delete view.buildSessionId
|
|
53
|
+
view.status = 'draft'
|
|
54
|
+
delete view.error
|
|
55
|
+
}
|
|
56
|
+
return before
|
|
57
|
+
})
|
|
58
|
+
let updated: WorkspaceEntry
|
|
59
|
+
try {
|
|
60
|
+
const layout = { ...layoutBefore }
|
|
61
|
+
delete layout.selectedModel
|
|
62
|
+
delete layout.selectedEffort
|
|
63
|
+
delete layout.selectedSpeedMode
|
|
64
|
+
await saveLayout(layout, current.path)
|
|
65
|
+
updated = await updateWorkspaceHarness(ws.id, type)
|
|
66
|
+
} catch (error) {
|
|
67
|
+
const recovery = await Promise.allSettled([
|
|
68
|
+
saveLayout(layoutBefore, current.path),
|
|
69
|
+
updateWorkspaceState(current, state => Object.assign(state, before))
|
|
70
|
+
])
|
|
71
|
+
for (const result of recovery) {
|
|
72
|
+
if (result.status === 'rejected')
|
|
73
|
+
console.error('Could not restore workspace state', result.reason)
|
|
74
|
+
}
|
|
75
|
+
throw error
|
|
76
|
+
}
|
|
77
|
+
// Capture and dispose the old runtime before allowing another transition.
|
|
78
|
+
// stopWorkspace only signals local processes; it does not wait for their exit.
|
|
79
|
+
try {
|
|
80
|
+
harness.stopWorkspace?.(current.path)
|
|
81
|
+
} catch (error) {
|
|
82
|
+
console.error('Could not stop previous workspace runtime', error)
|
|
83
|
+
}
|
|
84
|
+
harnessStore.invalidate(current)
|
|
85
|
+
publishEvent({ type: 'workspace-harness:switched', workspaceId: ws.id, harness: type })
|
|
86
|
+
return updated
|
|
87
|
+
})
|
|
88
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { WorkspaceEntry } from '@/lib/types'
|
|
2
|
+
|
|
3
|
+
const operations = new Map<string, number>()
|
|
4
|
+
const switching = new Set<string>()
|
|
5
|
+
export class HarnessTransitionError extends Error {}
|
|
6
|
+
|
|
7
|
+
export function reserveWorkspaceOperation(id: string): () => void {
|
|
8
|
+
if (switching.has(id)) throw new HarnessTransitionError('Agent is changing. Try again')
|
|
9
|
+
operations.set(id, (operations.get(id) ?? 0) + 1)
|
|
10
|
+
return () => {
|
|
11
|
+
const count = (operations.get(id) ?? 1) - 1
|
|
12
|
+
if (count) operations.set(id, count)
|
|
13
|
+
else operations.delete(id)
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export async function withHarnessTransition<T>(
|
|
18
|
+
ws: WorkspaceEntry,
|
|
19
|
+
operation: () => Promise<T>
|
|
20
|
+
): Promise<T> {
|
|
21
|
+
if (switching.has(ws.id) || operations.has(ws.id))
|
|
22
|
+
throw new HarnessTransitionError('Workspace is busy. Try again when the agent is idle')
|
|
23
|
+
switching.add(ws.id)
|
|
24
|
+
try {
|
|
25
|
+
return await operation()
|
|
26
|
+
} finally {
|
|
27
|
+
switching.delete(ws.id)
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -7,11 +7,34 @@ import { mkdir } from 'node:fs/promises'
|
|
|
7
7
|
import { join } from 'node:path'
|
|
8
8
|
|
|
9
9
|
import type { WorkspaceType } from '@/lib/types'
|
|
10
|
-
|
|
10
|
+
import { workspaceIdFromName } from '@/lib/workspace-name'
|
|
11
|
+
import { validateWorkspaceId } from '@/lib/ids'
|
|
12
|
+
import { getWorkspace } from './registry'
|
|
11
13
|
|
|
12
14
|
import { harnessFor } from '../harness/registry'
|
|
13
15
|
import { createDependencyInstallLogPath, scaffoldMoiDir } from './scaffold'
|
|
14
|
-
import {
|
|
16
|
+
import { installWorkspaceSkills } from '../skills/workspace'
|
|
17
|
+
|
|
18
|
+
// Reserve a unique folder whose basename is also its workspace ID.
|
|
19
|
+
export async function createWorkspaceDirectory(
|
|
20
|
+
name: string,
|
|
21
|
+
root: string,
|
|
22
|
+
lookup = getWorkspace
|
|
23
|
+
): Promise<string> {
|
|
24
|
+
const base = workspaceIdFromName(name)
|
|
25
|
+
await mkdir(root, { recursive: true })
|
|
26
|
+
for (let suffix = 1; ; suffix++) {
|
|
27
|
+
const id = suffix === 1 ? base : `${base}-${suffix}`
|
|
28
|
+
if (validateWorkspaceId(id) || (await lookup(id))) continue
|
|
29
|
+
const path = join(root, id)
|
|
30
|
+
try {
|
|
31
|
+
await mkdir(path)
|
|
32
|
+
return path
|
|
33
|
+
} catch (error) {
|
|
34
|
+
if ((error as NodeJS.ErrnoException).code !== 'EEXIST') throw error
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
15
38
|
|
|
16
39
|
// Where each backend loads skills from — the harness owns the answer
|
|
17
40
|
// (Claude Code: `.claude/skills/`; OpenClaw: `<workspace>/skills/`; Codex:
|
|
@@ -32,9 +55,9 @@ export type ProvisionResult = {
|
|
|
32
55
|
installLogPath: string
|
|
33
56
|
}
|
|
34
57
|
|
|
35
|
-
// Lay down everything a workspace needs:
|
|
36
|
-
// skills
|
|
37
|
-
//
|
|
58
|
+
// Lay down everything a workspace needs: reset Claude/Codex's shared skill
|
|
59
|
+
// (or copy skills to other backends' own destinations), and bootstrap `.moi/`.
|
|
60
|
+
// Re-running refreshes skills and leaves an existing `.moi/` untouched.
|
|
38
61
|
// Registration in the workspace registry is a separate, caller-owned step.
|
|
39
62
|
export async function provisionWorkspace(
|
|
40
63
|
workspaceRoot: string,
|
|
@@ -42,7 +65,7 @@ export async function provisionWorkspace(
|
|
|
42
65
|
): Promise<ProvisionResult> {
|
|
43
66
|
const skillsDir = skillsDirFor(workspaceRoot, type)
|
|
44
67
|
await mkdir(workspaceRoot, { recursive: true })
|
|
45
|
-
await
|
|
68
|
+
await installWorkspaceSkills(workspaceRoot, type)
|
|
46
69
|
const installLogPath = createDependencyInstallLogPath()
|
|
47
70
|
const scaffold = await scaffoldMoiDir(workspaceRoot, undefined, undefined, installLogPath)
|
|
48
71
|
return { skillsDir, scaffold, installLogPath }
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { join } from 'path'
|
|
2
|
+
import { isSpeedMode } from '@/lib/speed-mode'
|
|
2
3
|
|
|
3
4
|
import type {
|
|
4
5
|
AppletKind,
|
|
@@ -18,6 +19,8 @@ function normalizeLayout(parsed: Record<string, unknown>): WorkspaceLayout {
|
|
|
18
19
|
layout.layoutMode = defaults.layoutMode
|
|
19
20
|
}
|
|
20
21
|
layout.tabs = normalizeWorkspaceTabs(layout.tabs)
|
|
22
|
+
if (!isSpeedMode(layout.selectedSpeedMode)) delete layout.selectedSpeedMode
|
|
23
|
+
delete layout.selectedFastMode
|
|
21
24
|
if (typeof layout.icon === 'string') {
|
|
22
25
|
layout.icon = { type: 'upload', value: layout.icon }
|
|
23
26
|
} else if (layout.icon !== undefined && !isWorkspaceIcon(layout.icon)) {
|
|
@@ -11,6 +11,7 @@ import { DATA_DIR } from '../data-dir'
|
|
|
11
11
|
import { allHarnesses } from '../harness/registry'
|
|
12
12
|
import type { DiscoveredWorkspaceCandidate } from '../harness/types'
|
|
13
13
|
import { createdWorkspacesRoot } from '../app-config'
|
|
14
|
+
import { findStateIdForPath } from '../workspace-state'
|
|
14
15
|
|
|
15
16
|
// Replace the home-dir prefix with `~` for display. Keeps the original
|
|
16
17
|
// absolute path in place; callers should put the result in `displayPath`.
|
|
@@ -71,6 +72,17 @@ function locked<T>(operation: () => Promise<T>): Promise<T> {
|
|
|
71
72
|
return run
|
|
72
73
|
}
|
|
73
74
|
|
|
75
|
+
// A removed workspace keeps its state folder. Re-adding the same folder takes
|
|
76
|
+
// its old id back, and with it the pinned chat, selections and chat settings.
|
|
77
|
+
async function previousWorkspaceId(
|
|
78
|
+
entries: WorkspaceEntry[],
|
|
79
|
+
normalPath: string
|
|
80
|
+
): Promise<string | undefined> {
|
|
81
|
+
const id = await findStateIdForPath(normalPath)
|
|
82
|
+
if (!id || validateWorkspaceId(id) || entries.some(e => e.id === id)) return undefined
|
|
83
|
+
return id
|
|
84
|
+
}
|
|
85
|
+
|
|
74
86
|
export type RegisterOptions = {
|
|
75
87
|
// Register under this id instead of a generated one. Only accepted while the
|
|
76
88
|
// workspace is unregistered — see `workspaceIdError`.
|
|
@@ -124,7 +136,7 @@ export async function registerWorkspace(
|
|
|
124
136
|
const existing = entries.find(e => e.path === normalPath)
|
|
125
137
|
if (existing) return existing
|
|
126
138
|
const entry: WorkspaceEntry = {
|
|
127
|
-
id: opts.id ?? newWorkspaceId(),
|
|
139
|
+
id: opts.id ?? (await previousWorkspaceId(entries, normalPath)) ?? newWorkspaceId(),
|
|
128
140
|
path: normalPath,
|
|
129
141
|
addedAt: new Date().toISOString(),
|
|
130
142
|
...(opts.type ? { type: opts.type } : {}),
|
|
@@ -277,3 +289,17 @@ export async function discoverWorkspaces(): Promise<DiscoveredWorkspace[]> {
|
|
|
277
289
|
withDisplayPath
|
|
278
290
|
)
|
|
279
291
|
}
|
|
292
|
+
|
|
293
|
+
export async function updateWorkspaceHarness(
|
|
294
|
+
id: string,
|
|
295
|
+
type: WorkspaceType
|
|
296
|
+
): Promise<WorkspaceEntry> {
|
|
297
|
+
return locked(async () => {
|
|
298
|
+
const entries = await readRegistry()
|
|
299
|
+
const entry = entries.find(entry => entry.id === id)
|
|
300
|
+
if (!entry) throw new Error('Workspace not found')
|
|
301
|
+
entry.type = type
|
|
302
|
+
await writeRegistry(entries)
|
|
303
|
+
return withDisplayPath(entry)
|
|
304
|
+
})
|
|
305
|
+
}
|
|
@@ -343,8 +343,7 @@ moi views set <view-id> --title "<title>" --icon <icon-id>
|
|
|
343
343
|
Choose from the available view icons in the hidden context when that list is present. Then write
|
|
344
344
|
`.moi/views/<view-id>.tsx` and use the same title and icon in its config. Run
|
|
345
345
|
`moi check --only views/<view-id>` before `moi bundle --only views/<view-id>`. A successful bundle
|
|
346
|
-
replaces the pending screen in the same tab.
|
|
347
|
-
`moi:/views/<view-id>` link.
|
|
346
|
+
replaces the pending screen in the same tab.
|
|
348
347
|
|
|
349
348
|
### Styling and UI components
|
|
350
349
|
|
|
@@ -453,8 +452,11 @@ After the final successful checks, hand off the result according to the task:
|
|
|
453
452
|
|
|
454
453
|
- After building or editing a widget, run `moi navigate 'moi:/overview'`.
|
|
455
454
|
- After editing an existing view, run `moi navigate 'moi:/views/<view-id>'`.
|
|
456
|
-
- After a pending view build, keep the current tab open
|
|
457
|
-
|
|
455
|
+
- After a pending view build, keep the current tab open.
|
|
456
|
+
|
|
457
|
+
Use the chat's owning tab from the hidden context to decide whether a view link is useful.
|
|
458
|
+
In a view's own chat, summarize the result without linking back to that same view. Include
|
|
459
|
+
`moi:/views/<view-id>` links when replying from Overview or pointing to another view.
|
|
458
460
|
|
|
459
461
|
Keep the final reply brief and user-facing. Do not include file or storage links, file paths, or
|
|
460
462
|
bundle, test, and runtime-log summaries.
|
|
@@ -520,4 +522,4 @@ This skill is installed with Moi (via the CLI or the UI) and can fall behind whe
|
|
|
520
522
|
- **Then** — if you updated, mention it.
|
|
521
523
|
|
|
522
524
|
<!-- moi skill version marker — read by `moi skill` to detect drift; do not edit by hand -->
|
|
523
|
-
<moi-skill version="0.20.
|
|
525
|
+
<moi-skill version="0.20.1" />
|
|
@@ -124,8 +124,7 @@ distinct `id` values. A single area can omit `id`, which defaults to `"default"`
|
|
|
124
124
|
|
|
125
125
|
```tsx
|
|
126
126
|
import { Cursors } from 'moi/collab'
|
|
127
|
-
|
|
128
|
-
<Cursors id="board">{children}</Cursors>
|
|
127
|
+
;<Cursors id="board">{children}</Cursors>
|
|
129
128
|
```
|
|
130
129
|
|
|
131
130
|
#### `PresenceFrame` and `PresenceAvatars`
|
|
@@ -164,8 +163,7 @@ owns focus when wrappers are nested.
|
|
|
164
163
|
import { PresenceFrame, PresenceAvatars } from 'moi/collab'
|
|
165
164
|
import { Input } from '../ui/input'
|
|
166
165
|
import { Textarea } from '../ui/textarea'
|
|
167
|
-
|
|
168
|
-
<>
|
|
166
|
+
;<>
|
|
169
167
|
<PresenceFrame id="title" align="start">
|
|
170
168
|
<label htmlFor="title">Title</label>
|
|
171
169
|
<Input id="title" />
|
|
@@ -213,8 +211,7 @@ Wrap each record in a group so its fields belong to that record.
|
|
|
213
211
|
```tsx
|
|
214
212
|
import { PresenceGroup, PresenceFrame } from 'moi/collab'
|
|
215
213
|
import { Input } from '../ui/input'
|
|
216
|
-
|
|
217
|
-
<PresenceGroup id={task.id}>
|
|
214
|
+
;<PresenceGroup id={task.id}>
|
|
218
215
|
<PresenceFrame id="title">
|
|
219
216
|
<Input aria-label="Task title" defaultValue={task.title} />
|
|
220
217
|
</PresenceFrame>
|
|
@@ -237,8 +234,7 @@ its avatar glides from the previous target to the next.
|
|
|
237
234
|
```tsx
|
|
238
235
|
import { PresenceGroup, PresenceAvatars } from 'moi/collab'
|
|
239
236
|
import { Input } from '../ui/input'
|
|
240
|
-
|
|
241
|
-
<PresenceGroup id="tasks">
|
|
237
|
+
;<PresenceGroup id="tasks">
|
|
242
238
|
{tasks.map(task => (
|
|
243
239
|
<PresenceAvatars key={task.id} id={task.id}>
|
|
244
240
|
<Input aria-label={task.title} defaultValue={task.title} />
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
# Moi applet design
|
|
2
|
+
|
|
3
|
+
Applets should feel useful, clear, and at home in the workspace.
|
|
4
|
+
|
|
5
|
+
This guide is the highest-priority visual contract for widgets and views inside a Moi workspace. Follow generic design guidance only where it agrees with this guide.
|
|
6
|
+
|
|
7
|
+
## Design principles
|
|
8
|
+
|
|
9
|
+
### Focus on the task
|
|
10
|
+
|
|
11
|
+
Decide what people need to understand and do before choosing how the screen should look. Include only the information and controls that serve that task. Relevant source context can inform the work without becoming a field, section, or feature. Available space is not a reason to add content. A sparse screen can be complete.
|
|
12
|
+
|
|
13
|
+
Lead with what people came for and make the next action obvious. Individually useful elements can still compete or repeat one another, so consolidate related information and give supporting content less emphasis.
|
|
14
|
+
|
|
15
|
+
### Start with one useful workflow
|
|
16
|
+
|
|
17
|
+
For a new view, build the smallest complete workflow that helps the user do something useful. Include what that workflow needs to work end to end. Add secondary workflows, configuration, reporting, and extra ways to organize things as the user asks for them.
|
|
18
|
+
|
|
19
|
+
### Use progressive disclosure
|
|
20
|
+
|
|
21
|
+
Keep essential information and frequent actions visible. Reveal supporting details when the user selects an item or chooses a clearly named action, and show editing controls when they choose to edit. Keep those entry points easy to find and preserve context when opening and closing details. Don't hide the main task behind clicks or build speculative features just to tuck them into accordions.
|
|
22
|
+
|
|
23
|
+
### Give expression a purpose
|
|
24
|
+
|
|
25
|
+
Use typography, composition, color, imagery, texture, or a small content-linked metaphor to give the applet character. A visual detail may support the subject or mood without carrying data or enabling an action. Keep the treatment focused so the content remains easy to scan.
|
|
26
|
+
|
|
27
|
+
## Layout
|
|
28
|
+
|
|
29
|
+
**Group through spacing and alignment.** Start with an open layout. Add a divider only when adjacent regions need a visible boundary. Use surfaces only for interactive objects, independent scrolling regions, distinct states, or a dedicated work area. Keep ordinary headings, tabs, summaries, metrics, and sections unboxed. Avoid large rounded page frames and nested cards.
|
|
30
|
+
|
|
31
|
+
**Keep a consistent rhythm.** Use a 4 px spacing rhythm, with smaller gaps inside groups and larger gaps between them. Apply outer padding once. Align repeated values and actions so content changes do not move them around. When removing a container, remove its unnecessary padding and radius and realign its contents.
|
|
32
|
+
|
|
33
|
+
**Size to the content.** Use natural height for simple tasks and extra space for tables, boards, canvases, and other work areas that benefit from it. Don't stretch content to fill the frame. Adapt to narrow widths, long content, and chat sharing the workspace.
|
|
34
|
+
|
|
35
|
+
## Shared system
|
|
36
|
+
|
|
37
|
+
### Typography
|
|
38
|
+
|
|
39
|
+
**Use a small, consistent set of styles.** Establish clear roles for headings, ordinary content, and supporting information. Text with the same role and importance shares the same typography.
|
|
40
|
+
|
|
41
|
+
Inherit the workspace font. Use regular weight for most text and medium for emphasis, including focal prompts or values when weight helps establish hierarchy. Reserve other weights for explicit user customization.
|
|
42
|
+
|
|
43
|
+
**Choose readable defaults.** Use `text-sm` for controls and general UI, and `text-base` for focused content when space allows. Sizes below `text-sm` should be rare, limited to unusually tight controls. Use larger text for headings or a focal value.
|
|
44
|
+
|
|
45
|
+
Reserve `font-mono` for code, commands, and code-like identifiers. Numeric values, measurements, percentages, timers, timestamps, prices, counts, labels, keyboard shortcuts, and key names use the workspace font. Add `tabular-nums` when stable widths or alignment help.
|
|
46
|
+
|
|
47
|
+
### Controls
|
|
48
|
+
|
|
49
|
+
Use [bundled components](UI-COMPONENTS.md) with their existing variants, sizes, and shapes. Controls with the same role and importance share component variants. Keep feedback near the action that caused it.
|
|
50
|
+
|
|
51
|
+
### Icons
|
|
52
|
+
|
|
53
|
+
Use Tabler icons when they clarify meaning, identify a familiar action, or reinforce a focused visual metaphor. Avoid adding an icon to every label or control. Set stroke explicitly: `1.75` at 12–16 px and `1.5` at 20–24 px. Let components control icon size when provided.
|
|
54
|
+
|
|
55
|
+
### Color and surfaces
|
|
56
|
+
|
|
57
|
+
Use semantic tokens and their matching foregrounds. The default root is `h-full w-full bg-background text-foreground`.
|
|
58
|
+
|
|
59
|
+
For widgets, the host sets the `background` token to the workspace’s `primary`, supplies a readable `foreground`, and derives a light local `primary` action surface. The host wrapper is transparent: each widget must paint its own opaque root, normally with `bg-background`, or provide an opaque fallback behind full-bleed media. Views inherit the page theme.
|
|
60
|
+
|
|
61
|
+
| Intent | Classes |
|
|
62
|
+
| ------------------ | ------------------------------------------------------------------------------------------------------------------ |
|
|
63
|
+
| Main content | `text-foreground` |
|
|
64
|
+
| Supporting content | `text-muted-foreground` |
|
|
65
|
+
| Inset surface | `bg-card text-card-foreground` |
|
|
66
|
+
| Quiet fill | `bg-muted` for inset regions, skeletons, and disabled structure |
|
|
67
|
+
| Control state | `bg-accent text-accent-foreground` for hover, active, and selected controls |
|
|
68
|
+
| Main action | `bg-primary text-primary-foreground hover:bg-primary/90` |
|
|
69
|
+
| State | `text-success`, `bg-success/10`, `text-destructive`, or `bg-destructive/10` in views; `text-foreground` in widgets |
|
|
70
|
+
| Object edge | `ring-1 ring-border` for complete container and control outlines |
|
|
71
|
+
| Separator | A one-sided border such as `border-b border-border`, never doubled with a ring |
|
|
72
|
+
| Focus | `focus-visible:ring-2 focus-visible:ring-ring` |
|
|
73
|
+
| Floating content | `bg-popover text-popover-foreground` for menus, tooltips, and popovers inside the applet scope |
|
|
74
|
+
|
|
75
|
+
Keep every text level comfortably readable and don't let muted text dominate the screen. Communicate meaning through wording, symbols, or shapes as well as color.
|
|
76
|
+
|
|
77
|
+
Use additional colors for meaningful data, imagery, brands, a content-linked visual accent, or an explicit user preference. Keep data mappings consistent and understandable. Derive custom tonal treatments from local tokens.
|
|
78
|
+
|
|
79
|
+
Use the shared radius scale and existing control shapes. Reserve `rounded-full` for pills, circles, avatars, and status dots; do not turn rectangular controls into capsules.
|
|
80
|
+
|
|
81
|
+
### Texture
|
|
82
|
+
|
|
83
|
+
Texture is optional, limited to the root, and backed by an opaque semantic color: `texture-checker`, `texture-grid`, `texture-noise`, `texture-gradient-linear`, or `texture-inset-shadow`.
|
|
84
|
+
|
|
85
|
+
Behind dense content, use plain `bg-background`, `texture-gradient-linear`, or `texture-inset-shadow`; checker, grid, and noise may only surround an opaque work area. Never stack or tune textures, or put them behind full-bleed media. Coordinate related widgets and views.
|
|
86
|
+
|
|
87
|
+
### Interaction and states
|
|
88
|
+
|
|
89
|
+
**Make every action usable.** Controls need clear names, comfortable targets, keyboard support, and visible focus. Charts need understandable labels or equivalent information.
|
|
90
|
+
|
|
91
|
+
**Show the states the applet can reach.**
|
|
92
|
+
|
|
93
|
+
- **Loading:** preserve the expected content shape with a skeleton; use spinners for compact or shapeless work.
|
|
94
|
+
- **Empty:** explain the absence and offer a relevant next step when one exists.
|
|
95
|
+
- **Error:** explain the problem plainly and provide recovery.
|
|
96
|
+
- **Refreshing:** keep existing content visible and show progress near the refresh action.
|
|
97
|
+
- **Stale:** identify outdated information near the affected content.
|
|
98
|
+
- **Disabled:** keep the control recognizable and make its unavailability understandable.
|
|
99
|
+
|
|
100
|
+
Keep the main work surface in the same position and size as states change. Feedback must fit the applet’s available space.
|
|
101
|
+
|
|
102
|
+
Use brief, interruptible motion to explain changes or acknowledge input. Respect reduced motion, avoid looping decoration and animation on frequently changing numbers, and make audio and video user-initiated.
|
|
103
|
+
|
|
104
|
+
## Widgets
|
|
105
|
+
|
|
106
|
+
**Widgets support a quick glance or immediate action.** Choose the smallest footprint that presents the content clearly. Keep the main information prominent and supporting controls limited to the immediate task. Put tabs, deeper navigation, and multi-step work in a view. Keep hover feedback on controls; leave the widget surface unchanged.
|
|
107
|
+
|
|
108
|
+
The host owns the widget’s outer shape, clipping, and elevation. Do not add another outer card.
|
|
109
|
+
|
|
110
|
+
The grid has four columns, 160 px rows, 8 px gaps, and a maximum width of 640 px. Widgets span one to four rows and columns. Width is flexible; height is fixed:
|
|
111
|
+
|
|
112
|
+
`rowSpan × 160 + (rowSpan − 1) × 8`
|
|
113
|
+
|
|
114
|
+
Fit content and reachable states within that height without accidental scrolling or clipped controls.
|
|
115
|
+
|
|
116
|
+
## Views
|
|
117
|
+
|
|
118
|
+
**Views support sustained work.** Each view represents one screen and owns its layout, padding, and scrolling. Establish clear context, a primary work area, and relevant actions. A title is useful when the content does not already establish context.
|
|
119
|
+
|
|
120
|
+
Prefer one main scroller. When everything fits comfortably, keep essential information and actions within one viewport. Avoid horizontal page scrolling; wide content may scroll within its own bounded region. Add bounded internal scrolling only when independent scroll positions help the task.
|
|
121
|
+
|
|
122
|
+
Internal tabs, filters, and master-detail layouts may organize the current task. Cross-screen navigation belongs to the workspace; do not add a client-side router.
|
|
123
|
+
|
|
124
|
+
## UI copy
|
|
125
|
+
|
|
126
|
+
Write from the end user's perspective. Name things in simple language people understand, not by how the system is built. Describe what something is or does in plain terms rather than selling it. Prefer specific, clear wording over clever wording.
|
|
127
|
+
|
|
128
|
+
Use active voice by default. An action says exactly what will happen: "Save changes," not "Submit." Keep the same action name through the whole flow, so a button labeled "Publish" produces a confirmation that says "Published."
|
|
129
|
+
|
|
130
|
+
For failure and empty states, follow [Interaction and states](#interaction-and-states). Keep the wording specific and use the interface's voice. Errors do not apologize.
|
|
131
|
+
|
|
132
|
+
Use plain verbs, sentence case, and no filler. Let each written element do exactly one job. Omit terminal periods in headings, labels, metadata, and short standalone UI lines. Use sentence punctuation for paragraphs or multiple complete sentences.
|
|
133
|
+
|
|
134
|
+
## Design slop
|
|
135
|
+
|
|
136
|
+
Design slop is a repeated visual shortcut that makes an interface feel generic or agent-made. Avoid decorative patterns added by habit instead of because they suit the content.
|
|
137
|
+
|
|
138
|
+
- **Decorative accent lines:** Do not place short colored lines, partial borders, or a single colored edge beside headings, prompts, or values as generic decoration. Choose a visual treatment connected to the content, or leave the area open.
|
|
139
|
+
- **SaaS card kit:** Use repeated cards when they represent a real repeated unit, such as comparable metrics, records, or actions. Avoid turning unrelated sections into identical rounded containers with the same radius, border, and shadow.
|
|
140
|
+
- **Template chrome:** Avoid stock decoration: all-caps eyebrows, middle-dot metadata, `LABEL — fragment` headings, monospace labels, and arrows on every action. Use these patterns only when they clarify hierarchy, state, or sequence.
|
|
141
|
+
|
|
142
|
+
## Final check
|
|
143
|
+
|
|
144
|
+
- **First use:** Can someone tell what the screen is for and complete its main workflow? Check what they notice first and what they can do next.
|
|
145
|
+
- **Subtract:** Temporarily remove secondary groups, helper copy, badges, icons, and wrappers. Restore only what the task, a decision, a state, or recovery needs. Preserve accessible labels.
|
|
146
|
+
- **Deduplicate:** When two elements communicate the same thing, keep the clearer one closest to the relevant action.
|
|
147
|
+
- **Contrast:** Check that emphasis levels are clear and the screen does not feel washed out.
|
|
148
|
+
- **Verify:** Check realistic content, narrow widths, reachable states, keyboard use, and unintended scrolling. For widgets, also check how the result sits beside other applets.
|
|
@@ -54,6 +54,6 @@ moi scratch clear
|
|
|
54
54
|
"marked / selected / special" without going fully opaque.
|
|
55
55
|
- `solid` — fully opaque fill in the color (interior matches the outline). Use for solid blocks,
|
|
56
56
|
legend keys, or a label chip; anything behind it is hidden.
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
A rect's outline is always a rough (hand-drawn) stroke, matching what the toolbar draws. Default
|
|
58
|
+
fill is `semi`; pass `--fill none` for an outline-only box or `--fill solid` for an opaque block.
|
|
59
59
|
- Coordinates are tldraw canvas space (origin top-left, y down).
|
|
@@ -55,6 +55,9 @@ element, also pass `nativeButton={false}`.
|
|
|
55
55
|
Use the installed portal and stacking behavior; don't add a second portal or z-index overrides.
|
|
56
56
|
`applet-portal.tsx` preserves applet styles for portalled content. Never edit or remove it.
|
|
57
57
|
|
|
58
|
+
A custom overlay must use the closest `[data-applet]` root to keep applet scope and theme. Give
|
|
59
|
+
it a minimal z-index only when document order and a scoped portal cannot resolve the overlap.
|
|
60
|
+
|
|
58
61
|
## Styling and icons
|
|
59
62
|
|
|
60
63
|
- Use semantic theme tokens and built-in variants. Reserve `className` for layout;
|
package/ui-components/badge.tsx
CHANGED
|
@@ -4,7 +4,7 @@ import { cva, type VariantProps } from 'class-variance-authority'
|
|
|
4
4
|
import { cn } from './utils'
|
|
5
5
|
|
|
6
6
|
const badgeVariants = cva(
|
|
7
|
-
'group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-sm border border-transparent px-1.5 py-0.5 text-xs font-medium whitespace-nowrap transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3
|
|
7
|
+
'group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-sm border border-transparent px-1.5 py-0.5 text-xs font-medium whitespace-nowrap transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg:not([class*=size-])]:size-3',
|
|
8
8
|
{
|
|
9
9
|
variants: {
|
|
10
10
|
variant: {
|