moi-computer 0.8.0 → 0.8.1-next.0

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 (100) hide show
  1. package/client/api/workspace-keys.ts +1 -2
  2. package/client/app/AppRouter.tsx +10 -3
  3. package/client/app/routes/HomeRoute.tsx +1 -1
  4. package/client/app/shell/SidebarLayout.tsx +2 -14
  5. package/client/components/shared/Composer.tsx +20 -7
  6. package/client/components/shared/PanelHeader.tsx +8 -1
  7. package/client/components/ui/button.tsx +3 -3
  8. package/client/components/ui/dialog.tsx +1 -1
  9. package/client/components/ui/dropdown-menu.tsx +2 -2
  10. package/client/components/ui/hover-card.tsx +1 -1
  11. package/client/components/ui/popover.tsx +1 -1
  12. package/client/components/ui/resizable.tsx +40 -0
  13. package/client/features/chat/ChatEmptyState.tsx +9 -11
  14. package/client/features/chat/ChatPanel.tsx +76 -48
  15. package/client/features/chat/ChatPopup.tsx +16 -2
  16. package/client/features/chat/ChatPromptBubbles.tsx +6 -8
  17. package/client/features/chat/ChatSelector.tsx +24 -7
  18. package/client/features/chat/ModelPicker.tsx +5 -4
  19. package/client/features/chat/TurnView.tsx +108 -13
  20. package/client/features/chat/api.ts +1 -18
  21. package/client/features/chat/chat-send.ts +2 -2
  22. package/client/features/chat/{ChatComposer.tsx → composer/ChatComposer.tsx} +6 -5
  23. package/client/features/chat/composer/banners/ChatErrorBanner.tsx +28 -0
  24. package/client/features/chat/composer/banners/ComposerBanner.tsx +30 -0
  25. package/client/features/chat/composer/banners/WorkspaceAgentAvailabilityBanner.tsx +91 -0
  26. package/client/features/{workspace → chat/composer/banners}/WorkspaceSkillUpdateBanner.tsx +9 -7
  27. package/client/features/chat/composer/useWorkspaceComposerState.tsx +74 -0
  28. package/client/features/{workspace → chat/composer}/useWorkspaceSkillUpdates.ts +1 -1
  29. package/client/features/chat/group-turns.ts +46 -28
  30. package/client/features/chat/interleave-notices.ts +84 -0
  31. package/client/features/chat/model-order.ts +9 -3
  32. package/client/features/chat/tool-group/TimelineRow.tsx +23 -11
  33. package/client/features/chat/tool-group/ToolCallGroup.tsx +38 -3
  34. package/client/features/chat/tool-group/format.ts +23 -7
  35. package/client/features/chat/useAppletChatMessage.ts +11 -16
  36. package/client/features/chat/useChat.ts +3 -7
  37. package/client/features/dev/ChatStatesPage.tsx +428 -0
  38. package/client/features/dev/DevIndexPage.tsx +52 -0
  39. package/client/features/dev/DevRoutes.tsx +6 -3
  40. package/client/features/dev/HarnessDebugPage.tsx +3 -3
  41. package/client/features/dev/chat-states-fixtures.ts +744 -0
  42. package/client/features/scratchpad/Scratchpad.tsx +4 -0
  43. package/client/features/scratchpad/scratch-session.ts +71 -0
  44. package/client/features/views/ViewBuilderTab.tsx +5 -4
  45. package/client/features/views/useViewBuilderActions.ts +2 -2
  46. package/client/features/workspace/WorkspaceLayoutContext.tsx +4 -2
  47. package/client/features/workspace/WorkspaceScreen.tsx +128 -146
  48. package/client/features/workspace/WorkspaceSplitLayout.tsx +111 -0
  49. package/client/features/workspace/api.ts +33 -8
  50. package/client/features/workspace/useFitsSplitLayout.ts +31 -5
  51. package/client/index.css +1 -1
  52. package/client/lib/flags.ts +4 -3
  53. package/client/runtime/useWorkspaceEvents.ts +18 -1
  54. package/client/store/ui.ts +5 -1
  55. package/dist/{chunk-0pcdwjkp.js → chunk-2vaafjp4.js} +1 -1
  56. package/dist/{chunk-9y2zbzqz.js → chunk-35fq49qa.js} +1 -1
  57. package/dist/chunk-gny990qx.css +1 -0
  58. package/dist/chunk-gt7n06ef.js +1 -0
  59. package/dist/{chunk-r5ce5cdg.js → chunk-kkj86722.js} +75 -75
  60. package/dist/chunk-n7pga5x3.js +80 -0
  61. package/dist/chunk-xeyxk7ep.js +10 -0
  62. package/dist/{chunk-h9h8f176.js → chunk-xzx7c9hq.js} +1 -1
  63. package/dist/index.html +1 -1
  64. package/lib/format.ts +17 -1
  65. package/lib/themes.ts +2 -2
  66. package/lib/types.ts +38 -8
  67. package/lib/workspace-layout.ts +2 -2
  68. package/package.json +2 -1
  69. package/server/agent.ts +199 -0
  70. package/server/api.ts +36 -17
  71. package/server/env-apply.ts +4 -0
  72. package/server/harness/README.md +28 -12
  73. package/server/harness/claude-code/auth.ts +54 -0
  74. package/server/harness/claude-code/index.ts +6 -1
  75. package/server/harness/codex/adapter.ts +9 -1
  76. package/server/harness/codex/auth.ts +50 -0
  77. package/server/harness/codex/index.ts +6 -1
  78. package/server/harness/codex/session.ts +33 -14
  79. package/server/harness/openclaw/NOTES.md +518 -187
  80. package/server/harness/openclaw/adapter.ts +125 -31
  81. package/server/harness/openclaw/compat.ts +99 -0
  82. package/server/harness/openclaw/cron-view.ts +78 -0
  83. package/server/harness/openclaw/discovery.ts +145 -52
  84. package/server/harness/openclaw/gateway.ts +224 -36
  85. package/server/harness/openclaw/index.ts +56 -21
  86. package/server/harness/openclaw/session.ts +971 -55
  87. package/server/harness/openclaw/strip.ts +87 -15
  88. package/server/harness/openclaw/thinking.ts +198 -0
  89. package/server/harness/types.ts +10 -5
  90. package/server/layout.ts +5 -2
  91. package/workspace/.claude/skills/moi-workspace/DESIGN.md +19 -9
  92. package/client/features/dev/PixelPainter.tsx +0 -94
  93. package/client/features/dev/PlaygroundPage.tsx +0 -69
  94. package/dist/chunk-0k7brsms.js +0 -9
  95. package/dist/chunk-dfs36zgc.js +0 -1
  96. package/dist/chunk-dtwxpxbg.js +0 -51
  97. package/dist/chunk-ga7t9qsk.js +0 -2
  98. package/dist/chunk-tey2nq7c.js +0 -31
  99. package/dist/chunk-z73xpsa0.js +0 -50
  100. package/dist/chunk-zzgredta.css +0 -1
@@ -21,6 +21,7 @@ import 'tldraw/tldraw.css'
21
21
 
22
22
  import { useWorkspaceId } from '@/client/features/workspace/WorkspaceContext'
23
23
  import { setScratchExecutor } from '@/client/features/scratchpad/scratch-executor'
24
+ import { persistScratchSession } from '@/client/features/scratchpad/scratch-session'
24
25
  import { type WorkspaceEvent, useWorkspaceEvent } from '@/client/runtime/useWorkspaceEvents'
25
26
  import type { ScratchOp, ScratchOpResult } from '@/lib/types'
26
27
  import {
@@ -268,6 +269,8 @@ export function Scratchpad() {
268
269
  // a lock. ('fill' = the style bar's "Solid"; 'solid' there means "Semi".)
269
270
  editor.setStyleForNextShapes(DefaultFillStyle, 'fill')
270
271
  })
272
+ // Restore this browser's camera/zoom for the workspace, then keep it saved.
273
+ const stopSessionSave = persistScratchSession(editor, workspaceId)
271
274
  const unlisten = editor.store.listen(
272
275
  () => {
273
276
  if (applyingRemote.current) {
@@ -307,6 +310,7 @@ export function Scratchpad() {
307
310
  editor.focus()
308
311
  return () => {
309
312
  unlisten()
313
+ stopSessionSave()
310
314
  doc.removeEventListener('pointerdown', onPointerDown, true)
311
315
  if (saveTimer.current) clearTimeout(saveTimer.current)
312
316
  setScratchExecutor(workspaceId, null)
@@ -0,0 +1,71 @@
1
+ import {
2
+ type Editor,
3
+ type TLSessionStateSnapshot,
4
+ createSessionStateSnapshotSignal,
5
+ loadSessionStateSnapshotIntoStore,
6
+ react
7
+ } from 'tldraw'
8
+ import { create } from 'zustand'
9
+ import { persist } from 'zustand/middleware'
10
+
11
+ // Camera/zoom and the rest of tldraw's session state are per-browser UI
12
+ // preferences — never written to `.moi/.scratchpad.json`, which holds only the
13
+ // shared document. They get their own persisted store (`moi:scratch-sessions`)
14
+ // rather than a slot in the `moi:ui` store: the blobs are tldraw's own
15
+ // versioned TLSessionStateSnapshot, migrated by tldraw on load, and saving one
16
+ // rewrites the whole persisted record — better to keep that churn off app prefs.
17
+ type ScratchSessionStore = {
18
+ sessions: Record<string, TLSessionStateSnapshot>
19
+ setSession: (workspaceId: string, session: TLSessionStateSnapshot) => void
20
+ removeSession: (workspaceId: string) => void
21
+ }
22
+
23
+ export const useScratchSessionStore = create<ScratchSessionStore>()(
24
+ persist(
25
+ set => ({
26
+ sessions: {},
27
+ setSession: (workspaceId, session) =>
28
+ set(state => ({ sessions: { ...state.sessions, [workspaceId]: session } })),
29
+ removeSession: workspaceId =>
30
+ set(state => {
31
+ const sessions = { ...state.sessions }
32
+ delete sessions[workspaceId]
33
+ return { sessions }
34
+ })
35
+ }),
36
+ { name: 'moi:scratch-sessions' }
37
+ )
38
+ )
39
+
40
+ const SAVE_DEBOUNCE_MS = 500
41
+
42
+ // Restore this browser's saved session (camera, zoom, selection) into a mounted
43
+ // editor, then keep it saved as it changes. Call from onMount, after the store
44
+ // is hydrated from the server snapshot — loading the session then just moves
45
+ // the viewport. Returns a cleanup that stops the watcher. A corrupt or
46
+ // version-skewed snapshot is discarded and the editor keeps its default
47
+ // viewport.
48
+ export function persistScratchSession(editor: Editor, workspaceId: string): () => void {
49
+ const { sessions, setSession, removeSession } = useScratchSessionStore.getState()
50
+ const saved = sessions[workspaceId]
51
+ if (saved) {
52
+ try {
53
+ loadSessionStateSnapshotIntoStore(editor.store, saved)
54
+ } catch {
55
+ removeSession(workspaceId)
56
+ }
57
+ }
58
+ const signal = createSessionStateSnapshotSignal(editor.store)
59
+ let timer: ReturnType<typeof setTimeout> | null = null
60
+ const stop = react('save scratch session', () => {
61
+ const session = signal.get()
62
+ if (!session) return
63
+ // Debounced: the signal updates on every camera tick while panning/zooming.
64
+ if (timer) clearTimeout(timer)
65
+ timer = setTimeout(() => setSession(workspaceId, session), SAVE_DEBOUNCE_MS)
66
+ })
67
+ return () => {
68
+ stop()
69
+ if (timer) clearTimeout(timer)
70
+ }
71
+ }
@@ -3,6 +3,7 @@ import { type FormEvent, type KeyboardEvent, useEffect, useRef, useState } from
3
3
  import { Button } from '@/client/components/ui/button'
4
4
  import {
5
5
  canSubmitComposerAction,
6
+ type ComposerAvailability,
6
7
  Composer,
7
8
  ComposerFooter,
8
9
  ComposerSubmitButton,
@@ -14,7 +15,7 @@ import { Spinner } from '@/client/components/ui/spinner'
14
15
 
15
16
  type ViewBuilderTabProps = {
16
17
  builder: ViewBuilder
17
- unavailableReason: string | null | undefined
18
+ composerAvailability: ComposerAvailability
18
19
  onSave: (requirements: string) => Promise<unknown>
19
20
  onSubmit: (requirements: string) => Promise<unknown>
20
21
  onOpenChat: () => void
@@ -23,7 +24,7 @@ type ViewBuilderTabProps = {
23
24
 
24
25
  export function ViewBuilderTab({
25
26
  builder,
26
- unavailableReason,
27
+ composerAvailability,
27
28
  onSave,
28
29
  onSubmit,
29
30
  onOpenChat,
@@ -36,7 +37,7 @@ export function ViewBuilderTab({
36
37
  const onSaveRef = useRef(onSave)
37
38
  onSaveRef.current = onSave
38
39
  const hasRequirements = requirements.trim().length > 0
39
- const canSubmit = canSubmitComposerAction(hasRequirements, submitting, unavailableReason)
40
+ const canSubmit = canSubmitComposerAction(hasRequirements, submitting, composerAvailability)
40
41
 
41
42
  useEffect(() => {
42
43
  if (builder.status !== 'draft' || requirements === builder.input.requirements) return
@@ -101,7 +102,7 @@ export function ViewBuilderTab({
101
102
  label="Build view"
102
103
  hasContent={hasRequirements}
103
104
  loading={submitting}
104
- unavailableReason={unavailableReason}
105
+ availability={composerAvailability}
105
106
  />
106
107
  </ComposerFooter>
107
108
  </Composer>
@@ -1,9 +1,9 @@
1
1
  import { useQueryClient } from '@tanstack/react-query'
2
2
 
3
- import { useWorkspaceModels } from '@/client/features/chat/api'
4
3
  import { resolveChatRunOptions, startOptimisticTurn } from '@/client/features/chat/chat-send'
5
4
  import { liveStore } from '@/client/features/chat/chat-store'
6
5
  import { useSelectedSession } from '@/client/features/chat/useSelectedSession'
6
+ import { useWorkspaceAgent } from '@/client/features/workspace/api'
7
7
  import { useWorkspaceLayoutCtx } from '@/client/features/workspace/WorkspaceLayoutContext'
8
8
  import {
9
9
  useCreateViewBuilder,
@@ -17,7 +17,7 @@ export function useViewBuilderActions() {
17
17
  const queryClient = useQueryClient()
18
18
  const { workspaceId, layout } = useWorkspaceLayoutCtx()
19
19
  const [, selectSession] = useSelectedSession()
20
- const modelData = useWorkspaceModels(workspaceId).data
20
+ const modelData = useWorkspaceAgent(workspaceId).data
21
21
  const createMutation = useCreateViewBuilder(workspaceId)
22
22
  const saveMutation = useSaveViewBuilder(workspaceId)
23
23
  const submitMutation = useSubmitViewBuilder(workspaceId)
@@ -11,7 +11,7 @@ import { workspaceKeys } from '@/client/api/workspace-keys'
11
11
  import type { WorkspaceLayout, WorkspaceType } from '@/lib/types'
12
12
  import { createDefaultWorkspaceLayout } from '@/lib/workspace-layout'
13
13
 
14
- type WorkspaceLayoutContextValue = {
14
+ export type WorkspaceLayoutContextValue = {
15
15
  // The persisted layout (widget grid, layout mode, theme). Falls back to an
16
16
  // empty default while the query is still loading.
17
17
  layout: WorkspaceLayout
@@ -33,7 +33,9 @@ type WorkspaceLayoutContextValue = {
33
33
  isLoading: boolean
34
34
  }
35
35
 
36
- const WorkspaceLayoutContext = createContext<WorkspaceLayoutContextValue | null>(null)
36
+ // Exported (with its value type) so fixture surfaces like /dev/chat-states can
37
+ // provide a static value without mounting the query-backed provider.
38
+ export const WorkspaceLayoutContext = createContext<WorkspaceLayoutContextValue | null>(null)
37
39
 
38
40
  export function useWorkspaceLayoutCtx(): WorkspaceLayoutContextValue {
39
41
  const ctx = useContext(WorkspaceLayoutContext)
@@ -28,9 +28,7 @@ import { ViewBuilderTab } from '@/client/features/views/ViewBuilderTab'
28
28
  import { ViewManager } from '@/client/features/views/ViewManager'
29
29
  import { useViewBuilderActions } from '@/client/features/views/useViewBuilderActions'
30
30
  import { useFitsSplitLayout } from '@/client/features/workspace/useFitsSplitLayout'
31
- import { useWorkspaceAvailability } from '@/client/features/workspace/api'
32
- import { WorkspaceSkillUpdateBanner } from '@/client/features/workspace/WorkspaceSkillUpdateBanner'
33
- import { useWorkspaceSkillUpdates } from '@/client/features/workspace/useWorkspaceSkillUpdates'
31
+ import { useWorkspaceComposerState } from '@/client/features/chat/composer/useWorkspaceComposerState'
34
32
  import { useWorkspaceTheme } from '@/client/runtime/workspace-theme'
35
33
  import {
36
34
  hasRunningWorkspaceActivity,
@@ -61,6 +59,8 @@ import {
61
59
  viewTabId
62
60
  } from '@/lib/workspace-tabs'
63
61
 
62
+ import { WorkspaceSplitLayout } from './WorkspaceSplitLayout'
63
+
64
64
  const Scratchpad = lazy(() =>
65
65
  import('@/client/features/scratchpad/Scratchpad').then(module => ({
66
66
  default: module.Scratchpad
@@ -78,22 +78,22 @@ function viewIcon(view: ViewInfo, builders: ViewBuilder[]) {
78
78
  }
79
79
 
80
80
  type SectionControlsProps = {
81
- mode: LayoutMode
82
81
  onToggleMode: () => void
83
82
  }
84
83
 
85
- // Temporary layout switch: fullscreen tabbed workspace ⇄ legacy split view.
86
- function SectionControls({ mode, onToggleMode }: SectionControlsProps) {
87
- const fullscreen = mode === 'fullscreen'
84
+ // Full-screen workspace action: open the chat as a docked split column.
85
+ function SectionControls({ onToggleMode }: SectionControlsProps) {
88
86
  return (
89
- <Button
90
- variant="ghost"
91
- size="icon-sm"
92
- onClick={onToggleMode}
93
- aria-label={fullscreen ? 'Switch to split view' : 'Switch to full-screen view'}
94
- >
95
- <IconLayoutSidebarRight stroke={1.75} />
96
- </Button>
87
+ <Tooltip>
88
+ <TooltipTrigger
89
+ render={
90
+ <Button variant="ghost" size="icon-sm" onClick={onToggleMode} aria-label="Dock agent">
91
+ <IconLayoutSidebarRight stroke={1.75} />
92
+ </Button>
93
+ }
94
+ />
95
+ <TooltipContent>Dock agent</TooltipContent>
96
+ </Tooltip>
97
97
  )
98
98
  }
99
99
 
@@ -199,17 +199,17 @@ function applyVisibleTabOrder(
199
199
 
200
200
  export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenProps) {
201
201
  const { layout, setLayout, name, icon, provider, workspaceId } = useWorkspaceLayoutCtx()
202
- // Keep the composer read/write, but block sends when its agent executable is
203
- // missing. The Send button explains how to install it.
204
- const availability = useWorkspaceAvailability(workspaceId).data
205
- const { bannerProps: skillUpdateBanner } = useWorkspaceSkillUpdates(workspaceId)
206
- const unavailableReason =
207
- availability === undefined ? undefined : availability.available ? null : availability.reason
208
202
  const builderActions = useViewBuilderActions()
209
- const { ref: rowRef, fits: canUseSplit } = useFitsSplitLayout<HTMLDivElement>()
203
+ const {
204
+ ref: rowRef,
205
+ fits: canUseSplit,
206
+ constraints: splitLayoutConstraints
207
+ } = useFitsSplitLayout<HTMLDivElement>()
210
208
  const [widgetMode, setWidgetMode] = useState<WidgetMode>('idle')
211
209
  const [floatingChatOpen, setFloatingChatOpen] = useState(false)
212
210
  const [chatFocusRequest, setChatFocusRequest] = useState(0)
211
+ const dockedChatWidth = useUiStore(state => state.dockedChatWidth)
212
+ const setDockedChatWidth = useUiStore(state => state.setDockedChatWidth)
213
213
  const sessionActivity = useLive(state => state.activity)
214
214
  const hasRunningSession = hasRunningWorkspaceActivity(sessionActivity, workspaceId)
215
215
 
@@ -251,6 +251,10 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
251
251
  selectSession,
252
252
  dismissError
253
253
  } = useChat({ activeTab, appletParams })
254
+ const { composerBanner, composerAvailability } = useWorkspaceComposerState(workspaceId, {
255
+ chatError: error,
256
+ onDismissChatError: dismissError
257
+ })
254
258
 
255
259
  const openSet = new Set(tabsState.open)
256
260
 
@@ -415,7 +419,7 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
415
419
  // Chat messages fired from applet UI. `openChat` is the reveal: on a view tab
416
420
  // in full-screen mode the chat is a closed popover, and a run the user can't
417
421
  // see is worse than a panel that opens itself.
418
- useAppletChatMessage({ send, revealChat: openChat, unavailableReason })
422
+ useAppletChatMessage({ send, revealChat: openChat, composerAvailability })
419
423
 
420
424
  const createItems: CreateWorkspaceTabItem[] = [
421
425
  ...(!dockedSplit && !openSet.has('agent')
@@ -495,15 +499,13 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
495
499
  previewTurn={previewTurn}
496
500
  sessionId={sessionId}
497
501
  processing={processing}
498
- error={error}
499
- onDismissError={dismissError}
500
- composerBanner={
501
- skillUpdateBanner ? <WorkspaceSkillUpdateBanner {...skillUpdateBanner} /> : undefined
502
- }
503
- unavailableReason={unavailableReason}
502
+ composerBanner={composerBanner}
503
+ composerAvailability={composerAvailability}
504
504
  send={send}
505
505
  stop={stop}
506
506
  onSelectSession={selectSession}
507
+ onClose={() => setMode('fullscreen')}
508
+ docked
507
509
  />
508
510
  )
509
511
 
@@ -516,124 +518,110 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
516
518
  previewTurn={previewTurn}
517
519
  sessionId={sessionId}
518
520
  processing={processing}
519
- error={error}
520
- onDismissError={dismissError}
521
- composerBanner={
522
- skillUpdateBanner ? <WorkspaceSkillUpdateBanner {...skillUpdateBanner} /> : undefined
523
- }
524
- unavailableReason={unavailableReason}
521
+ composerBanner={composerBanner}
522
+ composerAvailability={composerAvailability}
525
523
  send={send}
526
524
  stop={stop}
527
525
  onSelectSession={selectSession}
528
526
  />
529
527
  )
530
528
 
531
- return (
532
- <div className="relative flex h-full min-h-0 flex-col bg-background font-sans text-foreground">
533
- <div ref={rowRef} className="flex min-h-0 flex-1">
534
- {/* Full-screen: whole panel. Split: the left content column. */}
535
- {(mode === 'fullscreen' || hasWorkspaceContent) && (
536
- <div
537
- className={cn(
538
- 'flex min-h-0 flex-1 flex-col-reverse',
539
- mode === 'split' && 'min-w-(--column-w)'
540
- )}
541
- >
542
- {activeTab === 'agent' ? (
543
- tabbedChat
544
- ) : activeTab === 'widgets' ? (
545
- <Widgets
546
- editing={widgetMode === 'editing'}
547
- onEditingChange={editing => setWidgetMode(editing ? 'editing' : 'idle')}
548
- widgets={widgets}
549
- onCreateWidget={() => {
550
- selectSession(null)
551
- openChat('Create widget')
552
- }}
553
- />
554
- ) : activeTab === 'scratchpad' ? (
555
- <Suspense fallback={null}>
556
- <Scratchpad />
557
- </Suspense>
558
- ) : activeBuilder ? (
559
- <ViewBuilderTab
560
- key={activeBuilder.id}
561
- builder={activeBuilder}
562
- unavailableReason={unavailableReason}
563
- onSave={requirements => builderActions.save(activeBuilder.id, requirements)}
564
- onSubmit={requirements => {
565
- if (mode === 'fullscreen') setFloatingChatOpen(true)
566
- return builderActions.submit(activeBuilder, requirements)
567
- }}
568
- onOpenChat={() => {
569
- selectSession(activeBuilder.sessionId)
570
- openChat()
571
- }}
572
- onDiscard={() => discardBuilder(activeBuilder)}
573
- />
574
- ) : null}
575
-
576
- {/* Views are not part of the chain above: ViewManager keeps them
577
- mounted across tab switches (and collapses to nothing while
578
- another tab is on screen), which is what makes a switch back
579
- instant. It stays with the content, so the header below it in
580
- the DOM keeps painting over both. */}
581
- <ViewManager
582
- views={views}
583
- activeViewId={activeView?.id ?? null}
584
- params={appletParams}
529
+ const workspacePanel = (
530
+ <div
531
+ className={cn(
532
+ 'flex h-full min-h-0 min-w-0 flex-1 flex-col-reverse overflow-hidden bg-background shadow-xs transition-[border-radius]',
533
+ mode === 'split' && 'rounded-xl'
534
+ )}
535
+ >
536
+ {activeTab === 'agent' ? (
537
+ tabbedChat
538
+ ) : activeTab === 'widgets' ? (
539
+ <Widgets
540
+ editing={widgetMode === 'editing'}
541
+ onEditingChange={editing => setWidgetMode(editing ? 'editing' : 'idle')}
542
+ widgets={widgets}
543
+ onCreateWidget={() => {
544
+ selectSession(null)
545
+ openChat('Create widget')
546
+ }}
547
+ />
548
+ ) : activeTab === 'scratchpad' ? (
549
+ <Suspense fallback={null}>
550
+ <Scratchpad />
551
+ </Suspense>
552
+ ) : activeBuilder ? (
553
+ <ViewBuilderTab
554
+ key={activeBuilder.id}
555
+ builder={activeBuilder}
556
+ composerAvailability={composerAvailability}
557
+ onSave={requirements => builderActions.save(activeBuilder.id, requirements)}
558
+ onSubmit={requirements => {
559
+ if (mode === 'fullscreen') setFloatingChatOpen(true)
560
+ return builderActions.submit(activeBuilder, requirements)
561
+ }}
562
+ onOpenChat={() => {
563
+ selectSession(activeBuilder.sessionId)
564
+ openChat()
565
+ }}
566
+ onDiscard={() => discardBuilder(activeBuilder)}
567
+ />
568
+ ) : null}
569
+
570
+ {/* Views are not part of the chain above: ViewManager keeps them
571
+ mounted across tab switches (and collapses to nothing while
572
+ another tab is on screen), which is what makes a switch back
573
+ instant. It stays with the content, so the header below it in
574
+ the DOM keeps painting over both. */}
575
+ <ViewManager views={views} activeViewId={activeView?.id ?? null} params={appletParams} />
576
+
577
+ <PanelHeader>
578
+ <div className="flex min-w-0 flex-1 items-center gap-4">
579
+ <div className="flex items-center gap-2">
580
+ <img
581
+ src={icon ?? workspaceProviderIcon[provider ?? 'claude-code']}
582
+ alt=""
583
+ className="size-5 shrink-0 rounded-xs"
585
584
  />
586
-
587
- <PanelHeader>
588
- <div className="flex min-w-0 flex-1 items-center gap-4">
589
- <div className="flex items-center gap-2">
590
- <img
591
- src={icon ?? workspaceProviderIcon[provider ?? 'claude-code']}
592
- alt=""
593
- className="size-5 shrink-0 rounded-xs"
594
- />
595
- {name && (
596
- <span className="truncate text-sm font-medium text-foreground">{name}</span>
597
- )}
598
- </div>
599
- <WorkspaceTabs
600
- tabs={tabItems}
601
- active={activeTab}
602
- createItems={createItems}
603
- onSelect={openTab}
604
- onClose={closeTab}
605
- onReorder={reorderTabs}
606
- />
607
- </div>
608
- <div className="flex shrink-0 items-center gap-1">
609
- <WorkspaceCustomizeAction
610
- active={widgetMode === 'customizing'}
611
- onToggle={() =>
612
- setWidgetMode(widgetMode === 'customizing' ? 'idle' : 'customizing')
613
- }
614
- />
615
- <WorkspaceSettings />
616
- {hasWorkspaceContent && canUseSplit && (
617
- <SectionControls
618
- mode={mode}
619
- onToggleMode={() => setMode(mode === 'fullscreen' ? 'split' : 'fullscreen')}
620
- />
621
- )}
622
- </div>
623
- </PanelHeader>
585
+ {name && <span className="truncate text-sm font-medium text-foreground">{name}</span>}
624
586
  </div>
625
- )}
587
+ <WorkspaceTabs
588
+ tabs={tabItems}
589
+ active={activeTab}
590
+ createItems={createItems}
591
+ onSelect={openTab}
592
+ onClose={closeTab}
593
+ onReorder={reorderTabs}
594
+ />
595
+ </div>
596
+ <div className="flex shrink-0 items-center gap-1">
597
+ <WorkspaceCustomizeAction
598
+ active={widgetMode === 'customizing'}
599
+ onToggle={() => setWidgetMode(widgetMode === 'customizing' ? 'idle' : 'customizing')}
600
+ />
601
+ <WorkspaceSettings />
602
+ {hasWorkspaceContent && canUseSplit && mode === 'fullscreen' && (
603
+ <SectionControls onToggleMode={() => setMode('split')} />
604
+ )}
605
+ </div>
606
+ </PanelHeader>
607
+ </div>
608
+ )
626
609
 
627
- {/* Split: Agent chat as a bounded right column. Full-screen mode uses the
628
- Agent tab instead. */}
629
- {mode === 'split' && (
630
- <div
631
- className={cn(
632
- 'flex min-h-0 min-w-(--chat-min) flex-[0_1_var(--chat-max)] flex-col overflow-hidden border-l border-border'
633
- )}
634
- >
635
- {dockedChat}
636
- </div>
610
+ return (
611
+ <div className="relative flex h-full min-h-0 flex-col font-sans text-foreground">
612
+ <div ref={rowRef} className="flex min-h-0 flex-1">
613
+ {hasWorkspaceContent && canUseSplit && splitLayoutConstraints ? (
614
+ <WorkspaceSplitLayout
615
+ {...splitLayoutConstraints}
616
+ workspace={workspacePanel}
617
+ chat={dockedChat}
618
+ open={mode === 'split'}
619
+ chatWidth={dockedChatWidth}
620
+ onCollapse={() => setMode('fullscreen')}
621
+ onChatWidthChange={setDockedChatWidth}
622
+ />
623
+ ) : (
624
+ workspacePanel
637
625
  )}
638
626
  </div>
639
627
 
@@ -661,14 +649,8 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
661
649
  previewTurn={previewTurn}
662
650
  sessionId={sessionId}
663
651
  processing={processing}
664
- error={error}
665
- onDismissError={dismissError}
666
- composerBanner={
667
- skillUpdateBanner ? (
668
- <WorkspaceSkillUpdateBanner {...skillUpdateBanner} />
669
- ) : undefined
670
- }
671
- unavailableReason={unavailableReason}
652
+ composerBanner={composerBanner}
653
+ composerAvailability={composerAvailability}
672
654
  send={send}
673
655
  stop={stop}
674
656
  onSelectSession={selectSession}
@@ -0,0 +1,111 @@
1
+ import { useLayoutEffect, useRef, useState } from 'react'
2
+ import type { ReactNode } from 'react'
3
+ import type { PanelImperativeHandle } from 'react-resizable-panels'
4
+
5
+ import { ResizableHandle, ResizablePanel, ResizablePanelGroup } from '../../components/ui/resizable'
6
+ import { cn } from '../../lib/cn'
7
+
8
+ import type { WorkspaceSplitLayoutConstraints } from './useFitsSplitLayout'
9
+
10
+ type WorkspaceSplitLayoutProps = WorkspaceSplitLayoutConstraints & {
11
+ workspace: ReactNode
12
+ chat: ReactNode
13
+ open: boolean
14
+ chatWidth: number
15
+ onCollapse: () => void
16
+ onChatWidthChange: (width: number) => void
17
+ }
18
+
19
+ export function WorkspaceSplitLayout({
20
+ workspace,
21
+ chat,
22
+ open,
23
+ workspaceMinWidth,
24
+ chatMinWidth,
25
+ chatMaxWidth,
26
+ chatWidth,
27
+ onCollapse,
28
+ onChatWidthChange
29
+ }: WorkspaceSplitLayoutProps) {
30
+ const chatPanelRef = useRef<PanelImperativeHandle>(null)
31
+ const transitionFrameRef = useRef<number | null>(null)
32
+ const [transitionsEnabled, setTransitionsEnabled] = useState(false)
33
+ const openChatWidth = Math.min(Math.max(chatWidth, chatMinWidth), chatMaxWidth)
34
+ const defaultChatSize = useRef(open ? openChatWidth : 0).current
35
+
36
+ useLayoutEffect(() => {
37
+ const chatPanel = chatPanelRef.current
38
+ if (!chatPanel) return
39
+
40
+ if (open) {
41
+ chatPanel.resize(openChatWidth)
42
+ } else {
43
+ chatPanel.collapse()
44
+ }
45
+ }, [openChatWidth, open])
46
+
47
+ return (
48
+ <ResizablePanelGroup
49
+ orientation="horizontal"
50
+ className={cn(
51
+ 'overflow-visible!',
52
+ transitionsEnabled &&
53
+ '[&>#chat]:transition-[flex-grow] [&>#chat]:duration-200 [&>#chat]:ease-in-out motion-reduce:[&>#chat]:transition-none!',
54
+ transitionsEnabled && 'has-[[data-separator=active]]:[&>#chat]:transition-none!'
55
+ )}
56
+ onLayoutChanged={(_layout, meta) => {
57
+ if (!transitionsEnabled && transitionFrameRef.current === null) {
58
+ transitionFrameRef.current = requestAnimationFrame(() => {
59
+ setTransitionsEnabled(true)
60
+ })
61
+ }
62
+
63
+ if (meta.isUserInteraction) {
64
+ requestAnimationFrame(() => {
65
+ const chatPanel = chatPanelRef.current
66
+ if (!chatPanel) return
67
+ const size = chatPanel.getSize()
68
+ if (size.inPixels > 0) onChatWidthChange(Math.round(size.inPixels))
69
+ })
70
+ }
71
+ }}
72
+ >
73
+ <ResizablePanel id="workspace" className="overflow-visible!" minSize={workspaceMinWidth}>
74
+ <div data-slot="workspace-split-workspace" className="flex h-full min-h-0 min-w-0 flex-col">
75
+ {workspace}
76
+ </div>
77
+ </ResizablePanel>
78
+ <ResizableHandle aria-label="Resize chat" hidden={!open} disabled={!open} />
79
+ <ResizablePanel
80
+ id="chat"
81
+ aria-hidden={!open}
82
+ inert={!open}
83
+ collapsible
84
+ collapsedSize={0}
85
+ defaultSize={defaultChatSize}
86
+ minSize={chatMinWidth}
87
+ maxSize={chatMaxWidth}
88
+ groupResizeBehavior="preserve-pixel-size"
89
+ panelRef={chatPanelRef}
90
+ onResize={(size, _id, previousSize) => {
91
+ if (open && size.inPixels === 0 && previousSize && previousSize.inPixels > 0) {
92
+ onCollapse()
93
+ }
94
+ }}
95
+ className={cn(
96
+ 'overflow-hidden!',
97
+ transitionsEnabled &&
98
+ 'transition-opacity duration-200 ease-in-out motion-reduce:transition-none',
99
+ open ? 'opacity-100' : 'opacity-0'
100
+ )}
101
+ >
102
+ <div
103
+ data-slot="workspace-split-chat"
104
+ className="flex h-full min-h-0 min-w-(--chat-min) flex-col"
105
+ >
106
+ {chat}
107
+ </div>
108
+ </ResizablePanel>
109
+ </ResizablePanelGroup>
110
+ )
111
+ }