@robota-sdk/agent-transport 3.0.0-beta.75 → 3.0.0-beta.76

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (187) hide show
  1. package/README.md +10 -10
  2. package/dist/node/headless/index.cjs +1 -1
  3. package/dist/node/{headless-CT2ibQnr.cjs → headless-OnpVk4-k.cjs} +7 -7
  4. package/dist/node/index.cjs +1 -1
  5. package/dist/node/index.d.ts +1 -6
  6. package/dist/node/index.d.ts.map +1 -1
  7. package/dist/node/index.js +1 -1
  8. package/dist/node/index.js.map +1 -1
  9. package/package.json +7 -75
  10. package/src/index.ts +1 -5
  11. package/src/transport-registry.ts +0 -9
  12. package/dist/node/http/index.cjs +0 -1
  13. package/dist/node/http/index.d.ts +0 -2
  14. package/dist/node/http/index.js +0 -1
  15. package/dist/node/http-2Jiuflc1.js +0 -2
  16. package/dist/node/http-2Jiuflc1.js.map +0 -1
  17. package/dist/node/http-CBAvefLw.cjs +0 -1
  18. package/dist/node/index-BNccqSpv.d.ts +0 -86
  19. package/dist/node/index-BNccqSpv.d.ts.map +0 -1
  20. package/dist/node/index-BUhHIf7X.d.ts +0 -86
  21. package/dist/node/index-BUhHIf7X.d.ts.map +0 -1
  22. package/dist/node/index-BnAGE-u9.d.ts +0 -33
  23. package/dist/node/index-BnAGE-u9.d.ts.map +0 -1
  24. package/dist/node/index-BrQ4gGw0.d.ts +0 -213
  25. package/dist/node/index-BrQ4gGw0.d.ts.map +0 -1
  26. package/dist/node/index-CoeBF21y.d.ts +0 -213
  27. package/dist/node/index-CoeBF21y.d.ts.map +0 -1
  28. package/dist/node/index-DHt-2VQ-.d.ts +0 -46
  29. package/dist/node/index-DHt-2VQ-.d.ts.map +0 -1
  30. package/dist/node/index-DMwKN5Le.d.ts +0 -33
  31. package/dist/node/index-DMwKN5Le.d.ts.map +0 -1
  32. package/dist/node/index-c0M42fsA.d.ts +0 -46
  33. package/dist/node/index-c0M42fsA.d.ts.map +0 -1
  34. package/dist/node/mcp/index.cjs +0 -1
  35. package/dist/node/mcp/index.d.ts +0 -2
  36. package/dist/node/mcp/index.js +0 -1
  37. package/dist/node/mcp-BOglBJNy.cjs +0 -1
  38. package/dist/node/mcp-D3BBVK7C.js +0 -2
  39. package/dist/node/mcp-D3BBVK7C.js.map +0 -1
  40. package/dist/node/rolldown-runtime-CMqjfN_6.cjs +0 -1
  41. package/dist/node/tui/index.cjs +0 -1
  42. package/dist/node/tui/index.d.ts +0 -2
  43. package/dist/node/tui/index.js +0 -1
  44. package/dist/node/tui-CcH5EsQh.js +0 -25
  45. package/dist/node/tui-CcH5EsQh.js.map +0 -1
  46. package/dist/node/tui-DznRbcku.cjs +0 -24
  47. package/dist/node/ws/index.cjs +0 -1
  48. package/dist/node/ws/index.d.ts +0 -2
  49. package/dist/node/ws/index.js +0 -1
  50. package/dist/node/ws-Dc2RUwVs.js +0 -2
  51. package/dist/node/ws-Dc2RUwVs.js.map +0 -1
  52. package/dist/node/ws-QNMQn5kg.cjs +0 -1
  53. package/src/http/__tests__/http-transport.test.ts +0 -55
  54. package/src/http/__tests__/routes.test.ts +0 -168
  55. package/src/http/http-transport.ts +0 -41
  56. package/src/http/index.ts +0 -4
  57. package/src/http/routes.ts +0 -152
  58. package/src/mcp/__tests__/mcp-server.test.ts +0 -66
  59. package/src/mcp/__tests__/mcp-transport.test.ts +0 -46
  60. package/src/mcp/index.ts +0 -4
  61. package/src/mcp/mcp-server.ts +0 -163
  62. package/src/mcp/mcp-transport.ts +0 -48
  63. package/src/tui/App.tsx +0 -491
  64. package/src/tui/BackgroundTaskPanel.tsx +0 -36
  65. package/src/tui/CjkTextInput.tsx +0 -199
  66. package/src/tui/ConfirmPrompt.tsx +0 -70
  67. package/src/tui/ContextWarningBanner.tsx +0 -34
  68. package/src/tui/ExecutionWorkspaceDetailPane.tsx +0 -64
  69. package/src/tui/ExecutionWorkspaceSwitcher.tsx +0 -187
  70. package/src/tui/InputArea.tsx +0 -310
  71. package/src/tui/InteractivePrompt.tsx +0 -59
  72. package/src/tui/ListPicker.tsx +0 -95
  73. package/src/tui/MenuSelect.tsx +0 -104
  74. package/src/tui/MessageList.tsx +0 -284
  75. package/src/tui/PermissionPrompt.tsx +0 -86
  76. package/src/tui/PluginTUI.tsx +0 -258
  77. package/src/tui/SessionPicker.tsx +0 -68
  78. package/src/tui/SessionStatusBar.tsx +0 -73
  79. package/src/tui/SlashAutocomplete.tsx +0 -110
  80. package/src/tui/StatusBar.tsx +0 -236
  81. package/src/tui/StreamingIndicator.tsx +0 -93
  82. package/src/tui/TextPrompt.tsx +0 -81
  83. package/src/tui/ToolCommandOutput.tsx +0 -39
  84. package/src/tui/ToolDiffBlock.tsx +0 -32
  85. package/src/tui/TransportTUI.tsx +0 -117
  86. package/src/tui/TuiInteractionChannel.ts +0 -495
  87. package/src/tui/UpdateNotice.tsx +0 -14
  88. package/src/tui/UsageSummaryEntry.tsx +0 -39
  89. package/src/tui/WaveText.tsx +0 -44
  90. package/src/tui/__tests__/InteractivePrompt.test.tsx +0 -82
  91. package/src/tui/__tests__/ListPicker.test.tsx +0 -159
  92. package/src/tui/__tests__/MenuSelect.test.tsx +0 -103
  93. package/src/tui/__tests__/PluginTUI.test.tsx +0 -167
  94. package/src/tui/__tests__/SlashAutocomplete.test.tsx +0 -140
  95. package/src/tui/__tests__/TextPrompt.test.tsx +0 -98
  96. package/src/tui/__tests__/TuiInteractionChannel.display-contract.test.ts +0 -239
  97. package/src/tui/__tests__/TuiInteractionChannel.lifecycle.test.ts +0 -297
  98. package/src/tui/__tests__/TuiInteractionChannel.requestAction.test.ts +0 -124
  99. package/src/tui/__tests__/UpdateNotice.test.tsx +0 -15
  100. package/src/tui/__tests__/abort-after-permission.test.tsx +0 -169
  101. package/src/tui/__tests__/abort-streaming-e2e.test.tsx +0 -183
  102. package/src/tui/__tests__/background-task-panel.test.tsx +0 -53
  103. package/src/tui/__tests__/background-task-row-format.test.ts +0 -59
  104. package/src/tui/__tests__/channel-factory-integration.test.ts +0 -138
  105. package/src/tui/__tests__/cjk-text-input-flow.test.ts +0 -109
  106. package/src/tui/__tests__/cjk-text-input.test.ts +0 -191
  107. package/src/tui/__tests__/command-effect-handler.test.ts +0 -127
  108. package/src/tui/__tests__/command-output-summary.test.ts +0 -95
  109. package/src/tui/__tests__/compact-event-bridge.test.ts +0 -20
  110. package/src/tui/__tests__/confirm-permission-flow.test.ts +0 -130
  111. package/src/tui/__tests__/confirm-prompt.test.tsx +0 -87
  112. package/src/tui/__tests__/execution-workspace-switcher.test.tsx +0 -110
  113. package/src/tui/__tests__/execution-workspace-view-model.test.ts +0 -93
  114. package/src/tui/__tests__/fixtures/provider-setup-prompt-driver.tsx +0 -125
  115. package/src/tui/__tests__/input-area-flow.test.ts +0 -164
  116. package/src/tui/__tests__/message-list-rendering.test.tsx +0 -353
  117. package/src/tui/__tests__/prompt-queue.test.tsx +0 -255
  118. package/src/tui/__tests__/provider-setup-pty-e2e.test.ts +0 -233
  119. package/src/tui/__tests__/pty/pty-driver.ts +0 -135
  120. package/src/tui/__tests__/pty/tui-pty.ptytest.ts +0 -61
  121. package/src/tui/__tests__/render-channel-options.test.ts +0 -32
  122. package/src/tui/__tests__/render-markdown.test.ts +0 -72
  123. package/src/tui/__tests__/selection-flow.test.ts +0 -61
  124. package/src/tui/__tests__/session-init-poller.test.ts +0 -102
  125. package/src/tui/__tests__/session-naming.test.ts +0 -64
  126. package/src/tui/__tests__/session-switch-channel.test.tsx +0 -307
  127. package/src/tui/__tests__/slash-routing-effects.test.ts +0 -228
  128. package/src/tui/__tests__/status-activity.test.ts +0 -71
  129. package/src/tui/__tests__/status-bar.test.tsx +0 -177
  130. package/src/tui/__tests__/streaming-indicator.test.tsx +0 -137
  131. package/src/tui/__tests__/text-prompt-flow.test.ts +0 -77
  132. package/src/tui/__tests__/tui-channel-init-failure.test.ts +0 -57
  133. package/src/tui/__tests__/tui-state-manager.test.ts +0 -401
  134. package/src/tui/background-task-row-format.ts +0 -53
  135. package/src/tui/command-interaction.ts +0 -9
  136. package/src/tui/command-output-summary.ts +0 -122
  137. package/src/tui/create-default-tui-cli-adapter.ts +0 -41
  138. package/src/tui/execution-workspace-view-model.ts +0 -123
  139. package/src/tui/flows/cjk-text-input-flow.ts +0 -285
  140. package/src/tui/flows/confirm-prompt-flow.ts +0 -45
  141. package/src/tui/flows/input-area-flow.ts +0 -189
  142. package/src/tui/flows/permission-prompt-flow.ts +0 -85
  143. package/src/tui/flows/selection-flow.ts +0 -126
  144. package/src/tui/flows/session-init-poller.ts +0 -77
  145. package/src/tui/flows/text-prompt-flow.ts +0 -98
  146. package/src/tui/hooks/command-effect-handler.ts +0 -97
  147. package/src/tui/hooks/command-effect-queue.ts +0 -39
  148. package/src/tui/hooks/side-effects-types.ts +0 -35
  149. package/src/tui/hooks/useAutocomplete.ts +0 -87
  150. package/src/tui/hooks/usePluginCallbacks.ts +0 -31
  151. package/src/tui/hooks/usePluginScreenData.ts +0 -85
  152. package/src/tui/hooks/useSideEffects.ts +0 -175
  153. package/src/tui/hooks/useSlashRouting.ts +0 -118
  154. package/src/tui/hooks/useStatusLineSettings.ts +0 -37
  155. package/src/tui/hooks/useTuiChannel.ts +0 -95
  156. package/src/tui/index.ts +0 -14
  157. package/src/tui/interactions/CommandConfirm.tsx +0 -36
  158. package/src/tui/interactions/CommandPicker.tsx +0 -77
  159. package/src/tui/interactions/__tests__/CommandConfirm.test.tsx +0 -124
  160. package/src/tui/interactions/__tests__/CommandPicker.test.tsx +0 -138
  161. package/src/tui/plugin-tui-handlers.ts +0 -163
  162. package/src/tui/render-markdown.ts +0 -130
  163. package/src/tui/render.tsx +0 -129
  164. package/src/tui/session-naming.ts +0 -33
  165. package/src/tui/status-activity.ts +0 -63
  166. package/src/tui/tui-cli-adapter-context.tsx +0 -13
  167. package/src/tui/tui-cli-adapter.ts +0 -25
  168. package/src/tui/tui-state-manager.ts +0 -226
  169. package/src/tui/tui-transport.ts +0 -35
  170. package/src/tui/types.ts +0 -15
  171. package/src/tui/utils/__tests__/edit-diff.test.ts +0 -426
  172. package/src/tui/utils/__tests__/paste-detection.test.ts +0 -116
  173. package/src/tui/utils/__tests__/paste-labels.test.ts +0 -46
  174. package/src/tui/utils/__tests__/tool-call-extractor.test.ts +0 -227
  175. package/src/tui/utils/__tests__/tool-diff-summary.test.ts +0 -104
  176. package/src/tui/utils/edit-diff.ts +0 -153
  177. package/src/tui/utils/paste-labels.ts +0 -9
  178. package/src/tui/utils/tool-call-extractor.ts +0 -92
  179. package/src/tui/utils/tool-diff-summary.ts +0 -75
  180. package/src/ws/__tests__/ws-handler.test.ts +0 -409
  181. package/src/ws/__tests__/ws-transport.test.ts +0 -53
  182. package/src/ws/index.ts +0 -13
  183. package/src/ws/ws-background-messages.ts +0 -170
  184. package/src/ws/ws-handler.ts +0 -280
  185. package/src/ws/ws-protocol.ts +0 -78
  186. package/src/ws/ws-transport-configurable.ts +0 -128
  187. package/src/ws/ws-transport.ts +0 -42
@@ -1,164 +0,0 @@
1
- import { describe, expect, it } from 'vitest';
2
- import {
3
- appendPromptHistory,
4
- createPasteLabelChange,
5
- createPromptHistoryNavigationState,
6
- extractPromptHistory,
7
- getAutocompletePopupAction,
8
- getPromptHistoryInputAction,
9
- getPendingPromptInputAction,
10
- moveAutocompleteSelection,
11
- navigatePromptHistory,
12
- resolveEnterCommandSelection,
13
- resolveTabCompletion,
14
- shouldSubmitInput,
15
- } from '../flows/input-area-flow.js';
16
- import type { ICommand } from '@robota-sdk/agent-interface-transport';
17
- import {
18
- createAssistantMessage,
19
- createSystemMessage,
20
- createUserMessage,
21
- messageToHistoryEntry,
22
- } from '@robota-sdk/agent-core';
23
-
24
- const command = (name: string, subcommands?: ICommand[]): ICommand => ({
25
- name,
26
- description: `${name} command`,
27
- source: 'test',
28
- subcommands,
29
- execute: async () => {},
30
- });
31
-
32
- describe('input area flow', () => {
33
- it('Given autocomplete key info When mapped Then popup actions are produced', () => {
34
- expect(getAutocompletePopupAction({ upArrow: true })).toBe('previous');
35
- expect(getAutocompletePopupAction({ downArrow: true })).toBe('next');
36
- expect(getAutocompletePopupAction({ escape: true })).toBe('close');
37
- expect(getAutocompletePopupAction({ tab: true })).toBe('complete');
38
- });
39
-
40
- it('Given pending prompt key info When mapped Then cancel queue action is produced', () => {
41
- expect(getPendingPromptInputAction({ backspace: true })).toBe('cancelQueue');
42
- expect(getPendingPromptInputAction({ delete: true })).toBe('cancelQueue');
43
- expect(getPendingPromptInputAction({ downArrow: true })).toBeUndefined();
44
- });
45
-
46
- it('Given wrapping autocomplete When moving beyond bounds Then index wraps', () => {
47
- expect(moveAutocompleteSelection(0, 3, 'previous')).toBe(2);
48
- expect(moveAutocompleteSelection(2, 3, 'next')).toBe(0);
49
- });
50
-
51
- it('Given parent command input When tab completes subcommand Then child name is inserted', () => {
52
- const result = resolveTabCompletion('/plugin i', command('install'));
53
-
54
- expect(result).toEqual({ type: 'insert', value: '/plugin install ' });
55
- });
56
-
57
- it('Given command with subcommands When enter selects it Then command name is inserted', () => {
58
- const result = resolveEnterCommandSelection('/pl', command('plugin', [command('list')]));
59
-
60
- expect(result).toEqual({ type: 'insert', value: '/plugin ', selectedIndex: 0 });
61
- });
62
-
63
- it('Given leaf command When enter selects it Then submit value is emitted', () => {
64
- const result = resolveEnterCommandSelection('/he', command('help'));
65
-
66
- expect(result).toEqual({ type: 'submit', value: '/help' });
67
- });
68
-
69
- it('Given command with no args and no subcommands When enter selects Then submits', () => {
70
- const result = resolveEnterCommandSelection('/ex', command('exit'));
71
-
72
- expect(result).toEqual({ type: 'submit', value: '/exit' });
73
- });
74
-
75
- it('Given subcommand selected (args present) When enter selects Then submits', () => {
76
- const result = resolveEnterCommandSelection('/mode plan', command('plan'));
77
-
78
- expect(result).toEqual({ type: 'submit', value: '/mode plan' });
79
- });
80
-
81
- it('Given multiline paste When label change is created Then label is inserted at cursor', () => {
82
- const result = createPasteLabelChange('abef', 2, 7, 'c\nd\ne');
83
-
84
- expect(result).toEqual({
85
- value: 'ab[Pasted text #7 +3 lines]ef',
86
- cursorHint: 27,
87
- label: '[Pasted text #7 +3 lines]',
88
- lineCount: 3,
89
- });
90
- });
91
-
92
- it('Given blank prompt When checked Then submit is rejected', () => {
93
- expect(shouldSubmitInput(' ')).toBe(false);
94
- expect(shouldSubmitInput(' hello ')).toBe(true);
95
- });
96
-
97
- it('Given prompt history key info When mapped Then history actions are produced', () => {
98
- expect(getPromptHistoryInputAction({ upArrow: true })).toBe('previous');
99
- expect(getPromptHistoryInputAction({ downArrow: true })).toBe('next');
100
- expect(getPromptHistoryInputAction({ escape: true })).toBeUndefined();
101
- });
102
-
103
- it('Given empty prompt history When navigating Then input is unchanged', () => {
104
- const result = navigatePromptHistory(
105
- 'draft',
106
- [],
107
- createPromptHistoryNavigationState(),
108
- 'previous',
109
- );
110
-
111
- expect(result).toEqual({
112
- value: 'draft',
113
- cursorHint: 5,
114
- state: createPromptHistoryNavigationState(),
115
- });
116
- });
117
-
118
- it('Given draft and history When pressing up Then latest prompt is recalled and draft is saved', () => {
119
- const result = navigatePromptHistory(
120
- 'draft text',
121
- ['first', 'second'],
122
- createPromptHistoryNavigationState(),
123
- 'previous',
124
- );
125
-
126
- expect(result).toEqual({
127
- value: 'second',
128
- cursorHint: 6,
129
- state: { selectedIndex: 1, draft: 'draft text' },
130
- });
131
- });
132
-
133
- it('Given history navigation When pressing down past latest Then draft is restored', () => {
134
- const result = navigatePromptHistory(
135
- 'second',
136
- ['first', 'second'],
137
- { selectedIndex: 1, draft: 'draft text' },
138
- 'next',
139
- );
140
-
141
- expect(result).toEqual({
142
- value: 'draft text',
143
- cursorHint: 10,
144
- state: createPromptHistoryNavigationState(),
145
- });
146
- });
147
-
148
- it('Given prompt submit When appended Then blank and consecutive duplicates are ignored', () => {
149
- expect(appendPromptHistory(['first'], 'second')).toEqual(['first', 'second']);
150
- expect(appendPromptHistory(['first'], 'first')).toEqual(['first']);
151
- expect(appendPromptHistory(['first'], ' ')).toEqual(['first']);
152
- });
153
-
154
- it('Given history entries When extracted Then only user chat content is included', () => {
155
- const entries = [
156
- messageToHistoryEntry(createUserMessage('first')),
157
- messageToHistoryEntry(createAssistantMessage('answer')),
158
- messageToHistoryEntry(createSystemMessage('system')),
159
- messageToHistoryEntry(createUserMessage('second')),
160
- ];
161
-
162
- expect(extractPromptHistory(entries)).toEqual(['first', 'second']);
163
- });
164
- });
@@ -1,353 +0,0 @@
1
- /**
2
- * Rendering tests for MessageList — verifies that IHistoryEntry[]
3
- * entries render with correct labels and content.
4
- *
5
- * These tests catch rendering bugs that data-flow tests miss:
6
- * - tool execution list must show "Tool:" label with tool names
7
- * - chat messages must show correct role labels
8
- * - event entries must show formatted content
9
- */
10
-
11
- import React from 'react';
12
- import { render } from 'ink-testing-library';
13
- import { describe, it, expect } from 'vitest';
14
- import MessageList from '../MessageList.js';
15
- import type { IHistoryEntry } from '@robota-sdk/agent-core';
16
- import {
17
- createUserMessage,
18
- createAssistantMessage,
19
- createSystemMessage,
20
- createToolMessage,
21
- messageToHistoryEntry,
22
- } from '@robota-sdk/agent-core';
23
-
24
- function makeToolSummaryEntry(): IHistoryEntry {
25
- return {
26
- id: 'tool-1',
27
- timestamp: new Date(),
28
- category: 'event',
29
- type: 'tool-summary',
30
- data: {
31
- tools: [
32
- { toolName: 'Read', firstArg: 'file.ts', isRunning: false, result: 'success' },
33
- { toolName: 'Edit', firstArg: 'file.ts', isRunning: false, result: 'success' },
34
- ],
35
- summary: '✓ Read(file.ts)\n✓ Edit(file.ts)',
36
- },
37
- };
38
- }
39
-
40
- function makeSkillInvocationEntry(): IHistoryEntry {
41
- return {
42
- id: 'evt-1',
43
- timestamp: new Date(),
44
- category: 'event',
45
- type: 'skill-activation',
46
- data: {
47
- type: 'skill-activation',
48
- skillName: 'audit',
49
- source: 'plugin',
50
- invocation: 'user-slash',
51
- mode: 'inject',
52
- status: 'started',
53
- timestamp: '2026-05-06T00:00:00.000Z',
54
- message: 'Invoking plugin skill: audit',
55
- },
56
- };
57
- }
58
-
59
- describe('MessageList rendering', () => {
60
- // ── Tool summary rendering ────────────────────────────────────
61
-
62
- it('tool execution list renders with "Tool:" label and tool names', () => {
63
- const history: IHistoryEntry[] = [makeToolSummaryEntry()];
64
- const { lastFrame } = render(<MessageList history={history} />);
65
- const output = lastFrame() ?? '';
66
-
67
- expect(output).toContain('Tool:');
68
- expect(output).toContain('Read(file.ts)');
69
- expect(output).toContain('Edit(file.ts)');
70
- });
71
-
72
- // ── Skill invocation rendering ────────────────────────────────
73
-
74
- it('skill-activation event renders with "System:" label and message', () => {
75
- const history: IHistoryEntry[] = [makeSkillInvocationEntry()];
76
- const { lastFrame } = render(<MessageList history={history} />);
77
- const output = lastFrame() ?? '';
78
-
79
- expect(output).toContain('System:');
80
- expect(output).toContain('Invoking plugin skill: audit');
81
- });
82
-
83
- // ── Chat message rendering ────────────────────────────────────
84
-
85
- it('user message renders with "You:" label', () => {
86
- const history: IHistoryEntry[] = [messageToHistoryEntry(createUserMessage('hello'))];
87
- const { lastFrame } = render(<MessageList history={history} />);
88
- const output = lastFrame() ?? '';
89
-
90
- expect(output).toContain('You:');
91
- expect(output).toContain('hello');
92
- });
93
-
94
- it('assistant message renders with "Robota:" label', () => {
95
- const history: IHistoryEntry[] = [
96
- messageToHistoryEntry(createAssistantMessage('response text')),
97
- ];
98
- const { lastFrame } = render(<MessageList history={history} />);
99
- const output = lastFrame() ?? '';
100
-
101
- expect(output).toContain('Robota:');
102
- expect(output).toContain('response text');
103
- });
104
-
105
- it('assistant message preserves CJK and emoji content', () => {
106
- const content = '긴 한국어 응답과 emoji 🎉 를 표시합니다';
107
- const history: IHistoryEntry[] = [messageToHistoryEntry(createAssistantMessage(content))];
108
- const { lastFrame } = render(<MessageList history={history} />);
109
-
110
- expect(lastFrame()).toContain(content);
111
- });
112
-
113
- it('assistant message renders markdown diff fenced code block content', () => {
114
- const response = [
115
- 'Patch preview:',
116
- '',
117
- '```diff',
118
- '- const oldValue = true;',
119
- '+ const newValue = true;',
120
- '```',
121
- ].join('\n');
122
- const history: IHistoryEntry[] = [messageToHistoryEntry(createAssistantMessage(response))];
123
- const { lastFrame } = render(<MessageList history={history} />);
124
- const output = lastFrame() ?? '';
125
-
126
- expect(output).toContain('Robota:');
127
- expect(output).toContain('Patch preview:');
128
- expect(output).toContain('- const oldValue = true;');
129
- expect(output).toContain('+ const newValue = true;');
130
- });
131
-
132
- it('tool message diff summary renders through markdown diff body format', () => {
133
- const toolSummary = [
134
- {
135
- line: 'Edit(/src/index.ts)',
136
- diffFile: '/src/index.ts',
137
- diffLines: [
138
- { type: 'remove', lineNumber: 1, text: 'const oldValue = true;' },
139
- { type: 'add', lineNumber: 1, text: 'const newValue = true;' },
140
- ],
141
- },
142
- ];
143
- const history: IHistoryEntry[] = [
144
- messageToHistoryEntry(
145
- createToolMessage(JSON.stringify(toolSummary), {
146
- toolCallId: 'call_1',
147
- name: 'tools',
148
- }),
149
- ),
150
- ];
151
-
152
- const { lastFrame } = render(<MessageList history={history} />);
153
- const output = lastFrame() ?? '';
154
-
155
- expect(output).toContain('/src/index.ts');
156
- expect(output).toContain('- 1 | const oldValue = true;');
157
- expect(output).toContain('+ 1 | const newValue = true;');
158
- expect(output).not.toContain('│ 1 - const oldValue = true;');
159
- });
160
-
161
- it('tool-summary event renders persisted edit diff metadata', () => {
162
- const history: IHistoryEntry[] = [
163
- {
164
- id: 'summary_1',
165
- timestamp: new Date(),
166
- category: 'event',
167
- type: 'tool-summary',
168
- data: {
169
- tools: [
170
- {
171
- toolName: 'Edit',
172
- firstArg: '/src/index.ts',
173
- isRunning: false,
174
- result: 'success',
175
- diffFile: '/src/index.ts',
176
- diffLines: [
177
- { type: 'remove', lineNumber: 1, text: 'const temporary = true;' },
178
- { type: 'add', lineNumber: 1, text: 'const original = true;' },
179
- ],
180
- },
181
- ],
182
- summary: '✓ Edit(/src/index.ts)',
183
- },
184
- },
185
- ];
186
-
187
- const { lastFrame } = render(<MessageList history={history} />);
188
- const output = lastFrame() ?? '';
189
-
190
- expect(output).toContain('/src/index.ts');
191
- expect(output).toContain('- 1 | const temporary = true;');
192
- expect(output).toContain('+ 1 | const original = true;');
193
- });
194
-
195
- it('tool-summary event collapses long command output with transcript hint', () => {
196
- const commandOutput = Array.from({ length: 7 }, (_, index) => `line-${index + 1}`).join('\n');
197
- const history: IHistoryEntry[] = [
198
- {
199
- id: 'summary_command_long',
200
- timestamp: new Date(),
201
- category: 'event',
202
- type: 'tool-summary',
203
- data: {
204
- tools: [
205
- {
206
- toolName: 'Bash',
207
- firstArg: 'pnpm test',
208
- isRunning: false,
209
- result: 'success',
210
- toolResultData: JSON.stringify({
211
- success: true,
212
- output: commandOutput,
213
- exitCode: 0,
214
- }),
215
- },
216
- ],
217
- summary: '✓ Bash(pnpm test)',
218
- },
219
- },
220
- ];
221
-
222
- const { lastFrame } = render(<MessageList history={history} />);
223
- const output = lastFrame() ?? '';
224
-
225
- expect(output).toContain('✓ Bash(pnpm test)');
226
- expect(output).toContain('line-1');
227
- expect(output).toContain('line-4');
228
- expect(output).not.toContain('line-5');
229
- expect(output).toContain('... +3 lines (full output in session transcript)');
230
- });
231
-
232
- it('tool-summary event marks non-zero command exits as failed', () => {
233
- const history: IHistoryEntry[] = [
234
- {
235
- id: 'summary_command_failed',
236
- timestamp: new Date(),
237
- category: 'event',
238
- type: 'tool-summary',
239
- data: {
240
- tools: [
241
- {
242
- toolName: 'Bash',
243
- firstArg: 'exit 42',
244
- isRunning: false,
245
- result: 'success',
246
- toolResultData: JSON.stringify({ success: true, output: '', exitCode: 42 }),
247
- },
248
- ],
249
- summary: '✓ Bash(exit 42)',
250
- },
251
- },
252
- ];
253
-
254
- const { lastFrame } = render(<MessageList history={history} />);
255
- const output = lastFrame() ?? '';
256
-
257
- expect(output).toContain('✗ Bash(exit 42)');
258
- expect(output).toContain('exit 42');
259
- });
260
-
261
- it('usage-summary event renders compact token and cost visibility', () => {
262
- const history: IHistoryEntry[] = [
263
- {
264
- id: 'usage_1',
265
- timestamp: new Date(),
266
- category: 'event',
267
- type: 'usage-summary',
268
- data: {
269
- kind: 'exact',
270
- scope: 'turn',
271
- promptTokens: 100,
272
- completionTokens: 50,
273
- totalTokens: 150,
274
- contextUsedTokens: 150,
275
- contextMaxTokens: 1000,
276
- contextUsedPercentage: 15,
277
- costStatus: 'unknown',
278
- },
279
- },
280
- ];
281
-
282
- const { lastFrame } = render(<MessageList history={history} />);
283
- const output = lastFrame() ?? '';
284
-
285
- expect(output).toContain('Usage:');
286
- expect(output).toContain('exact');
287
- expect(output).toContain('150 tokens');
288
- expect(output).toContain('in 100');
289
- expect(output).toContain('out 50');
290
- expect(output).toContain('cost unknown');
291
- });
292
-
293
- it('system message renders with "System:" label', () => {
294
- const history: IHistoryEntry[] = [
295
- messageToHistoryEntry(createSystemMessage('Interrupted by user.')),
296
- ];
297
- const { lastFrame } = render(<MessageList history={history} />);
298
- const output = lastFrame() ?? '';
299
-
300
- expect(output).toContain('System:');
301
- expect(output).toContain('Interrupted by user.');
302
- });
303
-
304
- // ── Display order after abort ─────────────────────────────────
305
-
306
- it('abort display order: You → Tool → Robota → System', () => {
307
- const history: IHistoryEntry[] = [
308
- messageToHistoryEntry(createUserMessage('/audit')),
309
- makeToolSummaryEntry(),
310
- messageToHistoryEntry(createAssistantMessage('partial response')),
311
- messageToHistoryEntry(createSystemMessage('Interrupted by user.')),
312
- ];
313
-
314
- const { lastFrame } = render(<MessageList history={history} />);
315
- const output = lastFrame() ?? '';
316
-
317
- const youIdx = output.indexOf('You:');
318
- const toolIdx = output.indexOf('Tool:');
319
- const robotaIdx = output.indexOf('Robota:');
320
- const systemIdx = output.indexOf('Interrupted by user.');
321
-
322
- // All must be present
323
- expect(youIdx).toBeGreaterThanOrEqual(0);
324
- expect(toolIdx).toBeGreaterThanOrEqual(0);
325
- expect(robotaIdx).toBeGreaterThanOrEqual(0);
326
- expect(systemIdx).toBeGreaterThanOrEqual(0);
327
-
328
- // Order: You → Tool → Robota → System
329
- expect(youIdx).toBeLessThan(toolIdx);
330
- expect(toolIdx).toBeLessThan(robotaIdx);
331
- expect(robotaIdx).toBeLessThan(systemIdx);
332
- });
333
-
334
- // ── Mixed history ─────────────────────────────────────────────
335
-
336
- it('renders mixed chat and event entries in order', () => {
337
- const history: IHistoryEntry[] = [
338
- messageToHistoryEntry(createUserMessage('hello')),
339
- makeSkillInvocationEntry(),
340
- makeToolSummaryEntry(),
341
- messageToHistoryEntry(createAssistantMessage('done')),
342
- ];
343
-
344
- const { lastFrame } = render(<MessageList history={history} />);
345
- const output = lastFrame() ?? '';
346
-
347
- // All four entries rendered
348
- expect(output).toContain('You:');
349
- expect(output).toContain('Invoking plugin skill: audit');
350
- expect(output).toContain('Tool:');
351
- expect(output).toContain('Robota:');
352
- });
353
- });