moi-computer 0.12.0 → 0.12.1-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/client/AGENTS.md +2 -2
- package/client/api/app-ui-keys.ts +1 -1
- package/client/api/workspace-keys.ts +1 -3
- package/client/app/routes/WorkspaceRoute.tsx +2 -8
- package/client/features/applets/applet-runtime.ts +11 -13
- package/client/features/chat/ChatPanel.tsx +70 -49
- package/client/features/chat/ChatPopup.tsx +81 -8
- package/client/features/chat/applet-chat-intents.ts +31 -12
- package/client/features/chat/chat-send.ts +33 -1
- package/client/features/chat/chat-store.ts +10 -0
- package/client/features/chat/composer/ChatComposer.tsx +24 -27
- package/client/features/chat/composer/ModelPicker.tsx +3 -3
- package/client/features/chat/composer/useWorkspaceComposerState.tsx +3 -3
- package/client/features/chat/connection/chat-frames.ts +14 -7
- package/client/features/chat/messages/ChatEmptyState.tsx +33 -19
- package/client/features/chat/messages/MarkdownContent.tsx +3 -3
- package/client/features/chat/messages/fork-history.ts +14 -0
- package/client/features/chat/sessions/ChatSelector.tsx +138 -79
- package/client/features/chat/sessions/api.ts +109 -19
- package/client/features/chat/sessions/browser-tab-state.ts +30 -7
- package/client/features/chat/sessions/useSelectedSession.ts +217 -51
- package/client/features/chat/useChat.ts +43 -45
- package/client/features/collab/client.ts +10 -11
- package/client/features/collab/hooks.tsx +6 -11
- package/client/features/collab/host-state.ts +57 -128
- package/client/features/collab/provider.tsx +3 -3
- package/client/features/collab/testing/fake-engine.ts +6 -27
- package/client/features/collab/workspace-users-menu.tsx +3 -7
- package/client/features/drawings/{useViewBuilderSketch.ts → useViewSketch.ts} +7 -7
- package/client/features/home/HomePage.tsx +2 -2
- package/client/features/overview/Overview.tsx +3 -6
- package/client/features/overview/default/ViewsWidget.tsx +5 -12
- package/client/features/overview/default/registry.tsx +2 -4
- package/client/features/views/PendingViewScreen.tsx +279 -0
- package/client/features/views/ViewManager.tsx +10 -10
- package/client/features/views/api.ts +63 -130
- package/client/features/views/useViewActions.ts +151 -0
- package/client/features/views/useViewDrafts.ts +79 -0
- package/client/features/views/view-presentation.ts +4 -5
- package/client/features/views/view-submission.ts +88 -0
- package/client/features/workspace/WorkspaceMenu.tsx +63 -0
- package/client/features/workspace/WorkspaceScreen.tsx +180 -375
- package/client/features/workspace/browser-tab-state.ts +16 -9
- package/client/features/workspace/moi-context.ts +13 -15
- package/client/features/workspace/tab-resolution.ts +16 -29
- package/client/features/workspace/useWorkspaceNavigation.ts +146 -104
- package/client/index.tsx +5 -1
- package/client/runtime/useWorkspaceEvents.ts +7 -6
- package/client/store/ui.ts +25 -29
- package/dist/chunk-1zhnhy00.js +1 -0
- package/dist/chunk-27501vke.js +1 -0
- package/dist/{chunk-jf6czgrz.js → chunk-9xtv6djt.js} +2 -2
- package/dist/chunk-am1x230f.js +2 -0
- package/dist/{chunk-nez8sdta.js → chunk-darpsw65.js} +1 -1
- package/dist/{chunk-97eg9mjn.js → chunk-gps4qc38.js} +1 -1
- package/dist/{chunk-3a48fyf7.js → chunk-hzwr8dp8.js} +4 -4
- package/dist/{chunk-efdyz6xp.js → chunk-j905va8r.js} +1 -1
- package/dist/chunk-n33w9y38.js +10 -0
- package/dist/chunk-r63ks44z.js +68 -0
- package/dist/{chunk-vfpsc75k.js → chunk-vqpkqtdr.js} +1 -1
- package/dist/chunk-wd46nk26.css +1 -0
- package/dist/chunk-xgt7vxt9.js +1 -0
- package/dist/{chunk-z3byfve5.js → chunk-yvzhwtfa.js} +2 -2
- package/dist/index.html +1 -1
- package/lib/ids.ts +2 -5
- package/lib/moi-context.ts +100 -73
- package/lib/navigation.ts +48 -87
- package/lib/session-drafts.ts +10 -0
- package/lib/types.ts +64 -31
- package/lib/view-build-directives.ts +12 -0
- package/lib/workspace-layout.ts +1 -1
- package/lib/workspace-tabs.ts +12 -7
- package/package.json +3 -1
- package/server/agent-launcher.ts +27 -0
- package/server/api.ts +119 -209
- package/server/app-config.ts +21 -2
- package/server/applets/build-worker.ts +2 -1
- package/server/applets/view-source.ts +7 -1
- package/server/cli-env.ts +72 -50
- package/server/cli.ts +101 -64
- package/server/control.ts +82 -63
- package/server/data-dir.ts +13 -0
- package/server/functions.ts +2 -1
- package/server/harness/README.md +8 -0
- package/server/harness/acp/adapter.ts +2 -2
- package/server/harness/acp/client.ts +2 -1
- package/server/harness/acp/discovery.ts +3 -3
- package/server/harness/acp/session.ts +6 -9
- package/server/harness/claude-code/adapter.ts +13 -8
- package/server/harness/claude-code/auth.ts +3 -2
- package/server/harness/claude-code/cli.ts +3 -1
- package/server/harness/claude-code/git-worktree.ts +5 -2
- package/server/harness/claude-code/index.ts +5 -0
- package/server/harness/claude-code/mcp.ts +2 -0
- package/server/harness/claude-code/models.ts +2 -0
- package/server/harness/claude-code/session.ts +5 -34
- package/server/harness/claude-code/sessions.ts +8 -12
- package/server/harness/codex/NOTES.md +23 -4
- package/server/harness/codex/adapter.ts +5 -3
- package/server/harness/codex/client.ts +13 -21
- package/server/harness/codex/index.ts +18 -0
- package/server/harness/codex/session.ts +6 -14
- package/server/harness/codex/thread-list.ts +74 -0
- package/server/harness/fork.ts +12 -0
- package/server/harness/openclaw/adapter.ts +3 -3
- package/server/harness/openclaw/session.ts +2 -30
- package/server/harness/session-title.ts +12 -3
- package/server/harness/types.ts +8 -3
- package/server/moi-scaffold.ts +2 -1
- package/server/pending-views.ts +164 -0
- package/server/registry.ts +14 -4
- package/server/selected-session.ts +91 -44
- package/server/service.ts +16 -2
- package/server/session-archive.ts +32 -0
- package/server/session-config.ts +16 -111
- package/server/session-lifecycle.ts +17 -0
- package/server/session-store.ts +127 -0
- package/server/status.ts +3 -1
- package/server/tabs.ts +7 -10
- package/server/view-sessions.ts +267 -0
- package/server/views.ts +30 -41
- package/server/web.ts +47 -45
- package/server/workspace-env.ts +27 -0
- package/server/workspace-init.ts +6 -2
- package/workspace/.claude/skills/moi-workspace/SKILL.md +49 -20
- package/workspace/.claude/skills/moi-workspace/references/COLLAB.md +2 -5
- package/client/features/views/ViewBuilder.tsx +0 -239
- package/client/features/views/useViewBuilderActions.ts +0 -103
- package/client/features/views/useViewBuilderDrafts.ts +0 -68
- package/dist/chunk-2jncyq65.js +0 -1
- package/dist/chunk-e2q5ken7.js +0 -68
- package/dist/chunk-h2kj1ysj.js +0 -1
- package/dist/chunk-nzwgm8vc.css +0 -1
- package/dist/chunk-ph0h6h86.js +0 -1
- package/dist/chunk-ryg9z3kn.js +0 -10
- package/dist/chunk-tpn177bt.js +0 -2
- package/lib/view-builder-directives.ts +0 -16
- package/server/chat-selection.ts +0 -22
- package/server/view-builders.ts +0 -453
|
@@ -4,34 +4,37 @@ import type { AuthProvider, ProxyUserState, UserProfile } from '@/lib/collab/typ
|
|
|
4
4
|
import { createLocalUser } from './local-user'
|
|
5
5
|
|
|
6
6
|
export type UserProfileInput = Omit<UserProfile, 'color'> & { color?: UserProfile['color'] }
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
readonly
|
|
12
|
-
readonly workspaces: Readonly<Record<string, WorkspaceDirectory<Profile>>>
|
|
13
|
-
}
|
|
14
|
-
export type HostStateInput = State<UserProfileInput>
|
|
15
|
-
export type HostState = State<UserProfile>
|
|
16
|
-
export type HostApi = {
|
|
17
|
-
getHostState: () => HostState | undefined
|
|
18
|
-
setHostState: (state: HostStateInput) => void
|
|
19
|
-
subscribeHostState: (listener: (state: HostState | undefined) => void) => () => void
|
|
7
|
+
// What an outer host publishes: the viewer's id and everyone moi may show.
|
|
8
|
+
// `me` must be listed in `users`; leave it out when nobody is signed in.
|
|
9
|
+
export type HostUsers = {
|
|
10
|
+
me?: string | null
|
|
11
|
+
users: readonly UserProfileInput[]
|
|
20
12
|
}
|
|
13
|
+
// `window.moi.collab`. An outer host calls it from a module script placed after
|
|
14
|
+
// moi's bundle, once at startup and again whenever a user or the viewer changes.
|
|
15
|
+
// A classic inline script runs before the bundle and finds nothing here.
|
|
16
|
+
//
|
|
17
|
+
// window.moi.collab.publishUsers({ me: 'alex', users: [{ id: 'alex', name: 'Alex' }] })
|
|
18
|
+
export type HostApi = { publishUsers: (next: HostUsers) => void }
|
|
21
19
|
// Who supplies the current user: local setup, an outer host, or an auth proxy.
|
|
22
20
|
export type CurrentUserSource = 'local' | 'external' | AuthProvider
|
|
23
21
|
|
|
24
22
|
// Keep the existing key so local profiles survive the startup change.
|
|
25
23
|
const PROFILE_KEY = 'moi:collab:dev-profile'
|
|
24
|
+
const NO_USERS: readonly UserProfile[] = Object.freeze([])
|
|
26
25
|
let currentUser: UserProfile | undefined
|
|
27
|
-
let installed = false
|
|
28
26
|
let currentUserSource: CurrentUserSource | undefined
|
|
27
|
+
// One list for the whole app. Undefined until a host publishes; from then on it
|
|
28
|
+
// is authoritative, including when it is empty.
|
|
29
|
+
let directory: readonly UserProfile[] | undefined
|
|
30
|
+
let installed = false
|
|
29
31
|
const listeners = new Set<() => void>()
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
const directoryListeners = new Set<() => void>()
|
|
33
|
+
|
|
34
|
+
// Normalized profiles list their fields in one order, so text equality is exact.
|
|
35
|
+
function sameProfile(a: UserProfile | undefined, b: UserProfile | undefined): boolean {
|
|
36
|
+
return JSON.stringify(a) === JSON.stringify(b)
|
|
37
|
+
}
|
|
35
38
|
|
|
36
39
|
export function normalizeUserProfile(value: UserProfileInput): UserProfile {
|
|
37
40
|
if (!value || typeof value.id !== 'string' || !value.id.trim())
|
|
@@ -53,100 +56,51 @@ export function normalizeUserProfile(value: UserProfileInput): UserProfile {
|
|
|
53
56
|
return Object.freeze(normalized)
|
|
54
57
|
}
|
|
55
58
|
|
|
56
|
-
export function
|
|
57
|
-
users
|
|
58
|
-
): readonly UserProfile[] {
|
|
59
|
-
if (!Array.isArray(users)) throw new Error('Workspace users must be an array.')
|
|
59
|
+
export function normalizeUsers(users: readonly UserProfileInput[]): readonly UserProfile[] {
|
|
60
|
+
if (!Array.isArray(users)) throw new Error('Users must be an array.')
|
|
60
61
|
const ids = new Set<string>()
|
|
61
62
|
const snapshot = users.map(user => {
|
|
62
63
|
const normalized = normalizeUserProfile(user)
|
|
63
|
-
if (ids.has(normalized.id)) throw new Error('
|
|
64
|
+
if (ids.has(normalized.id)) throw new Error('Users must have unique ids.')
|
|
64
65
|
ids.add(normalized.id)
|
|
65
66
|
return normalized
|
|
66
67
|
})
|
|
67
68
|
return Object.freeze(snapshot)
|
|
68
69
|
}
|
|
69
70
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
if (!
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
return [id, Object.freeze({ status: 'ready' as const, users })] as const
|
|
87
|
-
})
|
|
88
|
-
// Validate everything before discarding directories on sign-out.
|
|
89
|
-
return Object.freeze({
|
|
90
|
-
currentUser: current,
|
|
91
|
-
workspaces: current ? Object.freeze(Object.fromEntries(entries)) : EMPTY_WORKSPACES
|
|
92
|
-
})
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
export function getHostState(): HostState | undefined {
|
|
96
|
-
return hostState
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
export function getWorkspaceDirectory(workspaceId: string): WorkspaceDirectory | undefined {
|
|
100
|
-
if (!hostState) return undefined
|
|
101
|
-
const directory = Object.hasOwn(hostState.workspaces, workspaceId)
|
|
102
|
-
? hostState.workspaces[workspaceId]
|
|
103
|
-
: undefined
|
|
104
|
-
return directory ?? LOADING_DIRECTORY
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
export function setHostState(next: HostStateInput): void {
|
|
108
|
-
const normalized = normalizeHostState(next)
|
|
109
|
-
const previousDirectories = new Map(
|
|
110
|
-
[...workspaceListeners.keys()].map(id => [id, getWorkspaceDirectory(id)])
|
|
111
|
-
)
|
|
71
|
+
// Replaces the viewer and the whole directory in one step. The host sends the
|
|
72
|
+
// full list every time, so a removal is simply an id that is no longer there.
|
|
73
|
+
// Invalid input throws and publishes nothing.
|
|
74
|
+
export function publishUsers(next: HostUsers): void {
|
|
75
|
+
if (!next || typeof next !== 'object') throw new Error('Users must be published as an object.')
|
|
76
|
+
const users = normalizeUsers(next.users)
|
|
77
|
+
let user: UserProfile | undefined
|
|
78
|
+
if (next.me !== undefined && next.me !== null) {
|
|
79
|
+
if (typeof next.me !== 'string') throw new Error('The current user id must be a string.')
|
|
80
|
+
const id = next.me.trim()
|
|
81
|
+
user = users.find(candidate => candidate.id === id)
|
|
82
|
+
if (!user) throw new Error('The current user must be listed in users.')
|
|
83
|
+
}
|
|
84
|
+
// An unchanged viewer keeps its profile object and stays quiet: every notice
|
|
85
|
+
// makes each open workspace resend that profile to its room.
|
|
86
|
+
const changed = currentUserSource !== 'external' || !sameProfile(currentUser, user)
|
|
112
87
|
// Publish every field before notifying any observer, including transport listeners.
|
|
113
|
-
hostState = normalized
|
|
114
88
|
currentUserSource = 'external'
|
|
115
|
-
currentUser =
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
}
|
|
121
|
-
hostListeners.forEach(listener => listener())
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
export function subscribeHostStateStore(listener: () => void): () => void {
|
|
125
|
-
hostListeners.add(listener)
|
|
126
|
-
return () => {
|
|
127
|
-
hostListeners.delete(listener)
|
|
128
|
-
}
|
|
89
|
+
if (changed) currentUser = user
|
|
90
|
+
// A signed-out viewer sees no one, whatever the host still lists.
|
|
91
|
+
directory = user ? users : NO_USERS
|
|
92
|
+
if (changed) listeners.forEach(listener => listener())
|
|
93
|
+
directoryListeners.forEach(listener => listener())
|
|
129
94
|
}
|
|
130
95
|
|
|
131
|
-
export function
|
|
132
|
-
|
|
133
|
-
listener(getHostState())
|
|
134
|
-
return unsubscribe
|
|
96
|
+
export function getDirectory(): readonly UserProfile[] | undefined {
|
|
97
|
+
return directory
|
|
135
98
|
}
|
|
136
99
|
|
|
137
|
-
export function
|
|
138
|
-
|
|
139
|
-
listener: () => void
|
|
140
|
-
): () => void {
|
|
141
|
-
let subscriptions = workspaceListeners.get(workspaceId)
|
|
142
|
-
if (!subscriptions) {
|
|
143
|
-
subscriptions = new Set()
|
|
144
|
-
workspaceListeners.set(workspaceId, subscriptions)
|
|
145
|
-
}
|
|
146
|
-
subscriptions.add(listener)
|
|
100
|
+
export function subscribeDirectoryStore(listener: () => void): () => void {
|
|
101
|
+
directoryListeners.add(listener)
|
|
147
102
|
return () => {
|
|
148
|
-
|
|
149
|
-
if (!subscriptions.size) workspaceListeners.delete(workspaceId)
|
|
103
|
+
directoryListeners.delete(listener)
|
|
150
104
|
}
|
|
151
105
|
}
|
|
152
106
|
|
|
@@ -175,11 +129,7 @@ export function setProxyUserState({ provider, profile }: ProxyUserState): void {
|
|
|
175
129
|
currentUser = undefined
|
|
176
130
|
} else {
|
|
177
131
|
const normalized = profile === undefined ? undefined : normalizeUserProfile(profile)
|
|
178
|
-
if (
|
|
179
|
-
currentUserSource === provider &&
|
|
180
|
-
JSON.stringify(currentUser) === JSON.stringify(normalized)
|
|
181
|
-
)
|
|
182
|
-
return
|
|
132
|
+
if (currentUserSource === provider && sameProfile(currentUser, normalized)) return
|
|
183
133
|
currentUserSource = provider
|
|
184
134
|
currentUser = normalized
|
|
185
135
|
}
|
|
@@ -205,6 +155,7 @@ export function setLocalUser(next: UserProfile): void {
|
|
|
205
155
|
}
|
|
206
156
|
|
|
207
157
|
// Called after startup config and proxy identity settle, before React mounts.
|
|
158
|
+
// A host that has already published keeps the viewer it chose, signed in or not.
|
|
208
159
|
export function initializeLocalUser(enabled: boolean, proxyUser: ProxyUserState | undefined): void {
|
|
209
160
|
if (!enabled || !proxyUser || proxyUser.provider !== undefined || currentUserSource !== undefined)
|
|
210
161
|
return
|
|
@@ -220,35 +171,13 @@ export function initializeLocalUser(enabled: boolean, proxyUser: ProxyUserState
|
|
|
220
171
|
setLocalUser(createLocalUser())
|
|
221
172
|
}
|
|
222
173
|
|
|
223
|
-
//
|
|
174
|
+
// Runs while moi's bundle evaluates, so a host script placed after the bundle
|
|
175
|
+
// finds `publishUsers` at once and can publish before the app mounts.
|
|
224
176
|
export function installHostApi(): void {
|
|
225
177
|
if (typeof window === 'undefined' || installed) return
|
|
226
178
|
installed = true
|
|
227
|
-
const host = window as Window & {
|
|
228
|
-
moi?: {
|
|
229
|
-
collab?: {
|
|
230
|
-
getHostState?: () => HostStateInput | undefined
|
|
231
|
-
}
|
|
232
|
-
[key: string]: unknown
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
const previous = host.moi?.collab
|
|
236
|
-
if (previous?.getHostState) {
|
|
237
|
-
try {
|
|
238
|
-
setHostState(previous.getHostState() ?? { workspaces: {} })
|
|
239
|
-
} catch {
|
|
240
|
-
// An unavailable host remains authoritative; never restore a local profile.
|
|
241
|
-
setHostState({ workspaces: {} })
|
|
242
|
-
}
|
|
243
|
-
}
|
|
179
|
+
const host = window as Window & { moi?: { collab?: HostApi; [key: string]: unknown } }
|
|
244
180
|
host.moi ??= {}
|
|
245
|
-
const api: HostApi = {
|
|
246
|
-
getHostState,
|
|
247
|
-
setHostState,
|
|
248
|
-
subscribeHostState
|
|
249
|
-
}
|
|
181
|
+
const api: HostApi = { publishUsers }
|
|
250
182
|
host.moi.collab = api
|
|
251
|
-
if (typeof window.dispatchEvent === 'function') {
|
|
252
|
-
window.dispatchEvent(new CustomEvent('moi:collab-ready'))
|
|
253
|
-
}
|
|
254
183
|
}
|
|
@@ -3,7 +3,7 @@ import type { ReactNode } from 'react'
|
|
|
3
3
|
import { useRouter } from 'wouter'
|
|
4
4
|
import { usePathname } from 'wouter/use-browser-location'
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { tabFromPath } from '@/lib/workspace-tabs'
|
|
7
7
|
|
|
8
8
|
import { CollabClient, NO_ENGINE } from './client'
|
|
9
9
|
import type { CollabEngineApi } from './client'
|
|
@@ -13,9 +13,9 @@ export const CollabContext = createContext<CollabEngineApi>(NO_ENGINE)
|
|
|
13
13
|
const AppletPresenceContext = createContext<AppletPresence | null>(null)
|
|
14
14
|
|
|
15
15
|
export function pageFromPath(path: string, workspaceId: string, base = ''): string {
|
|
16
|
-
const prefix =
|
|
16
|
+
const prefix = `${base.replace(/\/$/, '')}/workspace/${encodeURIComponent(workspaceId)}/`
|
|
17
17
|
const page = path.startsWith(prefix) ? path.slice(prefix.length) : ''
|
|
18
|
-
return tabFromPath(page) ??
|
|
18
|
+
return tabFromPath(page) ?? (page || 'overview')
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
export type CollabProviderProps = {
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type { UserProfile, Connection, PresenceRegistration } from '@/lib/collab/types'
|
|
2
2
|
import { COLLAB_PROTOCOL_VERSION } from '@/lib/collab/protocol'
|
|
3
3
|
import type { CollabEngineApi } from '../client'
|
|
4
|
-
import {
|
|
5
|
-
import type { WorkspaceDirectory } from '../host-state'
|
|
4
|
+
import { normalizeUsers } from '../host-state'
|
|
6
5
|
import { CollabStore } from '../store'
|
|
7
6
|
|
|
8
7
|
export type FakeEngineOptions = {
|
|
@@ -11,32 +10,23 @@ export type FakeEngineOptions = {
|
|
|
11
10
|
otherConnections?: Connection[]
|
|
12
11
|
// Full fixture directory, including users who are offline.
|
|
13
12
|
users?: readonly UserProfile[]
|
|
14
|
-
directoryStatus?: WorkspaceDirectory['status']
|
|
15
13
|
}
|
|
16
14
|
export type FakeEngine = CollabEngineApi & {
|
|
17
15
|
setOtherConnections: (otherConnections: Connection[]) => void
|
|
18
16
|
setUsers: (users: readonly UserProfile[] | undefined) => void
|
|
19
|
-
setDirectoryStatus: (status: WorkspaceDirectory['status'] | undefined) => void
|
|
20
17
|
}
|
|
21
18
|
|
|
22
19
|
export function createFakeEngine({
|
|
23
20
|
self,
|
|
24
21
|
page = 'preview',
|
|
25
22
|
otherConnections = [],
|
|
26
|
-
users
|
|
27
|
-
directoryStatus = users === undefined ? undefined : 'ready'
|
|
23
|
+
users
|
|
28
24
|
}: FakeEngineOptions): FakeEngine {
|
|
29
25
|
const store = new CollabStore()
|
|
30
26
|
const presence = new Map<string, PresenceRegistration>()
|
|
31
27
|
const userListeners = new Set<() => void>()
|
|
32
|
-
|
|
28
|
+
let directory = users === undefined ? undefined : normalizeUsers(users)
|
|
33
29
|
let profiles = directory ?? (self ? [self] : [])
|
|
34
|
-
let directorySnapshot: WorkspaceDirectory | undefined =
|
|
35
|
-
directoryStatus === 'ready'
|
|
36
|
-
? { status: directoryStatus, users: directory ?? [] }
|
|
37
|
-
: directoryStatus === 'loading'
|
|
38
|
-
? { status: directoryStatus }
|
|
39
|
-
: undefined
|
|
40
30
|
let currentOtherConnections = otherConnections
|
|
41
31
|
let location: Connection['location'] = { page, status: 'active' }
|
|
42
32
|
const connections = (): Connection[] => [
|
|
@@ -89,8 +79,8 @@ export function createFakeEngine({
|
|
|
89
79
|
subscribe: store.subscribe,
|
|
90
80
|
getCurrentUser: () => self,
|
|
91
81
|
subscribeCurrentUser: () => () => {},
|
|
92
|
-
|
|
93
|
-
|
|
82
|
+
getDirectory: () => directory,
|
|
83
|
+
subscribeDirectory: listener => {
|
|
94
84
|
userListeners.add(listener)
|
|
95
85
|
return () => {
|
|
96
86
|
userListeners.delete(listener)
|
|
@@ -109,21 +99,10 @@ export function createFakeEngine({
|
|
|
109
99
|
announce()
|
|
110
100
|
},
|
|
111
101
|
setUsers: next => {
|
|
112
|
-
|
|
113
|
-
directorySnapshot =
|
|
114
|
-
directory === undefined ? undefined : { status: 'ready', users: directory }
|
|
102
|
+
directory = next === undefined ? undefined : normalizeUsers(next)
|
|
115
103
|
if (directory) profiles = directory
|
|
116
104
|
userListeners.forEach(listener => listener())
|
|
117
105
|
announce()
|
|
118
|
-
},
|
|
119
|
-
setDirectoryStatus: status => {
|
|
120
|
-
directorySnapshot =
|
|
121
|
-
status === 'ready'
|
|
122
|
-
? { status, users: profiles }
|
|
123
|
-
: status === 'loading'
|
|
124
|
-
? { status }
|
|
125
|
-
: undefined
|
|
126
|
-
userListeners.forEach(listener => listener())
|
|
127
106
|
}
|
|
128
107
|
}
|
|
129
108
|
}
|
|
@@ -14,12 +14,12 @@ import {
|
|
|
14
14
|
} from '@/client/components/ui/popover'
|
|
15
15
|
import { cn } from '@/client/lib/cn'
|
|
16
16
|
import type { WorkspaceTabId } from '@/lib/types'
|
|
17
|
-
import { tabFromPath } from '@/lib/
|
|
17
|
+
import { tabFromPath } from '@/lib/workspace-tabs'
|
|
18
18
|
|
|
19
19
|
import { User } from './components/user'
|
|
20
20
|
import { UserAvatarGroup } from './components/user-avatar-group'
|
|
21
21
|
import { pageFromPath, useCollabEnabled, useCollabEngine } from './provider'
|
|
22
|
-
import { useConnectionState, useWorkspaceUsers
|
|
22
|
+
import { useConnectionState, useWorkspaceUsers } from './hooks'
|
|
23
23
|
import { summarizeWorkspaceUsers } from './users'
|
|
24
24
|
import type { WorkspaceUserInfo } from './users'
|
|
25
25
|
|
|
@@ -42,7 +42,6 @@ export function WorkspaceUsersMenu({
|
|
|
42
42
|
const engine = useCollabEngine()
|
|
43
43
|
const state = useConnectionState()
|
|
44
44
|
const workspaceUsers = useWorkspaceUsers()
|
|
45
|
-
const directory = useWorkspaceDirectory()
|
|
46
45
|
const currentUser = useSyncExternalStore(
|
|
47
46
|
engine.subscribeCurrentUser,
|
|
48
47
|
engine.getCurrentUser,
|
|
@@ -89,10 +88,7 @@ export function WorkspaceUsersMenu({
|
|
|
89
88
|
onOpenTab(tab)
|
|
90
89
|
}}
|
|
91
90
|
/>
|
|
92
|
-
{
|
|
93
|
-
<p className="px-2 py-1 text-xs text-muted-foreground">Loading workspace users…</p>
|
|
94
|
-
)}
|
|
95
|
-
{users.length === 0 && directory?.status !== 'loading' && (
|
|
91
|
+
{users.length === 0 && (
|
|
96
92
|
<p className="px-2 py-1 text-xs text-muted-foreground">No workspace users to show.</p>
|
|
97
93
|
)}
|
|
98
94
|
</PopoverContent>
|
|
@@ -10,9 +10,9 @@ import type { WorkspaceTabId } from '@/lib/types'
|
|
|
10
10
|
|
|
11
11
|
import { useDrawingLayer } from './useDrawingLayer'
|
|
12
12
|
|
|
13
|
-
type
|
|
13
|
+
type UseViewSketchOptions = {
|
|
14
14
|
active: boolean
|
|
15
|
-
|
|
15
|
+
viewId: string
|
|
16
16
|
sessionId: string
|
|
17
17
|
source: WorkspaceTabId
|
|
18
18
|
workspaceId: string
|
|
@@ -20,18 +20,18 @@ type UseViewBuilderSketchOptions = {
|
|
|
20
20
|
onContinueInChat: () => void
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
export type
|
|
23
|
+
export type ViewSketchController = ReturnType<typeof useViewSketch>
|
|
24
24
|
|
|
25
|
-
export function
|
|
25
|
+
export function useViewSketch({
|
|
26
26
|
active,
|
|
27
|
-
|
|
27
|
+
viewId,
|
|
28
28
|
sessionId,
|
|
29
29
|
source,
|
|
30
30
|
workspaceId,
|
|
31
31
|
onEditingStart,
|
|
32
32
|
onContinueInChat
|
|
33
|
-
}:
|
|
34
|
-
const attachmentIdRef = useRef(`sketch:${
|
|
33
|
+
}: UseViewSketchOptions) {
|
|
34
|
+
const attachmentIdRef = useRef(`sketch:${viewId}`)
|
|
35
35
|
const uploadRevisionRef = useRef(0)
|
|
36
36
|
const uploadedBlobRef = useRef<Blob | null>(null)
|
|
37
37
|
const pendingStageRef = useRef<Promise<void> | null>(null)
|
|
@@ -34,7 +34,7 @@ import {
|
|
|
34
34
|
} from '@/client/features/home/workspace-presentation'
|
|
35
35
|
import { resolveWorkspaceTheme } from '@/lib/themes'
|
|
36
36
|
import type { DiscoveredWorkspace, WorkspaceEntry } from '@/lib/types'
|
|
37
|
-
import {
|
|
37
|
+
import { resolveUrl } from '@/lib/navigation'
|
|
38
38
|
|
|
39
39
|
import { WorkspacePreview } from './WorkspacePreview'
|
|
40
40
|
|
|
@@ -198,7 +198,7 @@ function WorkspaceCard({ workspace }: WorkspaceCardProps) {
|
|
|
198
198
|
<TooltipTrigger
|
|
199
199
|
render={
|
|
200
200
|
<Link
|
|
201
|
-
href={
|
|
201
|
+
href={resolveUrl('moi:/chat', { workspaceId: workspace.id })}
|
|
202
202
|
aria-label={`Chat in ${name}`}
|
|
203
203
|
style={getWorkspaceThemeStyle(theme)}
|
|
204
204
|
className="absolute right-3 bottom-3 rounded-lg outline-none focus-visible:ring-3 focus-visible:ring-ring/50"
|
|
@@ -24,7 +24,7 @@ import { WidgetShell } from '@/client/features/applets/WidgetShell'
|
|
|
24
24
|
import { Button } from '@/client/components/ui/button'
|
|
25
25
|
import { cn } from '@/client/lib/cn'
|
|
26
26
|
import { useUiStore } from '@/client/store/ui'
|
|
27
|
-
import type {
|
|
27
|
+
import type { CompiledView, WidgetInfo } from '@/lib/types'
|
|
28
28
|
import { isDefaultWidget } from '@/lib/default-widgets'
|
|
29
29
|
|
|
30
30
|
import { HiddenPanel } from './HiddenPanel'
|
|
@@ -177,8 +177,7 @@ type OverviewProps = {
|
|
|
177
177
|
onCustomizingChange: (customizing: boolean) => void
|
|
178
178
|
// Authoritative widget set from useWidgets; positions come from layout.
|
|
179
179
|
widgets: WidgetInfo[]
|
|
180
|
-
views:
|
|
181
|
-
builders: ViewBuilder[]
|
|
180
|
+
views: CompiledView[]
|
|
182
181
|
}
|
|
183
182
|
|
|
184
183
|
export function Overview({
|
|
@@ -190,8 +189,7 @@ export function Overview({
|
|
|
190
189
|
onThemingChange,
|
|
191
190
|
onCustomizingChange,
|
|
192
191
|
widgets,
|
|
193
|
-
views
|
|
194
|
-
builders
|
|
192
|
+
views
|
|
195
193
|
}: OverviewProps) {
|
|
196
194
|
const { layout, setLayout } = useWorkspaceLayoutCtx()
|
|
197
195
|
const hasSentMessageFromMoi = useUiStore(state => state.hasSentMessageFromMoi)
|
|
@@ -230,7 +228,6 @@ export function Overview({
|
|
|
230
228
|
function renderItem(id: string) {
|
|
231
229
|
const defaultWidget = renderDefaultWidget(id, {
|
|
232
230
|
views,
|
|
233
|
-
builders,
|
|
234
231
|
onOpenView,
|
|
235
232
|
onCreateView,
|
|
236
233
|
showOnboarding
|
|
@@ -33,7 +33,7 @@ import { useDeleteView, useRenameView } from '@/client/features/views/api'
|
|
|
33
33
|
import { getViewIcon, getViewLabel } from '@/client/features/views/view-presentation'
|
|
34
34
|
import { useWorkspaceLayoutCtx } from '@/client/features/workspace/WorkspaceLayoutContext'
|
|
35
35
|
import { cn } from '@/client/lib/cn'
|
|
36
|
-
import type {
|
|
36
|
+
import type { CompiledView } from '@/lib/types'
|
|
37
37
|
|
|
38
38
|
type NewViewButtonProps = {
|
|
39
39
|
outlined: boolean
|
|
@@ -74,7 +74,7 @@ function NewViewButton({ outlined, onClick }: NewViewButtonProps) {
|
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
type ViewItemProps = {
|
|
77
|
-
view:
|
|
77
|
+
view: CompiledView
|
|
78
78
|
Icon: TablerIcon
|
|
79
79
|
onOpen: () => void
|
|
80
80
|
}
|
|
@@ -206,20 +206,13 @@ function ViewItem({ view, Icon, onOpen }: ViewItemProps) {
|
|
|
206
206
|
}
|
|
207
207
|
|
|
208
208
|
type ViewsWidgetProps = {
|
|
209
|
-
views:
|
|
210
|
-
builders: ViewBuilder[]
|
|
209
|
+
views: CompiledView[]
|
|
211
210
|
onOpenView: (viewId: string) => void
|
|
212
211
|
onCreateView: () => void
|
|
213
212
|
showOnboarding: boolean
|
|
214
213
|
}
|
|
215
214
|
|
|
216
|
-
export function ViewsWidget({
|
|
217
|
-
views,
|
|
218
|
-
builders,
|
|
219
|
-
onOpenView,
|
|
220
|
-
onCreateView,
|
|
221
|
-
showOnboarding
|
|
222
|
-
}: ViewsWidgetProps) {
|
|
215
|
+
export function ViewsWidget({ views, onOpenView, onCreateView, showOnboarding }: ViewsWidgetProps) {
|
|
223
216
|
const empty = views.length === 0
|
|
224
217
|
|
|
225
218
|
return (
|
|
@@ -236,7 +229,7 @@ export function ViewsWidget({
|
|
|
236
229
|
<ViewItem
|
|
237
230
|
key={view.id}
|
|
238
231
|
view={view}
|
|
239
|
-
Icon={getViewIcon(view
|
|
232
|
+
Icon={getViewIcon(view)}
|
|
240
233
|
onOpen={() => onOpenView(view.id)}
|
|
241
234
|
/>
|
|
242
235
|
))}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import type { ReactNode } from 'react'
|
|
2
2
|
|
|
3
|
-
import type {
|
|
3
|
+
import type { CompiledView } from '@/lib/types'
|
|
4
4
|
import { DEFAULT_VIEWS_WIDGET, isDefaultWidget, type DefaultWidgetId } from '@/lib/default-widgets'
|
|
5
5
|
|
|
6
6
|
import { ViewsWidget } from './ViewsWidget'
|
|
7
7
|
|
|
8
8
|
export type DefaultWidgetRenderContext = {
|
|
9
|
-
views:
|
|
10
|
-
builders: ViewBuilder[]
|
|
9
|
+
views: CompiledView[]
|
|
11
10
|
onOpenView: (viewId: string) => void
|
|
12
11
|
onCreateView: () => void
|
|
13
12
|
showOnboarding: boolean
|
|
@@ -19,7 +18,6 @@ const DEFAULT_WIDGET_RENDERERS: Record<DefaultWidgetId, DefaultWidgetRenderer> =
|
|
|
19
18
|
[DEFAULT_VIEWS_WIDGET.id]: context => (
|
|
20
19
|
<ViewsWidget
|
|
21
20
|
views={context.views}
|
|
22
|
-
builders={context.builders}
|
|
23
21
|
onOpenView={context.onOpenView}
|
|
24
22
|
onCreateView={context.onCreateView}
|
|
25
23
|
showOnboarding={context.showOnboarding}
|