moi-computer 0.12.1-next.1 → 0.12.1-next.3

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 (123) hide show
  1. package/client/AGENTS.md +3 -2
  2. package/client/api/app-config.ts +3 -9
  3. package/client/api/workspace-keys.ts +2 -1
  4. package/client/app/app-provider.tsx +25 -0
  5. package/client/app/app-router.tsx +2 -0
  6. package/client/app/routes/settings-route.tsx +10 -0
  7. package/client/app/routes/workspace-route.tsx +4 -0
  8. package/client/app/shell/sidebar-layout.tsx +38 -51
  9. package/client/dev/index.html +5 -5
  10. package/client/features/account/account-menu.tsx +96 -0
  11. package/client/features/account/account-provider.tsx +142 -0
  12. package/client/features/account/account-test-utils.tsx +293 -0
  13. package/client/features/account/api.ts +142 -0
  14. package/client/features/account/identity.ts +23 -0
  15. package/client/features/applets/api.ts +1 -1
  16. package/client/features/chat/connection/chat-frames.ts +2 -2
  17. package/client/features/chat/sessions/api.ts +1 -1
  18. package/client/features/chat/use-chat.ts +1 -1
  19. package/client/features/collab/applet-api.ts +15 -14
  20. package/client/features/collab/components/cursors.tsx +61 -24
  21. package/client/features/collab/components/presence-avatars.tsx +25 -12
  22. package/client/features/collab/components/presence-frame.tsx +20 -24
  23. package/client/features/collab/components/presence-group.tsx +15 -7
  24. package/client/features/collab/components/user-avatar-group.tsx +21 -8
  25. package/client/features/collab/components/user-avatar.tsx +38 -7
  26. package/client/features/collab/components/user.tsx +31 -12
  27. package/client/features/collab/host-state.ts +24 -7
  28. package/client/features/collab/local-user.ts +1 -1
  29. package/client/features/collab/proxy-user.ts +4 -9
  30. package/client/features/collab/users.ts +0 -5
  31. package/client/features/collab/workspace-users-menu.tsx +3 -3
  32. package/client/features/demo/demo-dialog.tsx +25 -79
  33. package/client/features/dev/collab/collab-playground.tsx +7 -7
  34. package/client/features/dev/collab/local-user-settings.tsx +7 -53
  35. package/client/features/dev/workspace-setup-preview.tsx +43 -16
  36. package/client/features/harness/device-login-steps.tsx +2 -2
  37. package/client/features/home/api.ts +29 -9
  38. package/client/features/home/home-page.tsx +7 -4
  39. package/client/features/scratchpad/scratchpad.tsx +3 -6
  40. package/client/features/settings/api.ts +14 -8
  41. package/client/features/settings/connectors-settings.tsx +3 -3
  42. package/client/features/settings/environment-settings.tsx +3 -3
  43. package/client/features/settings/general-settings.tsx +1 -1
  44. package/client/features/settings/profile-settings.tsx +95 -0
  45. package/client/features/settings/settings-page.tsx +44 -0
  46. package/client/features/settings/settings-section.tsx +26 -0
  47. package/client/features/settings/users-settings.tsx +195 -0
  48. package/client/features/update/update-control.tsx +1 -1
  49. package/client/features/workspace/add/create-workspace-dialog.tsx +5 -2
  50. package/client/features/workspace/api.ts +12 -16
  51. package/client/features/workspace/setup/workspace-login-state.tsx +4 -4
  52. package/client/features/workspace/setup/workspace-setup.tsx +2 -1
  53. package/client/features/workspace/workspace-content.tsx +12 -52
  54. package/client/features/workspace/workspace-frame.tsx +76 -0
  55. package/client/features/workspace/workspace-layout-context.tsx +2 -0
  56. package/client/features/workspace/workspace-pending-screen.tsx +26 -0
  57. package/client/features/workspace/workspace-screen.tsx +3 -3
  58. package/client/index.html +28 -9
  59. package/client/index.tsx +7 -2
  60. package/client/lib/browser-tab-id.ts +4 -0
  61. package/client/lib/user-display-name.ts +6 -0
  62. package/client/main.tsx +12 -6
  63. package/client/runtime/app-context.ts +20 -0
  64. package/client/runtime/use-workspace-events.ts +29 -153
  65. package/client/runtime/workspace-events.ts +151 -0
  66. package/dist/chunk-20ynagd4.js +2 -0
  67. package/dist/chunk-42tde9a6.js +1 -0
  68. package/dist/chunk-9w543s0r.js +2 -0
  69. package/dist/{chunk-q0gbdts4.js → chunk-a5372n61.js} +71 -71
  70. package/dist/chunk-aja9y1vn.js +68 -0
  71. package/dist/chunk-fvcvrh3d.css +1 -0
  72. package/dist/chunk-gtfjw3nx.js +1 -0
  73. package/dist/{chunk-hvh9f5h0.js → chunk-j39y2aky.js} +1 -1
  74. package/dist/chunk-pja30km3.js +1 -0
  75. package/dist/{chunk-d7cbm65e.js → chunk-rm894bc2.js} +1 -1
  76. package/dist/chunk-tevvtfbk.js +10 -0
  77. package/dist/{chunk-jvyvwwv3.js → chunk-tgt9zd0r.js} +1 -1
  78. package/dist/chunk-tv5k5z00.js +1 -0
  79. package/dist/chunk-zq2ae5dx.js +2 -0
  80. package/dist/index.html +29 -10
  81. package/lib/ids.ts +2 -2
  82. package/lib/types.ts +1 -1
  83. package/package.json +1 -1
  84. package/server/api/index.ts +43 -28
  85. package/server/app-config.ts +7 -0
  86. package/server/applets/thumbnails.ts +8 -5
  87. package/server/harness/codex/thread-list.ts +4 -0
  88. package/server/static.ts +4 -2
  89. package/server/vendor.ts +23 -30
  90. package/server/web.ts +4 -2
  91. package/server/workspaces/init.ts +0 -10
  92. package/server/workspaces/layout.ts +11 -6
  93. package/server/workspaces/registry.ts +31 -9
  94. package/dist/chunk-08ndj2rg.js +0 -2
  95. package/dist/chunk-2x040tmg.js +0 -68
  96. package/dist/chunk-3smxq0ts.js +0 -1
  97. package/dist/chunk-68ch5hs8.js +0 -2
  98. package/dist/chunk-9vg3xa81.js +0 -2
  99. package/dist/chunk-c2p00p9j.css +0 -1
  100. package/dist/chunk-cs833y9j.js +0 -1
  101. package/dist/chunk-nwevqe86.js +0 -10
  102. package/dist/chunk-rt30jbcm.js +0 -1
  103. package/dist/chunk-y5y3kj67.js +0 -1
  104. /package/client/vendor/react/{development → 19.2.4/development}/_impl/react-dom-client.js +0 -0
  105. /package/client/vendor/react/{development → 19.2.4/development}/_impl/react-dom.js +0 -0
  106. /package/client/vendor/react/{development → 19.2.4/development}/_impl/react-jsx-dev-runtime.js +0 -0
  107. /package/client/vendor/react/{development → 19.2.4/development}/_impl/react-jsx-runtime.js +0 -0
  108. /package/client/vendor/react/{development → 19.2.4/development}/_impl/react.js +0 -0
  109. /package/client/vendor/react/{development → 19.2.4/development}/react-dom-client.js +0 -0
  110. /package/client/vendor/react/{development → 19.2.4/development}/react-dom.js +0 -0
  111. /package/client/vendor/react/{development → 19.2.4/development}/react-jsx-dev-runtime.js +0 -0
  112. /package/client/vendor/react/{development → 19.2.4/development}/react-jsx-runtime.js +0 -0
  113. /package/client/vendor/react/{development → 19.2.4/development}/react.js +0 -0
  114. /package/client/vendor/react/{production → 19.2.4/production}/_impl/react-dom-client.js +0 -0
  115. /package/client/vendor/react/{production → 19.2.4/production}/_impl/react-dom.js +0 -0
  116. /package/client/vendor/react/{production → 19.2.4/production}/_impl/react-jsx-dev-runtime.js +0 -0
  117. /package/client/vendor/react/{production → 19.2.4/production}/_impl/react-jsx-runtime.js +0 -0
  118. /package/client/vendor/react/{production → 19.2.4/production}/_impl/react.js +0 -0
  119. /package/client/vendor/react/{production → 19.2.4/production}/react-dom-client.js +0 -0
  120. /package/client/vendor/react/{production → 19.2.4/production}/react-dom.js +0 -0
  121. /package/client/vendor/react/{production → 19.2.4/production}/react-jsx-dev-runtime.js +0 -0
  122. /package/client/vendor/react/{production → 19.2.4/production}/react-jsx-runtime.js +0 -0
  123. /package/client/vendor/react/{production → 19.2.4/production}/react.js +0 -0
@@ -36,7 +36,7 @@ function ConnectorsContent({ connectors }: ConnectorsContentProps) {
36
36
  if (connectors.isError) {
37
37
  return (
38
38
  <ConnectorsState>
39
- <p className="text-sm text-muted-foreground">Could not load connectors.</p>
39
+ <p className="text-sm text-muted-foreground">Could not load connectors</p>
40
40
  <Button variant="outline" size="sm" onClick={() => connectors.refetch()}>
41
41
  Retry
42
42
  </Button>
@@ -48,7 +48,7 @@ function ConnectorsContent({ connectors }: ConnectorsContentProps) {
48
48
  return (
49
49
  <ConnectorsState>
50
50
  <IconPlugConnected size={24} stroke={1.5} className="text-muted-foreground" />
51
- <p className="text-sm text-foreground">No connectors configured.</p>
51
+ <p className="text-sm text-foreground">No connectors configured</p>
52
52
  </ConnectorsState>
53
53
  )
54
54
  }
@@ -81,7 +81,7 @@ export function ConnectorsSettings() {
81
81
  return (
82
82
  <SettingsPage
83
83
  title="Connectors"
84
- description="Connectors available to the agent in this workspace."
84
+ description="Connectors available to the agent in this workspace"
85
85
  >
86
86
  <ConnectorsContent connectors={connectors} />
87
87
  </SettingsPage>
@@ -57,7 +57,7 @@ export function EnvironmentSettings() {
57
57
  <IconLoader2 className="size-4 animate-spin" stroke={1.75} />
58
58
  </div>
59
59
  ) : variables.length === 0 ? (
60
- <p className="px-3.5 py-4 text-sm text-muted-foreground">No variables yet.</p>
60
+ <p className="px-3.5 py-4 text-sm text-muted-foreground">No variables yet</p>
61
61
  ) : (
62
62
  variables.map(variable => {
63
63
  const editable = variable.source !== 'dotenv'
@@ -132,8 +132,8 @@ export function EnvironmentSettings() {
132
132
  title="Inherit .env files"
133
133
  description={
134
134
  dotenvFiles > 0
135
- ? `Discovered ${fileCount} ${fileCount === 1 ? 'key' : 'keys'} across ${dotenvFiles} ${dotenvFiles === 1 ? 'file' : 'files'} in this space.`
136
- : 'No .env files found in this space.'
135
+ ? `Discovered ${fileCount} ${fileCount === 1 ? 'key' : 'keys'} across ${dotenvFiles} ${dotenvFiles === 1 ? 'file' : 'files'} in this space`
136
+ : 'No .env files found in this space'
137
137
  }
138
138
  control={
139
139
  <Switch
@@ -32,7 +32,7 @@ export function GeneralSettings() {
32
32
  }
33
33
 
34
34
  return (
35
- <SettingsPage title="General" description="Basic details for this space.">
35
+ <SettingsPage title="General" description="Basic details for this space">
36
36
  <SettingsSection>
37
37
  <SettingsRow
38
38
  title="Path"
@@ -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,44 @@
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
+
9
+ export function SettingsPage() {
10
+ const account = useAccount()
11
+ useEffect(() => {
12
+ if (account.cloud && !account.demo && account.status === 'signed-out') {
13
+ window.location.replace('/cloud/login')
14
+ }
15
+ }, [account.cloud, account.demo, account.status, account.registered])
16
+ if (account.demo) return <Redirect to="/" replace />
17
+ if (account.status === 'signed-out') return null
18
+ return (
19
+ <div className="min-h-0 flex-1 overflow-y-auto">
20
+ <div className="mx-auto flex w-full max-w-3xl flex-col gap-6 px-6 py-8 sm:px-10 sm:py-12">
21
+ <h1 className="text-xl font-medium">Settings</h1>
22
+ {account.status === 'loading' ? (
23
+ <div className="flex flex-col gap-4" aria-label="Loading settings">
24
+ <Skeleton className="h-7 w-32" />
25
+ <Skeleton className="h-10 w-full max-w-md" />
26
+ <Skeleton className="h-10 w-full max-w-md" />
27
+ </div>
28
+ ) : account.status === 'error' ? (
29
+ <div className="flex flex-col items-start gap-3">
30
+ <p role="alert">Couldn’t load your account</p>
31
+ <Button variant="outline" onClick={account.retry}>
32
+ Try again
33
+ </Button>
34
+ </div>
35
+ ) : (
36
+ <div className="flex w-full max-w-xl min-w-0 flex-col gap-4">
37
+ <ProfileSettings />
38
+ {account.registered && <UsersSettings />}
39
+ </div>
40
+ )}
41
+ </div>
42
+ </div>
43
+ )
44
+ }
@@ -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
+ }
@@ -83,7 +83,7 @@ export function UpdateButton({ busy, blocked, label, errorMessage, onClick }: Up
83
83
  <div>
84
84
  <Button
85
85
  type="button"
86
- size="icon"
86
+ size="icon-sm"
87
87
  variant={busy ? 'ghost' : 'default'}
88
88
  aria-label={label}
89
89
  disabled={blocked || busy}
@@ -100,6 +100,7 @@ export function CreateWorkspaceDialog({ trigger }: CreateWorkspaceDialogProps) {
100
100
  {step === 'name' ? (
101
101
  <WorkspaceNameStep
102
102
  name={name}
103
+ showExistingFolder={appConfig.environment === 'local'}
103
104
  validationError={nameError}
104
105
  onNameChange={setName}
105
106
  onSubmit={continueToAgent}
@@ -131,6 +132,7 @@ export function CreateWorkspaceDialog({ trigger }: CreateWorkspaceDialogProps) {
131
132
 
132
133
  type WorkspaceNameStepProps = {
133
134
  name: string
135
+ showExistingFolder: boolean
134
136
  validationError: string | null
135
137
  onNameChange: (name: string) => void
136
138
  onSubmit: () => void
@@ -138,6 +140,7 @@ type WorkspaceNameStepProps = {
138
140
 
139
141
  function WorkspaceNameStep({
140
142
  name,
143
+ showExistingFolder,
141
144
  validationError,
142
145
  onNameChange,
143
146
  onSubmit
@@ -180,9 +183,9 @@ function WorkspaceNameStep({
180
183
  </div>
181
184
 
182
185
  <div className="flex items-center justify-end gap-2">
183
- <ExistingFolderButton />
186
+ {showExistingFolder && <ExistingFolderButton />}
184
187
  <Button type="submit" disabled={!name.trim() || Boolean(validationError)}>
185
- Next
188
+ Continue
186
189
  </Button>
187
190
  </div>
188
191
  </form>
@@ -1,14 +1,10 @@
1
- import { useEffect } from 'react'
2
-
3
1
  import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
4
2
 
5
3
  import { jsonRequest, requestJson, requestVoid } from '@/client/api/http'
6
4
  import { WORKSPACE_RESOURCE_OPTIONS } from '@/client/api/query-options'
7
5
  import { workspaceKeys } from '@/client/api/workspace-keys'
8
- import {
9
- onWorkspaceEventsReconnect,
10
- useWorkspaceEvent
11
- } from '@/client/runtime/use-workspace-events'
6
+ import { BROWSER_TAB_ID } from '@/client/lib/browser-tab-id'
7
+ import { useWorkspaceEvent } from '@/client/runtime/use-workspace-events'
12
8
  import type {
13
9
  WorkspaceAgent,
14
10
  WorkspaceLayout,
@@ -39,13 +35,6 @@ export function useWorkspaceLayout(workspaceId: string) {
39
35
  // focus refetches pick up model changes after a CLI update.
40
36
  export function useWorkspaceAgent(workspaceId: string) {
41
37
  const queryClient = useQueryClient()
42
- useEffect(
43
- () =>
44
- onWorkspaceEventsReconnect(() => {
45
- void queryClient.invalidateQueries({ queryKey: workspaceKeys.agent(workspaceId) })
46
- }),
47
- [queryClient, workspaceId]
48
- )
49
38
  useWorkspaceEvent(event => {
50
39
  if (event.type === 'harness:updated' && event.workspaceId === workspaceId) {
51
40
  queryClient.setQueryData<WorkspaceAgent>(workspaceKeys.agent(workspaceId), prev =>
@@ -62,8 +51,15 @@ export function useWorkspaceAgent(workspaceId: string) {
62
51
  queryFn: async ({ signal }) => {
63
52
  const key = workspaceKeys.agent(workspaceId)
64
53
  const previous = queryClient.getQueryData<WorkspaceAgent>(key)
54
+ // `refresh=true` makes the server re-probe the CLI (three child
55
+ // processes, seconds) instead of answering from its 30s cache. Only
56
+ // worth it when the last snapshot was a failure: the user may have
57
+ // signed in or installed the agent since, and that is also the only
58
+ // state with a "check again" button. A working agent is reconfirmed
59
+ // from the cache.
60
+ const refresh = previous !== undefined && previous.availability.status !== 'available'
65
61
  const result = await requestJson<WorkspaceAgent>(
66
- `/api/workspaces/${workspaceId}/agent?refresh=true`,
62
+ `/api/workspaces/${workspaceId}/agent${refresh ? '?refresh=true' : ''}`,
67
63
  { signal }
68
64
  )
69
65
  // A live auth event received during this request is newer than its snapshot.
@@ -136,11 +132,11 @@ export function useSaveLayout(workspaceId: string) {
136
132
  mutationFn: layout =>
137
133
  requestVoid(
138
134
  `/api/workspaces/${workspaceId}`,
139
- jsonRequest('PUT', layout),
135
+ jsonRequest('PUT', { ...layout, origin: BROWSER_TAB_ID }),
140
136
  'Failed to save layout'
141
137
  ),
142
138
  onSuccess: () => {
143
- queryClient.invalidateQueries({ queryKey: workspaceKeys.preview(workspaceId) })
139
+ queryClient.invalidateQueries({ queryKey: workspaceKeys.previews })
144
140
  }
145
141
  })
146
142
  }
@@ -76,7 +76,7 @@ export function WorkspaceLoginState({
76
76
  <Spinner className="size-6 self-center text-muted-foreground" stroke={1.5} />
77
77
  ) : checkError ? (
78
78
  <div role="alert" className="flex flex-col items-start gap-2">
79
- <p>Could not check agent login status.</p>
79
+ <p>Could not check agent sign-in status.</p>
80
80
  <Button
81
81
  variant="secondary"
82
82
  disabled={auth.isFetching}
@@ -104,8 +104,8 @@ export function WorkspaceLoginState({
104
104
  <>
105
105
  <p role="status" className="text-sm text-muted-foreground">
106
106
  {pending.codeUrl && !waitingForBrowser
107
- ? 'Sign in to get the authorization code.'
108
- : 'Sign in in your browser, then come back to Moi. Your workspace will open once you’re connected.'}
107
+ ? `Sign in to ${name} to get the authorization code.`
108
+ : `Sign in to ${name}, then come back to Moi. Your workspace will open once you’re connected.`}
109
109
  </p>
110
110
  <a
111
111
  className={buttonVariants({ variant: 'secondary' })}
@@ -113,7 +113,7 @@ export function WorkspaceLoginState({
113
113
  target="_blank"
114
114
  rel="noopener noreferrer"
115
115
  >
116
- Open browser
116
+ Open {name}
117
117
  </a>
118
118
  {waitingForBrowser && pending.codeUrl && (
119
119
  <Button variant="ghost" onClick={() => setManualLogin(true)}>
@@ -72,6 +72,7 @@ export function useWorkspaceSetup(
72
72
  ) : (
73
73
  (recovery ?? <WorkspaceLoadingState />)
74
74
  ),
75
- ready: ready && !welcoming
75
+ ready: ready && !welcoming,
76
+ setupRequired: welcoming || !!recovery
76
77
  }
77
78
  }