moi-computer 0.12.1-next.2 → 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 +6 -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 +10 -0
- package/client/app/routes/workspace-route.tsx +21 -19
- package/client/app/shell/sidebar-layout.tsx +34 -53
- 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-menu.tsx +96 -0
- package/client/features/account/account-provider.tsx +142 -0
- package/client/features/account/account-test-utils.tsx +294 -0
- package/client/features/account/api.ts +142 -0
- package/client/features/account/identity.ts +23 -0
- package/client/features/app-settings/api.ts +33 -0
- package/client/features/app-settings/general-settings.tsx +39 -0
- package/client/features/app-settings/profile-settings.tsx +95 -0
- package/client/features/app-settings/settings-page.tsx +48 -0
- package/client/features/app-settings/settings-section.tsx +26 -0
- package/client/features/app-settings/users-settings.tsx +195 -0
- 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/applet-api.ts +15 -14
- package/client/features/collab/components/cursors.tsx +61 -24
- package/client/features/collab/components/presence-avatars.tsx +25 -12
- package/client/features/collab/components/presence-frame.tsx +20 -24
- package/client/features/collab/components/presence-group.tsx +15 -7
- package/client/features/collab/components/user-avatar-group.tsx +21 -8
- package/client/features/collab/components/user-avatar.tsx +38 -7
- package/client/features/collab/components/user.tsx +31 -12
- package/client/features/collab/users.ts +0 -5
- package/client/features/collab/workspace-users-menu.tsx +4 -4
- package/client/features/demo/demo-dialog.tsx +11 -3
- package/client/features/dev/collab/collab-playground.tsx +7 -7
- package/client/features/dev/collab/local-user-settings.tsx +7 -53
- 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/update/update-control.tsx +1 -1
- 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 +11 -7
- 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}/connectors-settings.tsx +3 -3
- package/client/features/{settings → workspace/settings}/environment-settings.tsx +3 -3
- package/client/features/{settings → workspace/settings}/general-settings.tsx +77 -3
- 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/lib/user-display-name.ts +6 -0
- package/client/main.tsx +4 -1
- 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 +72 -63
- 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 +164 -131
- package/server/api/onboarding.ts +46 -0
- package/server/app-config.ts +23 -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 +23 -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 -16
- package/server/workspaces/layout.ts +3 -0
- package/server/workspaces/registry.ts +58 -10
- 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-00rh9df4.js +0 -2
- package/dist/chunk-4nh7y1hq.css +0 -1
- package/dist/chunk-am4agx6v.js +0 -2
- package/dist/chunk-d7cbm65e.js +0 -2
- package/dist/chunk-hbpdv7vd.js +0 -1
- package/dist/chunk-hmka9rt5.js +0 -2
- package/dist/chunk-hvh9f5h0.js +0 -14
- package/dist/chunk-mjjregkn.js +0 -10
- package/dist/chunk-pcnahct1.js +0 -5
- package/dist/chunk-rt30jbcm.js +0 -1
- package/dist/chunk-vt6zybej.js +0 -2
- package/dist/chunk-wbkwf6cc.js +0 -68
- package/dist/chunk-xjyfyz64.js +0 -1
- package/dist/chunk-y8nbwp21.js +0 -546
- package/dist/chunk-ysfdcew7.js +0 -1
- package/lib/experimental.ts +0 -14
- package/workspace/.claude/skills/moi-workspace/references/DESIGN.md +0 -157
- /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,95 @@
|
|
|
1
|
+
import { useId, useRef, useState } from 'react'
|
|
2
|
+
import { useMutation } from '@tanstack/react-query'
|
|
3
|
+
import { Field, FieldGroup, FieldLabel } from '@/ui-components/field'
|
|
4
|
+
import { Input } from '@/client/components/ui/input'
|
|
5
|
+
import { toast } from '@/client/components/ui/toast'
|
|
6
|
+
import { useAccount } from '../account/account-provider'
|
|
7
|
+
import { SettingsSection } from './settings-section'
|
|
8
|
+
|
|
9
|
+
export function ProfileSettings() {
|
|
10
|
+
const account = useAccount()
|
|
11
|
+
if (!account.profile) return null
|
|
12
|
+
return (
|
|
13
|
+
<SettingsSection title="Profile">
|
|
14
|
+
<FieldGroup>
|
|
15
|
+
<NameField
|
|
16
|
+
key={account.profile.id}
|
|
17
|
+
name={account.profile.name ?? ''}
|
|
18
|
+
readOnly={!account.canEdit}
|
|
19
|
+
onSave={account.saveName}
|
|
20
|
+
/>
|
|
21
|
+
{account.email && (
|
|
22
|
+
<Field>
|
|
23
|
+
<FieldLabel htmlFor="profile-email">Email</FieldLabel>
|
|
24
|
+
<Input id="profile-email" value={account.email} readOnly type="email" />
|
|
25
|
+
</Field>
|
|
26
|
+
)}
|
|
27
|
+
</FieldGroup>
|
|
28
|
+
</SettingsSection>
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
type NameFieldProps = {
|
|
33
|
+
name: string
|
|
34
|
+
readOnly?: boolean
|
|
35
|
+
onSave: (name: string) => Promise<string>
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function NameField({ name, readOnly, onSave }: NameFieldProps) {
|
|
39
|
+
const id = useId()
|
|
40
|
+
const [draft, setDraft] = useState<string>()
|
|
41
|
+
const save = useMutation({
|
|
42
|
+
mutationFn: onSave,
|
|
43
|
+
onSuccess: () => setDraft(undefined),
|
|
44
|
+
onError: error =>
|
|
45
|
+
toast.add({ title: 'Couldn’t save name', description: error.message, type: 'error' })
|
|
46
|
+
})
|
|
47
|
+
const pending = save.isPending
|
|
48
|
+
const skipBlur = useRef(false)
|
|
49
|
+
|
|
50
|
+
function commit() {
|
|
51
|
+
if (readOnly || pending) return
|
|
52
|
+
const next = (draft ?? name).trim()
|
|
53
|
+
if (!next || next.length > 80 || next === name) {
|
|
54
|
+
setDraft(undefined)
|
|
55
|
+
return
|
|
56
|
+
}
|
|
57
|
+
setDraft(next)
|
|
58
|
+
save.mutate(next)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return (
|
|
62
|
+
<Field>
|
|
63
|
+
<FieldLabel htmlFor={id}>Name</FieldLabel>
|
|
64
|
+
<Input
|
|
65
|
+
id={id}
|
|
66
|
+
value={draft ?? name}
|
|
67
|
+
autoComplete="name"
|
|
68
|
+
maxLength={80}
|
|
69
|
+
readOnly={readOnly}
|
|
70
|
+
disabled={pending}
|
|
71
|
+
onChange={event => setDraft(event.target.value)}
|
|
72
|
+
onBlur={() => {
|
|
73
|
+
if (skipBlur.current) {
|
|
74
|
+
skipBlur.current = false
|
|
75
|
+
return
|
|
76
|
+
}
|
|
77
|
+
void commit()
|
|
78
|
+
}}
|
|
79
|
+
onKeyDown={event => {
|
|
80
|
+
if (event.nativeEvent.isComposing) return
|
|
81
|
+
if (event.key === 'Enter') {
|
|
82
|
+
event.preventDefault()
|
|
83
|
+
event.currentTarget.blur()
|
|
84
|
+
}
|
|
85
|
+
if (event.key === 'Escape') {
|
|
86
|
+
event.preventDefault()
|
|
87
|
+
skipBlur.current = true
|
|
88
|
+
setDraft(undefined)
|
|
89
|
+
event.currentTarget.blur()
|
|
90
|
+
}
|
|
91
|
+
}}
|
|
92
|
+
/>
|
|
93
|
+
</Field>
|
|
94
|
+
)
|
|
95
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { useEffect } from 'react'
|
|
2
|
+
import { Redirect } from 'wouter'
|
|
3
|
+
import { Button } from '@/client/components/ui/button'
|
|
4
|
+
import { Skeleton } from '@/client/components/ui/skeleton'
|
|
5
|
+
import { useAccount } from '../account/account-provider'
|
|
6
|
+
import { ProfileSettings } from './profile-settings'
|
|
7
|
+
import { UsersSettings } from './users-settings'
|
|
8
|
+
import { useAppConfig } from '@/client/api/app-config'
|
|
9
|
+
import { GeneralSettings } from './general-settings'
|
|
10
|
+
|
|
11
|
+
export function SettingsPage() {
|
|
12
|
+
const { collab } = useAppConfig()
|
|
13
|
+
const account = useAccount()
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
if (account.cloud && !account.demo && account.status === 'signed-out') {
|
|
16
|
+
window.location.replace('/cloud/login')
|
|
17
|
+
}
|
|
18
|
+
}, [account.cloud, account.demo, account.status, account.registered])
|
|
19
|
+
if (account.demo) return <Redirect to="/" replace />
|
|
20
|
+
if (account.status === 'signed-out') return null
|
|
21
|
+
return (
|
|
22
|
+
<div className="min-h-0 flex-1 overflow-y-auto">
|
|
23
|
+
<div className="mx-auto flex w-full max-w-3xl flex-col gap-6 px-6 py-8 sm:px-10 sm:py-12">
|
|
24
|
+
<h1 className="text-xl font-medium">Settings</h1>
|
|
25
|
+
{account.status === 'loading' ? (
|
|
26
|
+
<div className="flex flex-col gap-4" aria-label="Loading settings">
|
|
27
|
+
<Skeleton className="h-7 w-32" />
|
|
28
|
+
<Skeleton className="h-10 w-full max-w-md" />
|
|
29
|
+
<Skeleton className="h-10 w-full max-w-md" />
|
|
30
|
+
</div>
|
|
31
|
+
) : account.status === 'error' ? (
|
|
32
|
+
<div className="flex flex-col items-start gap-3">
|
|
33
|
+
<p role="alert">Couldn’t load your account</p>
|
|
34
|
+
<Button variant="outline" onClick={account.retry}>
|
|
35
|
+
Try again
|
|
36
|
+
</Button>
|
|
37
|
+
</div>
|
|
38
|
+
) : (
|
|
39
|
+
<div className="flex w-full max-w-xl min-w-0 flex-col gap-4">
|
|
40
|
+
<ProfileSettings />
|
|
41
|
+
{collab && account.registered && <UsersSettings />}
|
|
42
|
+
<GeneralSettings />
|
|
43
|
+
</div>
|
|
44
|
+
)}
|
|
45
|
+
</div>
|
|
46
|
+
</div>
|
|
47
|
+
)
|
|
48
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { useId } from 'react'
|
|
2
|
+
import type { ReactNode } from 'react'
|
|
3
|
+
|
|
4
|
+
type SettingsSectionProps = {
|
|
5
|
+
title: string
|
|
6
|
+
description?: ReactNode
|
|
7
|
+
children: ReactNode
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function SettingsSection({ title, description, children }: SettingsSectionProps) {
|
|
11
|
+
const headingId = useId()
|
|
12
|
+
return (
|
|
13
|
+
<section
|
|
14
|
+
aria-labelledby={headingId}
|
|
15
|
+
className="-mx-6 flex min-w-0 flex-col rounded-2xl bg-background p-6 shadow-xs"
|
|
16
|
+
>
|
|
17
|
+
<header className="mb-6 flex flex-col gap-1">
|
|
18
|
+
<h2 id={headingId} className="text-lg font-medium">
|
|
19
|
+
{title}
|
|
20
|
+
</h2>
|
|
21
|
+
{description && <p className="text-sm text-muted-foreground">{description}</p>}
|
|
22
|
+
</header>
|
|
23
|
+
<div className="flex min-w-0 flex-col gap-6">{children}</div>
|
|
24
|
+
</section>
|
|
25
|
+
)
|
|
26
|
+
}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { useState, useSyncExternalStore } from 'react'
|
|
2
|
+
import { IconX } from '@tabler/icons-react'
|
|
3
|
+
import { useIsMutating, useMutation, useQueryClient } from '@tanstack/react-query'
|
|
4
|
+
import { Field, FieldLabel } from '@/ui-components/field'
|
|
5
|
+
import { Button } from '@/client/components/ui/button'
|
|
6
|
+
import { Input } from '@/client/components/ui/input'
|
|
7
|
+
import { Skeleton } from '@/client/components/ui/skeleton'
|
|
8
|
+
import { toast } from '@/client/components/ui/toast'
|
|
9
|
+
import { User } from '@/client/features/collab/components/user'
|
|
10
|
+
import {
|
|
11
|
+
getDirectory,
|
|
12
|
+
normalizeUserProfile,
|
|
13
|
+
subscribeDirectoryStore
|
|
14
|
+
} from '@/client/features/collab/host-state'
|
|
15
|
+
import { useAccount } from '../account/account-provider'
|
|
16
|
+
import { SettingsSection } from './settings-section'
|
|
17
|
+
import {
|
|
18
|
+
accountKeys,
|
|
19
|
+
CloudApiError,
|
|
20
|
+
cancelInvitation,
|
|
21
|
+
inviteMember,
|
|
22
|
+
removeMember
|
|
23
|
+
} from '../account/api'
|
|
24
|
+
import type { CloudSession, TeamMember } from '../account/api'
|
|
25
|
+
|
|
26
|
+
export function UsersSettings() {
|
|
27
|
+
const { team, removingMemberIds, setRemovingMemberIds } = useAccount()
|
|
28
|
+
const directory = useSyncExternalStore(subscribeDirectoryStore, getDirectory, getDirectory)
|
|
29
|
+
const qc = useQueryClient()
|
|
30
|
+
const [email, setEmail] = useState('')
|
|
31
|
+
const mutation = useMutation({
|
|
32
|
+
mutationKey: accountKeys.team,
|
|
33
|
+
mutationFn: (action: () => Promise<unknown>) => action(),
|
|
34
|
+
onSuccess: () => qc.invalidateQueries({ queryKey: accountKeys.team }),
|
|
35
|
+
onError: error => {
|
|
36
|
+
toast.add({ title: 'Couldn’t update users', description: error.message, type: 'error' })
|
|
37
|
+
if (error instanceof CloudApiError && error.status === 401)
|
|
38
|
+
void qc.invalidateQueries({ queryKey: accountKeys.session })
|
|
39
|
+
}
|
|
40
|
+
})
|
|
41
|
+
const pending = useIsMutating({ mutationKey: accountKeys.team }) > 0
|
|
42
|
+
|
|
43
|
+
function act(action: () => Promise<unknown>) {
|
|
44
|
+
if (!pending) mutation.mutate(action)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function remove(member: TeamMember) {
|
|
48
|
+
const userId = qc.getQueryData<CloudSession>(accountKeys.session)?.user.id
|
|
49
|
+
const restore = () => setRemovingMemberIds(ids => ids.filter(id => id !== member.id))
|
|
50
|
+
let undone = false
|
|
51
|
+
setRemovingMemberIds(ids => [...ids, member.id])
|
|
52
|
+
// Keep access intact until the toast closes, so Undo needs no restore API.
|
|
53
|
+
const id = toast.add({
|
|
54
|
+
title: `${member.name.trim() || member.email} removed`,
|
|
55
|
+
timeout: 5000,
|
|
56
|
+
onClose: () => {
|
|
57
|
+
if (undone || qc.getQueryData<CloudSession>(accountKeys.session)?.user.id !== userId) {
|
|
58
|
+
restore()
|
|
59
|
+
return
|
|
60
|
+
}
|
|
61
|
+
void mutation.mutateAsync(() => removeMember(member.id)).then(restore, restore)
|
|
62
|
+
},
|
|
63
|
+
actionProps: {
|
|
64
|
+
children: 'Undo',
|
|
65
|
+
onClick: () => {
|
|
66
|
+
undone = true
|
|
67
|
+
toast.close(id)
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
})
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (team.isPending)
|
|
74
|
+
return (
|
|
75
|
+
<SettingsSection title="Users">
|
|
76
|
+
<div className="flex flex-col gap-4" aria-label="Loading users">
|
|
77
|
+
<Skeleton className="h-6 w-32" />
|
|
78
|
+
<Skeleton className="h-24 w-full" />
|
|
79
|
+
</div>
|
|
80
|
+
</SettingsSection>
|
|
81
|
+
)
|
|
82
|
+
if (team.isError)
|
|
83
|
+
return (
|
|
84
|
+
<SettingsSection title="Users">
|
|
85
|
+
<div className="flex flex-col items-start gap-3">
|
|
86
|
+
<p role="alert">{team.error.message}</p>
|
|
87
|
+
<Button variant="outline" onClick={() => void team.refetch()}>
|
|
88
|
+
Try again
|
|
89
|
+
</Button>
|
|
90
|
+
</div>
|
|
91
|
+
</SettingsSection>
|
|
92
|
+
)
|
|
93
|
+
const { members, invitations, role } = team.data
|
|
94
|
+
const owner = role === 'owner'
|
|
95
|
+
|
|
96
|
+
return (
|
|
97
|
+
<SettingsSection title="Users">
|
|
98
|
+
<ul className="flex flex-col gap-4">
|
|
99
|
+
{members
|
|
100
|
+
.filter(member => !removingMemberIds.includes(member.id))
|
|
101
|
+
.map(member => (
|
|
102
|
+
<li key={member.id} className="flex items-center gap-3">
|
|
103
|
+
<User
|
|
104
|
+
profile={normalizeUserProfile({
|
|
105
|
+
...directory?.find(user => user.id === member.userId),
|
|
106
|
+
id: member.userId,
|
|
107
|
+
name: member.name,
|
|
108
|
+
email: member.email
|
|
109
|
+
})}
|
|
110
|
+
size="sm"
|
|
111
|
+
showYouLabel={member.me}
|
|
112
|
+
description={member.name?.trim() ? member.email : undefined}
|
|
113
|
+
className="flex-1"
|
|
114
|
+
/>
|
|
115
|
+
<span className="text-xs text-muted-foreground">
|
|
116
|
+
{member.role === 'owner' ? 'Owner' : 'Member'}
|
|
117
|
+
</span>
|
|
118
|
+
{owner && !member.me && (
|
|
119
|
+
<Button
|
|
120
|
+
variant="ghost"
|
|
121
|
+
size="sm"
|
|
122
|
+
disabled={pending}
|
|
123
|
+
aria-label={`Remove ${member.email}`}
|
|
124
|
+
onClick={() => remove(member)}
|
|
125
|
+
>
|
|
126
|
+
Remove
|
|
127
|
+
</Button>
|
|
128
|
+
)}
|
|
129
|
+
</li>
|
|
130
|
+
))}
|
|
131
|
+
{owner &&
|
|
132
|
+
invitations.map(invitation => (
|
|
133
|
+
<li
|
|
134
|
+
key={`invitation-${invitation.id}`}
|
|
135
|
+
className="group/invitation flex items-center gap-3"
|
|
136
|
+
tabIndex={0}
|
|
137
|
+
>
|
|
138
|
+
<User
|
|
139
|
+
profile={normalizeUserProfile({ id: invitation.id, email: invitation.email })}
|
|
140
|
+
size="sm"
|
|
141
|
+
description={`Invitation expires ${new Date(invitation.expiresAt).toLocaleDateString()}`}
|
|
142
|
+
className="flex-1 text-muted-foreground [&_[data-slot=avatar]]:opacity-50"
|
|
143
|
+
/>
|
|
144
|
+
<div className="flex shrink-0 items-center gap-2">
|
|
145
|
+
<span className="text-xs text-muted-foreground [@media(hover:hover)]:group-focus-within/invitation:hidden [@media(hover:hover)]:group-hover/invitation:hidden">
|
|
146
|
+
Pending invite
|
|
147
|
+
</span>
|
|
148
|
+
<Button
|
|
149
|
+
variant="ghost"
|
|
150
|
+
size="icon-sm"
|
|
151
|
+
className="text-muted-foreground transition-none group-focus-within/invitation:inline-flex group-hover/invitation:inline-flex [@media(hover:hover)]:hidden"
|
|
152
|
+
disabled={pending}
|
|
153
|
+
aria-label={`Cancel invitation for ${invitation.email}`}
|
|
154
|
+
onClick={() => act(() => cancelInvitation(invitation.id))}
|
|
155
|
+
>
|
|
156
|
+
<IconX stroke={1.75} />
|
|
157
|
+
</Button>
|
|
158
|
+
</div>
|
|
159
|
+
</li>
|
|
160
|
+
))}
|
|
161
|
+
</ul>
|
|
162
|
+
{owner && (
|
|
163
|
+
<form
|
|
164
|
+
className="flex items-end gap-2"
|
|
165
|
+
onSubmit={event => {
|
|
166
|
+
event.preventDefault()
|
|
167
|
+
const value = email.trim()
|
|
168
|
+
if (!value) return
|
|
169
|
+
act(async () => {
|
|
170
|
+
await inviteMember(value)
|
|
171
|
+
setEmail('')
|
|
172
|
+
})
|
|
173
|
+
}}
|
|
174
|
+
>
|
|
175
|
+
<Field className="min-w-0 flex-1">
|
|
176
|
+
<FieldLabel htmlFor="invite-email">Invite someone</FieldLabel>
|
|
177
|
+
<Input
|
|
178
|
+
id="invite-email"
|
|
179
|
+
type="email"
|
|
180
|
+
required
|
|
181
|
+
autoComplete="off"
|
|
182
|
+
placeholder="Email"
|
|
183
|
+
value={email}
|
|
184
|
+
disabled={pending}
|
|
185
|
+
onChange={event => setEmail(event.target.value)}
|
|
186
|
+
/>
|
|
187
|
+
</Field>
|
|
188
|
+
<Button type="submit" disabled={pending}>
|
|
189
|
+
Invite
|
|
190
|
+
</Button>
|
|
191
|
+
</form>
|
|
192
|
+
)}
|
|
193
|
+
</SettingsSection>
|
|
194
|
+
)
|
|
195
|
+
}
|
|
@@ -13,13 +13,10 @@ import { prepareChatAttachments, type ChatSendOptions, type PreparedAttachments
|
|
|
13
13
|
import { useLayoutEffect } from 'react'
|
|
14
14
|
import { useQueryClient, type QueryClient } from '@tanstack/react-query'
|
|
15
15
|
import { toast } from '@/client/components/ui/toast'
|
|
16
|
-
import {
|
|
17
|
-
selectedSessionForTab,
|
|
18
|
-
selectedSessionKey
|
|
19
|
-
} from '@/client/features/chat/sessions/use-selected-session'
|
|
16
|
+
import { cachedSelectedSession } from '@/client/features/chat/sessions/use-selected-session'
|
|
20
17
|
import { useCollabEnabled } from '@/client/features/collab'
|
|
21
18
|
import { useLatestRef } from '@/client/lib/use-latest-ref'
|
|
22
|
-
import type { SelectedSessionScope,
|
|
19
|
+
import type { SelectedSessionScope, WorkspaceTabId } from '@/lib/types'
|
|
23
20
|
import { useCurrentTabId } from './sessions/use-selected-session'
|
|
24
21
|
import { useWorkspaceId } from '@/client/features/workspace/workspace-context'
|
|
25
22
|
import type { AgentAvailability } from '@/client/lib/agent-availability'
|
|
@@ -62,21 +59,8 @@ export function createAppletMessageHandler(
|
|
|
62
59
|
) {
|
|
63
60
|
const pending = new Set<() => void>()
|
|
64
61
|
let disposed = false
|
|
65
|
-
const selectedSession = () =>
|
|
66
|
-
|
|
67
|
-
selectedSessionKey(workspaceId, scope)
|
|
68
|
-
)
|
|
69
|
-
const shared = queryClient.getQueryData<WorkspaceSessionSelection>(
|
|
70
|
-
selectedSessionKey(workspaceId)
|
|
71
|
-
)
|
|
72
|
-
return (
|
|
73
|
-
selectedSessionForTab(
|
|
74
|
-
shared,
|
|
75
|
-
getOptions().tabId,
|
|
76
|
-
scope === 'browser-tab' ? state : undefined
|
|
77
|
-
) ?? null
|
|
78
|
-
)
|
|
79
|
-
}
|
|
62
|
+
const selectedSession = () =>
|
|
63
|
+
cachedSelectedSession(queryClient, workspaceId, getOptions().tabId, scope) ?? null
|
|
80
64
|
|
|
81
65
|
async function handle(event: AppletChatMessage): Promise<void> {
|
|
82
66
|
if (disposed) return
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { SpeedMode } from '@/lib/types'
|
|
1
2
|
import type {
|
|
2
3
|
AttachmentInput,
|
|
3
4
|
AttachmentOrigin,
|
|
@@ -12,16 +13,17 @@ import { composerDraftKey } from '@/lib/session-drafts'
|
|
|
12
13
|
import type { QueryClient } from '@tanstack/react-query'
|
|
13
14
|
|
|
14
15
|
import { workspaceKeys } from '@/client/api/workspace-keys'
|
|
16
|
+
import { changeWorkspaceStateCache } from '@/client/features/workspace/workspace-state'
|
|
15
17
|
import { attachmentKey, liveStore } from '@/client/features/chat/chat-store'
|
|
16
18
|
import { useUiStore } from '@/client/store/ui'
|
|
17
19
|
import type { StagedAttachment } from '@/client/features/chat/composer/attachments/types'
|
|
18
|
-
import { resolveSelectedModel } from '@/client/features/chat/composer/model-order'
|
|
20
|
+
import { resolveSpeedMode, resolveSelectedModel } from '@/client/features/chat/composer/model-order'
|
|
19
21
|
import type { MoiUserMessageOptions } from '@/client/features/workspace/moi-context'
|
|
20
22
|
import { STREAM_RESPONSES } from '@/client/lib/flags'
|
|
21
23
|
import { formatChatTitle } from '@/lib/chat-title'
|
|
22
24
|
import { applyEvent, emptyViewState } from '@/lib/format'
|
|
23
25
|
import { messageAttachmentLimitError } from '@/lib/message-attachments'
|
|
24
|
-
import type { Part,
|
|
26
|
+
import type { Part, SessionSummary, ViewState, WorkspaceHarness, WorkspaceTabId } from '@/lib/types'
|
|
25
27
|
|
|
26
28
|
// Explicit attachments belong to this send, independently of the user's draft.
|
|
27
29
|
export type PreparedAttachments = {
|
|
@@ -163,7 +165,7 @@ export function startOptimisticTurn({
|
|
|
163
165
|
}
|
|
164
166
|
|
|
165
167
|
type StartOptimisticSessionInput = {
|
|
166
|
-
tabId?:
|
|
168
|
+
tabId?: WorkspaceTabId
|
|
167
169
|
queryClient: QueryClient
|
|
168
170
|
workspaceId: string
|
|
169
171
|
sessionId: string
|
|
@@ -179,20 +181,25 @@ export function startOptimisticSession({
|
|
|
179
181
|
text,
|
|
180
182
|
filenames = []
|
|
181
183
|
}: StartOptimisticSessionInput): void {
|
|
184
|
+
// File the chat under its tab now; the server confirms it with the send.
|
|
185
|
+
if (tabId && tabId !== 'overview')
|
|
186
|
+
changeWorkspaceStateCache(queryClient, workspaceId, draft => {
|
|
187
|
+
draft.sessions[sessionId] = { ...draft.sessions[sessionId], tabId }
|
|
188
|
+
})
|
|
182
189
|
const summary = formatChatTitle(text, filenames)
|
|
183
190
|
if (!summary) return
|
|
184
|
-
queryClient.setQueryData<
|
|
185
|
-
{ sessionId, summary, lastModified: Date.now()
|
|
191
|
+
queryClient.setQueryData<SessionSummary[]>(workspaceKeys.sessions(workspaceId), current => [
|
|
192
|
+
{ sessionId, summary, lastModified: Date.now() },
|
|
186
193
|
...(current ?? []).filter(session => session.sessionId !== sessionId)
|
|
187
194
|
])
|
|
188
195
|
}
|
|
189
196
|
|
|
190
197
|
export function resolveChatRunOptions(
|
|
191
|
-
modelsData:
|
|
198
|
+
modelsData: WorkspaceHarness | undefined,
|
|
192
199
|
pickedModel: string | undefined,
|
|
193
200
|
pickedEffort: string | undefined,
|
|
194
|
-
|
|
195
|
-
): { model?: string; effort?: string;
|
|
201
|
+
pickedSpeedMode?: SpeedMode
|
|
202
|
+
): { model?: string; effort?: string; speedMode?: SpeedMode; stream?: true } {
|
|
196
203
|
const models = modelsData?.models
|
|
197
204
|
const savedModel =
|
|
198
205
|
!pickedModel || !models || models.some(candidate => candidate.value === pickedModel)
|
|
@@ -213,15 +220,12 @@ export function resolveChatRunOptions(
|
|
|
213
220
|
pickedEffort && (!modelInfo || (modelInfo.supportedEffortLevels ?? []).includes(pickedEffort))
|
|
214
221
|
? pickedEffort
|
|
215
222
|
: undefined
|
|
216
|
-
const
|
|
217
|
-
pickedFastMode === undefined || !modelInfo || modelInfo.supportsFastMode
|
|
218
|
-
? pickedFastMode
|
|
219
|
-
: false
|
|
223
|
+
const speedMode = modelInfo ? resolveSpeedMode(modelInfo, pickedSpeedMode) : pickedSpeedMode
|
|
220
224
|
const stream = STREAM_RESPONSES && modelsData?.supportsStreaming ? true : undefined
|
|
221
225
|
return {
|
|
222
226
|
model,
|
|
223
227
|
effort,
|
|
224
|
-
...(
|
|
228
|
+
...(speedMode !== undefined ? { speedMode } : {}),
|
|
225
229
|
stream
|
|
226
230
|
}
|
|
227
231
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Model, WorkspaceType } from '@/lib/types'
|
|
1
|
+
import type { SpeedMode, Model, WorkspaceType } from '@/lib/types'
|
|
2
2
|
|
|
3
3
|
export const DEFAULT_EFFORT = 'high'
|
|
4
4
|
|
|
@@ -79,9 +79,13 @@ export function hasEffortChoice(levels: readonly string[]): boolean {
|
|
|
79
79
|
return levels.length > 1
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
export function
|
|
83
|
-
|
|
84
|
-
|
|
82
|
+
export function resolveSpeedMode(
|
|
83
|
+
model: Model,
|
|
84
|
+
selectedSpeedMode: SpeedMode | undefined
|
|
85
|
+
): SpeedMode {
|
|
86
|
+
const mode = selectedSpeedMode ?? 'normal'
|
|
87
|
+
if (mode === 'ultrafast' && model.supportsUltrafastMode) return mode
|
|
88
|
+
return mode !== 'normal' && model.supportsFastMode ? 'fast' : 'normal'
|
|
85
89
|
}
|
|
86
90
|
|
|
87
91
|
export function sortModelsByProviderOrder(models: Model[], provider: WorkspaceType): Model[] {
|