@causyne/agent 1.20.112 → 1.20.117
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/docs/ARCHITECTURE.md +29 -0
- package/package.json +1 -1
- package/src/agentLoop.js +153 -68
- package/src/agentLoop.ts +152 -71
- package/src/browser/browserRuntime.js +13 -8
- package/src/browser/browserRuntime.ts +16 -8
- package/src/browser/causyneBrowser.js +37 -9
- package/src/browser/causyneBrowser.ts +37 -9
- package/src/browser/searchProviders.js +18 -7
- package/src/browser/searchProviders.ts +17 -5
- package/src/browser/snapshotWindow.js +1 -1
- package/src/browser/snapshotWindow.ts +1 -1
- package/src/browser/urlPolicy.js +21 -10
- package/src/browser/urlPolicy.ts +19 -10
- package/src/browser/workspacePreview.js +13 -1
- package/src/browser/workspacePreview.ts +11 -1
- package/src/cliMode.js +5 -1
- package/src/computerUse/visionGrounding.js +31 -27
- package/src/computerUse/visionGrounding.ts +27 -27
- package/src/continuum/ui/continuumPicker.js +14 -6
- package/src/continuum/ui/continuumPicker.ts +13 -6
- package/src/continuum/ui/continuumPickerView.js +24 -15
- package/src/continuum/ui/continuumPickerView.ts +24 -16
- package/src/memory/scopedFacts.js +171 -0
- package/src/memory/scopedFacts.ts +214 -0
- package/src/memory.d.ts +13 -1
- package/src/memory.js +9 -12
- package/src/observer/advisory.js +32 -22
- package/src/observer/advisory.ts +30 -18
- package/src/observer/coldObserver.js +21 -33
- package/src/observer/coldObserver.ts +20 -33
- package/src/observer/evidence.js +20 -13
- package/src/observer/evidence.ts +21 -13
- package/src/observer.js +47 -12
- package/src/observer.ts +50 -18
- package/src/perception.js +124 -3
- package/src/perception.ts +128 -4
- package/src/planCache.js +17 -3
- package/src/planCache.ts +17 -3
- package/src/pluginsFactory/discovery.js +28 -16
- package/src/pluginsFactory/discovery.ts +29 -16
- package/src/pluginsFactory/pluginsFactory.js +213 -38
- package/src/pluginsFactory/pluginsFactory.ts +218 -39
- package/src/pluginsFactory/strategy.js +26 -16
- package/src/pluginsFactory/strategy.ts +34 -19
- package/src/pluginsFactory/templates.js +183 -62
- package/src/pluginsFactory/templates.ts +174 -54
- package/src/smartToolsUse.js +4 -5
- package/src/smartToolsUse.ts +4 -6
- package/src/taskShape.js +49 -7
- package/src/taskShape.ts +55 -7
- package/src/timeMachine.js +43 -22
- package/src/timeMachine.ts +44 -22
- package/src/tool-scripts/desktop_act.applescript +1 -0
- package/src/toolPacks.js +27 -5
- package/src/toolPacks.ts +32 -5
- package/src/tools/computerUse.js +23 -10
- package/src/tools/computerUse.ts +19 -8
- package/src/tools/desktopAct.js +12 -1
- package/src/tools/memoryWrite.js +8 -10
- package/src/tools/memoryWrite.ts +13 -11
- package/src/tools/pluginsFactory.js +108 -5
- package/src/tools/pluginsFactory.ts +115 -5
- package/src/tui/CausyneRotor.js +24 -10
- package/src/tui/CausyneRotor.ts +25 -10
- package/src/tui/activityLayout.js +9 -5
- package/src/tui/activityLayout.ts +9 -5
- package/src/tui/ask.js +34 -14
- package/src/tui/banner.js +55 -18
- package/src/tui/banner.ts +52 -17
- package/src/tui/block.js +47 -20
- package/src/tui/block.ts +54 -27
- package/src/tui/chatRenderer.js +139 -84
- package/src/tui/chatboxClipboard.js +12 -5
- package/src/tui/chatboxClipboard.ts +10 -4
- package/src/tui/clipboardImage.js +52 -42
- package/src/tui/clipboardImage.ts +50 -39
- package/src/tui/clipboardSync.js +12 -1
- package/src/tui/clipboardSync.ts +9 -1
- package/src/tui/codeProgress.js +60 -28
- package/src/tui/codeProgress.ts +60 -27
- package/src/tui/codeStreamRenderer.js +94 -23
- package/src/tui/codeStreamRenderer.ts +92 -23
- package/src/tui/commandPresentation.js +9 -2
- package/src/tui/commandPresentation.ts +9 -2
- package/src/tui/completion.js +45 -23
- package/src/tui/composerControls.js +21 -10
- package/src/tui/composerControls.ts +18 -10
- package/src/tui/composerGeometry.js +6 -4
- package/src/tui/composerGeometry.ts +6 -4
- package/src/tui/consoleGuard.js +29 -7
- package/src/tui/consoleGuard.ts +28 -7
- package/src/tui/dialogs.js +134 -71
- package/src/tui/diff.js +8 -4
- package/src/tui/history.js +6 -5
- package/src/tui/home.js +25 -13
- package/src/tui/homeView.js +37 -18
- package/src/tui/homeView.ts +38 -18
- package/src/tui/inlineSlash.js +6 -5
- package/src/tui/inlineSlash.ts +6 -5
- package/src/tui/keys.js +36 -18
- package/src/tui/layout.js +27 -9
- package/src/tui/layout.ts +26 -9
- package/src/tui/lineEditor.js +49 -23
- package/src/tui/markdownMath.js +64 -14
- package/src/tui/markdownMath.ts +69 -13
- package/src/tui/messageActionPlacement.js +28 -13
- package/src/tui/messageActionPlacement.ts +28 -13
- package/src/tui/messageInteraction.js +111 -46
- package/src/tui/messageInteraction.ts +115 -47
- package/src/tui/modelPicker.js +44 -15
- package/src/tui/modelPicker.ts +48 -15
- package/src/tui/observerPicker.js +56 -13
- package/src/tui/observerPicker.ts +73 -30
- package/src/tui/overlay.js +79 -35
- package/src/tui/overlay.ts +81 -34
- package/src/tui/prompt.js +186 -94
- package/src/tui/runningLight.js +1 -1
- package/src/tui/runningLight.ts +1 -1
- package/src/tui/scrollInteraction.js +64 -36
- package/src/tui/scrollInteraction.ts +70 -37
- package/src/tui/selectList.js +60 -32
- package/src/tui/sessionLayout.js +11 -3
- package/src/tui/sessionLayout.ts +10 -3
- package/src/tui/sessionPicker.js +74 -46
- package/src/tui/sessionPicker.ts +73 -48
- package/src/tui/sessionPickerView.js +32 -19
- package/src/tui/sessionPickerView.ts +31 -18
- package/src/tui/sessionSidebar.js +87 -57
- package/src/tui/sessionSidebar.ts +90 -54
- package/src/tui/setup.js +28 -3
- package/src/tui/setup.ts +27 -3
- package/src/tui/skillAuthoring.js +11 -5
- package/src/tui/skillAuthoring.ts +11 -5
- package/src/tui/smartLinkClick.js +75 -23
- package/src/tui/smartLinkClick.ts +86 -26
- package/src/tui/stage.js +47 -16
- package/src/tui/stage.ts +53 -18
- package/src/tui/stageSurface.js +232 -51
- package/src/tui/statusLine.js +85 -53
- package/src/tui/statusLine.ts +82 -46
- package/src/tui/terminalInputFramer.js +5 -2
- package/src/tui/text.js +117 -46
- package/src/tui/text.ts +113 -43
- package/src/tui/textLayout.js +6 -4
- package/src/tui/textLayout.ts +11 -5
- package/src/tui/theme.js +17 -8
- package/src/tui/thinkingBox.js +95 -95
- package/src/tui/thinkingBox.ts +105 -80
- package/src/tui/toolActivityPolicy.js +8 -1
- package/src/tui/toolActivityPolicy.ts +7 -1
- package/src/tui/toolDisplay.js +15 -6
- package/src/tui/toolDisplay.ts +16 -6
- package/src/tui/toolOutputNormalizer.js +16 -3
- package/src/tui/toolOutputNormalizer.ts +13 -3
- package/src/tui/transcript.js +15 -9
- package/src/tui/turnRail.js +176 -80
- package/src/tui/turnRail.ts +173 -71
- package/src/tui/usageCard.js +136 -80
- package/src/tui/usageCard.ts +145 -103
- package/src/tui/viewport.js +48 -23
- package/src/tui/viewport.ts +48 -27
- package/src/tui/viewportAnchor.js +2 -2
- package/src/tui/viewportAnchor.ts +2 -2
- package/src/tui/workspaceFileIndex.js +8 -6
- package/src/tui/workspaceFileIndex.ts +8 -6
- package/src/tui/workspaceSwitch.js +13 -10
- package/src/tui/workspaceSwitch.ts +11 -7
- package/src/types/contracts.ts +3 -0
package/src/tui/codeProgress.ts
CHANGED
|
@@ -28,14 +28,15 @@ const MAX_STREAM_PREVIEW_CHARS = 256_000;
|
|
|
28
28
|
|
|
29
29
|
const FILE_TOOLS: Record<string, string> = {
|
|
30
30
|
fs_write: 'Creating', fs_edit: 'Editing', MultiEdit: 'Editing',
|
|
31
|
+
write: 'Creating', edit: 'Editing', multiedit: 'Editing', multi_edit: 'Editing',
|
|
31
32
|
'fs.write': 'Creating', 'fs.edit': 'Editing',
|
|
32
33
|
fs_delete: 'Removing', fs_move: 'Moving',
|
|
33
|
-
write_file: 'Creating', edit_file: 'Editing', delete_file: 'Removing',
|
|
34
|
+
write_file: 'Creating', write_to_file: 'Creating', edit_file: 'Editing', delete_file: 'Removing',
|
|
34
35
|
create_file: 'Creating', new_file: 'Creating',
|
|
35
36
|
remove_file: 'Removing', unlink: 'Removing', move_file: 'Moving',
|
|
36
37
|
replace_file_content: 'Editing', multi_replace_file_content: 'Editing',
|
|
37
38
|
apply_patch: 'Editing', patch: 'Editing', str_replace_editor: 'Editing',
|
|
38
|
-
WriteFile: 'Creating', EditFile: 'Editing', DeleteFile: 'Removing',
|
|
39
|
+
WriteFile: 'Creating', WriteToFile: 'Creating', EditFile: 'Editing', DeleteFile: 'Removing',
|
|
39
40
|
CreateFile: 'Creating', RemoveFile: 'Removing', MoveFile: 'Moving',
|
|
40
41
|
ReplaceFileContent: 'Editing', MultiReplaceFileContent: 'Editing'
|
|
41
42
|
};
|
|
@@ -93,16 +94,17 @@ export function codeProgressFromAction(
|
|
|
93
94
|
phase: CodePhase = 'working',
|
|
94
95
|
source: CodeProgressEvent['source'] = 'tool'
|
|
95
96
|
): CodeProgressEvent | null {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
const
|
|
99
|
-
const
|
|
97
|
+
if (typeof tool !== 'string' || !Object.hasOwn(FILE_TOOLS, tool)) return null;
|
|
98
|
+
const operation = FILE_TOOLS[tool]!;
|
|
99
|
+
const safeArgs: Record<string, unknown> = args && typeof args === 'object' ? args : {};
|
|
100
|
+
const path = stringField(safeArgs.path ?? safeArgs.Path ?? safeArgs.file_path ?? safeArgs.FilePath ?? safeArgs.AbsolutePath ?? safeArgs.TargetFile ?? safeArgs.source);
|
|
101
|
+
const destination = stringField(safeArgs.destination);
|
|
100
102
|
const label = path ? path.split(/[/\\]/).pop() || path : 'file';
|
|
101
103
|
const description = operation === 'Moving' && destination
|
|
102
104
|
? `Moving ${label} to ${destination}`
|
|
103
105
|
: `${operation} ${label}`;
|
|
104
|
-
const before = previousCodeFromArgs(
|
|
105
|
-
const code = codeFromArgs(
|
|
106
|
+
const before = previousCodeFromArgs(safeArgs);
|
|
107
|
+
const code = codeFromArgs(safeArgs);
|
|
106
108
|
return {
|
|
107
109
|
type: 'code_progress', id, phase, operation,
|
|
108
110
|
...(path ? { path } : {}), description,
|
|
@@ -113,21 +115,24 @@ export function codeProgressFromAction(
|
|
|
113
115
|
export class StreamingCodePreview {
|
|
114
116
|
private buffer = '';
|
|
115
117
|
private lastCode = '';
|
|
116
|
-
private lastSentAt =
|
|
118
|
+
private lastSentAt: number | null = null;
|
|
117
119
|
private truncated = false;
|
|
118
120
|
|
|
119
121
|
accept(chunk: string, now = Date.now()): CodeProgressEvent | null {
|
|
120
|
-
if (!chunk) return null;
|
|
122
|
+
if (!chunk || typeof chunk !== 'string') return null;
|
|
121
123
|
this.buffer += chunk;
|
|
122
124
|
if (this.buffer.length > MAX_STREAM_PREVIEW_CHARS) {
|
|
123
125
|
this.buffer = this.buffer.slice(-MAX_STREAM_PREVIEW_CHARS);
|
|
124
126
|
this.truncated = true;
|
|
125
127
|
}
|
|
126
|
-
|
|
128
|
+
const safeNow = Number.isFinite(now) ? now : Date.now();
|
|
129
|
+
if (this.lastSentAt !== null && safeNow >= this.lastSentAt && safeNow - this.lastSentAt < 100 && !chunk.includes('\n')) {
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
127
132
|
const code = this.draftCode();
|
|
128
133
|
if (!code.trim() || code === this.lastCode) return null;
|
|
129
134
|
this.lastCode = code;
|
|
130
|
-
this.lastSentAt =
|
|
135
|
+
this.lastSentAt = safeNow;
|
|
131
136
|
return { type: 'code_progress', id: 'model-draft', phase: 'draft',
|
|
132
137
|
operation: 'Drafting', description: 'Writing code from the model stream', code,
|
|
133
138
|
...(this.truncated ? { codeTruncated: true } : {}), source: 'model' };
|
|
@@ -184,12 +189,16 @@ export class NativeCodeObserver {
|
|
|
184
189
|
}
|
|
185
190
|
|
|
186
191
|
handle(event: CodeProgressEvent): void {
|
|
187
|
-
if (!event.path || !['Creating', 'Editing'].includes(event.operation)) return;
|
|
192
|
+
if (!event || typeof event !== 'object' || !event.path || !['Creating', 'Editing'].includes(event.operation)) return;
|
|
188
193
|
if (event.code !== undefined || event.phase === 'failed') {
|
|
189
194
|
this.stop(event.id);
|
|
190
195
|
return;
|
|
191
196
|
}
|
|
192
|
-
const target =
|
|
197
|
+
const target = this.resolveTarget(event.path);
|
|
198
|
+
if (!target) {
|
|
199
|
+
this.stop(event.id);
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
193
202
|
if (event.phase === 'working') {
|
|
194
203
|
this.stop(event.id);
|
|
195
204
|
const previous = this.read(target);
|
|
@@ -229,7 +238,7 @@ export class NativeCodeObserver {
|
|
|
229
238
|
}
|
|
230
239
|
|
|
231
240
|
dispose(): void {
|
|
232
|
-
for (const id of this.active.keys()) this.stop(id);
|
|
241
|
+
for (const id of [...this.active.keys()]) this.stop(id);
|
|
233
242
|
}
|
|
234
243
|
|
|
235
244
|
private stop(id: string): void {
|
|
@@ -238,13 +247,25 @@ export class NativeCodeObserver {
|
|
|
238
247
|
this.active.delete(id);
|
|
239
248
|
}
|
|
240
249
|
|
|
250
|
+
private resolveTarget(rawPath: string): string | null {
|
|
251
|
+
const root = path.resolve(this.workspaceRoot);
|
|
252
|
+
const target = path.resolve(root, rawPath);
|
|
253
|
+
const rel = path.relative(root, target);
|
|
254
|
+
if (!rel || rel.startsWith('..') || path.isAbsolute(rel)) return null;
|
|
255
|
+
return target;
|
|
256
|
+
}
|
|
257
|
+
|
|
241
258
|
private read(file: string): string | null {
|
|
242
259
|
try {
|
|
243
260
|
const name = path.basename(file).toLowerCase();
|
|
244
261
|
if (/^(\.env(?:\.|$)|.*\.(?:pem|key|p12|pfx)$)/u.test(name)) return null;
|
|
245
|
-
const
|
|
262
|
+
const realRoot = fs.realpathSync(this.workspaceRoot);
|
|
263
|
+
const realFile = fs.realpathSync(file);
|
|
264
|
+
const rel = path.relative(realRoot, realFile);
|
|
265
|
+
if (!rel || rel.startsWith('..') || path.isAbsolute(rel)) return null;
|
|
266
|
+
const stat = fs.lstatSync(realFile);
|
|
246
267
|
if (!stat.isFile() || stat.size > 256_000) return null;
|
|
247
|
-
const bytes = fs.readFileSync(
|
|
268
|
+
const bytes = fs.readFileSync(realFile);
|
|
248
269
|
if (bytes.includes(0)) return null;
|
|
249
270
|
return bytes.toString('utf8');
|
|
250
271
|
} catch {
|
|
@@ -263,7 +284,7 @@ function splitCodeLines(code: string): string[] {
|
|
|
263
284
|
}
|
|
264
285
|
|
|
265
286
|
function previewLines(event: CodeProgressEvent): PreviewLine[] {
|
|
266
|
-
if (event.code === undefined) return [];
|
|
287
|
+
if (!event || typeof event !== 'object' || event.code === undefined) return [];
|
|
267
288
|
|
|
268
289
|
// When creating or drafting code, every line is new code (addition).
|
|
269
290
|
// Even if a previous file existed on disk, the action is Creating/Drafting.
|
|
@@ -339,6 +360,7 @@ export function codePreviewLineCount(event: CodeProgressEvent): number {
|
|
|
339
360
|
}
|
|
340
361
|
|
|
341
362
|
export function defaultPreviewStart(event: CodeProgressEvent): number {
|
|
363
|
+
if (!event || typeof event !== 'object') return 0;
|
|
342
364
|
const codeLines = previewLines(event);
|
|
343
365
|
const maxStart = Math.max(0, codeLines.length - CODE_PANEL_LINES);
|
|
344
366
|
if (event.operation === 'Editing') {
|
|
@@ -365,17 +387,28 @@ function highlightCode(kind: PreviewLine['kind'], text: string, width: number):
|
|
|
365
387
|
return paint(role, marker) + `\x1b[${background}m ${body}\x1b[49m`;
|
|
366
388
|
}
|
|
367
389
|
|
|
390
|
+
function oneLineCodeText(value: unknown): string {
|
|
391
|
+
return safeDisplay(value).replace(/\s+/g, ' ').trim();
|
|
392
|
+
}
|
|
393
|
+
|
|
368
394
|
/** Render a bounded, resize-safe panel. The terminal theme supplies rounded corners. */
|
|
369
395
|
export function renderCodeProgress(event: CodeProgressEvent, width: number, modelNote = '', startLine?: number): string[] {
|
|
370
|
-
const
|
|
396
|
+
const safeEvent: CodeProgressEvent =
|
|
397
|
+
event && typeof event === 'object'
|
|
398
|
+
? event
|
|
399
|
+
: { type: 'code_progress', id: 'unknown', phase: 'working', operation: 'code', description: '', source: 'tool' };
|
|
400
|
+
const safeWidth = Number.isFinite(width) ? Math.max(12, Math.floor(width)) : 80;
|
|
371
401
|
const inner = safeWidth - 4;
|
|
372
|
-
const
|
|
373
|
-
const
|
|
374
|
-
|
|
375
|
-
if (
|
|
376
|
-
|
|
402
|
+
const operation = oneLineCodeText(safeEvent.operation).toLowerCase() || 'code';
|
|
403
|
+
const title = `${safeEvent.phase === 'done' ? '✓ ' : safeEvent.phase === 'failed' ? '× ' : ''}code · ${operation}`;
|
|
404
|
+
const rows = [truncate(oneLineCodeText(safeEvent.description), inner)];
|
|
405
|
+
if (safeEvent.path) rows.push(truncate(oneLineCodeText(safeEvent.path), inner));
|
|
406
|
+
if (modelNote) rows.push(truncate(`model note: ${oneLineCodeText(modelNote)}`, inner));
|
|
407
|
+
const codeLines = previewLines(safeEvent);
|
|
377
408
|
const maxStart = Math.max(0, codeLines.length - CODE_PANEL_LINES);
|
|
378
|
-
const start = startLine === undefined
|
|
409
|
+
const start = startLine === undefined || !Number.isFinite(startLine)
|
|
410
|
+
? defaultPreviewStart(safeEvent)
|
|
411
|
+
: Math.max(0, Math.min(Math.floor(startLine), maxStart));
|
|
379
412
|
const visible = codeLines.slice(start, start + CODE_PANEL_LINES);
|
|
380
413
|
if (visible.length) {
|
|
381
414
|
rows.push('');
|
|
@@ -383,7 +416,7 @@ export function renderCodeProgress(event: CodeProgressEvent, width: number, mode
|
|
|
383
416
|
if (codeLines.length > CODE_PANEL_LINES) {
|
|
384
417
|
rows.push(truncate(`lines ${start + 1}-${start + visible.length} of ${codeLines.length} · scroll over code`, inner));
|
|
385
418
|
}
|
|
386
|
-
if (
|
|
419
|
+
if (safeEvent.codeTruncated) rows.push(truncate('Earlier draft content exceeded the preview limit', inner));
|
|
387
420
|
}
|
|
388
|
-
return panel(rows, { width: safeWidth, title, role:
|
|
421
|
+
return panel(rows, { width: safeWidth, title, role: safeEvent.phase === 'failed' ? 'danger' : 'rule' });
|
|
389
422
|
}
|
|
@@ -4,6 +4,14 @@ import { calculateThinkingLineCount, DEFAULT_MAX_EXPANDED_LINES, renderThinkingF
|
|
|
4
4
|
import { formatElapsed } from './statusLine.js';
|
|
5
5
|
import { markerAt } from './messageInteraction.js';
|
|
6
6
|
import { AdaptiveWheelDampener } from './scrollInteraction.js';
|
|
7
|
+
import { safeDisplay } from './text.js';
|
|
8
|
+
function stripTrailingEllipsisText(value) {
|
|
9
|
+
let text = value.trim();
|
|
10
|
+
while (text.endsWith('…') || text.endsWith('...')) {
|
|
11
|
+
text = (text.endsWith('...') ? text.slice(0, -3) : text.slice(0, -1)).trimEnd();
|
|
12
|
+
}
|
|
13
|
+
return text;
|
|
14
|
+
}
|
|
7
15
|
function lastStart(event) {
|
|
8
16
|
return Math.max(0, codePreviewLineCount(event) - CODE_PANEL_LINES);
|
|
9
17
|
}
|
|
@@ -13,6 +21,7 @@ export class CodeStreamRenderer extends ChatRenderer {
|
|
|
13
21
|
modelNote = '';
|
|
14
22
|
lastReasoning = '';
|
|
15
23
|
currentActivity = 'thinking';
|
|
24
|
+
lastReasoningActivity = 'thinking';
|
|
16
25
|
streamingNowMs = 320;
|
|
17
26
|
streamingTick = undefined;
|
|
18
27
|
codePanels = new WeakMap();
|
|
@@ -30,15 +39,19 @@ export class CodeStreamRenderer extends ChatRenderer {
|
|
|
30
39
|
* so the running-light shimmer advances smoothly across both surfaces.
|
|
31
40
|
*/
|
|
32
41
|
onStatusTick(nowMs, tick) {
|
|
33
|
-
|
|
34
|
-
|
|
42
|
+
if (!Number.isFinite(nowMs))
|
|
43
|
+
return;
|
|
44
|
+
this.streamingNowMs = Math.max(0, nowMs);
|
|
45
|
+
if (tick === undefined || Number.isFinite(tick)) {
|
|
46
|
+
this.streamingTick = tick === undefined ? undefined : Math.max(0, Math.floor(tick));
|
|
47
|
+
}
|
|
35
48
|
const transcript = this.transcript;
|
|
36
49
|
if (!transcript || !Array.isArray(transcript.frames))
|
|
37
50
|
return;
|
|
38
51
|
const activeFrame = transcript.frames.findLast((f) => f?.meta?.reasoning === true && f.meta?.streaming === true);
|
|
39
52
|
if (activeFrame && activeFrame.meta) {
|
|
40
|
-
if (
|
|
41
|
-
activeFrame.meta.durationText = formatElapsed(
|
|
53
|
+
if (this.streamingNowMs > 0) {
|
|
54
|
+
activeFrame.meta.durationText = formatElapsed(this.streamingNowMs);
|
|
42
55
|
}
|
|
43
56
|
activeFrame.rows = null;
|
|
44
57
|
activeFrame.renderedWidth = -1;
|
|
@@ -103,6 +116,7 @@ export class CodeStreamRenderer extends ChatRenderer {
|
|
|
103
116
|
if (next === state.start)
|
|
104
117
|
return true;
|
|
105
118
|
state.start = next;
|
|
119
|
+
state.userScrolled = true;
|
|
106
120
|
state.followTail = next === limit;
|
|
107
121
|
frame.rows = null;
|
|
108
122
|
frame.renderedWidth = -1;
|
|
@@ -128,8 +142,28 @@ export class CodeStreamRenderer extends ChatRenderer {
|
|
|
128
142
|
if (!frame || frame.meta?.reasoning !== true || frame.meta?.collapsed)
|
|
129
143
|
return false;
|
|
130
144
|
const content = typeof frame.meta.content === 'string' ? frame.meta.content : '';
|
|
131
|
-
const
|
|
132
|
-
|
|
145
|
+
const renderedMainWidth = (typeof frame.renderedWidth === 'number' && Number.isFinite(frame.renderedWidth) && frame.renderedWidth > 0)
|
|
146
|
+
? frame.renderedWidth
|
|
147
|
+
: (typeof surface?.viewport?.viewWidth === 'number' && Number.isFinite(surface.viewport.viewWidth) && surface.viewport.viewWidth > 0)
|
|
148
|
+
? surface.viewport.viewWidth
|
|
149
|
+
: 0;
|
|
150
|
+
const prevForcedWidth = this.forcedWidth;
|
|
151
|
+
if (renderedMainWidth > 0 && !prevForcedWidth) {
|
|
152
|
+
this.forcedWidth = renderedMainWidth;
|
|
153
|
+
}
|
|
154
|
+
let measureWidth;
|
|
155
|
+
try {
|
|
156
|
+
measureWidth = this.measure();
|
|
157
|
+
}
|
|
158
|
+
finally {
|
|
159
|
+
this.forcedWidth = prevForcedWidth;
|
|
160
|
+
}
|
|
161
|
+
const totalLines = calculateThinkingLineCount(content, measureWidth);
|
|
162
|
+
const rawMaxVisible = Number(frame.meta.maxVisibleLines);
|
|
163
|
+
const maxVisibleLines = Number.isFinite(rawMaxVisible) && rawMaxVisible >= 1
|
|
164
|
+
? Math.floor(rawMaxVisible)
|
|
165
|
+
: DEFAULT_MAX_EXPANDED_LINES;
|
|
166
|
+
const limit = Math.max(0, totalLines - maxVisibleLines);
|
|
133
167
|
if (limit === 0)
|
|
134
168
|
return false;
|
|
135
169
|
if (!frame.meta._dampener) {
|
|
@@ -156,6 +190,7 @@ export class CodeStreamRenderer extends ChatRenderer {
|
|
|
156
190
|
this.activeCode = null;
|
|
157
191
|
this.modelNote = '';
|
|
158
192
|
this.lastReasoning = '';
|
|
193
|
+
this.lastReasoningActivity = 'thinking';
|
|
159
194
|
this.collapseFinishedReasoningFrames(true);
|
|
160
195
|
super.resetTurn();
|
|
161
196
|
}
|
|
@@ -190,33 +225,55 @@ export class CodeStreamRenderer extends ChatRenderer {
|
|
|
190
225
|
handle(message) {
|
|
191
226
|
const selfStatus = this;
|
|
192
227
|
if (message?.type === 'agent_activity') {
|
|
193
|
-
const rawActivity = String(message.activity || message.message || '').trim();
|
|
228
|
+
const rawActivity = safeDisplay(String(message.activity || message.message || '')).replace(/\s+/g, ' ').trim();
|
|
194
229
|
if (rawActivity) {
|
|
195
|
-
|
|
230
|
+
const normalizedActivity = stripTrailingEllipsisText(rawActivity);
|
|
231
|
+
this.currentActivity = normalizedActivity;
|
|
232
|
+
const isRespondingPhase = /^responding\b/i.test(normalizedActivity);
|
|
196
233
|
if (this._activeReasoning && this.lastReasoning) {
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
234
|
+
if (isRespondingPhase) {
|
|
235
|
+
// Finalize an open reasoning / native-step frame with its real
|
|
236
|
+
// activity instead of relabeling executed steps as "responding".
|
|
237
|
+
super.onAgentReasoning({
|
|
238
|
+
content: this.lastReasoning,
|
|
239
|
+
streaming: false,
|
|
240
|
+
activity: this.lastReasoningActivity || 'thinking'
|
|
241
|
+
});
|
|
242
|
+
this._activeReasoning = false;
|
|
243
|
+
this.lastReasoning = '';
|
|
244
|
+
}
|
|
245
|
+
else {
|
|
246
|
+
this.lastReasoningActivity = normalizedActivity;
|
|
247
|
+
super.onAgentReasoning({
|
|
248
|
+
content: this.lastReasoning,
|
|
249
|
+
streaming: true,
|
|
250
|
+
activity: normalizedActivity,
|
|
251
|
+
title: rawActivity
|
|
252
|
+
});
|
|
253
|
+
}
|
|
203
254
|
if (selfStatus.quietStatus) {
|
|
204
255
|
selfStatus.currentStatus = rawActivity;
|
|
205
256
|
selfStatus.onStatusChange?.(rawActivity);
|
|
206
257
|
}
|
|
207
258
|
return true;
|
|
208
259
|
}
|
|
209
|
-
const handled = super.handle(message);
|
|
210
260
|
if (selfStatus.quietStatus) {
|
|
261
|
+
// Full-screen quietStatus owns live phase indicators via the footer;
|
|
262
|
+
// do not append transient phase notices into the permanent transcript.
|
|
211
263
|
selfStatus.currentStatus = rawActivity;
|
|
212
264
|
selfStatus.onStatusChange?.(rawActivity);
|
|
265
|
+
return true;
|
|
213
266
|
}
|
|
214
|
-
return
|
|
267
|
+
return super.handle({
|
|
268
|
+
...message,
|
|
269
|
+
activity: rawActivity,
|
|
270
|
+
message: rawActivity
|
|
271
|
+
});
|
|
215
272
|
}
|
|
216
273
|
}
|
|
217
274
|
if (message?.type === 'notice' && message.nativeStep === true) {
|
|
218
275
|
this.stepCount = (this.stepCount || 0) + 1;
|
|
219
|
-
const stepLine = String(message.message || '').trim();
|
|
276
|
+
const stepLine = safeDisplay(String(message.message || '')).replace(/\s+/g, ' ').trim();
|
|
220
277
|
if (stepLine) {
|
|
221
278
|
const actionName = String(message.actionName || stepLine).toLowerCase();
|
|
222
279
|
let activity = this.currentActivity || 'processing';
|
|
@@ -236,6 +293,7 @@ export class CodeStreamRenderer extends ChatRenderer {
|
|
|
236
293
|
activity = 'planning';
|
|
237
294
|
}
|
|
238
295
|
this.currentActivity = activity;
|
|
296
|
+
this.lastReasoningActivity = activity;
|
|
239
297
|
if (selfStatus.quietStatus) {
|
|
240
298
|
const statusLabel = `${activity.charAt(0).toUpperCase() + activity.slice(1)}…`;
|
|
241
299
|
selfStatus.currentStatus = statusLabel;
|
|
@@ -266,8 +324,8 @@ export class CodeStreamRenderer extends ChatRenderer {
|
|
|
266
324
|
this._activeReasoning = false;
|
|
267
325
|
}
|
|
268
326
|
if (this.activeCode && this.transcript) {
|
|
269
|
-
const note = content.trim().split('\n').at(-1) || '';
|
|
270
|
-
this.modelNote = note.slice(-140);
|
|
327
|
+
const note = safeDisplay(content).trim().split('\n').at(-1) || '';
|
|
328
|
+
this.modelNote = Array.from(note).slice(-140).join('');
|
|
271
329
|
this.paintCodePanel(this.activeCode);
|
|
272
330
|
if (message.streaming === false) {
|
|
273
331
|
this.lastReasoning = '';
|
|
@@ -275,9 +333,14 @@ export class CodeStreamRenderer extends ChatRenderer {
|
|
|
275
333
|
return true;
|
|
276
334
|
}
|
|
277
335
|
const preservedStatus = selfStatus.quietStatus ? selfStatus.currentStatus : '';
|
|
336
|
+
const rawReasonActivity = message.activity || this.currentActivity || 'thinking';
|
|
337
|
+
const reasonActivity = /^responding\b/i.test(String(rawReasonActivity))
|
|
338
|
+
? (this.lastReasoningActivity || 'thinking')
|
|
339
|
+
: String(rawReasonActivity);
|
|
340
|
+
this.lastReasoningActivity = reasonActivity;
|
|
278
341
|
const handled = super.handle({
|
|
279
342
|
...message,
|
|
280
|
-
activity:
|
|
343
|
+
activity: reasonActivity
|
|
281
344
|
});
|
|
282
345
|
if (message.streaming === false) {
|
|
283
346
|
this.lastReasoning = '';
|
|
@@ -304,7 +367,7 @@ export class CodeStreamRenderer extends ChatRenderer {
|
|
|
304
367
|
super.onAgentReasoning({
|
|
305
368
|
content: this.lastReasoning,
|
|
306
369
|
streaming: false,
|
|
307
|
-
activity: this.currentActivity
|
|
370
|
+
activity: this.lastReasoningActivity || this.currentActivity
|
|
308
371
|
});
|
|
309
372
|
}
|
|
310
373
|
this._activeReasoning = false;
|
|
@@ -327,7 +390,8 @@ export class CodeStreamRenderer extends ChatRenderer {
|
|
|
327
390
|
if (!this.transcript && event.phase === 'draft')
|
|
328
391
|
return;
|
|
329
392
|
if (this.lastReasoning && !this.modelNote) {
|
|
330
|
-
|
|
393
|
+
const lastLine = safeDisplay(this.lastReasoning).trim().split('\n').at(-1) || '';
|
|
394
|
+
this.modelNote = Array.from(lastLine).slice(-140).join('');
|
|
331
395
|
}
|
|
332
396
|
if (this._activeReasoning) {
|
|
333
397
|
super.onAgentReasoning({ content: this.lastReasoning, streaming: false });
|
|
@@ -360,6 +424,7 @@ export class CodeStreamRenderer extends ChatRenderer {
|
|
|
360
424
|
}
|
|
361
425
|
}
|
|
362
426
|
const state = targetFrame ? this.codePanels.get(targetFrame) : undefined;
|
|
427
|
+
const transitionedToEdit = Boolean(state && event.operation === 'Editing' && state.event.operation !== 'Editing');
|
|
363
428
|
const panelState = state || {
|
|
364
429
|
event,
|
|
365
430
|
modelNote: this.modelNote,
|
|
@@ -368,7 +433,13 @@ export class CodeStreamRenderer extends ChatRenderer {
|
|
|
368
433
|
};
|
|
369
434
|
panelState.event = event;
|
|
370
435
|
panelState.modelNote = this.modelNote;
|
|
371
|
-
|
|
436
|
+
if (transitionedToEdit && !panelState.userScrolled) {
|
|
437
|
+
panelState.followTail = false;
|
|
438
|
+
panelState.start = defaultPreviewStart(event);
|
|
439
|
+
}
|
|
440
|
+
else {
|
|
441
|
+
panelState.start = panelState.followTail ? lastStart(event) : Math.min(panelState.start, lastStart(event));
|
|
442
|
+
}
|
|
372
443
|
const produce = () => {
|
|
373
444
|
for (const row of renderCodeProgress(panelState.event, this.measure(), panelState.modelNote, panelState.start))
|
|
374
445
|
this.write(row);
|
|
@@ -4,6 +4,15 @@ import { calculateThinkingLineCount, DEFAULT_MAX_EXPANDED_LINES, renderThinkingF
|
|
|
4
4
|
import { formatElapsed, type StatusLine } from './statusLine.js';
|
|
5
5
|
import { markerAt } from './messageInteraction.js';
|
|
6
6
|
import { AdaptiveWheelDampener } from './scrollInteraction.js';
|
|
7
|
+
import { safeDisplay } from './text.js';
|
|
8
|
+
|
|
9
|
+
function stripTrailingEllipsisText(value: string): string {
|
|
10
|
+
let text = value.trim();
|
|
11
|
+
while (text.endsWith('…') || text.endsWith('...')) {
|
|
12
|
+
text = (text.endsWith('...') ? text.slice(0, -3) : text.slice(0, -1)).trimEnd();
|
|
13
|
+
}
|
|
14
|
+
return text;
|
|
15
|
+
}
|
|
7
16
|
|
|
8
17
|
type RendererEvent = { type: string; [key: string]: unknown };
|
|
9
18
|
type CodePanelState = {
|
|
@@ -11,6 +20,7 @@ type CodePanelState = {
|
|
|
11
20
|
modelNote: string;
|
|
12
21
|
start: number;
|
|
13
22
|
followTail: boolean;
|
|
23
|
+
userScrolled?: boolean;
|
|
14
24
|
dampener?: AdaptiveWheelDampener;
|
|
15
25
|
};
|
|
16
26
|
type CodeFrame = { id: number; meta?: Record<string, unknown> | null; rows?: string[] | null; renderedWidth?: number; produce?: (width: number) => string[] };
|
|
@@ -38,6 +48,7 @@ export class CodeStreamRenderer extends ChatRenderer {
|
|
|
38
48
|
private modelNote = '';
|
|
39
49
|
private lastReasoning = '';
|
|
40
50
|
private currentActivity = 'thinking';
|
|
51
|
+
private lastReasoningActivity = 'thinking';
|
|
41
52
|
private streamingNowMs = 320;
|
|
42
53
|
private streamingTick: number | undefined = undefined;
|
|
43
54
|
private readonly codePanels = new WeakMap<CodeFrame, CodePanelState>();
|
|
@@ -57,16 +68,19 @@ export class CodeStreamRenderer extends ChatRenderer {
|
|
|
57
68
|
* so the running-light shimmer advances smoothly across both surfaces.
|
|
58
69
|
*/
|
|
59
70
|
onStatusTick(nowMs: number, tick?: number): void {
|
|
60
|
-
|
|
61
|
-
this.
|
|
71
|
+
if (!Number.isFinite(nowMs)) return;
|
|
72
|
+
this.streamingNowMs = Math.max(0, nowMs);
|
|
73
|
+
if (tick === undefined || Number.isFinite(tick)) {
|
|
74
|
+
this.streamingTick = tick === undefined ? undefined : Math.max(0, Math.floor(tick));
|
|
75
|
+
}
|
|
62
76
|
const transcript = this.transcript as unknown as CodeTranscript | null;
|
|
63
77
|
if (!transcript || !Array.isArray(transcript.frames)) return;
|
|
64
78
|
const activeFrame = transcript.frames.findLast(
|
|
65
79
|
(f: CodeFrame) => f?.meta?.reasoning === true && f.meta?.streaming === true
|
|
66
80
|
);
|
|
67
81
|
if (activeFrame && activeFrame.meta) {
|
|
68
|
-
if (
|
|
69
|
-
activeFrame.meta.durationText = formatElapsed(
|
|
82
|
+
if (this.streamingNowMs > 0) {
|
|
83
|
+
activeFrame.meta.durationText = formatElapsed(this.streamingNowMs);
|
|
70
84
|
}
|
|
71
85
|
activeFrame.rows = null;
|
|
72
86
|
activeFrame.renderedWidth = -1;
|
|
@@ -145,6 +159,7 @@ export class CodeStreamRenderer extends ChatRenderer {
|
|
|
145
159
|
if (next === state.start) return true;
|
|
146
160
|
|
|
147
161
|
state.start = next;
|
|
162
|
+
state.userScrolled = true;
|
|
148
163
|
state.followTail = next === limit;
|
|
149
164
|
frame.rows = null;
|
|
150
165
|
frame.renderedWidth = -1;
|
|
@@ -169,8 +184,27 @@ export class CodeStreamRenderer extends ChatRenderer {
|
|
|
169
184
|
if (!frame || frame.meta?.reasoning !== true || frame.meta?.collapsed) return false;
|
|
170
185
|
|
|
171
186
|
const content = typeof frame.meta.content === 'string' ? frame.meta.content : '';
|
|
172
|
-
const
|
|
173
|
-
|
|
187
|
+
const renderedMainWidth = (typeof frame.renderedWidth === 'number' && Number.isFinite(frame.renderedWidth) && frame.renderedWidth > 0)
|
|
188
|
+
? frame.renderedWidth
|
|
189
|
+
: (typeof surface?.viewport?.viewWidth === 'number' && Number.isFinite(surface.viewport.viewWidth) && surface.viewport.viewWidth > 0)
|
|
190
|
+
? surface.viewport.viewWidth
|
|
191
|
+
: 0;
|
|
192
|
+
const prevForcedWidth = (this as any).forcedWidth;
|
|
193
|
+
if (renderedMainWidth > 0 && !prevForcedWidth) {
|
|
194
|
+
(this as any).forcedWidth = renderedMainWidth;
|
|
195
|
+
}
|
|
196
|
+
let measureWidth: number;
|
|
197
|
+
try {
|
|
198
|
+
measureWidth = this.measure();
|
|
199
|
+
} finally {
|
|
200
|
+
(this as any).forcedWidth = prevForcedWidth;
|
|
201
|
+
}
|
|
202
|
+
const totalLines = calculateThinkingLineCount(content, measureWidth);
|
|
203
|
+
const rawMaxVisible = Number(frame.meta.maxVisibleLines);
|
|
204
|
+
const maxVisibleLines = Number.isFinite(rawMaxVisible) && rawMaxVisible >= 1
|
|
205
|
+
? Math.floor(rawMaxVisible)
|
|
206
|
+
: DEFAULT_MAX_EXPANDED_LINES;
|
|
207
|
+
const limit = Math.max(0, totalLines - maxVisibleLines);
|
|
174
208
|
if (limit === 0) return false;
|
|
175
209
|
|
|
176
210
|
if (!frame.meta._dampener) {
|
|
@@ -198,6 +232,7 @@ export class CodeStreamRenderer extends ChatRenderer {
|
|
|
198
232
|
this.activeCode = null;
|
|
199
233
|
this.modelNote = '';
|
|
200
234
|
this.lastReasoning = '';
|
|
235
|
+
this.lastReasoningActivity = 'thinking';
|
|
201
236
|
this.collapseFinishedReasoningFrames(true);
|
|
202
237
|
super.resetTurn();
|
|
203
238
|
}
|
|
@@ -239,34 +274,55 @@ export class CodeStreamRenderer extends ChatRenderer {
|
|
|
239
274
|
};
|
|
240
275
|
|
|
241
276
|
if (message?.type === 'agent_activity') {
|
|
242
|
-
const rawActivity = String((message as any).activity || (message as any).message || '').trim();
|
|
277
|
+
const rawActivity = safeDisplay(String((message as any).activity || (message as any).message || '')).replace(/\s+/g, ' ').trim();
|
|
243
278
|
if (rawActivity) {
|
|
244
|
-
|
|
279
|
+
const normalizedActivity = stripTrailingEllipsisText(rawActivity);
|
|
280
|
+
this.currentActivity = normalizedActivity;
|
|
281
|
+
const isRespondingPhase = /^responding\b/i.test(normalizedActivity);
|
|
245
282
|
if (this._activeReasoning && this.lastReasoning) {
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
283
|
+
if (isRespondingPhase) {
|
|
284
|
+
// Finalize an open reasoning / native-step frame with its real
|
|
285
|
+
// activity instead of relabeling executed steps as "responding".
|
|
286
|
+
super.onAgentReasoning({
|
|
287
|
+
content: this.lastReasoning,
|
|
288
|
+
streaming: false,
|
|
289
|
+
activity: this.lastReasoningActivity || 'thinking'
|
|
290
|
+
});
|
|
291
|
+
this._activeReasoning = false;
|
|
292
|
+
this.lastReasoning = '';
|
|
293
|
+
} else {
|
|
294
|
+
this.lastReasoningActivity = normalizedActivity;
|
|
295
|
+
super.onAgentReasoning({
|
|
296
|
+
content: this.lastReasoning,
|
|
297
|
+
streaming: true,
|
|
298
|
+
activity: normalizedActivity,
|
|
299
|
+
title: rawActivity
|
|
300
|
+
});
|
|
301
|
+
}
|
|
252
302
|
if (selfStatus.quietStatus) {
|
|
253
303
|
selfStatus.currentStatus = rawActivity;
|
|
254
304
|
selfStatus.onStatusChange?.(rawActivity);
|
|
255
305
|
}
|
|
256
306
|
return true;
|
|
257
307
|
}
|
|
258
|
-
const handled = super.handle(message);
|
|
259
308
|
if (selfStatus.quietStatus) {
|
|
309
|
+
// Full-screen quietStatus owns live phase indicators via the footer;
|
|
310
|
+
// do not append transient phase notices into the permanent transcript.
|
|
260
311
|
selfStatus.currentStatus = rawActivity;
|
|
261
312
|
selfStatus.onStatusChange?.(rawActivity);
|
|
313
|
+
return true;
|
|
262
314
|
}
|
|
263
|
-
return
|
|
315
|
+
return super.handle({
|
|
316
|
+
...message,
|
|
317
|
+
activity: rawActivity,
|
|
318
|
+
message: rawActivity
|
|
319
|
+
});
|
|
264
320
|
}
|
|
265
321
|
}
|
|
266
322
|
|
|
267
323
|
if (message?.type === 'notice' && message.nativeStep === true) {
|
|
268
324
|
this.stepCount = (this.stepCount || 0) + 1;
|
|
269
|
-
const stepLine = String(message.message || '').trim();
|
|
325
|
+
const stepLine = safeDisplay(String(message.message || '')).replace(/\s+/g, ' ').trim();
|
|
270
326
|
if (stepLine) {
|
|
271
327
|
const actionName = String((message as any).actionName || stepLine).toLowerCase();
|
|
272
328
|
let activity = this.currentActivity || 'processing';
|
|
@@ -282,6 +338,7 @@ export class CodeStreamRenderer extends ChatRenderer {
|
|
|
282
338
|
activity = 'planning';
|
|
283
339
|
}
|
|
284
340
|
this.currentActivity = activity;
|
|
341
|
+
this.lastReasoningActivity = activity;
|
|
285
342
|
if (selfStatus.quietStatus) {
|
|
286
343
|
const statusLabel = `${activity.charAt(0).toUpperCase() + activity.slice(1)}…`;
|
|
287
344
|
selfStatus.currentStatus = statusLabel;
|
|
@@ -314,8 +371,8 @@ export class CodeStreamRenderer extends ChatRenderer {
|
|
|
314
371
|
this._activeReasoning = false;
|
|
315
372
|
}
|
|
316
373
|
if (this.activeCode && this.transcript) {
|
|
317
|
-
const note = content.trim().split('\n').at(-1) || '';
|
|
318
|
-
this.modelNote = note.slice(-140);
|
|
374
|
+
const note = safeDisplay(content).trim().split('\n').at(-1) || '';
|
|
375
|
+
this.modelNote = Array.from(note).slice(-140).join('');
|
|
319
376
|
this.paintCodePanel(this.activeCode);
|
|
320
377
|
if (message.streaming === false) {
|
|
321
378
|
this.lastReasoning = '';
|
|
@@ -323,9 +380,14 @@ export class CodeStreamRenderer extends ChatRenderer {
|
|
|
323
380
|
return true;
|
|
324
381
|
}
|
|
325
382
|
const preservedStatus = selfStatus.quietStatus ? selfStatus.currentStatus : '';
|
|
383
|
+
const rawReasonActivity = (message as any).activity || this.currentActivity || 'thinking';
|
|
384
|
+
const reasonActivity = /^responding\b/i.test(String(rawReasonActivity))
|
|
385
|
+
? (this.lastReasoningActivity || 'thinking')
|
|
386
|
+
: String(rawReasonActivity);
|
|
387
|
+
this.lastReasoningActivity = reasonActivity;
|
|
326
388
|
const handled = super.handle({
|
|
327
389
|
...message,
|
|
328
|
-
activity:
|
|
390
|
+
activity: reasonActivity
|
|
329
391
|
});
|
|
330
392
|
if (message.streaming === false) {
|
|
331
393
|
this.lastReasoning = '';
|
|
@@ -351,7 +413,7 @@ export class CodeStreamRenderer extends ChatRenderer {
|
|
|
351
413
|
super.onAgentReasoning({
|
|
352
414
|
content: this.lastReasoning,
|
|
353
415
|
streaming: false,
|
|
354
|
-
activity: this.currentActivity
|
|
416
|
+
activity: this.lastReasoningActivity || this.currentActivity
|
|
355
417
|
});
|
|
356
418
|
}
|
|
357
419
|
this._activeReasoning = false;
|
|
@@ -373,7 +435,8 @@ export class CodeStreamRenderer extends ChatRenderer {
|
|
|
373
435
|
|| typeof event.description !== 'string' || !['draft', 'working', 'done', 'failed'].includes(event.phase)) return;
|
|
374
436
|
if (!this.transcript && event.phase === 'draft') return;
|
|
375
437
|
if (this.lastReasoning && !this.modelNote) {
|
|
376
|
-
|
|
438
|
+
const lastLine = safeDisplay(this.lastReasoning).trim().split('\n').at(-1) || '';
|
|
439
|
+
this.modelNote = Array.from(lastLine).slice(-140).join('');
|
|
377
440
|
}
|
|
378
441
|
if (this._activeReasoning) {
|
|
379
442
|
super.onAgentReasoning({ content: this.lastReasoning, streaming: false });
|
|
@@ -408,6 +471,7 @@ export class CodeStreamRenderer extends ChatRenderer {
|
|
|
408
471
|
}
|
|
409
472
|
|
|
410
473
|
const state = targetFrame ? this.codePanels.get(targetFrame) : undefined;
|
|
474
|
+
const transitionedToEdit = Boolean(state && event.operation === 'Editing' && state.event.operation !== 'Editing');
|
|
411
475
|
const panelState: CodePanelState = state || {
|
|
412
476
|
event,
|
|
413
477
|
modelNote: this.modelNote,
|
|
@@ -416,7 +480,12 @@ export class CodeStreamRenderer extends ChatRenderer {
|
|
|
416
480
|
};
|
|
417
481
|
panelState.event = event;
|
|
418
482
|
panelState.modelNote = this.modelNote;
|
|
419
|
-
|
|
483
|
+
if (transitionedToEdit && !panelState.userScrolled) {
|
|
484
|
+
panelState.followTail = false;
|
|
485
|
+
panelState.start = defaultPreviewStart(event);
|
|
486
|
+
} else {
|
|
487
|
+
panelState.start = panelState.followTail ? lastStart(event) : Math.min(panelState.start, lastStart(event));
|
|
488
|
+
}
|
|
420
489
|
const produce = (): void => {
|
|
421
490
|
for (const row of renderCodeProgress(panelState.event, this.measure(), panelState.modelNote, panelState.start)) this.write(row);
|
|
422
491
|
};
|