moi-computer 0.11.1-next.1 → 0.11.1-next.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/client/app/AppRouter.tsx +2 -2
- package/client/app/routes/WorkspaceRoute.tsx +7 -9
- package/client/app/shell/SidebarLayout.tsx +18 -15
- package/client/components/shared/BottomPanel.tsx +26 -14
- package/client/components/shared/PanelHeader.tsx +1 -1
- package/client/components/shared/ReorderableList.tsx +7 -2
- package/client/components/shared/WorkspaceIcon.tsx +92 -0
- package/client/components/ui/alert-dialog.tsx +1 -0
- package/client/components/ui/checkbox.tsx +1 -0
- package/client/components/ui/inline-input.tsx +84 -0
- package/client/components/ui/toast.tsx +2 -2
- package/client/features/applets/AppletMount.tsx +1 -1
- package/client/features/applets/applet-cache.ts +3 -3
- package/client/features/applets/applet-runtime.ts +147 -108
- package/client/features/applets/applet-styles.ts +2 -2
- package/client/features/applets/applet-thumbnail.ts +6 -8
- package/client/features/applets/useApplet.ts +10 -9
- package/client/features/chat/ChatPanel.tsx +19 -10
- package/client/features/chat/ChatPopup.tsx +7 -2
- package/client/features/chat/applet-chat-intents.ts +170 -0
- package/client/features/chat/chat-send.ts +116 -64
- package/client/features/chat/chat-store.ts +51 -62
- package/client/features/chat/composer/ChatComposer.tsx +43 -132
- package/client/features/chat/composer/ModelPicker.tsx +41 -42
- package/client/features/chat/composer/attachments/AttachmentChip.tsx +99 -0
- package/client/features/chat/composer/attachments/DrawingAttachmentChip.tsx +37 -0
- package/client/features/chat/composer/attachments/FileAttachmentChip.tsx +22 -0
- package/client/features/chat/composer/attachments/TextAttachmentChip.tsx +11 -0
- package/client/features/chat/composer/attachments/draft-attachments.ts +168 -0
- package/client/features/chat/composer/attachments/types.ts +25 -0
- package/client/features/chat/composer/attachments/uploads.ts +26 -0
- package/client/features/chat/composer/model-order.ts +15 -0
- package/client/features/chat/{chat-connection.ts → connection/chat-connection.ts} +1 -1
- package/client/features/chat/{chat-frames.ts → connection/chat-frames.ts} +6 -7
- package/client/features/chat/{ChatEmptyState.tsx → messages/ChatEmptyState.tsx} +16 -11
- package/client/features/chat/{MarkdownContent.tsx → messages/MarkdownContent.tsx} +16 -1
- package/client/features/chat/{TurnView.tsx → messages/TurnView.tsx} +22 -15
- package/client/features/chat/{group-turns.ts → messages/group-turns.ts} +1 -0
- package/client/features/chat/{interleave-notices.ts → messages/interleave-notices.ts} +7 -11
- package/client/features/chat/{tool-group → messages/tool-group}/SubagentCard.tsx +1 -1
- package/client/features/chat/{tool-group → messages/tool-group}/TimelineRow.tsx +2 -2
- package/client/features/chat/{tool-group → messages/tool-group}/ToolCallGroup.tsx +2 -5
- package/client/features/chat/{tool-group → messages/tool-group}/format/codex.ts +4 -1
- package/client/features/chat/{ChatSelector.tsx → sessions/ChatSelector.tsx} +3 -3
- package/client/features/chat/{api.ts → sessions/api.ts} +1 -1
- package/client/features/chat/useChat.ts +37 -23
- package/client/features/dev/ChatStatesPage.tsx +5 -6
- package/client/features/dev/HarnessDebugPage.tsx +10 -7
- package/client/features/dev/ToolCallsPage.tsx +1 -1
- package/client/features/dev/UiComponentPreviews.tsx +21 -0
- package/client/features/dev/chat-states-fixtures.ts +13 -2
- package/client/features/drawings/useChatAnnotation.ts +17 -17
- package/client/features/drawings/useDrawingLayer.ts +7 -9
- package/client/features/drawings/useViewBuilderSketch.ts +18 -15
- package/client/features/home/HomePage.tsx +8 -7
- package/client/features/home/WorkspacePreview.tsx +1 -1
- package/client/features/home/workspace-presentation.tsx +1 -11
- package/client/features/home/workspace-setup/WorkspaceAgentStep.tsx +2 -4
- package/client/features/overview/HiddenPanel.tsx +109 -0
- package/client/features/overview/Overview.tsx +302 -0
- package/client/features/overview/WidgetCanvas.tsx +164 -0
- package/client/features/{widgets → overview}/WidgetFrame.tsx +24 -16
- package/client/features/overview/WorkspaceName.tsx +60 -0
- package/client/features/overview/api.ts +30 -0
- package/client/features/overview/default/ViewsWidget.tsx +252 -0
- package/client/features/overview/default/registry.tsx +36 -0
- package/client/features/{widgets → overview}/grid.ts +36 -0
- package/client/features/overview/useGridReconcile.ts +94 -0
- package/client/features/scratchpad/Scratchpad.tsx +7 -8
- package/client/features/scratchpad/ScratchpadControls.tsx +0 -1
- package/client/features/scratchpad/useScratchpadSnapshot.tsx +23 -13
- package/client/features/settings/GeneralSettings.tsx +55 -58
- package/client/features/settings/SettingsLayout.tsx +2 -2
- package/client/features/settings/WorkspaceIconPicker.tsx +318 -0
- package/client/features/settings/WorkspaceSettingsDialog.tsx +65 -0
- package/client/features/settings/api.ts +48 -24
- package/client/features/views/ViewBuilder.tsx +5 -4
- package/client/features/views/ViewManager.tsx +11 -13
- package/client/features/views/api.ts +36 -2
- package/client/features/views/useViewBuilderActions.ts +8 -5
- package/client/features/views/useViewBuilderDrafts.ts +23 -21
- package/client/features/views/view-presentation.ts +13 -0
- package/client/features/workspace/{CustomizePanel.tsx → ThemePanel.tsx} +26 -31
- package/client/features/workspace/UnavailablePage.tsx +21 -0
- package/client/features/workspace/WorkspaceLayoutContext.tsx +4 -7
- package/client/features/workspace/WorkspaceScreen.tsx +205 -161
- package/client/features/workspace/WorkspaceSplitLayout.tsx +1 -1
- package/client/features/workspace/WorkspaceTabs.tsx +2 -0
- package/client/features/workspace/api.ts +0 -26
- package/client/features/workspace/moi-context.ts +8 -9
- package/client/features/workspace/tab-resolution.ts +10 -33
- package/client/features/workspace/useWorkspaceNavigation.ts +164 -101
- package/client/index.css +1 -1
- package/client/lib/app-icon-registry.ts +2 -0
- package/client/lib/use-latest-ref.ts +11 -0
- package/client/main.tsx +1 -1
- package/client/runtime/useWorkspaceEvents.ts +59 -14
- package/client/theme.css +5 -5
- package/dist/chunk-1pp135b4.js +1 -0
- package/dist/chunk-2gs8jjx4.css +1 -0
- package/dist/chunk-94m3q9ce.js +1 -0
- package/dist/chunk-azkjzc7a.js +68 -0
- package/dist/{chunk-w482ew2c.js → chunk-brr0zbeh.js} +73 -73
- package/dist/chunk-m1fvqssh.js +2 -0
- package/dist/chunk-p34hvqt3.js +1 -0
- package/dist/{chunk-4s15axjs.js → chunk-p83f0jnj.js} +2 -2
- package/dist/{chunk-j3wvxjr7.js → chunk-tzz101ea.js} +1 -1
- package/dist/chunk-xg01f6pn.js +10 -0
- package/dist/{chunk-53a7pxcz.js → chunk-zs4mte79.js} +1 -1
- package/dist/index.html +1 -1
- package/lib/app-icons.ts +1 -0
- package/lib/applet-selector.ts +24 -0
- package/lib/chat-title.ts +6 -1
- package/lib/default-widgets.ts +32 -0
- package/lib/format.ts +18 -6
- package/lib/message-attachments.ts +40 -0
- package/lib/moi-attachments.ts +204 -0
- package/lib/moi-context.ts +20 -35
- package/lib/navigation.ts +84 -0
- package/lib/types.ts +84 -26
- package/lib/workspace-icon.ts +20 -0
- package/lib/workspace-layout.ts +22 -2
- package/lib/workspace-tabs.ts +9 -33
- package/package.json +27 -27
- package/registry.json +13 -0
- package/server/AGENTS.md +1 -0
- package/server/api.ts +115 -38
- package/server/applet-typecheck.ts +95 -0
- package/server/applets/applet-css.ts +55 -0
- package/server/{bundler → applets}/build-applet.ts +13 -246
- package/server/applets/config.ts +226 -0
- package/server/applets/dependencies.ts +206 -0
- package/server/{applets.ts → applets/index.ts} +15 -161
- package/server/applets/runtime/base.ts +4 -0
- package/server/applets/runtime/moi.ts +42 -0
- package/server/applets/runtime/rpc.ts +17 -0
- package/server/applets/view-source.ts +67 -0
- package/server/attachment-message.ts +95 -0
- package/server/cli.ts +163 -97
- package/server/control.ts +63 -42
- package/server/harness/README.md +32 -41
- package/server/harness/acp/adapter.ts +7 -21
- package/server/harness/acp/session.ts +31 -50
- package/server/harness/claude-code/NOTES.md +8 -2
- package/server/harness/claude-code/adapter.ts +8 -25
- package/server/harness/claude-code/index.ts +2 -0
- package/server/harness/claude-code/session.ts +42 -47
- package/server/harness/claude-code/sessions.ts +9 -4
- package/server/harness/codex/NOTES.md +222 -350
- package/server/harness/codex/adapter.ts +102 -52
- package/server/harness/codex/auth.ts +1 -3
- package/server/harness/codex/client.ts +169 -249
- package/server/harness/codex/discovery.ts +9 -17
- package/server/harness/codex/index.ts +3 -1
- package/server/harness/codex/pagination.ts +24 -0
- package/server/harness/codex/permissions.ts +32 -8
- package/server/harness/codex/probe.ts +10 -13
- package/server/harness/codex/session.ts +567 -181
- package/server/harness/codex/transport.ts +184 -0
- package/server/harness/debug.ts +1 -1
- package/server/harness/hermes/NOTES.md +1 -1
- package/server/harness/hermes/index.ts +4 -0
- package/server/harness/openclaw/NOTES.md +1 -1
- package/server/harness/openclaw/adapter.ts +22 -4
- package/server/harness/openclaw/gateway.ts +5 -3
- package/server/harness/openclaw/session.ts +27 -27
- package/server/harness/types.ts +5 -3
- package/server/layout.ts +9 -14
- package/server/moi-scaffold.ts +21 -13
- package/server/navigation-relay.ts +110 -0
- package/server/registry.ts +8 -0
- package/server/selected-session.ts +24 -4
- package/server/skill-update.ts +5 -3
- package/server/skill-version.ts +4 -7
- package/server/skills-template.ts +48 -9
- package/server/tabs.ts +19 -33
- package/server/uploads.ts +0 -0
- package/server/view-builders.ts +18 -1
- package/server/views.ts +126 -6
- package/server/web.ts +38 -9
- package/server/widgets.ts +12 -5
- package/server/workspace-config.ts +13 -9
- package/ui-components/alert-dialog.tsx +1 -1
- package/ui-components/alert.tsx +1 -1
- package/ui-components/avatar.tsx +1 -1
- package/ui-components/button.tsx +2 -2
- package/ui-components/checkbox.tsx +2 -1
- package/ui-components/combobox.tsx +3 -1
- package/ui-components/docs/kbd.md +191 -0
- package/ui-components/dropdown-menu.tsx +1 -1
- package/ui-components/field.tsx +1 -1
- package/ui-components/input-group.tsx +2 -2
- package/ui-components/kbd.tsx +32 -0
- package/ui-components/radio-group.tsx +2 -1
- package/ui-components/slider.tsx +1 -1
- package/ui-components/switch.tsx +3 -2
- package/ui-components/tabs.tsx +1 -1
- package/workspace/.claude/skills/moi-workspace/SKILL.md +284 -228
- package/workspace/.claude/skills/moi-workspace/references/DESIGN.md +100 -153
- package/workspace/.claude/skills/moi-workspace/references/INTENTS.md +156 -0
- package/client/features/chat/attachment-staging.ts +0 -153
- package/client/features/chat/uploads.ts +0 -18
- package/client/features/chat/useAppletChatMessage.ts +0 -68
- package/client/features/settings/IconPicker.tsx +0 -442
- package/client/features/settings/WorkspaceSettings.tsx +0 -95
- package/client/features/settings/render-icon.ts +0 -173
- package/client/features/widgets/HiddenPanel.tsx +0 -80
- package/client/features/widgets/WidgetGrid.tsx +0 -123
- package/client/features/widgets/Widgets.tsx +0 -262
- package/client/features/widgets/useGridReconcile.ts +0 -73
- package/dist/chunk-6664vxpk.css +0 -1
- package/dist/chunk-87thzbtw.js +0 -2
- package/dist/chunk-a6jad1a6.js +0 -1
- package/dist/chunk-dghwstd2.js +0 -9
- package/dist/chunk-eg120aca.js +0 -1
- package/dist/chunk-vwjeezeb.js +0 -1
- package/dist/chunk-yc471zah.js +0 -70
- package/server/bundler/applet-css.ts +0 -160
- /package/client/features/chat/{ChatPromptBubbles.tsx → messages/ChatPromptBubbles.tsx} +0 -0
- /package/client/features/chat/{ShimmerText.tsx → messages/ShimmerText.tsx} +0 -0
- /package/client/features/chat/{preview-turn.ts → messages/preview-turn.ts} +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/CodeBlock.tsx +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/Collapse.tsx +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/ReadImagePreview.tsx +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/ToolOutput.tsx +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/detect.ts +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/fixtures.ts +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/format/claude.ts +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/format/hermes.ts +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/format/index.ts +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/format/mcp.ts +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/format/openclaw.ts +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/format/shared.ts +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/format/shell.ts +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/index.ts +0 -0
- /package/client/features/chat/{useStickToBottom.ts → messages/useStickToBottom.ts} +0 -0
- /package/client/features/chat/{session-view.ts → sessions/session-view.ts} +0 -0
- /package/client/features/chat/{useSelectedSession.ts → sessions/useSelectedSession.ts} +0 -0
- /package/server/{bundler → applets}/build-worker.ts +0 -0
package/server/harness/README.md
CHANGED
|
@@ -22,7 +22,7 @@ Message types flow through four layers; each has one home:
|
|
|
22
22
|
│ REST payloads (SessionInfo, Models, …) re-exports it)
|
|
23
23
|
▼
|
|
24
24
|
4. client React Query cache of StreamEvents + client/features/chat/*
|
|
25
|
-
ephemeral preview store → ViewState → (tool-group/format
|
|
25
|
+
ephemeral preview store → ViewState → (messages/tool-group/format/ holds the
|
|
26
26
|
TurnView rendering per-provider labels/briefs)
|
|
27
27
|
```
|
|
28
28
|
|
|
@@ -57,8 +57,7 @@ Socket-protocol notes the layers rely on (all defined in `lib/types.ts`):
|
|
|
57
57
|
lifecycle signal — never derived by counting sends vs results. The snapshot
|
|
58
58
|
(sent on connect and re-broadcast periodically) is authoritative: the client
|
|
59
59
|
rebuilds its whole activity map from it, so a lost terminal frame self-heals.
|
|
60
|
-
`requires-action`
|
|
61
|
-
yet — the client shows no loader for it.
|
|
60
|
+
`requires-action` suppresses the loader.
|
|
62
61
|
- **`preview`** — live token frames, cumulative text, never persisted;
|
|
63
62
|
cleared when the turn with matching `meta.apiMessageId` lands.
|
|
64
63
|
|
|
@@ -75,9 +74,9 @@ server/harness/
|
|
|
75
74
|
hand-written wire types it consumes
|
|
76
75
|
session.ts live per-thread state machine (send/interrupt/turn
|
|
77
76
|
accounting/preview forwarding)
|
|
78
|
-
<transport>.ts
|
|
79
|
-
codex/
|
|
80
|
-
|
|
77
|
+
<transport>.ts connection management: codex/client.ts owns processes and
|
|
78
|
+
codex/transport.ts frames stdio; openclaw/gateway.ts owns
|
|
79
|
+
the gateway connection (CC uses the Agent SDK)
|
|
81
80
|
discovery.ts / models.ts / sessions.ts / mcp.ts as needed
|
|
82
81
|
NOTES.md the backend's wire protocol, empirically verified
|
|
83
82
|
*.test.ts tests live next to the code they cover
|
|
@@ -192,29 +191,19 @@ tool calls left unsettled at turn end are closed (Hermes never completes file
|
|
|
192
191
|
read/write calls live), and a completing `tool_call_update` carries no title, so
|
|
193
192
|
the established name is kept. See `hermes/NOTES.md`.
|
|
194
193
|
|
|
195
|
-
**Codex — shipped, experimental.**
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
MCP
|
|
207
|
-
|
|
208
|
-
reports a missing `codex` executable (PATH + login-shell PATH lookup, with a
|
|
209
|
-
Codex Desktop app-bundle fallback — `executable.ts`) to setup flows and the
|
|
210
|
-
workspace composer. Sessions use `workspace-write` with network disabled by
|
|
211
|
-
default and `approvalPolicy: on-request`; server→client approval requests are
|
|
212
|
-
accepted by moi at the transport — an interim default-approve policy until UI
|
|
213
|
-
approvals land (`codex/permissions.ts`). The same policy is reapplied on
|
|
214
|
-
thread start, resume, and every turn. Known gaps: no interactive approval flow
|
|
215
|
-
yet. Per-turn application context tells Codex to request escalated localhost
|
|
216
|
-
access before control-server commands. Images ride inline as data URLs only
|
|
217
|
-
(no `localImage` path mode).
|
|
194
|
+
**Codex — shipped, experimental.** One `codex app-server` per workspace supplies
|
|
195
|
+
chat, model/session catalogs, history, steering, and interruption. The harness
|
|
196
|
+
maps items into shared display events, including subagent transcripts, reasoning
|
|
197
|
+
previews, usage, and hook/MCP failure notices.
|
|
198
|
+
Model, effort, and fast-mode choices apply on the next new turn; the sent model
|
|
199
|
+
matches the picker even when Codex config names an unavailable model.
|
|
200
|
+
|
|
201
|
+
Workspace env is fixed at process spawn. Executable lookup prefers PATH over
|
|
202
|
+
the desktop bundle; config and credentials remain owned by Codex. Sessions use
|
|
203
|
+
workspace-write access with network disabled, and moi automatically accepts
|
|
204
|
+
supported permission requests. Command-approval UI, native question forms, and
|
|
205
|
+
MCP elicitation are not implemented. See [Codex harness notes](codex/NOTES.md)
|
|
206
|
+
for module ownership, ordering rules, runtime diagnostics, and boundaries.
|
|
218
207
|
|
|
219
208
|
Workspace availability also checks provider authentication when a workspace is
|
|
220
209
|
given. Claude Code is probed with `claude auth status` under the effective
|
|
@@ -260,8 +249,8 @@ doubles as the evaluation rubric for new harnesses.
|
|
|
260
249
|
- **Set model** — ideally live mid-session.
|
|
261
250
|
- **Set reasoning effort** — CC applies `applyFlagSettings({ effortLevel })`
|
|
262
251
|
before the next message; Codex takes it per turn.
|
|
263
|
-
- **Thinking/reasoning display mode** (Codex
|
|
264
|
-
|
|
252
|
+
- **Thinking/reasoning display mode** (Codex requests `summary: 'detailed'`
|
|
253
|
+
so visible summaries do not depend on CLI defaults).
|
|
265
254
|
- **Token streaming opt-in** (CC: `includePartialMessages`, construct-time;
|
|
266
255
|
Codex: always streams, moi gates forwarding).
|
|
267
256
|
- **Permissions / tool policy** — allowed tools, permission mode; backends
|
|
@@ -283,7 +272,9 @@ doubles as the evaluation rubric for new harnesses.
|
|
|
283
272
|
### Input capabilities
|
|
284
273
|
|
|
285
274
|
- Images (base64 blocks vs data URLs vs file paths — a capability, not a given).
|
|
286
|
-
-
|
|
275
|
+
- Attachments share `server/attachment-message.ts` for preparation and
|
|
276
|
+
`lib/moi-attachments.ts` for serialization and replay. Files and path-delivered
|
|
277
|
+
images carry readable paths; inline images keep their native content blocks.
|
|
287
278
|
- Rich content blocks vs plain-string prompts.
|
|
288
279
|
|
|
289
280
|
### Discovery / metadata
|
|
@@ -308,25 +299,26 @@ doubles as the evaluation rubric for new harnesses.
|
|
|
308
299
|
|
|
309
300
|
## Capability comparison
|
|
310
301
|
|
|
311
|
-
Legend: ✅ supported · ⚠️ partial/workaround · ❌ missing.
|
|
302
|
+
Legend: ✅ supported · ⚠️ partial/workaround · ❌ missing. The Codex column
|
|
303
|
+
describes what moi exposes, not every RPC available in the upstream protocol.
|
|
312
304
|
|
|
313
305
|
| Feature | Claude Agent SDK | OpenClaw gateway | Codex app-server | Hermes (ACP) |
|
|
314
306
|
| ------------------------ | --------------------------------------------------- | ------------------------- | ------------------------------------- | ------------------------------------ |
|
|
315
307
|
| Long-lived session | ✅ subprocess per session | ✅ gateway-side | ✅ server-side, N threads/process | ✅ process per workspace, N sessions |
|
|
316
308
|
| Queue/steer mid-turn | ⚠️ queued next turn | ⚠️ | ✅ `turn/steer` into live turn | ⚠️ queued (ACP has no steer) |
|
|
317
|
-
| Resume | ✅ | ✅ | ✅
|
|
309
|
+
| Resume | ✅ | ✅ | ✅ `thread/resume` | ✅ `session/load` (+ fork) |
|
|
318
310
|
| Interrupt | ✅ `interrupt()` | ✅ | ✅ `turn/interrupt` | ✅ `session/cancel` → `cancelled` |
|
|
319
311
|
| List models | ✅ `supportedModels()` | ✅ `models.list` | ✅ `model/list` | ✅ inline on `session/new` |
|
|
320
312
|
| Live model switch | ✅ `setModel()` | ✅ `sessions.patch` | ✅ per-turn override | ⚠️ drops session MCP servers |
|
|
321
313
|
| Live effort switch | ✅ `applyFlagSettings` | ✅ `thinkingLevel` patch | ✅ per-turn | ❌ no effort concept in ACP |
|
|
322
314
|
| Token deltas | ✅ opt-in | ✅ `chat` frames | ✅ `item/*/delta` | ✅ always on, thinking + text |
|
|
323
|
-
| Images in input | ✅ base64 blocks | ⚠️ materialize to path | ✅ data
|
|
315
|
+
| Images in input | ✅ base64 blocks | ⚠️ materialize to path | ✅ inline data URLs | ✅ base64 blocks |
|
|
324
316
|
| Interactive approvals | ⚠️ (we bypass) | ✅ | ✅ server→client requests (we bypass) | ✅ real, with diffs (we bypass) |
|
|
325
317
|
| Session list/history API | ✅ `listSessions()` + jsonl | ✅ `sessions.get` | ✅ `thread/list`/`read` | ✅ `session/list` (cwd + cursor) |
|
|
326
318
|
| Home card preview | ✅ session file scan | ✅ cached first message | ⚠️ live app-server only | ⚠️ live process only |
|
|
327
319
|
| MCP status | ✅ `mcpServerStatus()` | n/a | ✅ `mcpServerStatus/list` | ⚠️ per-session config, no status RPC |
|
|
328
|
-
| Usage reporting | ⚠️ cost/duration on `result` (adapter drops tokens) | ✅ tokens + cost per turn | ✅
|
|
329
|
-
| Structured output | ❌ | ❌ |
|
|
320
|
+
| Usage reporting | ⚠️ cost/duration on `result` (adapter drops tokens) | ✅ tokens + cost per turn | ✅ per-turn tokens and duration | ✅ tokens per turn |
|
|
321
|
+
| Structured output | ❌ | ❌ | ⚠️ title generation only | ❌ |
|
|
330
322
|
|
|
331
323
|
## Design lessons so far
|
|
332
324
|
|
|
@@ -334,10 +326,9 @@ Legend: ✅ supported · ⚠️ partial/workaround · ❌ missing.
|
|
|
334
326
|
via `applyFlagSettings`) or construct-time (streaming).
|
|
335
327
|
Encode that distinction per-setting in the adapter interface instead of
|
|
336
328
|
hardcoding the drain-then-rebuild machinery.
|
|
337
|
-
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
support both.
|
|
329
|
+
- Chat harnesses keep connections open (CC subprocess, OpenClaw gateway,
|
|
330
|
+
Codex app-server). Separate one-shot work, such as Codex title generation,
|
|
331
|
+
can use a short-lived process without changing chat session ownership.
|
|
341
332
|
- Event vocabularies differ in kind, not just names: CC emits raw
|
|
342
333
|
tool_use/tool_result pairs; Codex emits semantic items (a patch, a command)
|
|
343
334
|
with their own lifecycle. The adapter layer is where that converges on
|
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
// call both closes the open assistant turn and becomes a turn of its own —
|
|
8
8
|
// the same item-per-turn model the Codex adapter produces.
|
|
9
9
|
|
|
10
|
-
import {
|
|
10
|
+
import { replayAttachmentParts } from '@/lib/moi-attachments'
|
|
11
|
+
import { formatChatTitle } from '@/lib/chat-title'
|
|
11
12
|
import type { Part, ToolCall, ToolState, Turn, TurnMeta } from '@/lib/format'
|
|
12
|
-
import { stripMoiContext } from '@/lib/moi-context'
|
|
13
13
|
|
|
14
14
|
import {
|
|
15
15
|
type AcpSessionListEntry,
|
|
@@ -109,31 +109,17 @@ export function acpUsageToTurnMeta(usage: Usage | null | undefined): TurnMeta['u
|
|
|
109
109
|
return { inputTokens, outputTokens, totalTokens }
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
//
|
|
113
|
-
//
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
// first: it is appended after the note, and `splitAttachmentNote` parses the
|
|
117
|
-
// note as the text's tail. An envelope-only block (an attachment-only send
|
|
118
|
-
// carries the envelope as its lone text) folds to no parts — the caller skips
|
|
119
|
-
// the bubble entirely.
|
|
120
|
-
export function replayedUserParts(raw: string): Part[] {
|
|
121
|
-
const split = splitAttachmentNote(stripMoiContext(raw))
|
|
122
|
-
const parts: Part[] = split.files.map(f => ({
|
|
123
|
-
type: 'file',
|
|
124
|
-
mediaType: 'application/octet-stream',
|
|
125
|
-
url: f.path,
|
|
126
|
-
filename: f.filename
|
|
127
|
-
}))
|
|
128
|
-
if (split.text.trim()) parts.push({ type: 'text', text: split.text })
|
|
129
|
-
return parts
|
|
112
|
+
// Replay collects text and image chunks before reconstructing attachments,
|
|
113
|
+
// so inline images can be paired with their descriptions in message order.
|
|
114
|
+
export function replayedUserParts(raw: string, images: readonly Part[] = []): Part[] {
|
|
115
|
+
return replayAttachmentParts([...images, { type: 'text', text: raw }])
|
|
130
116
|
}
|
|
131
117
|
|
|
132
118
|
export function acpSessionToSessionInfo(entry: AcpSessionListEntry): SessionInfo {
|
|
133
119
|
const updated = entry.updatedAt ? Date.parse(entry.updatedAt) : NaN
|
|
134
120
|
return {
|
|
135
121
|
sessionId: entry.sessionId,
|
|
136
|
-
summary: entry.title?.trim() || 'Untitled session',
|
|
122
|
+
summary: formatChatTitle(entry.title?.trim() ?? '') || 'Untitled session',
|
|
137
123
|
lastModified: Number.isNaN(updated) ? 0 : updated,
|
|
138
124
|
...(entry.cwd ? { cwd: entry.cwd } : {})
|
|
139
125
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { MessageAttachment } from '@/lib/types'
|
|
1
2
|
// Per-(workspaceId, sessionId) live ACP session adapter.
|
|
2
3
|
//
|
|
3
4
|
// One agent process per workspace (see ./client.ts) serves every session in
|
|
@@ -18,7 +19,11 @@
|
|
|
18
19
|
// - `session/prompt` is a long-running request that resolves at end of turn,
|
|
19
20
|
// so its promise IS the turn's lifetime — activity is mirrored from it,
|
|
20
21
|
// never derived by counting frames.
|
|
21
|
-
import {
|
|
22
|
+
import {
|
|
23
|
+
materializeAttachmentPaths,
|
|
24
|
+
prepareAttachmentMessage,
|
|
25
|
+
type PreparedAttachmentMessage
|
|
26
|
+
} from '../../attachment-message'
|
|
22
27
|
import { type MoiContext, appendMoiContext, renderMoiContext } from '@/lib/moi-context'
|
|
23
28
|
import { type Part, applyEvent, emptyViewState } from '@/lib/format'
|
|
24
29
|
import type { Model, SessionActivity, StreamEvent, ViewState, WorkspaceType } from '@/lib/types'
|
|
@@ -50,12 +55,6 @@ import { broadcast } from '../../state'
|
|
|
50
55
|
import { renameSelectedSession } from '../../selected-session'
|
|
51
56
|
import { hasSessionConfig, renameSessionConfig, saveSessionConfig } from '../../session-config'
|
|
52
57
|
import { renameViewBuilderSession } from '../../view-builders'
|
|
53
|
-
import {
|
|
54
|
-
type StoredUpload,
|
|
55
|
-
materializeToPath,
|
|
56
|
-
resolveUploads,
|
|
57
|
-
uploadToDisplayPart
|
|
58
|
-
} from '../../uploads'
|
|
59
58
|
|
|
60
59
|
export type AcpSpawnContext = {
|
|
61
60
|
workspaceId: string
|
|
@@ -204,11 +203,8 @@ function flushAssistant(
|
|
|
204
203
|
|
|
205
204
|
function flushUserChunk(rec: SessionRecord) {
|
|
206
205
|
if (!rec.userChunk && rec.userImageParts.length === 0) return
|
|
207
|
-
//
|
|
208
|
-
|
|
209
|
-
// a bubble. Replayed images render above the text like the live bubble, and
|
|
210
|
-
// a turn with nothing left (no typed text, no images) drops entirely.
|
|
211
|
-
const parts = [...rec.userImageParts, ...replayedUserParts(rec.userChunk)]
|
|
206
|
+
// Reconstruct the full message once its text and image chunks are collected.
|
|
207
|
+
const parts = replayedUserParts(rec.userChunk, rec.userImageParts)
|
|
212
208
|
rec.userChunk = ''
|
|
213
209
|
rec.userImageParts = []
|
|
214
210
|
if (parts.length === 0) return
|
|
@@ -308,9 +304,9 @@ function handleSessionUpdate(rec: SessionRecord, update: SessionUpdate, provider
|
|
|
308
304
|
// Rebuilt as a data URL — the cold-reload fallback (live bubbles point
|
|
309
305
|
// at moi's served upload URL, but that store is gone after a restart).
|
|
310
306
|
rec.userImageParts.push({
|
|
311
|
-
type: 'file',
|
|
307
|
+
type: 'file-attachment',
|
|
312
308
|
mediaType: content.mimeType,
|
|
313
|
-
|
|
309
|
+
previewUrl: `data:${content.mimeType};base64,${content.data}`
|
|
314
310
|
})
|
|
315
311
|
}
|
|
316
312
|
return
|
|
@@ -489,34 +485,17 @@ async function attachReplayDurations(rec: SessionRecord): Promise<void> {
|
|
|
489
485
|
})
|
|
490
486
|
}
|
|
491
487
|
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
if (part) parts.push(part)
|
|
504
|
-
}
|
|
505
|
-
if (text) parts.push({ type: 'text', text })
|
|
506
|
-
|
|
507
|
-
const blocks: AcpPromptBlock[] = []
|
|
508
|
-
const files: { filename: string; path: string }[] = []
|
|
509
|
-
for (const u of uploads) {
|
|
510
|
-
if (u.kind === 'image' && u.data && supportsImages) {
|
|
511
|
-
blocks.push({ type: 'image', mimeType: u.mediaType, data: u.data.toString('base64') })
|
|
512
|
-
} else if (u.kind === 'file' || (u.kind === 'image' && !supportsImages)) {
|
|
513
|
-
const p = await materializeToPath(u)
|
|
514
|
-
if (p) files.push({ filename: u.filename, path: p })
|
|
515
|
-
}
|
|
516
|
-
}
|
|
517
|
-
const agentText = appendAttachmentNote(text, files)
|
|
518
|
-
if (agentText) blocks.unshift({ type: 'text', text: agentText })
|
|
519
|
-
return { blocks, parts }
|
|
488
|
+
function buildPrompt(message: PreparedAttachmentMessage): AcpPromptBlock[] {
|
|
489
|
+
const images = message.attachments.filter(
|
|
490
|
+
attachment => attachment.type === 'image' && 'data' in attachment
|
|
491
|
+
)
|
|
492
|
+
const blocks: AcpPromptBlock[] = images.map(image => ({
|
|
493
|
+
type: 'image',
|
|
494
|
+
mimeType: image.mediaType,
|
|
495
|
+
data: image.data.toString('base64')
|
|
496
|
+
}))
|
|
497
|
+
if (message.text) blocks.unshift({ type: 'text', text: message.text })
|
|
498
|
+
return blocks
|
|
520
499
|
}
|
|
521
500
|
|
|
522
501
|
// Run one prompt to completion, then drain anything queued behind it.
|
|
@@ -582,23 +561,25 @@ export async function sendAcpMessage(
|
|
|
582
561
|
sessionId: string
|
|
583
562
|
isNew: boolean
|
|
584
563
|
content: string
|
|
585
|
-
attachments?:
|
|
564
|
+
attachments?: MessageAttachment[]
|
|
586
565
|
optimisticId?: string
|
|
587
566
|
model?: string
|
|
588
567
|
stream?: boolean
|
|
589
568
|
context?: MoiContext
|
|
590
569
|
}
|
|
591
570
|
): Promise<void> {
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
571
|
+
if (config.supportsImages === false) {
|
|
572
|
+
await materializeAttachmentPaths(input.workspaceId, input.attachments)
|
|
573
|
+
}
|
|
574
|
+
const prepared = prepareAttachmentMessage(
|
|
575
|
+
input.workspaceId,
|
|
597
576
|
input.content,
|
|
598
|
-
|
|
577
|
+
input.attachments,
|
|
599
578
|
config.supportsImages !== false
|
|
600
579
|
)
|
|
601
|
-
if (
|
|
580
|
+
if (!prepared.text) return
|
|
581
|
+
const blocks = buildPrompt(prepared)
|
|
582
|
+
const { parts } = prepared
|
|
602
583
|
|
|
603
584
|
// ACP has no native ambient-context channel, so the envelope rides in the
|
|
604
585
|
// text block. The backend persists that text verbatim and echoes it on
|
|
@@ -10,7 +10,7 @@ spec for the CC adapter.
|
|
|
10
10
|
> their wire examples are not an exhaustive list of today's SDK messages, and
|
|
11
11
|
> the migration proposed in §14 has shipped. Current display types live in
|
|
12
12
|
> `lib/format.ts`, mapping in `adapter.ts`, and rendering in
|
|
13
|
-
> `client/features/chat/TurnView.tsx`. Use the installed `sdk.d.ts` for current
|
|
13
|
+
> `client/features/chat/messages/TurnView.tsx`. Use the installed `sdk.d.ts` for current
|
|
14
14
|
> wire types.
|
|
15
15
|
|
|
16
16
|
Evidence drawn from:
|
|
@@ -504,7 +504,13 @@ type Part =
|
|
|
504
504
|
| { type: 'text'; text: string; citations?: Citation[] }
|
|
505
505
|
| { type: 'reasoning'; text: string; redacted?: boolean; signature?: string }
|
|
506
506
|
| { type: 'tool-call'; call: ToolCall }
|
|
507
|
-
| {
|
|
507
|
+
| {
|
|
508
|
+
type: 'file-attachment'
|
|
509
|
+
mediaType: string
|
|
510
|
+
label?: string
|
|
511
|
+
previewUrl?: string
|
|
512
|
+
path?: string
|
|
513
|
+
}
|
|
508
514
|
| { type: 'source-url'; url: string; title?: string; sourceId: string }
|
|
509
515
|
| { type: 'source-document'; mediaType: string; title: string; sourceId: string }
|
|
510
516
|
| { type: 'data'; name: string; data: unknown } // escape hatch
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { replayAttachmentParts } from '@/lib/moi-attachments'
|
|
1
2
|
import type {
|
|
2
3
|
AdapterEmit,
|
|
3
4
|
Part,
|
|
@@ -15,7 +16,6 @@ import type {
|
|
|
15
16
|
TurnOrigin
|
|
16
17
|
} from '@/lib/format'
|
|
17
18
|
|
|
18
|
-
import { isAttachmentOnlyPlaceholder, splitAttachmentNote } from '@/lib/attachment-note'
|
|
19
19
|
import { stripMoiContext } from '@/lib/moi-context'
|
|
20
20
|
import { classifySystemMessage, filterSystemText } from '@/lib/system-messages'
|
|
21
21
|
|
|
@@ -544,29 +544,7 @@ export class ClaudeAdapter {
|
|
|
544
544
|
if (b.text) {
|
|
545
545
|
let text = b.text
|
|
546
546
|
if (msg.type === 'user' && !msg.isSynthetic && !systemVerdict) {
|
|
547
|
-
|
|
548
|
-
// appended to the user's text (see lib/attachment-note.ts). The
|
|
549
|
-
// SDK persists that appended text, so fold the note back into
|
|
550
|
-
// file chips here — a reloaded bubble matches the live one
|
|
551
|
-
// instead of leaking temp paths into it.
|
|
552
|
-
const split = splitAttachmentNote(text)
|
|
553
|
-
// moi's own context envelope strips precisely (marker-guarded);
|
|
554
|
-
// other embedded machinery — system reminders, hook output —
|
|
555
|
-
// strips by the shared rules, keeping the typed text.
|
|
556
|
-
text = filterSystemText(stripMoiContext(split.text)).text
|
|
557
|
-
for (const f of split.files) {
|
|
558
|
-
parts.push({
|
|
559
|
-
type: 'file',
|
|
560
|
-
mediaType: 'application/octet-stream',
|
|
561
|
-
url: f.path,
|
|
562
|
-
filename: f.filename
|
|
563
|
-
})
|
|
564
|
-
}
|
|
565
|
-
// An attachment-only message carries a synthesized placeholder
|
|
566
|
-
// prompt; the bubble should show just the attachments.
|
|
567
|
-
if (isAttachmentOnlyPlaceholder(text) && parts.some(p => p.type === 'file')) {
|
|
568
|
-
text = ''
|
|
569
|
-
}
|
|
547
|
+
text = filterSystemText(stripMoiContext(text)).text
|
|
570
548
|
}
|
|
571
549
|
if (text) {
|
|
572
550
|
parts.push({ type: 'text', text })
|
|
@@ -619,13 +597,18 @@ export class ClaudeAdapter {
|
|
|
619
597
|
}
|
|
620
598
|
}
|
|
621
599
|
if (url) {
|
|
622
|
-
parts.push({ type: 'file', mediaType, url,
|
|
600
|
+
parts.push({ type: 'file-attachment', mediaType, previewUrl: url, label: b.filename })
|
|
623
601
|
}
|
|
624
602
|
break
|
|
625
603
|
}
|
|
626
604
|
}
|
|
627
605
|
}
|
|
628
606
|
|
|
607
|
+
if (msg.type === 'user' && !msg.isSynthetic && !systemVerdict) {
|
|
608
|
+
const restored = replayAttachmentParts(parts)
|
|
609
|
+
parts.splice(0, parts.length, ...restored)
|
|
610
|
+
firstText = parts.find(p => p.type === 'text')?.text ?? ''
|
|
611
|
+
}
|
|
629
612
|
if (parts.length === 0) return undefined
|
|
630
613
|
|
|
631
614
|
const role: 'user' | 'assistant' = msg.type === 'user' ? 'user' : 'assistant'
|
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
getCCActiveSessions,
|
|
17
17
|
interruptCCSession,
|
|
18
18
|
killAllCCSessions,
|
|
19
|
+
killWorkspaceSessions,
|
|
19
20
|
restartWorkspaceSessions,
|
|
20
21
|
retireCCSessionsOnCliChange,
|
|
21
22
|
sendCCMessage
|
|
@@ -109,6 +110,7 @@ export const claudeCodeHarness: Harness = {
|
|
|
109
110
|
startLogin: ws => startClaudeLogin(ws.path),
|
|
110
111
|
|
|
111
112
|
onEnvChanged: workspacePath => restartWorkspaceSessions(workspacePath),
|
|
113
|
+
stopWorkspace: workspacePath => killWorkspaceSessions(workspacePath),
|
|
112
114
|
shutdown: () => killAllCCSessions(),
|
|
113
115
|
skillsDir: workspaceRoot => join(workspaceRoot, '.claude', 'skills'),
|
|
114
116
|
|
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
//
|
|
7
7
|
// The SDK persists history to disk. After eviction or a server restart, the
|
|
8
8
|
// next message resumes that history in a new process.
|
|
9
|
+
import { prepareAttachmentMessage, type PreparedAttachmentMessage } from '../../attachment-message'
|
|
10
|
+
import { attachmentLabel } from '@/lib/moi-attachments'
|
|
9
11
|
import {
|
|
10
12
|
type Options,
|
|
11
13
|
type Query,
|
|
@@ -13,7 +15,6 @@ import {
|
|
|
13
15
|
query
|
|
14
16
|
} from '@anthropic-ai/claude-agent-sdk'
|
|
15
17
|
|
|
16
|
-
import { appendAttachmentNote, attachmentOnlyPlaceholder } from '@/lib/attachment-note'
|
|
17
18
|
import { buildSessionTitleSource } from '../session-title'
|
|
18
19
|
import { ClaudeAdapter } from './adapter'
|
|
19
20
|
import { CLAUDE_APPROVAL_HOOKS } from './permissions'
|
|
@@ -28,7 +29,6 @@ import { tapWire } from '../debug'
|
|
|
28
29
|
import { broadcast } from '../../state'
|
|
29
30
|
import { renameSelectedSession } from '../../selected-session'
|
|
30
31
|
import { hasSessionConfig, renameSessionConfig, saveSessionConfig } from '../../session-config'
|
|
31
|
-
import { type StoredUpload, resolveUploads, uploadToDisplayPart } from '../../uploads'
|
|
32
32
|
import {
|
|
33
33
|
markViewBuilderBuildingBySession,
|
|
34
34
|
markViewBuilderWaitingBySession,
|
|
@@ -44,44 +44,25 @@ type ImageMediaType = 'image/jpeg' | 'image/png' | 'image/gif' | 'image/webp'
|
|
|
44
44
|
|
|
45
45
|
type MessageContent = SDKUserMessage['message']['content']
|
|
46
46
|
|
|
47
|
-
//
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
const parts: Part[] = []
|
|
55
|
-
for (const u of uploads) {
|
|
56
|
-
const part = uploadToDisplayPart(u)
|
|
57
|
-
if (part) parts.push(part)
|
|
58
|
-
}
|
|
59
|
-
if (displayText) parts.push({ type: 'text', text: displayText })
|
|
60
|
-
|
|
61
|
-
if (uploads.length === 0) return { content: text, parts }
|
|
62
|
-
|
|
63
|
-
const blocks: Exclude<MessageContent, string> = []
|
|
64
|
-
for (const u of uploads) {
|
|
65
|
-
if (u.kind === 'image' && u.data) {
|
|
66
|
-
blocks.push({
|
|
67
|
-
type: 'image',
|
|
68
|
-
source: {
|
|
69
|
-
type: 'base64',
|
|
70
|
-
media_type: u.mediaType as ImageMediaType,
|
|
71
|
-
data: u.data.toString('base64')
|
|
72
|
-
}
|
|
73
|
-
})
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
const files = uploads.filter(u => u.kind === 'file' && u.path)
|
|
78
|
-
const agentText = appendAttachmentNote(
|
|
79
|
-
text || attachmentOnlyPlaceholder(uploads.map(upload => upload.filename)),
|
|
80
|
-
files.map(f => ({ filename: f.filename, path: f.path! }))
|
|
47
|
+
// Only the native SDK block shape belongs to this harness.
|
|
48
|
+
export function buildUserMessage(message: PreparedAttachmentMessage): {
|
|
49
|
+
content: MessageContent
|
|
50
|
+
parts: Part[]
|
|
51
|
+
} {
|
|
52
|
+
const images = message.attachments.filter(
|
|
53
|
+
attachment => attachment.type === 'image' && 'data' in attachment
|
|
81
54
|
)
|
|
82
|
-
|
|
83
|
-
blocks
|
|
84
|
-
|
|
55
|
+
if (!images.length) return { content: message.text, parts: message.parts }
|
|
56
|
+
const blocks: Exclude<MessageContent, string> = images.map(image => ({
|
|
57
|
+
type: 'image',
|
|
58
|
+
source: {
|
|
59
|
+
type: 'base64',
|
|
60
|
+
media_type: image.mediaType as ImageMediaType,
|
|
61
|
+
data: image.data.toString('base64')
|
|
62
|
+
}
|
|
63
|
+
}))
|
|
64
|
+
blocks.push({ type: 'text', text: message.text })
|
|
65
|
+
return { content: blocks, parts: message.parts }
|
|
85
66
|
}
|
|
86
67
|
|
|
87
68
|
// Each live session owns a subprocess. Only idle sessions can be evicted.
|
|
@@ -711,12 +692,9 @@ function createLiveSession(input: {
|
|
|
711
692
|
// Accept immediately, but keep the prompt and its settings in moi until its
|
|
712
693
|
// turn starts. The returned promise settles when the message reaches the SDK.
|
|
713
694
|
export async function sendCCMessage(input: SendMessageInput): Promise<void> {
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
: []
|
|
718
|
-
if (!input.content && uploads.length === 0) return
|
|
719
|
-
const { content: userContent, parts } = buildUserMessage(input.content, uploads)
|
|
695
|
+
const prepared = prepareAttachmentMessage(input.workspaceId, input.content, input.attachments)
|
|
696
|
+
if (!prepared.text) return
|
|
697
|
+
const { content: userContent, parts } = buildUserMessage(prepared)
|
|
720
698
|
// Keep context in its own block: the SDK skips tag-leading blocks when
|
|
721
699
|
// extracting titles and previews, and the adapter strips them on replay.
|
|
722
700
|
const content: MessageContent = input.context
|
|
@@ -756,7 +734,7 @@ export async function sendCCMessage(input: SendMessageInput): Promise<void> {
|
|
|
756
734
|
timestamp: new Date().toISOString()
|
|
757
735
|
}
|
|
758
736
|
})
|
|
759
|
-
const label = input.content ||
|
|
737
|
+
const label = input.content || prepared.attachments.map(attachmentLabel).join(', ')
|
|
760
738
|
const completion = Promise.withResolvers<void>()
|
|
761
739
|
const accepted = new Promise<void>((resolve, reject) => {
|
|
762
740
|
messages.pending.push({
|
|
@@ -764,7 +742,7 @@ export async function sendCCMessage(input: SendMessageInput): Promise<void> {
|
|
|
764
742
|
content,
|
|
765
743
|
titleSource: buildSessionTitleSource(
|
|
766
744
|
input.content,
|
|
767
|
-
|
|
745
|
+
prepared.attachments.map(attachmentLabel)
|
|
768
746
|
),
|
|
769
747
|
turnId,
|
|
770
748
|
wireId: crypto.randomUUID(),
|
|
@@ -969,6 +947,23 @@ export function restartWorkspaceSessions(workspacePath: string): void {
|
|
|
969
947
|
}
|
|
970
948
|
}
|
|
971
949
|
|
|
950
|
+
// Stop every queued message and subprocess for a workspace being removed.
|
|
951
|
+
export function killWorkspaceSessions(workspacePath: string): void {
|
|
952
|
+
for (const messages of messageQueues.values()) {
|
|
953
|
+
if (messages.workspacePath !== workspacePath) continue
|
|
954
|
+
messages.stopping = true
|
|
955
|
+
cancelPendingMessages(messages, new Error('Workspace removed'))
|
|
956
|
+
messages.active?.complete()
|
|
957
|
+
messages.active = null
|
|
958
|
+
}
|
|
959
|
+
for (const s of [...sessions.values()]) {
|
|
960
|
+
if (s.workspacePath === workspacePath) teardown(s)
|
|
961
|
+
}
|
|
962
|
+
for (const [key, messages] of messageQueues) {
|
|
963
|
+
if (messages.workspacePath === workspacePath) messageQueues.delete(key)
|
|
964
|
+
}
|
|
965
|
+
}
|
|
966
|
+
|
|
972
967
|
// A CLI update may introduce models the current process cannot use. Mark it
|
|
973
968
|
// for replacement at the next safe dispatch boundary.
|
|
974
969
|
export function retireCCSessionsOnCliChange(): void {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// Session discovery + history replay for Claude Code workspaces, backed by
|
|
2
2
|
// the Agent SDK's persisted `.jsonl` session files.
|
|
3
|
+
import { attachmentLabel, splitAttachments, stripAttachmentsLoose } from '@/lib/moi-attachments'
|
|
3
4
|
import {
|
|
4
5
|
getSessionInfo,
|
|
5
6
|
getSessionMessages,
|
|
@@ -35,12 +36,16 @@ export function claudeSessionSummary(
|
|
|
35
36
|
session: Pick<SDKSessionInfo, 'customTitle' | 'firstPrompt' | 'summary'>
|
|
36
37
|
): string {
|
|
37
38
|
if (session.customTitle || !session.firstPrompt || session.summary !== session.firstPrompt) {
|
|
38
|
-
return session.summary
|
|
39
|
+
return stripAttachmentsLoose(session.summary)
|
|
39
40
|
}
|
|
40
|
-
const
|
|
41
|
+
const attached = splitAttachments(session.firstPrompt)
|
|
42
|
+
const split = splitAttachmentNote(attached.text)
|
|
41
43
|
return isAttachmentOnlyPlaceholder(split.text)
|
|
42
44
|
? attachmentOnlyFilenames(split.text).join(', ')
|
|
43
|
-
:
|
|
45
|
+
: stripAttachmentsLoose(split.text) ||
|
|
46
|
+
[...attached.attachments.map(attachmentLabel), ...split.files.map(f => f.filename)].join(
|
|
47
|
+
', '
|
|
48
|
+
)
|
|
44
49
|
}
|
|
45
50
|
|
|
46
51
|
export function visibleClaudeSessions<T extends Pick<SDKSessionInfo, 'tag'>>(sessions: T[]): T[] {
|
|
@@ -67,7 +72,7 @@ export function selectOldestSessionFirstUserMessage(
|
|
|
67
72
|
(a.createdAt ?? a.lastModified) - (b.createdAt ?? b.lastModified) ||
|
|
68
73
|
a.sessionId.localeCompare(b.sessionId)
|
|
69
74
|
)[0]
|
|
70
|
-
return oldest?.firstPrompt
|
|
75
|
+
return oldest?.firstPrompt ? stripAttachmentsLoose(oldest.firstPrompt) : undefined
|
|
71
76
|
}
|
|
72
77
|
|
|
73
78
|
export function selectLatestSessionUpdatedAt(
|