moi-computer 0.12.1-next.3 → 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 +4 -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 +1 -1
- package/client/app/routes/workspace-route.tsx +21 -19
- 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-test-utils.tsx +4 -3
- package/client/features/app-settings/api.ts +33 -0
- package/client/features/app-settings/general-settings.tsx +39 -0
- package/client/features/{settings → app-settings}/settings-page.tsx +5 -1
- 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/workspace-users-menu.tsx +1 -1
- package/client/features/demo/demo-dialog.tsx +11 -3
- 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/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 +6 -5
- 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}/general-settings.tsx +76 -2
- 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/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 +71 -62
- 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 +163 -126
- package/server/api/onboarding.ts +46 -0
- package/server/app-config.ts +16 -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 +22 -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 -6
- package/server/workspaces/layout.ts +3 -0
- package/server/workspaces/registry.ts +27 -1
- 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-20ynagd4.js +0 -2
- package/dist/chunk-42tde9a6.js +0 -1
- package/dist/chunk-9w543s0r.js +0 -2
- package/dist/chunk-a5372n61.js +0 -546
- package/dist/chunk-aja9y1vn.js +0 -68
- package/dist/chunk-fvcvrh3d.css +0 -1
- package/dist/chunk-gtfjw3nx.js +0 -1
- package/dist/chunk-j39y2aky.js +0 -14
- package/dist/chunk-pcnahct1.js +0 -5
- package/dist/chunk-pja30km3.js +0 -1
- package/dist/chunk-rm894bc2.js +0 -2
- package/dist/chunk-tevvtfbk.js +0 -10
- package/dist/chunk-tgt9zd0r.js +0 -2
- package/dist/chunk-tv5k5z00.js +0 -1
- package/dist/chunk-zq2ae5dx.js +0 -2
- package/lib/experimental.ts +0 -14
- package/workspace/.claude/skills/moi-workspace/references/DESIGN.md +0 -157
- /package/client/features/{settings → app-settings}/profile-settings.tsx +0 -0
- /package/client/features/{settings → app-settings}/settings-section.tsx +0 -0
- /package/client/features/{settings → app-settings}/users-settings.tsx +0 -0
- /package/client/features/{settings → workspace/settings}/connectors-settings.tsx +0 -0
- /package/client/features/{settings → workspace/settings}/environment-settings.tsx +0 -0
- /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
|
@@ -11,13 +11,16 @@ import {
|
|
|
11
11
|
startOptimisticSession
|
|
12
12
|
} from '@/client/features/chat/chat-send'
|
|
13
13
|
import {
|
|
14
|
-
optimisticallySetSelectedSession,
|
|
15
14
|
renameSelectedSessionInCache,
|
|
15
|
+
setSelectedSessionInCache,
|
|
16
16
|
usePinnedSession
|
|
17
17
|
} from '@/client/features/chat/sessions/use-selected-session'
|
|
18
|
-
import {
|
|
18
|
+
import {
|
|
19
|
+
changeWorkspaceStateCache,
|
|
20
|
+
getCachedWorkspaceState
|
|
21
|
+
} from '@/client/features/workspace/workspace-state'
|
|
19
22
|
import { useCollabEnabled } from '@/client/features/collab'
|
|
20
|
-
import {
|
|
23
|
+
import { useWorkspaceHarness } from '@/client/features/workspace/api'
|
|
21
24
|
import { useWorkspaceLayoutCtx } from '@/client/features/workspace/workspace-layout-context'
|
|
22
25
|
import {
|
|
23
26
|
useCreateView,
|
|
@@ -26,7 +29,7 @@ import {
|
|
|
26
29
|
useSubmitView
|
|
27
30
|
} from '@/client/features/views/api'
|
|
28
31
|
import { recoverViewSubmission } from './view-submission'
|
|
29
|
-
import type { PendingView
|
|
32
|
+
import type { PendingView } from '@/lib/types'
|
|
30
33
|
import { viewTabId } from '@/lib/workspace-tabs'
|
|
31
34
|
|
|
32
35
|
export function useViewActions() {
|
|
@@ -35,7 +38,7 @@ export function useViewActions() {
|
|
|
35
38
|
const selectionScope = collabEnabled ? 'browser-tab' : 'shared'
|
|
36
39
|
const { workspaceId, layout } = useWorkspaceLayoutCtx()
|
|
37
40
|
const { pinnedSessionId } = usePinnedSession()
|
|
38
|
-
const modelData =
|
|
41
|
+
const modelData = useWorkspaceHarness(workspaceId).data
|
|
39
42
|
const createMutation = useCreateView(workspaceId)
|
|
40
43
|
const saveMutation = useSaveViewDraft(workspaceId)
|
|
41
44
|
const submitMutation = useSubmitView(workspaceId)
|
|
@@ -64,7 +67,7 @@ export function useViewActions() {
|
|
|
64
67
|
})
|
|
65
68
|
if (!pinnedSessionId) {
|
|
66
69
|
moveChatDraft(workspaceId, draftId, sessionId)
|
|
67
|
-
|
|
70
|
+
setSelectedSessionInCache(
|
|
68
71
|
queryClient,
|
|
69
72
|
workspaceId,
|
|
70
73
|
sessionId,
|
|
@@ -77,23 +80,19 @@ export function useViewActions() {
|
|
|
77
80
|
attachments
|
|
78
81
|
)
|
|
79
82
|
|
|
80
|
-
const config = queryClient
|
|
81
|
-
|
|
82
|
-
)?.config
|
|
83
|
-
const { model, effort, fastMode, stream } = resolveChatRunOptions(
|
|
83
|
+
const config = getCachedWorkspaceState(queryClient, workspaceId)?.sessions[sessionId]?.config
|
|
84
|
+
const { model, effort, speedMode, stream } = resolveChatRunOptions(
|
|
84
85
|
modelData,
|
|
85
86
|
config?.model ?? layout.selectedModel,
|
|
86
87
|
config?.effort ?? layout.selectedEffort,
|
|
87
|
-
config?.
|
|
88
|
+
config?.speedMode ?? layout.selectedSpeedMode
|
|
88
89
|
)
|
|
89
90
|
|
|
90
|
-
queryClient
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
)
|
|
96
|
-
)
|
|
91
|
+
changeWorkspaceStateCache(queryClient, workspaceId, draft => {
|
|
92
|
+
const view = draft.pendingViews[pendingView.id]
|
|
93
|
+
if (view?.status === 'draft')
|
|
94
|
+
Object.assign(view, { status: 'starting', requirements: text, buildSessionId: sessionId })
|
|
95
|
+
})
|
|
97
96
|
|
|
98
97
|
try {
|
|
99
98
|
const result = await submitMutation.mutateAsync({
|
|
@@ -109,13 +108,13 @@ export function useViewActions() {
|
|
|
109
108
|
: {}),
|
|
110
109
|
model,
|
|
111
110
|
effort,
|
|
112
|
-
|
|
111
|
+
speedMode,
|
|
113
112
|
stream
|
|
114
113
|
})
|
|
115
114
|
moveChatDraft(workspaceId, sessionId, result.sessionId)
|
|
116
115
|
renameSelectedSessionInCache(queryClient, workspaceId, sessionId, result.sessionId)
|
|
117
116
|
if (!pinnedSessionId)
|
|
118
|
-
|
|
117
|
+
setSelectedSessionInCache(
|
|
119
118
|
queryClient,
|
|
120
119
|
workspaceId,
|
|
121
120
|
result.sessionId,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IconArticle, type TablerIcon } from '@tabler/icons-react'
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { resolveIdentityIcon } from '@/client/lib/identity-icon-registry'
|
|
4
4
|
import type { ViewInfo } from '@/lib/types'
|
|
5
5
|
|
|
6
6
|
export function getViewLabel(view: ViewInfo): string {
|
|
@@ -8,5 +8,5 @@ export function getViewLabel(view: ViewInfo): string {
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
export function getViewIcon(view: ViewInfo): TablerIcon {
|
|
11
|
-
return
|
|
11
|
+
return resolveIdentityIcon(view.icon) ?? IconArticle
|
|
12
12
|
}
|
|
@@ -1,28 +1,22 @@
|
|
|
1
1
|
import type { QueryClient } from '@tanstack/react-query'
|
|
2
2
|
import { requestJson } from '@/client/api/http'
|
|
3
3
|
import { workspaceKeys } from '@/client/api/workspace-keys'
|
|
4
|
-
import { appUiKeys } from '@/client/api/app-ui-keys'
|
|
5
4
|
import {
|
|
6
5
|
readSelectedSession,
|
|
7
|
-
writeSelectedSession
|
|
6
|
+
writeSelectedSession,
|
|
7
|
+
type BrowserTabSelection
|
|
8
8
|
} from '@/client/features/chat/sessions/browser-tab-state'
|
|
9
|
-
import {
|
|
9
|
+
import { browserTabSelectionKey } from '@/client/features/chat/sessions/use-selected-session'
|
|
10
10
|
import { moveChatDraft } from '@/client/features/chat/chat-send'
|
|
11
11
|
import { liveStore } from '@/client/features/chat/chat-store'
|
|
12
|
+
import {
|
|
13
|
+
getCachedWorkspaceState,
|
|
14
|
+
receiveWorkspaceState
|
|
15
|
+
} from '@/client/features/workspace/workspace-state'
|
|
12
16
|
import { useUiStore } from '@/client/store/ui'
|
|
13
17
|
import { composerDraftKey, draftSessionId } from '@/lib/session-drafts'
|
|
14
18
|
import { viewTabId } from '@/lib/workspace-tabs'
|
|
15
|
-
import type {
|
|
16
|
-
PendingView,
|
|
17
|
-
SelectedSessionScope,
|
|
18
|
-
SessionInfo,
|
|
19
|
-
ViewInfo,
|
|
20
|
-
WorkspaceSessionSelection
|
|
21
|
-
} from '@/lib/types'
|
|
22
|
-
|
|
23
|
-
function pendingView(view: ViewInfo | undefined): PendingView | undefined {
|
|
24
|
-
return view?.status === 'compiled' ? undefined : view
|
|
25
|
-
}
|
|
19
|
+
import type { SelectedSessionScope, SessionSummary, WorkspaceState } from '@/lib/types'
|
|
26
20
|
|
|
27
21
|
// A failed HTTP response does not prove startup failed. Refresh the server's
|
|
28
22
|
// state before restoring the fresh composer; never replay the request.
|
|
@@ -35,52 +29,45 @@ export async function recoverViewSubmission(
|
|
|
35
29
|
pinned: boolean,
|
|
36
30
|
selectionScope: SelectedSessionScope = 'shared'
|
|
37
31
|
) {
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
)
|
|
43
|
-
let target = cachedView?.executionSessionId ?? sessionId
|
|
32
|
+
const tabId = viewTabId(viewId)
|
|
33
|
+
let target =
|
|
34
|
+
getCachedWorkspaceState(queryClient, workspaceId)?.pendingViews[viewId]?.buildSessionId ??
|
|
35
|
+
sessionId
|
|
44
36
|
try {
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
requestJson<WorkspaceSessionSelection>(`/api/workspaces/${workspaceId}/selected-session`)
|
|
48
|
-
])
|
|
49
|
-
const view = pendingView(views.find(view => view.id === viewId))
|
|
37
|
+
const state = await requestJson<WorkspaceState>(`/api/workspaces/${workspaceId}/state`)
|
|
38
|
+
const view = state.pendingViews[viewId]
|
|
50
39
|
if (!pinned && view?.status === 'draft') {
|
|
51
|
-
target = draftSessionId(
|
|
52
|
-
queryClient.setQueryData<
|
|
40
|
+
target = draftSessionId(tabId)
|
|
41
|
+
queryClient.setQueryData<SessionSummary[]>(workspaceKeys.sessions(workspaceId), sessions =>
|
|
53
42
|
sessions?.filter(session => session.sessionId !== sessionId)
|
|
54
43
|
)
|
|
55
44
|
queryClient.removeQueries({ queryKey: workspaceKeys.events(workspaceId, sessionId) })
|
|
56
45
|
} else {
|
|
57
46
|
target =
|
|
58
|
-
view?.
|
|
59
|
-
(pinned ?
|
|
47
|
+
view?.buildSessionId ??
|
|
48
|
+
(pinned ? state.pinnedSessionId : state.selected[tabId]) ??
|
|
60
49
|
sessionId
|
|
61
50
|
}
|
|
62
51
|
moveChatDraft(workspaceId, sessionId, target)
|
|
63
52
|
if (view?.status === 'draft' || view?.status === 'failed')
|
|
64
53
|
liveStore.getState().setActivity(workspaceId, target, 'idle')
|
|
65
|
-
queryClient
|
|
66
|
-
queryClient.setQueryData(appUiKeys.sessionSelection(workspaceId), selection)
|
|
54
|
+
receiveWorkspaceState(queryClient, workspaceId, state)
|
|
67
55
|
if (selectionScope === 'browser-tab' && !pinned) {
|
|
68
56
|
const local =
|
|
69
|
-
queryClient.getQueryData<
|
|
70
|
-
|
|
71
|
-
) ?? readSelectedSession(workspaceId)
|
|
57
|
+
queryClient.getQueryData<BrowserTabSelection>(browserTabSelectionKey(workspaceId)) ??
|
|
58
|
+
readSelectedSession(workspaceId)
|
|
72
59
|
const selected = { ...local.selected }
|
|
73
|
-
if (view?.status === 'draft') delete selected[
|
|
74
|
-
else selected[
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
60
|
+
if (view?.status === 'draft') delete selected[tabId]
|
|
61
|
+
else selected[tabId] = target
|
|
62
|
+
queryClient.setQueryData<BrowserTabSelection>(browserTabSelectionKey(workspaceId), {
|
|
63
|
+
selected
|
|
64
|
+
})
|
|
65
|
+
writeSelectedSession(workspaceId, { selected })
|
|
78
66
|
}
|
|
79
67
|
} catch {
|
|
80
68
|
moveChatDraft(workspaceId, sessionId, target)
|
|
81
69
|
// Offline: retain the draft at its current identity until state can refresh.
|
|
82
|
-
void queryClient.invalidateQueries({ queryKey: workspaceKeys.
|
|
83
|
-
void queryClient.invalidateQueries({ queryKey: appUiKeys.sessionSelection(workspaceId) })
|
|
70
|
+
void queryClient.invalidateQueries({ queryKey: workspaceKeys.state(workspaceId) })
|
|
84
71
|
}
|
|
85
72
|
const draftKey = composerDraftKey(workspaceId, target)
|
|
86
73
|
const ui = useUiStore.getState()
|
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
import { useMutation,
|
|
1
|
+
import { useMutation, useQueryClient } from '@tanstack/react-query'
|
|
2
2
|
|
|
3
3
|
import { jsonRequest, requestJson } from '@/client/api/http'
|
|
4
4
|
import { workspaceKeys } from '@/client/api/workspace-keys'
|
|
5
5
|
import { useUiStore } from '@/client/store/ui'
|
|
6
|
-
import type {
|
|
7
|
-
DiscoveredWorkspace,
|
|
8
|
-
HarnessInstallations,
|
|
9
|
-
WorkspaceEntry,
|
|
10
|
-
WorkspaceType
|
|
11
|
-
} from '@/lib/types'
|
|
6
|
+
import type { DiscoveredWorkspace, WorkspaceEntry, WorkspaceType } from '@/lib/types'
|
|
12
7
|
|
|
13
8
|
export function upsertWorkspaceEntry(
|
|
14
9
|
entries: WorkspaceEntry[] | undefined,
|
|
@@ -42,23 +37,8 @@ export type ImportWorkspaceInput = {
|
|
|
42
37
|
type: WorkspaceType
|
|
43
38
|
}
|
|
44
39
|
|
|
45
|
-
export type WorkspaceCreationInfo = {
|
|
46
|
-
installed: HarnessInstallations
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export function useWorkspaceCreationInfo() {
|
|
50
|
-
return useQuery<WorkspaceCreationInfo>({
|
|
51
|
-
queryKey: workspaceKeys.creationInfo,
|
|
52
|
-
// Installations can change while the app is open (the user installs the
|
|
53
|
-
// agent CLI) — refetch on mount instead of caching forever.
|
|
54
|
-
queryFn: () => requestJson('/api/workspaces/create'),
|
|
55
|
-
staleTime: 30_000,
|
|
56
|
-
refetchOnMount: 'always'
|
|
57
|
-
})
|
|
58
|
-
}
|
|
59
|
-
|
|
60
40
|
export type CreateWorkspaceInput = {
|
|
61
|
-
name
|
|
41
|
+
name?: string
|
|
62
42
|
type: WorkspaceType
|
|
63
43
|
}
|
|
64
44
|
|
|
@@ -2,7 +2,8 @@ import { type FormEvent, type ReactElement, useState } from 'react'
|
|
|
2
2
|
|
|
3
3
|
import { useLocation } from 'wouter'
|
|
4
4
|
|
|
5
|
-
import { useCreateWorkspace
|
|
5
|
+
import { useCreateWorkspace } from '@/client/features/workspace/add/api'
|
|
6
|
+
import { useHarnessStatuses } from '@/client/features/harness/api'
|
|
6
7
|
import { useAppConfig } from '@/client/api/app-config'
|
|
7
8
|
import { Button } from '@/client/components/ui/button'
|
|
8
9
|
import {
|
|
@@ -13,7 +14,7 @@ import {
|
|
|
13
14
|
} from '@/client/components/ui/dialog'
|
|
14
15
|
import { Input } from '@/client/components/ui/input'
|
|
15
16
|
import { Tooltip, TooltipContent, TooltipTrigger } from '@/client/components/ui/tooltip'
|
|
16
|
-
import {
|
|
17
|
+
import { validateWorkspaceName } from '@/lib/workspace-name'
|
|
17
18
|
import { WORKSPACE_TYPE_ORDER } from '@/lib/workspace-types'
|
|
18
19
|
import type { WorkspaceType } from '@/lib/types'
|
|
19
20
|
|
|
@@ -34,7 +35,7 @@ const DEFAULT_WORKSPACE_TYPE = WORKSPACE_TYPE_ORDER[0]
|
|
|
34
35
|
export function CreateWorkspaceDialog({ trigger }: CreateWorkspaceDialogProps) {
|
|
35
36
|
const [, navigate] = useLocation()
|
|
36
37
|
const appConfig = useAppConfig()
|
|
37
|
-
const info =
|
|
38
|
+
const info = useHarnessStatuses()
|
|
38
39
|
const createMutation = useCreateWorkspace()
|
|
39
40
|
|
|
40
41
|
const [open, setOpen] = useState(false)
|
|
@@ -43,10 +44,10 @@ export function CreateWorkspaceDialog({ trigger }: CreateWorkspaceDialogProps) {
|
|
|
43
44
|
const [name, setName] = useState('')
|
|
44
45
|
|
|
45
46
|
const trimmedName = name.trim()
|
|
46
|
-
const nameError = trimmedName ?
|
|
47
|
+
const nameError = trimmedName ? validateWorkspaceName(trimmedName) : null
|
|
47
48
|
const isCreating = createMutation.isPending
|
|
48
49
|
const isChecking = info.isPending || info.isFetching
|
|
49
|
-
const installed = info.isError ? undefined : info.data
|
|
50
|
+
const installed = info.isError ? undefined : info.data
|
|
50
51
|
const options = getWorkspaceAgentOptions(installed)
|
|
51
52
|
const selectedAvailable = options.some(option => option.type === type && !option.disabled)
|
|
52
53
|
const detectionError = !isChecking && !installed ? 'Could not check installed agents.' : undefined
|
|
@@ -6,7 +6,7 @@ import { workspaceDisplayName } from '@/client/features/workspace/workspace-pres
|
|
|
6
6
|
import type { WorkspaceType } from '@/lib/types'
|
|
7
7
|
|
|
8
8
|
import { WorkspaceAgentSelector } from './workspace-agent-selector'
|
|
9
|
-
import {
|
|
9
|
+
import { useHarnessStatuses } from '@/client/features/harness/api'
|
|
10
10
|
import { getWorkspaceAgentOptions } from './workspace-agent-options'
|
|
11
11
|
import { WorkspaceDialogContent } from './workspace-dialog-content'
|
|
12
12
|
import type { WorkspaceImportChoice } from './use-workspace-import'
|
|
@@ -29,9 +29,9 @@ export function ImportWorkspaceDialog({
|
|
|
29
29
|
onReset
|
|
30
30
|
}: ImportWorkspaceDialogProps) {
|
|
31
31
|
const [open, setOpen] = useState(true)
|
|
32
|
-
const info =
|
|
32
|
+
const info = useHarnessStatuses()
|
|
33
33
|
const isChecking = info.isPending || info.isFetching
|
|
34
|
-
const installed = info.isError ? undefined : info.data
|
|
34
|
+
const installed = info.isError ? undefined : info.data
|
|
35
35
|
const options = getWorkspaceAgentOptions(installed, choice.workspace.types)
|
|
36
36
|
const detectionError = !isChecking && !installed ? 'Could not check installed agents.' : undefined
|
|
37
37
|
const canImport =
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { workspaceTypeDescription } from '@/client/features/workspace/workspace-presentation'
|
|
2
2
|
import { HARNESS_INSTRUCTIONS } from '@/lib/harness-instructions'
|
|
3
|
-
import type {
|
|
3
|
+
import type { HarnessStatuses, WorkspaceType } from '@/lib/types'
|
|
4
4
|
import { WORKSPACE_TYPE_ORDER } from '@/lib/workspace-types'
|
|
5
5
|
|
|
6
6
|
type WorkspaceAgentConfig = {
|
|
@@ -14,25 +14,24 @@ const workspaceAgents: Record<WorkspaceType, WorkspaceAgentConfig> = {
|
|
|
14
14
|
hermes: { importOnly: true }
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
export type WorkspaceAgentOption
|
|
18
|
-
|
|
19
|
-
description: string
|
|
20
|
-
disabled: boolean
|
|
21
|
-
disabledReason?: string
|
|
22
|
-
disabledCommand?: string
|
|
23
|
-
}
|
|
17
|
+
export type { HarnessOption as WorkspaceAgentOption } from '@/client/features/harness/harness-selector'
|
|
18
|
+
import type { HarnessOption as WorkspaceAgentOption } from '@/client/features/harness/harness-selector'
|
|
24
19
|
|
|
25
20
|
export function getWorkspaceAgentOptions(
|
|
26
|
-
|
|
21
|
+
statuses?: HarnessStatuses,
|
|
27
22
|
detectedTypes: WorkspaceType[] = []
|
|
28
23
|
): WorkspaceAgentOption[] {
|
|
29
|
-
if (!
|
|
24
|
+
if (!statuses) return []
|
|
25
|
+
const installed = (type: WorkspaceType) => {
|
|
26
|
+
const availability = statuses[type].availability
|
|
27
|
+
return availability.status !== 'unavailable' || availability.code !== 'not-installed'
|
|
28
|
+
}
|
|
30
29
|
return WORKSPACE_TYPE_ORDER.filter(
|
|
31
|
-
type => installed
|
|
30
|
+
type => installed(type) || !workspaceAgents[type].importOnly
|
|
32
31
|
).map(type => {
|
|
33
32
|
const config = workspaceAgents[type]
|
|
34
33
|
const instruction = HARNESS_INSTRUCTIONS[type]
|
|
35
|
-
const disabled = !installed
|
|
34
|
+
const disabled = !installed(type) || (config.importOnly && !detectedTypes.includes(type))
|
|
36
35
|
return {
|
|
37
36
|
type,
|
|
38
37
|
description: workspaceTypeDescription[type],
|
|
@@ -1,15 +1,9 @@
|
|
|
1
|
+
import { HarnessSelector } from '@/client/features/harness/harness-selector'
|
|
1
2
|
import { type ReactNode, useEffect } from 'react'
|
|
2
3
|
|
|
3
|
-
import { IconCircleCheckFilled } from '@tabler/icons-react'
|
|
4
|
-
|
|
5
4
|
import { Button } from '@/client/components/ui/button'
|
|
6
|
-
import { workspaceProviderIcon } from '@/client/components/shared/workspace-icon'
|
|
7
5
|
import { DialogDescription, DialogTitle } from '@/client/components/ui/dialog'
|
|
8
6
|
import { Skeleton } from '@/client/components/ui/skeleton'
|
|
9
|
-
import { Tooltip, TooltipContent, TooltipTrigger } from '@/client/components/ui/tooltip'
|
|
10
|
-
import { workspaceTypeLabel } from '@/client/features/workspace/workspace-presentation'
|
|
11
|
-
import { cn } from '@/client/lib/cn'
|
|
12
|
-
import { useUiStore } from '@/client/store/ui'
|
|
13
7
|
import type { WorkspaceType } from '@/lib/types'
|
|
14
8
|
|
|
15
9
|
import {
|
|
@@ -17,7 +11,7 @@ import {
|
|
|
17
11
|
type WorkspaceAgentOption
|
|
18
12
|
} from './workspace-agent-options'
|
|
19
13
|
|
|
20
|
-
const WORKSPACE_AGENT_DESCRIPTION = 'Choose
|
|
14
|
+
const WORKSPACE_AGENT_DESCRIPTION = 'Choose the agent to build the workspace'
|
|
21
15
|
type WorkspaceAgentSelectorProps = {
|
|
22
16
|
title: string
|
|
23
17
|
selectedType: WorkspaceType
|
|
@@ -47,15 +41,8 @@ export function WorkspaceAgentSelector({
|
|
|
47
41
|
onTypeChange,
|
|
48
42
|
onSubmit
|
|
49
43
|
}: WorkspaceAgentSelectorProps) {
|
|
50
|
-
const hasSentMessageFromMoi = useUiStore(state => state.hasSentMessageFromMoi)
|
|
51
44
|
const selectableType = resolveWorkspaceAgentSelection(options, selectedType)
|
|
52
45
|
const selectedUnavailable = selectableType !== selectedType
|
|
53
|
-
const subscriptionTip =
|
|
54
|
-
selectableType === 'claude-code'
|
|
55
|
-
? 'Tip: you can use your existing Claude subscription in Moi'
|
|
56
|
-
: selectableType === 'codex'
|
|
57
|
-
? 'Tip: you can use your existing ChatGPT subscription in Moi'
|
|
58
|
-
: undefined
|
|
59
46
|
|
|
60
47
|
useEffect(() => {
|
|
61
48
|
if (!isPending && selectableType && selectedUnavailable) onTypeChange(selectableType)
|
|
@@ -79,16 +66,13 @@ export function WorkspaceAgentSelector({
|
|
|
79
66
|
<Skeleton className="h-32 min-w-32 flex-1" />
|
|
80
67
|
</div>
|
|
81
68
|
) : (
|
|
82
|
-
<
|
|
69
|
+
<HarnessSelector
|
|
83
70
|
disabled={isPending}
|
|
84
71
|
options={options}
|
|
85
72
|
selectedType={selectedUnavailable ? undefined : selectedType}
|
|
86
73
|
onTypeChange={onTypeChange}
|
|
87
74
|
/>
|
|
88
75
|
)}
|
|
89
|
-
{!hasSentMessageFromMoi && subscriptionTip && (
|
|
90
|
-
<p className="w-0 min-w-full text-sm text-muted-foreground">{subscriptionTip}</p>
|
|
91
|
-
)}
|
|
92
76
|
</div>
|
|
93
77
|
|
|
94
78
|
{errorMessage && (
|
|
@@ -110,116 +94,3 @@ export function WorkspaceAgentSelector({
|
|
|
110
94
|
</div>
|
|
111
95
|
)
|
|
112
96
|
}
|
|
113
|
-
|
|
114
|
-
type WorkspaceAgentCardsProps = {
|
|
115
|
-
disabled: boolean
|
|
116
|
-
options: WorkspaceAgentOption[]
|
|
117
|
-
selectedType?: WorkspaceType
|
|
118
|
-
onTypeChange: (type: WorkspaceType) => void
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
function WorkspaceAgentCards({
|
|
122
|
-
disabled,
|
|
123
|
-
options,
|
|
124
|
-
selectedType,
|
|
125
|
-
onTypeChange
|
|
126
|
-
}: WorkspaceAgentCardsProps) {
|
|
127
|
-
return (
|
|
128
|
-
<fieldset
|
|
129
|
-
disabled={disabled}
|
|
130
|
-
aria-label="Agent"
|
|
131
|
-
className="flex min-w-0 flex-wrap justify-center gap-2"
|
|
132
|
-
>
|
|
133
|
-
{options.map(option => (
|
|
134
|
-
<WorkspaceAgentOptionButton
|
|
135
|
-
key={option.type}
|
|
136
|
-
option={option}
|
|
137
|
-
selected={selectedType === option.type}
|
|
138
|
-
onSelect={onTypeChange}
|
|
139
|
-
/>
|
|
140
|
-
))}
|
|
141
|
-
</fieldset>
|
|
142
|
-
)
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
type WorkspaceAgentOptionButtonProps = {
|
|
146
|
-
option: WorkspaceAgentOption
|
|
147
|
-
selected: boolean
|
|
148
|
-
onSelect: (type: WorkspaceType) => void
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
function WorkspaceAgentOptionButton({
|
|
152
|
-
option,
|
|
153
|
-
selected,
|
|
154
|
-
onSelect
|
|
155
|
-
}: WorkspaceAgentOptionButtonProps) {
|
|
156
|
-
const showDisabledTooltip = Boolean(option.disabledReason)
|
|
157
|
-
const button = (
|
|
158
|
-
<button
|
|
159
|
-
type="button"
|
|
160
|
-
disabled={option.disabled && !showDisabledTooltip}
|
|
161
|
-
aria-disabled={option.disabled || undefined}
|
|
162
|
-
aria-pressed={selected}
|
|
163
|
-
onClick={event => {
|
|
164
|
-
if (option.disabled) {
|
|
165
|
-
event.preventDefault()
|
|
166
|
-
return
|
|
167
|
-
}
|
|
168
|
-
onSelect(option.type)
|
|
169
|
-
}}
|
|
170
|
-
className={cn(
|
|
171
|
-
'relative flex h-32 min-w-32 flex-1 flex-col items-start justify-between gap-6 rounded-xl bg-card p-4 text-left ring-1 ring-border transition-opacity outline-none focus-visible:ring-3 focus-visible:ring-ring/50',
|
|
172
|
-
!selected && 'opacity-70',
|
|
173
|
-
!selected && !option.disabled && 'cursor-pointer hover:opacity-100',
|
|
174
|
-
option.disabled && 'cursor-not-allowed'
|
|
175
|
-
)}
|
|
176
|
-
>
|
|
177
|
-
<span className="relative inline-flex">
|
|
178
|
-
<WorkspaceAgentIcon type={option.type} />
|
|
179
|
-
{selected && (
|
|
180
|
-
<IconCircleCheckFilled
|
|
181
|
-
size={16}
|
|
182
|
-
stroke={1.75}
|
|
183
|
-
aria-hidden="true"
|
|
184
|
-
className="absolute -top-1.5 -right-1.5"
|
|
185
|
-
/>
|
|
186
|
-
)}
|
|
187
|
-
</span>
|
|
188
|
-
<span className="flex min-w-0 flex-col gap-0.5">
|
|
189
|
-
<span className="text-sm font-medium text-foreground">
|
|
190
|
-
{workspaceTypeLabel[option.type]}
|
|
191
|
-
</span>
|
|
192
|
-
<span className="text-xs leading-4 text-muted-foreground">{option.description}</span>
|
|
193
|
-
</span>
|
|
194
|
-
</button>
|
|
195
|
-
)
|
|
196
|
-
|
|
197
|
-
if (!showDisabledTooltip) return button
|
|
198
|
-
|
|
199
|
-
return (
|
|
200
|
-
<Tooltip>
|
|
201
|
-
<TooltipTrigger render={button} />
|
|
202
|
-
<TooltipContent className="max-w-[calc(100vw-2rem)] leading-5 sm:max-w-96">
|
|
203
|
-
<span className="text-center">
|
|
204
|
-
{option.disabledReason}
|
|
205
|
-
{option.disabledCommand && (
|
|
206
|
-
<>
|
|
207
|
-
<br />
|
|
208
|
-
<code className="rounded-xs bg-accent px-1 py-0.5 font-mono wrap-anywhere">
|
|
209
|
-
{option.disabledCommand}
|
|
210
|
-
</code>
|
|
211
|
-
</>
|
|
212
|
-
)}
|
|
213
|
-
</span>
|
|
214
|
-
</TooltipContent>
|
|
215
|
-
</Tooltip>
|
|
216
|
-
)
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
type WorkspaceAgentIconProps = {
|
|
220
|
-
type: WorkspaceType
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
function WorkspaceAgentIcon({ type }: WorkspaceAgentIconProps) {
|
|
224
|
-
return <img src={workspaceProviderIcon[type]} alt="" className="size-8 shrink-0" />
|
|
225
|
-
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { receiveWorkspaceHarness } from './harness-transition'
|
|
1
2
|
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
|
|
2
3
|
|
|
3
4
|
import { jsonRequest, requestJson, requestVoid } from '@/client/api/http'
|
|
@@ -6,20 +7,16 @@ import { workspaceKeys } from '@/client/api/workspace-keys'
|
|
|
6
7
|
import { BROWSER_TAB_ID } from '@/client/lib/browser-tab-id'
|
|
7
8
|
import { useWorkspaceEvent } from '@/client/runtime/use-workspace-events'
|
|
8
9
|
import type {
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
WorkspaceHarness,
|
|
11
|
+
WorkspaceEntry,
|
|
12
|
+
WorkspaceLayoutResponse,
|
|
11
13
|
WorkspaceLayoutSave,
|
|
12
14
|
WorkspaceSkillsStatus,
|
|
13
15
|
WorkspaceSkillsUpdateFailure,
|
|
14
16
|
WorkspaceType
|
|
15
17
|
} from '@/lib/types'
|
|
16
18
|
|
|
17
|
-
export type WorkspaceLayoutResponse
|
|
18
|
-
cwd: string
|
|
19
|
-
name: string
|
|
20
|
-
provider?: WorkspaceType
|
|
21
|
-
agentId?: string
|
|
22
|
-
}
|
|
19
|
+
export type { WorkspaceLayoutResponse } from '@/lib/types'
|
|
23
20
|
|
|
24
21
|
export function useWorkspaceLayout(workspaceId: string) {
|
|
25
22
|
return useQuery<WorkspaceLayoutResponse>({
|
|
@@ -29,49 +26,34 @@ export function useWorkspaceLayout(workspaceId: string) {
|
|
|
29
26
|
})
|
|
30
27
|
}
|
|
31
28
|
|
|
32
|
-
//
|
|
33
|
-
|
|
34
|
-
// `harness:updated` events refresh availability;
|
|
35
|
-
// focus refetches pick up model changes after a CLI update.
|
|
36
|
-
export function useWorkspaceAgent(workspaceId: string) {
|
|
29
|
+
// Workspace models, capabilities, and readiness for credential overrides or gateways.
|
|
30
|
+
export function useWorkspaceHarness(workspaceId: string) {
|
|
37
31
|
const queryClient = useQueryClient()
|
|
38
32
|
useWorkspaceEvent(event => {
|
|
39
33
|
if (event.type === 'harness:updated' && event.workspaceId === workspaceId) {
|
|
40
|
-
queryClient.
|
|
34
|
+
void queryClient.cancelQueries({ queryKey: workspaceKeys.harness(workspaceId) })
|
|
35
|
+
queryClient.setQueryData<WorkspaceHarness>(workspaceKeys.harness(workspaceId), prev =>
|
|
41
36
|
prev ? { ...prev, availability: event.availability } : prev
|
|
42
37
|
)
|
|
43
38
|
}
|
|
44
39
|
// Env can swap credentials; the server dropped its cache — refetch.
|
|
45
40
|
if (event.type === 'env:updated' && event.workspaceId === workspaceId) {
|
|
46
|
-
queryClient.invalidateQueries({ queryKey: workspaceKeys.
|
|
41
|
+
queryClient.invalidateQueries({ queryKey: workspaceKeys.harness(workspaceId) })
|
|
47
42
|
}
|
|
48
43
|
})
|
|
49
|
-
return useQuery<
|
|
50
|
-
queryKey: workspaceKeys.
|
|
44
|
+
return useQuery<WorkspaceHarness>({
|
|
45
|
+
queryKey: workspaceKeys.harness(workspaceId),
|
|
51
46
|
queryFn: async ({ signal }) => {
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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'
|
|
61
|
-
const result = await requestJson<WorkspaceAgent>(
|
|
62
|
-
`/api/workspaces/${workspaceId}/agent${refresh ? '?refresh=true' : ''}`,
|
|
47
|
+
const previous = queryClient.getQueryData<WorkspaceHarness>(
|
|
48
|
+
workspaceKeys.harness(workspaceId)
|
|
49
|
+
)
|
|
50
|
+
const refresh = previous?.hasAuthOverrides && previous.availability.status !== 'available'
|
|
51
|
+
return requestJson<WorkspaceHarness>(
|
|
52
|
+
`/api/workspaces/${workspaceId}/harness${refresh ? '?refresh=true' : ''}`,
|
|
63
53
|
{ signal }
|
|
64
54
|
)
|
|
65
|
-
// A live auth event received during this request is newer than its snapshot.
|
|
66
|
-
const current = queryClient.getQueryData<WorkspaceAgent>(key)
|
|
67
|
-
return current && current !== previous
|
|
68
|
-
? { ...result, availability: current.availability }
|
|
69
|
-
: result
|
|
70
55
|
},
|
|
71
56
|
staleTime: 30_000,
|
|
72
|
-
// Reconfirm cached failures on entry; a recent successful check can be reused.
|
|
73
|
-
refetchOnMount: query =>
|
|
74
|
-
query.state.data?.availability.status === 'available' ? true : 'always',
|
|
75
57
|
refetchOnWindowFocus: true
|
|
76
58
|
})
|
|
77
59
|
}
|
|
@@ -140,3 +122,17 @@ export function useSaveLayout(workspaceId: string) {
|
|
|
140
122
|
}
|
|
141
123
|
})
|
|
142
124
|
}
|
|
125
|
+
|
|
126
|
+
export function useChangeWorkspaceHarness(workspaceId: string) {
|
|
127
|
+
const queryClient = useQueryClient()
|
|
128
|
+
return useMutation({
|
|
129
|
+
mutationFn: (type: WorkspaceType) =>
|
|
130
|
+
requestJson<WorkspaceEntry>(
|
|
131
|
+
`/api/workspaces/${workspaceId}/harness`,
|
|
132
|
+
jsonRequest('PATCH', { type })
|
|
133
|
+
),
|
|
134
|
+
onSuccess: entry => {
|
|
135
|
+
void receiveWorkspaceHarness(queryClient, workspaceId, entry.type ?? 'claude-code')
|
|
136
|
+
}
|
|
137
|
+
})
|
|
138
|
+
}
|