moi-computer 0.13.1-next.2 → 0.13.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/client/app/app-provider.tsx +14 -20
- package/client/app/app-router.tsx +5 -8
- package/client/app/routes/workspace-route.tsx +28 -11
- package/client/app/shell/sidebar-layout.tsx +5 -10
- package/client/features/app-settings/api.ts +3 -3
- package/client/features/applets/applet-cache.ts +1 -2
- package/client/features/applets/use-applet.ts +18 -20
- package/client/features/chat/chat-store.ts +1 -1
- package/client/features/chat/connection/chat-connection.ts +25 -68
- package/client/features/chat/connection/chat-frames.ts +20 -32
- package/client/features/chat/sessions/api.ts +2 -2
- package/client/features/chat/sessions/use-selected-session.ts +0 -13
- package/client/features/collab/presence/client.ts +63 -83
- package/client/features/collab/presence/provider.tsx +8 -2
- package/client/features/dev/chat-states-page.tsx +1 -1
- package/client/features/dev/harness-debug-page.tsx +2 -2
- package/client/features/scratchpad/scratchpad.tsx +29 -20
- package/client/features/views/api.ts +38 -14
- package/client/features/views/use-view-actions.ts +2 -23
- package/client/features/workspace/api.ts +6 -11
- package/client/features/workspace/harness-transition.ts +3 -5
- package/client/features/workspace/remote.ts +9 -0
- package/client/features/workspace/settings/use-env-vars.ts +4 -4
- package/client/features/workspace/tab-resolution.ts +1 -8
- package/client/features/workspace/use-workspace-navigation.ts +5 -4
- package/client/features/workspace/use-workspace-socket.ts +51 -0
- package/client/features/workspace/workspace-content.tsx +5 -18
- package/client/features/workspace/workspace-layout-context.tsx +6 -13
- package/client/features/workspace/workspace-preferences.ts +67 -10
- package/client/features/workspace/workspace-state.ts +57 -21
- package/client/runtime/app-context.ts +2 -2
- package/client/runtime/app-events.ts +75 -0
- package/client/runtime/reconnecting-socket.ts +115 -0
- package/client/runtime/{use-workspace-events.ts → use-client-events.ts} +9 -10
- package/client/store/ui.ts +1 -6
- package/client/store/workspace-session.ts +30 -0
- package/dist/chunk-0t8m1ehd.js +2 -0
- package/dist/chunk-851bx8ss.js +72 -0
- package/dist/{chunk-n0fawy9x.js → chunk-c8g5x288.js} +1 -1
- package/dist/chunk-cty37f3v.js +1 -0
- package/dist/chunk-dy6f6h3e.js +5 -0
- package/dist/chunk-j6928pwm.js +1 -0
- package/dist/{chunk-rmd0ctfx.js → chunk-k32585ne.js} +73 -73
- package/dist/chunk-qtkv7hp8.js +2 -0
- package/dist/chunk-rh58dc0y.js +2 -0
- package/dist/{chunk-ec5ennpv.js → chunk-wjbejzek.js} +1 -1
- package/dist/index.html +1 -1
- package/lib/events.ts +61 -0
- package/lib/ids.ts +2 -8
- package/lib/moi-context.ts +19 -5
- package/lib/types.ts +16 -20
- package/lib/workspace-layout.ts +3 -20
- package/package.json +2 -1
- package/server/AGENTS.md +4 -4
- package/server/README.md +50 -33
- package/server/api/index.ts +175 -152
- package/server/applets/views.ts +15 -14
- package/server/applets/widgets.ts +4 -3
- package/server/cli/commands/init.ts +7 -2
- package/server/cli/commands/refresh.ts +2 -5
- package/server/cli/commands/remote.ts +128 -26
- package/server/cli/remote-control.ts +12 -9
- package/server/cli/remote-operations.ts +47 -44
- package/server/control.ts +33 -34
- package/server/events.ts +14 -13
- package/server/harness/README.md +7 -7
- package/server/harness/acp/session.ts +9 -5
- package/server/harness/auth.ts +7 -30
- package/server/harness/claude-code/session.ts +8 -4
- package/server/harness/codex/NOTES.md +1 -1
- package/server/harness/codex/session.ts +18 -10
- package/server/harness/hermes/NOTES.md +3 -3
- package/server/harness/openclaw/session.ts +9 -5
- package/server/onboarding/jobs.ts +8 -8
- package/server/operations/commands.ts +1 -1
- package/server/remote/broker-client.ts +76 -0
- package/server/remote/broker.ts +81 -0
- package/server/remote/client.ts +212 -152
- package/server/remote/errors.ts +2 -0
- package/server/remote/routes.ts +121 -0
- package/server/scratchpad/document.ts +3 -2
- package/server/scratchpad/executor.ts +2 -2
- package/server/scratchpad/relay.ts +3 -3
- package/server/sessions/archive.ts +1 -1
- package/server/sessions/lifecycle.ts +1 -1
- package/server/sessions/pending-views.ts +19 -12
- package/server/sessions/send-message.ts +102 -0
- package/server/sessions/view-sessions.ts +4 -94
- package/server/web.ts +42 -31
- package/server/workspace-state/file.ts +2 -0
- package/server/workspace-state/index.ts +15 -4
- package/server/workspaces/api.ts +4 -8
- package/server/workspaces/config.ts +14 -13
- package/server/workspaces/env-apply.ts +1 -1
- package/server/workspaces/layout.ts +40 -7
- package/server/workspaces/shared.ts +1 -1
- package/server/workspaces/tabs.ts +1 -2
- package/skill/SKILL.md +75 -34
- package/skill/references/SCRATCHPAD.md +4 -0
- package/skill/references/UI-COMPONENTS.md +1 -1
- package/client/features/scratchpad/scratch-executor.ts +0 -20
- package/client/runtime/workspace-events.ts +0 -168
- package/dist/chunk-44khk4sp.js +0 -2
- package/dist/chunk-ba6mz56s.js +0 -72
- package/dist/chunk-ectsnw81.js +0 -2
- package/dist/chunk-en7w5ypg.js +0 -1
- package/dist/chunk-f695wcx5.js +0 -5
- package/dist/chunk-pdt9hxfw.js +0 -2
- package/dist/chunk-zv22wv0g.js +0 -1
|
@@ -3,23 +3,22 @@ import { useEffect } from 'react'
|
|
|
3
3
|
import { useLatestRef } from '@/client/lib/use-latest-ref'
|
|
4
4
|
|
|
5
5
|
import { useAppContext } from './app-context'
|
|
6
|
-
import type {
|
|
6
|
+
import type { ClientEventHandler } from './app-events'
|
|
7
7
|
|
|
8
|
-
export type {
|
|
8
|
+
export type { ClientEvent, ClientEventHandler } from './app-events'
|
|
9
9
|
|
|
10
|
-
// Listen to
|
|
10
|
+
// Listen to every client event. Subscribing never opens or closes the
|
|
11
11
|
// socket — `AppProvider` owns that — so a route switch that briefly leaves
|
|
12
12
|
// nothing subscribed costs nothing. A no-op outside `AppProvider`.
|
|
13
|
-
export function
|
|
13
|
+
export function useClientEvent(handler: ClientEventHandler) {
|
|
14
14
|
const events = useAppContext()?.events
|
|
15
15
|
const handlerRef = useLatestRef(handler)
|
|
16
16
|
useEffect(() => events?.subscribe(event => handlerRef.current(event)), [events, handlerRef])
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
// Listen to
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
useWorkspaceEvent(event => {
|
|
19
|
+
// Listen to one workspace plus app-wide events.
|
|
20
|
+
export function useWorkspaceEvent(workspaceId: string, handler: ClientEventHandler) {
|
|
21
|
+
useClientEvent(event => {
|
|
23
22
|
if (
|
|
24
23
|
'workspaceId' in event &&
|
|
25
24
|
event.workspaceId !== undefined &&
|
|
@@ -51,8 +50,8 @@ export function useNavigationClient(
|
|
|
51
50
|
}
|
|
52
51
|
}, [events, workspaceId])
|
|
53
52
|
|
|
54
|
-
useWorkspaceEvent(async event => {
|
|
55
|
-
if (!events || event.type !== 'navigation:request'
|
|
53
|
+
useWorkspaceEvent(workspaceId, async event => {
|
|
54
|
+
if (!events || event.type !== 'navigation:request') return
|
|
56
55
|
try {
|
|
57
56
|
if (events.navigationWorkspace !== workspaceId) {
|
|
58
57
|
throw new Error('The browser switched workspaces.')
|
package/client/store/ui.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { LayoutMode
|
|
2
|
-
import { createDefaultWorkspaceTabs } from '@/lib/workspace-layout'
|
|
1
|
+
import type { LayoutMode } from '@/lib/types'
|
|
3
2
|
import { create } from 'zustand'
|
|
4
3
|
import { createJSONStorage, persist } from 'zustand/middleware'
|
|
5
4
|
import type { StateStorage } from 'zustand/middleware'
|
|
@@ -7,16 +6,12 @@ import type { StateStorage } from 'zustand/middleware'
|
|
|
7
6
|
// Per-browser UI preferences and onboarding markers, persisted to localStorage
|
|
8
7
|
// so they survive reloads. Server-backed per-user app state belongs in DATA_DIR.
|
|
9
8
|
export type WorkspaceUi = {
|
|
10
|
-
// Open tabs and the tab a bare `/workspace/:id` lands on. Each window follows
|
|
11
|
-
// its own URL; the last window to change tabs decides what is saved.
|
|
12
|
-
tabs: WorkspaceTabsState
|
|
13
9
|
layoutMode: LayoutMode
|
|
14
10
|
dockedChatWidth: number
|
|
15
11
|
popupChatWidth: number
|
|
16
12
|
}
|
|
17
13
|
|
|
18
14
|
export const defaultWorkspaceUi: WorkspaceUi = {
|
|
19
|
-
tabs: createDefaultWorkspaceTabs(),
|
|
20
15
|
layoutMode: 'split',
|
|
21
16
|
dockedChatWidth: 360,
|
|
22
17
|
popupChatWidth: 440
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { WorkspaceTabId } from '@/lib/types'
|
|
2
|
+
import { create } from 'zustand'
|
|
3
|
+
import { createJSONStorage, persist } from 'zustand/middleware'
|
|
4
|
+
|
|
5
|
+
type WorkspaceSession = {
|
|
6
|
+
activeTab?: WorkspaceTabId
|
|
7
|
+
chatOpen?: boolean
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
type WorkspaceSessionStore = {
|
|
11
|
+
workspaces: Record<string, WorkspaceSession>
|
|
12
|
+
setWorkspaceSession: (workspaceId: string, patch: WorkspaceSession) => void
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// Per-browser-tab UI state that survives reloads.
|
|
16
|
+
export const useWorkspaceSessionStore = create<WorkspaceSessionStore>()(
|
|
17
|
+
persist(
|
|
18
|
+
set => ({
|
|
19
|
+
workspaces: {},
|
|
20
|
+
setWorkspaceSession: (workspaceId, patch) =>
|
|
21
|
+
set(state => ({
|
|
22
|
+
workspaces: {
|
|
23
|
+
...state.workspaces,
|
|
24
|
+
[workspaceId]: { ...state.workspaces[workspaceId], ...patch }
|
|
25
|
+
}
|
|
26
|
+
}))
|
|
27
|
+
}),
|
|
28
|
+
{ name: 'moi:workspace-session', storage: createJSONStorage(() => sessionStorage) }
|
|
29
|
+
)
|
|
30
|
+
)
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
class Lo extends Error{status;constructor(e,t){super(t);this.status=e;this.name="HttpError"}}async function o(e,t){let s=await e.text();return new Lo(e.status,s||t)}async function h(e,t,s="Request failed"){let n=await fetch(e,t);if(!n.ok)throw await o(n,s);return n.json()}async function he(e,t,s="Request failed"){let n=await fetch(e,t);if(!n.ok)throw await o(n,s)}function S(e,t){return{method:e,headers:{"Content-Type":"application/json"},body:t===void 0?void 0:JSON.stringify(t)}}
|
|
2
|
+
export{Lo,h,he,S};
|