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.
Files changed (109) hide show
  1. package/client/app/app-provider.tsx +14 -20
  2. package/client/app/app-router.tsx +5 -8
  3. package/client/app/routes/workspace-route.tsx +28 -11
  4. package/client/app/shell/sidebar-layout.tsx +5 -10
  5. package/client/features/app-settings/api.ts +3 -3
  6. package/client/features/applets/applet-cache.ts +1 -2
  7. package/client/features/applets/use-applet.ts +18 -20
  8. package/client/features/chat/chat-store.ts +1 -1
  9. package/client/features/chat/connection/chat-connection.ts +25 -68
  10. package/client/features/chat/connection/chat-frames.ts +20 -32
  11. package/client/features/chat/sessions/api.ts +2 -2
  12. package/client/features/chat/sessions/use-selected-session.ts +0 -13
  13. package/client/features/collab/presence/client.ts +63 -83
  14. package/client/features/collab/presence/provider.tsx +8 -2
  15. package/client/features/dev/chat-states-page.tsx +1 -1
  16. package/client/features/dev/harness-debug-page.tsx +2 -2
  17. package/client/features/scratchpad/scratchpad.tsx +29 -20
  18. package/client/features/views/api.ts +38 -14
  19. package/client/features/views/use-view-actions.ts +2 -23
  20. package/client/features/workspace/api.ts +6 -11
  21. package/client/features/workspace/harness-transition.ts +3 -5
  22. package/client/features/workspace/remote.ts +9 -0
  23. package/client/features/workspace/settings/use-env-vars.ts +4 -4
  24. package/client/features/workspace/tab-resolution.ts +1 -8
  25. package/client/features/workspace/use-workspace-navigation.ts +5 -4
  26. package/client/features/workspace/use-workspace-socket.ts +51 -0
  27. package/client/features/workspace/workspace-content.tsx +5 -18
  28. package/client/features/workspace/workspace-layout-context.tsx +6 -13
  29. package/client/features/workspace/workspace-preferences.ts +67 -10
  30. package/client/features/workspace/workspace-state.ts +57 -21
  31. package/client/runtime/app-context.ts +2 -2
  32. package/client/runtime/app-events.ts +75 -0
  33. package/client/runtime/reconnecting-socket.ts +115 -0
  34. package/client/runtime/{use-workspace-events.ts → use-client-events.ts} +9 -10
  35. package/client/store/ui.ts +1 -6
  36. package/client/store/workspace-session.ts +30 -0
  37. package/dist/chunk-0t8m1ehd.js +2 -0
  38. package/dist/chunk-851bx8ss.js +72 -0
  39. package/dist/{chunk-n0fawy9x.js → chunk-c8g5x288.js} +1 -1
  40. package/dist/chunk-cty37f3v.js +1 -0
  41. package/dist/chunk-dy6f6h3e.js +5 -0
  42. package/dist/chunk-j6928pwm.js +1 -0
  43. package/dist/{chunk-rmd0ctfx.js → chunk-k32585ne.js} +73 -73
  44. package/dist/chunk-qtkv7hp8.js +2 -0
  45. package/dist/chunk-rh58dc0y.js +2 -0
  46. package/dist/{chunk-ec5ennpv.js → chunk-wjbejzek.js} +1 -1
  47. package/dist/index.html +1 -1
  48. package/lib/events.ts +61 -0
  49. package/lib/ids.ts +2 -8
  50. package/lib/moi-context.ts +19 -5
  51. package/lib/types.ts +16 -20
  52. package/lib/workspace-layout.ts +3 -20
  53. package/package.json +2 -1
  54. package/server/AGENTS.md +4 -4
  55. package/server/README.md +50 -33
  56. package/server/api/index.ts +175 -152
  57. package/server/applets/views.ts +15 -14
  58. package/server/applets/widgets.ts +4 -3
  59. package/server/cli/commands/init.ts +7 -2
  60. package/server/cli/commands/refresh.ts +2 -5
  61. package/server/cli/commands/remote.ts +128 -26
  62. package/server/cli/remote-control.ts +12 -9
  63. package/server/cli/remote-operations.ts +47 -44
  64. package/server/control.ts +33 -34
  65. package/server/events.ts +14 -13
  66. package/server/harness/README.md +7 -7
  67. package/server/harness/acp/session.ts +9 -5
  68. package/server/harness/auth.ts +7 -30
  69. package/server/harness/claude-code/session.ts +8 -4
  70. package/server/harness/codex/NOTES.md +1 -1
  71. package/server/harness/codex/session.ts +18 -10
  72. package/server/harness/hermes/NOTES.md +3 -3
  73. package/server/harness/openclaw/session.ts +9 -5
  74. package/server/onboarding/jobs.ts +8 -8
  75. package/server/operations/commands.ts +1 -1
  76. package/server/remote/broker-client.ts +76 -0
  77. package/server/remote/broker.ts +81 -0
  78. package/server/remote/client.ts +212 -152
  79. package/server/remote/errors.ts +2 -0
  80. package/server/remote/routes.ts +121 -0
  81. package/server/scratchpad/document.ts +3 -2
  82. package/server/scratchpad/executor.ts +2 -2
  83. package/server/scratchpad/relay.ts +3 -3
  84. package/server/sessions/archive.ts +1 -1
  85. package/server/sessions/lifecycle.ts +1 -1
  86. package/server/sessions/pending-views.ts +19 -12
  87. package/server/sessions/send-message.ts +102 -0
  88. package/server/sessions/view-sessions.ts +4 -94
  89. package/server/web.ts +42 -31
  90. package/server/workspace-state/file.ts +2 -0
  91. package/server/workspace-state/index.ts +15 -4
  92. package/server/workspaces/api.ts +4 -8
  93. package/server/workspaces/config.ts +14 -13
  94. package/server/workspaces/env-apply.ts +1 -1
  95. package/server/workspaces/layout.ts +40 -7
  96. package/server/workspaces/shared.ts +1 -1
  97. package/server/workspaces/tabs.ts +1 -2
  98. package/skill/SKILL.md +75 -34
  99. package/skill/references/SCRATCHPAD.md +4 -0
  100. package/skill/references/UI-COMPONENTS.md +1 -1
  101. package/client/features/scratchpad/scratch-executor.ts +0 -20
  102. package/client/runtime/workspace-events.ts +0 -168
  103. package/dist/chunk-44khk4sp.js +0 -2
  104. package/dist/chunk-ba6mz56s.js +0 -72
  105. package/dist/chunk-ectsnw81.js +0 -2
  106. package/dist/chunk-en7w5ypg.js +0 -1
  107. package/dist/chunk-f695wcx5.js +0 -5
  108. package/dist/chunk-pdt9hxfw.js +0 -2
  109. 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 { WorkspaceEventHandler } from './workspace-events'
6
+ import type { ClientEventHandler } from './app-events'
7
7
 
8
- export type { WorkspaceEvent, WorkspaceEventHandler } from './workspace-events'
8
+ export type { ClientEvent, ClientEventHandler } from './app-events'
9
9
 
10
- // Listen to the app's workspace events. Subscribing never opens or closes the
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 useWorkspaceEvent(handler: WorkspaceEventHandler) {
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 events for one workspace. Events that name no workspace (such as
20
- // `moi refresh`) reach every open workspace.
21
- export function useWorkspaceScopedEvent(workspaceId: string, handler: WorkspaceEventHandler) {
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' || event.workspaceId !== workspaceId) return
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.')
@@ -1,5 +1,4 @@
1
- import type { LayoutMode, WorkspaceTabsState } from '@/lib/types'
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};