repoburg 1.3.188 → 1.3.196
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/.prettierignore +5 -0
- package/agent-pane/.prettierrc +8 -0
- package/agent-pane/backend/coverage/base.css +224 -0
- package/agent-pane/backend/coverage/block-navigation.js +87 -0
- package/agent-pane/backend/coverage/clover.xml +887 -0
- package/agent-pane/backend/coverage/coverage-final.json +10 -0
- package/agent-pane/backend/coverage/favicon.png +0 -0
- package/agent-pane/backend/coverage/index.html +176 -0
- package/agent-pane/backend/coverage/prettify.css +1 -0
- package/agent-pane/backend/coverage/prettify.js +2 -0
- package/agent-pane/backend/coverage/sort-arrow-sprite.png +0 -0
- package/agent-pane/backend/coverage/sorter.js +210 -0
- package/agent-pane/backend/coverage/src/codex/codex-provider.ts.html +1402 -0
- package/agent-pane/backend/coverage/src/codex/index.html +131 -0
- package/agent-pane/backend/coverage/src/codex/item-mapper.ts.html +331 -0
- package/agent-pane/backend/coverage/src/db/index.html +131 -0
- package/agent-pane/backend/coverage/src/db/index.ts.html +436 -0
- package/agent-pane/backend/coverage/src/db/schema.ts.html +175 -0
- package/agent-pane/backend/coverage/src/index.html +116 -0
- package/agent-pane/backend/coverage/src/index.ts.html +262 -0
- package/agent-pane/backend/coverage/src/routes/index.html +146 -0
- package/agent-pane/backend/coverage/src/routes/sessions.ts.html +991 -0
- package/agent-pane/backend/coverage/src/routes/turns.ts.html +256 -0
- package/agent-pane/backend/coverage/src/routes/workspaces.ts.html +406 -0
- package/agent-pane/backend/coverage/src/ws/index.html +116 -0
- package/agent-pane/backend/coverage/src/ws/index.ts.html +238 -0
- 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/dist/index.js +70869 -0
- package/agent-pane/backend/package-lock.json +4529 -1013
- package/agent-pane/backend/package.json +10 -6
- package/agent-pane/backend/src/claude/claude-message-mapper.test.ts +163 -0
- package/agent-pane/backend/src/claude/claude-message-mapper.ts +154 -0
- package/agent-pane/backend/src/claude/claude-provider.test.ts +65 -0
- package/agent-pane/backend/src/claude/claude-provider.ts +482 -0
- package/agent-pane/backend/src/claude/claude-types.ts +33 -0
- package/agent-pane/backend/src/codex/app-server-client.test.ts +183 -0
- package/agent-pane/backend/src/codex/app-server-client.ts +225 -0
- package/agent-pane/backend/src/codex/app-server-types.ts +259 -0
- package/agent-pane/backend/src/codex/codex-provider-runtime-config.test.ts +56 -0
- package/agent-pane/backend/src/codex/codex-provider.test.ts +60 -0
- package/agent-pane/backend/src/codex/codex-provider.ts +521 -265
- package/agent-pane/backend/src/codex/item-mapper.test.ts +221 -0
- package/agent-pane/backend/src/codex/item-mapper.ts +35 -8
- package/agent-pane/backend/src/codex/shared-app-server.ts +25 -0
- package/agent-pane/backend/src/db/index.test.ts +125 -0
- package/agent-pane/backend/src/db/index.ts +39 -8
- package/agent-pane/backend/src/db/schema.ts +28 -74
- package/agent-pane/backend/src/index.ts +29 -2
- package/agent-pane/backend/src/integration/__fixtures__/cancel-turn.json +29 -0
- package/agent-pane/backend/src/integration/__fixtures__/delta-streaming.json +40 -0
- package/agent-pane/backend/src/integration/__fixtures__/failed-turn.json +16 -0
- package/agent-pane/backend/src/integration/__fixtures__/mcp-tool-call.json +60 -0
- package/agent-pane/backend/src/integration/__fixtures__/missing-item-started.json +34 -0
- package/agent-pane/backend/src/integration/__fixtures__/multi-item-turn.json +85 -0
- package/agent-pane/backend/src/integration/__fixtures__/multi-turn.json +48 -0
- package/agent-pane/backend/src/integration/__fixtures__/simple-turn.json +35 -0
- package/agent-pane/backend/src/integration/delta-streaming.test.ts +130 -0
- package/agent-pane/backend/src/integration/helpers/app-server-mock.ts +272 -0
- package/agent-pane/backend/src/integration/helpers/test-app.ts +108 -0
- package/agent-pane/backend/src/integration/helpers/ws-capture.ts +64 -0
- package/agent-pane/backend/src/integration/item-lifecycle.test.ts +133 -0
- package/agent-pane/backend/src/integration/mcp-tool-call.test.ts +102 -0
- package/agent-pane/backend/src/integration/missing-item-started.test.ts +91 -0
- package/agent-pane/backend/src/integration/multi-turn.test.ts +121 -0
- package/agent-pane/backend/src/integration/session-operations.test.ts +168 -0
- package/agent-pane/backend/src/integration/title-generation.test.ts +109 -0
- package/agent-pane/backend/src/integration/turn-cancel.test.ts +111 -0
- package/agent-pane/backend/src/integration/turn-failure.test.ts +97 -0
- package/agent-pane/backend/src/integration/turn-lifecycle.test.ts +141 -0
- package/agent-pane/backend/src/providers/index.ts +14 -0
- package/agent-pane/backend/src/providers/registry.test.ts +92 -0
- package/agent-pane/backend/src/providers/registry.ts +43 -0
- package/agent-pane/backend/src/providers/runtime-provider.ts +25 -0
- package/agent-pane/backend/src/routes/files.ts +31 -0
- package/agent-pane/backend/src/routes/mcp.ts +33 -0
- package/agent-pane/backend/src/routes/models.test.ts +92 -0
- package/agent-pane/backend/src/routes/models.ts +16 -0
- package/agent-pane/backend/src/routes/plugins.ts +40 -0
- package/agent-pane/backend/src/routes/providers.test.ts +69 -0
- package/agent-pane/backend/src/routes/providers.ts +57 -0
- package/agent-pane/backend/src/routes/sessions.test.ts +424 -0
- package/agent-pane/backend/src/routes/sessions.ts +295 -42
- package/agent-pane/backend/src/routes/skills.test.ts +114 -0
- package/agent-pane/backend/src/routes/skills.ts +70 -0
- package/agent-pane/backend/src/routes/turns.test.ts +152 -0
- package/agent-pane/backend/src/routes/turns.ts +36 -16
- package/agent-pane/backend/src/routes/workspaces.test.ts +197 -0
- package/agent-pane/backend/src/routes/workspaces.ts +73 -55
- package/agent-pane/backend/src/ws/index.test.ts +107 -0
- package/agent-pane/backend/src/ws/index.ts +19 -11
- package/agent-pane/backend/tsconfig.json +4 -2
- package/agent-pane/backend/vitest.config.ts +20 -0
- package/agent-pane/eslint.config.js +33 -0
- package/agent-pane/frontend/coverage/base.css +224 -0
- package/agent-pane/frontend/coverage/block-navigation.js +87 -0
- package/agent-pane/frontend/coverage/clover.xml +2962 -0
- package/agent-pane/frontend/coverage/coverage-final.json +37 -0
- package/agent-pane/frontend/coverage/favicon.png +0 -0
- package/agent-pane/frontend/coverage/index.html +251 -0
- package/agent-pane/frontend/coverage/prettify.css +1 -0
- package/agent-pane/frontend/coverage/prettify.js +2 -0
- package/agent-pane/frontend/coverage/sort-arrow-sprite.png +0 -0
- package/agent-pane/frontend/coverage/sorter.js +210 -0
- package/agent-pane/frontend/coverage/src/App.tsx.html +217 -0
- package/agent-pane/frontend/coverage/src/AppInitializer.tsx.html +223 -0
- package/agent-pane/frontend/coverage/src/api/client.ts.html +187 -0
- package/agent-pane/frontend/coverage/src/api/index.html +161 -0
- package/agent-pane/frontend/coverage/src/api/sessions.ts.html +316 -0
- package/agent-pane/frontend/coverage/src/api/websocket.ts.html +544 -0
- package/agent-pane/frontend/coverage/src/api/workspaces.ts.html +199 -0
- package/agent-pane/frontend/coverage/src/components/CollapsibleToolCalls.tsx.html +226 -0
- package/agent-pane/frontend/coverage/src/components/CommandInputBar.tsx.html +382 -0
- package/agent-pane/frontend/coverage/src/components/CommandPalette.tsx.html +715 -0
- package/agent-pane/frontend/coverage/src/components/IdeWorkspace.tsx.html +160 -0
- package/agent-pane/frontend/coverage/src/components/ModelSelector.tsx.html +478 -0
- package/agent-pane/frontend/coverage/src/components/NewSessionDialog.tsx.html +472 -0
- package/agent-pane/frontend/coverage/src/components/RenderArea.tsx.html +574 -0
- package/agent-pane/frontend/coverage/src/components/RightPanel.tsx.html +205 -0
- package/agent-pane/frontend/coverage/src/components/RuntimeIcon.tsx.html +133 -0
- package/agent-pane/frontend/coverage/src/components/SessionTabs.tsx.html +217 -0
- package/agent-pane/frontend/coverage/src/components/StatusBar.tsx.html +271 -0
- package/agent-pane/frontend/coverage/src/components/StatusDot.tsx.html +109 -0
- package/agent-pane/frontend/coverage/src/components/Toast.tsx.html +313 -0
- package/agent-pane/frontend/coverage/src/components/TurnContent.tsx.html +1216 -0
- package/agent-pane/frontend/coverage/src/components/WorkspaceSidebar.tsx.html +1138 -0
- package/agent-pane/frontend/coverage/src/components/index.html +326 -0
- package/agent-pane/frontend/coverage/src/components/panels/ChangesPanel.tsx.html +247 -0
- package/agent-pane/frontend/coverage/src/components/panels/LogsPanel.tsx.html +160 -0
- package/agent-pane/frontend/coverage/src/components/panels/MetricsPanel.tsx.html +427 -0
- package/agent-pane/frontend/coverage/src/components/panels/TurnsPanel.tsx.html +397 -0
- package/agent-pane/frontend/coverage/src/components/panels/index.html +161 -0
- package/agent-pane/frontend/coverage/src/constants/index.html +116 -0
- package/agent-pane/frontend/coverage/src/constants/models.ts.html +406 -0
- package/agent-pane/frontend/coverage/src/hooks/index.html +146 -0
- package/agent-pane/frontend/coverage/src/hooks/useEscapeKey.ts.html +124 -0
- package/agent-pane/frontend/coverage/src/hooks/useOutsideClick.ts.html +142 -0
- package/agent-pane/frontend/coverage/src/hooks/useSessionStatus.ts.html +187 -0
- package/agent-pane/frontend/coverage/src/index.html +146 -0
- package/agent-pane/frontend/coverage/src/main.tsx.html +115 -0
- package/agent-pane/frontend/coverage/src/store/index.html +116 -0
- package/agent-pane/frontend/coverage/src/store/store.ts.html +2404 -0
- package/agent-pane/frontend/coverage/src/test/component-helpers.ts.html +190 -0
- package/agent-pane/frontend/coverage/src/test/fixtures.ts.html +367 -0
- package/agent-pane/frontend/coverage/src/test/index.html +131 -0
- package/agent-pane/frontend/coverage/src/types/index.html +116 -0
- package/agent-pane/frontend/coverage/src/types/index.ts.html +466 -0
- package/agent-pane/frontend/coverage/src/utils/changes.ts.html +202 -0
- package/agent-pane/frontend/coverage/src/utils/duration.ts.html +127 -0
- package/agent-pane/frontend/coverage/src/utils/index.html +131 -0
- package/agent-pane/frontend/dist/assets/index-Bg0PF2aV.css +1 -0
- package/agent-pane/frontend/dist/assets/index-BlybeX5e.js +281 -0
- package/agent-pane/frontend/dist/index.html +19 -0
- package/agent-pane/frontend/package-lock.json +2434 -213
- package/agent-pane/frontend/package.json +10 -3
- package/agent-pane/frontend/src/App.test.tsx +74 -0
- package/agent-pane/frontend/src/App.tsx +1 -1
- package/agent-pane/frontend/src/AppInitializer.test.tsx +142 -0
- package/agent-pane/frontend/src/AppInitializer.tsx +1 -1
- package/agent-pane/frontend/src/api/client.test.ts +126 -0
- package/agent-pane/frontend/src/api/client.ts +22 -29
- package/agent-pane/frontend/src/api/models.ts +7 -0
- package/agent-pane/frontend/src/api/providers.ts +12 -0
- package/agent-pane/frontend/src/api/sessions.test.ts +241 -0
- package/agent-pane/frontend/src/api/sessions.ts +43 -1
- package/agent-pane/frontend/src/api/skills.ts +12 -0
- package/agent-pane/frontend/src/api/websocket.test.ts +288 -0
- package/agent-pane/frontend/src/api/websocket.ts +27 -2
- package/agent-pane/frontend/src/api/workspaces.test.ts +112 -0
- package/agent-pane/frontend/src/api/workspaces.ts +17 -3
- package/agent-pane/frontend/src/components/CollapsibleToolCalls.test.tsx +49 -0
- package/agent-pane/frontend/src/components/CollapsibleToolCalls.tsx +2 -5
- package/agent-pane/frontend/src/components/CommandInputBar.test.tsx +133 -0
- package/agent-pane/frontend/src/components/CommandInputBar.tsx +296 -17
- package/agent-pane/frontend/src/components/CommandPalette.test.tsx +230 -0
- package/agent-pane/frontend/src/components/CommandPalette.tsx +26 -23
- package/agent-pane/frontend/src/components/IdeWorkspace.tsx +1 -1
- package/agent-pane/frontend/src/components/ModelSelector.test.tsx +129 -0
- package/agent-pane/frontend/src/components/ModelSelector.tsx +191 -0
- package/agent-pane/frontend/src/components/NewSessionDialog.test.tsx +95 -0
- package/agent-pane/frontend/src/components/NewSessionDialog.tsx +58 -13
- package/agent-pane/frontend/src/components/RenderArea.test.tsx +160 -0
- package/agent-pane/frontend/src/components/RenderArea.tsx +18 -25
- package/agent-pane/frontend/src/components/RightPanel.test.tsx +43 -0
- package/agent-pane/frontend/src/components/RightPanel.tsx +1 -1
- package/agent-pane/frontend/src/components/RuntimeIcon.test.tsx +32 -0
- package/agent-pane/frontend/src/components/RuntimeIcon.tsx +1 -1
- package/agent-pane/frontend/src/components/SessionTabs.test.tsx +72 -0
- package/agent-pane/frontend/src/components/SessionTabs.tsx +12 -12
- package/agent-pane/frontend/src/components/StatusBar.test.tsx +56 -0
- package/agent-pane/frontend/src/components/StatusBar.tsx +25 -31
- package/agent-pane/frontend/src/components/StatusDot.test.tsx +25 -0
- package/agent-pane/frontend/src/components/StatusDot.tsx +2 -7
- package/agent-pane/frontend/src/components/Toast.test.tsx +79 -0
- package/agent-pane/frontend/src/components/Toast.tsx +2 -6
- package/agent-pane/frontend/src/components/TurnContent.test.tsx +287 -0
- package/agent-pane/frontend/src/components/TurnContent.tsx +107 -24
- package/agent-pane/frontend/src/components/WorkspaceSidebar.test.tsx +297 -0
- package/agent-pane/frontend/src/components/WorkspaceSidebar.tsx +33 -32
- package/agent-pane/frontend/src/components/input/OptionSubPopup.tsx +32 -0
- package/agent-pane/frontend/src/components/input/SkillMentionPopup.test.tsx +63 -0
- package/agent-pane/frontend/src/components/input/SkillMentionPopup.tsx +78 -0
- package/agent-pane/frontend/src/components/input/SlashPopup.test.tsx +96 -0
- package/agent-pane/frontend/src/components/input/SlashPopup.tsx +63 -0
- package/agent-pane/frontend/src/components/panels/ChangesPanel.test.tsx +61 -0
- package/agent-pane/frontend/src/components/panels/ChangesPanel.tsx +12 -39
- package/agent-pane/frontend/src/components/panels/LogsPanel.test.tsx +58 -0
- package/agent-pane/frontend/src/components/panels/LogsPanel.tsx +1 -1
- package/agent-pane/frontend/src/components/panels/MetricsPanel.test.tsx +71 -0
- package/agent-pane/frontend/src/components/panels/MetricsPanel.tsx +63 -31
- package/agent-pane/frontend/src/components/panels/TurnsPanel.test.tsx +83 -0
- package/agent-pane/frontend/src/components/panels/TurnsPanel.tsx +66 -7
- package/agent-pane/frontend/src/constants/models.test.ts +97 -0
- package/agent-pane/frontend/src/constants/models.ts +129 -0
- package/agent-pane/frontend/src/hooks/useEscapeKey.test.ts +42 -0
- package/agent-pane/frontend/src/hooks/useEscapeKey.ts +13 -0
- package/agent-pane/frontend/src/hooks/useOutsideClick.test.ts +92 -0
- package/agent-pane/frontend/src/hooks/useOutsideClick.ts +19 -0
- package/agent-pane/frontend/src/hooks/useProvider.ts +44 -0
- package/agent-pane/frontend/src/hooks/useSessionStatus.test.ts +114 -0
- package/agent-pane/frontend/src/hooks/useSessionStatus.ts +34 -0
- package/agent-pane/frontend/src/main.test.tsx +37 -0
- package/agent-pane/frontend/src/main.tsx +1 -1
- package/agent-pane/frontend/src/store/sessionSlice.ts +417 -0
- package/agent-pane/frontend/src/store/store.test.ts +1284 -0
- package/agent-pane/frontend/src/store/store.ts +16 -617
- package/agent-pane/frontend/src/store/uiSlice.ts +83 -0
- package/agent-pane/frontend/src/store/workspaceSlice.ts +77 -0
- package/agent-pane/frontend/src/store/wsSlice.ts +292 -0
- package/agent-pane/frontend/src/styles/app.css +113 -7
- package/agent-pane/frontend/src/test/component-helpers.ts +36 -0
- package/agent-pane/frontend/src/test/fixtures.ts +96 -0
- package/agent-pane/frontend/src/test-setup.ts +5 -0
- package/agent-pane/frontend/src/types/index.test.ts +128 -0
- package/agent-pane/frontend/src/types/index.ts +80 -104
- package/agent-pane/frontend/src/utils/changes.test.ts +81 -0
- package/agent-pane/frontend/src/utils/changes.ts +39 -0
- package/agent-pane/frontend/src/utils/duration.test.ts +71 -0
- package/agent-pane/frontend/src/utils/duration.ts +14 -0
- package/agent-pane/frontend/tsconfig.json +4 -1
- package/agent-pane/frontend/vite.config.ts +6 -0
- package/agent-pane/frontend/vitest.config.ts +29 -0
- package/agent-pane/package-lock.json +1527 -0
- package/agent-pane/package.json +19 -0
- package/agent-pane/shared/provider-types.ts +53 -0
- package/agent-pane/shared/types.ts +107 -0
- package/agentpane-branch-session.png +0 -0
- package/agentpane-expanded-all.png +0 -0
- package/agentpane-fixed-rendering.png +0 -0
- package/agentpane-focus-check.png +0 -0
- package/agentpane-initial.png +0 -0
- package/agentpane-mcp-detail.png +0 -0
- package/agentpane-no-focus-ring.png +0 -0
- package/agentpane-soft-focus.png +0 -0
- package/backend/dist/src/llm-provider/ollama-llm.provider.js +1 -0
- package/backend/dist/src/llm-provider/ollama-llm.provider.js.map +1 -1
- package/backend/dist/tsconfig.build.tsbuildinfo +1 -1
- package/data.db +0 -0
- package/empty-state.png +0 -0
- package/frontend-home.png +0 -0
- package/model-selector-open.png +0 -0
- package/package.json +1 -1
- package/slash-popup-working.png +0 -0
- package/agent-pane/frontend/src/components/DiffViewer.tsx +0 -27
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared test fixtures for frontend tests.
|
|
3
|
+
*
|
|
4
|
+
* Factory functions for creating typed test objects with sensible defaults.
|
|
5
|
+
* Imported by store tests and component tests to keep fixture logic DRY.
|
|
6
|
+
*/
|
|
7
|
+
import type { Session, SessionDetail, Turn, Item, ItemType, TokenUsage, Workspace } from '@agentpane/shared';
|
|
8
|
+
|
|
9
|
+
const NOW = '2025-01-01T00:00:00Z';
|
|
10
|
+
|
|
11
|
+
/** Create a Session with optional overrides. */
|
|
12
|
+
export function makeSession(id: string, overrides: Partial<Session> = {}): Session {
|
|
13
|
+
return {
|
|
14
|
+
id,
|
|
15
|
+
title: null,
|
|
16
|
+
runtime_type: 'codex',
|
|
17
|
+
model: null,
|
|
18
|
+
model_reasoning_effort: null,
|
|
19
|
+
cwd: null,
|
|
20
|
+
external_thread_id: null,
|
|
21
|
+
status: 'active',
|
|
22
|
+
is_running: 0,
|
|
23
|
+
lifecycle: 'working',
|
|
24
|
+
has_unreviewed: 0,
|
|
25
|
+
runtime_config: null,
|
|
26
|
+
created_at: NOW,
|
|
27
|
+
updated_at: NOW,
|
|
28
|
+
...overrides,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** Create a SessionDetail with turns and optional overrides. */
|
|
33
|
+
export function makeDetail(id: string, turns: Turn[] = [], overrides: Partial<SessionDetail> = {}): SessionDetail {
|
|
34
|
+
return {
|
|
35
|
+
...makeSession(id),
|
|
36
|
+
turns,
|
|
37
|
+
...overrides,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** Create a Turn with optional overrides. */
|
|
42
|
+
export function makeTurn(id: string, sessionId: string, overrides: Partial<Turn> = {}): Turn {
|
|
43
|
+
return {
|
|
44
|
+
id,
|
|
45
|
+
session_id: sessionId,
|
|
46
|
+
user_prompt: 'test prompt',
|
|
47
|
+
agent_response: null,
|
|
48
|
+
thoughts: null,
|
|
49
|
+
token_usage: null,
|
|
50
|
+
external_turn_id: null,
|
|
51
|
+
status: 'completed',
|
|
52
|
+
error: null,
|
|
53
|
+
created_at: NOW,
|
|
54
|
+
updated_at: NOW,
|
|
55
|
+
items: [],
|
|
56
|
+
...overrides,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** Create an Item with a given type and optional data. */
|
|
61
|
+
export function makeItem(id: string, turnId: string, type: ItemType = 'agent_message'): Item {
|
|
62
|
+
return {
|
|
63
|
+
id,
|
|
64
|
+
turn_id: turnId,
|
|
65
|
+
external_item_id: `ext-${id}`,
|
|
66
|
+
type,
|
|
67
|
+
data: { text: 'hello' },
|
|
68
|
+
status: 'completed',
|
|
69
|
+
created_at: NOW,
|
|
70
|
+
updated_at: NOW,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** Create a TokenUsage object with optional overrides. */
|
|
75
|
+
export function makeUsage(overrides: Partial<TokenUsage> = {}): TokenUsage {
|
|
76
|
+
return {
|
|
77
|
+
input_tokens: 100,
|
|
78
|
+
cached_input_tokens: 0,
|
|
79
|
+
cache_write_input_tokens: 0,
|
|
80
|
+
output_tokens: 200,
|
|
81
|
+
reasoning_output_tokens: 0,
|
|
82
|
+
...overrides,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** Create a Workspace with optional overrides. */
|
|
87
|
+
export function makeWorkspace(id: string, path: string, overrides: Partial<Workspace> = {}): Workspace {
|
|
88
|
+
return {
|
|
89
|
+
id,
|
|
90
|
+
path,
|
|
91
|
+
label: null,
|
|
92
|
+
deleted: 0,
|
|
93
|
+
created_at: NOW,
|
|
94
|
+
...overrides,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
|
|
2
|
+
import { runtimeIcon, formatDuration, statusToDot, statusToLabel } from './index.ts';
|
|
3
|
+
|
|
4
|
+
describe('runtimeIcon', () => {
|
|
5
|
+
it('maps codex to ic-codex/CX', () => {
|
|
6
|
+
expect(runtimeIcon('codex')).toEqual({ iconClass: 'ic-codex', iconText: 'CX' });
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
it('maps claude to ic-claude/CL', () => {
|
|
10
|
+
expect(runtimeIcon('claude')).toEqual({ iconClass: 'ic-claude', iconText: 'CL' });
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it('maps repoburg to ic-repoburg/RB', () => {
|
|
14
|
+
expect(runtimeIcon('repoburg')).toEqual({ iconClass: 'ic-repoburg', iconText: 'RB' });
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it('maps cursor to ic-cursor/CR', () => {
|
|
18
|
+
expect(runtimeIcon('cursor')).toEqual({ iconClass: 'ic-cursor', iconText: 'CR' });
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('defaults to codex for unknown runtime', () => {
|
|
22
|
+
expect(runtimeIcon('unknown')).toEqual({ iconClass: 'ic-codex', iconText: 'CX' });
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
describe('formatDuration', () => {
|
|
27
|
+
beforeEach(() => {
|
|
28
|
+
vi.useFakeTimers();
|
|
29
|
+
vi.setSystemTime(new Date('2025-01-01T00:01:00Z'));
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
afterEach(() => {
|
|
33
|
+
vi.useRealTimers();
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('returns seconds only for <60s', () => {
|
|
37
|
+
expect(formatDuration('2025-01-01T00:00:45Z', '2025-01-01T00:00:50Z')).toBe('5s');
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('returns 0s for same timestamps', () => {
|
|
41
|
+
expect(formatDuration('2025-01-01T00:00:00Z', '2025-01-01T00:00:00Z')).toBe('0s');
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('returns minutes and seconds for 60-3599s', () => {
|
|
45
|
+
expect(formatDuration('2025-01-01T00:00:00Z', '2025-01-01T00:03:42Z')).toBe('3m 42s');
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it('returns hours and minutes for >=3600s', () => {
|
|
49
|
+
expect(formatDuration('2025-01-01T00:00:00Z', '2025-01-01T01:23:00Z')).toBe('1h 23m');
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('uses Date.now() when endISO is null', () => {
|
|
53
|
+
// start is 2025-01-01T00:00:00Z, now is 2025-01-01T00:01:00Z → 60s
|
|
54
|
+
expect(formatDuration('2025-01-01T00:00:00Z', null)).toBe('1m 0s');
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
describe('statusToDot', () => {
|
|
59
|
+
it('returns empty string when lifecycle is finished', () => {
|
|
60
|
+
expect(statusToDot('active', false, false, 'finished')).toBe('');
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it('returns running when isRunning is true', () => {
|
|
64
|
+
expect(statusToDot('active', true)).toBe('running');
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('returns queued when hasUnreviewed and not failed', () => {
|
|
68
|
+
expect(statusToDot('active', false, true)).toBe('queued');
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it('does not return queued when hasUnreviewed and status is failed', () => {
|
|
72
|
+
expect(statusToDot('failed', false, true)).toBe('error');
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it('returns error for failed status', () => {
|
|
76
|
+
expect(statusToDot('failed', false)).toBe('error');
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it('returns paused for aborted status', () => {
|
|
80
|
+
expect(statusToDot('aborted', false)).toBe('paused');
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it('returns paused for active status (default)', () => {
|
|
84
|
+
expect(statusToDot('active', false)).toBe('paused');
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it('returns paused for completed status', () => {
|
|
88
|
+
expect(statusToDot('completed', false)).toBe('paused');
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
describe('statusToLabel', () => {
|
|
93
|
+
it('returns Finished when lifecycle is finished', () => {
|
|
94
|
+
expect(statusToLabel('active', false, false, 'finished')).toBe('Finished');
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it('returns Running when isRunning is true', () => {
|
|
98
|
+
expect(statusToLabel('active', true)).toBe('Running');
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
it('returns Review Pending when hasUnreviewed and not failed', () => {
|
|
102
|
+
expect(statusToLabel('active', false, true)).toBe('Review Pending');
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
it('returns Failed for failed status', () => {
|
|
106
|
+
expect(statusToLabel('failed', false)).toBe('Failed');
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it('returns Aborted for aborted status', () => {
|
|
110
|
+
expect(statusToLabel('aborted', false)).toBe('Aborted');
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
it('returns Idle for active status', () => {
|
|
114
|
+
expect(statusToLabel('active', false)).toBe('Idle');
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
it('returns Completed for completed status', () => {
|
|
118
|
+
expect(statusToLabel('completed', false)).toBe('Completed');
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it('returns Running for running status', () => {
|
|
122
|
+
expect(statusToLabel('running', false)).toBe('Running');
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
it('returns raw status string for unknown status', () => {
|
|
126
|
+
expect(statusToLabel('custom', false)).toBe('custom');
|
|
127
|
+
});
|
|
128
|
+
});
|
|
@@ -1,79 +1,20 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export type
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
title: string | null;
|
|
19
|
-
runtime_type: string;
|
|
20
|
-
model: string | null;
|
|
21
|
-
cwd: string | null;
|
|
22
|
-
external_thread_id: string | null;
|
|
23
|
-
status: SessionStatus;
|
|
24
|
-
is_running: number; // 0 | 1
|
|
25
|
-
lifecycle: 'working' | 'finished';
|
|
26
|
-
has_unreviewed: number; // 0 | 1
|
|
27
|
-
created_at: string;
|
|
28
|
-
updated_at: string;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export interface TokenUsage {
|
|
32
|
-
input_tokens: number;
|
|
33
|
-
cached_input_tokens: number;
|
|
34
|
-
cache_write_input_tokens: number;
|
|
35
|
-
output_tokens: number;
|
|
36
|
-
reasoning_output_tokens: number;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export interface Item {
|
|
40
|
-
id: string;
|
|
41
|
-
turn_id: string;
|
|
42
|
-
external_item_id: string | null;
|
|
43
|
-
type: ItemType;
|
|
44
|
-
data: Record<string, unknown> | null;
|
|
45
|
-
status: ItemStatus;
|
|
46
|
-
created_at: string;
|
|
47
|
-
updated_at: string;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export interface Turn {
|
|
51
|
-
id: string;
|
|
52
|
-
session_id: string;
|
|
53
|
-
user_prompt: string;
|
|
54
|
-
agent_response: string | null;
|
|
55
|
-
thoughts: string | null;
|
|
56
|
-
token_usage: TokenUsage | null;
|
|
57
|
-
external_turn_id: string | null;
|
|
58
|
-
status: TurnStatus;
|
|
59
|
-
error: string | null;
|
|
60
|
-
created_at: string;
|
|
61
|
-
updated_at: string;
|
|
62
|
-
items: Item[];
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export interface SessionDetail extends Session {
|
|
66
|
-
turns: Turn[];
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// Workspace — directory path for grouping sessions in sidebar
|
|
70
|
-
export interface Workspace {
|
|
71
|
-
id: string;
|
|
72
|
-
path: string;
|
|
73
|
-
label: string | null;
|
|
74
|
-
deleted: number; // 0 = active, 1 = soft-deleted (hidden from sidebar)
|
|
75
|
-
created_at: string;
|
|
76
|
-
}
|
|
1
|
+
// Frontend types — re-exports shared types and adds UI-only types + helper functions.
|
|
2
|
+
// Shared types (Session, Turn, Item, Workspace, TokenUsage, etc.) come from @agentpane/shared.
|
|
3
|
+
|
|
4
|
+
export type {
|
|
5
|
+
SessionStatus,
|
|
6
|
+
TurnStatus,
|
|
7
|
+
ItemType,
|
|
8
|
+
ItemStatus,
|
|
9
|
+
Session,
|
|
10
|
+
Turn,
|
|
11
|
+
TokenUsage,
|
|
12
|
+
Item,
|
|
13
|
+
Workspace,
|
|
14
|
+
SessionDetail,
|
|
15
|
+
} from '@agentpane/shared';
|
|
16
|
+
|
|
17
|
+
export type { ProviderDefinition, ProviderCapabilities, SessionRuntimeConfig, ModelInfo, Extension } from '@agentpane/shared';
|
|
77
18
|
|
|
78
19
|
// UI-only types (not from backend)
|
|
79
20
|
|
|
@@ -83,13 +24,6 @@ export interface LogEntry {
|
|
|
83
24
|
message: string;
|
|
84
25
|
}
|
|
85
26
|
|
|
86
|
-
export interface DiffLine {
|
|
87
|
-
type: 'add' | 'del' | 'ctx';
|
|
88
|
-
content: string;
|
|
89
|
-
oldLine?: number;
|
|
90
|
-
newLine?: number;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
27
|
export interface PaletteCommand {
|
|
94
28
|
id: string;
|
|
95
29
|
label: string;
|
|
@@ -100,18 +34,32 @@ export interface PaletteCommand {
|
|
|
100
34
|
export type RightTab = 'turns' | 'metrics' | 'changes' | 'logs';
|
|
101
35
|
export type ChangesScope = 'session' | 'turngroup';
|
|
102
36
|
|
|
103
|
-
|
|
37
|
+
/**
|
|
38
|
+
* Map a runtime type string to an icon class and text badge for the UI.
|
|
39
|
+
* @param runtimeType — The session's `runtime_type` field (e.g. `'codex'`, `'claude'`).
|
|
40
|
+
* @returns An object with `iconClass` (CSS class) and `iconText` (2-letter badge).
|
|
41
|
+
*/
|
|
104
42
|
export function runtimeIcon(runtimeType: string): { iconClass: string; iconText: string } {
|
|
105
43
|
switch (runtimeType) {
|
|
106
|
-
case 'claude':
|
|
107
|
-
|
|
108
|
-
case '
|
|
109
|
-
|
|
110
|
-
|
|
44
|
+
case 'claude':
|
|
45
|
+
return { iconClass: 'ic-claude', iconText: 'CL' };
|
|
46
|
+
case 'codex':
|
|
47
|
+
return { iconClass: 'ic-codex', iconText: 'CX' };
|
|
48
|
+
case 'repoburg':
|
|
49
|
+
return { iconClass: 'ic-repoburg', iconText: 'RB' };
|
|
50
|
+
case 'cursor':
|
|
51
|
+
return { iconClass: 'ic-cursor', iconText: 'CR' };
|
|
52
|
+
default:
|
|
53
|
+
return { iconClass: 'ic-codex', iconText: 'CX' };
|
|
111
54
|
}
|
|
112
55
|
}
|
|
113
56
|
|
|
114
|
-
|
|
57
|
+
/**
|
|
58
|
+
* Format a duration between two ISO timestamps as a human-readable string.
|
|
59
|
+
* @param startISO — Start timestamp in ISO 8601 format.
|
|
60
|
+
* @param endISO — End timestamp in ISO 8601 format, or `null` to use `Date.now()` (for running sessions).
|
|
61
|
+
* @returns Duration string like `'12s'`, `'3m 42s'`, or `'1h 23m'`.
|
|
62
|
+
*/
|
|
115
63
|
export function formatDuration(startISO: string, endISO: string | null): string {
|
|
116
64
|
const start = new Date(startISO).getTime();
|
|
117
65
|
const end = endISO ? new Date(endISO).getTime() : Date.now();
|
|
@@ -125,29 +73,57 @@ export function formatDuration(startISO: string, endISO: string | null): string
|
|
|
125
73
|
return `${hours}h ${remMin}m`;
|
|
126
74
|
}
|
|
127
75
|
|
|
128
|
-
|
|
129
|
-
|
|
76
|
+
/**
|
|
77
|
+
* Map a session's state to a CSS status-dot class for the sidebar/tabs.
|
|
78
|
+
* @param status — The session's `status` field from the DB.
|
|
79
|
+
* @param isRunning — Whether the session is currently running a turn.
|
|
80
|
+
* @param hasUnreviewed — Whether the session has unreviewed completed turns.
|
|
81
|
+
* @param lifecycle — The session's lifecycle (`'working'` or `'finished'`).
|
|
82
|
+
* @returns A dot class string (`'running'`, `'queued'`, `'error'`, `'paused'`) or `''` (no dot).
|
|
83
|
+
*/
|
|
84
|
+
export function statusToDot(status: string, isRunning: boolean, hasUnreviewed = false, lifecycle = 'working'): string {
|
|
130
85
|
if (lifecycle === 'finished') return '';
|
|
131
86
|
if (isRunning) return 'running';
|
|
132
87
|
if (hasUnreviewed && status !== 'failed') return 'queued';
|
|
133
88
|
switch (status) {
|
|
134
|
-
case 'failed':
|
|
135
|
-
|
|
136
|
-
|
|
89
|
+
case 'failed':
|
|
90
|
+
return 'error';
|
|
91
|
+
case 'aborted':
|
|
92
|
+
return 'paused';
|
|
93
|
+
default:
|
|
94
|
+
return 'paused';
|
|
137
95
|
}
|
|
138
96
|
}
|
|
139
97
|
|
|
140
|
-
|
|
141
|
-
|
|
98
|
+
/**
|
|
99
|
+
* Map a session's state to a human-readable status label for the UI.
|
|
100
|
+
* @param status — The session's `status` field from the DB.
|
|
101
|
+
* @param isRunning — Whether the session is currently running a turn.
|
|
102
|
+
* @param hasUnreviewed — Whether the session has unreviewed completed turns.
|
|
103
|
+
* @param lifecycle — The session's lifecycle (`'working'` or `'finished'`).
|
|
104
|
+
* @returns A label string like `'Running'`, `'Review Pending'`, `'Idle'`, `'Finished'`, `'Failed'`.
|
|
105
|
+
*/
|
|
106
|
+
export function statusToLabel(
|
|
107
|
+
status: string,
|
|
108
|
+
isRunning: boolean,
|
|
109
|
+
hasUnreviewed = false,
|
|
110
|
+
lifecycle = 'working',
|
|
111
|
+
): string {
|
|
142
112
|
if (lifecycle === 'finished') return 'Finished';
|
|
143
113
|
if (isRunning) return 'Running';
|
|
144
114
|
if (hasUnreviewed && status !== 'failed') return 'Review Pending';
|
|
145
115
|
switch (status) {
|
|
146
|
-
case 'failed':
|
|
147
|
-
|
|
148
|
-
case '
|
|
149
|
-
|
|
150
|
-
case '
|
|
151
|
-
|
|
116
|
+
case 'failed':
|
|
117
|
+
return 'Failed';
|
|
118
|
+
case 'aborted':
|
|
119
|
+
return 'Aborted';
|
|
120
|
+
case 'active':
|
|
121
|
+
return 'Idle';
|
|
122
|
+
case 'completed':
|
|
123
|
+
return 'Completed';
|
|
124
|
+
case 'running':
|
|
125
|
+
return 'Running';
|
|
126
|
+
default:
|
|
127
|
+
return status;
|
|
152
128
|
}
|
|
153
|
-
}
|
|
129
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { collectFileChanges } from './changes.ts';
|
|
3
|
+
import type { Turn } from '@agentpane/shared';
|
|
4
|
+
|
|
5
|
+
function makeTurn(items: { type: string; data?: Record<string, unknown> }[]): Turn {
|
|
6
|
+
return {
|
|
7
|
+
id: 't1',
|
|
8
|
+
session_id: 's1',
|
|
9
|
+
user_prompt: 'test',
|
|
10
|
+
agent_response: null,
|
|
11
|
+
thoughts: null,
|
|
12
|
+
token_usage: null,
|
|
13
|
+
external_turn_id: null,
|
|
14
|
+
status: 'completed',
|
|
15
|
+
error: null,
|
|
16
|
+
created_at: '2025-01-01T00:00:00Z',
|
|
17
|
+
updated_at: '2025-01-01T00:00:00Z',
|
|
18
|
+
items: items.map((item, i) => ({
|
|
19
|
+
id: `i${i}`,
|
|
20
|
+
turn_id: 't1',
|
|
21
|
+
external_item_id: `ext${i}`,
|
|
22
|
+
type: item.type,
|
|
23
|
+
data: item.data ?? null,
|
|
24
|
+
status: 'completed',
|
|
25
|
+
created_at: '2025-01-01T00:00:00Z',
|
|
26
|
+
updated_at: '2025-01-01T00:00:00Z',
|
|
27
|
+
})),
|
|
28
|
+
} as Turn;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
describe('collectFileChanges', () => {
|
|
32
|
+
it('returns empty array for empty turns', () => {
|
|
33
|
+
expect(collectFileChanges([])).toEqual([]);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('returns empty array when no file_change items', () => {
|
|
37
|
+
const turn = makeTurn([{ type: 'agent_message', data: { text: 'hello' } }]);
|
|
38
|
+
expect(collectFileChanges([turn])).toEqual([]);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it('collects file changes from all turns in session scope', () => {
|
|
42
|
+
const t1 = makeTurn([{ type: 'file_change', data: { changes: [{ path: '/src/a.ts', kind: 'modify' }] } }]);
|
|
43
|
+
const t2 = makeTurn([{ type: 'file_change', data: { changes: [{ path: '/src/b.ts', kind: 'create' }] } }]);
|
|
44
|
+
const result = collectFileChanges([t1, t2]);
|
|
45
|
+
expect(result).toHaveLength(2);
|
|
46
|
+
expect(result[0].path).toBe('/src/a.ts');
|
|
47
|
+
expect(result[1].path).toBe('/src/b.ts');
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('collects from single turn in turngroup scope', () => {
|
|
51
|
+
const t1 = makeTurn([{ type: 'file_change', data: { changes: [{ path: '/src/a.ts', kind: 'modify' }] } }]);
|
|
52
|
+
const t2 = makeTurn([{ type: 'file_change', data: { changes: [{ path: '/src/b.ts', kind: 'create' }] } }]);
|
|
53
|
+
const result = collectFileChanges([t1, t2], 'turngroup', 0);
|
|
54
|
+
expect(result).toHaveLength(1);
|
|
55
|
+
expect(result[0].path).toBe('/src/a.ts');
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it('deduplicates by path keeping last occurrence', () => {
|
|
59
|
+
const t1 = makeTurn([{ type: 'file_change', data: { changes: [{ path: '/src/a.ts', kind: 'modify' }] } }]);
|
|
60
|
+
const t2 = makeTurn([{ type: 'file_change', data: { changes: [{ path: '/src/a.ts', kind: 'delete' }] } }]);
|
|
61
|
+
const result = collectFileChanges([t1, t2]);
|
|
62
|
+
expect(result).toHaveLength(1);
|
|
63
|
+
expect(result[0].kind).toBe('delete');
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it('handles multiple changes in a single item', () => {
|
|
67
|
+
const turn = makeTurn([
|
|
68
|
+
{
|
|
69
|
+
type: 'file_change',
|
|
70
|
+
data: {
|
|
71
|
+
changes: [
|
|
72
|
+
{ path: '/src/a.ts', kind: 'modify' },
|
|
73
|
+
{ path: '/src/b.ts', kind: 'create' },
|
|
74
|
+
],
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
]);
|
|
78
|
+
const result = collectFileChanges([turn]);
|
|
79
|
+
expect(result).toHaveLength(2);
|
|
80
|
+
});
|
|
81
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { Turn, ChangesScope } from '../types/index.ts';
|
|
2
|
+
|
|
3
|
+
export interface FileChangeEntry {
|
|
4
|
+
path: string;
|
|
5
|
+
kind: string;
|
|
6
|
+
turnIdx: number;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/** Collect file changes from turns, optionally scoped to a single turn.
|
|
10
|
+
* Deduplicates by path (keeps last occurrence).
|
|
11
|
+
* @param turns All turns in the session.
|
|
12
|
+
* @param scope 'session' = all turns, 'turngroup' = only `turnIdx`.
|
|
13
|
+
* @param turnIdx Index of the selected turn (used when scope = 'turngroup').
|
|
14
|
+
* @returns Deduplicated list of file changes. */
|
|
15
|
+
export function collectFileChanges(turns: Turn[], scope: ChangesScope = 'session', turnIdx = 0): FileChangeEntry[] {
|
|
16
|
+
const entries: FileChangeEntry[] = [];
|
|
17
|
+
|
|
18
|
+
if (scope === 'session') {
|
|
19
|
+
turns.forEach((t, ti) => extractChanges(t, ti, entries));
|
|
20
|
+
} else {
|
|
21
|
+
const turn = turns[turnIdx];
|
|
22
|
+
if (turn) extractChanges(turn, turnIdx, entries);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Deduplicate by path (keep last occurrence)
|
|
26
|
+
const seen = new Map<string, FileChangeEntry>();
|
|
27
|
+
for (const e of entries) seen.set(e.path, e);
|
|
28
|
+
return Array.from(seen.values());
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** Extract file_change items from a single turn into the entries array. */
|
|
32
|
+
function extractChanges(turn: Turn, turnIdx: number, entries: FileChangeEntry[]): void {
|
|
33
|
+
for (const item of turn.items) {
|
|
34
|
+
if (item.type === 'file_change' && item.data?.changes) {
|
|
35
|
+
const changes = item.data.changes as Array<{ path: string; kind: string }>;
|
|
36
|
+
for (const c of changes) entries.push({ path: c.path, kind: c.kind, turnIdx });
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
|
|
2
|
+
import { calcSessionDuration } from './duration.ts';
|
|
3
|
+
import type { SessionDetail } from '@agentpane/shared';
|
|
4
|
+
|
|
5
|
+
function makeDetail(turns: { created_at: string; updated_at: string }[]): SessionDetail {
|
|
6
|
+
return {
|
|
7
|
+
id: 's1',
|
|
8
|
+
title: null,
|
|
9
|
+
runtime_type: 'codex',
|
|
10
|
+
model: null,
|
|
11
|
+
model_reasoning_effort: null,
|
|
12
|
+
cwd: null,
|
|
13
|
+
external_thread_id: null,
|
|
14
|
+
status: 'active',
|
|
15
|
+
is_running: 0,
|
|
16
|
+
lifecycle: 'working',
|
|
17
|
+
has_unreviewed: 0,
|
|
18
|
+
runtime_config: null,
|
|
19
|
+
created_at: '2025-01-01T00:00:00Z',
|
|
20
|
+
updated_at: '2025-01-01T00:00:00Z',
|
|
21
|
+
turns: turns.map((t, i) => ({
|
|
22
|
+
id: `t${i}`,
|
|
23
|
+
session_id: 's1',
|
|
24
|
+
user_prompt: 'test',
|
|
25
|
+
agent_response: null,
|
|
26
|
+
thoughts: null,
|
|
27
|
+
token_usage: null,
|
|
28
|
+
external_turn_id: null,
|
|
29
|
+
status: 'completed',
|
|
30
|
+
error: null,
|
|
31
|
+
created_at: t.created_at,
|
|
32
|
+
updated_at: t.updated_at,
|
|
33
|
+
items: [],
|
|
34
|
+
})),
|
|
35
|
+
} as SessionDetail;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
describe('calcSessionDuration', () => {
|
|
39
|
+
beforeEach(() => {
|
|
40
|
+
vi.useFakeTimers();
|
|
41
|
+
vi.setSystemTime(new Date('2025-01-01T01:00:00Z'));
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
afterEach(() => {
|
|
45
|
+
vi.useRealTimers();
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it('returns — for null detail', () => {
|
|
49
|
+
expect(calcSessionDuration(null, false)).toBe('—');
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('returns — for empty turns', () => {
|
|
53
|
+
const detail = makeDetail([]);
|
|
54
|
+
expect(calcSessionDuration(detail, false)).toBe('—');
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it('uses lastTurn.updated_at when not running', () => {
|
|
58
|
+
const detail = makeDetail([
|
|
59
|
+
{ created_at: '2025-01-01T00:00:00Z', updated_at: '2025-01-01T00:00:00Z' },
|
|
60
|
+
{ created_at: '2025-01-01T00:00:10Z', updated_at: '2025-01-01T00:05:00Z' },
|
|
61
|
+
]);
|
|
62
|
+
// 5 minutes = 300s = 5m 0s
|
|
63
|
+
expect(calcSessionDuration(detail, false)).toBe('5m 0s');
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it('uses Date.now() when running (null endISO)', () => {
|
|
67
|
+
const detail = makeDetail([{ created_at: '2025-01-01T00:00:00Z', updated_at: '2025-01-01T00:00:30Z' }]);
|
|
68
|
+
// now is 01:00:00, start is 00:00:00 → 3600s = 1h 0m
|
|
69
|
+
expect(calcSessionDuration(detail, true)).toBe('1h 0m');
|
|
70
|
+
});
|
|
71
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { SessionDetail } from '../types/index.ts';
|
|
2
|
+
import { formatDuration } from '../types/index.ts';
|
|
3
|
+
|
|
4
|
+
/** Calculate the total duration of a session from first turn to last turn (or now if running).
|
|
5
|
+
* @param detail SessionDetail with turns.
|
|
6
|
+
* @param isRunning Whether the session is currently running (extends to now).
|
|
7
|
+
* @returns Formatted duration string, or '—' if no turns. */
|
|
8
|
+
export function calcSessionDuration(detail: SessionDetail | null, isRunning: boolean): string {
|
|
9
|
+
if (!detail || detail.turns.length === 0) return '—';
|
|
10
|
+
const firstTurn = detail.turns[0];
|
|
11
|
+
const lastTurn = detail.turns[detail.turns.length - 1];
|
|
12
|
+
const endISO = isRunning ? null : lastTurn.updated_at;
|
|
13
|
+
return formatDuration(firstTurn.created_at, endISO);
|
|
14
|
+
}
|
|
@@ -15,7 +15,10 @@
|
|
|
15
15
|
"noUnusedLocals": true,
|
|
16
16
|
"noUnusedParameters": true,
|
|
17
17
|
"noFallthroughCasesInSwitch": true,
|
|
18
|
-
"allowImportingTsExtensions": true
|
|
18
|
+
"allowImportingTsExtensions": true,
|
|
19
|
+
"paths": {
|
|
20
|
+
"@agentpane/shared": ["../shared/types.ts"]
|
|
21
|
+
}
|
|
19
22
|
},
|
|
20
23
|
"include": ["src"],
|
|
21
24
|
"exclude": ["node_modules"]
|