moi-computer 0.7.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 (123) hide show
  1. package/README.md +2 -2
  2. package/client/api/workspace-keys.ts +1 -2
  3. package/client/app/AppRouter.tsx +10 -3
  4. package/client/app/routes/HomeRoute.tsx +1 -1
  5. package/client/app/shell/SidebarLayout.tsx +2 -14
  6. package/client/components/shared/BottomPanel.tsx +2 -1
  7. package/client/components/shared/Composer.tsx +20 -7
  8. package/client/components/shared/PanelHeader.tsx +8 -1
  9. package/client/components/ui/button.tsx +3 -3
  10. package/client/components/ui/dialog.tsx +1 -1
  11. package/client/components/ui/dropdown-menu.tsx +2 -2
  12. package/client/components/ui/hover-card.tsx +1 -1
  13. package/client/components/ui/popover.tsx +1 -1
  14. package/client/components/ui/resizable.tsx +40 -0
  15. package/client/features/applets/AppletMount.tsx +9 -22
  16. package/client/features/applets/applet-cache.ts +7 -0
  17. package/client/features/applets/applet-styles.ts +21 -1
  18. package/client/features/applets/useApplet.ts +1 -1
  19. package/client/features/chat/ChatEmptyState.tsx +9 -11
  20. package/client/features/chat/ChatPanel.tsx +76 -48
  21. package/client/features/chat/ChatPopup.tsx +16 -2
  22. package/client/features/chat/ChatPromptBubbles.tsx +6 -8
  23. package/client/features/chat/ChatSelector.tsx +25 -8
  24. package/client/features/chat/ModelPicker.tsx +5 -4
  25. package/client/features/chat/TurnView.tsx +108 -13
  26. package/client/features/chat/api.ts +1 -18
  27. package/client/features/chat/chat-send.ts +2 -2
  28. package/client/features/chat/{ChatComposer.tsx → composer/ChatComposer.tsx} +24 -9
  29. package/client/features/chat/composer/banners/ChatErrorBanner.tsx +28 -0
  30. package/client/features/chat/composer/banners/ComposerBanner.tsx +30 -0
  31. package/client/features/chat/composer/banners/WorkspaceAgentAvailabilityBanner.tsx +91 -0
  32. package/client/features/{workspace → chat/composer/banners}/WorkspaceSkillUpdateBanner.tsx +9 -7
  33. package/client/features/chat/composer/useWorkspaceComposerState.tsx +74 -0
  34. package/client/features/{workspace → chat/composer}/useWorkspaceSkillUpdates.ts +1 -1
  35. package/client/features/chat/group-turns.ts +46 -28
  36. package/client/features/chat/interleave-notices.ts +84 -0
  37. package/client/features/chat/model-order.ts +9 -3
  38. package/client/features/chat/tool-group/TimelineRow.tsx +23 -11
  39. package/client/features/chat/tool-group/ToolCallGroup.tsx +38 -3
  40. package/client/features/chat/tool-group/format.ts +23 -7
  41. package/client/features/chat/useAppletChatMessage.ts +11 -16
  42. package/client/features/chat/useChat.ts +3 -7
  43. package/client/features/dev/ChatStatesPage.tsx +428 -0
  44. package/client/features/dev/DevIndexPage.tsx +52 -0
  45. package/client/features/dev/DevRoutes.tsx +6 -3
  46. package/client/features/dev/HarnessDebugPage.tsx +3 -3
  47. package/client/features/dev/chat-states-fixtures.ts +744 -0
  48. package/client/features/home/api.ts +0 -10
  49. package/client/features/home/workspace-setup/CreateWorkspaceDialog.tsx +21 -64
  50. package/client/features/home/workspace-setup/ImportWorkspaceDialog.tsx +1 -1
  51. package/client/features/scratchpad/Scratchpad.tsx +5 -3
  52. package/client/features/scratchpad/scratch-session.ts +71 -0
  53. package/client/features/views/ViewBuilderTab.tsx +5 -4
  54. package/client/features/views/ViewManager.tsx +258 -0
  55. package/client/features/views/useViewBuilderActions.ts +2 -2
  56. package/client/features/views/view-residency.ts +77 -0
  57. package/client/features/widgets/WidgetFrame.tsx +6 -2
  58. package/client/features/workspace/CustomizePanel.tsx +40 -24
  59. package/client/features/workspace/WorkspaceLayoutContext.tsx +12 -2
  60. package/client/features/workspace/WorkspaceScreen.tsx +131 -201
  61. package/client/features/workspace/WorkspaceSplitLayout.tsx +111 -0
  62. package/client/features/workspace/WorkspaceTabs.tsx +1 -1
  63. package/client/features/workspace/api.ts +33 -8
  64. package/client/features/workspace/useFitsSplitLayout.ts +31 -5
  65. package/client/index.css +5 -2
  66. package/client/lib/flags.ts +4 -3
  67. package/client/runtime/useWorkspaceEvents.ts +18 -1
  68. package/client/runtime/workspace-theme.ts +29 -10
  69. package/client/store/ui.ts +5 -1
  70. package/client/theme.css +96 -6
  71. package/dist/{chunk-0pcdwjkp.js → chunk-2vaafjp4.js} +1 -1
  72. package/dist/{chunk-9y2zbzqz.js → chunk-35fq49qa.js} +1 -1
  73. package/dist/chunk-gny990qx.css +1 -0
  74. package/dist/chunk-gt7n06ef.js +1 -0
  75. package/dist/{chunk-rxvx4ta9.js → chunk-kkj86722.js} +75 -75
  76. package/dist/chunk-n7pga5x3.js +80 -0
  77. package/dist/chunk-xeyxk7ep.js +10 -0
  78. package/dist/{chunk-w3tnv51j.js → chunk-xzx7c9hq.js} +1 -1
  79. package/dist/index.html +1 -1
  80. package/lib/format.ts +17 -1
  81. package/lib/themes.ts +123 -51
  82. package/lib/types.ts +40 -13
  83. package/lib/workspace-layout.ts +2 -2
  84. package/package.json +6 -4
  85. package/server/agent.ts +199 -0
  86. package/server/api.ts +38 -90
  87. package/server/bundler/build-applet.ts +7 -4
  88. package/server/cli.ts +46 -15
  89. package/server/control.ts +13 -6
  90. package/server/env-apply.ts +4 -0
  91. package/server/harness/README.md +28 -12
  92. package/server/harness/claude-code/auth.ts +54 -0
  93. package/server/harness/claude-code/index.ts +6 -1
  94. package/server/harness/codex/adapter.ts +9 -1
  95. package/server/harness/codex/auth.ts +50 -0
  96. package/server/harness/codex/index.ts +6 -1
  97. package/server/harness/codex/session.ts +33 -14
  98. package/server/harness/openclaw/NOTES.md +518 -187
  99. package/server/harness/openclaw/adapter.ts +125 -31
  100. package/server/harness/openclaw/compat.ts +99 -0
  101. package/server/harness/openclaw/cron-view.ts +78 -0
  102. package/server/harness/openclaw/discovery.ts +145 -52
  103. package/server/harness/openclaw/gateway.ts +224 -36
  104. package/server/harness/openclaw/index.ts +56 -21
  105. package/server/harness/openclaw/session.ts +971 -55
  106. package/server/harness/openclaw/strip.ts +87 -15
  107. package/server/harness/openclaw/thinking.ts +198 -0
  108. package/server/harness/types.ts +10 -5
  109. package/server/layout.ts +5 -2
  110. package/server/moi-scaffold.ts +1 -1
  111. package/server/registry.ts +0 -20
  112. package/server/theme.ts +24 -27
  113. package/workspace/.claude/skills/moi-workspace/DESIGN.md +100 -53
  114. package/workspace/.claude/skills/moi-workspace/SKILL.md +10 -12
  115. package/client/features/dev/PixelPainter.tsx +0 -94
  116. package/client/features/dev/PlaygroundPage.tsx +0 -69
  117. package/dist/chunk-175bm057.js +0 -27
  118. package/dist/chunk-55sh4dty.js +0 -2
  119. package/dist/chunk-afgbg75t.js +0 -50
  120. package/dist/chunk-agtetn7n.css +0 -1
  121. package/dist/chunk-dfs36zgc.js +0 -1
  122. package/dist/chunk-exj6hr30.js +0 -9
  123. package/dist/chunk-m11ckkxd.js +0 -51
@@ -32,6 +32,7 @@ import {
32
32
  } from './TimelineRow'
33
33
  import { ToolOutput } from './ToolOutput'
34
34
  import {
35
+ formatDuration,
35
36
  formatInputBrief,
36
37
  parseCodexMcp,
37
38
  formatMcpTool,
@@ -62,7 +63,13 @@ export function ToolCallGroup({ parts, cwd = null, processing = false }: ToolCal
62
63
  // A reasoning block reads as live "Thinking" only while it's the last
63
64
  // row of an active stream; anything after it makes it a done "Thought".
64
65
  return (
65
- <ReasoningRow key={i} text={part.text} inProgress={processing && isLast} {...pos} />
66
+ <ReasoningRow
67
+ key={i}
68
+ text={part.text}
69
+ durationMs={part.durationMs}
70
+ inProgress={processing && isLast}
71
+ {...pos}
72
+ />
66
73
  )
67
74
  return <ToolCallCard key={part.call.toolCallId || i} call={part.call} cwd={cwd} {...pos} />
68
75
  })}
@@ -144,9 +151,37 @@ function ToolRow({ isFirst, isLast, call, leading, marker, name, brief, preview
144
151
  // so the streaming thought is visible; it collapses on its own the moment
145
152
  // anything follows it (a text/tool row makes it no longer the last row, so
146
153
  // `inProgress` goes false and it reverts to the user's collapsed default).
147
- type ReasoningRowProps = RowPosition & { text: string; inProgress?: boolean }
148
- function ReasoningRow({ isFirst, isLast, text, inProgress = false }: ReasoningRowProps) {
154
+ //
155
+ // Some backends report that the model reasoned without handing over the text
156
+ // (Anthropic `redacted_thinking`; the OpenClaw codex app-server, which sends a
157
+ // Reasoning item with timing only). Those rows have nothing to expand, so they
158
+ // render as a bare label — "Thought for 1.2s" — with no chevron.
159
+ type ReasoningRowProps = RowPosition & {
160
+ text: string
161
+ inProgress?: boolean
162
+ durationMs?: number
163
+ }
164
+ function ReasoningRow({
165
+ isFirst,
166
+ isLast,
167
+ text,
168
+ inProgress = false,
169
+ durationMs
170
+ }: ReasoningRowProps) {
149
171
  const [open, setOpen] = useState(false)
172
+ if (!text) {
173
+ const doneLabel =
174
+ durationMs === undefined ? 'Thought' : `Thought for ${formatDuration(durationMs)}`
175
+ return (
176
+ <TimelineRow isFirst={isFirst} isLast={isLast} loading={inProgress}>
177
+ <div className={cn(HEADER, 'min-w-0 flex-1 cursor-default')}>
178
+ <span className="text-xs font-medium text-muted-foreground">
179
+ {inProgress ? 'Thinking' : doneLabel}
180
+ </span>
181
+ </div>
182
+ </TimelineRow>
183
+ )
184
+ }
150
185
  const label = inProgress ? 'Thinking' : 'Thought'
151
186
  const expanded = inProgress || open
152
187
  return (
@@ -68,14 +68,18 @@ function getInputValue(input: Record<string, unknown>, key: string): string {
68
68
  return typeof value === 'string' ? value : ''
69
69
  }
70
70
 
71
- // Compact wall-clock duration: sub-second → "850ms", under a minute → "3.2s" /
72
- // "11s", longer → "1m 5s". Used on the subagent card's duration badge.
71
+ // Compact wall-clock duration in whole seconds: under a minute → "3s", longer
72
+ // → "1m 5s". Used on agent-run and subagent duration labels.
73
+ //
74
+ // Never milliseconds. A column of "Thought for 514ms" / "Thought for 784ms"
75
+ // rows reads as jitter — the exact figure is noise at this size, and the
76
+ // varying width makes the list look ragged next to a plain "Thought for 1s".
77
+ // Sub-second durations round UP so a real pause never renders as "0s".
73
78
  export function formatDuration(ms: number): string {
74
- if (ms < 1000) return `${Math.round(ms)}ms`
75
- const s = ms / 1000
76
- if (s < 60) return `${s < 10 ? s.toFixed(1) : Math.round(s)}s`
79
+ const s = Math.max(1, Math.round(ms / 1000))
80
+ if (s < 60) return `${s}s`
77
81
  const m = Math.floor(s / 60)
78
- const rem = Math.round(s % 60)
82
+ const rem = s % 60
79
83
  return rem ? `${m}m ${rem}s` : `${m}m`
80
84
  }
81
85
 
@@ -97,6 +101,11 @@ const OPENCLAW_TOOL_LABELS: Record<string, string> = {
97
101
  edit: 'Edit file',
98
102
  apply_patch: 'Edit',
99
103
  exec: 'Bash',
104
+ // 2026.7.2+ renamed the shell tool `bash` and split filesystem tools out.
105
+ bash: 'Bash',
106
+ ls: 'List files',
107
+ find: 'Find files',
108
+ grep: 'Search',
100
109
  process: 'Manage process',
101
110
  web_search: 'Web search',
102
111
  web_fetch: 'Fetch',
@@ -309,7 +318,14 @@ function formatOpenClawBrief(
309
318
  const firstLine = patch.split('\n').find(l => l.startsWith('*** ')) ?? patch.split('\n')[0]
310
319
  return shorten(firstLine ?? '')
311
320
  }
312
- if (tool === 'exec') return shorten(`$ ${getInputValue(input, 'command')}`)
321
+ if (tool === 'exec' || tool === 'bash') {
322
+ // `command` on 2026.7.1 + the newer `bash` tool; the 2026.7.2 exec sandbox
323
+ // instead carries a `code` script (JS that shells out) — show whichever.
324
+ const command = getInputValue(input, 'command') || getInputValue(input, 'code')
325
+ return command ? shorten(`$ ${command}`) : ''
326
+ }
327
+ if (tool === 'ls' || tool === 'find' || tool === 'grep')
328
+ return shorten(getInputValue(input, 'path') || getInputValue(input, 'pattern'))
313
329
  if (tool === 'process') {
314
330
  const action = getInputValue(input, 'action')
315
331
  const name = getInputValue(input, 'name')
@@ -13,6 +13,7 @@
13
13
  import { reportAppletError } from '@/client/features/applets/applet-log'
14
14
  import { type AppletChatMessage, useAppletEvent } from '@/client/features/applets/applet-runtime'
15
15
  import type { ChatSendOptions } from '@/client/features/chat/chat-send'
16
+ import type { ComposerAvailability } from '@/client/components/shared/Composer'
16
17
  import { useWorkspaceId } from '@/client/features/workspace/WorkspaceContext'
17
18
 
18
19
  type UseAppletChatMessageOptions = {
@@ -21,36 +22,30 @@ type UseAppletChatMessageOptions = {
21
22
  // full-screen mode the chat is a popover that is closed by default, so
22
23
  // without this the agent would start working somewhere the user can't see.
23
24
  revealChat: () => void
24
- // Same gate the composer's send button uses: `null` means the agent is
25
- // ready, a string names why it isn't, and `undefined` means the availability
26
- // query hasn't answered yet. Only `null` may send.
27
- unavailableReason: string | null | undefined
25
+ // Same explicit availability state the composer's send button uses.
26
+ composerAvailability: ComposerAvailability
28
27
  }
29
28
 
30
29
  // Why an applet message can't go out right now, or null when it can. The gate
31
- // is exactly the composer's — `canSubmitComposerAction` requires `null`, so
32
- // `undefined` (availability still loading) blocks there too. Starting a run the
33
- // visible UI would have refused is worse than dropping a click the user can
34
- // repeat a moment later.
35
- export function appletSendBlockedReason(
36
- unavailableReason: string | null | undefined
37
- ): string | null {
38
- if (unavailableReason === null) return null
39
- if (unavailableReason === undefined) {
30
+ // is exactly the composer's. Starting a run the visible UI would have refused
31
+ // is worse than dropping a click the user can repeat a moment later.
32
+ export function appletSendBlockedReason(availability: ComposerAvailability): string | null {
33
+ if (availability.status === 'available') return null
34
+ if (availability.status === 'checking') {
40
35
  return "this workspace's agent availability has not resolved yet"
41
36
  }
42
- return `this workspace's agent is unavailable (${unavailableReason})`
37
+ return "this workspace's agent is unavailable"
43
38
  }
44
39
 
45
40
  export function useAppletChatMessage({
46
41
  send,
47
42
  revealChat,
48
- unavailableReason
43
+ composerAvailability
49
44
  }: UseAppletChatMessageOptions): void {
50
45
  const workspaceId = useWorkspaceId()
51
46
 
52
47
  useAppletEvent(workspaceId, 'sendChatMessage', (event: AppletChatMessage) => {
53
- const blocked = appletSendBlockedReason(unavailableReason)
48
+ const blocked = appletSendBlockedReason(composerAvailability)
54
49
  if (blocked) {
55
50
  // Journaled rather than dropped quietly: from the applet's side the
56
51
  // button did nothing, and this is the only place that says why.
@@ -3,12 +3,8 @@ import { useCallback, useMemo } from 'react'
3
3
  import { useQueryClient } from '@tanstack/react-query'
4
4
 
5
5
  import { workspaceKeys } from '@/client/api/workspace-keys'
6
- import {
7
- useSessionConfig,
8
- useSessionView,
9
- useWorkspaceModels,
10
- useWorkspaceSessions
11
- } from '@/client/features/chat/api'
6
+ import { useSessionConfig, useSessionView, useWorkspaceSessions } from '@/client/features/chat/api'
7
+ import { useWorkspaceAgent } from '@/client/features/workspace/api'
12
8
  import { useSelectedSession } from '@/client/features/chat/useSelectedSession'
13
9
  import {
14
10
  type WorkspaceTabAddress,
@@ -51,7 +47,7 @@ export function useChat(address: WorkspaceTabAddress) {
51
47
  const { layout } = useWorkspaceLayoutCtx()
52
48
  const [selectedSession, selectSession] = useSelectedSession()
53
49
  const selectedSessionId = selectedSession ?? null
54
- const modelsData = useWorkspaceModels(workspaceId).data
50
+ const modelsData = useWorkspaceAgent(workspaceId).data
55
51
  const sessions = useWorkspaceSessions(workspaceId).data
56
52
  // Snapshot of the workspace's ambient UI state + queued one-shot
57
53
  // directives, taken when the message actually goes out.
@@ -0,0 +1,428 @@
1
+ // Designer-facing dev route: ONE continuous conversation rendered by the
2
+ // PRODUCTION chat components (TurnView, tool groups, subagent cards, notice
3
+ // rows, the preview-turn path, selector rows) over inline fixtures — no server
4
+ // data. The transcript runs through the exact ChatPanel pipeline (groupTurns →
5
+ // interleaveNotices → TurnView/ChatNoticeRow, plus the live tail), so a
6
+ // designer can restyle the chat by looking at this page and it stays truthful
7
+ // as components evolve. A fixed control switches the live tail state and the
8
+ // error banner; the sidebar holds jump links to each scripted state.
9
+ import { useEffect, useState } from 'react'
10
+
11
+ import { IconChevronDown, IconEdit } from '@tabler/icons-react'
12
+
13
+ import { Button } from '@/client/components/ui/button'
14
+ import {
15
+ DropdownMenu,
16
+ DropdownMenuContent,
17
+ DropdownMenuGroup,
18
+ DropdownMenuItem,
19
+ DropdownMenuLabel,
20
+ DropdownMenuSeparator,
21
+ DropdownMenuTrigger
22
+ } from '@/client/components/ui/dropdown-menu'
23
+ import { Switch } from '@/client/components/ui/switch'
24
+ import { ChatNoticeRow } from '@/client/features/chat/ChatPanel'
25
+ import { ChatErrorBanner } from '@/client/features/chat/composer/banners/ChatErrorBanner'
26
+ import { ChatSessionItem } from '@/client/features/chat/ChatSelector'
27
+ import { ThinkingIndicator, TurnView } from '@/client/features/chat/TurnView'
28
+ import { isSessionRunning, liveStore } from '@/client/features/chat/chat-store'
29
+ import { groupTurns } from '@/client/features/chat/group-turns'
30
+ import { interleaveNotices } from '@/client/features/chat/interleave-notices'
31
+ import { buildPreviewTurn } from '@/client/features/chat/preview-turn'
32
+ import {
33
+ WorkspaceLayoutContext,
34
+ type WorkspaceLayoutContextValue
35
+ } from '@/client/features/workspace/WorkspaceLayoutContext'
36
+ import { createDefaultWorkspaceLayout } from '@/lib/workspace-layout'
37
+ import type { SystemNotice, Turn } from '@/lib/types'
38
+
39
+ import {
40
+ DEV_CWD,
41
+ DEV_WORKSPACE_ID,
42
+ RUNNING_SELECTOR_SESSION_ID,
43
+ chatError,
44
+ conversationAnchors,
45
+ conversationNotices,
46
+ conversationTurns,
47
+ reasoningStreamPreview,
48
+ selectorSessions,
49
+ textStreamPreview,
50
+ toLivePreview
51
+ } from './chat-states-fixtures'
52
+
53
+ // Static stand-in for the query-backed workspace layout provider: TurnView
54
+ // reads `cwd` from this context to shorten tool paths.
55
+ const layoutCtxValue: WorkspaceLayoutContextValue = {
56
+ layout: createDefaultWorkspaceLayout(),
57
+ setLayout: () => {},
58
+ name: 'moi',
59
+ icon: null,
60
+ cwd: DEV_CWD,
61
+ provider: 'openclaw',
62
+ workspaceId: DEV_WORKSPACE_ID,
63
+ isLoading: false
64
+ }
65
+
66
+ // Map from timeline item id (turn or notice) → anchor slug, for the invisible
67
+ // jump targets woven between conversation items.
68
+ const ANCHOR_BY_ITEM_ID: Record<string, string> = Object.fromEntries(
69
+ conversationAnchors.map(a => [a.itemId, a.anchor])
70
+ )
71
+
72
+ type TailState = 'none' | 'dots' | 'thinking' | 'text'
73
+
74
+ const TAIL_OPTIONS: { value: TailState; label: string }[] = [
75
+ { value: 'none', label: 'None' },
76
+ { value: 'dots', label: 'Dots' },
77
+ { value: 'thinking', label: 'Thinking' },
78
+ { value: 'text', label: 'Text' }
79
+ ]
80
+
81
+ function tailPreviewTurn(tail: TailState): Turn | null {
82
+ if (tail === 'thinking') return buildPreviewTurn(toLivePreview(reasoningStreamPreview))
83
+ if (tail === 'text') return buildPreviewTurn(toLivePreview(textStreamPreview))
84
+ return null
85
+ }
86
+
87
+ type TranscriptProps = {
88
+ turns: Turn[]
89
+ notices?: SystemNotice[]
90
+ previewTurn?: Turn | null
91
+ processing?: boolean
92
+ // Timeline item id (turn/notice) → anchor element id injected before it.
93
+ anchors?: Record<string, string>
94
+ }
95
+
96
+ // Mirrors ChatPanel's timeline: append the preview turn, fold tool-only turns
97
+ // (groupTurns), weave notices in, then map to the real row components. The
98
+ // pulsing dots appear exactly when ChatPanel shows them — processing with no
99
+ // preview content yet. Anchors render as zero-size absolute spans so the
100
+ // gap-6 rhythm between items stays untouched.
101
+ function Transcript({
102
+ turns,
103
+ notices = [],
104
+ previewTurn = null,
105
+ processing = false,
106
+ anchors = {}
107
+ }: TranscriptProps) {
108
+ const grouped = groupTurns(previewTurn ? [...turns, previewTurn] : turns)
109
+ const timeline = interleaveNotices(grouped, notices)
110
+ const lastTurnId = grouped.length > 0 ? grouped[grouped.length - 1].id : null
111
+ return (
112
+ <div className="flex w-full flex-col gap-6">
113
+ {timeline.map(item => {
114
+ const id = item.kind === 'notice' ? item.notice.id : item.turn.id
115
+ const anchor = anchors[id]
116
+ return (
117
+ <div key={item.kind === 'notice' ? `notice:${id}` : id} className="relative">
118
+ {anchor && <span id={anchor} aria-hidden className="absolute -top-8" />}
119
+ {item.kind === 'notice' ? (
120
+ <ChatNoticeRow notice={item.notice} />
121
+ ) : (
122
+ <TurnView turn={item.turn} processing={processing && item.turn.id === lastTurnId} />
123
+ )}
124
+ </div>
125
+ )
126
+ })}
127
+ {processing && !previewTurn && <ThinkingIndicator />}
128
+ </div>
129
+ )
130
+ }
131
+
132
+ function noop() {}
133
+ async function asyncNoop() {}
134
+
135
+ // The real chat header strip: the session dropdown, closed by default, with
136
+ // the fixture rows (badges, running spinner) inside — same composition as
137
+ // ChatSelector's menu.
138
+ function SelectorHeader() {
139
+ return (
140
+ <header className="flex w-full items-center justify-between pr-2 pb-2 pl-2">
141
+ <DropdownMenu modal={false}>
142
+ <DropdownMenuTrigger
143
+ render={
144
+ <Button variant="ghost">
145
+ <span className="max-w-64 truncate">{selectorSessions[0].summary}</span>
146
+ <IconChevronDown stroke={1.5} />
147
+ </Button>
148
+ }
149
+ />
150
+ <DropdownMenuContent
151
+ align="start"
152
+ className="flex max-h-100 w-max max-w-72 min-w-40 flex-col overflow-hidden"
153
+ >
154
+ <DropdownMenuItem
155
+ className="shrink-0 gap-1 font-medium text-muted-foreground! **:text-muted-foreground!"
156
+ onClick={noop}
157
+ >
158
+ <IconEdit size={16} stroke={1.75} />
159
+ New chat
160
+ </DropdownMenuItem>
161
+ <DropdownMenuSeparator className="shrink-0" />
162
+ <DropdownMenuGroup>
163
+ <DropdownMenuLabel>Today</DropdownMenuLabel>
164
+ {selectorSessions.map(session => (
165
+ <ChatSessionItem
166
+ key={session.sessionId}
167
+ session={session}
168
+ active={session.sessionId === selectorSessions[0].sessionId}
169
+ // The archive affordance replaces the running spinner on
170
+ // hover/touch, so the running row keeps archiving off to show
171
+ // the pure spinner treatment.
172
+ canArchive={session.sessionId !== RUNNING_SELECTOR_SESSION_ID}
173
+ confirmingArchive={false}
174
+ onSelect={noop}
175
+ onArchive={asyncNoop}
176
+ onRequestArchive={noop}
177
+ workspaceId={DEV_WORKSPACE_ID}
178
+ />
179
+ ))}
180
+ </DropdownMenuGroup>
181
+ </DropdownMenuContent>
182
+ </DropdownMenu>
183
+ </header>
184
+ )
185
+ }
186
+
187
+ type TailControlsProps = {
188
+ tail: TailState
189
+ onTail: (tail: TailState) => void
190
+ showError: boolean
191
+ onShowError: (show: boolean) => void
192
+ }
193
+
194
+ // Fixed dev control for the conversation's live tail and the error banner.
195
+ // Sits at the end of the page DOM, so it paints above the content without
196
+ // z-index.
197
+ function TailControls({ tail, onTail, showError, onShowError }: TailControlsProps) {
198
+ return (
199
+ <div className="fixed right-4 bottom-20 flex flex-col gap-2 rounded-xl bg-popover p-2 text-popover-foreground shadow-md ring-1 ring-border">
200
+ <span className="px-1 text-xs text-muted-foreground">Live tail</span>
201
+ <div className="flex gap-1 rounded-lg bg-accent p-1">
202
+ {TAIL_OPTIONS.map(option => (
203
+ <Button
204
+ key={option.value}
205
+ type="button"
206
+ variant={tail === option.value ? 'default' : 'ghost'}
207
+ size="sm"
208
+ onClick={() => onTail(option.value)}
209
+ >
210
+ {option.label}
211
+ </Button>
212
+ ))}
213
+ </div>
214
+ <label className="flex items-center justify-between gap-2 px-1 text-xs text-muted-foreground">
215
+ Error banner
216
+ <Switch checked={showError} onCheckedChange={onShowError} />
217
+ </label>
218
+ </div>
219
+ )
220
+ }
221
+
222
+ export function ChatStatesPage() {
223
+ const [tail, setTail] = useState<TailState>('text')
224
+ const [showError, setShowError] = useState(false)
225
+
226
+ // The running selector row's spinner reads the live activity store. Seed it,
227
+ // and re-seed after any server status_snapshot reconcile (which rebuilds the
228
+ // activity map and would drop this fixture entry).
229
+ useEffect(() => {
230
+ const seed = () => {
231
+ const state = liveStore.getState()
232
+ if (!isSessionRunning(state.activity, DEV_WORKSPACE_ID, RUNNING_SELECTOR_SESSION_ID)) {
233
+ state.setActivity(DEV_WORKSPACE_ID, RUNNING_SELECTOR_SESSION_ID, 'running')
234
+ }
235
+ }
236
+ seed()
237
+ const unsubscribe = liveStore.subscribe(seed)
238
+ return () => {
239
+ unsubscribe()
240
+ liveStore.getState().setActivity(DEV_WORKSPACE_ID, RUNNING_SELECTOR_SESSION_ID, 'idle')
241
+ }
242
+ }, [])
243
+
244
+ const previewTurn = tailPreviewTurn(tail)
245
+ const processing = tail !== 'none'
246
+
247
+ return (
248
+ <WorkspaceLayoutContext value={layoutCtxValue}>
249
+ <div className="min-h-dvh bg-background font-sans text-foreground">
250
+ <div className="mx-auto flex w-full max-w-5xl gap-10 px-6 py-10">
251
+ <nav className="sticky top-10 hidden h-fit w-44 shrink-0 flex-col gap-1.5 self-start xl:flex">
252
+ <span className="pb-1 text-[11px] font-medium tracking-widest text-muted-foreground uppercase">
253
+ Chat states
254
+ </span>
255
+ {conversationAnchors.map(entry => (
256
+ <a
257
+ key={entry.anchor}
258
+ href={`#${entry.anchor}`}
259
+ className="text-xs text-muted-foreground hover:text-foreground"
260
+ >
261
+ {entry.label}
262
+ </a>
263
+ ))}
264
+ </nav>
265
+
266
+ <main className="flex w-full max-w-(--chat-max-container) min-w-0 flex-1 flex-col">
267
+ <header className="flex flex-col gap-1 pb-6">
268
+ <span className="text-[11px] font-medium tracking-widest text-muted-foreground uppercase">
269
+ Playground / Chat states
270
+ </span>
271
+ <p className="text-sm text-muted-foreground">
272
+ One continuous conversation covering every chat state, rendered by the production
273
+ components over inline fixtures.
274
+ </p>
275
+ </header>
276
+
277
+ <SelectorHeader />
278
+
279
+ <div className="flex flex-col pt-4">
280
+ <Transcript
281
+ turns={conversationTurns}
282
+ notices={conversationNotices}
283
+ previewTurn={previewTurn}
284
+ processing={processing}
285
+ anchors={ANCHOR_BY_ITEM_ID}
286
+ />
287
+
288
+ {showError && (
289
+ <div className="mt-6 flex w-full flex-col gap-2 rounded-t-xl rounded-b-2xl bg-destructive/10 p-2">
290
+ <ChatErrorBanner error={chatError} onDismiss={() => setShowError(false)} />
291
+ </div>
292
+ )}
293
+ </div>
294
+
295
+ <details className="mt-16 border-t border-border pt-6 text-xs text-muted-foreground">
296
+ <summary className="cursor-pointer font-medium">Notes for designers</summary>
297
+ <ul className="mt-3 flex list-disc flex-col gap-1.5 pl-4">
298
+ <li>
299
+ User bubbles render markdown verbatim (whitespace preserved, no markdown parsing)
300
+ — the fenced code block in the long question is intentional.
301
+ </li>
302
+ <li>
303
+ The moon reply carries a full <code>TurnMeta</code> payload (model, provider, stop
304
+ reason, usage, cost) but nothing in the transcript renders meta yet — it rides on
305
+ the turn for future treatments.
306
+ </li>
307
+ <li>
308
+ Approval-pending and approval-denied tool rows render as plain dot rows with no
309
+ body; there is no dedicated approval treatment yet.
310
+ </li>
311
+ <li>
312
+ Pending and running tool calls render identically (spinner node, no output).
313
+ </li>
314
+ <li>
315
+ Channel provenance (the IRC hello) lives on the session (<code>origin</code> badge
316
+ in the selector), not on the turn — the gateway's inbound metadata envelope is
317
+ stripped before display.
318
+ </li>
319
+ <li>
320
+ Nested subagent transcripts render reasoning and tool rows only; nested plain text
321
+ is skipped, and the final answer shows in the summary segment.
322
+ </li>
323
+ <li>
324
+ The busy dots follow ChatPanel's rule — they show whenever the agent is processing
325
+ and no preview content is visible yet, including under running tool rows.
326
+ </li>
327
+ <li>
328
+ Empty-chat states (<code>ChatEmptyState</code>: placeholder and first-run welcome)
329
+ cannot appear in a continuous transcript — find them in the chat with no turns.
330
+ </li>
331
+ <li>
332
+ Text-part <code>citations</code> (the sources reply carries one) are not rendered
333
+ — only the standalone <code>source-url</code> / <code>source-document</code> parts
334
+ show, as small underlined links.
335
+ </li>
336
+ <li>
337
+ <code>Edit</code> results render as plain text — <code>ToolOutput</code>{' '}
338
+ highlights only read/write-with-content or JSON outputs.
339
+ </li>
340
+ <li>
341
+ The image <code>Read</code> row's expanded body holds a{' '}
342
+ <code>ReadImagePreview</code> that loads the workspace preview endpoint; with this
343
+ page's fake workspace id the request 404s and the preview hides itself, leaving
344
+ the body empty. It needs a live workspace to show the picture.
345
+ </li>
346
+ <li>
347
+ <code>TurnOrigin</code> <code>'tool-return'</code> turns never reach the
348
+ transcript: adapters strip <code>tool_result</code> blocks and fold them into the
349
+ owning tool call, so no adapter emits one. (If one ever appeared, TurnView would
350
+ render its parts left-aligned, without the user bubble.)
351
+ </li>
352
+ </ul>
353
+
354
+ <p className="mt-5 font-medium text-foreground">No rendering yet</p>
355
+ <p className="mt-1">
356
+ These claude-code states reach the client but currently render nothing in the chat —
357
+ each needs a designed treatment, not just styling (shapes in{' '}
358
+ <code>lib/format.ts</code>):
359
+ </p>
360
+ <ul className="mt-2 flex list-disc flex-col gap-1.5 pl-4">
361
+ <li>
362
+ <code>rate-limit</code> notice —{' '}
363
+ <code>{"{ kind: 'rate-limit', at, info: { resetsAt: 1754300400 } }"}</code>
364
+ </li>
365
+ <li>
366
+ <code>api-retry</code> notice —{' '}
367
+ <code>
368
+ {
369
+ "{ kind: 'api-retry', at, attempt: 2, maxRetries: 10, delayMs: 8000, error: 'overloaded_error' }"
370
+ }
371
+ </code>
372
+ </li>
373
+ <li>
374
+ <code>hook</code> notice —{' '}
375
+ <code>
376
+ {
377
+ "{ kind: 'hook', at, hookId: 'hook_1a2b', hookName: 'PostToolUse', event: 'PostToolUse', status: 'response', output: 'ok', exitCode: 0, outcome: 'success' }"
378
+ }
379
+ </code>
380
+ </li>
381
+ <li>
382
+ <code>session-state</code> notice —{' '}
383
+ <code>{"{ kind: 'session-state', at, state: 'requires-action' }"}</code> (blocked
384
+ on a permission prompt; no loader or banner exists for it).
385
+ </li>
386
+ <li>
387
+ <code>files-persisted</code> notice —{' '}
388
+ <code>
389
+ {
390
+ "{ kind: 'files-persisted', at, files: ['notes/summary.md'], failed: [{ filename: 'shots/huge.png', error: 'exceeds size limit' }] }"
391
+ }
392
+ </code>
393
+ </li>
394
+ <li>
395
+ <code>elicitation</code> notice —{' '}
396
+ <code>
397
+ {"{ kind: 'elicitation', at, server: 'github', elicitationId: 'elic_7f3a' }"}
398
+ </code>
399
+ </li>
400
+ <li>
401
+ <code>SessionSnapshot</code> —{' '}
402
+ <code>
403
+ {
404
+ "{ sessionId, model: 'claude-sonnet-4-6', cwd, permissionMode: 'bypassPermissions', tools: ['Bash', 'Read', …], mcpServers: [{ name: 'github', status: 'connected' }], skills: ['moi-workspace'], … }"
405
+ }
406
+ </code>
407
+ </li>
408
+ <li>
409
+ <code>ResultSummary</code> —{' '}
410
+ <code>{"{ subtype: 'success', cost: 0.1129, turns: 6, durationMs: 48210 }"}</code>{' '}
411
+ (error subtypes: <code>error_during_execution</code>, <code>error_max_turns</code>
412
+ , budget and structured-output variants).
413
+ </li>
414
+ </ul>
415
+ </details>
416
+ </main>
417
+ </div>
418
+
419
+ <TailControls
420
+ tail={tail}
421
+ onTail={setTail}
422
+ showError={showError}
423
+ onShowError={setShowError}
424
+ />
425
+ </div>
426
+ </WorkspaceLayoutContext>
427
+ )
428
+ }