@causyne/agent 1.20.112 → 1.20.116
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 +72 -37
- package/src/agentLoop.ts +70 -38
- package/src/browser/browserRuntime.js +13 -8
- package/src/browser/browserRuntime.ts +16 -8
- package/src/browser/causyneBrowser.js +7 -2
- package/src/browser/causyneBrowser.ts +8 -2
- 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/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/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/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/timeMachine.js +43 -22
- package/src/timeMachine.ts +44 -22
- package/src/tool-scripts/desktop_act.applescript +1 -0
- package/src/tools/computerUse.js +23 -10
- package/src/tools/computerUse.ts +19 -8
- package/src/tools/desktopAct.js +12 -1
- 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 +135 -83
- 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 +57 -26
- package/src/tui/codeProgress.ts +57 -25
- package/src/tui/codeStreamRenderer.js +59 -14
- package/src/tui/codeStreamRenderer.ts +58 -14
- 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 +33 -17
- 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 +162 -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 +120 -49
- 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 +156 -67
- package/src/tui/turnRail.ts +155 -58
- package/src/tui/usageCard.js +80 -45
- package/src/tui/usageCard.ts +81 -46
- 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
|
@@ -6,7 +6,7 @@ import { writeClipboardSync } from './clipboardSync.js';
|
|
|
6
6
|
import { registerStageConsoleGuard, setTransientNotice } from './consoleGuard.js';
|
|
7
7
|
import { detectLinkAtPoint, openDetectedLink } from './smartLinkClick.js';
|
|
8
8
|
import { sidebarVisible, sessionMainWidth } from './sessionSidebar.js';
|
|
9
|
-
import { stripAnsi, truncate, padEnd, visibleWidth } from './text.js';
|
|
9
|
+
import { safeDisplay, stripAnsi, truncate, padEnd, visibleWidth } from './text.js';
|
|
10
10
|
import { Layer } from './overlay.js';
|
|
11
11
|
import {} from './messageActionPlacement.js';
|
|
12
12
|
// @ts-expect-error Legacy theme has no declaration yet.
|
|
@@ -31,52 +31,78 @@ export class MessageActionsLayer extends Layer {
|
|
|
31
31
|
this.list = {
|
|
32
32
|
filtered: items,
|
|
33
33
|
selected: 0,
|
|
34
|
-
moveTo: (index) => {
|
|
34
|
+
moveTo: (index) => {
|
|
35
|
+
if (!Number.isFinite(index) || items.length === 0)
|
|
36
|
+
return;
|
|
37
|
+
this.list.selected = Math.max(0, Math.min(items.length - 1, Math.floor(index)));
|
|
38
|
+
}
|
|
35
39
|
};
|
|
36
40
|
}
|
|
41
|
+
cleanText(value) {
|
|
42
|
+
return safeDisplay(typeof value === 'string' ? value : String(value ?? ''))
|
|
43
|
+
.replace(/[\r\n]+/g, ' ')
|
|
44
|
+
.trim();
|
|
45
|
+
}
|
|
37
46
|
preferredHeight() { return this.items.length + 2; }
|
|
38
47
|
preferredWidth(maxWidth) {
|
|
48
|
+
const safeMax = Number.isFinite(maxWidth)
|
|
49
|
+
? Math.floor(maxWidth)
|
|
50
|
+
: maxWidth === Number.POSITIVE_INFINITY
|
|
51
|
+
? Number.POSITIVE_INFINITY
|
|
52
|
+
: 64;
|
|
39
53
|
const maxItemContent = this.items.reduce((max, item) => {
|
|
40
|
-
const labelW = visibleWidth(`▸ ${item.label}`);
|
|
41
|
-
const
|
|
54
|
+
const labelW = visibleWidth(`▸ ${this.cleanText(item.label)}`);
|
|
55
|
+
const cleanDesc = item.description ? this.cleanText(item.description) : '';
|
|
56
|
+
const descW = cleanDesc ? visibleWidth(cleanDesc) + 4 : 0;
|
|
42
57
|
return Math.max(max, labelW + descW);
|
|
43
58
|
}, 0);
|
|
44
59
|
const wanted = Math.max(48, maxItemContent + 6);
|
|
45
|
-
|
|
60
|
+
const minWidth = safeMax < 36 ? Math.max(1, safeMax) : 36;
|
|
61
|
+
return Math.max(minWidth, Math.min(safeMax, wanted));
|
|
46
62
|
}
|
|
47
63
|
body(width) {
|
|
48
|
-
const
|
|
49
|
-
|
|
64
|
+
const safeWidth = Number.isFinite(width) ? Math.max(1, Math.floor(width)) : 60;
|
|
65
|
+
const cleanItems = this.items.map((item) => ({
|
|
66
|
+
label: this.cleanText(item.label),
|
|
67
|
+
description: item.description ? this.cleanText(item.description) : ''
|
|
68
|
+
}));
|
|
69
|
+
const labelWidth = cleanItems.reduce((max, item) => Math.max(max, visibleWidth(`▸ ${item.label}`)), 0);
|
|
70
|
+
return cleanItems.map((item, index) => {
|
|
50
71
|
const selected = index === this.list.selected;
|
|
51
72
|
const rawLabel = `${selected ? '▸' : ' '} ${item.label}`;
|
|
52
73
|
const pad = ' '.repeat(Math.max(0, labelWidth - visibleWidth(rawLabel)));
|
|
53
74
|
const styledLabel = selected
|
|
54
75
|
? `${paint('accent', bold(rawLabel))}${pad}`
|
|
55
76
|
: `${paint('ink', rawLabel)}${pad}`;
|
|
56
|
-
const descBudget = Math.max(0,
|
|
77
|
+
const descBudget = Math.max(0, safeWidth - labelWidth - 2);
|
|
57
78
|
const description = item.description && descBudget > 3
|
|
58
79
|
? ` ${dim(truncate(item.description, descBudget, '…'))}`
|
|
59
80
|
: '';
|
|
60
|
-
return truncate(`${styledLabel}${description}`,
|
|
81
|
+
return truncate(`${styledLabel}${description}`, safeWidth, '…');
|
|
61
82
|
});
|
|
62
83
|
}
|
|
63
84
|
key(event) {
|
|
64
|
-
if (event
|
|
85
|
+
if (!event || typeof event !== 'object')
|
|
86
|
+
return 'handled';
|
|
87
|
+
const keyName = typeof event.name === 'string' ? event.name : '';
|
|
88
|
+
if (keyName === 'escape') {
|
|
65
89
|
this.settled = true;
|
|
66
90
|
this.onPick(null);
|
|
67
91
|
return 'close';
|
|
68
92
|
}
|
|
69
|
-
if (
|
|
70
|
-
|
|
71
|
-
|
|
93
|
+
if (keyName === 'up' || keyName === 'down') {
|
|
94
|
+
if (this.items.length > 0) {
|
|
95
|
+
const delta = keyName === 'up' ? -1 : 1;
|
|
96
|
+
this.list.moveTo((this.list.selected + delta + this.items.length) % this.items.length);
|
|
97
|
+
}
|
|
72
98
|
return 'handled';
|
|
73
99
|
}
|
|
74
|
-
if (
|
|
100
|
+
if (keyName === 'enter' || keyName === 'return') {
|
|
75
101
|
this.settled = true;
|
|
76
102
|
this.onPick(this.items[this.list.selected] ?? null);
|
|
77
103
|
return 'close';
|
|
78
104
|
}
|
|
79
|
-
if (!event.ctrl && !event.alt && (
|
|
105
|
+
if (!event.ctrl && !event.alt && keyName && (keyName.length === 1 || keyName === 'space' || keyName === 'backspace')) {
|
|
80
106
|
this.settled = true;
|
|
81
107
|
this.onPick(null);
|
|
82
108
|
return 'dismiss';
|
|
@@ -95,8 +121,8 @@ export function isMouseMotion(sequence) {
|
|
|
95
121
|
return Number.isFinite(code) && (code & 32) !== 0;
|
|
96
122
|
}
|
|
97
123
|
export function handleMessageMouse(host, loop, event) {
|
|
98
|
-
const mouse = event.mouse;
|
|
99
|
-
const surface = host.surface;
|
|
124
|
+
const mouse = event && typeof event === 'object' ? event.mouse : undefined;
|
|
125
|
+
const surface = host && typeof host === 'object' ? host.surface : null;
|
|
100
126
|
if (!mouse || !surface)
|
|
101
127
|
return false;
|
|
102
128
|
const marker = messageAt(surface, mouse);
|
|
@@ -149,31 +175,48 @@ export function handleMessageMouse(host, loop, event) {
|
|
|
149
175
|
}
|
|
150
176
|
const isMessage = (marker) => (marker.kind === 'user' || marker.kind === 'assistant')
|
|
151
177
|
&& typeof marker.meta?.messageText === 'string';
|
|
178
|
+
const positiveDim = (value, fallback) => {
|
|
179
|
+
const n = Number(value);
|
|
180
|
+
return Number.isFinite(n) && n > 0 ? Math.floor(n) : fallback;
|
|
181
|
+
};
|
|
152
182
|
/** Resolve screen coordinates against the painted viewport to find any frame marker. */
|
|
153
183
|
export function markerAt(surface, point) {
|
|
154
|
-
if (!surface
|
|
184
|
+
if (!surface
|
|
185
|
+
|| surface.stage?.reserved === false
|
|
186
|
+
|| !point
|
|
187
|
+
|| typeof point !== 'object'
|
|
188
|
+
|| !Number.isFinite(point.x)
|
|
189
|
+
|| !Number.isFinite(point.y)) {
|
|
155
190
|
return null;
|
|
156
|
-
|
|
157
|
-
const
|
|
191
|
+
}
|
|
192
|
+
const px = Math.floor(point.x);
|
|
193
|
+
const py = Math.floor(point.y);
|
|
194
|
+
const rawViewW = surface.viewport?.viewWidth;
|
|
195
|
+
const surfWidth = positiveDim(surface.width, positiveDim(rawViewW, positiveDim(surface.viewport?.width, 80)));
|
|
196
|
+
const mainWidth = sidebarVisible(surfWidth, false, surface.env)
|
|
197
|
+
? sessionMainWidth(surfWidth, false, surface.env)
|
|
198
|
+
: surfWidth;
|
|
158
199
|
const leftGutter = (surface.turnRailLayout?.turns?.length ?? 0) > 0 ? 3 : 0;
|
|
159
|
-
const viewWidth =
|
|
160
|
-
if (
|
|
200
|
+
const viewWidth = positiveDim(rawViewW, positiveDim(surface.viewport?.width, surfWidth));
|
|
201
|
+
if (px < leftGutter || px >= Math.min(mainWidth, viewWidth + leftGutter))
|
|
161
202
|
return null;
|
|
162
|
-
const stageHeight = surface.stage?.height
|
|
163
|
-
const
|
|
164
|
-
const
|
|
165
|
-
const
|
|
203
|
+
const stageHeight = surface.stage?.height === 0 ? 0 : positiveDim(surface.stage?.height, 24);
|
|
204
|
+
const outRows = positiveDim(surface.out?.rows, stageHeight);
|
|
205
|
+
const top = Math.max(0, outRows - stageHeight);
|
|
206
|
+
const viewRow = py - top;
|
|
207
|
+
const viewHeight = positiveDim(surface.viewport?.viewHeight, positiveDim(surface.viewport?.height, stageHeight));
|
|
166
208
|
if (viewRow < 0 || viewRow >= viewHeight)
|
|
167
209
|
return null;
|
|
168
210
|
const transcript = surface.transcript || surface.renderer?.transcript;
|
|
169
211
|
if (!transcript)
|
|
170
212
|
return null;
|
|
171
213
|
const flat = transcript.flatten(viewWidth);
|
|
172
|
-
const
|
|
214
|
+
const scrollTop = Number.isFinite(surface.viewport?.scrollTop) ? Math.max(0, Math.floor(surface.viewport.scrollTop)) : 0;
|
|
215
|
+
const visible = Math.max(0, Math.min(viewHeight, flat.rows.length - scrollTop));
|
|
173
216
|
const padding = viewHeight - visible;
|
|
174
217
|
if (viewRow < padding)
|
|
175
218
|
return null;
|
|
176
|
-
const row =
|
|
219
|
+
const row = scrollTop + viewRow - padding;
|
|
177
220
|
for (let i = flat.markers.length - 1; i >= 0; i--) {
|
|
178
221
|
const marker = flat.markers[i];
|
|
179
222
|
if (!marker || marker.row > row)
|
|
@@ -193,14 +236,18 @@ export function messageAt(surface, point) {
|
|
|
193
236
|
/** Highlight only the visible non-empty rows of the hovered message, without altering transcript data. */
|
|
194
237
|
export function markHoveredMessage(rows, surface, contentWidth) {
|
|
195
238
|
registerStageConsoleGuard(surface);
|
|
239
|
+
if (!Array.isArray(rows) || rows.length === 0 || !surface?.transcript?.flatten)
|
|
240
|
+
return;
|
|
241
|
+
const safeContentWidth = Number.isFinite(contentWidth) && contentWidth > 0 ? Math.floor(contentWidth) : 1;
|
|
196
242
|
const id = surface.hoveredMessageFrameId;
|
|
197
|
-
if (
|
|
243
|
+
if (id === null || id === undefined)
|
|
198
244
|
return;
|
|
199
|
-
const flat = surface.transcript.flatten(
|
|
245
|
+
const flat = surface.transcript.flatten(safeContentWidth);
|
|
200
246
|
const marker = flat.markers.find(item => item.id === id);
|
|
201
247
|
if (!marker || !isMessage(marker))
|
|
202
248
|
return;
|
|
203
|
-
const
|
|
249
|
+
const scrollTop = Number.isFinite(surface.viewport?.scrollTop) ? Math.max(0, Math.floor(surface.viewport.scrollTop)) : 0;
|
|
250
|
+
const visible = Math.max(0, Math.min(rows.length, flat.rows.length - scrollTop));
|
|
204
251
|
const padding = rows.length - visible;
|
|
205
252
|
const next = flat.markers[flat.markers.indexOf(marker) + 1];
|
|
206
253
|
const rawStart = marker.row;
|
|
@@ -217,10 +264,10 @@ export function markHoveredMessage(rows, surface, contentWidth) {
|
|
|
217
264
|
}
|
|
218
265
|
if (firstContentRow >= rawEnd)
|
|
219
266
|
return;
|
|
220
|
-
const first = Math.max(firstContentRow,
|
|
221
|
-
const last = Math.min(lastContentRow + 1,
|
|
267
|
+
const first = Math.max(firstContentRow, scrollTop);
|
|
268
|
+
const last = Math.min(lastContentRow + 1, scrollTop + visible);
|
|
222
269
|
for (let transcriptRow = first; transcriptRow < last; transcriptRow++) {
|
|
223
|
-
const row = transcriptRow -
|
|
270
|
+
const row = transcriptRow - scrollTop + padding;
|
|
224
271
|
if (row < padding || row >= rows.length)
|
|
225
272
|
continue;
|
|
226
273
|
const existingRow = rows[row] ?? '';
|
|
@@ -240,7 +287,7 @@ export function markHoveredMessage(rows, surface, contentWidth) {
|
|
|
240
287
|
}
|
|
241
288
|
}
|
|
242
289
|
}
|
|
243
|
-
rows[row] = fill('surfaceHi', padEnd(content,
|
|
290
|
+
rows[row] = fill('surfaceHi', padEnd(truncate(content, safeContentWidth, ''), safeContentWidth));
|
|
244
291
|
}
|
|
245
292
|
}
|
|
246
293
|
function messageText(content) {
|
|
@@ -270,6 +317,8 @@ function messagesMatch(persistedContent, shownText) {
|
|
|
270
317
|
}
|
|
271
318
|
/** Match in conversation order; never guess a fork point from visual row alone. */
|
|
272
319
|
export function persistedMessageIndex(marker, markers, messages) {
|
|
320
|
+
if (!marker || !Array.isArray(markers) || !Array.isArray(messages))
|
|
321
|
+
return null;
|
|
273
322
|
let matched = -1;
|
|
274
323
|
for (const shown of markers) {
|
|
275
324
|
if (!isMessage(shown))
|
|
@@ -342,7 +391,11 @@ export function openMessageActions(host, loop, marker, anchorY = null) {
|
|
|
342
391
|
return;
|
|
343
392
|
const sourceId = loop.memoryManager?.sessionId || getActiveSessionId();
|
|
344
393
|
const source = syncInFlightMessagesToSession(loop, sourceId);
|
|
345
|
-
const
|
|
394
|
+
const viewWidth = positiveDim(host.surface?.viewport?.width, 80);
|
|
395
|
+
const flat = host.surface?.transcript?.flatten
|
|
396
|
+
? host.surface.transcript.flatten(viewWidth)
|
|
397
|
+
: null;
|
|
398
|
+
const markers = flat?.markers || [];
|
|
346
399
|
const index = source ? persistedMessageIndex(marker, markers, source.messages) : null;
|
|
347
400
|
const canModifySession = Boolean(source && index !== null);
|
|
348
401
|
const options = [
|
|
@@ -355,17 +408,20 @@ export function openMessageActions(host, loop, marker, anchorY = null) {
|
|
|
355
408
|
: [])
|
|
356
409
|
];
|
|
357
410
|
let messageBounds = null;
|
|
358
|
-
if (
|
|
359
|
-
const flat = host.surface.transcript.flatten(host.surface.viewport.width);
|
|
411
|
+
if (flat && host.surface?.viewport) {
|
|
360
412
|
const mIdx = flat.markers.findIndex(m => m.id === marker.id);
|
|
361
413
|
if (mIdx >= 0) {
|
|
362
414
|
const nextM = flat.markers[mIdx + 1];
|
|
363
|
-
const rawStart =
|
|
415
|
+
const rawStart = flat.markers[mIdx].row;
|
|
364
416
|
const rawEnd = nextM ? nextM.row - 1 : flat.rows.length - 1;
|
|
365
|
-
const
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
const
|
|
417
|
+
const scrollTop = Number.isFinite(host.surface.viewport.scrollTop)
|
|
418
|
+
? Math.max(0, Math.floor(host.surface.viewport.scrollTop))
|
|
419
|
+
: 0;
|
|
420
|
+
const viewHeight = positiveDim(host.surface.viewport.height, 24);
|
|
421
|
+
const visible = Math.max(0, Math.min(viewHeight, flat.rows.length - scrollTop));
|
|
422
|
+
const padding = viewHeight - visible;
|
|
423
|
+
const startRow = rawStart - scrollTop + padding;
|
|
424
|
+
const endRow = rawEnd - scrollTop + padding;
|
|
369
425
|
messageBounds = { startRow, endRow, textLength: text.length };
|
|
370
426
|
}
|
|
371
427
|
}
|
|
@@ -403,6 +459,7 @@ export function openMessageActions(host, loop, marker, anchorY = null) {
|
|
|
403
459
|
loop.taskId = `cli_chat_${Date.now()}`;
|
|
404
460
|
loop.tokenTracker?.reset?.();
|
|
405
461
|
const info = { id: forked.id, title: forked.title, messagesCount: history.length };
|
|
462
|
+
host.surface?.setSessionInfo?.(info);
|
|
406
463
|
host.renderer?.setSessionInfo?.(info);
|
|
407
464
|
host.renderer?.renderSessionHistory?.(history, info);
|
|
408
465
|
host.surface?.viewport?.toBottom?.();
|
|
@@ -431,6 +488,7 @@ export function openMessageActions(host, loop, marker, anchorY = null) {
|
|
|
431
488
|
loop.messages = history;
|
|
432
489
|
loop.taskId = `cli_chat_${Date.now()}`;
|
|
433
490
|
const info = { id: latestSource.id, title: latestSource.title, messagesCount: history.length };
|
|
491
|
+
host.surface?.setSessionInfo?.(info);
|
|
434
492
|
host.renderer?.setSessionInfo?.(info);
|
|
435
493
|
host.renderer?.renderSessionHistory?.(history, info);
|
|
436
494
|
host.surface?.viewport?.toBottom?.();
|
|
@@ -447,12 +505,19 @@ export function openMessageActions(host, loop, marker, anchorY = null) {
|
|
|
447
505
|
}
|
|
448
506
|
/** Mouse selection for the small message menu; other dialogs retain their own input handling. */
|
|
449
507
|
export function handleMessageActionMenuMouse(layer, event) {
|
|
450
|
-
if (!layer.messageActions || !layer.actionLayout || !event.mouse)
|
|
508
|
+
if (!layer || !event || !layer.messageActions || !layer.actionLayout || !event.mouse)
|
|
451
509
|
return null;
|
|
452
510
|
const { x, y, width, count } = layer.actionLayout;
|
|
453
511
|
const { mouse } = event;
|
|
454
|
-
|
|
455
|
-
|
|
512
|
+
if (!Number.isFinite(mouse.x) || !Number.isFinite(mouse.y)
|
|
513
|
+
|| !Number.isFinite(x) || !Number.isFinite(y)
|
|
514
|
+
|| !Number.isFinite(width) || !Number.isFinite(count)) {
|
|
515
|
+
return 'handled';
|
|
516
|
+
}
|
|
517
|
+
const mouseX = Math.floor(mouse.x);
|
|
518
|
+
const mouseY = Math.floor(mouse.y);
|
|
519
|
+
const index = mouseY - (Math.floor(y) + 1); // only the frame precedes the action rows
|
|
520
|
+
if (mouseX < x || mouseX >= x + width || index < 0 || index >= count) {
|
|
456
521
|
return mouse.button === 0 && mouse.pressed ? 'close' : 'handled';
|
|
457
522
|
}
|
|
458
523
|
layer.list?.moveTo(index);
|
|
@@ -12,7 +12,7 @@ import { writeClipboardSync } from './clipboardSync.js';
|
|
|
12
12
|
import { registerStageConsoleGuard, setTransientNotice } from './consoleGuard.js';
|
|
13
13
|
import { detectLinkAtPoint, openDetectedLink } from './smartLinkClick.js';
|
|
14
14
|
import { sidebarVisible, sessionMainWidth } from './sessionSidebar.js';
|
|
15
|
-
import { stripAnsi, truncate, padEnd, visibleWidth } from './text.js';
|
|
15
|
+
import { safeDisplay, stripAnsi, truncate, padEnd, visibleWidth } from './text.js';
|
|
16
16
|
import { Layer } from './overlay.js';
|
|
17
17
|
import { type MessageBounds } from './messageActionPlacement.js';
|
|
18
18
|
// @ts-expect-error Legacy theme has no declaration yet.
|
|
@@ -28,12 +28,14 @@ export interface MessageMarker {
|
|
|
28
28
|
interface MousePoint { x: number; y: number }
|
|
29
29
|
interface MessageSurface {
|
|
30
30
|
width: number;
|
|
31
|
+
env?: { CAUSYNE_SIDEBAR?: string };
|
|
31
32
|
out: { rows?: number };
|
|
32
33
|
stage: { height: number; reserved: boolean };
|
|
33
34
|
viewport: { height: number; width: number; scrollTop: number; toBottom?: () => void };
|
|
34
35
|
transcript: { flatten(width: number): { rows: string[]; markers: MessageMarker[] } };
|
|
35
36
|
hoveredMessageFrameId?: number | null;
|
|
36
37
|
turnRailLayout?: { turns?: unknown[] } | null;
|
|
38
|
+
setSessionInfo?: (info: object) => void;
|
|
37
39
|
}
|
|
38
40
|
|
|
39
41
|
interface MessageHost {
|
|
@@ -77,59 +79,84 @@ export class MessageActionsLayer extends Layer {
|
|
|
77
79
|
this.list = {
|
|
78
80
|
filtered: items,
|
|
79
81
|
selected: 0,
|
|
80
|
-
moveTo: (index: number) => {
|
|
82
|
+
moveTo: (index: number) => {
|
|
83
|
+
if (!Number.isFinite(index) || items.length === 0) return;
|
|
84
|
+
this.list.selected = Math.max(0, Math.min(items.length - 1, Math.floor(index)));
|
|
85
|
+
}
|
|
81
86
|
};
|
|
82
87
|
}
|
|
83
88
|
|
|
89
|
+
private cleanText(value: unknown): string {
|
|
90
|
+
return safeDisplay(typeof value === 'string' ? value : String(value ?? ''))
|
|
91
|
+
.replace(/[\r\n]+/g, ' ')
|
|
92
|
+
.trim();
|
|
93
|
+
}
|
|
94
|
+
|
|
84
95
|
override preferredHeight(): number { return this.items.length + 2; }
|
|
85
96
|
|
|
86
97
|
preferredWidth(maxWidth: number): number {
|
|
98
|
+
const safeMax = Number.isFinite(maxWidth)
|
|
99
|
+
? Math.floor(maxWidth)
|
|
100
|
+
: maxWidth === Number.POSITIVE_INFINITY
|
|
101
|
+
? Number.POSITIVE_INFINITY
|
|
102
|
+
: 64;
|
|
87
103
|
const maxItemContent = this.items.reduce((max, item) => {
|
|
88
|
-
const labelW = visibleWidth(`▸ ${item.label}`);
|
|
89
|
-
const
|
|
104
|
+
const labelW = visibleWidth(`▸ ${this.cleanText(item.label)}`);
|
|
105
|
+
const cleanDesc = item.description ? this.cleanText(item.description) : '';
|
|
106
|
+
const descW = cleanDesc ? visibleWidth(cleanDesc) + 4 : 0;
|
|
90
107
|
return Math.max(max, labelW + descW);
|
|
91
108
|
}, 0);
|
|
92
109
|
const wanted = Math.max(48, maxItemContent + 6);
|
|
93
|
-
|
|
110
|
+
const minWidth = safeMax < 36 ? Math.max(1, safeMax) : 36;
|
|
111
|
+
return Math.max(minWidth, Math.min(safeMax, wanted));
|
|
94
112
|
}
|
|
95
113
|
|
|
96
114
|
override body(width: number): string[] {
|
|
97
|
-
const
|
|
115
|
+
const safeWidth = Number.isFinite(width) ? Math.max(1, Math.floor(width)) : 60;
|
|
116
|
+
const cleanItems = this.items.map((item) => ({
|
|
117
|
+
label: this.cleanText(item.label),
|
|
118
|
+
description: item.description ? this.cleanText(item.description) : ''
|
|
119
|
+
}));
|
|
120
|
+
const labelWidth = cleanItems.reduce(
|
|
98
121
|
(max, item) => Math.max(max, visibleWidth(`▸ ${item.label}`)),
|
|
99
122
|
0
|
|
100
123
|
);
|
|
101
|
-
return
|
|
124
|
+
return cleanItems.map((item, index) => {
|
|
102
125
|
const selected = index === this.list.selected;
|
|
103
126
|
const rawLabel = `${selected ? '▸' : ' '} ${item.label}`;
|
|
104
127
|
const pad = ' '.repeat(Math.max(0, labelWidth - visibleWidth(rawLabel)));
|
|
105
128
|
const styledLabel = selected
|
|
106
129
|
? `${paint('accent', bold(rawLabel))}${pad}`
|
|
107
130
|
: `${paint('ink', rawLabel)}${pad}`;
|
|
108
|
-
const descBudget = Math.max(0,
|
|
131
|
+
const descBudget = Math.max(0, safeWidth - labelWidth - 2);
|
|
109
132
|
const description = item.description && descBudget > 3
|
|
110
133
|
? ` ${dim(truncate(item.description, descBudget, '…'))}`
|
|
111
134
|
: '';
|
|
112
|
-
return truncate(`${styledLabel}${description}`,
|
|
135
|
+
return truncate(`${styledLabel}${description}`, safeWidth, '…');
|
|
113
136
|
});
|
|
114
137
|
}
|
|
115
138
|
|
|
116
|
-
override key(event: { name
|
|
117
|
-
if (event
|
|
139
|
+
override key(event: { name?: string; ctrl?: boolean; alt?: boolean } | null | undefined): string {
|
|
140
|
+
if (!event || typeof event !== 'object') return 'handled';
|
|
141
|
+
const keyName = typeof event.name === 'string' ? event.name : '';
|
|
142
|
+
if (keyName === 'escape') {
|
|
118
143
|
this.settled = true;
|
|
119
144
|
this.onPick(null);
|
|
120
145
|
return 'close';
|
|
121
146
|
}
|
|
122
|
-
if (
|
|
123
|
-
|
|
124
|
-
|
|
147
|
+
if (keyName === 'up' || keyName === 'down') {
|
|
148
|
+
if (this.items.length > 0) {
|
|
149
|
+
const delta = keyName === 'up' ? -1 : 1;
|
|
150
|
+
this.list.moveTo((this.list.selected + delta + this.items.length) % this.items.length);
|
|
151
|
+
}
|
|
125
152
|
return 'handled';
|
|
126
153
|
}
|
|
127
|
-
if (
|
|
154
|
+
if (keyName === 'enter' || keyName === 'return') {
|
|
128
155
|
this.settled = true;
|
|
129
156
|
this.onPick(this.items[this.list.selected] ?? null);
|
|
130
157
|
return 'close';
|
|
131
158
|
}
|
|
132
|
-
if (!event.ctrl && !event.alt && (
|
|
159
|
+
if (!event.ctrl && !event.alt && keyName && (keyName.length === 1 || keyName === 'space' || keyName === 'backspace')) {
|
|
133
160
|
this.settled = true;
|
|
134
161
|
this.onPick(null);
|
|
135
162
|
return 'dismiss';
|
|
@@ -171,8 +198,8 @@ export function handleMessageMouse(
|
|
|
171
198
|
shift?: boolean;
|
|
172
199
|
}
|
|
173
200
|
): boolean {
|
|
174
|
-
const mouse = event.mouse;
|
|
175
|
-
const surface = host.surface;
|
|
201
|
+
const mouse = event && typeof event === 'object' ? event.mouse : undefined;
|
|
202
|
+
const surface = host && typeof host === 'object' ? host.surface : null;
|
|
176
203
|
if (!mouse || !surface) return false;
|
|
177
204
|
const marker = messageAt(surface, mouse);
|
|
178
205
|
if (surface.hoveredMessageFrameId !== (marker?.id ?? null)) {
|
|
@@ -238,26 +265,47 @@ const isMessage = (marker: MessageMarker): boolean =>
|
|
|
238
265
|
(marker.kind === 'user' || marker.kind === 'assistant')
|
|
239
266
|
&& typeof marker.meta?.messageText === 'string';
|
|
240
267
|
|
|
268
|
+
const positiveDim = (value: unknown, fallback: number): number => {
|
|
269
|
+
const n = Number(value);
|
|
270
|
+
return Number.isFinite(n) && n > 0 ? Math.floor(n) : fallback;
|
|
271
|
+
};
|
|
272
|
+
|
|
241
273
|
/** Resolve screen coordinates against the painted viewport to find any frame marker. */
|
|
242
274
|
export function markerAt(surface: MessageSurface | null, point: MousePoint): MessageMarker | null {
|
|
243
|
-
if (
|
|
244
|
-
|
|
245
|
-
|
|
275
|
+
if (
|
|
276
|
+
!surface
|
|
277
|
+
|| surface.stage?.reserved === false
|
|
278
|
+
|| !point
|
|
279
|
+
|| typeof point !== 'object'
|
|
280
|
+
|| !Number.isFinite(point.x)
|
|
281
|
+
|| !Number.isFinite(point.y)
|
|
282
|
+
) {
|
|
283
|
+
return null;
|
|
284
|
+
}
|
|
285
|
+
const px = Math.floor(point.x);
|
|
286
|
+
const py = Math.floor(point.y);
|
|
287
|
+
const rawViewW = (surface.viewport as any)?.viewWidth;
|
|
288
|
+
const surfWidth = positiveDim(surface.width, positiveDim(rawViewW, positiveDim(surface.viewport?.width, 80)));
|
|
289
|
+
const mainWidth = sidebarVisible(surfWidth, false, surface.env)
|
|
290
|
+
? sessionMainWidth(surfWidth, false, surface.env)
|
|
291
|
+
: surfWidth;
|
|
246
292
|
const leftGutter = (surface.turnRailLayout?.turns?.length ?? 0) > 0 ? 3 : 0;
|
|
247
|
-
const viewWidth = (
|
|
248
|
-
if (
|
|
249
|
-
const stageHeight = surface.stage?.height
|
|
250
|
-
const
|
|
251
|
-
const
|
|
252
|
-
const
|
|
293
|
+
const viewWidth = positiveDim(rawViewW, positiveDim(surface.viewport?.width, surfWidth));
|
|
294
|
+
if (px < leftGutter || px >= Math.min(mainWidth, viewWidth + leftGutter)) return null;
|
|
295
|
+
const stageHeight = surface.stage?.height === 0 ? 0 : positiveDim(surface.stage?.height, 24);
|
|
296
|
+
const outRows = positiveDim(surface.out?.rows, stageHeight);
|
|
297
|
+
const top = Math.max(0, outRows - stageHeight);
|
|
298
|
+
const viewRow = py - top;
|
|
299
|
+
const viewHeight = positiveDim((surface.viewport as any)?.viewHeight, positiveDim(surface.viewport?.height, stageHeight));
|
|
253
300
|
if (viewRow < 0 || viewRow >= viewHeight) return null;
|
|
254
301
|
const transcript = surface.transcript || (surface as any).renderer?.transcript;
|
|
255
302
|
if (!transcript) return null;
|
|
256
303
|
const flat = transcript.flatten(viewWidth);
|
|
257
|
-
const
|
|
304
|
+
const scrollTop = Number.isFinite(surface.viewport?.scrollTop) ? Math.max(0, Math.floor(surface.viewport.scrollTop)) : 0;
|
|
305
|
+
const visible = Math.max(0, Math.min(viewHeight, flat.rows.length - scrollTop));
|
|
258
306
|
const padding = viewHeight - visible;
|
|
259
307
|
if (viewRow < padding) return null;
|
|
260
|
-
const row =
|
|
308
|
+
const row = scrollTop + viewRow - padding;
|
|
261
309
|
for (let i = flat.markers.length - 1; i >= 0; i--) {
|
|
262
310
|
const marker = flat.markers[i];
|
|
263
311
|
if (!marker || marker.row > row) continue;
|
|
@@ -279,12 +327,15 @@ export function markHoveredMessage(
|
|
|
279
327
|
rows: string[], surface: MessageSurface, contentWidth: number
|
|
280
328
|
): void {
|
|
281
329
|
registerStageConsoleGuard(surface);
|
|
330
|
+
if (!Array.isArray(rows) || rows.length === 0 || !surface?.transcript?.flatten) return;
|
|
331
|
+
const safeContentWidth = Number.isFinite(contentWidth) && contentWidth > 0 ? Math.floor(contentWidth) : 1;
|
|
282
332
|
const id = surface.hoveredMessageFrameId;
|
|
283
|
-
if (
|
|
284
|
-
const flat = surface.transcript.flatten(
|
|
333
|
+
if (id === null || id === undefined) return;
|
|
334
|
+
const flat = surface.transcript.flatten(safeContentWidth);
|
|
285
335
|
const marker = flat.markers.find(item => item.id === id);
|
|
286
336
|
if (!marker || !isMessage(marker)) return;
|
|
287
|
-
const
|
|
337
|
+
const scrollTop = Number.isFinite(surface.viewport?.scrollTop) ? Math.max(0, Math.floor(surface.viewport.scrollTop)) : 0;
|
|
338
|
+
const visible = Math.max(0, Math.min(rows.length, flat.rows.length - scrollTop));
|
|
288
339
|
const padding = rows.length - visible;
|
|
289
340
|
const next = flat.markers[flat.markers.indexOf(marker) + 1];
|
|
290
341
|
const rawStart = marker.row;
|
|
@@ -302,10 +353,10 @@ export function markHoveredMessage(
|
|
|
302
353
|
}
|
|
303
354
|
if (firstContentRow >= rawEnd) return;
|
|
304
355
|
|
|
305
|
-
const first = Math.max(firstContentRow,
|
|
306
|
-
const last = Math.min(lastContentRow + 1,
|
|
356
|
+
const first = Math.max(firstContentRow, scrollTop);
|
|
357
|
+
const last = Math.min(lastContentRow + 1, scrollTop + visible);
|
|
307
358
|
for (let transcriptRow = first; transcriptRow < last; transcriptRow++) {
|
|
308
|
-
const row = transcriptRow -
|
|
359
|
+
const row = transcriptRow - scrollTop + padding;
|
|
309
360
|
if (row < padding || row >= rows.length) continue;
|
|
310
361
|
const existingRow = rows[row] ?? '';
|
|
311
362
|
let content = existingRow;
|
|
@@ -322,7 +373,7 @@ export function markHoveredMessage(
|
|
|
322
373
|
}
|
|
323
374
|
}
|
|
324
375
|
}
|
|
325
|
-
rows[row] = fill('surfaceHi', padEnd(content,
|
|
376
|
+
rows[row] = fill('surfaceHi', padEnd(truncate(content, safeContentWidth, ''), safeContentWidth));
|
|
326
377
|
}
|
|
327
378
|
}
|
|
328
379
|
|
|
@@ -351,6 +402,7 @@ function messagesMatch(persistedContent: unknown, shownText: string | undefined)
|
|
|
351
402
|
export function persistedMessageIndex(
|
|
352
403
|
marker: MessageMarker, markers: MessageMarker[], messages: SessionRecord['messages']
|
|
353
404
|
): number | null {
|
|
405
|
+
if (!marker || !Array.isArray(markers) || !Array.isArray(messages)) return null;
|
|
354
406
|
let matched = -1;
|
|
355
407
|
for (const shown of markers) {
|
|
356
408
|
if (!isMessage(shown)) continue;
|
|
@@ -418,7 +470,11 @@ export function openMessageActions(host: MessageHost, loop: MessageLoop, marker:
|
|
|
418
470
|
if (typeof text !== 'string') return;
|
|
419
471
|
const sourceId = loop.memoryManager?.sessionId || getActiveSessionId();
|
|
420
472
|
const source = syncInFlightMessagesToSession(loop, sourceId);
|
|
421
|
-
const
|
|
473
|
+
const viewWidth = positiveDim(host.surface?.viewport?.width, 80);
|
|
474
|
+
const flat = host.surface?.transcript?.flatten
|
|
475
|
+
? host.surface.transcript.flatten(viewWidth)
|
|
476
|
+
: null;
|
|
477
|
+
const markers = flat?.markers || [];
|
|
422
478
|
const index = source ? persistedMessageIndex(marker, markers, source.messages) : null;
|
|
423
479
|
|
|
424
480
|
const canModifySession = Boolean(source && index !== null);
|
|
@@ -433,17 +489,20 @@ export function openMessageActions(host: MessageHost, loop: MessageLoop, marker:
|
|
|
433
489
|
];
|
|
434
490
|
|
|
435
491
|
let messageBounds: MessageBounds | null = null;
|
|
436
|
-
if (
|
|
437
|
-
const flat = host.surface.transcript.flatten(host.surface.viewport.width);
|
|
492
|
+
if (flat && host.surface?.viewport) {
|
|
438
493
|
const mIdx = flat.markers.findIndex(m => m.id === marker.id);
|
|
439
494
|
if (mIdx >= 0) {
|
|
440
495
|
const nextM = flat.markers[mIdx + 1];
|
|
441
|
-
const rawStart =
|
|
496
|
+
const rawStart = flat.markers[mIdx]!.row;
|
|
442
497
|
const rawEnd = nextM ? nextM.row - 1 : flat.rows.length - 1;
|
|
443
|
-
const
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
const
|
|
498
|
+
const scrollTop = Number.isFinite(host.surface.viewport.scrollTop)
|
|
499
|
+
? Math.max(0, Math.floor(host.surface.viewport.scrollTop))
|
|
500
|
+
: 0;
|
|
501
|
+
const viewHeight = positiveDim(host.surface.viewport.height, 24);
|
|
502
|
+
const visible = Math.max(0, Math.min(viewHeight, flat.rows.length - scrollTop));
|
|
503
|
+
const padding = viewHeight - visible;
|
|
504
|
+
const startRow = rawStart - scrollTop + padding;
|
|
505
|
+
const endRow = rawEnd - scrollTop + padding;
|
|
447
506
|
messageBounds = { startRow, endRow, textLength: text.length };
|
|
448
507
|
}
|
|
449
508
|
}
|
|
@@ -483,6 +542,7 @@ export function openMessageActions(host: MessageHost, loop: MessageLoop, marker:
|
|
|
483
542
|
loop.taskId = `cli_chat_${Date.now()}`;
|
|
484
543
|
loop.tokenTracker?.reset?.();
|
|
485
544
|
const info = { id: forked.id, title: forked.title, messagesCount: history.length };
|
|
545
|
+
host.surface?.setSessionInfo?.(info);
|
|
486
546
|
host.renderer?.setSessionInfo?.(info);
|
|
487
547
|
host.renderer?.renderSessionHistory?.(history, info);
|
|
488
548
|
host.surface?.viewport?.toBottom?.();
|
|
@@ -511,6 +571,7 @@ export function openMessageActions(host: MessageHost, loop: MessageLoop, marker:
|
|
|
511
571
|
loop.messages = history;
|
|
512
572
|
loop.taskId = `cli_chat_${Date.now()}`;
|
|
513
573
|
const info = { id: latestSource.id, title: latestSource.title, messagesCount: history.length };
|
|
574
|
+
host.surface?.setSessionInfo?.(info);
|
|
514
575
|
host.renderer?.setSessionInfo?.(info);
|
|
515
576
|
host.renderer?.renderSessionHistory?.(history, info);
|
|
516
577
|
host.surface?.viewport?.toBottom?.();
|
|
@@ -533,11 +594,18 @@ export function handleMessageActionMenuMouse(
|
|
|
533
594
|
list?: { moveTo(index: number): unknown }; key(event: { name: string }): string | null },
|
|
534
595
|
event: { mouse?: MousePoint & { button?: number; pressed?: boolean }; sequence?: string }
|
|
535
596
|
): string | null {
|
|
536
|
-
if (!layer.messageActions || !layer.actionLayout || !event.mouse) return null;
|
|
597
|
+
if (!layer || !event || !layer.messageActions || !layer.actionLayout || !event.mouse) return null;
|
|
537
598
|
const { x, y, width, count } = layer.actionLayout;
|
|
538
599
|
const { mouse } = event;
|
|
539
|
-
|
|
540
|
-
|
|
600
|
+
if (!Number.isFinite(mouse.x) || !Number.isFinite(mouse.y)
|
|
601
|
+
|| !Number.isFinite(x) || !Number.isFinite(y)
|
|
602
|
+
|| !Number.isFinite(width) || !Number.isFinite(count)) {
|
|
603
|
+
return 'handled';
|
|
604
|
+
}
|
|
605
|
+
const mouseX = Math.floor(mouse.x);
|
|
606
|
+
const mouseY = Math.floor(mouse.y);
|
|
607
|
+
const index = mouseY - (Math.floor(y) + 1); // only the frame precedes the action rows
|
|
608
|
+
if (mouseX < x || mouseX >= x + width || index < 0 || index >= count) {
|
|
541
609
|
return mouse.button === 0 && mouse.pressed ? 'close' : 'handled';
|
|
542
610
|
}
|
|
543
611
|
layer.list?.moveTo(index);
|