moi-computer 0.13.1-next.0 → 0.13.1-next.2
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/api/app-config.ts +12 -2
- package/client/api/http.ts +11 -1
- package/client/app/app-router.tsx +3 -2
- package/client/app/routes/home-route.tsx +1 -1
- package/client/app/routes/workspace-registration.tsx +68 -0
- package/client/app/routes/workspace-route.tsx +37 -13
- package/client/app/shell/sidebar-layout.tsx +10 -5
- package/client/components/shared/workspace-icon.tsx +8 -17
- package/client/features/account/account-test-utils.tsx +18 -4
- package/client/features/account/api.ts +10 -8
- package/client/features/account/profile-actions.ts +5 -7
- package/client/features/app-settings/avatar-upload.tsx +62 -0
- package/client/features/app-settings/profile-settings.tsx +10 -0
- package/client/features/app-settings/settings-page.tsx +2 -1
- package/client/features/applets/api.ts +6 -6
- package/client/features/applets/applet-cache.ts +6 -5
- package/client/features/applets/applet-log.ts +2 -1
- package/client/features/applets/applet-runtime.ts +2 -1
- package/client/features/applets/use-applet.ts +73 -18
- package/client/features/applets/widget-shell.tsx +4 -2
- package/client/features/chat/applet-chat-intents.ts +5 -13
- package/client/features/chat/chat-popup.tsx +8 -4
- package/client/features/chat/chat-send.ts +2 -2
- package/client/features/chat/composer/model-order.ts +4 -4
- package/client/features/chat/composer/model-picker.tsx +12 -10
- package/client/features/chat/composer/use-workspace-composer-state.tsx +1 -1
- package/client/features/chat/sessions/api.ts +11 -28
- package/client/features/chat/sessions/use-selected-session.ts +18 -100
- package/client/features/chat/use-chat.ts +8 -12
- package/client/features/collab/applet-api.ts +1 -1
- package/client/features/collab/components/cursors.tsx +6 -1
- package/client/features/collab/components/presence-avatars.tsx +1 -1
- package/client/features/collab/components/presence-frame.tsx +1 -1
- package/client/features/collab/components/presence-group.tsx +1 -1
- package/client/features/collab/components/presence-helpers.ts +2 -2
- package/client/features/collab/components/user-avatar-group.tsx +1 -1
- package/client/features/collab/components/user-avatar.tsx +1 -1
- package/client/features/collab/components/user.tsx +1 -1
- package/client/features/collab/index.ts +3 -3
- package/client/features/collab/members/api.ts +17 -0
- package/client/features/collab/members/hooks.ts +97 -0
- package/client/features/collab/members/store.ts +148 -0
- package/client/features/{workspace-members → collab/members}/types.ts +7 -5
- package/client/features/collab/{client.ts → presence/client.ts} +4 -5
- package/client/features/collab/{hooks.tsx → presence/hooks.tsx} +1 -1
- package/client/features/collab/{provider.tsx → presence/provider.tsx} +1 -12
- package/client/features/collab/{users.ts → presence/users.ts} +19 -21
- package/client/features/collab/proxy-user.ts +1 -3
- package/client/features/collab/sharing/agent-invite.tsx +30 -0
- package/client/features/collab/sharing/workspace-members.tsx +269 -0
- package/client/features/collab/sharing/workspace-sharing-menu.tsx +179 -0
- package/client/features/collab/testing/component-fixtures.tsx +3 -3
- package/client/features/collab/testing/fake-engine.ts +2 -2
- package/client/features/dev/chat-states-page.tsx +3 -1
- package/client/features/dev/collab/collab-playground.tsx +2 -2
- package/client/features/dev/dev-index-page.tsx +0 -6
- package/client/features/dev/dev-routes.tsx +0 -2
- package/client/features/dev/harness-debug-page.tsx +7 -7
- package/client/features/dev/workspace-setup-mocks.ts +1 -2
- package/client/features/dev/workspace-setup-preview.tsx +6 -4
- package/client/features/harness/api.ts +13 -10
- package/client/features/harness/harness-login-panel.tsx +9 -5
- package/client/features/harness/harness-presentation.ts +4 -4
- package/client/features/harness/harness-selector.tsx +13 -13
- package/client/features/harness/use-harness-login.ts +5 -5
- package/client/features/home/api.ts +38 -2
- package/client/features/home/home-page.tsx +43 -13
- package/client/features/home/shared-workspaces.tsx +70 -0
- package/client/features/home/workspace-invitations.tsx +101 -0
- package/client/features/identity/host-api.ts +5 -4
- package/client/features/identity/store.ts +1 -7
- package/client/features/onboarding/agent-setup-step.tsx +8 -8
- package/client/features/onboarding/onboarding-page.tsx +3 -2
- package/client/features/onboarding/workspace-setup-step.tsx +1 -1
- package/client/features/overview/api.ts +3 -5
- package/client/features/overview/default/registry.tsx +1 -1
- package/client/features/overview/default/views-widget.tsx +2 -2
- package/client/features/overview/hidden-panel.tsx +7 -5
- package/client/features/overview/overview.tsx +18 -16
- package/client/features/overview/workspace-name.tsx +2 -2
- package/client/features/scratchpad/scratchpad.tsx +9 -7
- package/client/features/scratchpad/use-scratchpad-snapshot.tsx +13 -5
- package/client/features/views/api.ts +34 -16
- package/client/features/views/use-view-actions.ts +10 -20
- package/client/features/views/view-manager.tsx +1 -1
- package/client/features/views/view-submission.ts +2 -21
- package/client/features/workspace/add/api.ts +5 -4
- package/client/features/workspace/add/create-workspace-dialog.tsx +12 -9
- package/client/features/workspace/add/import-workspace-dialog.tsx +7 -7
- package/client/features/workspace/add/use-workspace-import.ts +10 -10
- package/client/features/workspace/add/workspace-agent-options.ts +21 -20
- package/client/features/workspace/add/workspace-agent-selector.tsx +11 -11
- package/client/features/workspace/api.ts +60 -13
- package/client/features/workspace/harness-transition.ts +7 -13
- package/client/features/workspace/remote.ts +25 -0
- package/client/features/workspace/settings/api.ts +7 -12
- package/client/features/workspace/settings/connectors-settings.tsx +3 -3
- package/client/features/workspace/settings/general-settings.tsx +8 -8
- package/client/features/workspace/setup/workspace-login-state.tsx +4 -4
- package/client/features/workspace/setup/workspace-recovery-states.tsx +43 -14
- package/client/features/workspace/setup/workspace-setup.tsx +6 -6
- package/client/features/workspace/tab-resolution.ts +2 -2
- package/client/features/workspace/use-workspace-navigation.ts +7 -4
- package/client/features/workspace/workspace-content.tsx +32 -26
- package/client/features/workspace/workspace-frame.tsx +13 -26
- package/client/features/workspace/workspace-layout-context.tsx +45 -12
- package/client/features/workspace/workspace-menu.tsx +2 -2
- package/client/features/workspace/workspace-pane.tsx +22 -0
- package/client/features/workspace/workspace-pending-screen.tsx +1 -1
- package/client/features/workspace/workspace-preferences.ts +34 -0
- package/client/features/workspace/workspace-presentation.tsx +12 -16
- package/client/features/workspace/workspace-screen.tsx +2 -2
- package/client/features/workspace/workspace-state.ts +2 -1
- package/client/features/workspace/workspace-tabs.tsx +1 -1
- package/client/features/workspace/workspace-test-utils.ts +23 -0
- package/client/runtime/use-workspace-events.ts +14 -0
- package/client/runtime/workspace-events.ts +9 -9
- package/client/store/ui.ts +29 -9
- package/dist/chunk-44khk4sp.js +2 -0
- package/dist/chunk-ba6mz56s.js +72 -0
- package/dist/chunk-ec5ennpv.js +1 -0
- package/dist/chunk-ectsnw81.js +2 -0
- package/dist/chunk-en7w5ypg.js +1 -0
- package/dist/chunk-f695wcx5.js +5 -0
- package/dist/chunk-kffcah9w.css +1 -0
- package/dist/{chunk-kdgk4dac.js → chunk-n0fawy9x.js} +1 -1
- package/dist/chunk-pdt9hxfw.js +2 -0
- package/dist/chunk-rmd0ctfx.js +546 -0
- package/dist/chunk-zv22wv0g.js +1 -0
- package/dist/index.html +1 -1
- package/lib/harness-instructions.ts +4 -4
- package/lib/harness-types.ts +13 -0
- package/lib/types.ts +34 -50
- package/lib/workspace-config.ts +48 -0
- package/lib/workspace-layout.ts +2 -4
- package/package.json +4 -2
- package/server/README.md +29 -27
- package/server/api/harnesses.ts +5 -5
- package/server/api/index.ts +170 -68
- package/server/app-config.ts +2 -7
- package/server/applets/declarations.ts +6 -7
- package/server/applets/index.ts +15 -9
- package/server/applets/views.ts +2 -17
- package/server/applets/widgets.ts +3 -2
- package/server/cli/commands/config.ts +8 -20
- package/server/cli/commands/hermes.ts +2 -2
- package/server/cli/commands/init.ts +96 -64
- package/server/cli/commands/openclaw.ts +2 -2
- package/server/cli/commands/refresh.ts +10 -1
- package/server/cli/commands/remote.ts +228 -0
- package/server/cli/commands/skill.ts +4 -4
- package/server/cli/commands/tabs.ts +5 -12
- package/server/cli/control.ts +35 -4
- package/server/cli/index.ts +10 -6
- package/server/cli/remote-command.ts +77 -0
- package/server/cli/remote-control.ts +70 -0
- package/server/cli/remote-operations.ts +244 -0
- package/server/collab/config.ts +4 -8
- package/server/collab/manager.ts +5 -2
- package/server/collab/skill/index.ts +4 -50
- package/server/control.ts +38 -11
- package/server/harness/acp/session.ts +4 -4
- package/server/harness/auth.ts +26 -31
- package/server/harness/claude-code/index.ts +1 -1
- package/server/harness/codex/discovery.ts +1 -1
- package/server/harness/codex/session.ts +1 -1
- package/server/harness/detect.ts +14 -19
- package/server/harness/executable.ts +10 -10
- package/server/harness/hermes/NOTES.md +2 -2
- package/server/harness/hermes/index.ts +1 -1
- package/server/harness/install.ts +11 -11
- package/server/harness/openclaw/index.ts +1 -1
- package/server/harness/registry.ts +7 -6
- package/server/harness/types.ts +4 -4
- package/server/onboarding/jobs.ts +1 -1
- package/server/operations/commands.ts +46 -0
- package/server/operations/files.ts +148 -0
- package/server/operations/server.ts +206 -0
- package/server/remote/agent.ts +103 -0
- package/server/remote/client.ts +665 -0
- package/server/remote/workspace.ts +34 -0
- package/server/scratchpad/document.ts +32 -12
- package/server/scratchpad/executor.ts +16 -7
- package/server/sessions/config.ts +8 -5
- package/server/sessions/pending-views.ts +16 -0
- package/server/sessions/view-sessions.ts +10 -12
- package/server/skills/locations.ts +4 -4
- package/server/skills/template.ts +3 -2
- package/server/skills/update.ts +12 -12
- package/server/skills/version.ts +7 -7
- package/server/skills/workspace.ts +13 -13
- package/server/web.ts +12 -10
- package/server/workspace-state/file.ts +2 -0
- package/server/workspace-state/index.ts +0 -4
- package/server/workspaces/api.ts +28 -0
- package/server/workspaces/change-harness.ts +15 -26
- package/server/workspaces/import.ts +4 -4
- package/server/workspaces/init.ts +15 -13
- package/server/workspaces/layout.ts +60 -66
- package/server/workspaces/registry.ts +43 -18
- package/server/workspaces/scaffold.ts +1 -0
- package/server/workspaces/shared.ts +74 -0
- package/server/workspaces/tabs.ts +6 -12
- package/skill/SKILL.md +24 -4
- package/client/api/app-ui-keys.ts +0 -6
- package/client/features/chat/sessions/browser-tab-state.ts +0 -43
- package/client/features/collab/workspace-users-menu.tsx +0 -190
- package/client/features/dev/cloud-avatar-upload.tsx +0 -58
- package/client/features/dev/cloud-page.tsx +0 -363
- package/client/features/workspace/browser-tab-state.ts +0 -51
- package/client/features/workspace/layout-save.ts +0 -13
- package/client/features/workspace-members/api.ts +0 -20
- package/client/features/workspace-members/hooks.ts +0 -127
- package/client/features/workspace-members/keys.ts +0 -6
- package/client/features/workspace-members/store.ts +0 -123
- package/dist/chunk-00s35r33.js +0 -546
- package/dist/chunk-7rz6g7g7.js +0 -1
- package/dist/chunk-af2jyddf.js +0 -2
- package/dist/chunk-cekekc3f.css +0 -1
- package/dist/chunk-ep5vh16c.js +0 -75
- package/dist/chunk-s5s1vzdw.js +0 -2
- package/dist/chunk-svxhxfeq.js +0 -2
- package/dist/chunk-t0r0bds1.js +0 -1
- package/dist/chunk-vp2qzc0d.js +0 -1
- package/dist/chunk-wz5qv1bn.js +0 -2
- package/lib/workspace-types.ts +0 -13
- package/server/workspace-state/legacy-migration.ts +0 -79
- /package/client/features/collab/{presence-publisher.ts → presence/presence-publisher.ts} +0 -0
- /package/client/features/collab/{presence-target.ts → presence/presence-target.ts} +0 -0
- /package/client/features/collab/{store.ts → presence/store.ts} +0 -0
package/skill/SKILL.md
CHANGED
|
@@ -50,6 +50,26 @@ User can switch between these, but can access the chat (this conversation and ot
|
|
|
50
50
|
|
|
51
51
|
## Working in the workspace
|
|
52
52
|
|
|
53
|
+
### Local or remote workspace
|
|
54
|
+
|
|
55
|
+
Before working, read `remote` in `.moi/.workspace.json` (read only; never edit the file). A missing
|
|
56
|
+
file or absent `remote` means local, and the rest of this section does not apply.
|
|
57
|
+
|
|
58
|
+
`remote: { user_id, workspace_id }` means the workspace lives on its owner's machine. This folder
|
|
59
|
+
holds only the reference and skills.
|
|
60
|
+
|
|
61
|
+
- Edit shared files with `moi remote read`, `write`, `patch`, `file-upload`, and `file-download`;
|
|
62
|
+
paths are relative to the owner's workspace root. `moi remote exec '<command>'` runs there.
|
|
63
|
+
- Use the ordinary commands from this folder as usual. `moi check`, `bundle`, `views`, `theme`,
|
|
64
|
+
`config`, `tabs`, `call-server-fn`, `debug logs`, and scratchpad reads/edits act on the owner.
|
|
65
|
+
- `moi refresh`, `navigate`, and `scratch view` act on your user's running Moi and browser. Refresh
|
|
66
|
+
after remote changes.
|
|
67
|
+
- Image input and output paths refer to the machine running the CLI. `config icon` and
|
|
68
|
+
`scratch add image` upload local files to the owner; `scratch read-image` saves the owner's
|
|
69
|
+
image locally, and `scratch view --out` saves the visitor browser's canvas screenshot locally.
|
|
70
|
+
- Never create local applet copies or fall back to local content when the owner is unavailable.
|
|
71
|
+
Remote chat and the settings UI are unavailable.
|
|
72
|
+
|
|
53
73
|
### Boundaries
|
|
54
74
|
|
|
55
75
|
- Never read or modify files outside the `.moi` directory, unless the user explicitly asks. If you
|
|
@@ -59,7 +79,7 @@ User can switch between these, but can access the chat (this conversation and ot
|
|
|
59
79
|
|
|
60
80
|
### Files and folders
|
|
61
81
|
|
|
62
|
-
|
|
82
|
+
For local workspaces, the source of truth is the `.moi` folder in the root of "Project" folder. Contains source code of all
|
|
63
83
|
Applets, bundled code, settings, etc. Can be committed to version control. Folder is partially
|
|
64
84
|
initialised when Workspace starts, you have full ownership of it.
|
|
65
85
|
|
|
@@ -83,14 +103,14 @@ my-agent-folder/
|
|
|
83
103
|
users-api.server.ts <- Server-side async functions the view can call (optional)
|
|
84
104
|
...
|
|
85
105
|
package.json <- Applet dependencies that you manage
|
|
86
|
-
.workspace.json <-
|
|
106
|
+
.workspace.json <- Internal config. Only read `remote` for the check above; do not edit.
|
|
87
107
|
.scratchpad.json <- Scratchpad canvas snapshot. Internal — inspect only via `moi scratch read`, never open it.
|
|
88
108
|
.scratchpad/ <- Scratchpad image files. Internal — pull pixels via `moi scratch read-image`, never open it.
|
|
89
109
|
```
|
|
90
110
|
|
|
91
111
|
Every dot-prefixed file or folder inside `.moi/` (`.build/`, `.cache/`, `.workspace.json`,
|
|
92
112
|
`.scratchpad*`, `.gitignore`, …) is a Moi internal: auto-generated and liable to change format
|
|
93
|
-
without notice.
|
|
113
|
+
without notice. Except for the read-only `remote` check above, do not read, edit, or delete them, and never point
|
|
94
114
|
tooling at them; go through the `moi` CLI instead. Version control needs no special handling: the
|
|
95
115
|
scaffolded `.moi/.gitignore` already excludes the machine-local entries (`.build/`, `.cache/`,
|
|
96
116
|
`node_modules/`), while `.workspace.json` and `.scratchpad.json` are workspace state that ships
|
|
@@ -522,4 +542,4 @@ This skill is installed with Moi (via the CLI or the UI) and can fall behind whe
|
|
|
522
542
|
- **Then** — if you updated, mention it.
|
|
523
543
|
|
|
524
544
|
<!-- moi skill version marker — read by `moi skill` to detect drift; do not edit by hand -->
|
|
525
|
-
<moi-skill version="0.
|
|
545
|
+
<moi-skill version="0.21.0" />
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import type { WorkspaceTabId } from '@/lib/types'
|
|
2
|
-
|
|
3
|
-
// Collab keeps each browser tab's unpinned chat choice, including a separate
|
|
4
|
-
// selection for every workspace tab. The workspace pin remains server-owned.
|
|
5
|
-
export type BrowserTabSelection = {
|
|
6
|
-
// A browser tab can explicitly choose an empty chat (null). An absent key
|
|
7
|
-
// inherits the server selection, including CLI-created view handoffs.
|
|
8
|
-
selected: Partial<Record<WorkspaceTabId, string | null>>
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const keyFor = (workspaceId: string) => `moi:collab:${workspaceId}:session`
|
|
12
|
-
const emptySelection = (): BrowserTabSelection => ({ selected: {} })
|
|
13
|
-
|
|
14
|
-
export function readSelectedSession(workspaceId: string): BrowserTabSelection {
|
|
15
|
-
try {
|
|
16
|
-
const saved = sessionStorage.getItem(keyFor(workspaceId))
|
|
17
|
-
if (!saved) return emptySelection()
|
|
18
|
-
// The first Collab build stored only the overview chat ID.
|
|
19
|
-
if (!saved.startsWith('{')) return { selected: { overview: saved } }
|
|
20
|
-
const value: unknown = JSON.parse(saved)
|
|
21
|
-
if (!value || typeof value !== 'object' || !('selected' in value)) return emptySelection()
|
|
22
|
-
const selected = (value as { selected: unknown }).selected
|
|
23
|
-
if (!selected || typeof selected !== 'object' || Array.isArray(selected))
|
|
24
|
-
return emptySelection()
|
|
25
|
-
return {
|
|
26
|
-
selected: Object.fromEntries(
|
|
27
|
-
Object.entries(selected).filter(
|
|
28
|
-
([, sessionId]) => typeof sessionId === 'string' || sessionId === null
|
|
29
|
-
)
|
|
30
|
-
)
|
|
31
|
-
}
|
|
32
|
-
} catch {
|
|
33
|
-
return emptySelection()
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export function writeSelectedSession(workspaceId: string, selection: BrowserTabSelection): void {
|
|
38
|
-
try {
|
|
39
|
-
sessionStorage.setItem(keyFor(workspaceId), JSON.stringify({ selected: selection.selected }))
|
|
40
|
-
} catch {
|
|
41
|
-
// The in-memory query still works when browser storage is denied.
|
|
42
|
-
}
|
|
43
|
-
}
|
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
import { useState, useSyncExternalStore } from 'react'
|
|
2
|
-
|
|
3
|
-
import { IconChevronDown } from '@tabler/icons-react'
|
|
4
|
-
import type { Icon as TabIcon } from '@tabler/icons-react'
|
|
5
|
-
import { useRouter } from 'wouter'
|
|
6
|
-
import { usePathname } from 'wouter/use-browser-location'
|
|
7
|
-
|
|
8
|
-
import { Button } from '@/client/components/ui/button'
|
|
9
|
-
import {
|
|
10
|
-
Popover,
|
|
11
|
-
PopoverContent,
|
|
12
|
-
PopoverTitle,
|
|
13
|
-
PopoverTrigger
|
|
14
|
-
} from '@/client/components/ui/popover'
|
|
15
|
-
import { cn } from '@/client/lib/cn'
|
|
16
|
-
import type { WorkspaceTabId } from '@/lib/types'
|
|
17
|
-
import { tabFromPath } from '@/lib/workspace-tabs'
|
|
18
|
-
|
|
19
|
-
import { UserContainer } from './components/user'
|
|
20
|
-
import { UserAvatarGroupContainer as UserAvatarGroup } from './components/user-avatar-group'
|
|
21
|
-
import { pageFromPath, useCollabEnabled, useCollabEngine } from './provider'
|
|
22
|
-
import { useConnectionState, useWorkspaceUsers } from './hooks'
|
|
23
|
-
import { summarizeWorkspaceUsers } from './users'
|
|
24
|
-
import type { WorkspaceUserInfo } from './users'
|
|
25
|
-
|
|
26
|
-
export type TabInfo = { label: string; Icon: TabIcon }
|
|
27
|
-
type DescribeTab = (tab: WorkspaceTabId) => TabInfo | null
|
|
28
|
-
const USER_STATUS_ORDER = { active: 0, away: 1, offline: 2 }
|
|
29
|
-
|
|
30
|
-
type WorkspaceUsersMenuProps = {
|
|
31
|
-
workspaceId: string
|
|
32
|
-
describeTab: DescribeTab
|
|
33
|
-
onOpenTab: (tab: WorkspaceTabId) => void
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export function WorkspaceUsersMenu({
|
|
37
|
-
workspaceId,
|
|
38
|
-
describeTab,
|
|
39
|
-
onOpenTab
|
|
40
|
-
}: WorkspaceUsersMenuProps) {
|
|
41
|
-
const enabled = useCollabEnabled()
|
|
42
|
-
const engine = useCollabEngine()
|
|
43
|
-
const state = useConnectionState()
|
|
44
|
-
const workspaceUsers = useWorkspaceUsers()
|
|
45
|
-
const currentUser = useSyncExternalStore(
|
|
46
|
-
engine.subscribeCurrentUser,
|
|
47
|
-
engine.getCurrentUser,
|
|
48
|
-
engine.getCurrentUser
|
|
49
|
-
)
|
|
50
|
-
const router = useRouter()
|
|
51
|
-
const page = pageFromPath(usePathname(router), workspaceId, router.base)
|
|
52
|
-
const users = summarizeWorkspaceUsers(state.connections, {
|
|
53
|
-
currentUser,
|
|
54
|
-
connectionId: state.connectionId,
|
|
55
|
-
users: workspaceUsers,
|
|
56
|
-
page
|
|
57
|
-
})
|
|
58
|
-
const avatarIds = users
|
|
59
|
-
.filter(user => user.self || user.status !== 'offline')
|
|
60
|
-
.map(user => user.profile.id)
|
|
61
|
-
const [open, setOpen] = useState(false)
|
|
62
|
-
|
|
63
|
-
if (!enabled || workspaceUsers.length <= 1) return null
|
|
64
|
-
|
|
65
|
-
return (
|
|
66
|
-
<Popover open={open} onOpenChange={setOpen}>
|
|
67
|
-
<PopoverTrigger
|
|
68
|
-
render={
|
|
69
|
-
<Button
|
|
70
|
-
variant="ghost"
|
|
71
|
-
size="sm"
|
|
72
|
-
aria-label="Users in this workspace"
|
|
73
|
-
className="gap-0.5 rounded-full pr-1 pl-1 data-popup-open:bg-accent"
|
|
74
|
-
/>
|
|
75
|
-
}
|
|
76
|
-
>
|
|
77
|
-
<UserAvatarGroup ids={avatarIds} size="xs" max={4} />
|
|
78
|
-
<IconChevronDown stroke={2.5} className="size-3! text-muted-foreground" />
|
|
79
|
-
</PopoverTrigger>
|
|
80
|
-
<PopoverContent align="end" className="max-w-64 p-1">
|
|
81
|
-
<PopoverTitle className="sr-only">Users in this workspace</PopoverTitle>
|
|
82
|
-
<WorkspaceUsersList
|
|
83
|
-
users={users}
|
|
84
|
-
page={page}
|
|
85
|
-
describeTab={describeTab}
|
|
86
|
-
onOpenTab={tab => {
|
|
87
|
-
setOpen(false)
|
|
88
|
-
onOpenTab(tab)
|
|
89
|
-
}}
|
|
90
|
-
/>
|
|
91
|
-
{users.length === 0 && (
|
|
92
|
-
<p className="px-2 py-1 text-xs text-muted-foreground">No workspace users to show.</p>
|
|
93
|
-
)}
|
|
94
|
-
</PopoverContent>
|
|
95
|
-
</Popover>
|
|
96
|
-
)
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
type WorkspaceUsersListProps = {
|
|
100
|
-
users: WorkspaceUserInfo[]
|
|
101
|
-
page: string
|
|
102
|
-
describeTab: DescribeTab
|
|
103
|
-
onOpenTab: (tab: WorkspaceTabId) => void
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
export function WorkspaceUsersList({
|
|
107
|
-
users,
|
|
108
|
-
page,
|
|
109
|
-
describeTab,
|
|
110
|
-
onOpenTab
|
|
111
|
-
}: WorkspaceUsersListProps) {
|
|
112
|
-
const sorted = users.toSorted(
|
|
113
|
-
(a, b) =>
|
|
114
|
-
USER_STATUS_ORDER[a.status] - USER_STATUS_ORDER[b.status] || Number(b.self) - Number(a.self)
|
|
115
|
-
)
|
|
116
|
-
return (
|
|
117
|
-
<ul className="flex max-h-80 scroll-fade flex-col overflow-y-auto">
|
|
118
|
-
{sorted.map(user => (
|
|
119
|
-
<UserRow
|
|
120
|
-
key={user.profile.id}
|
|
121
|
-
user={user}
|
|
122
|
-
page={page}
|
|
123
|
-
describeTab={describeTab}
|
|
124
|
-
onOpenTab={onOpenTab}
|
|
125
|
-
/>
|
|
126
|
-
))}
|
|
127
|
-
</ul>
|
|
128
|
-
)
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
type UserRowProps = Omit<WorkspaceUsersListProps, 'users'> & { user: WorkspaceUserInfo }
|
|
132
|
-
|
|
133
|
-
function UserRow({ user, page, describeTab, onOpenTab }: UserRowProps) {
|
|
134
|
-
const tabs = user.pages.map(candidate => {
|
|
135
|
-
const tab = tabFromPath(candidate)
|
|
136
|
-
return { tab, info: tab ? describeTab(tab) : null }
|
|
137
|
-
})
|
|
138
|
-
const destination =
|
|
139
|
-
user.self || user.status === 'offline'
|
|
140
|
-
? undefined
|
|
141
|
-
: tabs.find(({ tab, info }) => tab !== null && info !== null && tab !== page)
|
|
142
|
-
const target = destination?.tab
|
|
143
|
-
const labels = [
|
|
144
|
-
...new Set(tabs.map(({ tab, info }) => info?.label ?? tab ?? 'Another tab'))
|
|
145
|
-
].join(', ')
|
|
146
|
-
const where =
|
|
147
|
-
user.status === 'offline'
|
|
148
|
-
? 'Offline'
|
|
149
|
-
: user.status === 'away'
|
|
150
|
-
? labels
|
|
151
|
-
? `${labels} · Away`
|
|
152
|
-
: 'Away'
|
|
153
|
-
: labels || 'Another tab'
|
|
154
|
-
const Icon = user.status === 'offline' ? undefined : tabs[0]?.info?.Icon
|
|
155
|
-
const content = (
|
|
156
|
-
<UserContainer
|
|
157
|
-
id={user.profile.id}
|
|
158
|
-
className="flex-1"
|
|
159
|
-
size="sm"
|
|
160
|
-
showYouLabel
|
|
161
|
-
description={
|
|
162
|
-
<span className="flex items-center gap-1 text-xs">
|
|
163
|
-
{Icon && <Icon size={12} stroke={1.75} className="shrink-0" />}
|
|
164
|
-
<span className="truncate">{where}</span>
|
|
165
|
-
</span>
|
|
166
|
-
}
|
|
167
|
-
/>
|
|
168
|
-
)
|
|
169
|
-
const row = 'flex w-full items-center gap-2.5 rounded-md px-2 py-1 text-left'
|
|
170
|
-
|
|
171
|
-
return (
|
|
172
|
-
<li>
|
|
173
|
-
{target ? (
|
|
174
|
-
<button
|
|
175
|
-
type="button"
|
|
176
|
-
title={`Go to ${destination?.info?.label}`}
|
|
177
|
-
className={cn(
|
|
178
|
-
row,
|
|
179
|
-
'cursor-pointer outline-none hover:bg-accent focus-visible:ring-3 focus-visible:ring-ring/50'
|
|
180
|
-
)}
|
|
181
|
-
onClick={() => onOpenTab(target)}
|
|
182
|
-
>
|
|
183
|
-
{content}
|
|
184
|
-
</button>
|
|
185
|
-
) : (
|
|
186
|
-
<div className={row}>{content}</div>
|
|
187
|
-
)}
|
|
188
|
-
</li>
|
|
189
|
-
)
|
|
190
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { useRef, type ReactNode } from 'react'
|
|
2
|
-
import { useMutation } from '@tanstack/react-query'
|
|
3
|
-
import { IconLoader } from '@tabler/icons-react'
|
|
4
|
-
import { Button } from '@/client/components/ui/button'
|
|
5
|
-
import { toast } from '@/client/components/ui/toast'
|
|
6
|
-
import { Tooltip, TooltipContent, TooltipTrigger } from '@/client/components/ui/tooltip'
|
|
7
|
-
import { useAccount } from '../account/account-provider'
|
|
8
|
-
|
|
9
|
-
type CloudAvatarUploadProps = { children: ReactNode }
|
|
10
|
-
|
|
11
|
-
export function CloudAvatarUpload({ children }: CloudAvatarUploadProps) {
|
|
12
|
-
const account = useAccount()
|
|
13
|
-
const input = useRef<HTMLInputElement>(null)
|
|
14
|
-
const upload = useMutation({
|
|
15
|
-
mutationFn: (file: File) => account.saveAvatar(file),
|
|
16
|
-
onSuccess: () => toast.add({ title: 'Avatar updated', type: 'success' }),
|
|
17
|
-
onError: error =>
|
|
18
|
-
toast.add({ title: 'Couldn’t update avatar', description: error.message, type: 'error' })
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
return (
|
|
22
|
-
<>
|
|
23
|
-
<input
|
|
24
|
-
ref={input}
|
|
25
|
-
type="file"
|
|
26
|
-
accept="image/*"
|
|
27
|
-
aria-label="Choose an avatar file"
|
|
28
|
-
className="hidden"
|
|
29
|
-
disabled={upload.isPending}
|
|
30
|
-
onChange={event => {
|
|
31
|
-
const file = event.currentTarget.files?.[0]
|
|
32
|
-
event.currentTarget.value = ''
|
|
33
|
-
if (file) upload.mutate(file)
|
|
34
|
-
}}
|
|
35
|
-
/>
|
|
36
|
-
<Tooltip>
|
|
37
|
-
<TooltipTrigger
|
|
38
|
-
render={
|
|
39
|
-
<Button
|
|
40
|
-
variant="ghost"
|
|
41
|
-
size="icon"
|
|
42
|
-
className="rounded-full"
|
|
43
|
-
aria-label="Change your avatar"
|
|
44
|
-
aria-busy={upload.isPending}
|
|
45
|
-
disabled={upload.isPending || !account.registered}
|
|
46
|
-
onClick={() => input.current?.click()}
|
|
47
|
-
/>
|
|
48
|
-
}
|
|
49
|
-
>
|
|
50
|
-
{upload.isPending ? <IconLoader className="animate-spin" stroke={1.5} /> : children}
|
|
51
|
-
</TooltipTrigger>
|
|
52
|
-
<TooltipContent>
|
|
53
|
-
{upload.isPending ? 'Updating avatar…' : 'Change your avatar'}
|
|
54
|
-
</TooltipContent>
|
|
55
|
-
</Tooltip>
|
|
56
|
-
</>
|
|
57
|
-
)
|
|
58
|
-
}
|