repoburg 1.3.202 → 1.3.209
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/agent-pane/backend/dist/index.js +2103 -32003
- package/agent-pane/backend/dist/server.js +45313 -0
- package/backend/dist/src/agent-runtime/agent-runtime.types.d.ts +1 -0
- package/backend/dist/src/llm-orchestration/hooks/frontend-notification.hook.js +6 -6
- package/backend/dist/src/llm-orchestration/hooks/frontend-notification.hook.js.map +1 -1
- package/backend/dist/src/llm-orchestration/llm-turn-processor.service.js +1 -0
- package/backend/dist/src/llm-orchestration/llm-turn-processor.service.js.map +1 -1
- package/backend/dist/tsconfig.build.tsbuildinfo +1 -1
- package/daemon/dist/agentPane.js +128 -0
- package/daemon/dist/agentPane.spec.js +183 -0
- package/daemon/dist/index.js +28 -8
- package/daemon/package.json +1 -1
- package/model-selector-scroll.png +0 -0
- package/package.json +10 -2
- package/agent-pane/.prettierignore +0 -5
- package/agent-pane/.prettierrc +0 -8
- package/agent-pane/backend/coverage/base.css +0 -224
- package/agent-pane/backend/coverage/block-navigation.js +0 -87
- package/agent-pane/backend/coverage/clover.xml +0 -887
- package/agent-pane/backend/coverage/coverage-final.json +0 -10
- package/agent-pane/backend/coverage/favicon.png +0 -0
- package/agent-pane/backend/coverage/index.html +0 -176
- package/agent-pane/backend/coverage/prettify.css +0 -1
- package/agent-pane/backend/coverage/prettify.js +0 -2
- package/agent-pane/backend/coverage/sort-arrow-sprite.png +0 -0
- package/agent-pane/backend/coverage/sorter.js +0 -210
- package/agent-pane/backend/coverage/src/codex/codex-provider.ts.html +0 -1402
- package/agent-pane/backend/coverage/src/codex/index.html +0 -131
- package/agent-pane/backend/coverage/src/codex/item-mapper.ts.html +0 -331
- package/agent-pane/backend/coverage/src/db/index.html +0 -131
- package/agent-pane/backend/coverage/src/db/index.ts.html +0 -436
- package/agent-pane/backend/coverage/src/db/schema.ts.html +0 -175
- package/agent-pane/backend/coverage/src/index.html +0 -116
- package/agent-pane/backend/coverage/src/index.ts.html +0 -262
- package/agent-pane/backend/coverage/src/routes/index.html +0 -146
- package/agent-pane/backend/coverage/src/routes/sessions.ts.html +0 -991
- package/agent-pane/backend/coverage/src/routes/turns.ts.html +0 -256
- package/agent-pane/backend/coverage/src/routes/workspaces.ts.html +0 -406
- package/agent-pane/backend/coverage/src/ws/index.html +0 -116
- package/agent-pane/backend/coverage/src/ws/index.ts.html +0 -238
- package/agent-pane/backend/data.db +0 -0
- package/agent-pane/backend/data.db-shm +0 -0
- package/agent-pane/backend/data.db-wal +0 -0
- package/agent-pane/backend/package-lock.json +0 -5945
- package/agent-pane/backend/package.json +0 -33
- package/agent-pane/backend/scripts/backfill-from-jsonl.ts +0 -206
- package/agent-pane/backend/scripts/import-session-from-jsonl.ts +0 -264
- package/agent-pane/backend/src/claude/claude-message-mapper.test.ts +0 -271
- package/agent-pane/backend/src/claude/claude-message-mapper.ts +0 -259
- package/agent-pane/backend/src/claude/claude-provider.test.ts +0 -455
- package/agent-pane/backend/src/claude/claude-provider.ts +0 -1319
- package/agent-pane/backend/src/claude/claude-types.ts +0 -45
- package/agent-pane/backend/src/codex/app-server-client.test.ts +0 -183
- package/agent-pane/backend/src/codex/app-server-client.ts +0 -247
- package/agent-pane/backend/src/codex/app-server-types.ts +0 -259
- package/agent-pane/backend/src/codex/codex-provider-runtime-config.test.ts +0 -56
- package/agent-pane/backend/src/codex/codex-provider.test.ts +0 -60
- package/agent-pane/backend/src/codex/codex-provider.ts +0 -619
- package/agent-pane/backend/src/codex/item-mapper.test.ts +0 -221
- package/agent-pane/backend/src/codex/item-mapper.ts +0 -86
- package/agent-pane/backend/src/codex/shared-app-server.ts +0 -25
- package/agent-pane/backend/src/db/index.test.ts +0 -125
- package/agent-pane/backend/src/db/index.ts +0 -236
- package/agent-pane/backend/src/db/schema.ts +0 -34
- package/agent-pane/backend/src/index.ts +0 -89
- package/agent-pane/backend/src/integration/__fixtures__/cancel-turn.json +0 -29
- package/agent-pane/backend/src/integration/__fixtures__/delta-streaming.json +0 -40
- package/agent-pane/backend/src/integration/__fixtures__/failed-turn.json +0 -16
- package/agent-pane/backend/src/integration/__fixtures__/mcp-tool-call.json +0 -60
- package/agent-pane/backend/src/integration/__fixtures__/missing-item-started.json +0 -34
- package/agent-pane/backend/src/integration/__fixtures__/multi-item-turn.json +0 -85
- package/agent-pane/backend/src/integration/__fixtures__/multi-turn.json +0 -48
- package/agent-pane/backend/src/integration/__fixtures__/simple-turn.json +0 -35
- package/agent-pane/backend/src/integration/delta-streaming.test.ts +0 -130
- package/agent-pane/backend/src/integration/helpers/app-server-mock.ts +0 -272
- package/agent-pane/backend/src/integration/helpers/test-app.ts +0 -110
- package/agent-pane/backend/src/integration/helpers/ws-capture.ts +0 -64
- package/agent-pane/backend/src/integration/item-lifecycle.test.ts +0 -133
- package/agent-pane/backend/src/integration/mcp-tool-call.test.ts +0 -102
- package/agent-pane/backend/src/integration/missing-item-started.test.ts +0 -91
- package/agent-pane/backend/src/integration/multi-turn.test.ts +0 -121
- package/agent-pane/backend/src/integration/session-operations.test.ts +0 -175
- package/agent-pane/backend/src/integration/threads-claude-fork.test.ts +0 -241
- package/agent-pane/backend/src/integration/threads.test.ts +0 -309
- package/agent-pane/backend/src/integration/title-generation.test.ts +0 -109
- package/agent-pane/backend/src/integration/turn-cancel.test.ts +0 -111
- package/agent-pane/backend/src/integration/turn-failure.test.ts +0 -97
- package/agent-pane/backend/src/integration/turn-lifecycle.test.ts +0 -141
- package/agent-pane/backend/src/providers/index.ts +0 -16
- package/agent-pane/backend/src/providers/registry.test.ts +0 -92
- package/agent-pane/backend/src/providers/registry.ts +0 -43
- package/agent-pane/backend/src/providers/runtime-provider.ts +0 -49
- package/agent-pane/backend/src/repoburg/action-mapping.test.ts +0 -122
- package/agent-pane/backend/src/repoburg/action-mapping.ts +0 -294
- package/agent-pane/backend/src/repoburg/agent-runtime-client.test.ts +0 -271
- package/agent-pane/backend/src/repoburg/agent-runtime-client.ts +0 -285
- package/agent-pane/backend/src/repoburg/backend-resolver.test.ts +0 -356
- package/agent-pane/backend/src/repoburg/backend-resolver.ts +0 -261
- package/agent-pane/backend/src/repoburg/repoburg-client.test.ts +0 -180
- package/agent-pane/backend/src/repoburg/repoburg-client.ts +0 -194
- package/agent-pane/backend/src/repoburg/repoburg-provider.test.ts +0 -780
- package/agent-pane/backend/src/repoburg/repoburg-provider.ts +0 -471
- package/agent-pane/backend/src/repoburg/turn-projector.test.ts +0 -621
- package/agent-pane/backend/src/repoburg/turn-projector.ts +0 -637
- package/agent-pane/backend/src/routes/files.ts +0 -31
- package/agent-pane/backend/src/routes/mcp.ts +0 -33
- package/agent-pane/backend/src/routes/models.test.ts +0 -92
- package/agent-pane/backend/src/routes/models.ts +0 -16
- package/agent-pane/backend/src/routes/plugins.ts +0 -40
- package/agent-pane/backend/src/routes/providers.test.ts +0 -86
- package/agent-pane/backend/src/routes/providers.ts +0 -86
- package/agent-pane/backend/src/routes/sessions.test.ts +0 -772
- package/agent-pane/backend/src/routes/sessions.ts +0 -565
- package/agent-pane/backend/src/routes/skills.test.ts +0 -114
- package/agent-pane/backend/src/routes/skills.ts +0 -70
- package/agent-pane/backend/src/routes/threads.ts +0 -323
- package/agent-pane/backend/src/routes/turns.test.ts +0 -196
- package/agent-pane/backend/src/routes/turns.ts +0 -103
- package/agent-pane/backend/src/routes/workspaces.test.ts +0 -197
- package/agent-pane/backend/src/routes/workspaces.ts +0 -128
- package/agent-pane/backend/src/ws/index.test.ts +0 -107
- package/agent-pane/backend/src/ws/index.ts +0 -51
- package/agent-pane/backend/tsconfig.json +0 -25
- package/agent-pane/backend/vitest.config.ts +0 -20
- package/agent-pane/eslint.config.js +0 -33
- package/agent-pane/frontend/coverage/base.css +0 -224
- package/agent-pane/frontend/coverage/block-navigation.js +0 -87
- package/agent-pane/frontend/coverage/clover.xml +0 -2962
- package/agent-pane/frontend/coverage/coverage-final.json +0 -37
- package/agent-pane/frontend/coverage/favicon.png +0 -0
- package/agent-pane/frontend/coverage/index.html +0 -251
- package/agent-pane/frontend/coverage/prettify.css +0 -1
- package/agent-pane/frontend/coverage/prettify.js +0 -2
- package/agent-pane/frontend/coverage/sort-arrow-sprite.png +0 -0
- package/agent-pane/frontend/coverage/sorter.js +0 -210
- package/agent-pane/frontend/coverage/src/App.tsx.html +0 -217
- package/agent-pane/frontend/coverage/src/AppInitializer.tsx.html +0 -223
- package/agent-pane/frontend/coverage/src/api/client.ts.html +0 -187
- package/agent-pane/frontend/coverage/src/api/index.html +0 -161
- package/agent-pane/frontend/coverage/src/api/sessions.ts.html +0 -316
- package/agent-pane/frontend/coverage/src/api/websocket.ts.html +0 -544
- package/agent-pane/frontend/coverage/src/api/workspaces.ts.html +0 -199
- package/agent-pane/frontend/coverage/src/components/CollapsibleToolCalls.tsx.html +0 -226
- package/agent-pane/frontend/coverage/src/components/CommandInputBar.tsx.html +0 -382
- package/agent-pane/frontend/coverage/src/components/CommandPalette.tsx.html +0 -715
- package/agent-pane/frontend/coverage/src/components/IdeWorkspace.tsx.html +0 -160
- package/agent-pane/frontend/coverage/src/components/ModelSelector.tsx.html +0 -478
- package/agent-pane/frontend/coverage/src/components/NewSessionDialog.tsx.html +0 -472
- package/agent-pane/frontend/coverage/src/components/RenderArea.tsx.html +0 -574
- package/agent-pane/frontend/coverage/src/components/RightPanel.tsx.html +0 -205
- package/agent-pane/frontend/coverage/src/components/RuntimeIcon.tsx.html +0 -133
- package/agent-pane/frontend/coverage/src/components/SessionTabs.tsx.html +0 -217
- package/agent-pane/frontend/coverage/src/components/StatusBar.tsx.html +0 -271
- package/agent-pane/frontend/coverage/src/components/StatusDot.tsx.html +0 -109
- package/agent-pane/frontend/coverage/src/components/Toast.tsx.html +0 -313
- package/agent-pane/frontend/coverage/src/components/TurnContent.tsx.html +0 -1216
- package/agent-pane/frontend/coverage/src/components/WorkspaceSidebar.tsx.html +0 -1138
- package/agent-pane/frontend/coverage/src/components/index.html +0 -326
- package/agent-pane/frontend/coverage/src/components/panels/ChangesPanel.tsx.html +0 -247
- package/agent-pane/frontend/coverage/src/components/panels/LogsPanel.tsx.html +0 -160
- package/agent-pane/frontend/coverage/src/components/panels/MetricsPanel.tsx.html +0 -427
- package/agent-pane/frontend/coverage/src/components/panels/TurnsPanel.tsx.html +0 -397
- package/agent-pane/frontend/coverage/src/components/panels/index.html +0 -161
- package/agent-pane/frontend/coverage/src/constants/index.html +0 -116
- package/agent-pane/frontend/coverage/src/constants/models.ts.html +0 -406
- package/agent-pane/frontend/coverage/src/hooks/index.html +0 -146
- package/agent-pane/frontend/coverage/src/hooks/useEscapeKey.ts.html +0 -124
- package/agent-pane/frontend/coverage/src/hooks/useOutsideClick.ts.html +0 -142
- package/agent-pane/frontend/coverage/src/hooks/useSessionStatus.ts.html +0 -187
- package/agent-pane/frontend/coverage/src/index.html +0 -146
- package/agent-pane/frontend/coverage/src/main.tsx.html +0 -115
- package/agent-pane/frontend/coverage/src/store/index.html +0 -116
- package/agent-pane/frontend/coverage/src/store/store.ts.html +0 -2404
- package/agent-pane/frontend/coverage/src/test/component-helpers.ts.html +0 -190
- package/agent-pane/frontend/coverage/src/test/fixtures.ts.html +0 -367
- package/agent-pane/frontend/coverage/src/test/index.html +0 -131
- package/agent-pane/frontend/coverage/src/types/index.html +0 -116
- package/agent-pane/frontend/coverage/src/types/index.ts.html +0 -466
- package/agent-pane/frontend/coverage/src/utils/changes.ts.html +0 -202
- package/agent-pane/frontend/coverage/src/utils/duration.ts.html +0 -127
- package/agent-pane/frontend/coverage/src/utils/index.html +0 -131
- package/agent-pane/frontend/dist/assets/index-CJxD4YmJ.js +0 -370
- package/agent-pane/frontend/dist/assets/index-r-xwfOKQ.css +0 -1
- package/agent-pane/frontend/dist/index.html +0 -19
- package/agent-pane/frontend/index.html +0 -18
- package/agent-pane/frontend/package-lock.json +0 -4211
- package/agent-pane/frontend/package.json +0 -35
- package/agent-pane/frontend/src/App.test.tsx +0 -74
- package/agent-pane/frontend/src/App.tsx +0 -44
- package/agent-pane/frontend/src/AppInitializer.test.tsx +0 -142
- package/agent-pane/frontend/src/AppInitializer.tsx +0 -46
- package/agent-pane/frontend/src/__tests__/ThreadsPanel.test.tsx +0 -192
- package/agent-pane/frontend/src/api/client.test.ts +0 -126
- package/agent-pane/frontend/src/api/client.ts +0 -34
- package/agent-pane/frontend/src/api/models.ts +0 -7
- package/agent-pane/frontend/src/api/providers.ts +0 -17
- package/agent-pane/frontend/src/api/sessions.test.ts +0 -246
- package/agent-pane/frontend/src/api/sessions.ts +0 -97
- package/agent-pane/frontend/src/api/skills.ts +0 -12
- package/agent-pane/frontend/src/api/websocket.test.ts +0 -288
- package/agent-pane/frontend/src/api/websocket.ts +0 -240
- package/agent-pane/frontend/src/api/workspaces.test.ts +0 -112
- package/agent-pane/frontend/src/api/workspaces.ts +0 -38
- package/agent-pane/frontend/src/components/AskUserItem.test.tsx +0 -143
- package/agent-pane/frontend/src/components/AskUserItem.tsx +0 -207
- package/agent-pane/frontend/src/components/CollapsibleToolCalls.test.tsx +0 -49
- package/agent-pane/frontend/src/components/CollapsibleToolCalls.tsx +0 -56
- package/agent-pane/frontend/src/components/CommandInputBar.test.tsx +0 -133
- package/agent-pane/frontend/src/components/CommandInputBar.tsx +0 -584
- package/agent-pane/frontend/src/components/CommandPalette.test.tsx +0 -226
- package/agent-pane/frontend/src/components/CommandPalette.tsx +0 -194
- package/agent-pane/frontend/src/components/CommentableText.test.tsx +0 -196
- package/agent-pane/frontend/src/components/CommentableText.tsx +0 -379
- package/agent-pane/frontend/src/components/IdeWorkspace.test.tsx +0 -39
- package/agent-pane/frontend/src/components/IdeWorkspace.tsx +0 -51
- package/agent-pane/frontend/src/components/ModelSelector.test.tsx +0 -129
- package/agent-pane/frontend/src/components/ModelSelector.tsx +0 -191
- package/agent-pane/frontend/src/components/NewSessionDialog.test.tsx +0 -95
- package/agent-pane/frontend/src/components/NewSessionDialog.tsx +0 -129
- package/agent-pane/frontend/src/components/RenderArea.test.tsx +0 -160
- package/agent-pane/frontend/src/components/RenderArea.tsx +0 -170
- package/agent-pane/frontend/src/components/ResizeHandle.tsx +0 -29
- package/agent-pane/frontend/src/components/RightPanel.test.tsx +0 -43
- package/agent-pane/frontend/src/components/RightPanel.tsx +0 -46
- package/agent-pane/frontend/src/components/RuntimeIcon.test.tsx +0 -32
- package/agent-pane/frontend/src/components/RuntimeIcon.tsx +0 -16
- package/agent-pane/frontend/src/components/SessionTabs.test.tsx +0 -72
- package/agent-pane/frontend/src/components/SessionTabs.tsx +0 -49
- package/agent-pane/frontend/src/components/StatusBar.test.tsx +0 -56
- package/agent-pane/frontend/src/components/StatusBar.tsx +0 -129
- package/agent-pane/frontend/src/components/StatusDot.test.tsx +0 -25
- package/agent-pane/frontend/src/components/StatusDot.tsx +0 -8
- package/agent-pane/frontend/src/components/Toast.test.tsx +0 -79
- package/agent-pane/frontend/src/components/Toast.tsx +0 -76
- package/agent-pane/frontend/src/components/TurnContent.test.tsx +0 -377
- package/agent-pane/frontend/src/components/TurnContent.tsx +0 -594
- package/agent-pane/frontend/src/components/WorkspaceSidebar.test.tsx +0 -297
- package/agent-pane/frontend/src/components/WorkspaceSidebar.tsx +0 -351
- package/agent-pane/frontend/src/components/input/OptionSubPopup.tsx +0 -32
- package/agent-pane/frontend/src/components/input/SkillMentionPopup.test.tsx +0 -63
- package/agent-pane/frontend/src/components/input/SkillMentionPopup.tsx +0 -78
- package/agent-pane/frontend/src/components/input/SlashPopup.test.tsx +0 -96
- package/agent-pane/frontend/src/components/input/SlashPopup.tsx +0 -82
- package/agent-pane/frontend/src/components/panels/ChangesPanel.test.tsx +0 -61
- package/agent-pane/frontend/src/components/panels/ChangesPanel.tsx +0 -54
- package/agent-pane/frontend/src/components/panels/TasksPanel.test.tsx +0 -97
- package/agent-pane/frontend/src/components/panels/TasksPanel.tsx +0 -208
- package/agent-pane/frontend/src/components/panels/ThreadsPanel.tsx +0 -382
- package/agent-pane/frontend/src/components/panels/TurnsPanel.test.tsx +0 -131
- package/agent-pane/frontend/src/components/panels/TurnsPanel.tsx +0 -131
- package/agent-pane/frontend/src/constants/models.test.ts +0 -97
- package/agent-pane/frontend/src/constants/models.ts +0 -166
- package/agent-pane/frontend/src/hooks/useEscapeKey.test.ts +0 -42
- package/agent-pane/frontend/src/hooks/useEscapeKey.ts +0 -13
- package/agent-pane/frontend/src/hooks/useOutsideClick.test.ts +0 -92
- package/agent-pane/frontend/src/hooks/useOutsideClick.ts +0 -19
- package/agent-pane/frontend/src/hooks/useProvider.ts +0 -44
- package/agent-pane/frontend/src/hooks/useResizable.test.ts +0 -97
- package/agent-pane/frontend/src/hooks/useResizable.ts +0 -75
- package/agent-pane/frontend/src/hooks/useSessionStatus.test.ts +0 -116
- package/agent-pane/frontend/src/hooks/useSessionStatus.ts +0 -34
- package/agent-pane/frontend/src/main.test.tsx +0 -37
- package/agent-pane/frontend/src/main.tsx +0 -10
- package/agent-pane/frontend/src/store/sessionSlice.ts +0 -440
- package/agent-pane/frontend/src/store/store.test.ts +0 -1338
- package/agent-pane/frontend/src/store/store.ts +0 -37
- package/agent-pane/frontend/src/store/threadSlice.ts +0 -136
- package/agent-pane/frontend/src/store/uiSlice.ts +0 -133
- package/agent-pane/frontend/src/store/workspaceSlice.ts +0 -77
- package/agent-pane/frontend/src/store/wsSlice.ts +0 -368
- package/agent-pane/frontend/src/styles/app.css +0 -627
- package/agent-pane/frontend/src/styles/tokens.css +0 -62
- package/agent-pane/frontend/src/test/component-helpers.ts +0 -38
- package/agent-pane/frontend/src/test/fixtures.ts +0 -101
- package/agent-pane/frontend/src/test-setup.ts +0 -5
- package/agent-pane/frontend/src/types/index.test.ts +0 -128
- package/agent-pane/frontend/src/types/index.ts +0 -134
- package/agent-pane/frontend/src/utils/changes.test.ts +0 -81
- package/agent-pane/frontend/src/utils/changes.ts +0 -39
- package/agent-pane/frontend/src/utils/duration.test.ts +0 -76
- package/agent-pane/frontend/src/utils/duration.ts +0 -14
- package/agent-pane/frontend/tsconfig.json +0 -25
- package/agent-pane/frontend/vite.config.ts +0 -22
- package/agent-pane/frontend/vitest.config.ts +0 -29
- package/agent-pane/package-lock.json +0 -1527
- package/agent-pane/package.json +0 -19
- package/agent-pane/shared/provider-types.ts +0 -67
- package/agent-pane/shared/types.ts +0 -184
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
import { useState, useEffect, useRef, memo } from 'react';
|
|
2
|
-
import { useStore } from '../../store/store.ts';
|
|
3
|
-
import type { Item } from '../../types/index.ts';
|
|
4
|
-
import { SatelliteDish, Bot, Cog, ChevronRight, Check, CircleAlert, Square } from 'lucide-react';
|
|
5
|
-
|
|
6
|
-
/** Maximum output length before truncation (20KB — panel has more room than inline). */
|
|
7
|
-
const MAX_OUTPUT = 20_000;
|
|
8
|
-
|
|
9
|
-
/** A background_task item collected from turns, enriched with turn index for context. */
|
|
10
|
-
interface TaskEntry {
|
|
11
|
-
item: Item;
|
|
12
|
-
turnIndex: number;
|
|
13
|
-
turnPrompt: string;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/** Collect all background_task items from all turns, excluding local_agent
|
|
17
|
-
* (subagents are shown in tabs/subagent views, not in Tasks panel). */
|
|
18
|
-
function collectTaskItems(
|
|
19
|
-
turns: { id: string; user_prompt: string; items: Item[] }[],
|
|
20
|
-
): TaskEntry[] {
|
|
21
|
-
const entries: TaskEntry[] = [];
|
|
22
|
-
turns.forEach((turn, idx) => {
|
|
23
|
-
for (const item of turn.items) {
|
|
24
|
-
if (item.type === 'background_task') {
|
|
25
|
-
// Skip local_agent — subagents have their own tab/view
|
|
26
|
-
const taskType = (item.data?.task_type as string) || 'unknown';
|
|
27
|
-
if (taskType === 'local_agent') continue;
|
|
28
|
-
entries.push({ item, turnIndex: idx, turnPrompt: turn.user_prompt });
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
return entries;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/** Render a single task card with live output. */
|
|
36
|
-
function TaskCard({ entry }: { entry: TaskEntry }) {
|
|
37
|
-
const { item, turnIndex, turnPrompt } = entry;
|
|
38
|
-
const data = item.data || {};
|
|
39
|
-
const taskType = (data.task_type as string) || 'unknown';
|
|
40
|
-
const subagentType = (data.subagent_type as string) || null;
|
|
41
|
-
const desc = (data.description as string) || '';
|
|
42
|
-
const taskStatus = (data.status as string) || 'running';
|
|
43
|
-
const summary = (data.summary as string) || null;
|
|
44
|
-
const lastTool = (data.last_tool_name as string) || null;
|
|
45
|
-
const tokenCount = (data.token_count as number) || null;
|
|
46
|
-
const output = (data.output as string) || '';
|
|
47
|
-
const isRunning = item.status === 'in_progress';
|
|
48
|
-
const isSubagent = taskType === 'local_agent';
|
|
49
|
-
const isMonitor = taskType === 'local_bash';
|
|
50
|
-
const TaskIcon = isSubagent ? Bot : isMonitor ? SatelliteDish : Cog;
|
|
51
|
-
const typeLabel = isSubagent
|
|
52
|
-
? `Subagent${subagentType ? `: ${subagentType}` : ''}`
|
|
53
|
-
: isMonitor
|
|
54
|
-
? 'Monitor'
|
|
55
|
-
: 'Background Task';
|
|
56
|
-
const statusLabel =
|
|
57
|
-
taskStatus === 'running'
|
|
58
|
-
? 'running…'
|
|
59
|
-
: taskStatus === 'completed'
|
|
60
|
-
? 'done'
|
|
61
|
-
: taskStatus === 'failed'
|
|
62
|
-
? 'failed'
|
|
63
|
-
: taskStatus === 'stopped'
|
|
64
|
-
? 'stopped'
|
|
65
|
-
: taskStatus;
|
|
66
|
-
const isFailed = item.status === 'failed' || taskStatus === 'failed';
|
|
67
|
-
|
|
68
|
-
const [expanded, setExpanded] = useState(isRunning);
|
|
69
|
-
const [showFullOutput, setShowFullOutput] = useState(false);
|
|
70
|
-
const outputRef = useRef<HTMLPreElement>(null);
|
|
71
|
-
|
|
72
|
-
// Auto-expand while running, auto-collapse on completion
|
|
73
|
-
useEffect(() => {
|
|
74
|
-
if (isRunning) setExpanded(true);
|
|
75
|
-
}, [isRunning]);
|
|
76
|
-
|
|
77
|
-
// Auto-scroll output to bottom for running tasks
|
|
78
|
-
useEffect(() => {
|
|
79
|
-
if (expanded && isRunning && outputRef.current) {
|
|
80
|
-
outputRef.current.scrollTop = outputRef.current.scrollHeight;
|
|
81
|
-
}
|
|
82
|
-
}, [expanded, isRunning, output]);
|
|
83
|
-
|
|
84
|
-
const isTruncated = output.length > MAX_OUTPUT;
|
|
85
|
-
const displayOutput =
|
|
86
|
-
isTruncated && !showFullOutput
|
|
87
|
-
? output.slice(0, MAX_OUTPUT) + '\n… (truncated, click to expand)'
|
|
88
|
-
: output;
|
|
89
|
-
|
|
90
|
-
const statusIcon = isRunning ? null : taskStatus === 'completed' ? <Check size={12} /> : isFailed ? <CircleAlert size={12} /> : <Square size={12} />;
|
|
91
|
-
|
|
92
|
-
return (
|
|
93
|
-
<div className={`task-card ${isRunning ? 'task-running' : ''} ${isFailed ? 'task-failed' : ''}`}>
|
|
94
|
-
<div className="task-card-header" onClick={() => setExpanded((e) => !e)} style={{ cursor: 'pointer' }}>
|
|
95
|
-
<span className="task-card-icon">
|
|
96
|
-
<TaskIcon size={14} />
|
|
97
|
-
</span>
|
|
98
|
-
<span className="task-card-type">{typeLabel}</span>
|
|
99
|
-
<span className={`task-card-status ${isFailed ? 'task-status-failed' : isRunning ? 'task-status-running' : 'task-status-done'}`}>
|
|
100
|
-
{statusIcon} {statusLabel}
|
|
101
|
-
</span>
|
|
102
|
-
<ChevronRight
|
|
103
|
-
size={14}
|
|
104
|
-
className="task-card-chevron"
|
|
105
|
-
style={{ transform: expanded ? 'rotate(90deg)' : 'none', marginLeft: 'auto' }}
|
|
106
|
-
/>
|
|
107
|
-
</div>
|
|
108
|
-
|
|
109
|
-
{desc && <div className="task-card-desc">{desc}</div>}
|
|
110
|
-
|
|
111
|
-
{isRunning && lastTool && (
|
|
112
|
-
<div className="task-card-meta">
|
|
113
|
-
last tool: {lastTool}
|
|
114
|
-
{tokenCount != null && ` · ${tokenCount.toLocaleString()} tokens`}
|
|
115
|
-
</div>
|
|
116
|
-
)}
|
|
117
|
-
|
|
118
|
-
{expanded && (
|
|
119
|
-
<div className="task-card-body">
|
|
120
|
-
{output ? (
|
|
121
|
-
<>
|
|
122
|
-
<pre className="cmd-output task-output" ref={outputRef}>
|
|
123
|
-
<code>{displayOutput}</code>
|
|
124
|
-
</pre>
|
|
125
|
-
{isTruncated && (
|
|
126
|
-
<button className="cmd-output-toggle" onClick={() => setShowFullOutput((v) => !v)}>
|
|
127
|
-
{showFullOutput ? 'Show less' : `Show full output (${(output.length / 1024).toFixed(0)}KB)`}
|
|
128
|
-
</button>
|
|
129
|
-
)}
|
|
130
|
-
</>
|
|
131
|
-
) : summary ? (
|
|
132
|
-
<pre className="cmd-output task-output">
|
|
133
|
-
<code>{summary}</code>
|
|
134
|
-
</pre>
|
|
135
|
-
) : isRunning ? (
|
|
136
|
-
<div className="task-card-placeholder">Waiting for output…</div>
|
|
137
|
-
) : (
|
|
138
|
-
<div className="task-card-placeholder">No output captured.</div>
|
|
139
|
-
)}
|
|
140
|
-
<div className="task-card-context" title={turnPrompt}>
|
|
141
|
-
from turn {turnIndex + 1}: {turnPrompt.length > 60 ? turnPrompt.slice(0, 60) + '…' : turnPrompt}
|
|
142
|
-
</div>
|
|
143
|
-
</div>
|
|
144
|
-
)}
|
|
145
|
-
</div>
|
|
146
|
-
);
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
const MemoTaskCard = memo(TaskCard);
|
|
150
|
-
|
|
151
|
-
function TasksPanelBase() {
|
|
152
|
-
const activeSessionId = useStore((s) => s.activeSessionId);
|
|
153
|
-
const sessionDetails = useStore((s) => s.sessionDetails);
|
|
154
|
-
|
|
155
|
-
const detail = activeSessionId ? sessionDetails[activeSessionId] : null;
|
|
156
|
-
const turns = detail?.turns ?? [];
|
|
157
|
-
const bgTasks = detail?.backgroundTasks ?? [];
|
|
158
|
-
|
|
159
|
-
// Collect all background_task items from all turns
|
|
160
|
-
const taskEntries = collectTaskItems(turns);
|
|
161
|
-
|
|
162
|
-
// Sort: running first, then by turn index (most recent first within same status)
|
|
163
|
-
const sorted = [...taskEntries].sort((a, b) => {
|
|
164
|
-
const aRunning = a.item.status === 'in_progress';
|
|
165
|
-
const bRunning = b.item.status === 'in_progress';
|
|
166
|
-
if (aRunning && !bRunning) return -1;
|
|
167
|
-
if (!aRunning && bRunning) return 1;
|
|
168
|
-
return b.turnIndex - a.turnIndex;
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
// Count active tasks from both backgroundTasks event and in_progress items (dedup by task_id)
|
|
172
|
-
// Only count local_bash monitors — local_agent subagents are in tabs, not Tasks panel
|
|
173
|
-
const activeTypes = new Map<string, string>();
|
|
174
|
-
for (const t of bgTasks) {
|
|
175
|
-
if (t.task_type === 'local_bash') activeTypes.set(t.task_id, t.task_type);
|
|
176
|
-
}
|
|
177
|
-
for (const entry of taskEntries) {
|
|
178
|
-
if (entry.item.status === 'in_progress') {
|
|
179
|
-
const taskId = (entry.item.data?.task_id as string) ?? entry.item.external_item_id;
|
|
180
|
-
const taskType = (entry.item.data?.task_type as string) ?? 'unknown';
|
|
181
|
-
activeTypes.set(taskId, taskType);
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
const monitorCount = [...activeTypes.values()].filter((t) => t === 'local_bash').length;
|
|
185
|
-
|
|
186
|
-
if (taskEntries.length === 0) {
|
|
187
|
-
return <div className="empty-state">No background tasks yet</div>;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
return (
|
|
191
|
-
<div className="right-section">
|
|
192
|
-
<div className="right-section-title">
|
|
193
|
-
Background Tasks ({taskEntries.length})
|
|
194
|
-
{monitorCount > 0 && (
|
|
195
|
-
<span className="task-count-badge" style={{ color: 'var(--amber)' }}>
|
|
196
|
-
{' '}{monitorCount} running
|
|
197
|
-
</span>
|
|
198
|
-
)}
|
|
199
|
-
</div>
|
|
200
|
-
{sorted.map((entry) => (
|
|
201
|
-
<MemoTaskCard key={entry.item.id} entry={entry} />
|
|
202
|
-
))}
|
|
203
|
-
</div>
|
|
204
|
-
);
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
const TasksPanel = memo(TasksPanelBase);
|
|
208
|
-
export default TasksPanel;
|
|
@@ -1,382 +0,0 @@
|
|
|
1
|
-
import { useState, useRef, useCallback, useEffect } from 'react';
|
|
2
|
-
import { marked } from 'marked';
|
|
3
|
-
import DOMPurify from 'dompurify';
|
|
4
|
-
import { CheckCircle2, RotateCcw, Trash2, Send, MessageSquare, Navigation, Quote } from 'lucide-react';
|
|
5
|
-
import { useStore } from '../../store/store.ts';
|
|
6
|
-
import type { DiscussionThread, Turn, Item } from '../../types/index.ts';
|
|
7
|
-
|
|
8
|
-
marked.setOptions({ breaks: true, gfm: true });
|
|
9
|
-
|
|
10
|
-
function renderMarkdown(content: string): string {
|
|
11
|
-
const raw = marked.parse(content) as string;
|
|
12
|
-
return DOMPurify.sanitize(raw);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/** Extract text from item data (agent_message has {text}). */
|
|
16
|
-
function itemText(item: Item): string {
|
|
17
|
-
if (item.data?.text) return item.data.text as string;
|
|
18
|
-
return '';
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/** Strip the quoted prefix from a thread turn's user_prompt for display. */
|
|
22
|
-
function stripQuotePrefix(prompt: string): string {
|
|
23
|
-
const match = prompt.match(/^\[Quoting from your previous response\]:\n> .*\n\n([\s\S]*)$/);
|
|
24
|
-
return match ? match[1] : prompt;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
type ThreadFilter = 'open' | 'resolved' | 'all';
|
|
28
|
-
|
|
29
|
-
/** Render a single thread turn's conversation (user message + AI response). */
|
|
30
|
-
function ThreadTurnView({ turn }: { turn: Turn }) {
|
|
31
|
-
const agentItems = turn.items.filter((i) => i.type === 'agent_message');
|
|
32
|
-
const displayPrompt = stripQuotePrefix(turn.user_prompt);
|
|
33
|
-
|
|
34
|
-
return (
|
|
35
|
-
<div className="thread-card-turn">
|
|
36
|
-
{/* User message */}
|
|
37
|
-
<div className="thread-card-user-message">{displayPrompt}</div>
|
|
38
|
-
{/* AI responses */}
|
|
39
|
-
{agentItems.map((item) => (
|
|
40
|
-
<div
|
|
41
|
-
key={item.id}
|
|
42
|
-
className="thread-card-ai-response"
|
|
43
|
-
dangerouslySetInnerHTML={{ __html: renderMarkdown(itemText(item)) }}
|
|
44
|
-
/>
|
|
45
|
-
))}
|
|
46
|
-
{/* Pending state */}
|
|
47
|
-
{turn.items.length === 0 && (turn.status === 'pending' || turn.status === 'running') && (
|
|
48
|
-
<div className="thread-card-pending">{turn.status === 'running' ? 'AI is responding…' : 'Waiting…'}</div>
|
|
49
|
-
)}
|
|
50
|
-
</div>
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function ThreadCard({
|
|
55
|
-
thread,
|
|
56
|
-
isRunning,
|
|
57
|
-
threadTurns,
|
|
58
|
-
onResolve,
|
|
59
|
-
onReopen,
|
|
60
|
-
onDelete,
|
|
61
|
-
onFollowup,
|
|
62
|
-
onLocate,
|
|
63
|
-
}: {
|
|
64
|
-
thread: DiscussionThread;
|
|
65
|
-
isRunning: boolean;
|
|
66
|
-
threadTurns: Turn[];
|
|
67
|
-
onResolve: () => void;
|
|
68
|
-
onReopen: () => void;
|
|
69
|
-
onDelete: () => void;
|
|
70
|
-
onFollowup: (message: string) => void;
|
|
71
|
-
onLocate: () => void;
|
|
72
|
-
}) {
|
|
73
|
-
const [followup, setFollowup] = useState('');
|
|
74
|
-
const [expanded, setExpanded] = useState(true);
|
|
75
|
-
const followupRef = useRef<HTMLTextAreaElement>(null);
|
|
76
|
-
const conversationRef = useRef<HTMLDivElement>(null);
|
|
77
|
-
const [showQuoteBtn, setShowQuoteBtn] = useState(false);
|
|
78
|
-
const [quoteBtnPos, setQuoteBtnPos] = useState({ x: 0, y: 0 });
|
|
79
|
-
const [selectedText, setSelectedText] = useState('');
|
|
80
|
-
|
|
81
|
-
const FOLLOWUP_MIN = 28;
|
|
82
|
-
const FOLLOWUP_MAX = 120;
|
|
83
|
-
|
|
84
|
-
// Auto-scroll to bottom (latest message) when turns change or card expands
|
|
85
|
-
useEffect(() => {
|
|
86
|
-
const el = conversationRef.current;
|
|
87
|
-
if (el) el.scrollTop = el.scrollHeight;
|
|
88
|
-
}, [threadTurns.length, expanded]);
|
|
89
|
-
|
|
90
|
-
function autoResizeFollowup() {
|
|
91
|
-
const el = followupRef.current;
|
|
92
|
-
if (!el) return;
|
|
93
|
-
el.style.height = 'auto';
|
|
94
|
-
el.style.height = Math.min(el.scrollHeight, FOLLOWUP_MAX) + 'px';
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
const handleConversationMouseDown = useCallback(() => {
|
|
98
|
-
setShowQuoteBtn(false);
|
|
99
|
-
}, []);
|
|
100
|
-
|
|
101
|
-
const checkSelection = useCallback(() => {
|
|
102
|
-
const container = conversationRef.current;
|
|
103
|
-
if (!container) return;
|
|
104
|
-
const sel = window.getSelection();
|
|
105
|
-
if (!sel || sel.rangeCount === 0 || sel.isCollapsed) {
|
|
106
|
-
setShowQuoteBtn(false);
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
const range = sel.getRangeAt(0);
|
|
110
|
-
if (!container.contains(range.commonAncestorContainer)) {
|
|
111
|
-
setShowQuoteBtn(false);
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
// Only show quote button when selection is within an AI response
|
|
115
|
-
const targetEl =
|
|
116
|
-
range.commonAncestorContainer.nodeType === Node.TEXT_NODE
|
|
117
|
-
? range.commonAncestorContainer.parentElement
|
|
118
|
-
: (range.commonAncestorContainer as HTMLElement);
|
|
119
|
-
if (!targetEl?.closest('.thread-card-ai-response')) {
|
|
120
|
-
setShowQuoteBtn(false);
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
|
-
const text = sel.toString();
|
|
124
|
-
if (!text.trim()) {
|
|
125
|
-
setShowQuoteBtn(false);
|
|
126
|
-
return;
|
|
127
|
-
}
|
|
128
|
-
const selRect = range.getBoundingClientRect();
|
|
129
|
-
const BUTTON_HEIGHT = 28;
|
|
130
|
-
const GAP = 6;
|
|
131
|
-
const BUTTON_WIDTH_EST = 170;
|
|
132
|
-
|
|
133
|
-
// Detect backward selection via anchor (press) vs focus (release) order.
|
|
134
|
-
let backward = false;
|
|
135
|
-
if (sel.anchorNode && sel.focusNode) {
|
|
136
|
-
try {
|
|
137
|
-
const fr = document.createRange();
|
|
138
|
-
fr.setStart(sel.focusNode, sel.focusOffset);
|
|
139
|
-
fr.setEnd(sel.focusNode, sel.focusOffset);
|
|
140
|
-
const ar = document.createRange();
|
|
141
|
-
ar.setStart(sel.anchorNode, sel.anchorOffset);
|
|
142
|
-
ar.setEnd(sel.anchorNode, sel.anchorOffset);
|
|
143
|
-
backward = ar.compareBoundaryPoints(Range.START_TO_START, fr) > 0;
|
|
144
|
-
} catch {
|
|
145
|
-
backward = false;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
let btnY = selRect.top - BUTTON_HEIGHT - GAP;
|
|
150
|
-
if (btnY < 8) btnY = selRect.bottom + GAP;
|
|
151
|
-
let btnX = backward ? selRect.left - BUTTON_WIDTH_EST : selRect.right;
|
|
152
|
-
btnX = Math.max(8, Math.min(btnX, window.innerWidth - BUTTON_WIDTH_EST - 8));
|
|
153
|
-
setQuoteBtnPos({ x: btnX, y: btnY });
|
|
154
|
-
setSelectedText(text);
|
|
155
|
-
setShowQuoteBtn(true);
|
|
156
|
-
}, []);
|
|
157
|
-
|
|
158
|
-
// Detect selections on mouseup anywhere in the document so that releasing
|
|
159
|
-
// the mouse in the surrounding padding (common with backward drags) still
|
|
160
|
-
// registers the quote button.
|
|
161
|
-
useEffect(() => {
|
|
162
|
-
function onDocMouseUp(e: MouseEvent) {
|
|
163
|
-
const t = e.target as HTMLElement | null;
|
|
164
|
-
if (t && t.closest('.selection-actions')) return;
|
|
165
|
-
checkSelection();
|
|
166
|
-
}
|
|
167
|
-
document.addEventListener('mouseup', onDocMouseUp);
|
|
168
|
-
return () => document.removeEventListener('mouseup', onDocMouseUp);
|
|
169
|
-
}, [checkSelection]);
|
|
170
|
-
|
|
171
|
-
const handleQuoteClick = useCallback(() => {
|
|
172
|
-
const formatted = `\n\`\`\`QUOTE\n${selectedText}\n\`\`\`\n\n`;
|
|
173
|
-
setFollowup((prev) => prev + formatted);
|
|
174
|
-
setShowQuoteBtn(false);
|
|
175
|
-
setSelectedText('');
|
|
176
|
-
window.getSelection()?.removeAllRanges();
|
|
177
|
-
setTimeout(() => {
|
|
178
|
-
if (followupRef.current) {
|
|
179
|
-
followupRef.current.style.height = 'auto';
|
|
180
|
-
followupRef.current.style.height = Math.min(followupRef.current.scrollHeight, FOLLOWUP_MAX) + 'px';
|
|
181
|
-
followupRef.current.focus();
|
|
182
|
-
const len = followupRef.current.value.length;
|
|
183
|
-
followupRef.current.setSelectionRange(len, len);
|
|
184
|
-
}
|
|
185
|
-
}, 0);
|
|
186
|
-
}, [selectedText]);
|
|
187
|
-
|
|
188
|
-
return (
|
|
189
|
-
<div className={`thread-card ${thread.status === 'resolved' ? 'thread-resolved' : ''}`} id={`thread-${thread.id}`}>
|
|
190
|
-
{/* Header: quoted text + status */}
|
|
191
|
-
<div className="thread-card-header" onClick={() => setExpanded((e) => !e)}>
|
|
192
|
-
<div className="thread-card-quote">
|
|
193
|
-
“{thread.selected_text.slice(0, 100)}{thread.selected_text.length > 100 ? '…' : ''}”
|
|
194
|
-
</div>
|
|
195
|
-
<div className="thread-card-header-right">
|
|
196
|
-
<button
|
|
197
|
-
className="thread-locate-btn"
|
|
198
|
-
onClick={(e) => { e.stopPropagation(); onLocate(); }}
|
|
199
|
-
title="Scroll to text"
|
|
200
|
-
>
|
|
201
|
-
<Navigation size={12} />
|
|
202
|
-
</button>
|
|
203
|
-
<span className={`thread-status-badge ${thread.status === 'open' ? 'thread-status-open' : 'thread-status-resolved'}`}>
|
|
204
|
-
{thread.status === 'open' ? 'Open' : 'Resolved'}
|
|
205
|
-
</span>
|
|
206
|
-
</div>
|
|
207
|
-
</div>
|
|
208
|
-
|
|
209
|
-
{/* Conversation history */}
|
|
210
|
-
{expanded && (
|
|
211
|
-
<>
|
|
212
|
-
<div
|
|
213
|
-
className="thread-card-conversation"
|
|
214
|
-
ref={conversationRef}
|
|
215
|
-
onMouseDown={handleConversationMouseDown}
|
|
216
|
-
>
|
|
217
|
-
{threadTurns.map((turn) => (
|
|
218
|
-
<ThreadTurnView key={turn.id} turn={turn} />
|
|
219
|
-
))}
|
|
220
|
-
{threadTurns.length === 0 && (
|
|
221
|
-
<div className="thread-card-placeholder">No messages yet.</div>
|
|
222
|
-
)}
|
|
223
|
-
</div>
|
|
224
|
-
|
|
225
|
-
{/* Floating Quote button — shown when text is selected in an AI response */}
|
|
226
|
-
{showQuoteBtn && (
|
|
227
|
-
<div className="selection-actions" style={{ left: quoteBtnPos.x, top: quoteBtnPos.y }}>
|
|
228
|
-
<button
|
|
229
|
-
className="discuss-button"
|
|
230
|
-
onClick={handleQuoteClick}
|
|
231
|
-
title="Quote this text in your follow-up"
|
|
232
|
-
>
|
|
233
|
-
<Quote size={14} />
|
|
234
|
-
<span>Quote</span>
|
|
235
|
-
</button>
|
|
236
|
-
</div>
|
|
237
|
-
)}
|
|
238
|
-
|
|
239
|
-
{/* Follow-up input (only for open threads) */}
|
|
240
|
-
{thread.status === 'open' && (
|
|
241
|
-
<div className="thread-card-followup">
|
|
242
|
-
<textarea
|
|
243
|
-
ref={followupRef}
|
|
244
|
-
className="thread-card-followup-input"
|
|
245
|
-
placeholder={isRunning ? 'Agent is running…' : 'Type a follow-up…'}
|
|
246
|
-
value={followup}
|
|
247
|
-
onChange={(e) => {
|
|
248
|
-
setFollowup(e.target.value);
|
|
249
|
-
autoResizeFollowup();
|
|
250
|
-
}}
|
|
251
|
-
disabled={isRunning}
|
|
252
|
-
rows={1}
|
|
253
|
-
style={{ minHeight: FOLLOWUP_MIN, maxHeight: FOLLOWUP_MAX }}
|
|
254
|
-
onKeyDown={(e) => {
|
|
255
|
-
if (e.key === 'Enter' && (e.metaKey || e.ctrlKey) && !isRunning && followup.trim()) {
|
|
256
|
-
e.preventDefault();
|
|
257
|
-
onFollowup(followup.trim());
|
|
258
|
-
setFollowup('');
|
|
259
|
-
if (followupRef.current) followupRef.current.style.height = FOLLOWUP_MIN + 'px';
|
|
260
|
-
}
|
|
261
|
-
}}
|
|
262
|
-
/>
|
|
263
|
-
<button
|
|
264
|
-
className="thread-card-followup-send"
|
|
265
|
-
disabled={isRunning || !followup.trim()}
|
|
266
|
-
onClick={() => {
|
|
267
|
-
onFollowup(followup.trim());
|
|
268
|
-
setFollowup('');
|
|
269
|
-
}}
|
|
270
|
-
>
|
|
271
|
-
<Send size={13} />
|
|
272
|
-
</button>
|
|
273
|
-
</div>
|
|
274
|
-
)}
|
|
275
|
-
|
|
276
|
-
{/* Actions */}
|
|
277
|
-
<div className="thread-card-actions">
|
|
278
|
-
{thread.status === 'open' ? (
|
|
279
|
-
<button className="thread-action-btn" onClick={onResolve} title="Resolve thread">
|
|
280
|
-
<CheckCircle2 size={13} /> Resolve
|
|
281
|
-
</button>
|
|
282
|
-
) : (
|
|
283
|
-
<button className="thread-action-btn" onClick={onReopen} title="Reopen thread">
|
|
284
|
-
<RotateCcw size={13} /> Reopen
|
|
285
|
-
</button>
|
|
286
|
-
)}
|
|
287
|
-
<button className="thread-action-btn thread-action-danger" onClick={onDelete} title="Delete thread">
|
|
288
|
-
<Trash2 size={13} /> Delete
|
|
289
|
-
</button>
|
|
290
|
-
</div>
|
|
291
|
-
</>
|
|
292
|
-
)}
|
|
293
|
-
</div>
|
|
294
|
-
);
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
export default function ThreadsPanel() {
|
|
298
|
-
const { activeSessionId, sessionDetails, followupThread, resolveThread, reopenThread, deleteThread, activeRightTab, switchRightTab } = useStore();
|
|
299
|
-
const [filter, setFilter] = useState<ThreadFilter>('open');
|
|
300
|
-
|
|
301
|
-
const detail = activeSessionId ? sessionDetails[activeSessionId] : null;
|
|
302
|
-
const threads = detail?.threads ?? [];
|
|
303
|
-
const allTurns = detail?.turns ?? [];
|
|
304
|
-
const isRunning = detail?.is_running === 1;
|
|
305
|
-
|
|
306
|
-
const filtered = threads.filter((t) => {
|
|
307
|
-
if (filter === 'open') return t.status === 'open';
|
|
308
|
-
if (filter === 'resolved') return t.status === 'resolved';
|
|
309
|
-
return true;
|
|
310
|
-
});
|
|
311
|
-
|
|
312
|
-
const openCount = threads.filter((t) => t.status === 'open').length;
|
|
313
|
-
const resolvedCount = threads.filter((t) => t.status === 'resolved').length;
|
|
314
|
-
|
|
315
|
-
/** Scroll the render area to the <mark> anchored by this thread. */
|
|
316
|
-
function handleLocate(threadId: string) {
|
|
317
|
-
// If on changes tab, marks are not in DOM — switch to turns first
|
|
318
|
-
if (activeRightTab === 'changes') {
|
|
319
|
-
switchRightTab('turns');
|
|
320
|
-
}
|
|
321
|
-
setTimeout(() => {
|
|
322
|
-
const mark = document.querySelector(`mark[data-thread-id="${threadId}"]`);
|
|
323
|
-
if (mark) {
|
|
324
|
-
mark.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
|
325
|
-
mark.classList.add('thread-mark-flash');
|
|
326
|
-
setTimeout(() => mark.classList.remove('thread-mark-flash'), 1500);
|
|
327
|
-
}
|
|
328
|
-
}, activeRightTab === 'changes' ? 150 : 50);
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
if (!activeSessionId) {
|
|
332
|
-
return <div className="empty-state">No session selected</div>;
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
if (threads.length === 0) {
|
|
336
|
-
return (
|
|
337
|
-
<div className="empty-state">
|
|
338
|
-
<MessageSquare size={24} style={{ opacity: 0.3, marginBottom: 8 }} />
|
|
339
|
-
<div>No threads yet.</div>
|
|
340
|
-
<div style={{ fontSize: '11px', marginTop: '4px' }}>Select text in an agent response to start a discussion.</div>
|
|
341
|
-
</div>
|
|
342
|
-
);
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
return (
|
|
346
|
-
<div>
|
|
347
|
-
{/* Filter tabs */}
|
|
348
|
-
<div className="thread-filter-tabs">
|
|
349
|
-
<button className={`thread-filter-tab ${filter === 'open' ? 'active' : ''}`} onClick={() => setFilter('open')}>
|
|
350
|
-
Open ({openCount})
|
|
351
|
-
</button>
|
|
352
|
-
<button className={`thread-filter-tab ${filter === 'resolved' ? 'active' : ''}`} onClick={() => setFilter('resolved')}>
|
|
353
|
-
Resolved ({resolvedCount})
|
|
354
|
-
</button>
|
|
355
|
-
<button className={`thread-filter-tab ${filter === 'all' ? 'active' : ''}`} onClick={() => setFilter('all')}>
|
|
356
|
-
All ({threads.length})
|
|
357
|
-
</button>
|
|
358
|
-
</div>
|
|
359
|
-
|
|
360
|
-
{/* Thread list */}
|
|
361
|
-
{filtered.length === 0 ? (
|
|
362
|
-
<div className="empty-state" style={{ padding: '20px 0' }}>
|
|
363
|
-
No {filter} threads.
|
|
364
|
-
</div>
|
|
365
|
-
) : (
|
|
366
|
-
filtered.map((thread) => (
|
|
367
|
-
<ThreadCard
|
|
368
|
-
key={thread.id}
|
|
369
|
-
thread={thread}
|
|
370
|
-
isRunning={isRunning}
|
|
371
|
-
threadTurns={allTurns.filter((t) => t.thread_id === thread.id)}
|
|
372
|
-
onResolve={() => resolveThread(activeSessionId, thread.id)}
|
|
373
|
-
onReopen={() => reopenThread(activeSessionId, thread.id)}
|
|
374
|
-
onDelete={() => deleteThread(activeSessionId, thread.id)}
|
|
375
|
-
onFollowup={(msg) => followupThread(activeSessionId, thread.id, msg)}
|
|
376
|
-
onLocate={() => handleLocate(thread.id)}
|
|
377
|
-
/>
|
|
378
|
-
))
|
|
379
|
-
)}
|
|
380
|
-
</div>
|
|
381
|
-
);
|
|
382
|
-
}
|