@abacus-ai/cli 2.0.0-canary.1 → 2.0.0-canary.11

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 (198) hide show
  1. package/README.md +25 -0
  2. package/dist/index.mjs +466 -438
  3. package/package.json +4 -1
  4. package/.oxlintrc.json +0 -8
  5. package/resources/abacus.ico +0 -0
  6. package/resources/entitlements.plist +0 -9
  7. package/src/__e2e__/README.md +0 -196
  8. package/src/__e2e__/agent-interactions.e2e.test.tsx +0 -61
  9. package/src/__e2e__/cli-commands.e2e.test.tsx +0 -77
  10. package/src/__e2e__/conversation-throttle.e2e.test.ts +0 -453
  11. package/src/__e2e__/conversation.e2e.test.tsx +0 -56
  12. package/src/__e2e__/diff-preview.e2e.test.tsx +0 -3399
  13. package/src/__e2e__/file-creation.e2e.test.tsx +0 -149
  14. package/src/__e2e__/helpers/test-helpers.ts +0 -449
  15. package/src/__e2e__/keyboard-navigation.e2e.test.tsx +0 -34
  16. package/src/__e2e__/llm-models.e2e.test.ts +0 -402
  17. package/src/__e2e__/mcp/mcp-callback-flow.e2e.test.tsx +0 -71
  18. package/src/__e2e__/mcp/mcp-full-app-ui.e2e.test.tsx +0 -167
  19. package/src/__e2e__/mcp/mcp-ui-rendering.e2e.test.tsx +0 -185
  20. package/src/__e2e__/repl.e2e.test.tsx +0 -78
  21. package/src/__e2e__/shell-compatibility.e2e.test.tsx +0 -76
  22. package/src/__e2e__/theme-mcp.e2e.test.tsx +0 -98
  23. package/src/__e2e__/tool-permissions.e2e.test.tsx +0 -66
  24. package/src/args.ts +0 -22
  25. package/src/components/__tests__/react-compiler.test.tsx +0 -78
  26. package/src/components/__tests__/status-indicator.test.tsx +0 -403
  27. package/src/components/composer/__tests__/bash-runner.test.tsx +0 -263
  28. package/src/components/composer/agent-mode-indicator.tsx +0 -63
  29. package/src/components/composer/bash-runner.tsx +0 -54
  30. package/src/components/composer/commands/default-commands.tsx +0 -615
  31. package/src/components/composer/commands/handler.tsx +0 -59
  32. package/src/components/composer/commands/picker.tsx +0 -273
  33. package/src/components/composer/commands/registry.ts +0 -233
  34. package/src/components/composer/commands/types.ts +0 -33
  35. package/src/components/composer/context.tsx +0 -88
  36. package/src/components/composer/file-mention-picker.tsx +0 -83
  37. package/src/components/composer/help.tsx +0 -44
  38. package/src/components/composer/index.tsx +0 -1007
  39. package/src/components/composer/mentions.ts +0 -57
  40. package/src/components/composer/message-queue.tsx +0 -70
  41. package/src/components/composer/mode-panel.tsx +0 -35
  42. package/src/components/composer/modes/__tests__/bash-handler.test.tsx +0 -755
  43. package/src/components/composer/modes/__tests__/bash-renderer.test.tsx +0 -1108
  44. package/src/components/composer/modes/bash-handler.tsx +0 -132
  45. package/src/components/composer/modes/bash-renderer.tsx +0 -175
  46. package/src/components/composer/modes/default-handlers.tsx +0 -33
  47. package/src/components/composer/modes/index.ts +0 -41
  48. package/src/components/composer/modes/types.ts +0 -21
  49. package/src/components/composer/persistent-shell.ts +0 -283
  50. package/src/components/composer/process.ts +0 -65
  51. package/src/components/composer/types.ts +0 -9
  52. package/src/components/composer/use-mention-search.ts +0 -68
  53. package/src/components/error-boundry.tsx +0 -60
  54. package/src/components/exit-message.tsx +0 -29
  55. package/src/components/expanded-view.tsx +0 -74
  56. package/src/components/file-completion.tsx +0 -127
  57. package/src/components/header.tsx +0 -47
  58. package/src/components/logo.tsx +0 -37
  59. package/src/components/segments.tsx +0 -356
  60. package/src/components/status-indicator.tsx +0 -306
  61. package/src/components/tool-group-summary.tsx +0 -263
  62. package/src/components/tool-permissions/ask-user-question-permission-ui.tsx +0 -319
  63. package/src/components/tool-permissions/diff-preview.tsx +0 -359
  64. package/src/components/tool-permissions/index.ts +0 -5
  65. package/src/components/tool-permissions/permission-options.tsx +0 -401
  66. package/src/components/tool-permissions/permission-preview-header.tsx +0 -57
  67. package/src/components/tool-permissions/tool-permission-ui.tsx +0 -420
  68. package/src/components/tools/agent/ask-user-question.tsx +0 -107
  69. package/src/components/tools/agent/enter-plan-mode.tsx +0 -55
  70. package/src/components/tools/agent/exit-plan-mode.tsx +0 -83
  71. package/src/components/tools/agent/handoff-to-main.tsx +0 -27
  72. package/src/components/tools/agent/subagent.tsx +0 -37
  73. package/src/components/tools/agent/todo-write.tsx +0 -104
  74. package/src/components/tools/browser/close-tab.tsx +0 -58
  75. package/src/components/tools/browser/computer.tsx +0 -70
  76. package/src/components/tools/browser/get-interactive-elements.tsx +0 -54
  77. package/src/components/tools/browser/get-tab-content.tsx +0 -51
  78. package/src/components/tools/browser/navigate-to.tsx +0 -59
  79. package/src/components/tools/browser/new-tab.tsx +0 -60
  80. package/src/components/tools/browser/perform-action.tsx +0 -63
  81. package/src/components/tools/browser/refresh-tab.tsx +0 -43
  82. package/src/components/tools/browser/switch-tab.tsx +0 -58
  83. package/src/components/tools/filesystem/delete-file.tsx +0 -104
  84. package/src/components/tools/filesystem/edit.tsx +0 -220
  85. package/src/components/tools/filesystem/list-dir.tsx +0 -78
  86. package/src/components/tools/filesystem/read-file.tsx +0 -180
  87. package/src/components/tools/filesystem/upload-image.tsx +0 -76
  88. package/src/components/tools/ide/ide-diagnostics.tsx +0 -62
  89. package/src/components/tools/index.ts +0 -91
  90. package/src/components/tools/mcp/mcp-tool.tsx +0 -158
  91. package/src/components/tools/search/fetch-url.tsx +0 -73
  92. package/src/components/tools/search/file-search.tsx +0 -78
  93. package/src/components/tools/search/grep.tsx +0 -90
  94. package/src/components/tools/search/semantic-search.tsx +0 -66
  95. package/src/components/tools/search/web-search.tsx +0 -71
  96. package/src/components/tools/shared/index.tsx +0 -48
  97. package/src/components/tools/shared/zod-coercion.ts +0 -35
  98. package/src/components/tools/terminal/bash-tool-output.tsx +0 -188
  99. package/src/components/tools/terminal/get-terminal-output.tsx +0 -91
  100. package/src/components/tools/terminal/run-in-terminal.tsx +0 -131
  101. package/src/components/tools/types.ts +0 -16
  102. package/src/components/tools.tsx +0 -68
  103. package/src/components/ui/__tests__/divider.test.tsx +0 -61
  104. package/src/components/ui/__tests__/gradient.test.tsx +0 -125
  105. package/src/components/ui/__tests__/input.test.tsx +0 -166
  106. package/src/components/ui/__tests__/select.test.tsx +0 -273
  107. package/src/components/ui/__tests__/shimmer.test.tsx +0 -99
  108. package/src/components/ui/blinking-indicator.tsx +0 -27
  109. package/src/components/ui/divider.tsx +0 -162
  110. package/src/components/ui/gradient.tsx +0 -56
  111. package/src/components/ui/input.tsx +0 -228
  112. package/src/components/ui/select.tsx +0 -151
  113. package/src/components/ui/shimmer.tsx +0 -76
  114. package/src/context/agent-mode.tsx +0 -95
  115. package/src/context/extension-file.tsx +0 -136
  116. package/src/context/network-activity.tsx +0 -45
  117. package/src/context/notification.tsx +0 -62
  118. package/src/context/shell-size.tsx +0 -49
  119. package/src/context/shell-title.tsx +0 -38
  120. package/src/entrypoints/print-mode.ts +0 -312
  121. package/src/entrypoints/repl.tsx +0 -389
  122. package/src/hooks/use-agent.ts +0 -15
  123. package/src/hooks/use-api-client.ts +0 -1
  124. package/src/hooks/use-available-height.ts +0 -8
  125. package/src/hooks/use-cleanup.ts +0 -29
  126. package/src/hooks/use-interrupt-manager.ts +0 -242
  127. package/src/hooks/use-models.ts +0 -22
  128. package/src/index.ts +0 -217
  129. package/src/lib/__tests__/ansi.test.ts +0 -255
  130. package/src/lib/__tests__/cli.test.ts +0 -122
  131. package/src/lib/__tests__/commands.test.ts +0 -325
  132. package/src/lib/__tests__/constants.test.ts +0 -15
  133. package/src/lib/__tests__/focusables.test.ts +0 -25
  134. package/src/lib/__tests__/fs.test.ts +0 -231
  135. package/src/lib/__tests__/markdown.test.tsx +0 -348
  136. package/src/lib/__tests__/mcpCommandHandler.test.ts +0 -173
  137. package/src/lib/__tests__/mcpManagement.test.ts +0 -38
  138. package/src/lib/__tests__/path-paste.test.ts +0 -144
  139. package/src/lib/__tests__/path.test.ts +0 -300
  140. package/src/lib/__tests__/queries.test.ts +0 -39
  141. package/src/lib/__tests__/standaloneMcpService.test.ts +0 -71
  142. package/src/lib/__tests__/text-buffer.test.ts +0 -328
  143. package/src/lib/__tests__/text-utils.test.ts +0 -32
  144. package/src/lib/__tests__/timing.test.ts +0 -78
  145. package/src/lib/__tests__/utils.test.ts +0 -238
  146. package/src/lib/__tests__/vim-buffer-actions.test.ts +0 -154
  147. package/src/lib/ansi.ts +0 -150
  148. package/src/lib/cli-push-server.ts +0 -112
  149. package/src/lib/cli.ts +0 -44
  150. package/src/lib/clipboard.ts +0 -226
  151. package/src/lib/command-utils.ts +0 -93
  152. package/src/lib/commands.ts +0 -270
  153. package/src/lib/constants.ts +0 -3
  154. package/src/lib/extension-connection.ts +0 -181
  155. package/src/lib/focusables.ts +0 -7
  156. package/src/lib/fs.ts +0 -533
  157. package/src/lib/markdown/code-block.tsx +0 -63
  158. package/src/lib/markdown/index.ts +0 -4
  159. package/src/lib/markdown/link.tsx +0 -19
  160. package/src/lib/markdown/markdown.tsx +0 -372
  161. package/src/lib/markdown/types.ts +0 -15
  162. package/src/lib/mcpCommandHandler.ts +0 -121
  163. package/src/lib/mcpManagement.ts +0 -44
  164. package/src/lib/path-paste.ts +0 -185
  165. package/src/lib/path.ts +0 -179
  166. package/src/lib/queries.ts +0 -15
  167. package/src/lib/standaloneMcpService.ts +0 -688
  168. package/src/lib/status-utils.ts +0 -237
  169. package/src/lib/test-utils.tsx +0 -72
  170. package/src/lib/text-buffer.ts +0 -2415
  171. package/src/lib/text-utils.ts +0 -272
  172. package/src/lib/timing.ts +0 -63
  173. package/src/lib/types.ts +0 -295
  174. package/src/lib/utils.ts +0 -182
  175. package/src/lib/vim-buffer-actions.ts +0 -732
  176. package/src/providers/agent.tsx +0 -1063
  177. package/src/providers/api-client.tsx +0 -43
  178. package/src/services/logger.ts +0 -85
  179. package/src/terminal/detection.ts +0 -187
  180. package/src/terminal/exit.ts +0 -279
  181. package/src/terminal/notification.ts +0 -83
  182. package/src/terminal/progress.ts +0 -201
  183. package/src/terminal/setup.ts +0 -797
  184. package/src/terminal/types.ts +0 -51
  185. package/src/theme/context.tsx +0 -57
  186. package/src/theme/index.ts +0 -4
  187. package/src/theme/themed.tsx +0 -35
  188. package/src/theme/themes.json +0 -546
  189. package/src/theme/types.ts +0 -110
  190. package/src/tools/types.ts +0 -59
  191. package/src/tools/utils/__tests__/zod-coercion.test.ts +0 -33
  192. package/src/tools/utils/tool-ui-components.tsx +0 -649
  193. package/src/tools/utils/zod-coercion.ts +0 -35
  194. package/tsconfig.json +0 -16
  195. package/tsconfig.node.json +0 -29
  196. package/tsconfig.test.json +0 -27
  197. package/tsdown.config.ts +0 -17
  198. package/vitest.config.ts +0 -76
@@ -1,356 +0,0 @@
1
- import { View, Text } from "@codellm/jar";
2
- import { Fragment, memo, useMemo, useState, useEffect, useRef, startTransition } from "react";
3
-
4
- import { Markdown } from "../lib/markdown/index.js";
5
- import { capitalize, getRandomWord } from "../lib/status-utils.js";
6
- import { formatDurationMs } from "../lib/timing.js";
7
- import { HistorySegment } from "../lib/types.js";
8
- import { getSegmentContent } from "../lib/utils.js";
9
- import { useTheme } from "../theme/index.js";
10
- import { ErrorBoundary } from "./error-boundry.js";
11
- import { Tool } from "./tools.js";
12
- import { BlinkingIndicator } from "./ui/blinking-indicator.js";
13
- import { Shimmer } from "./ui/shimmer.js";
14
-
15
- const TextSegment = memo((props: HistorySegment) => {
16
- const { type, segment, isSpinny = false, source } = props;
17
- if (type !== "text") {
18
- throw Error(`Can only render text segments, got ${type}`);
19
- }
20
-
21
- const content = useMemo(() => getSegmentContent(segment), [segment]);
22
-
23
- if (!content?.trim()) {
24
- return null;
25
- }
26
-
27
- // User text segments - dim italic with ❯ prefix
28
- if (source === "user") {
29
- return (
30
- <View flexDirection="row" gap={1}>
31
- <Text color="white">❯</Text>
32
- <Text dimColor italic>
33
- {content}
34
- </Text>
35
- </View>
36
- );
37
- }
38
-
39
- // Bot text segments - spinny shows shimmer, normal shows markdown with ⏺ prefix
40
- if (isSpinny) {
41
- return (
42
- <View flexDirection="row" alignItems="center" gap={1}>
43
- <Shimmer text={content} />
44
- </View>
45
- );
46
- }
47
-
48
- return (
49
- <View flexDirection="column">
50
- <View flexDirection="row" gap={1}>
51
- <Text color="white">⏺</Text>
52
- <Markdown>{content.trimStart()}</Markdown>
53
- </View>
54
- </View>
55
- );
56
- });
57
- TextSegment.displayName = "TextSegment";
58
-
59
- /**
60
- * Expanded thinking segment: shows full thought content + duration.
61
- * Used in expanded view where thoughts are always visible.
62
- */
63
- export const ExpandedThinkingSegment = memo((props: HistorySegment) => {
64
- const { segment, thinkingStartTime, thinkingEndTime } = props;
65
- const { colors } = useTheme();
66
- const content = useMemo(() => getSegmentContent(segment), [segment]);
67
- const duration = useMemo(() => {
68
- if (thinkingStartTime && thinkingEndTime) {
69
- return `thought for ${formatDurationMs(thinkingEndTime - thinkingStartTime)}`;
70
- }
71
- return null;
72
- }, [thinkingStartTime, thinkingEndTime]);
73
-
74
- return (
75
- <View flexDirection="row" gap={1} alignItems="flex-start">
76
- <Text color={colors.textSubtle}>✳</Text>
77
- <View flexDirection="column" gap={0}>
78
- {duration && <Text dimColor>({duration})</Text>}
79
- {content && (
80
- <Text color={colors.textSubtle} wrap="wrap">
81
- {content}
82
- </Text>
83
- )}
84
- </View>
85
- </View>
86
- );
87
- });
88
- ExpandedThinkingSegment.displayName = "ExpandedThinkingSegment";
89
-
90
- /** Duration threshold (ms) below which we don't show timing numbers */
91
- const THINKING_DURATION_THRESHOLD = 5000;
92
-
93
- /** SDK-native thinking segment — emitted by thinking_delta / thinking_complete events.
94
- * Visible while active and for 2s after completion, then hides. */
95
- const ThinkingSegment = memo((props: HistorySegment) => {
96
- const { isSpinny = false, thinkingStartTime, thinkingEndTime } = props;
97
- const [currentTime, setCurrentTime] = useState(performance.now());
98
- const [hidden, setHidden] = useState(false);
99
-
100
- // Tick timer while actively thinking
101
- useEffect(() => {
102
- if (!isSpinny || !thinkingStartTime) return undefined;
103
- const interval = setInterval(() => {
104
- startTransition(() => setCurrentTime(performance.now()));
105
- }, 1000);
106
- return () => clearInterval(interval);
107
- }, [isSpinny, thinkingStartTime]);
108
-
109
- // After thinking completes, hide after 2s
110
- useEffect(() => {
111
- if (isSpinny || !thinkingEndTime) return undefined;
112
- const timer = setTimeout(() => setHidden(true), 2000);
113
- return () => clearTimeout(timer);
114
- }, [isSpinny, thinkingEndTime]);
115
-
116
- if (hidden) return null;
117
-
118
- const label = useMemo(() => {
119
- if (isSpinny) {
120
- if (!thinkingStartTime) return "thinking...";
121
- const elapsed = currentTime - thinkingStartTime;
122
- // Only show duration if thinking has lasted >5s
123
- return elapsed < THINKING_DURATION_THRESHOLD
124
- ? "thinking..."
125
- : `thinking for ${formatDurationMs(elapsed)}`;
126
- }
127
- if (thinkingStartTime && thinkingEndTime) {
128
- const duration = thinkingEndTime - thinkingStartTime;
129
- return duration < THINKING_DURATION_THRESHOLD
130
- ? "thought"
131
- : `thought for ${formatDurationMs(duration)}`;
132
- }
133
- return "thinking...";
134
- }, [thinkingStartTime, thinkingEndTime, isSpinny, currentTime]);
135
-
136
- return (
137
- <View flexDirection="row" gap={1} alignItems="flex-start">
138
- {isSpinny ? <BlinkingIndicator char="●" color="cyan" /> : <Text color="green">●</Text>}
139
- <Text dimColor>{label}</Text>
140
- </View>
141
- );
142
- });
143
- ThinkingSegment.displayName = "ThinkingSegment";
144
-
145
- /** SDK-native tool call segment — emitted by tool_requested / tool_execution_complete events */
146
- const ToolCallSegment = memo((props: HistorySegment) => {
147
- const { toolUseRequest, toolUseResult, toolDisplayData, parsedResult } = props;
148
-
149
- if (!toolUseRequest) return null;
150
-
151
- if (Array.isArray(toolUseRequest)) {
152
- return (
153
- <>
154
- {toolUseRequest.map((req, index) => (
155
- <Tool
156
- key={req.id ?? index}
157
- {...req}
158
- result={toolUseResult}
159
- displayData={toolDisplayData}
160
- parsedResult={parsedResult}
161
- />
162
- ))}
163
- </>
164
- );
165
- }
166
-
167
- return (
168
- <Tool
169
- {...toolUseRequest}
170
- result={toolUseResult}
171
- displayData={toolDisplayData}
172
- parsedResult={parsedResult}
173
- />
174
- );
175
- });
176
- ToolCallSegment.displayName = "ToolCallSegment";
177
-
178
- /** Generic collapsible — used for in-flight spinners ("Processing…", "Analyzing result…") */
179
- const CollapsibleComponentSegment = memo((props: HistorySegment) => {
180
- const { type, segment, title, isSpinny = false } = props;
181
- const { colors } = useTheme();
182
- const wordRef = useRef<string>(getRandomWord());
183
-
184
- if (type !== "collapsible_component") {
185
- throw Error(`Can only render collapsible component segments, got ${type}`);
186
- }
187
-
188
- const content = useMemo(() => getSegmentContent(segment), [segment]);
189
-
190
- if (!content && !title) {
191
- throw Error("Collapsible component segment must have content or title");
192
- }
193
-
194
- const displayTitle = title || capitalize(wordRef.current);
195
-
196
- return (
197
- <View
198
- borderStyle={content ? "single" : undefined}
199
- borderColor={colors.border}
200
- flexDirection="column"
201
- alignItems="flex-start"
202
- gap={1}
203
- >
204
- {displayTitle && (
205
- <View flexDirection="row" alignItems="center" gap={1}>
206
- {isSpinny ? (
207
- <>
208
- <Shimmer text={`${displayTitle}...`} />
209
- <Text dimColor>(esc to interrupt)</Text>
210
- </>
211
- ) : (
212
- <>
213
- <Text> </Text>
214
- <Text color={colors.textMuted}>{displayTitle}</Text>
215
- </>
216
- )}
217
- </View>
218
- )}
219
- {content && <Markdown>{content}</Markdown>}
220
- </View>
221
- );
222
- });
223
- CollapsibleComponentSegment.displayName = "CollapsibleComponentSegment";
224
-
225
- const NotificationSegment = memo((props: HistorySegment) => {
226
- const { type, message, severity = "info", actions, flashKey } = props;
227
- const { colors } = useTheme();
228
-
229
- if (type !== "code_llm_notification") {
230
- throw Error(`Can only render notification segments, got ${type}`);
231
- }
232
- const [isFlashing, setIsFlashing] = useState(false);
233
- const prevFlashKeyRef = useRef(flashKey);
234
-
235
- // Flash effect: when flashKey changes (duplicate notification), briefly highlight
236
- useEffect(() => {
237
- if (flashKey !== prevFlashKeyRef.current && flashKey != null) {
238
- prevFlashKeyRef.current = flashKey;
239
- setIsFlashing(true);
240
- const timer = setTimeout(() => setIsFlashing(false), 600);
241
- return () => clearTimeout(timer);
242
- }
243
- return undefined;
244
- }, [flashKey]);
245
-
246
- if (!message) {
247
- throw Error("Notification segment must have message");
248
- }
249
-
250
- const validSeverity = useMemo(
251
- () =>
252
- severity === "info" ||
253
- severity === "success" ||
254
- severity === "error" ||
255
- severity === "warning"
256
- ? severity
257
- : "info",
258
- [severity],
259
- );
260
-
261
- const textColor = useMemo(() => {
262
- switch (validSeverity) {
263
- case "info":
264
- return colors.info;
265
- case "success":
266
- return colors.success;
267
- case "warning":
268
- return colors.warning;
269
- case "error":
270
- return colors.error;
271
- default:
272
- return colors.info;
273
- }
274
- }, [validSeverity, colors]);
275
-
276
- const formatActionLabel = (actionType: string): string => {
277
- const words = actionType
278
- .replace(/_/g, " ")
279
- .replace(/([A-Z])/g, " $1")
280
- .trim()
281
- .split(" ")
282
- .filter((word) => word.length > 0);
283
- return words
284
- .map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
285
- .join(" ");
286
- };
287
-
288
- const actionLinks = useMemo(() => (actions || []).filter((action) => action.link), [actions]);
289
-
290
- return (
291
- <View flexDirection="column" gap={0}>
292
- <View flexDirection="row" gap={1}>
293
- <Text color={textColor}>{isFlashing ? "◉" : "●"}</Text>
294
- <Text color={textColor} bold={isFlashing} inverse={isFlashing}>
295
- {isFlashing ? ` ${message} ` : message}
296
- </Text>
297
- </View>
298
- {actionLinks.length > 0 && (
299
- <View marginLeft={2} flexDirection="row" gap={1}>
300
- {actionLinks.map((action, index) => (
301
- <Fragment key={index}>
302
- {index > 0 && <Text> | </Text>}
303
- <Text color="cyan" underline>
304
- {formatActionLabel(action.type)}
305
- </Text>
306
- </Fragment>
307
- ))}
308
- </View>
309
- )}
310
- </View>
311
- );
312
- });
313
- NotificationSegment.displayName = "NotificationSegment";
314
-
315
- const SegmentBase = memo(({ segment }: { segment: HistorySegment }) => {
316
- switch (segment.type) {
317
- case "text":
318
- return <TextSegment {...segment} />;
319
- case "thinking":
320
- return <ThinkingSegment {...segment} />;
321
- case "code_llm_tool_call":
322
- return <ToolCallSegment {...segment} />;
323
- case "collapsible_component":
324
- return <CollapsibleComponentSegment {...segment} />;
325
- case "code_llm_agent_tool_request":
326
- // History hydration produces this for older conversations — render same as tool call
327
- return <ToolCallSegment {...segment} />;
328
- case "code_llm_notification":
329
- return <NotificationSegment {...segment} />;
330
- default:
331
- // Silently skip unknown/unsupported segment types rather than crashing
332
- return null;
333
- }
334
- });
335
- SegmentBase.displayName = "SegmentBase";
336
-
337
- function SegmentErrorFallback(error: Error, _errorInfo: React.ErrorInfo | null) {
338
- const errorSegment: HistorySegment = {
339
- id: "error-fallback",
340
- status: "completed",
341
- source: "bot",
342
- type: "code_llm_notification",
343
- message: error.message,
344
- severity: "error",
345
- };
346
-
347
- return <NotificationSegment {...errorSegment} />;
348
- }
349
-
350
- export function Segment({ segment }: { segment: HistorySegment }) {
351
- return (
352
- <ErrorBoundary fallback={SegmentErrorFallback}>
353
- <SegmentBase segment={segment} />
354
- </ErrorBoundary>
355
- );
356
- }
@@ -1,306 +0,0 @@
1
- import { View, Text } from "@codellm/jar";
2
- import { useEffect, useRef, useState } from "react";
3
-
4
- import { useNetworkActivity } from "../context/network-activity.js";
5
- import { formatDurationMs } from "../lib/timing.js";
6
- import { AgentStatus, type RetryState } from "../providers/agent.js";
7
- import { Shimmer } from "./ui/shimmer.js";
8
-
9
- const STATUS_WORDS = [
10
- "baking",
11
- "beaming",
12
- "booping",
13
- "bouncing",
14
- "brewing",
15
- "bubbling",
16
- "chasing",
17
- "churning",
18
- "coalescing",
19
- "conjuring",
20
- "cooking",
21
- "crafting",
22
- "crunching",
23
- "cuddling",
24
- "dancing",
25
- "dazzling",
26
- "discovering",
27
- "doodling",
28
- "dreaming",
29
- "drifting",
30
- "enchanting",
31
- "exploring",
32
- "finding",
33
- "floating",
34
- "fluttering",
35
- "foraging",
36
- "forging",
37
- "frolicking",
38
- "gathering",
39
- "giggling",
40
- "gliding",
41
- "greeting",
42
- "growing",
43
- "hatching",
44
- "herding",
45
- "honking",
46
- "hopping",
47
- "hugging",
48
- "humming",
49
- "imagining",
50
- "inventing",
51
- "jingling",
52
- "juggling",
53
- "jumping",
54
- "kindling",
55
- "knitting",
56
- "launching",
57
- "leaping",
58
- "mapping",
59
- "marinating",
60
- "meandering",
61
- "mixing",
62
- "moseying",
63
- "munching",
64
- "napping",
65
- "nibbling",
66
- "noodling",
67
- "orbiting",
68
- "painting",
69
- "percolating",
70
- "petting",
71
- "plotting",
72
- "pondering",
73
- "popping",
74
- "prancing",
75
- "purring",
76
- "puzzling",
77
- "questing",
78
- "riding",
79
- "roaming",
80
- "rolling",
81
- "sauteeing",
82
- "scribbling",
83
- "seeking",
84
- "shimmying",
85
- "singing",
86
- "skipping",
87
- "sleeping",
88
- "snacking",
89
- "sniffing",
90
- "snuggling",
91
- "soaring",
92
- "sparking",
93
- "spinning",
94
- "splashing",
95
- "sprouting",
96
- "squishing",
97
- "stargazing",
98
- "stirring",
99
- "strolling",
100
- "swimming",
101
- "swinging",
102
- "tickling",
103
- "tinkering",
104
- "toasting",
105
- "tumbling",
106
- "twirling",
107
- "waddling",
108
- "wandering",
109
- "watching",
110
- "weaving",
111
- "whistling",
112
- "wibbling",
113
- "wiggling",
114
- "wishing",
115
- "wobbling",
116
- "wondering",
117
- "yawning",
118
- "zooming",
119
- ];
120
-
121
- interface StatusIndicatorProps {
122
- status: AgentStatus;
123
- /** Start time of the most recent thinking block (ms epoch) */
124
- thinkingStartTime?: number | null;
125
- /** End time of the most recent thinking block (ms epoch), null if still thinking */
126
- thinkingEndTime?: number | null;
127
- /** Current retry state, if retrying */
128
- retryState?: RetryState | null;
129
- /** Whether the network is currently online */
130
- networkOnline?: boolean;
131
- }
132
-
133
- function capitalize(word: string): string {
134
- return word.charAt(0).toUpperCase() + word.slice(1);
135
- }
136
-
137
- function getRandomWord(): string {
138
- const index = Math.floor(Math.random() * STATUS_WORDS.length);
139
- return STATUS_WORDS[index];
140
- }
141
-
142
- /** Thinking indicator: "thinking" → "thinking for 5s" → "thought for 1.2m" (shown 5s after done) */
143
- function useThinkingLabel(
144
- thinkingStartTime: number | null | undefined,
145
- thinkingEndTime: number | null | undefined,
146
- ): string | null {
147
- const [tick, setTick] = useState(0);
148
- const hideAfterRef = useRef<number | null>(null);
149
-
150
- useEffect(() => {
151
- if (!thinkingStartTime) return;
152
-
153
- const interval = setInterval(() => {
154
- setTick((t) => t + 1);
155
- }, 500);
156
-
157
- return () => clearInterval(interval);
158
- }, [thinkingStartTime]);
159
-
160
- if (!thinkingStartTime) return null;
161
-
162
- const now = Date.now();
163
-
164
- if (thinkingEndTime) {
165
- // After completion, show label for 5 seconds then hide
166
- if (hideAfterRef.current === null) {
167
- hideAfterRef.current = thinkingEndTime + 5000;
168
- }
169
- if (now > hideAfterRef.current) return null;
170
- const durationMs = thinkingEndTime - thinkingStartTime;
171
- // Only show duration if thinking lasted >5s
172
- return durationMs < 5000 ? "thought" : `thought for ${formatDurationMs(durationMs)}`;
173
- }
174
-
175
- // Reset hide timer when thinking restarts
176
- hideAfterRef.current = null;
177
-
178
- void tick; // consumed by interval to force re-render
179
-
180
- // Still thinking — show elapsed, only show duration if >5s
181
- const elapsedMs = now - thinkingStartTime;
182
- if (elapsedMs < 5000) return "thinking";
183
- return `thinking for ${formatDurationMs(elapsedMs)}`;
184
- }
185
-
186
- /** Countdown hook for retry delay. Returns remaining seconds. */
187
- function useRetryCountdown(retryState: RetryState | null): number {
188
- const [remaining, setRemaining] = useState(0);
189
- const startRef = useRef<number>(0);
190
-
191
- useEffect(() => {
192
- if (!retryState) {
193
- setRemaining(0);
194
- return;
195
- }
196
- startRef.current = Date.now();
197
- setRemaining(Math.ceil(retryState.delayMs / 1000));
198
-
199
- const interval = setInterval(() => {
200
- const elapsed = Date.now() - startRef.current;
201
- const left = Math.max(0, Math.ceil((retryState.delayMs - elapsed) / 1000));
202
- setRemaining(left);
203
- }, 1000);
204
-
205
- return () => clearInterval(interval);
206
- }, [retryState]);
207
-
208
- return remaining;
209
- }
210
-
211
- export const StatusIndicator = ({
212
- status,
213
- thinkingStartTime,
214
- thinkingEndTime,
215
- retryState,
216
- networkOnline = true,
217
- }: StatusIndicatorProps) => {
218
- const { activity } = useNetworkActivity();
219
- const [word, setWord] = useState(() => getRandomWord());
220
- const previousStatusRef = useRef<AgentStatus>(AgentStatus.Idle);
221
- const [justReconnected, setJustReconnected] = useState(false);
222
- const reconnectTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
223
-
224
- useEffect(() => {
225
- if (previousStatusRef.current === AgentStatus.Idle && status !== AgentStatus.Idle) {
226
- setWord(getRandomWord());
227
- }
228
- previousStatusRef.current = status;
229
- }, [status]);
230
-
231
- // Track "back online" flash
232
- const prevOnlineRef = useRef(networkOnline);
233
- useEffect(() => {
234
- if (!prevOnlineRef.current && networkOnline) {
235
- setJustReconnected(true);
236
- reconnectTimerRef.current = setTimeout(() => setJustReconnected(false), 2000);
237
- }
238
- prevOnlineRef.current = networkOnline;
239
- return () => {
240
- if (reconnectTimerRef.current) clearTimeout(reconnectTimerRef.current);
241
- };
242
- }, [networkOnline]);
243
-
244
- const thinkingLabel = useThinkingLabel(thinkingStartTime, thinkingEndTime);
245
- const retryCountdown = useRetryCountdown(retryState ?? null);
246
-
247
- // ── Offline state ──
248
- if (!networkOnline) {
249
- return (
250
- <View paddingLeft={1} flexDirection="row" gap={1}>
251
- <Text color="red">⚠</Text>
252
- <Text color="red">You are offline</Text>
253
- <Text dimColor>— will retry when you're back online</Text>
254
- </View>
255
- );
256
- }
257
-
258
- // ── Just reconnected flash ──
259
- if (justReconnected) {
260
- return (
261
- <View paddingLeft={1} flexDirection="row" gap={1}>
262
- <Text color="green">✓</Text>
263
- <Text color="green">Back online</Text>
264
- </View>
265
- );
266
- }
267
-
268
- // ── Retry state ──
269
- if (retryState) {
270
- const countdownLabel =
271
- retryCountdown > 0
272
- ? `(in ${retryCountdown}s)`
273
- : `(attempt ${retryState.attempt}/${retryState.maxAttempts})`;
274
- return (
275
- <View paddingLeft={1} flexDirection="row" gap={1}>
276
- <Text color="yellow">↻</Text>
277
- <Shimmer text="Retrying..." />
278
- <Text color="yellow">{countdownLabel}</Text>
279
- <Text dimColor>
280
- (attempt {retryState.attempt}/{retryState.maxAttempts} · esc to cancel)
281
- </Text>
282
- </View>
283
- );
284
- }
285
-
286
- // ── Normal operation ──
287
- const shouldShow = status !== AgentStatus.Idle && status !== AgentStatus.WaitingForToolPermission;
288
-
289
- if (!shouldShow) {
290
- return null;
291
- }
292
-
293
- const displayWord = status === AgentStatus.LoadingConversation ? "Resuming" : capitalize(word);
294
- const indicator = activity === "upload" ? "↑" : activity === "download" ? "↓" : "•";
295
-
296
- return (
297
- <View paddingLeft={1} flexDirection="row" gap={1}>
298
- <Text color="cyan">{indicator}</Text>
299
- <Shimmer text={`${displayWord}...`} />
300
- {thinkingLabel && <Text color="cyan">({thinkingLabel})</Text>}
301
- {status !== AgentStatus.LoadingConversation && (
302
- <Text dimColor>(esc/ctrl+c to interrupt)</Text>
303
- )}
304
- </View>
305
- );
306
- };