@causyne/agent 1.20.116 → 1.20.118
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/package.json +7 -2
- package/src/agentLoop.js +81 -31
- package/src/agentLoop.ts +82 -33
- package/src/browser/causyneBrowser.js +30 -7
- package/src/browser/causyneBrowser.ts +29 -7
- package/src/cliMode.js +24 -4
- package/src/commands.js +7 -1
- 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/perception.js +124 -3
- package/src/perception.ts +128 -4
- package/src/planCache.js +17 -3
- package/src/planCache.ts +17 -3
- package/src/plugins/pluginManager.js +74 -0
- package/src/reporting.js +12 -4
- package/src/skillsManager.js +3 -2
- package/src/skillsManager.ts +3 -2
- 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/toolPacks.js +27 -5
- package/src/toolPacks.ts +32 -5
- package/src/tools/memoryWrite.js +8 -10
- package/src/tools/memoryWrite.ts +13 -11
- package/src/tools/pluginManager.js +17 -2
- package/src/tui/chatRenderer.js +4 -1
- package/src/tui/codeProgress.js +3 -2
- package/src/tui/codeProgress.ts +3 -2
- package/src/tui/codeStreamRenderer.js +41 -15
- package/src/tui/codeStreamRenderer.ts +40 -15
- package/src/tui/composerControls.js +16 -3
- package/src/tui/composerControls.ts +14 -3
- package/src/tui/keys.js +3 -1
- package/src/tui/prompt.js +146 -16
- package/src/tui/scrollInteraction.js +2 -2
- package/src/tui/scrollInteraction.ts +2 -2
- package/src/tui/stageSurface.js +114 -4
- package/src/tui/turnRail.js +21 -14
- package/src/tui/turnRail.ts +19 -14
- package/src/tui/usageCard.js +164 -71
- package/src/tui/usageCard.ts +187 -96
- package/src/tui/workspaceSwitch.js +2 -0
- package/src/tui/workspaceSwitch.ts +1 -0
- package/src/types/contracts.ts +3 -0
- package/src/verification/boundedExplorer.js +119 -0
- package/src/verification/cliProbe.js +116 -0
- package/src/verification/featureMap.js +78 -0
- package/src/verification/interactivePty.js +188 -0
- package/src/verification/propertyProbe.js +121 -0
- package/src/verification/ptyProbe.js +125 -0
- package/src/verification/skillCatalog.d.ts +1 -0
- package/src/verification/skillCatalog.js +60 -0
- package/src/verification/statechart.js +143 -0
- package/src/verification/uiRuntime.js +57 -0
- package/src/verificationPlan.js +1 -1
- package/src/verificationPlan.ts +1 -1
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
|
};
|
|
@@ -21,6 +21,7 @@ export class CodeStreamRenderer extends ChatRenderer {
|
|
|
21
21
|
modelNote = '';
|
|
22
22
|
lastReasoning = '';
|
|
23
23
|
currentActivity = 'thinking';
|
|
24
|
+
lastReasoningActivity = 'thinking';
|
|
24
25
|
streamingNowMs = 320;
|
|
25
26
|
streamingTick = undefined;
|
|
26
27
|
codePanels = new WeakMap();
|
|
@@ -189,6 +190,7 @@ export class CodeStreamRenderer extends ChatRenderer {
|
|
|
189
190
|
this.activeCode = null;
|
|
190
191
|
this.modelNote = '';
|
|
191
192
|
this.lastReasoning = '';
|
|
193
|
+
this.lastReasoningActivity = 'thinking';
|
|
192
194
|
this.collapseFinishedReasoningFrames(true);
|
|
193
195
|
super.resetTurn();
|
|
194
196
|
}
|
|
@@ -225,30 +227,48 @@ export class CodeStreamRenderer extends ChatRenderer {
|
|
|
225
227
|
if (message?.type === 'agent_activity') {
|
|
226
228
|
const rawActivity = safeDisplay(String(message.activity || message.message || '')).replace(/\s+/g, ' ').trim();
|
|
227
229
|
if (rawActivity) {
|
|
228
|
-
|
|
230
|
+
const normalizedActivity = stripTrailingEllipsisText(rawActivity);
|
|
231
|
+
this.currentActivity = normalizedActivity;
|
|
232
|
+
const isRespondingPhase = /^responding\b/i.test(normalizedActivity);
|
|
229
233
|
if (this._activeReasoning && this.lastReasoning) {
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
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
|
+
}
|
|
236
254
|
if (selfStatus.quietStatus) {
|
|
237
255
|
selfStatus.currentStatus = rawActivity;
|
|
238
256
|
selfStatus.onStatusChange?.(rawActivity);
|
|
239
257
|
}
|
|
240
258
|
return true;
|
|
241
259
|
}
|
|
242
|
-
const handled = super.handle({
|
|
243
|
-
...message,
|
|
244
|
-
activity: rawActivity,
|
|
245
|
-
message: rawActivity
|
|
246
|
-
});
|
|
247
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.
|
|
248
263
|
selfStatus.currentStatus = rawActivity;
|
|
249
264
|
selfStatus.onStatusChange?.(rawActivity);
|
|
265
|
+
return true;
|
|
250
266
|
}
|
|
251
|
-
return
|
|
267
|
+
return super.handle({
|
|
268
|
+
...message,
|
|
269
|
+
activity: rawActivity,
|
|
270
|
+
message: rawActivity
|
|
271
|
+
});
|
|
252
272
|
}
|
|
253
273
|
}
|
|
254
274
|
if (message?.type === 'notice' && message.nativeStep === true) {
|
|
@@ -273,6 +293,7 @@ export class CodeStreamRenderer extends ChatRenderer {
|
|
|
273
293
|
activity = 'planning';
|
|
274
294
|
}
|
|
275
295
|
this.currentActivity = activity;
|
|
296
|
+
this.lastReasoningActivity = activity;
|
|
276
297
|
if (selfStatus.quietStatus) {
|
|
277
298
|
const statusLabel = `${activity.charAt(0).toUpperCase() + activity.slice(1)}…`;
|
|
278
299
|
selfStatus.currentStatus = statusLabel;
|
|
@@ -312,9 +333,14 @@ export class CodeStreamRenderer extends ChatRenderer {
|
|
|
312
333
|
return true;
|
|
313
334
|
}
|
|
314
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;
|
|
315
341
|
const handled = super.handle({
|
|
316
342
|
...message,
|
|
317
|
-
activity:
|
|
343
|
+
activity: reasonActivity
|
|
318
344
|
});
|
|
319
345
|
if (message.streaming === false) {
|
|
320
346
|
this.lastReasoning = '';
|
|
@@ -341,7 +367,7 @@ export class CodeStreamRenderer extends ChatRenderer {
|
|
|
341
367
|
super.onAgentReasoning({
|
|
342
368
|
content: this.lastReasoning,
|
|
343
369
|
streaming: false,
|
|
344
|
-
activity: this.currentActivity
|
|
370
|
+
activity: this.lastReasoningActivity || this.currentActivity
|
|
345
371
|
});
|
|
346
372
|
}
|
|
347
373
|
this._activeReasoning = false;
|
|
@@ -48,6 +48,7 @@ export class CodeStreamRenderer extends ChatRenderer {
|
|
|
48
48
|
private modelNote = '';
|
|
49
49
|
private lastReasoning = '';
|
|
50
50
|
private currentActivity = 'thinking';
|
|
51
|
+
private lastReasoningActivity = 'thinking';
|
|
51
52
|
private streamingNowMs = 320;
|
|
52
53
|
private streamingTick: number | undefined = undefined;
|
|
53
54
|
private readonly codePanels = new WeakMap<CodeFrame, CodePanelState>();
|
|
@@ -231,6 +232,7 @@ export class CodeStreamRenderer extends ChatRenderer {
|
|
|
231
232
|
this.activeCode = null;
|
|
232
233
|
this.modelNote = '';
|
|
233
234
|
this.lastReasoning = '';
|
|
235
|
+
this.lastReasoningActivity = 'thinking';
|
|
234
236
|
this.collapseFinishedReasoningFrames(true);
|
|
235
237
|
super.resetTurn();
|
|
236
238
|
}
|
|
@@ -274,30 +276,47 @@ export class CodeStreamRenderer extends ChatRenderer {
|
|
|
274
276
|
if (message?.type === 'agent_activity') {
|
|
275
277
|
const rawActivity = safeDisplay(String((message as any).activity || (message as any).message || '')).replace(/\s+/g, ' ').trim();
|
|
276
278
|
if (rawActivity) {
|
|
277
|
-
|
|
279
|
+
const normalizedActivity = stripTrailingEllipsisText(rawActivity);
|
|
280
|
+
this.currentActivity = normalizedActivity;
|
|
281
|
+
const isRespondingPhase = /^responding\b/i.test(normalizedActivity);
|
|
278
282
|
if (this._activeReasoning && this.lastReasoning) {
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
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
|
+
}
|
|
285
302
|
if (selfStatus.quietStatus) {
|
|
286
303
|
selfStatus.currentStatus = rawActivity;
|
|
287
304
|
selfStatus.onStatusChange?.(rawActivity);
|
|
288
305
|
}
|
|
289
306
|
return true;
|
|
290
307
|
}
|
|
291
|
-
const handled = super.handle({
|
|
292
|
-
...message,
|
|
293
|
-
activity: rawActivity,
|
|
294
|
-
message: rawActivity
|
|
295
|
-
});
|
|
296
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.
|
|
297
311
|
selfStatus.currentStatus = rawActivity;
|
|
298
312
|
selfStatus.onStatusChange?.(rawActivity);
|
|
313
|
+
return true;
|
|
299
314
|
}
|
|
300
|
-
return
|
|
315
|
+
return super.handle({
|
|
316
|
+
...message,
|
|
317
|
+
activity: rawActivity,
|
|
318
|
+
message: rawActivity
|
|
319
|
+
});
|
|
301
320
|
}
|
|
302
321
|
}
|
|
303
322
|
|
|
@@ -319,6 +338,7 @@ export class CodeStreamRenderer extends ChatRenderer {
|
|
|
319
338
|
activity = 'planning';
|
|
320
339
|
}
|
|
321
340
|
this.currentActivity = activity;
|
|
341
|
+
this.lastReasoningActivity = activity;
|
|
322
342
|
if (selfStatus.quietStatus) {
|
|
323
343
|
const statusLabel = `${activity.charAt(0).toUpperCase() + activity.slice(1)}…`;
|
|
324
344
|
selfStatus.currentStatus = statusLabel;
|
|
@@ -360,9 +380,14 @@ export class CodeStreamRenderer extends ChatRenderer {
|
|
|
360
380
|
return true;
|
|
361
381
|
}
|
|
362
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;
|
|
363
388
|
const handled = super.handle({
|
|
364
389
|
...message,
|
|
365
|
-
activity:
|
|
390
|
+
activity: reasonActivity
|
|
366
391
|
});
|
|
367
392
|
if (message.streaming === false) {
|
|
368
393
|
this.lastReasoning = '';
|
|
@@ -388,7 +413,7 @@ export class CodeStreamRenderer extends ChatRenderer {
|
|
|
388
413
|
super.onAgentReasoning({
|
|
389
414
|
content: this.lastReasoning,
|
|
390
415
|
streaming: false,
|
|
391
|
-
activity: this.currentActivity
|
|
416
|
+
activity: this.lastReasoningActivity || this.currentActivity
|
|
392
417
|
});
|
|
393
418
|
}
|
|
394
419
|
this._activeReasoning = false;
|
|
@@ -143,9 +143,22 @@ export function handlePromptEscape(prompt, formatInterruptedRow) {
|
|
|
143
143
|
prompt.scheduleDraw();
|
|
144
144
|
return;
|
|
145
145
|
}
|
|
146
|
-
if (prompt.usageCard) {
|
|
147
|
-
prompt.
|
|
148
|
-
|
|
146
|
+
if (prompt.usageCard || prompt.usageCardLoading) {
|
|
147
|
+
if (typeof prompt.closeUsageCard === 'function')
|
|
148
|
+
prompt.closeUsageCard();
|
|
149
|
+
else {
|
|
150
|
+
prompt.usageCard = null;
|
|
151
|
+
prompt.scheduleDraw();
|
|
152
|
+
}
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
if (prompt.statusCard !== null && prompt.statusCard !== undefined) {
|
|
156
|
+
if (typeof prompt.closeStatusCard === 'function')
|
|
157
|
+
prompt.closeStatusCard();
|
|
158
|
+
else {
|
|
159
|
+
prompt.statusCard = null;
|
|
160
|
+
prompt.scheduleDraw();
|
|
161
|
+
}
|
|
149
162
|
return;
|
|
150
163
|
}
|
|
151
164
|
if (prompt.completion) {
|
|
@@ -193,9 +193,20 @@ export function handlePromptEscape(
|
|
|
193
193
|
prompt.scheduleDraw();
|
|
194
194
|
return;
|
|
195
195
|
}
|
|
196
|
-
if ((prompt as any).usageCard) {
|
|
197
|
-
(prompt as any).
|
|
198
|
-
|
|
196
|
+
if ((prompt as any).usageCard || (prompt as any).usageCardLoading) {
|
|
197
|
+
if (typeof (prompt as any).closeUsageCard === 'function') (prompt as any).closeUsageCard();
|
|
198
|
+
else {
|
|
199
|
+
(prompt as any).usageCard = null;
|
|
200
|
+
prompt.scheduleDraw();
|
|
201
|
+
}
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
if ((prompt as any).statusCard !== null && (prompt as any).statusCard !== undefined) {
|
|
205
|
+
if (typeof (prompt as any).closeStatusCard === 'function') (prompt as any).closeStatusCard();
|
|
206
|
+
else {
|
|
207
|
+
(prompt as any).statusCard = null;
|
|
208
|
+
prompt.scheduleDraw();
|
|
209
|
+
}
|
|
199
210
|
return;
|
|
200
211
|
}
|
|
201
212
|
if (prompt.completion) {
|
package/src/tui/keys.js
CHANGED
|
@@ -479,7 +479,9 @@ function partialSuffixLength(text, marker) {
|
|
|
479
479
|
* There is no mode that reports the wheel alone. UX-02.
|
|
480
480
|
*/
|
|
481
481
|
export function mouseTracking(enabled) {
|
|
482
|
-
|
|
482
|
+
// Select SGR encoding before enabling reporting. Disable reporting before
|
|
483
|
+
// tearing down its encoding so no event can arrive as legacy X10 bytes.
|
|
484
|
+
return enabled ? '\x1b[?1006h\x1b[?1000h' : '\x1b[?1000l\x1b[?1006l';
|
|
483
485
|
}
|
|
484
486
|
|
|
485
487
|
/** Turn bracketed paste on/off. Paired with the editor's lifecycle. */
|
package/src/tui/prompt.js
CHANGED
|
@@ -29,7 +29,8 @@ import { composerGeometry } from './composerGeometry.js';
|
|
|
29
29
|
import { visibleWidth, truncate, wrapBlock, shortenHome, safeDisplay, stripAnsi } from './text.js';
|
|
30
30
|
import { pickExample, fitHints } from './banner.js';
|
|
31
31
|
import { panelRows } from './overlay.js';
|
|
32
|
-
import { renderUsageCardRows, collectUsageCardData } from './usageCard.js';
|
|
32
|
+
import { renderUsageCardRows, renderStatusCardRows, collectUsageCardData } from './usageCard.js';
|
|
33
|
+
import { buildStatusText } from '../reporting.js';
|
|
33
34
|
import { commandPalette, skillPicker, ApprovalLayer, DecisionLayer, ConfirmLayer, HomeLayer, TextLayer } from './dialogs.js';
|
|
34
35
|
import { describeTool } from './toolDisplay.js';
|
|
35
36
|
import { readClipboardSync, writeClipboardSync } from './clipboardSync.js';
|
|
@@ -135,6 +136,11 @@ export class ChatPrompt {
|
|
|
135
136
|
this.exitHook = null;
|
|
136
137
|
this.drawnRows = 0;
|
|
137
138
|
this.usageCard = null;
|
|
139
|
+
this.usageCardLoading = false;
|
|
140
|
+
this.statusCard = null;
|
|
141
|
+
this.statusCardUsage = null;
|
|
142
|
+
this.infoPanelVersion = 0;
|
|
143
|
+
this.usageRefreshPending = false;
|
|
138
144
|
|
|
139
145
|
// Which row of the drawn block the caret is parked on.
|
|
140
146
|
//
|
|
@@ -542,6 +548,10 @@ export class ChatPrompt {
|
|
|
542
548
|
this.tickTimer = setInterval(() => {
|
|
543
549
|
this.tick++;
|
|
544
550
|
if (this.busy) this.scheduleDraw();
|
|
551
|
+
// Keep the pinned usage/status view current without disk reads every 125 ms.
|
|
552
|
+
if (this.busy && (this.usageCard || this.statusCard !== null) && this.tick % 32 === 0) {
|
|
553
|
+
this.refreshPinnedPanels();
|
|
554
|
+
}
|
|
545
555
|
}, 125);
|
|
546
556
|
if (this.tickTimer.unref) this.tickTimer.unref();
|
|
547
557
|
}
|
|
@@ -667,16 +677,31 @@ export class ChatPrompt {
|
|
|
667
677
|
}));
|
|
668
678
|
}
|
|
669
679
|
|
|
670
|
-
/**
|
|
680
|
+
/** Usage and Status are non-modal panels: ordinary chat must not close them. */
|
|
671
681
|
async toggleUsageCard(loop = null) {
|
|
672
|
-
if (this.usageCard) {
|
|
673
|
-
this.
|
|
682
|
+
if (this.usageCard || this.usageCardLoading) {
|
|
683
|
+
this.closeUsageCard();
|
|
684
|
+
return false;
|
|
685
|
+
}
|
|
686
|
+
const version = ++this.infoPanelVersion;
|
|
687
|
+
this.statusCard = null;
|
|
688
|
+
this.statusCardUsage = null;
|
|
689
|
+
this.usageCardLoading = true;
|
|
690
|
+
try {
|
|
691
|
+
const data = await collectUsageCardData(loop || this.messageActionLoop);
|
|
692
|
+
if (version !== this.infoPanelVersion || !this.usageCardLoading) return false;
|
|
693
|
+
this.usageCard = data;
|
|
694
|
+
this.usageCardLoading = false;
|
|
674
695
|
this.scheduleDraw();
|
|
696
|
+
return true;
|
|
697
|
+
} catch (error) {
|
|
698
|
+
if (version === this.infoPanelVersion) {
|
|
699
|
+
this.usageCardLoading = false;
|
|
700
|
+
this.notice = this.sanitizeSingleLine(error instanceof Error ? error.message : String(error));
|
|
701
|
+
this.scheduleDraw();
|
|
702
|
+
}
|
|
675
703
|
return false;
|
|
676
704
|
}
|
|
677
|
-
this.usageCard = await collectUsageCardData(loop || this.messageActionLoop);
|
|
678
|
-
this.scheduleDraw();
|
|
679
|
-
return true;
|
|
680
705
|
}
|
|
681
706
|
|
|
682
707
|
showUsageCard(loop = null) {
|
|
@@ -684,12 +709,84 @@ export class ChatPrompt {
|
|
|
684
709
|
}
|
|
685
710
|
|
|
686
711
|
closeUsageCard() {
|
|
687
|
-
if (this.usageCard)
|
|
688
|
-
|
|
712
|
+
if (!this.usageCard && !this.usageCardLoading) return false;
|
|
713
|
+
++this.infoPanelVersion; // Invalidate an in-flight open or refresh.
|
|
714
|
+
this.usageCard = null;
|
|
715
|
+
this.usageCardLoading = false;
|
|
716
|
+
this.scheduleDraw();
|
|
717
|
+
return true;
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
async refreshUsageCard(loop = null) {
|
|
721
|
+
if (!this.usageCard || this.usageRefreshPending) return false;
|
|
722
|
+
const version = this.infoPanelVersion;
|
|
723
|
+
this.usageRefreshPending = true;
|
|
724
|
+
try {
|
|
725
|
+
const data = await collectUsageCardData(loop || this.messageActionLoop);
|
|
726
|
+
if (version !== this.infoPanelVersion || !this.usageCard) return false;
|
|
727
|
+
this.usageCard = data;
|
|
689
728
|
this.scheduleDraw();
|
|
690
729
|
return true;
|
|
730
|
+
} catch {
|
|
731
|
+
// A transient ledger read failure must not close an already visible panel.
|
|
732
|
+
return false;
|
|
733
|
+
} finally {
|
|
734
|
+
this.usageRefreshPending = false;
|
|
691
735
|
}
|
|
692
|
-
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
toggleStatusCard(loop = null) {
|
|
739
|
+
if (this.statusCard !== null) {
|
|
740
|
+
this.closeStatusCard();
|
|
741
|
+
return false;
|
|
742
|
+
}
|
|
743
|
+
const targetLoop = loop || this.messageActionLoop;
|
|
744
|
+
++this.infoPanelVersion; // A pending usage read must not reopen a replaced panel.
|
|
745
|
+
this.usageCard = null;
|
|
746
|
+
this.usageCardLoading = false;
|
|
747
|
+
this.statusCardUsage = null;
|
|
748
|
+
this.statusCard = buildStatusText({ loop: targetLoop });
|
|
749
|
+
this.scheduleDraw();
|
|
750
|
+
void this.refreshStatusCardMeta(targetLoop);
|
|
751
|
+
return true;
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
closeStatusCard() {
|
|
755
|
+
if (this.statusCard === null) return false;
|
|
756
|
+
++this.infoPanelVersion;
|
|
757
|
+
this.statusCard = null;
|
|
758
|
+
this.statusCardUsage = null;
|
|
759
|
+
this.scheduleDraw();
|
|
760
|
+
return true;
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
async refreshStatusCardMeta(loop = null) {
|
|
764
|
+
if (this.statusCard === null) return false;
|
|
765
|
+
const version = this.infoPanelVersion;
|
|
766
|
+
try {
|
|
767
|
+
const data = await collectUsageCardData(loop || this.messageActionLoop);
|
|
768
|
+
if (version !== this.infoPanelVersion || this.statusCard === null) return false;
|
|
769
|
+
this.statusCardUsage = data;
|
|
770
|
+
this.scheduleDraw();
|
|
771
|
+
return true;
|
|
772
|
+
} catch {
|
|
773
|
+
return false;
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
refreshPinnedPanels(loop = null) {
|
|
778
|
+
const targetLoop = loop || this.messageActionLoop;
|
|
779
|
+
if (this.usageCard) void this.refreshUsageCard(targetLoop);
|
|
780
|
+
if (this.statusCard !== null) {
|
|
781
|
+
this.statusCard = buildStatusText({ loop: targetLoop });
|
|
782
|
+
this.scheduleDraw();
|
|
783
|
+
void this.refreshStatusCardMeta(targetLoop);
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
statusCardRows(width) {
|
|
788
|
+
if (this.statusCard === null) return [];
|
|
789
|
+
return renderStatusCardRows(this.statusCard, this.statusCardUsage, width);
|
|
693
790
|
}
|
|
694
791
|
|
|
695
792
|
/**
|
|
@@ -877,6 +974,11 @@ export class ChatPrompt {
|
|
|
877
974
|
this.busy = busy;
|
|
878
975
|
resetTurnInterruptState(this, busy);
|
|
879
976
|
if (busy) this.startTick(); else this.stopTick();
|
|
977
|
+
if (!busy && this.usageCard) void this.refreshUsageCard();
|
|
978
|
+
if (this.statusCard !== null) {
|
|
979
|
+
this.statusCard = buildStatusText({ loop: this.messageActionLoop });
|
|
980
|
+
if (!busy) void this.refreshStatusCardMeta(this.messageActionLoop);
|
|
981
|
+
}
|
|
880
982
|
if (this.surface?.stage) this.surface.stage.invalidate();
|
|
881
983
|
this.draw();
|
|
882
984
|
}
|
|
@@ -897,15 +999,18 @@ export class ChatPrompt {
|
|
|
897
999
|
this.history.add(text);
|
|
898
1000
|
this.editor.clear();
|
|
899
1001
|
this.completion = null;
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
}
|
|
903
|
-
|
|
1002
|
+
// Do not dismiss a pinned information panel on any chat submission,
|
|
1003
|
+
// queued prompt, or agent run. Only Esc or the same command closes it.
|
|
904
1004
|
// Instant slash command shortcuts that operate directly on the prompt surface
|
|
905
|
-
if (text === '/usage'
|
|
1005
|
+
if ((text.trim().toLowerCase() === '/usage' || text.trim().toLowerCase() === '/cost')
|
|
1006
|
+
&& typeof this.toggleUsageCard === 'function') {
|
|
906
1007
|
void this.toggleUsageCard();
|
|
907
1008
|
return;
|
|
908
1009
|
}
|
|
1010
|
+
if (text.trim().toLowerCase() === '/status' && typeof this.toggleStatusCard === 'function') {
|
|
1011
|
+
this.toggleStatusCard();
|
|
1012
|
+
return;
|
|
1013
|
+
}
|
|
909
1014
|
|
|
910
1015
|
if (text === '/observer' || text === '/observer status') {
|
|
911
1016
|
import('./observerPicker.js').then(({ runInteractiveObserverPicker }) => {
|
|
@@ -1194,6 +1299,30 @@ export class ChatPrompt {
|
|
|
1194
1299
|
}
|
|
1195
1300
|
if (key.name === 'wheel') {
|
|
1196
1301
|
if (!viewport || !key.wheel) return true;
|
|
1302
|
+
// The reference timeline popover is itself scrollable when a dot
|
|
1303
|
+
// represents more turns than can fit. Wheel input over the card must
|
|
1304
|
+
// not move the chat viewport behind it.
|
|
1305
|
+
const layout = this.surface?.turnRailLayout;
|
|
1306
|
+
const card = layout?.cardRect;
|
|
1307
|
+
const pointerX = key.wheel.x;
|
|
1308
|
+
const pointerY = key.wheel.y;
|
|
1309
|
+
const relativeY = pointerY - (Number.isFinite(layout?.stageTop) ? layout.stageTop : 0);
|
|
1310
|
+
if (card && Array.isArray(card.groupTurns) &&
|
|
1311
|
+
Number.isFinite(pointerX) && Number.isFinite(pointerY) &&
|
|
1312
|
+
pointerX >= card.x && pointerX < card.x + card.width &&
|
|
1313
|
+
relativeY >= card.y && relativeY < card.y + card.height &&
|
|
1314
|
+
(key.wheel.direction === 'up' || key.wheel.direction === 'down')) {
|
|
1315
|
+
const previous = Number.isFinite(this.surface.turnRailCardOffset)
|
|
1316
|
+
? this.surface.turnRailCardOffset : 0;
|
|
1317
|
+
const maximum = Number.isFinite(card.maxOffset) ? Math.max(0, card.maxOffset) : 0;
|
|
1318
|
+
const change = key.wheel.direction === 'up' ? -1 : 1;
|
|
1319
|
+
const current = Math.max(0, Math.min(maximum, previous + change));
|
|
1320
|
+
if (current !== previous) {
|
|
1321
|
+
this.surface.turnRailCardOffset = current;
|
|
1322
|
+
this.scheduleDraw();
|
|
1323
|
+
}
|
|
1324
|
+
return true;
|
|
1325
|
+
}
|
|
1197
1326
|
if (this.renderer?.scrollCodePanel?.(key, this.surface)) {
|
|
1198
1327
|
if (typeof this.scheduleDraw === 'function') this.scheduleDraw(); else this.draw();
|
|
1199
1328
|
return true;
|
|
@@ -1894,7 +2023,8 @@ export class ChatPrompt {
|
|
|
1894
2023
|
punctuate: false
|
|
1895
2024
|
});
|
|
1896
2025
|
|
|
1897
|
-
const usageCardRows = this.usageCard ? renderUsageCardRows(this.usageCard,
|
|
2026
|
+
const usageCardRows = this.usageCard ? renderUsageCardRows(this.usageCard, boxWidth)
|
|
2027
|
+
: this.statusCard !== null ? this.statusCardRows(boxWidth) : [];
|
|
1898
2028
|
const planRows = this.planRows(width);
|
|
1899
2029
|
const pickerRows = this.completion ? this.pickerRows(width) : [];
|
|
1900
2030
|
this.pickerLayout = this.completion ? {
|
|
@@ -176,8 +176,8 @@ export function handleScrollbarMouse(key, viewport, surface, host) {
|
|
|
176
176
|
if (!hasRail)
|
|
177
177
|
return false;
|
|
178
178
|
const contentW = Math.max(20, mainW - 3);
|
|
179
|
-
// Rail
|
|
180
|
-
const isRailColumn = mouseX >= Math.max(contentW, mainW - 3) && mouseX
|
|
179
|
+
// Rail is inside the conversation; the sidebar starts at mainW and must not trigger scrolling
|
|
180
|
+
const isRailColumn = mouseX >= Math.max(contentW, mainW - 3) && mouseX < mainW;
|
|
181
181
|
if (isRailColumn) {
|
|
182
182
|
surface.activeTurnIndex = null;
|
|
183
183
|
surface.hoveredTurnIndex = null;
|
|
@@ -290,8 +290,8 @@ export function handleScrollbarMouse(
|
|
|
290
290
|
if (!hasRail) return false;
|
|
291
291
|
const contentW = Math.max(20, mainW - 3);
|
|
292
292
|
|
|
293
|
-
// Rail
|
|
294
|
-
const isRailColumn = mouseX >= Math.max(contentW, mainW - 3) && mouseX
|
|
293
|
+
// Rail is inside the conversation; the sidebar starts at mainW and must not trigger scrolling
|
|
294
|
+
const isRailColumn = mouseX >= Math.max(contentW, mainW - 3) && mouseX < mainW;
|
|
295
295
|
|
|
296
296
|
if (isRailColumn) {
|
|
297
297
|
(surface as any).activeTurnIndex = null;
|