@causyne/agent 1.20.63 → 1.20.65
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 +1 -1
- package/src/approvalPolicy.js +19 -0
- package/src/approvalPolicy.ts +18 -0
- package/src/browser/causyneBrowser.js +34 -4
- package/src/browser/causyneBrowser.ts +32 -4
- package/src/cliMode.js +3 -28
- package/src/commands.js +2 -0
- package/src/tui/composerControls.js +2 -0
- package/src/tui/composerControls.ts +2 -0
- package/src/tui/dialogs.js +36 -4
- package/src/tui/prompt.js +10 -3
package/package.json
CHANGED
package/src/approvalPolicy.js
CHANGED
|
@@ -38,6 +38,22 @@ export function isWholeFileDeletion(tool, args) {
|
|
|
38
38
|
return command.length > 0
|
|
39
39
|
&& (WHOLE_FILE_DELETE.test(command) || DELETE_API_CALL.test(command) || NESTED_SHELL_DELETE.test(command));
|
|
40
40
|
}
|
|
41
|
+
/** Routine browser verification inside the isolated agent browser (preview, snapshot, click, fill, screenshot, etc.) does not require HITL in Mode B or C unless uploading or downloading files. */
|
|
42
|
+
export function isRoutineBrowserVerification(tool, args) {
|
|
43
|
+
if (tool !== 'browser_act')
|
|
44
|
+
return false;
|
|
45
|
+
const actions = Array.isArray(args?.actions) ? args.actions : [];
|
|
46
|
+
if (actions.length === 0) {
|
|
47
|
+
const singleType = typeof args?.action === 'string' ? args.action : typeof args?.type === 'string' ? args.type : '';
|
|
48
|
+
return singleType !== 'download' && singleType !== 'upload';
|
|
49
|
+
}
|
|
50
|
+
return !actions.some(item => {
|
|
51
|
+
if (!item || typeof item !== 'object')
|
|
52
|
+
return false;
|
|
53
|
+
const type = String(item.type ?? item.action ?? '');
|
|
54
|
+
return type === 'download' || type === 'upload';
|
|
55
|
+
});
|
|
56
|
+
}
|
|
41
57
|
/** Prompt policy only. Sandbox denial, workspace checks, and observer veto run separately. */
|
|
42
58
|
export function requiresToolApproval(input) {
|
|
43
59
|
if (input.mode === 'C') {
|
|
@@ -48,6 +64,9 @@ export function requiresToolApproval(input) {
|
|
|
48
64
|
}
|
|
49
65
|
if (input.standingApproval)
|
|
50
66
|
return false;
|
|
67
|
+
if (input.mode !== 'A' && isRoutineBrowserVerification(input.tool, input.args)) {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
51
70
|
return input.risk === 'extreme'
|
|
52
71
|
|| input.heavyDownload
|
|
53
72
|
|| input.risk === 'dangerous'
|
package/src/approvalPolicy.ts
CHANGED
|
@@ -51,6 +51,21 @@ export function isWholeFileDeletion(tool: string, args: Record<string, unknown>)
|
|
|
51
51
|
&& (WHOLE_FILE_DELETE.test(command) || DELETE_API_CALL.test(command) || NESTED_SHELL_DELETE.test(command));
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
+
/** Routine browser verification inside the isolated agent browser (preview, snapshot, click, fill, screenshot, etc.) does not require HITL in Mode B or C unless uploading or downloading files. */
|
|
55
|
+
export function isRoutineBrowserVerification(tool: string, args: Record<string, unknown>): boolean {
|
|
56
|
+
if (tool !== 'browser_act') return false;
|
|
57
|
+
const actions = Array.isArray(args?.actions) ? args.actions : [];
|
|
58
|
+
if (actions.length === 0) {
|
|
59
|
+
const singleType = typeof args?.action === 'string' ? args.action : typeof args?.type === 'string' ? args.type : '';
|
|
60
|
+
return singleType !== 'download' && singleType !== 'upload';
|
|
61
|
+
}
|
|
62
|
+
return !actions.some(item => {
|
|
63
|
+
if (!item || typeof item !== 'object') return false;
|
|
64
|
+
const type = String((item as { type?: unknown; action?: unknown }).type ?? (item as { action?: unknown }).action ?? '');
|
|
65
|
+
return type === 'download' || type === 'upload';
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
|
|
54
69
|
/** Prompt policy only. Sandbox denial, workspace checks, and observer veto run separately. */
|
|
55
70
|
export function requiresToolApproval(input: ToolApprovalInput): boolean {
|
|
56
71
|
if (input.mode === 'C') {
|
|
@@ -59,6 +74,9 @@ export function requiresToolApproval(input: ToolApprovalInput): boolean {
|
|
|
59
74
|
return input.tool !== 'fs_delete' || !input.standingApproval;
|
|
60
75
|
}
|
|
61
76
|
if (input.standingApproval) return false;
|
|
77
|
+
if (input.mode !== 'A' && isRoutineBrowserVerification(input.tool, input.args)) {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
62
80
|
return input.risk === 'extreme'
|
|
63
81
|
|| input.heavyDownload
|
|
64
82
|
|| input.risk === 'dangerous'
|
|
@@ -10,7 +10,7 @@ import { windowSnapshot } from './snapshotWindow.js';
|
|
|
10
10
|
const NAVIGATION_TIMEOUT_MS = 30_000;
|
|
11
11
|
const ACTION_TIMEOUT_MS = 12_000;
|
|
12
12
|
const IFRAME_SNAPSHOT_TIMEOUT_MS = 3_000;
|
|
13
|
-
const IDLE_CLOSE_MS =
|
|
13
|
+
const IDLE_CLOSE_MS = 30 * 60_000;
|
|
14
14
|
const MAX_SEARCH_RESULTS = 10;
|
|
15
15
|
const MAX_EXTRACT_CHARS = 80_000;
|
|
16
16
|
const MAX_DOWNLOAD_BYTES = 250 * 1024 * 1024;
|
|
@@ -670,6 +670,7 @@ export class CausyneBrowser {
|
|
|
670
670
|
securedPages = new WeakSet();
|
|
671
671
|
pageStates = new WeakMap();
|
|
672
672
|
contextRouteInstalled = false;
|
|
673
|
+
lastTarget = null;
|
|
673
674
|
constructor(options = {}) {
|
|
674
675
|
this.workspace = path.resolve(options.workspace ?? process.cwd());
|
|
675
676
|
this.ensureBrowserCapability = options.ensureBrowserCapability ?? (() => ensureCapability('browser'));
|
|
@@ -681,8 +682,10 @@ export class CausyneBrowser {
|
|
|
681
682
|
}
|
|
682
683
|
setWorkspace(workspace) {
|
|
683
684
|
if (workspace && typeof workspace === 'string') {
|
|
684
|
-
if (this.workspace !== path.resolve(workspace))
|
|
685
|
+
if (this.workspace !== path.resolve(workspace)) {
|
|
685
686
|
this.workspacePreview.clear();
|
|
687
|
+
this.lastTarget = null;
|
|
688
|
+
}
|
|
686
689
|
this.workspace = path.resolve(workspace);
|
|
687
690
|
}
|
|
688
691
|
}
|
|
@@ -745,6 +748,7 @@ export class CausyneBrowser {
|
|
|
745
748
|
async snapshot(offset = 0) {
|
|
746
749
|
await this.start();
|
|
747
750
|
const state = await this.activeTab();
|
|
751
|
+
await this.restoreLastTargetIfBlank(state);
|
|
748
752
|
await this.captureSnapshotState(state);
|
|
749
753
|
return {
|
|
750
754
|
...windowSnapshot(state.lastSnapshot, offset),
|
|
@@ -1102,6 +1106,7 @@ export class CausyneBrowser {
|
|
|
1102
1106
|
state.refs.clear();
|
|
1103
1107
|
state.lastSnapshot = '';
|
|
1104
1108
|
state.lastStructure = null;
|
|
1109
|
+
this.lastTarget = { kind: 'url', url: state.page.url() };
|
|
1105
1110
|
}
|
|
1106
1111
|
async preview(state, filePath, workspace) {
|
|
1107
1112
|
state.runtimeErrors = [];
|
|
@@ -1113,6 +1118,28 @@ export class CausyneBrowser {
|
|
|
1113
1118
|
state.refs.clear();
|
|
1114
1119
|
state.lastSnapshot = '';
|
|
1115
1120
|
state.lastStructure = null;
|
|
1121
|
+
this.lastTarget = { kind: 'preview', workspace, filePath };
|
|
1122
|
+
}
|
|
1123
|
+
async restoreLastTargetIfBlank(state) {
|
|
1124
|
+
if (!this.lastTarget)
|
|
1125
|
+
return false;
|
|
1126
|
+
const currentUrl = state.page.url();
|
|
1127
|
+
if (currentUrl && currentUrl !== 'about:blank')
|
|
1128
|
+
return false;
|
|
1129
|
+
const target = this.lastTarget;
|
|
1130
|
+
try {
|
|
1131
|
+
if (target.kind === 'preview') {
|
|
1132
|
+
await this.preview(state, target.filePath, target.workspace);
|
|
1133
|
+
}
|
|
1134
|
+
else {
|
|
1135
|
+
await this.navigate(state, target.url);
|
|
1136
|
+
}
|
|
1137
|
+
await this.captureSnapshotState(state);
|
|
1138
|
+
return true;
|
|
1139
|
+
}
|
|
1140
|
+
catch {
|
|
1141
|
+
return false;
|
|
1142
|
+
}
|
|
1116
1143
|
}
|
|
1117
1144
|
async navigateWithMacroFallback(state, action) {
|
|
1118
1145
|
const { targetUrl, macroName, macroQuery } = this.resolveTargetUrl(action);
|
|
@@ -1178,8 +1205,11 @@ export class CausyneBrowser {
|
|
|
1178
1205
|
const refId = action.ref ?? (action.index !== undefined ? `e${action.index}` : undefined);
|
|
1179
1206
|
if (refId) {
|
|
1180
1207
|
let ref = state.refs.get(refId);
|
|
1181
|
-
if (!ref
|
|
1182
|
-
await this.
|
|
1208
|
+
if (!ref) {
|
|
1209
|
+
await this.restoreLastTargetIfBlank(state);
|
|
1210
|
+
if (!state.refs.has(refId)) {
|
|
1211
|
+
await this.captureSnapshotState(state).catch(() => { });
|
|
1212
|
+
}
|
|
1183
1213
|
ref = state.refs.get(refId);
|
|
1184
1214
|
}
|
|
1185
1215
|
if (!ref)
|
|
@@ -16,7 +16,7 @@ import { windowSnapshot, type SnapshotWindow } from './snapshotWindow.js';
|
|
|
16
16
|
const NAVIGATION_TIMEOUT_MS = 30_000;
|
|
17
17
|
const ACTION_TIMEOUT_MS = 12_000;
|
|
18
18
|
const IFRAME_SNAPSHOT_TIMEOUT_MS = 3_000;
|
|
19
|
-
const IDLE_CLOSE_MS =
|
|
19
|
+
const IDLE_CLOSE_MS = 30 * 60_000;
|
|
20
20
|
const MAX_SEARCH_RESULTS = 10;
|
|
21
21
|
const MAX_EXTRACT_CHARS = 80_000;
|
|
22
22
|
const MAX_DOWNLOAD_BYTES = 250 * 1024 * 1024;
|
|
@@ -936,6 +936,7 @@ export class CausyneBrowser {
|
|
|
936
936
|
private securedPages = new WeakSet<object>();
|
|
937
937
|
private pageStates = new WeakMap<object, TabState>();
|
|
938
938
|
private contextRouteInstalled = false;
|
|
939
|
+
private lastTarget: { kind: 'preview'; workspace: string; filePath: string } | { kind: 'url'; url: string } | null = null;
|
|
939
940
|
|
|
940
941
|
constructor(options: RuntimeOptions = {}) {
|
|
941
942
|
this.workspace = path.resolve(options.workspace ?? process.cwd());
|
|
@@ -949,7 +950,10 @@ export class CausyneBrowser {
|
|
|
949
950
|
|
|
950
951
|
setWorkspace(workspace: string): void {
|
|
951
952
|
if (workspace && typeof workspace === 'string') {
|
|
952
|
-
if (this.workspace !== path.resolve(workspace))
|
|
953
|
+
if (this.workspace !== path.resolve(workspace)) {
|
|
954
|
+
this.workspacePreview.clear();
|
|
955
|
+
this.lastTarget = null;
|
|
956
|
+
}
|
|
953
957
|
this.workspace = path.resolve(workspace);
|
|
954
958
|
}
|
|
955
959
|
}
|
|
@@ -1012,6 +1016,7 @@ export class CausyneBrowser {
|
|
|
1012
1016
|
async snapshot(offset = 0): Promise<SnapshotWindow & { tabId: string; url: string; title: string; refsCount: number; structure?: PageStructure | null }> {
|
|
1013
1017
|
await this.start();
|
|
1014
1018
|
const state = await this.activeTab();
|
|
1019
|
+
await this.restoreLastTargetIfBlank(state);
|
|
1015
1020
|
await this.captureSnapshotState(state);
|
|
1016
1021
|
return {
|
|
1017
1022
|
...windowSnapshot(state.lastSnapshot, offset),
|
|
@@ -1342,6 +1347,7 @@ export class CausyneBrowser {
|
|
|
1342
1347
|
state.refs.clear();
|
|
1343
1348
|
state.lastSnapshot = '';
|
|
1344
1349
|
state.lastStructure = null;
|
|
1350
|
+
this.lastTarget = { kind: 'url', url: state.page.url() };
|
|
1345
1351
|
}
|
|
1346
1352
|
|
|
1347
1353
|
private async preview(state: TabState, filePath: string, workspace: string): Promise<void> {
|
|
@@ -1353,6 +1359,25 @@ export class CausyneBrowser {
|
|
|
1353
1359
|
state.refs.clear();
|
|
1354
1360
|
state.lastSnapshot = '';
|
|
1355
1361
|
state.lastStructure = null;
|
|
1362
|
+
this.lastTarget = { kind: 'preview', workspace, filePath };
|
|
1363
|
+
}
|
|
1364
|
+
|
|
1365
|
+
private async restoreLastTargetIfBlank(state: TabState): Promise<boolean> {
|
|
1366
|
+
if (!this.lastTarget) return false;
|
|
1367
|
+
const currentUrl = state.page.url();
|
|
1368
|
+
if (currentUrl && currentUrl !== 'about:blank') return false;
|
|
1369
|
+
const target = this.lastTarget;
|
|
1370
|
+
try {
|
|
1371
|
+
if (target.kind === 'preview') {
|
|
1372
|
+
await this.preview(state, target.filePath, target.workspace);
|
|
1373
|
+
} else {
|
|
1374
|
+
await this.navigate(state, target.url);
|
|
1375
|
+
}
|
|
1376
|
+
await this.captureSnapshotState(state);
|
|
1377
|
+
return true;
|
|
1378
|
+
} catch {
|
|
1379
|
+
return false;
|
|
1380
|
+
}
|
|
1356
1381
|
}
|
|
1357
1382
|
|
|
1358
1383
|
private async navigateWithMacroFallback(state: TabState, action: BrowserAction): Promise<void> {
|
|
@@ -1414,8 +1439,11 @@ export class CausyneBrowser {
|
|
|
1414
1439
|
const refId = action.ref ?? (action.index !== undefined ? `e${action.index}` : undefined);
|
|
1415
1440
|
if (refId) {
|
|
1416
1441
|
let ref = state.refs.get(refId);
|
|
1417
|
-
if (!ref
|
|
1418
|
-
await this.
|
|
1442
|
+
if (!ref) {
|
|
1443
|
+
await this.restoreLastTargetIfBlank(state);
|
|
1444
|
+
if (!state.refs.has(refId)) {
|
|
1445
|
+
await this.captureSnapshotState(state).catch(() => {});
|
|
1446
|
+
}
|
|
1419
1447
|
ref = state.refs.get(refId);
|
|
1420
1448
|
}
|
|
1421
1449
|
if (!ref) throw new Error(`Unknown element ref ${refId}. Take a new snapshot before interacting.`);
|
package/src/cliMode.js
CHANGED
|
@@ -90,34 +90,9 @@ function makeApprovalHandler(conn, dialogs = null) {
|
|
|
90
90
|
// and a scrollable diff in one frame. The plain fallback asks the same
|
|
91
91
|
// question in the scrollback, which is all a non-TTY session can do.
|
|
92
92
|
if (dialogs && detail) {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
let approved = false;
|
|
97
|
-
let scope = 'reject';
|
|
98
|
-
|
|
99
|
-
for (;;) {
|
|
100
|
-
const answer = await dialogs.approve(detail);
|
|
101
|
-
approved = Boolean(answer && answer.approved);
|
|
102
|
-
scope = (answer && answer.scope) || 'reject';
|
|
103
|
-
|
|
104
|
-
if (scope !== 'always') break;
|
|
105
|
-
|
|
106
|
-
// A SECOND, EXPLICIT CONFIRMATION — the same shape opencode uses, and
|
|
107
|
-
// for the same reason: a standing grant is a much larger thing than
|
|
108
|
-
// approving one call, so it must not be reachable by one keystroke.
|
|
109
|
-
// The text says exactly what is being given up and for how long.
|
|
110
|
-
const confirmed = await dialogs.confirm(
|
|
111
|
-
`Allow ${bold(detail.tool)} to run WITHOUT asking, for the rest of this session?\n`
|
|
112
|
-
+ ` This lasts until Causyne restarts. Undo it any time with /approvals clear.`,
|
|
113
|
-
// Reaching this question already required moving onto Allow always
|
|
114
|
-
// and pressing Enter. A second Enter is therefore an explicit second
|
|
115
|
-
// confirmation, rather than a reflex approval on the first dialog.
|
|
116
|
-
{ defaultAnswer: true }
|
|
117
|
-
);
|
|
118
|
-
if (confirmed) break;
|
|
119
|
-
// Cancelled: ask again rather than denying something they never rejected.
|
|
120
|
-
}
|
|
93
|
+
const answer = await dialogs.approve(detail);
|
|
94
|
+
const approved = Boolean(answer && answer.approved);
|
|
95
|
+
const scope = (answer && answer.scope) || 'reject';
|
|
121
96
|
|
|
122
97
|
if (approved && scope === 'always') {
|
|
123
98
|
grantAlways(detail.tool);
|
package/src/commands.js
CHANGED
|
@@ -2234,6 +2234,8 @@ export const COMMANDS = [
|
|
|
2234
2234
|
ctx.loop.setAutonomyMode(target);
|
|
2235
2235
|
}
|
|
2236
2236
|
if (ctx.prompt) {
|
|
2237
|
+
ctx.prompt.renderer?.status?.setSession?.({ autonomyMode: target });
|
|
2238
|
+
ctx.prompt.surface?.setSessionInfo?.({ autonomyMode: target });
|
|
2237
2239
|
ctx.prompt.notice = `Mode ${target} active`;
|
|
2238
2240
|
if (ctx.prompt.scheduleDraw) ctx.prompt.scheduleDraw();
|
|
2239
2241
|
return ok(`Autonomy mode switched to ${target}.`, { effect: 'inline' });
|
|
@@ -19,6 +19,8 @@ export function openModeControl(prompt, loop) {
|
|
|
19
19
|
config.autonomyMode = item.value;
|
|
20
20
|
saveConfig(config);
|
|
21
21
|
loop.setAutonomyMode(item.value);
|
|
22
|
+
prompt.renderer?.status?.setSession?.({ autonomyMode: item.value });
|
|
23
|
+
prompt.surface?.setSessionInfo?.({ autonomyMode: item.value });
|
|
22
24
|
prompt.notice = `Mode ${item.value} active`;
|
|
23
25
|
prompt.scheduleDraw();
|
|
24
26
|
}
|
|
@@ -31,6 +31,8 @@ export function openModeControl(prompt: ControlPrompt, loop: ControlLoop): void
|
|
|
31
31
|
config.autonomyMode = item.value;
|
|
32
32
|
saveConfig(config);
|
|
33
33
|
loop.setAutonomyMode(item.value);
|
|
34
|
+
(prompt as any).renderer?.status?.setSession?.({ autonomyMode: item.value });
|
|
35
|
+
(prompt as any).surface?.setSessionInfo?.({ autonomyMode: item.value });
|
|
34
36
|
prompt.notice = `Mode ${item.value} active`;
|
|
35
37
|
prompt.scheduleDraw();
|
|
36
38
|
}
|
package/src/tui/dialogs.js
CHANGED
|
@@ -395,11 +395,18 @@ export class ApprovalLayer extends Layer {
|
|
|
395
395
|
|
|
396
396
|
/** The chip row: the selected option is filled, the rest are dimmed. */
|
|
397
397
|
optionRow() {
|
|
398
|
-
|
|
399
|
-
|
|
398
|
+
let col = 0;
|
|
399
|
+
this.optionBounds = [];
|
|
400
|
+
const parts = this.options.map((option, index) => {
|
|
401
|
+
const rendered = index === this.selected
|
|
400
402
|
? badge(option.id === 'reject' ? 'danger' : 'success', option.label)
|
|
401
|
-
: dim(` ${option.label} `)
|
|
402
|
-
|
|
403
|
+
: dim(` ${option.label} `);
|
|
404
|
+
const width = visibleWidth(rendered);
|
|
405
|
+
this.optionBounds.push({ index, option, startCol: col, endCol: col + width - 1 });
|
|
406
|
+
col += width + 1;
|
|
407
|
+
return rendered;
|
|
408
|
+
});
|
|
409
|
+
return parts.join(' ');
|
|
403
410
|
}
|
|
404
411
|
|
|
405
412
|
body(width, fullHeight) {
|
|
@@ -494,6 +501,31 @@ export class ApprovalLayer extends Layer {
|
|
|
494
501
|
return 'close';
|
|
495
502
|
}
|
|
496
503
|
|
|
504
|
+
if (event.name === 'mouse' && event.mouse && event.mouse.pressed && event.mouse.button === 0) {
|
|
505
|
+
if (!Array.isArray(this.optionBounds) || this.optionBounds.length === 0) {
|
|
506
|
+
this.optionRow();
|
|
507
|
+
}
|
|
508
|
+
const geom = this.panelGeometry;
|
|
509
|
+
if (geom && Number.isFinite(event.mouse.row) && Number.isFinite(geom.optionScreenRow)) {
|
|
510
|
+
if (Math.abs(event.mouse.row - geom.optionScreenRow) > 1) return 'handled';
|
|
511
|
+
}
|
|
512
|
+
const rawCol = Number.isFinite(event.mouse.col) ? event.mouse.col : -1;
|
|
513
|
+
const bodyCol = geom ? rawCol - 1 - (geom.inset || 0) - 2 : rawCol;
|
|
514
|
+
const hit = (this.optionBounds || []).find(b => bodyCol >= b.startCol && bodyCol <= b.endCol);
|
|
515
|
+
if (hit) {
|
|
516
|
+
this.selected = hit.index;
|
|
517
|
+
this.answer(Boolean(hit.option.answer), hit.option.id);
|
|
518
|
+
return 'close';
|
|
519
|
+
}
|
|
520
|
+
return 'handled';
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
if (event.name === 'wheel') {
|
|
524
|
+
if (event.wheel?.direction === 'up') this.scroll--;
|
|
525
|
+
else if (event.wheel?.direction === 'down') this.scroll++;
|
|
526
|
+
return 'handled';
|
|
527
|
+
}
|
|
528
|
+
|
|
497
529
|
switch (event.name) {
|
|
498
530
|
case 'up': this.scroll--; return 'handled';
|
|
499
531
|
case 'down': this.scroll++; return 'handled';
|
package/src/tui/prompt.js
CHANGED
|
@@ -896,11 +896,12 @@ export class ChatPrompt {
|
|
|
896
896
|
if (this.completion && this.handleCompletionKey(key)) return;
|
|
897
897
|
if (this.handleScrollKey(key)) return;
|
|
898
898
|
|
|
899
|
-
const
|
|
899
|
+
const isModeControl = Boolean(key.ctrl && key.name === 'g');
|
|
900
|
+
const control = isModeControl ? this.onOpenMode
|
|
900
901
|
: key.alt && key.name === 'm' ? this.onOpenModel
|
|
901
902
|
: key.ctrl && key.name === 't' ? this.onOpenVariant : null;
|
|
902
903
|
if (control) {
|
|
903
|
-
if (this.busy) {
|
|
904
|
+
if (this.busy && !isModeControl) {
|
|
904
905
|
this.notice = 'Finish or interrupt the current turn before switching controls';
|
|
905
906
|
this.scheduleDraw();
|
|
906
907
|
} else {
|
|
@@ -1692,11 +1693,17 @@ export class ChatPrompt {
|
|
|
1692
1693
|
const panelWidth = dialogWidth(availableWidth, this.layer.width || 64);
|
|
1693
1694
|
const maxHeight = dialogHeight(this.surface?.stage?.maxHeight || this.out?.rows, this.layer.preferredHeight());
|
|
1694
1695
|
const panel = panelRows(this.layer, panelWidth, maxHeight);
|
|
1695
|
-
const
|
|
1696
|
+
const status = this.statusRow(width);
|
|
1697
|
+
const all = this.clampRows(panel.concat(status), width);
|
|
1696
1698
|
|
|
1697
1699
|
// panelRows() called body(), which is where a layer publishes its cursor.
|
|
1698
1700
|
const cursor = this.layer.cursor;
|
|
1699
1701
|
const centered = this.surface ? centerRows(all, availableWidth) : { rows: all, inset: 0 };
|
|
1702
|
+
const stageHeight = this.surface?.stage?.height || this.out?.rows || all.length;
|
|
1703
|
+
this.layer.panelGeometry = {
|
|
1704
|
+
inset: centered.inset,
|
|
1705
|
+
optionScreenRow: stageHeight - status.length - 1
|
|
1706
|
+
};
|
|
1700
1707
|
this.present(centered.rows, cursor ? 1 + cursor.y : 0,
|
|
1701
1708
|
(cursor ? 2 + cursor.x : 0) + centered.inset);
|
|
1702
1709
|
}
|