@songtonyli/dsh-cli 0.1.32 → 0.1.34
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/README.md +1 -1
- package/bin/dsh.mjs +1 -1
- package/node_modules/@bufbuild/protobuf/README.md +41 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/clone.js +66 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv1/boot.js +18 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv1/enum.js +31 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv1/extension.js +28 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv1/file.js +18 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv1/index.js +39 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv1/message.js +24 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv1/service.js +27 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv1/symbols.js +43 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv1/types.js +15 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv2/boot.js +105 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv2/embed.js +244 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv2/enum.js +58 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv2/extension.js +28 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv2/file.js +35 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv2/index.js +39 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv2/message.js +24 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv2/restore-json-names.js +29 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv2/scalar.js +67 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv2/service.js +27 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv2/symbols.js +74 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv2/types.js +15 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/create.js +296 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/descriptors.js +53 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/equals.js +209 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/extensions.js +168 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/fields.js +45 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/from-binary.js +415 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/from-json.js +1037 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/index.js +55 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/is-message.js +33 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/json-value.js +15 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/merge.js +70 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/package.json +4 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/proto-int64.js +131 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/reflect/error.js +36 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/reflect/guard.js +78 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/reflect/index.js +41 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/reflect/message.js +157 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/reflect/names.js +115 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/reflect/nested-types.js +110 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/reflect/path.js +376 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/reflect/reflect-check.js +292 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/reflect/reflect-types.js +16 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/reflect/reflect.js +469 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/reflect/scalar.js +129 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/reflect/unsafe.js +149 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/registry.js +954 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/to-binary.js +437 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/to-json.js +625 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/txtpb/from-text.js +684 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/txtpb/index.js +21 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/txtpb/is-group-like.js +47 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/txtpb/reader.js +481 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/txtpb/to-text.js +358 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/txtpb/writer.js +220 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/types.js +15 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/unknown-enum.js +26 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wire/base64-encoding.js +188 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wire/binary-encoding.js +726 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wire/index.js +37 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wire/size-delimited.js +191 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wire/text-encoding.js +106 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wire/text-format.js +199 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wire/varint.js +334 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/any.js +75 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/duration.js +39 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/any_pb.js +27 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/api_pb.js +39 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/compiler/plugin_pb.js +68 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/cpp_features_pb.js +60 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/descriptor_pb.js +892 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/duration_pb.js +27 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/empty_pb.js +27 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/field_mask_pb.js +27 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/go_features_pb.js +126 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/java_features_pb.js +106 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/source_context_pb.js +27 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/struct_pb.js +59 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/timestamp_pb.js +27 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/type_pb.js +242 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/wrappers_pb.js +67 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/index.js +48 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/json.js +44 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/timestamp.js +57 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/wrappers.js +66 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/clone.js +63 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/codegenv1/boot.js +14 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/codegenv1/enum.js +26 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/codegenv1/extension.js +25 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/codegenv1/file.js +14 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/codegenv1/index.js +23 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/codegenv1/message.js +21 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/codegenv1/service.js +24 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/codegenv1/symbols.js +40 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/codegenv1/types.js +14 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/boot.js +101 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/embed.js +239 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/enum.js +53 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/extension.js +25 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/file.js +32 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/index.js +23 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/message.js +21 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/restore-json-names.js +26 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/scalar.js +63 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/service.js +24 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/symbols.js +71 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/types.js +14 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/create.js +293 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/descriptors.js +50 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/equals.js +206 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/extensions.js +159 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/fields.js +41 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/from-binary.js +409 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/from-json.js +1029 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/index.js +29 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/is-message.js +30 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/json-value.js +14 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/merge.js +67 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/package.json +4 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/proto-int64.js +128 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/reflect/error.js +31 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/reflect/guard.js +71 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/reflect/index.js +21 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/reflect/message.js +152 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/reflect/names.js +109 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/reflect/nested-types.js +105 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/reflect/path.js +369 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/reflect/reflect-check.js +284 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/reflect/reflect-types.js +14 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/reflect/reflect.js +464 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/reflect/scalar.js +124 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/reflect/unsafe.js +140 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/registry.js +948 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/to-binary.js +433 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/to-json.js +620 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/txtpb/from-text.js +680 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/txtpb/index.js +15 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/txtpb/is-group-like.js +44 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/txtpb/reader.js +477 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/txtpb/to-text.js +355 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/txtpb/writer.js +214 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/types.js +14 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/unknown-enum.js +23 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/wire/base64-encoding.js +184 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/wire/binary-encoding.js +721 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/wire/index.js +18 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/wire/size-delimited.js +186 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/wire/text-encoding.js +101 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/wire/text-format.js +195 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/wire/varint.js +325 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/any.js +69 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/duration.js +35 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/any_pb.js +24 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/api_pb.js +36 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/compiler/plugin_pb.js +65 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/cpp_features_pb.js +57 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/descriptor_pb.js +888 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/duration_pb.js +24 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/empty_pb.js +24 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/field_mask_pb.js +24 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/go_features_pb.js +123 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/java_features_pb.js +103 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/source_context_pb.js +24 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/struct_pb.js +56 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/timestamp_pb.js +24 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/type_pb.js +239 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/wrappers_pb.js +64 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/index.js +32 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/json.js +41 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/timestamp.js +50 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/wrappers.js +61 -0
- package/node_modules/@bufbuild/protobuf/package.json +136 -0
- package/node_modules/@deepseek-ai/dsh-base/package.json +1 -0
- package/node_modules/@deepseek-ai/dsh-client-ui-primitives/package.json +2 -2
- package/node_modules/@deepseek-ai/dsh-client-ui-sidebar/lib/client.js +1 -1
- package/node_modules/@deepseek-ai/dsh-client-ui-slots/package.json +2 -2
- package/node_modules/@deepseek-ai/dsh-llm-cursor/README.i18n.yaml +6 -0
- package/node_modules/@deepseek-ai/dsh-llm-cursor/README.md +143 -0
- package/node_modules/@deepseek-ai/dsh-llm-cursor/README.zh.md +143 -0
- package/node_modules/@deepseek-ai/dsh-llm-cursor/lib/index.js +3557 -0
- package/node_modules/@deepseek-ai/dsh-llm-cursor/package.json +61 -0
- package/node_modules/@deepseek-ai/dsh-tui-app/README.i18n.yaml +2 -2
- package/node_modules/@deepseek-ai/dsh-tui-app/README.md +39 -26
- package/node_modules/@deepseek-ai/dsh-tui-app/README.zh.md +39 -26
- package/node_modules/@deepseek-ai/dsh-tui-app/lib/index.js +1121 -223
- package/package.json +5 -1
|
@@ -551,6 +551,32 @@ function extensionOf(path) {
|
|
|
551
551
|
return dot <= 0 ? void 0 : base.slice(dot + 1).toLowerCase();
|
|
552
552
|
}
|
|
553
553
|
/**
|
|
554
|
+
* Whether a tool delegates to a subagent, by the same name rule the browser's
|
|
555
|
+
* process view applies: the `subagent` tool and every `subagent_*` tool.
|
|
556
|
+
* @param name - the tool name.
|
|
557
|
+
* @returns true for a tool whose card draws as one compact subagent row.
|
|
558
|
+
*/
|
|
559
|
+
function isSubagentTool(name) {
|
|
560
|
+
return name === "subagent" || name.startsWith("subagent_");
|
|
561
|
+
}
|
|
562
|
+
/**
|
|
563
|
+
* Read a subagent call's arguments into the facts its compact row draws.
|
|
564
|
+
* @param args - the parsed arguments, or undefined while they do not parse yet.
|
|
565
|
+
* @returns the description and the dim facts; empty ones for arguments that carry none.
|
|
566
|
+
*/
|
|
567
|
+
function subagentRowFacts(args) {
|
|
568
|
+
const record = typeof args === "object" && args !== null ? { ...args } : {};
|
|
569
|
+
const text = (value) => typeof value === "string" && value !== "" ? value : void 0;
|
|
570
|
+
const meta = [];
|
|
571
|
+
const model = text(record.model);
|
|
572
|
+
if (model !== void 0) meta.push(model);
|
|
573
|
+
if (record.run_in_background === true) meta.push("background");
|
|
574
|
+
return {
|
|
575
|
+
description: text(record.description) ?? "",
|
|
576
|
+
meta
|
|
577
|
+
};
|
|
578
|
+
}
|
|
579
|
+
/**
|
|
554
580
|
* Parse the model's raw argument JSON for presentation.
|
|
555
581
|
* @param argumentsJson - the `tool/call` event's verbatim argument string.
|
|
556
582
|
* @returns the parsed value, or undefined when it is not JSON.
|
|
@@ -573,10 +599,12 @@ function diffBody(diff) {
|
|
|
573
599
|
const rows = hunks(diffLines(diff.oldText, diff.newText), DIFF_CONTEXT_LINES);
|
|
574
600
|
const lines = [];
|
|
575
601
|
const code = [];
|
|
602
|
+
const marks = [];
|
|
576
603
|
for (const row of rows) {
|
|
577
604
|
if (row === void 0) {
|
|
578
605
|
lines.push(" …");
|
|
579
606
|
code.push(void 0);
|
|
607
|
+
marks.push(void 0);
|
|
580
608
|
continue;
|
|
581
609
|
}
|
|
582
610
|
const prefix = row.kind === "added" ? "+ " : row.kind === "removed" ? "- " : " ";
|
|
@@ -586,10 +614,12 @@ function diffBody(diff) {
|
|
|
586
614
|
prefix,
|
|
587
615
|
source: row.text
|
|
588
616
|
});
|
|
617
|
+
marks.push(row.kind === "context" ? void 0 : row.kind);
|
|
589
618
|
}
|
|
590
619
|
return {
|
|
591
620
|
lines,
|
|
592
|
-
code
|
|
621
|
+
code,
|
|
622
|
+
diff: marks
|
|
593
623
|
};
|
|
594
624
|
}
|
|
595
625
|
/**
|
|
@@ -600,14 +630,17 @@ function diffBody(diff) {
|
|
|
600
630
|
function diffsBody(diffs) {
|
|
601
631
|
const lines = [];
|
|
602
632
|
const code = [];
|
|
633
|
+
const marks = [];
|
|
603
634
|
for (const diff of diffs) {
|
|
604
635
|
const body = diffBody(diff);
|
|
605
636
|
lines.push(diff.path, ...body.lines);
|
|
606
637
|
code.push(void 0, ...body.code);
|
|
638
|
+
marks.push(void 0, ...body.diff);
|
|
607
639
|
}
|
|
608
640
|
return {
|
|
609
641
|
lines,
|
|
610
|
-
code
|
|
642
|
+
code,
|
|
643
|
+
diff: marks
|
|
611
644
|
};
|
|
612
645
|
}
|
|
613
646
|
/**
|
|
@@ -1310,17 +1343,17 @@ function reportChange(result) {
|
|
|
1310
1343
|
return text;
|
|
1311
1344
|
}
|
|
1312
1345
|
/** Control Sequence Introducer. */
|
|
1313
|
-
const CSI$
|
|
1346
|
+
const CSI$2 = "\x1B[";
|
|
1314
1347
|
/**
|
|
1315
1348
|
* Ends the foreground color a recolored run set. SGR 39 restores the default
|
|
1316
1349
|
* foreground only: bold, italic, underline, inverse, and the background set by
|
|
1317
1350
|
* enclosing markdown styling stay in force.
|
|
1318
1351
|
*/
|
|
1319
|
-
const RESET_FOREGROUND$1 = `${CSI$
|
|
1352
|
+
const RESET_FOREGROUND$1 = `${CSI$2}39m`;
|
|
1320
1353
|
/** Faint intensity: the only ramp level the two-level mode draws. */
|
|
1321
|
-
const DIM = `${CSI$
|
|
1354
|
+
const DIM = `${CSI$2}2m`;
|
|
1322
1355
|
/** Ends faint intensity. SGR 22 also ends bold, which shares the code. */
|
|
1323
|
-
const RESET_INTENSITY = `${CSI$
|
|
1356
|
+
const RESET_INTENSITY = `${CSI$2}22m`;
|
|
1324
1357
|
/** Ages the two-level mode draws faint; later ages draw as rendered. */
|
|
1325
1358
|
const DIM_AGES = 2;
|
|
1326
1359
|
/** First xterm 256-color grayscale index. */
|
|
@@ -1358,7 +1391,7 @@ const SRGB_GAMMA = 2.4;
|
|
|
1358
1391
|
* segmenter private, so this module holds one; grapheme segmentation does not
|
|
1359
1392
|
* vary by locale.
|
|
1360
1393
|
*/
|
|
1361
|
-
const GRAPHEMES$
|
|
1394
|
+
const GRAPHEMES$2 = new Intl.Segmenter(void 0, { granularity: "grapheme" });
|
|
1362
1395
|
/**
|
|
1363
1396
|
* Decide how far the terminal can draw the ramp.
|
|
1364
1397
|
*
|
|
@@ -1394,7 +1427,7 @@ function resolveFadeCapability(input) {
|
|
|
1394
1427
|
* @param steps - brightness levels; defaults to {@link FADE_STEPS}.
|
|
1395
1428
|
* @returns `steps` levels, darkest first.
|
|
1396
1429
|
*/
|
|
1397
|
-
function buildFadeRamp(bg, fg, steps =
|
|
1430
|
+
function buildFadeRamp(bg, fg, steps = 24) {
|
|
1398
1431
|
return Array.from({ length: steps }, (_unused, level) => {
|
|
1399
1432
|
if (level === steps - 1) return {
|
|
1400
1433
|
r: fg.r,
|
|
@@ -1469,6 +1502,11 @@ function toSrgb(value) {
|
|
|
1469
1502
|
}
|
|
1470
1503
|
/**
|
|
1471
1504
|
* The SGR sequence one age draws under.
|
|
1505
|
+
*
|
|
1506
|
+
* Truecolor draws a fractional age between its two neighbouring ramp levels,
|
|
1507
|
+
* mixed in linear light, so a word brightens continuously however the frames
|
|
1508
|
+
* fall against the level boundaries. The grayscale encoding has fewer values
|
|
1509
|
+
* than the ramp has levels and draws the level the age floors onto.
|
|
1472
1510
|
* @param style - the capability and the ramp.
|
|
1473
1511
|
* @param age - the brightness level; levels past the ramp draw its last one.
|
|
1474
1512
|
* @returns the sequence to open the run with, or the empty string when the
|
|
@@ -1478,9 +1516,19 @@ function toSrgb(value) {
|
|
|
1478
1516
|
function fadeSgr(style, age) {
|
|
1479
1517
|
if (style.capability === "none") return "";
|
|
1480
1518
|
if (style.capability === "dim") return age < DIM_AGES ? DIM : "";
|
|
1481
|
-
const
|
|
1519
|
+
const last = style.ramp.length - 1;
|
|
1520
|
+
const floor = Math.max(0, Math.min(Math.floor(age), last));
|
|
1521
|
+
const level = style.ramp[floor];
|
|
1482
1522
|
if (level === void 0) return "";
|
|
1483
|
-
|
|
1523
|
+
if (style.capability !== "truecolor") return grayscaleSgr(level);
|
|
1524
|
+
const next = style.ramp[floor + 1];
|
|
1525
|
+
const fraction = age - floor;
|
|
1526
|
+
if (next === void 0 || fraction <= 0) return truecolorSgr(level);
|
|
1527
|
+
return truecolorSgr({
|
|
1528
|
+
r: mix(level.r, next.r, fraction),
|
|
1529
|
+
g: mix(level.g, next.g, fraction),
|
|
1530
|
+
b: mix(level.b, next.b, fraction)
|
|
1531
|
+
});
|
|
1484
1532
|
}
|
|
1485
1533
|
/**
|
|
1486
1534
|
* Encode one level as a 24-bit foreground.
|
|
@@ -1488,7 +1536,7 @@ function fadeSgr(style, age) {
|
|
|
1488
1536
|
* @returns `ESC[38;2;R;G;Bm` with each channel clamped to a byte.
|
|
1489
1537
|
*/
|
|
1490
1538
|
function truecolorSgr(color) {
|
|
1491
|
-
return `${CSI$
|
|
1539
|
+
return `${CSI$2}38;2;${channel(color.r)};${channel(color.g)};${channel(color.b)}m`;
|
|
1492
1540
|
}
|
|
1493
1541
|
/**
|
|
1494
1542
|
* Encode one level as the nearest xterm grayscale index.
|
|
@@ -1498,7 +1546,7 @@ function truecolorSgr(color) {
|
|
|
1498
1546
|
function grayscaleSgr(color) {
|
|
1499
1547
|
const luminance = LUMINANCE$1.r * color.r + LUMINANCE$1.g * color.g + LUMINANCE$1.b * color.b;
|
|
1500
1548
|
const step = Math.round((luminance - GRAY_FIRST_VALUE) / GRAY_VALUE_STEP);
|
|
1501
|
-
return `${CSI$
|
|
1549
|
+
return `${CSI$2}38;5;${GRAY_FIRST_INDEX + Math.max(0, Math.min(GRAY_LEVELS - 1, step))}m`;
|
|
1502
1550
|
}
|
|
1503
1551
|
/**
|
|
1504
1552
|
* Clamp one channel to what an SGR byte carries.
|
|
@@ -1686,7 +1734,7 @@ function settledRgb(state, fg) {
|
|
|
1686
1734
|
* @returns the SGR sequence, or empty when the capability cannot encode a mix.
|
|
1687
1735
|
*/
|
|
1688
1736
|
function encodeMix(capability, color) {
|
|
1689
|
-
return capability === "truecolor" ? truecolorSgr(color) : `${CSI$
|
|
1737
|
+
return capability === "truecolor" ? truecolorSgr(color) : `${CSI$2}38;5;${String(nearestAnsi256(color))}m`;
|
|
1690
1738
|
}
|
|
1691
1739
|
/**
|
|
1692
1740
|
* Rebuild one card row as a per-run float-out mix.
|
|
@@ -1883,8 +1931,8 @@ var FadeTracker = class {
|
|
|
1883
1931
|
chunks = [];
|
|
1884
1932
|
openChunk = void 0;
|
|
1885
1933
|
constructor(options) {
|
|
1886
|
-
this.steps = options.steps ??
|
|
1887
|
-
this.stepMs = options.stepMs ??
|
|
1934
|
+
this.steps = options.steps ?? 24;
|
|
1935
|
+
this.stepMs = options.stepMs ?? 16;
|
|
1888
1936
|
this.now = options.now;
|
|
1889
1937
|
}
|
|
1890
1938
|
/**
|
|
@@ -2104,7 +2152,7 @@ function* cellsFromEnd(lines) {
|
|
|
2104
2152
|
for (const [line, text] of [...lines.entries()].reverse()) {
|
|
2105
2153
|
const cells = [];
|
|
2106
2154
|
let column = 0;
|
|
2107
|
-
for (const part of GRAPHEMES$
|
|
2155
|
+
for (const part of GRAPHEMES$2.segment(stripTerminalSequences(text))) {
|
|
2108
2156
|
const width = visibleWidth(part.segment);
|
|
2109
2157
|
cells.push({
|
|
2110
2158
|
line,
|
|
@@ -2167,7 +2215,7 @@ var CellWalk = class {
|
|
|
2167
2215
|
* the walk reached the start of the rendered text mid-chunk.
|
|
2168
2216
|
*/
|
|
2169
2217
|
function consumeSpan(cells, text) {
|
|
2170
|
-
const wanted = Array.from(GRAPHEMES$
|
|
2218
|
+
const wanted = Array.from(GRAPHEMES$2.segment(text), (part) => part.segment).filter((part) => !isBlank(part)).reverse();
|
|
2171
2219
|
const covered = [];
|
|
2172
2220
|
let index = 0;
|
|
2173
2221
|
let matched = 0;
|
|
@@ -2348,7 +2396,8 @@ const SGR = {
|
|
|
2348
2396
|
success: ["32", "39"],
|
|
2349
2397
|
warning: ["33", "39"],
|
|
2350
2398
|
error: ["31", "39"],
|
|
2351
|
-
inverse: ["7", "27"]
|
|
2399
|
+
inverse: ["7", "27"],
|
|
2400
|
+
band: ["48;5;236", "49"]
|
|
2352
2401
|
};
|
|
2353
2402
|
/**
|
|
2354
2403
|
* Build the palette.
|
|
@@ -2373,6 +2422,7 @@ function createPalette(enabled) {
|
|
|
2373
2422
|
warning: role("warning"),
|
|
2374
2423
|
error: role("error"),
|
|
2375
2424
|
inverse: role("inverse"),
|
|
2425
|
+
band: role("band"),
|
|
2376
2426
|
enabled
|
|
2377
2427
|
};
|
|
2378
2428
|
}
|
|
@@ -2393,6 +2443,58 @@ function paintDiffRows(rows, source, palette) {
|
|
|
2393
2443
|
});
|
|
2394
2444
|
}
|
|
2395
2445
|
/**
|
|
2446
|
+
* Lay one row on the {@link Palette.band} tint across the full width.
|
|
2447
|
+
* @param palette - the active palette.
|
|
2448
|
+
* @param row - the styled row, at most `width` columns.
|
|
2449
|
+
* @param width - the columns the band spans.
|
|
2450
|
+
* @returns the row padded to `width` under the tint; the row unchanged, with
|
|
2451
|
+
* no padding, when the palette is disabled.
|
|
2452
|
+
*/
|
|
2453
|
+
function bandRow(palette, row, width) {
|
|
2454
|
+
return palette.enabled ? palette.band(`${row}${" ".repeat(Math.max(0, width - visibleWidth(row)))}`) : row;
|
|
2455
|
+
}
|
|
2456
|
+
/** Narrowest width a diff box is drawn at: two borders, two spaces, and one column of text. */
|
|
2457
|
+
const DIFF_BOX_MIN_WIDTH = 5;
|
|
2458
|
+
/**
|
|
2459
|
+
* Wrap rows to `width`, framing each run of consecutive additions in a green
|
|
2460
|
+
* rounded box and each run of consecutive removals in a red one, so a change
|
|
2461
|
+
* reads as one region. A removal run directly followed by an addition run
|
|
2462
|
+
* draws as two stacked boxes, the old text above the new. Every returned line
|
|
2463
|
+
* is at most `width` columns, and every box line is exactly `width`.
|
|
2464
|
+
* @param rows - the styled rows.
|
|
2465
|
+
* @param marks - per row, whether it is an addition or a removal; undefined
|
|
2466
|
+
* for a row outside every box.
|
|
2467
|
+
* @param width - the columns the rows fit.
|
|
2468
|
+
* @param palette - the active palette; a disabled one draws the boxes uncolored.
|
|
2469
|
+
* @returns the wrapped rows with the boxes drawn around the changes; rows
|
|
2470
|
+
* wrapped without boxes when the width cannot hold a box.
|
|
2471
|
+
*/
|
|
2472
|
+
function boxDiffRows(rows, marks, width, palette) {
|
|
2473
|
+
const out = [];
|
|
2474
|
+
const inner = width - 4;
|
|
2475
|
+
let open;
|
|
2476
|
+
const close = () => {
|
|
2477
|
+
if (open === void 0) return;
|
|
2478
|
+
const paint = open === "added" ? palette.success : palette.error;
|
|
2479
|
+
out.push(paint(`╰${"─".repeat(width - 2)}╯`));
|
|
2480
|
+
open = void 0;
|
|
2481
|
+
};
|
|
2482
|
+
for (const [index, row] of rows.entries()) {
|
|
2483
|
+
const mark = width < DIFF_BOX_MIN_WIDTH ? void 0 : marks[index];
|
|
2484
|
+
if (mark !== open) close();
|
|
2485
|
+
if (mark === void 0) {
|
|
2486
|
+
out.push(...wrapTextWithAnsi(row, Math.max(1, width)));
|
|
2487
|
+
continue;
|
|
2488
|
+
}
|
|
2489
|
+
const paint = mark === "added" ? palette.success : palette.error;
|
|
2490
|
+
if (open === void 0) out.push(paint(`╭${"─".repeat(width - 2)}╮`));
|
|
2491
|
+
open = mark;
|
|
2492
|
+
for (const part of wrapTextWithAnsi(row, inner)) out.push(`${paint("│")} ${part}${" ".repeat(Math.max(0, inner - visibleWidth(part)))} ${paint("│")}`);
|
|
2493
|
+
}
|
|
2494
|
+
close();
|
|
2495
|
+
return out;
|
|
2496
|
+
}
|
|
2497
|
+
/**
|
|
2396
2498
|
* Decide whether the terminal gets color: `NO_COLOR` (any non-empty value)
|
|
2397
2499
|
* wins, then a non-empty non-zero `FORCE_COLOR`, then whether stdout is a TTY.
|
|
2398
2500
|
* @param env - the process environment.
|
|
@@ -2496,6 +2598,20 @@ const PART_GUTTER = "┃ ";
|
|
|
2496
2598
|
const NO_ARGUMENTS = "(no arguments)";
|
|
2497
2599
|
/** What the result section reports for a tool that answered with nothing. */
|
|
2498
2600
|
const NO_OUTPUT = "(no output)";
|
|
2601
|
+
/** Glyph a tool card header opens with, coloured by the card's status. */
|
|
2602
|
+
const TOOL_GLYPH = "◆";
|
|
2603
|
+
/** Glyph a user prompt opens with. */
|
|
2604
|
+
const USER_GLYPH = "❯";
|
|
2605
|
+
/** Glyph the reasoning header opens with; the reader marks reasoning sections with the same one. */
|
|
2606
|
+
const REASONING_GLYPH = "✻";
|
|
2607
|
+
/**
|
|
2608
|
+
* The header above a message's reasoning rows. It is one fixed string for a
|
|
2609
|
+
* streaming and a committed message alike, so committing never rewrites a row
|
|
2610
|
+
* that may already sit above the repaint floor.
|
|
2611
|
+
*/
|
|
2612
|
+
const REASONING_TITLE = "Thinking";
|
|
2613
|
+
/** Columns the reasoning rows are indented under their header. */
|
|
2614
|
+
const REASONING_INDENT = " ";
|
|
2499
2615
|
/**
|
|
2500
2616
|
* Whether one transcript child folds.
|
|
2501
2617
|
* @param child - a child of the transcript container.
|
|
@@ -2649,7 +2765,7 @@ var UserShellBlock = class {
|
|
|
2649
2765
|
this.drawn.clear();
|
|
2650
2766
|
}
|
|
2651
2767
|
/**
|
|
2652
|
-
* Draw the run, colouring `$ command` when the grammar answers.
|
|
2768
|
+
* Draw the run, colouring `$ command` when the grammar answers and the `$` in the accent.
|
|
2653
2769
|
* @param width - the columns the block lays out in.
|
|
2654
2770
|
* @returns a blank line, the wrapped rows, and a trailing blank line.
|
|
2655
2771
|
*/
|
|
@@ -2658,15 +2774,19 @@ var UserShellBlock = class {
|
|
|
2658
2774
|
const { lines, code } = shellCommandBody(this.command, this.rows.slice(1));
|
|
2659
2775
|
const painted = paintCodeRows(lines, code, this.theme.codeHighlight);
|
|
2660
2776
|
const inner = Math.max(1, width);
|
|
2777
|
+
const [command = "", ...output] = painted;
|
|
2661
2778
|
return [
|
|
2662
2779
|
"",
|
|
2663
|
-
...
|
|
2780
|
+
...[`${this.theme.palette.accent("$ ".trimEnd())} ${command.slice(2)}`, ...output].flatMap((row) => wrapTextWithAnsi(row, inner)),
|
|
2664
2781
|
""
|
|
2665
2782
|
];
|
|
2666
2783
|
});
|
|
2667
2784
|
}
|
|
2668
2785
|
};
|
|
2669
|
-
/**
|
|
2786
|
+
/**
|
|
2787
|
+
* A prompt the user submitted, drawn with a leading {@link USER_GLYPH} on the
|
|
2788
|
+
* palette's background band, which spans every row of the prompt.
|
|
2789
|
+
*/
|
|
2670
2790
|
var UserBlock = class {
|
|
2671
2791
|
theme;
|
|
2672
2792
|
text;
|
|
@@ -2709,12 +2829,15 @@ var UserBlock = class {
|
|
|
2709
2829
|
const palette = this.theme.palette;
|
|
2710
2830
|
const { marked, content: inner } = focusFrame(width, this.highlight);
|
|
2711
2831
|
const lines = this.drawn.get(`${String(width)}:${String(marked)}`, () => {
|
|
2712
|
-
return ["", ...wrapTextWithAnsi(this.text, Math.max(1, inner - 2)).map((line, index) => `${palette.accent(index === 0 ?
|
|
2832
|
+
return ["", ...wrapTextWithAnsi(this.text, Math.max(1, inner - 2)).map((line, index) => bandRow(palette, `${palette.accent(index === 0 ? USER_GLYPH : " ")} ${palette.bold(line)}`, inner))];
|
|
2713
2833
|
});
|
|
2714
2834
|
return marked ? withGutter(palette, lines, () => true, this.highlightLevel) : lines;
|
|
2715
2835
|
}
|
|
2716
2836
|
};
|
|
2717
|
-
/**
|
|
2837
|
+
/**
|
|
2838
|
+
* What a compact context row uses in place of the user prompt's
|
|
2839
|
+
* {@link USER_GLYPH}; the reader marks context sections with the same one.
|
|
2840
|
+
*/
|
|
2718
2841
|
const CONTEXT_GLYPH = "⬡";
|
|
2719
2842
|
/** A dim one-line notice about the session (a stopped turn, a command result, a model switch). */
|
|
2720
2843
|
var NoticeBlock = class {
|
|
@@ -3071,7 +3194,8 @@ var AssistantBlock = class {
|
|
|
3071
3194
|
return withGutter(this.theme.palette, lines, (index) => index >= section.from && index < section.to, this.highlightLevel);
|
|
3072
3195
|
}
|
|
3073
3196
|
/**
|
|
3074
|
-
* Stack the reasoning
|
|
3197
|
+
* Stack the reasoning, under its {@link REASONING_TITLE} header and
|
|
3198
|
+
* indented, over the reply, each through its own tail.
|
|
3075
3199
|
* @param inner - the columns the message lays out in.
|
|
3076
3200
|
* @returns the lines, gutter not yet applied, and where each section falls.
|
|
3077
3201
|
*/
|
|
@@ -3086,8 +3210,11 @@ var AssistantBlock = class {
|
|
|
3086
3210
|
to: 0
|
|
3087
3211
|
};
|
|
3088
3212
|
if (this.reasoning.trim() !== "") {
|
|
3213
|
+
const palette = this.theme.palette;
|
|
3089
3214
|
reasoning.from = lines.length;
|
|
3090
|
-
lines.push(
|
|
3215
|
+
lines.push(truncateToWidth(`${palette.heading(REASONING_GLYPH)} ${palette.dim(REASONING_TITLE)}`, inner, "…"));
|
|
3216
|
+
const width = Math.max(1, inner - 2);
|
|
3217
|
+
lines.push(...this.renderReasoning(width, lines.length).map((line) => `${REASONING_INDENT}${line}`));
|
|
3091
3218
|
reasoning.to = lines.length;
|
|
3092
3219
|
lines.push("");
|
|
3093
3220
|
}
|
|
@@ -3188,7 +3315,8 @@ var AssistantBlock = class {
|
|
|
3188
3315
|
}
|
|
3189
3316
|
};
|
|
3190
3317
|
/**
|
|
3191
|
-
* A tool call card: status
|
|
3318
|
+
* A tool call card: the status-coloured {@link TOOL_GLYPH}, the bold tool
|
|
3319
|
+
* name, the headline in the link colour, then a foldable body.
|
|
3192
3320
|
*
|
|
3193
3321
|
* The card arrives in two pieces, and each floats out on its own: the header
|
|
3194
3322
|
* and the call rows when the model starts the call (a stream delta, or the
|
|
@@ -3206,6 +3334,10 @@ var ToolBlock = class {
|
|
|
3206
3334
|
resultLines = [];
|
|
3207
3335
|
/** The code span behind each result row, for a `read` or `diff` result; absent otherwise. */
|
|
3208
3336
|
resultCode;
|
|
3337
|
+
/** Which result rows are diff additions or removals, for a `diff` result; absent otherwise. */
|
|
3338
|
+
resultDiff;
|
|
3339
|
+
/** The facts a folded subagent card draws as one row; absent for every other tool. */
|
|
3340
|
+
subagent;
|
|
3209
3341
|
expanded = false;
|
|
3210
3342
|
fade;
|
|
3211
3343
|
resultFade;
|
|
@@ -3272,6 +3404,16 @@ var ToolBlock = class {
|
|
|
3272
3404
|
this.revision += 1;
|
|
3273
3405
|
}
|
|
3274
3406
|
/**
|
|
3407
|
+
* Draw this card, while folded, as one subagent row: the task description
|
|
3408
|
+
* and its route, with the tool name while it runs and the outcome tag once
|
|
3409
|
+
* it settled. Unfolding draws the full card.
|
|
3410
|
+
* @param facts - the row's description and dim facts.
|
|
3411
|
+
*/
|
|
3412
|
+
setSubagent(facts) {
|
|
3413
|
+
this.subagent = facts;
|
|
3414
|
+
this.revision += 1;
|
|
3415
|
+
}
|
|
3416
|
+
/**
|
|
3275
3417
|
* Draw the header and the call rows through `fade` until it settles.
|
|
3276
3418
|
* @param fade - the level and drawing settings of this card's own fade.
|
|
3277
3419
|
*/
|
|
@@ -3303,10 +3445,12 @@ var ToolBlock = class {
|
|
|
3303
3445
|
* @param lines - the result rows before preview truncation.
|
|
3304
3446
|
* @param isError - whether the tool reported failure.
|
|
3305
3447
|
* @param code - the span behind each row, for a result the card colours as code.
|
|
3448
|
+
* @param diff - which rows are diff additions or removals, for a result the card boxes as a diff.
|
|
3306
3449
|
*/
|
|
3307
|
-
setResult(lines, isError, code) {
|
|
3450
|
+
setResult(lines, isError, code, diff) {
|
|
3308
3451
|
this.resultLines = lines;
|
|
3309
3452
|
this.resultCode = code;
|
|
3453
|
+
this.resultDiff = diff;
|
|
3310
3454
|
this.status = isError ? "error" : "done";
|
|
3311
3455
|
this.revision += 1;
|
|
3312
3456
|
}
|
|
@@ -3365,7 +3509,16 @@ var ToolBlock = class {
|
|
|
3365
3509
|
*/
|
|
3366
3510
|
layout(outer, marked) {
|
|
3367
3511
|
const palette = this.theme.palette;
|
|
3368
|
-
|
|
3512
|
+
if (this.subagent !== void 0 && !this.expanded) {
|
|
3513
|
+
const row = this.subagentRow(this.subagent, outer);
|
|
3514
|
+
return {
|
|
3515
|
+
call: [row],
|
|
3516
|
+
result: [],
|
|
3517
|
+
lines: ["", row],
|
|
3518
|
+
marker: 0
|
|
3519
|
+
};
|
|
3520
|
+
}
|
|
3521
|
+
const header = `${this.statusStyle()(TOOL_GLYPH)} ${palette.bold(this.toolName)}${this.call.title === "" ? "" : ` ${palette.link(this.call.title)}`}`;
|
|
3369
3522
|
const loading = this.status === "running" ? ["…"] : [];
|
|
3370
3523
|
const body = [
|
|
3371
3524
|
...this.call.lines,
|
|
@@ -3380,11 +3533,16 @@ var ToolBlock = class {
|
|
|
3380
3533
|
const kept = this.expanded ? body : foldRows(body, this.theme.toolPreviewLines, (hidden) => foldMarker(hidden, marked ? "marked" : "transcript"));
|
|
3381
3534
|
const shown = paintDiffRows(paintCodeRows(kept, code, this.theme.codeHighlight), kept, palette);
|
|
3382
3535
|
const callCount = Math.min(this.call.lines.length + loading.length, shown.length);
|
|
3383
|
-
const inner = Math.max(1, outer - 4);
|
|
3384
|
-
const rows = (lines) => lines.flatMap((line) => wrapTextWithAnsi(line, inner).map((part) => ` ${palette.dim("│")} ${part}`));
|
|
3385
|
-
const call = [...wrapTextWithAnsi(header, outer), ...rows(shown.slice(0, callCount))];
|
|
3386
|
-
const result = rows(shown.slice(callCount));
|
|
3387
3536
|
const cut = !this.expanded && body.length > this.theme.toolPreviewLines;
|
|
3537
|
+
const marks = [
|
|
3538
|
+
...this.call.diff ?? new Array(this.call.lines.length).fill(void 0),
|
|
3539
|
+
...new Array(loading.length).fill(void 0),
|
|
3540
|
+
...this.resultDiff ?? new Array(this.resultLines.length).fill(void 0)
|
|
3541
|
+
].slice(0, cut ? kept.length - 1 : kept.length);
|
|
3542
|
+
const inner = Math.max(1, outer - 4);
|
|
3543
|
+
const rows = (from, to) => boxDiffRows(shown.slice(from, to), marks.slice(from, to), inner, palette).map((part) => ` ${palette.dim("│")} ${part}`);
|
|
3544
|
+
const call = [...wrapTextWithAnsi(header, outer), ...rows(0, callCount)];
|
|
3545
|
+
const result = rows(callCount, shown.length);
|
|
3388
3546
|
return {
|
|
3389
3547
|
call,
|
|
3390
3548
|
result,
|
|
@@ -3393,9 +3551,41 @@ var ToolBlock = class {
|
|
|
3393
3551
|
...call,
|
|
3394
3552
|
...result
|
|
3395
3553
|
],
|
|
3396
|
-
marker: cut ? rows(shown.
|
|
3554
|
+
marker: cut ? rows(shown.length - 1, shown.length).length : 0
|
|
3397
3555
|
};
|
|
3398
3556
|
}
|
|
3557
|
+
/**
|
|
3558
|
+
* The colour of this card's status glyph.
|
|
3559
|
+
* @returns warning while running, success once done, error once failed.
|
|
3560
|
+
*/
|
|
3561
|
+
statusStyle() {
|
|
3562
|
+
const palette = this.theme.palette;
|
|
3563
|
+
return this.status === "running" ? palette.warning : this.status === "done" ? palette.success : palette.error;
|
|
3564
|
+
}
|
|
3565
|
+
/**
|
|
3566
|
+
* The one row a folded subagent card draws, led by the status-coloured
|
|
3567
|
+
* {@link SUBAGENT_RUNNING_GLYPH}. A running row carries the accent tool
|
|
3568
|
+
* name; a settled row is dim and ends on its outcome tag at the right edge:
|
|
3569
|
+
* `[failed]` for an error, `[started]` for a call that handed the child to
|
|
3570
|
+
* the background, whose result reads `started …` and whose glyph is dim,
|
|
3571
|
+
* and `[done]` for a call that returned the child's answer.
|
|
3572
|
+
* @param facts - the description and the dim facts.
|
|
3573
|
+
* @param width - the columns the row fits.
|
|
3574
|
+
* @returns the row, no wider than `width`.
|
|
3575
|
+
*/
|
|
3576
|
+
subagentRow(facts, width) {
|
|
3577
|
+
const palette = this.theme.palette;
|
|
3578
|
+
const meta = facts.meta.length === 0 ? "" : ` ${palette.dim(facts.meta.join(" · "))}`;
|
|
3579
|
+
const description = facts.description === "" ? "" : ` ${facts.description}`;
|
|
3580
|
+
if (this.status === "running") {
|
|
3581
|
+
const name = palette.bold(palette.accent(this.toolName));
|
|
3582
|
+
return truncateToWidth(`${palette.warning("◆")} ${name}${description}${meta}`, width, "…");
|
|
3583
|
+
}
|
|
3584
|
+
const started = this.status === "done" && this.resultLines[0]?.startsWith("started ") === true;
|
|
3585
|
+
const tag = this.status === "error" ? palette.error("[failed]") : started ? palette.dim("[started]") : palette.success("[done]");
|
|
3586
|
+
const cut = truncateToWidth(`${started ? palette.dim("◆") : this.statusStyle()("◆")} ${palette.dim(facts.description === "" ? this.toolName : facts.description)}${meta}`, Math.max(1, width - visibleWidth(tag) - 1), "…");
|
|
3587
|
+
return truncateToWidth(`${cut}${" ".repeat(Math.max(1, width - visibleWidth(cut) - visibleWidth(tag)))}${tag}`, width, "…");
|
|
3588
|
+
}
|
|
3399
3589
|
};
|
|
3400
3590
|
/**
|
|
3401
3591
|
* Draw one group of a card's rows at the mix its fade reports.
|
|
@@ -3814,7 +4004,7 @@ const REVERSE_VIDEO_OFF = "\x1B[0m";
|
|
|
3814
4004
|
/** Ends colour, bold, and italic a sliced token may have left open. */
|
|
3815
4005
|
const RESET_PAINT = "\x1B[39m\x1B[22m\x1B[23m";
|
|
3816
4006
|
/** Graphemes the overlay wraps at, matching the editor's default segmenter. */
|
|
3817
|
-
const GRAPHEMES = new Intl.Segmenter(void 0, { granularity: "grapheme" });
|
|
4007
|
+
const GRAPHEMES$1 = new Intl.Segmenter(void 0, { granularity: "grapheme" });
|
|
3818
4008
|
/**
|
|
3819
4009
|
* Take pi-tui's drawn block cursor off one rendered editor line.
|
|
3820
4010
|
*
|
|
@@ -3964,7 +4154,7 @@ function wrapEditorLine(line, maxWidth) {
|
|
|
3964
4154
|
endIndex: line.length
|
|
3965
4155
|
}];
|
|
3966
4156
|
const chunks = [];
|
|
3967
|
-
const segments = [...GRAPHEMES.segment(line)];
|
|
4157
|
+
const segments = [...GRAPHEMES$1.segment(line)];
|
|
3968
4158
|
let currentWidth = 0;
|
|
3969
4159
|
let chunkStart = 0;
|
|
3970
4160
|
let wrapOppIndex = -1;
|
|
@@ -4317,6 +4507,109 @@ async function exportSessionZip(ctx, sessionId, directory, signal) {
|
|
|
4317
4507
|
await pipeline(Readable.fromWeb(archive), createWriteStream(path), { signal });
|
|
4318
4508
|
return path;
|
|
4319
4509
|
}
|
|
4510
|
+
//#endregion
|
|
4511
|
+
//#region lib/types/pace.js
|
|
4512
|
+
/**
|
|
4513
|
+
* Grapheme segmenter for release cuts, so a frame never splits a surrogate
|
|
4514
|
+
* pair, a combining sequence, or a joined emoji.
|
|
4515
|
+
*/
|
|
4516
|
+
const GRAPHEMES = new Intl.Segmenter(void 0, { granularity: "grapheme" });
|
|
4517
|
+
/** The ordered queue of streamed text waiting for a frame. */
|
|
4518
|
+
var StreamPacer = class {
|
|
4519
|
+
drainFrames;
|
|
4520
|
+
entries = [];
|
|
4521
|
+
/** Graphemes the next frame may release beyond its own share. */
|
|
4522
|
+
credit = 0;
|
|
4523
|
+
/** UTF-16 length of the queued text, used as the backlog estimate. */
|
|
4524
|
+
backlog = 0;
|
|
4525
|
+
/** @param options - the drain length in frames. */
|
|
4526
|
+
constructor(options) {
|
|
4527
|
+
this.drainFrames = Math.max(1, options.drainFrames);
|
|
4528
|
+
}
|
|
4529
|
+
/**
|
|
4530
|
+
* Queue one delta.
|
|
4531
|
+
* @param channel - what the text belongs to; a push onto the same channel
|
|
4532
|
+
* as the newest entry extends that entry and keeps its `release`.
|
|
4533
|
+
* @param text - the delta. An empty delta still queues an entry, released
|
|
4534
|
+
* on the next frame at no cost, so a tool name that arrives without
|
|
4535
|
+
* arguments reaches the transcript in order.
|
|
4536
|
+
* @param release - receives the released parts of this entry, in order.
|
|
4537
|
+
*/
|
|
4538
|
+
push(channel, text, release) {
|
|
4539
|
+
const last = this.entries.at(-1);
|
|
4540
|
+
if (last !== void 0 && last.channel === channel) last.text += text;
|
|
4541
|
+
else this.entries.push({
|
|
4542
|
+
channel,
|
|
4543
|
+
text,
|
|
4544
|
+
release
|
|
4545
|
+
});
|
|
4546
|
+
this.backlog += text.length;
|
|
4547
|
+
}
|
|
4548
|
+
/**
|
|
4549
|
+
* Whether text is still waiting for a frame.
|
|
4550
|
+
* @returns true while any entry is queued.
|
|
4551
|
+
*/
|
|
4552
|
+
pending() {
|
|
4553
|
+
return this.entries.length > 0;
|
|
4554
|
+
}
|
|
4555
|
+
/**
|
|
4556
|
+
* Release one frame's share of the backlog.
|
|
4557
|
+
* @returns whether text is still queued after this frame.
|
|
4558
|
+
*/
|
|
4559
|
+
frame() {
|
|
4560
|
+
this.credit += Math.max(1, this.backlog / this.drainFrames);
|
|
4561
|
+
let budget = Math.floor(this.credit);
|
|
4562
|
+
this.credit -= budget;
|
|
4563
|
+
for (let entry = this.entries[0]; entry !== void 0; entry = this.entries[0]) {
|
|
4564
|
+
const cut = cutGraphemes(entry.text, budget);
|
|
4565
|
+
if (cut.graphemes === 0 && entry.text !== "") break;
|
|
4566
|
+
budget -= cut.graphemes;
|
|
4567
|
+
this.backlog -= cut.length;
|
|
4568
|
+
const head = entry.text.slice(0, cut.length);
|
|
4569
|
+
entry.text = entry.text.slice(cut.length);
|
|
4570
|
+
if (entry.text === "") this.entries.shift();
|
|
4571
|
+
entry.release(head);
|
|
4572
|
+
}
|
|
4573
|
+
if (this.entries.length === 0) this.credit = 0;
|
|
4574
|
+
return this.entries.length > 0;
|
|
4575
|
+
}
|
|
4576
|
+
/** Release everything queued, in order, at once. */
|
|
4577
|
+
flush() {
|
|
4578
|
+
const entries = this.entries.splice(0);
|
|
4579
|
+
this.backlog = 0;
|
|
4580
|
+
this.credit = 0;
|
|
4581
|
+
for (const entry of entries) entry.release(entry.text);
|
|
4582
|
+
}
|
|
4583
|
+
/** Drop everything queued without releasing it. */
|
|
4584
|
+
clear() {
|
|
4585
|
+
this.entries.length = 0;
|
|
4586
|
+
this.backlog = 0;
|
|
4587
|
+
this.credit = 0;
|
|
4588
|
+
}
|
|
4589
|
+
};
|
|
4590
|
+
/**
|
|
4591
|
+
* Measure the longest prefix of `text` that holds at most `limit` graphemes.
|
|
4592
|
+
* @param text - the queued text.
|
|
4593
|
+
* @param limit - graphemes the frame may still release.
|
|
4594
|
+
* @returns the prefix's grapheme count and UTF-16 length.
|
|
4595
|
+
*/
|
|
4596
|
+
function cutGraphemes(text, limit) {
|
|
4597
|
+
if (limit <= 0) return {
|
|
4598
|
+
graphemes: 0,
|
|
4599
|
+
length: 0
|
|
4600
|
+
};
|
|
4601
|
+
let graphemes = 0;
|
|
4602
|
+
let length = 0;
|
|
4603
|
+
for (const part of GRAPHEMES.segment(text)) {
|
|
4604
|
+
if (graphemes === limit) break;
|
|
4605
|
+
graphemes += 1;
|
|
4606
|
+
length += part.segment.length;
|
|
4607
|
+
}
|
|
4608
|
+
return {
|
|
4609
|
+
graphemes,
|
|
4610
|
+
length
|
|
4611
|
+
};
|
|
4612
|
+
}
|
|
4320
4613
|
/** Columns the ` ─ ` between the chip and the title takes. */
|
|
4321
4614
|
const CHIP_MARGIN = 3;
|
|
4322
4615
|
/** What opens a top rule. */
|
|
@@ -4483,7 +4776,7 @@ const HINTS = {
|
|
|
4483
4776
|
"esc cancel"
|
|
4484
4777
|
],
|
|
4485
4778
|
panel: [
|
|
4486
|
-
"↑↓ children · Enter
|
|
4779
|
+
"↑↓ children · Enter opens · Tab regions · Esc input",
|
|
4487
4780
|
"↑↓ children · Esc input",
|
|
4488
4781
|
"Esc input"
|
|
4489
4782
|
],
|
|
@@ -4514,15 +4807,27 @@ const REGION_LABELS = {
|
|
|
4514
4807
|
panel: "subagent panel",
|
|
4515
4808
|
bar: "status bar"
|
|
4516
4809
|
};
|
|
4517
|
-
/** The two keys that leave the input
|
|
4810
|
+
/** The two keys that leave the input when no follow-up waits. */
|
|
4518
4811
|
const ENTRY_KEYS = "Shift+↑ read · Shift+↓ status";
|
|
4812
|
+
/** The same pair while follow-ups wait: Shift+↑ selects one instead of reading. */
|
|
4813
|
+
const QUEUE_ENTRY_KEYS = "Shift+↑ select · Shift+↓ status";
|
|
4814
|
+
/**
|
|
4815
|
+
* The key the unfocused follow-ups list names. Shift+↑ is the direction out
|
|
4816
|
+
* of the input toward whatever sits above it.
|
|
4817
|
+
*/
|
|
4818
|
+
const QUEUE_ENTRY_HINT = "shift+↑ select";
|
|
4519
4819
|
/**
|
|
4520
4820
|
* The entry keys the unfocused status bar reserves before any fact is placed,
|
|
4521
4821
|
* in declared degradation steps. Both directions are named: reaching the
|
|
4522
|
-
* conversation and reaching the bar are the two
|
|
4523
|
-
* key nobody can see is a key nobody presses.
|
|
4822
|
+
* conversation or a waiting follow-up, and reaching the bar, are the two
|
|
4823
|
+
* ways out of the input, and a key nobody can see is a key nobody presses.
|
|
4824
|
+
* @param drawn - whether follow-ups sit above the editor, which Shift+↑ enters.
|
|
4825
|
+
* @returns the widest pair first, then the compact form.
|
|
4524
4826
|
*/
|
|
4525
|
-
|
|
4827
|
+
function entryHints(drawn = {}) {
|
|
4828
|
+
return [drawn.queue === true ? QUEUE_ENTRY_KEYS : ENTRY_KEYS, "Shift+↑↓ nav"];
|
|
4829
|
+
}
|
|
4830
|
+
entryHints();
|
|
4526
4831
|
/**
|
|
4527
4832
|
* The widest legend step of one region.
|
|
4528
4833
|
* @param region - the region holding the keyboard.
|
|
@@ -4547,7 +4852,9 @@ const KEY_LINES = {
|
|
|
4547
4852
|
"@ completes paths and sessions · / completes commands · Tab takes one",
|
|
4548
4853
|
"!cmd runs here · the next prompt can read it · !!cmd stays local",
|
|
4549
4854
|
`${ENTRY_KEYS} · Ctrl+G reader`,
|
|
4855
|
+
"Shift+↑ selects follow-ups while they wait",
|
|
4550
4856
|
"Ctrl+O folds every tool card and context row",
|
|
4857
|
+
"Ctrl+T todos · Ctrl+P parent session · Ctrl+L redraw · ? keys",
|
|
4551
4858
|
"Esc arms the stop · Esc again stops the turn",
|
|
4552
4859
|
"Ctrl+C clears the input, twice quits · Ctrl+D quits an empty input"
|
|
4553
4860
|
],
|
|
@@ -4567,8 +4874,8 @@ const OPEN = { kind: "open" };
|
|
|
4567
4874
|
/**
|
|
4568
4875
|
* What one key press means where the keyboard is.
|
|
4569
4876
|
*
|
|
4570
|
-
* `Escape`, `Ctrl+O`, and `Ctrl+
|
|
4571
|
-
* answered first. Everything else is the region's own.
|
|
4877
|
+
* `Escape`, `Ctrl+O`, `Ctrl+G`, `Ctrl+T`, `Ctrl+P`, and `Ctrl+L` mean the
|
|
4878
|
+
* same thing everywhere and are answered first. Everything else is the region's own.
|
|
4572
4879
|
* @param region - the region holding the keyboard.
|
|
4573
4880
|
* @param data - the raw key bytes.
|
|
4574
4881
|
* @returns the action to apply, or undefined when this region claims nothing
|
|
@@ -4579,6 +4886,9 @@ function resolveKey(region, data) {
|
|
|
4579
4886
|
if (matchesKey(data, "escape")) return ESCAPE;
|
|
4580
4887
|
if (matchesKey(data, "ctrl+o")) return FOLD_ALL;
|
|
4581
4888
|
if (matchesKey(data, "ctrl+g")) return READER;
|
|
4889
|
+
if (matchesKey(data, "ctrl+t")) return { kind: "todos" };
|
|
4890
|
+
if (matchesKey(data, "ctrl+p")) return { kind: "parent" };
|
|
4891
|
+
if (matchesKey(data, "ctrl+l")) return { kind: "redraw" };
|
|
4582
4892
|
switch (region) {
|
|
4583
4893
|
case "editor": return editorKey(data);
|
|
4584
4894
|
case "transcript": return transcriptKey(data);
|
|
@@ -4590,14 +4900,17 @@ function resolveKey(region, data) {
|
|
|
4590
4900
|
}
|
|
4591
4901
|
}
|
|
4592
4902
|
/**
|
|
4593
|
-
* What one key means while the editor holds the keyboard.
|
|
4903
|
+
* What one key means while the editor holds the keyboard. Shift+Up and
|
|
4904
|
+
* Shift+Down leave along the stack: the application lands on the first
|
|
4905
|
+
* drawn region in that direction — follow-ups or the conversation above,
|
|
4906
|
+
* the subagent panel or the status bar below.
|
|
4594
4907
|
* @param data - the raw key bytes.
|
|
4595
4908
|
* @returns the action, or undefined for every key pi-tui's editor owns.
|
|
4596
4909
|
*/
|
|
4597
4910
|
function editorKey(data) {
|
|
4598
4911
|
if (matchesKey(data, "shift+up")) return {
|
|
4599
|
-
kind: "
|
|
4600
|
-
|
|
4912
|
+
kind: "leave",
|
|
4913
|
+
direction: "up"
|
|
4601
4914
|
};
|
|
4602
4915
|
if (matchesKey(data, "shift+down")) return {
|
|
4603
4916
|
kind: "leave",
|
|
@@ -4605,6 +4918,7 @@ function editorKey(data) {
|
|
|
4605
4918
|
};
|
|
4606
4919
|
if (matchesKey(data, "ctrl+s")) return { kind: "steer" };
|
|
4607
4920
|
if (matchesKey(data, "shift+tab")) return { kind: "effort" };
|
|
4921
|
+
if (data === "?") return { kind: "help" };
|
|
4608
4922
|
}
|
|
4609
4923
|
/**
|
|
4610
4924
|
* The transcript's movement keys: the arrows step one section and one part,
|
|
@@ -4863,7 +5177,7 @@ function queueKey(data) {
|
|
|
4863
5177
|
function panelKey(data) {
|
|
4864
5178
|
const move = moveKey(data, PANEL_MOVES);
|
|
4865
5179
|
if (move !== void 0) return move;
|
|
4866
|
-
if (matchesKey(data, "enter")) return OPEN;
|
|
5180
|
+
if (matchesKey(data, "enter") || matchesKey(data, "right")) return OPEN;
|
|
4867
5181
|
return cycleKey(data) ?? typeKey(data);
|
|
4868
5182
|
}
|
|
4869
5183
|
/**
|
|
@@ -5193,7 +5507,7 @@ function flattenSections(blocks) {
|
|
|
5193
5507
|
* @param right - the other.
|
|
5194
5508
|
* @returns true when both name the same block and part.
|
|
5195
5509
|
*/
|
|
5196
|
-
function sameSection(left, right) {
|
|
5510
|
+
function sameSection$1(left, right) {
|
|
5197
5511
|
return left.block === right.block && left.part === right.part;
|
|
5198
5512
|
}
|
|
5199
5513
|
/**
|
|
@@ -5225,7 +5539,7 @@ function moveSection(cursor, step, blocks) {
|
|
|
5225
5539
|
if (index < 0) return sectionAt$1(sections, step >= 0 ? sections.length - 1 : 0, cursor);
|
|
5226
5540
|
return sectionAt$1(sections, index, cursor);
|
|
5227
5541
|
}
|
|
5228
|
-
const index = sections.findIndex((section) => sameSection(section, settled));
|
|
5542
|
+
const index = sections.findIndex((section) => sameSection$1(section, settled));
|
|
5229
5543
|
/* v8 ignore next -- a settled cursor is always in flattenSections */
|
|
5230
5544
|
if (index < 0) return settled;
|
|
5231
5545
|
return sectionAt$1(sections, clampIndex(index + step, sections.length), settled);
|
|
@@ -6174,12 +6488,13 @@ function anchorLabel(segment) {
|
|
|
6174
6488
|
/**
|
|
6175
6489
|
* The entry keys this width names.
|
|
6176
6490
|
* @param width - terminal columns the line must fit.
|
|
6491
|
+
* @param queue - whether follow-ups are drawn, which rewrites Shift+↑.
|
|
6177
6492
|
* @returns the widest step that keeps the facts the majority of the line, and
|
|
6178
6493
|
* the empty string on a terminal too narrow to spare the columns.
|
|
6179
6494
|
*/
|
|
6180
|
-
function entryHint(width) {
|
|
6495
|
+
function entryHint(width, queue) {
|
|
6181
6496
|
if (width < HINT_MIN_WIDTH) return "";
|
|
6182
|
-
return fitLegend(
|
|
6497
|
+
return fitLegend(entryHints({ queue }), Math.floor(width / HINT_WIDTH_SHARE));
|
|
6183
6498
|
}
|
|
6184
6499
|
/**
|
|
6185
6500
|
* The key facts that fit the middle of the unfocused line.
|
|
@@ -6216,12 +6531,13 @@ function middleFacts(facts, hidden, room) {
|
|
|
6216
6531
|
* @param segments - the segments in bar order.
|
|
6217
6532
|
* @param palette - the palette the line is dimmed with.
|
|
6218
6533
|
* @param width - terminal columns the line must fit.
|
|
6534
|
+
* @param queue - whether follow-ups are drawn, which rewrites Shift+↑.
|
|
6219
6535
|
* @returns one dim line.
|
|
6220
6536
|
*/
|
|
6221
|
-
function unfocusedLine(segments, palette, width) {
|
|
6537
|
+
function unfocusedLine(segments, palette, width, queue) {
|
|
6222
6538
|
const [anchor, ...rest] = segments;
|
|
6223
6539
|
const model = anchorLabel(anchor);
|
|
6224
|
-
const hint = entryHint(width);
|
|
6540
|
+
const hint = entryHint(width, queue);
|
|
6225
6541
|
const reserved = hint === "" ? 0 : visibleWidth(hint) + HINT_GAP;
|
|
6226
6542
|
const facts = rest.filter((segment) => KEY_SEGMENT_IDS.has(segment.id)).map((segment) => segment.label);
|
|
6227
6543
|
const drawn = middleFacts(facts, rest.length - facts.length, width - visibleWidth(model) - reserved);
|
|
@@ -6343,7 +6659,7 @@ function focusedLines(segments, selected, palette, width, level) {
|
|
|
6343
6659
|
*/
|
|
6344
6660
|
function renderFooter(segments, render) {
|
|
6345
6661
|
const width = Math.max(1, render.width);
|
|
6346
|
-
if (render.selected === void 0) return [unfocusedLine(segments, render.palette, width)];
|
|
6662
|
+
if (render.selected === void 0) return [unfocusedLine(segments, render.palette, width, render.queue === true)];
|
|
6347
6663
|
return focusedLines(segments, render.selected, render.palette, width, render.level ?? 0);
|
|
6348
6664
|
}
|
|
6349
6665
|
/**
|
|
@@ -7075,7 +7391,7 @@ function renderQueuePanel(rows, render) {
|
|
|
7075
7391
|
const glyph = selected === index ? palette.accent(FOLLOW_UP_GLYPH) : FOLLOW_UP_GLYPH;
|
|
7076
7392
|
for (const content of followUpLines(row.text, room, glyph)) lines.push(bodyLine(content, width, palette, tone));
|
|
7077
7393
|
}
|
|
7078
|
-
const hints = selected === void 0 ? [
|
|
7394
|
+
const hints = selected === void 0 ? [QUEUE_ENTRY_HINT] : HINTS.queue;
|
|
7079
7395
|
lines.push(bodyLine(palette.dim(fitLegend(hints, room)), width, palette, tone));
|
|
7080
7396
|
lines.push(bottomRule({
|
|
7081
7397
|
width,
|
|
@@ -7087,9 +7403,9 @@ function renderQueuePanel(rows, render) {
|
|
|
7087
7403
|
/** Narrowest turn list. */
|
|
7088
7404
|
const LIST_MIN_WIDTH = 18;
|
|
7089
7405
|
/** Widest turn list. */
|
|
7090
|
-
const LIST_MAX_WIDTH =
|
|
7406
|
+
const LIST_MAX_WIDTH = 28;
|
|
7091
7407
|
/** Share of the terminal the turn list asks for between its two bounds. */
|
|
7092
|
-
const LIST_SHARE = .
|
|
7408
|
+
const LIST_SHARE = .25;
|
|
7093
7409
|
/** Rows the frame itself takes: the top rule, the legend rule, and the bottom rule. */
|
|
7094
7410
|
const CHROME_ROWS = 3;
|
|
7095
7411
|
/** Columns one body column spends on the border before it and the space after it. */
|
|
@@ -7100,12 +7416,46 @@ const READER_CHIP = "READER";
|
|
|
7100
7416
|
const ELLIPSIS$1 = "…";
|
|
7101
7417
|
/** The left border of a body row and the border between the two panels. */
|
|
7102
7418
|
const SIDE = "│";
|
|
7103
|
-
/** Marks the listed
|
|
7104
|
-
const LIST_MARK = "▸
|
|
7105
|
-
/**
|
|
7106
|
-
const
|
|
7107
|
-
/**
|
|
7108
|
-
const
|
|
7419
|
+
/** Marks the listed section the keyboard holds. */
|
|
7420
|
+
const LIST_MARK = "▸";
|
|
7421
|
+
/** Opens the prompt band and the list's row for the turn being read, as it opens a prompt in the conversation. */
|
|
7422
|
+
const PROMPT_GLYPH = "❯";
|
|
7423
|
+
/** The gutter beside every row of the section the reader holds: the conversation walk's own mark. */
|
|
7424
|
+
const HELD_GUTTER = "┃ ";
|
|
7425
|
+
/** The gutter beside every other row of the panel. */
|
|
7426
|
+
const GUTTER = " ";
|
|
7427
|
+
/** Columns a section's rows are indented by under its header. */
|
|
7428
|
+
const BODY_INDENT = " ";
|
|
7429
|
+
/** Columns a tool result's header is indented by, so it reads as the answer to the call above it. */
|
|
7430
|
+
const RESULT_INDENT = " ";
|
|
7431
|
+
/** What a Markdown bullet of a reply is drawn as. */
|
|
7432
|
+
const BULLET = "• ";
|
|
7433
|
+
/** A Markdown bullet at the start of a reply row: its indentation, then the marker and one space. */
|
|
7434
|
+
const MARKDOWN_BULLET = /^(\s*)[-*+] /;
|
|
7435
|
+
/** What opens a source row a diff adds. */
|
|
7436
|
+
const ADDED_PREFIX = "+ ";
|
|
7437
|
+
/** What opens a source row a diff removes. */
|
|
7438
|
+
const REMOVED_PREFIX = "- ";
|
|
7439
|
+
/** Share of the way from the terminal background toward the foreground the prompt band is mixed at. */
|
|
7440
|
+
const PROMPT_TINT = .12;
|
|
7441
|
+
/** Share of the way from the terminal background toward green or red a diff band is mixed at. */
|
|
7442
|
+
const DIFF_TINT = .22;
|
|
7443
|
+
/** The color the added band is mixed toward: the palette's own `success` green. */
|
|
7444
|
+
const ADDED_RGB = {
|
|
7445
|
+
r: 0,
|
|
7446
|
+
g: 205,
|
|
7447
|
+
b: 0
|
|
7448
|
+
};
|
|
7449
|
+
/** The color the removed band is mixed toward: the palette's own `error` red. */
|
|
7450
|
+
const REMOVED_RGB = {
|
|
7451
|
+
r: 205,
|
|
7452
|
+
g: 0,
|
|
7453
|
+
b: 0
|
|
7454
|
+
};
|
|
7455
|
+
/** Control Sequence Introducer. */
|
|
7456
|
+
const CSI$1 = "\x1B[";
|
|
7457
|
+
/** Ends a background a band set, and nothing else. */
|
|
7458
|
+
const RESET_BACKGROUND = `${CSI$1}49m`;
|
|
7109
7459
|
/** What the reader says on a terminal it cannot draw its frame in. */
|
|
7110
7460
|
const TOO_SMALL = `terminal too small for the reader (needs ${String(24)}×${String(8)})`;
|
|
7111
7461
|
/**
|
|
@@ -7117,11 +7467,13 @@ const TOO_SMALL = `terminal too small for the reader (needs ${String(24)}×${Str
|
|
|
7117
7467
|
*/
|
|
7118
7468
|
const READER_HINTS = {
|
|
7119
7469
|
list: [
|
|
7470
|
+
"↑↓ jk sections · PgUp PgDn [ ] turns · → opens · / filters · Esc q closes",
|
|
7120
7471
|
"↑↓ sections · PgUp PgDn turns · → opens · / filters · Esc closes",
|
|
7121
7472
|
"↑↓ sections · → opens · Esc closes",
|
|
7122
7473
|
"Esc closes"
|
|
7123
7474
|
],
|
|
7124
7475
|
pane: [
|
|
7476
|
+
"↑↓ jk scrolls · PgUp PgDn Space b pages · [ ] turns · ← list · Esc q closes",
|
|
7125
7477
|
"↑↓ scrolls · PgUp PgDn pages · ← turns · Esc closes",
|
|
7126
7478
|
"↑↓ scrolls · ← turns · Esc closes",
|
|
7127
7479
|
"Esc closes"
|
|
@@ -7133,6 +7485,36 @@ const EMPTY_MEASURE = {
|
|
|
7133
7485
|
total: 0
|
|
7134
7486
|
};
|
|
7135
7487
|
/**
|
|
7488
|
+
* Encode one band color as a background under the capability that reads it.
|
|
7489
|
+
* @param capability - `truecolor` writes the color itself, `ansi256` the nearest index.
|
|
7490
|
+
* @param color - the band color.
|
|
7491
|
+
* @returns the style that lays the band under a text.
|
|
7492
|
+
*/
|
|
7493
|
+
function band(capability, color) {
|
|
7494
|
+
const open = capability === "truecolor" ? `${CSI$1}48;2;${String(color.r)};${String(color.g)};${String(color.b)}m` : `${CSI$1}48;5;${String(nearestAnsi256(color))}m`;
|
|
7495
|
+
return (text) => `${open}${text}${RESET_BACKGROUND}`;
|
|
7496
|
+
}
|
|
7497
|
+
/**
|
|
7498
|
+
* The bands the turn panel lays under the prompt and the diff rows, mixed from
|
|
7499
|
+
* the terminal's own background so they stay a shade off it on any theme.
|
|
7500
|
+
* @param style - the fade drawing settings, whose capability says how far the
|
|
7501
|
+
* terminal encodes a color and whose ramp ends on the assumed foreground.
|
|
7502
|
+
* @param background - the terminal background, as the terminal reported it.
|
|
7503
|
+
* @returns the bands, or undefined on a terminal that encodes no color, that
|
|
7504
|
+
* reported no background, or that has no ramp to read the foreground from.
|
|
7505
|
+
*/
|
|
7506
|
+
function readerTints(style, background) {
|
|
7507
|
+
const capability = style.capability;
|
|
7508
|
+
const foreground = style.ramp.at(-1);
|
|
7509
|
+
if (capability !== "truecolor" && capability !== "ansi256") return void 0;
|
|
7510
|
+
if (background === void 0 || foreground === void 0) return void 0;
|
|
7511
|
+
return {
|
|
7512
|
+
prompt: band(capability, mixFadeColor(background, foreground, PROMPT_TINT)),
|
|
7513
|
+
added: band(capability, mixFadeColor(background, ADDED_RGB, DIFF_TINT)),
|
|
7514
|
+
removed: band(capability, mixFadeColor(background, REMOVED_RGB, DIFF_TINT))
|
|
7515
|
+
};
|
|
7516
|
+
}
|
|
7517
|
+
/**
|
|
7136
7518
|
* Hold one index inside a list.
|
|
7137
7519
|
* @param value - the wanted index.
|
|
7138
7520
|
* @param min - the lowest allowed value.
|
|
@@ -7148,7 +7530,7 @@ function clamp(value, min, max) {
|
|
|
7148
7530
|
* @param right - the other.
|
|
7149
7531
|
* @returns true when both name the same block and part.
|
|
7150
7532
|
*/
|
|
7151
|
-
function
|
|
7533
|
+
function sameSection(left, right) {
|
|
7152
7534
|
return left.block === right.block && left.part === right.part;
|
|
7153
7535
|
}
|
|
7154
7536
|
/**
|
|
@@ -7162,13 +7544,23 @@ function groupIndex(state, groups) {
|
|
|
7162
7544
|
return index === -1 ? 0 : index;
|
|
7163
7545
|
}
|
|
7164
7546
|
/**
|
|
7547
|
+
* The turn the panel shows.
|
|
7548
|
+
* @param state - where the reader is.
|
|
7549
|
+
* @param groups - the turns the list names.
|
|
7550
|
+
* @returns the turn holding the cursor, the first listed turn when none
|
|
7551
|
+
* holds it, and undefined for a list naming no turn.
|
|
7552
|
+
*/
|
|
7553
|
+
function readerTurn(state, groups) {
|
|
7554
|
+
return groups[groupIndex(state, groups)];
|
|
7555
|
+
}
|
|
7556
|
+
/**
|
|
7165
7557
|
* Which section of its turn the reader is reading.
|
|
7166
7558
|
* @param state - where the reader is.
|
|
7167
7559
|
* @param group - the turn that holds the cursor.
|
|
7168
7560
|
* @returns the index into the turn's sections, and 0 when the turn no longer carries it.
|
|
7169
7561
|
*/
|
|
7170
7562
|
function sectionIndex(state, group) {
|
|
7171
|
-
const index = group.sections.findIndex((section) =>
|
|
7563
|
+
const index = group.sections.findIndex((section) => sameSection(section, state.cursor));
|
|
7172
7564
|
return index === -1 ? 0 : index;
|
|
7173
7565
|
}
|
|
7174
7566
|
/**
|
|
@@ -7187,49 +7579,231 @@ function sectionAt(cursor, blocks) {
|
|
|
7187
7579
|
};
|
|
7188
7580
|
}
|
|
7189
7581
|
/**
|
|
7190
|
-
*
|
|
7191
|
-
* kind of
|
|
7582
|
+
* The glyph a section opens with, in the list and in its panel header: the
|
|
7583
|
+
* glyph the conversation draws that kind of block with, so a section reads the
|
|
7584
|
+
* same on both surfaces.
|
|
7192
7585
|
* @param block - the block the section belongs to.
|
|
7193
7586
|
* @param part - the section.
|
|
7194
|
-
* @returns the
|
|
7587
|
+
* @returns the glyph.
|
|
7195
7588
|
*/
|
|
7196
|
-
function
|
|
7197
|
-
const label = sectionLabel(block, part);
|
|
7589
|
+
function sectionGlyph(block, part) {
|
|
7198
7590
|
switch (block.blockKind) {
|
|
7199
|
-
case "
|
|
7200
|
-
case "
|
|
7201
|
-
case "
|
|
7202
|
-
case "
|
|
7591
|
+
case "user": return PROMPT_GLYPH;
|
|
7592
|
+
case "context": return "⬡";
|
|
7593
|
+
case "assistant": return part.kind === "reasoning" ? "✻" : "¶";
|
|
7594
|
+
case "tool": return part.kind === "result" ? "⎿" : "◆";
|
|
7203
7595
|
/* v8 ignore next 2 -- closed-union exhaustiveness guard */
|
|
7204
7596
|
default: return assertNever(block, "tui reader block kind");
|
|
7205
7597
|
}
|
|
7206
7598
|
}
|
|
7207
7599
|
/**
|
|
7208
|
-
*
|
|
7209
|
-
*
|
|
7600
|
+
* Whether a tool's result has landed.
|
|
7601
|
+
* @param block - the tool's block.
|
|
7602
|
+
* @returns true once the block carries its result section.
|
|
7603
|
+
*/
|
|
7604
|
+
function settledTool(block) {
|
|
7605
|
+
return block.parts().some((candidate) => candidate.kind === "result");
|
|
7606
|
+
}
|
|
7607
|
+
/**
|
|
7608
|
+
* What a section is named after its glyph: `Prompt`, `Thinking`, and `Reply`
|
|
7609
|
+
* for a message, the tool and its headline for a call, `Result` for its
|
|
7610
|
+
* answer, and the injected context's own label. A tool whose result has not
|
|
7611
|
+
* landed says it is still running.
|
|
7612
|
+
* @param block - the block the section belongs to.
|
|
7613
|
+
* @param part - the section.
|
|
7614
|
+
* @returns the name, unstyled.
|
|
7615
|
+
*/
|
|
7616
|
+
function sectionName(block, part) {
|
|
7617
|
+
switch (block.blockKind) {
|
|
7618
|
+
case "user": return "Prompt";
|
|
7619
|
+
case "context": return sectionLabel(block, part);
|
|
7620
|
+
case "assistant": return part.kind === "reasoning" ? "Thinking" : "Reply";
|
|
7621
|
+
case "tool": {
|
|
7622
|
+
if (part.kind === "result") return "Result";
|
|
7623
|
+
const card = block.title === "" ? block.name : `${block.name} ${block.title}`;
|
|
7624
|
+
return settledTool(block) ? card : `${card} · running`;
|
|
7625
|
+
}
|
|
7626
|
+
/* v8 ignore next 2 -- closed-union exhaustiveness guard */
|
|
7627
|
+
default: return assertNever(block, "tui reader block kind");
|
|
7628
|
+
}
|
|
7629
|
+
}
|
|
7630
|
+
/**
|
|
7631
|
+
* One section's header as it is drawn at rest, styled the way the
|
|
7632
|
+
* conversation draws that kind of block: a call's `◆` in its status color
|
|
7633
|
+
* with the tool name in bold and its headline in the link blue, and a
|
|
7634
|
+
* reasoning, a result, and an injected context recessed.
|
|
7635
|
+
* @param block - the block the section belongs to.
|
|
7636
|
+
* @param part - the section.
|
|
7637
|
+
* @param palette - the palette the header is styled with.
|
|
7638
|
+
* @returns the styled glyph and name.
|
|
7639
|
+
*/
|
|
7640
|
+
function restingHeader(block, part, palette) {
|
|
7641
|
+
const glyph = sectionGlyph(block, part);
|
|
7642
|
+
const name = sectionName(block, part);
|
|
7643
|
+
if (block.blockKind === "tool" && part.kind === "call") return `${(settledTool(block) ? palette.success : palette.warning)(glyph)} ${palette.bold(block.name)}${palette.link(name.slice(block.name.length))}`;
|
|
7644
|
+
if (block.blockKind === "assistant" && part.kind === "reply") return `${palette.accent(glyph)} ${name}`;
|
|
7645
|
+
return palette.dim(`${glyph} ${name}`);
|
|
7646
|
+
}
|
|
7647
|
+
/**
|
|
7648
|
+
* The tone one source row draws in.
|
|
7649
|
+
* @param block - the block the section belongs to.
|
|
7650
|
+
* @param part - the section.
|
|
7651
|
+
* @param row - the source row.
|
|
7652
|
+
* @returns the tone: a tool's diff rows by their prefix, a reasoning or a
|
|
7653
|
+
* call recessed, and everything else plain.
|
|
7654
|
+
*/
|
|
7655
|
+
function rowTone(block, part, row) {
|
|
7656
|
+
if (block.blockKind === "tool") {
|
|
7657
|
+
if (row.startsWith(ADDED_PREFIX)) return "added";
|
|
7658
|
+
if (row.startsWith(REMOVED_PREFIX)) return "removed";
|
|
7659
|
+
}
|
|
7660
|
+
return part.kind === "reasoning" || part.kind === "call" ? "dim" : "plain";
|
|
7661
|
+
}
|
|
7662
|
+
/**
|
|
7663
|
+
* The source rows a section's body draws. A call whose first row repeats the
|
|
7664
|
+
* headline the header already names starts after it, and a reply's Markdown
|
|
7665
|
+
* bullets are drawn as `•`; every other row is the model-facing text as is.
|
|
7666
|
+
* @param block - the block the section belongs to.
|
|
7667
|
+
* @param part - the section.
|
|
7668
|
+
* @returns the rows, unwrapped.
|
|
7669
|
+
*/
|
|
7670
|
+
function bodySource(block, part) {
|
|
7671
|
+
if (block.blockKind === "tool" && part.kind === "call" && block.title !== "" && part.rows[0] === block.title) return part.rows.slice(1);
|
|
7672
|
+
if (part.kind === "reply") return part.rows.map((row) => row.replace(MARKDOWN_BULLET, `$1${BULLET}`));
|
|
7673
|
+
return part.rows;
|
|
7674
|
+
}
|
|
7675
|
+
/**
|
|
7676
|
+
* Fit one styled text to an exact number of columns.
|
|
7677
|
+
* @param text - the text, already styled.
|
|
7678
|
+
* @param width - the columns the cell takes.
|
|
7679
|
+
* @returns the text cut and padded to exactly `width`.
|
|
7680
|
+
*/
|
|
7681
|
+
function cell(text, width) {
|
|
7682
|
+
const cut = truncateToWidth(text, Math.max(1, width), ELLIPSIS$1);
|
|
7683
|
+
return `${cut}${" ".repeat(Math.max(0, width - visibleWidth(cut)))}`;
|
|
7684
|
+
}
|
|
7685
|
+
/**
|
|
7686
|
+
* The prompt that opens a turn: every wrapped row on one band across the
|
|
7687
|
+
* panel, the first led by `❯`, as the conversation draws a prompt.
|
|
7688
|
+
* @param rows - the prompt's source rows.
|
|
7689
|
+
* @param width - the columns right of the gutter.
|
|
7690
|
+
* @param look - the palette, the bands, and whether the reader holds the prompt.
|
|
7691
|
+
* @returns the rows, each exactly `width` columns.
|
|
7692
|
+
*/
|
|
7693
|
+
function promptRows(rows, width, look) {
|
|
7694
|
+
const { palette, tints, held } = look;
|
|
7695
|
+
const room = Math.max(1, width - visibleWidth(BODY_INDENT));
|
|
7696
|
+
const glyph = held ? palette.bold(palette.accent(PROMPT_GLYPH)) : palette.accent(PROMPT_GLYPH);
|
|
7697
|
+
return rows.flatMap((row) => wrapTextWithAnsi(row, room)).map((line, index) => {
|
|
7698
|
+
const text = cell(`${index === 0 ? `${glyph} ` : BODY_INDENT}${palette.bold(line)}`, width);
|
|
7699
|
+
return tints === void 0 ? text : tints.prompt(text);
|
|
7700
|
+
});
|
|
7701
|
+
}
|
|
7702
|
+
/**
|
|
7703
|
+
* One section's header row: its glyph and name, accented end to end while the
|
|
7704
|
+
* reader holds the section.
|
|
7705
|
+
* @param block - the block the section belongs to.
|
|
7706
|
+
* @param part - the section.
|
|
7707
|
+
* @param width - the columns right of the gutter.
|
|
7708
|
+
* @param look - the palette and whether the reader holds the section.
|
|
7709
|
+
* @returns the header, no wider than `width`.
|
|
7710
|
+
*/
|
|
7711
|
+
function headerRow(block, part, width, look) {
|
|
7712
|
+
const { palette, held } = look;
|
|
7713
|
+
return truncateToWidth(`${part.kind === "result" ? RESULT_INDENT : ""}${held ? palette.bold(palette.accent(`${sectionGlyph(block, part)} ${sectionName(block, part)}`)) : restingHeader(block, part, palette)}`, Math.max(1, width), ELLIPSIS$1);
|
|
7714
|
+
}
|
|
7715
|
+
/**
|
|
7716
|
+
* One wrapped body row, painted in its tone.
|
|
7717
|
+
* @param line - the wrapped text.
|
|
7718
|
+
* @param tone - how the source row it came from is tinted.
|
|
7719
|
+
* @param indent - the columns before it.
|
|
7720
|
+
* @param width - the columns right of the gutter.
|
|
7721
|
+
* @param look - the palette and the bands.
|
|
7722
|
+
* @returns the row; a diff row on a band fills the panel to its last column.
|
|
7723
|
+
*/
|
|
7724
|
+
function bodyRow(line, tone, indent, width, look) {
|
|
7725
|
+
const { palette, tints } = look;
|
|
7726
|
+
switch (tone) {
|
|
7727
|
+
case "plain": return `${indent}${line}`;
|
|
7728
|
+
case "dim": return `${indent}${palette.dim(line)}`;
|
|
7729
|
+
case "added":
|
|
7730
|
+
case "removed": {
|
|
7731
|
+
const paint = tone === "added" ? palette.success : palette.error;
|
|
7732
|
+
const tint = tints === void 0 ? void 0 : tone === "added" ? tints.added : tints.removed;
|
|
7733
|
+
if (tint === void 0) return `${indent}${paint(line)}`;
|
|
7734
|
+
return `${indent}${tint(cell(paint(line), Math.max(1, width - visibleWidth(indent))))}`;
|
|
7735
|
+
}
|
|
7736
|
+
/* v8 ignore next 2 -- closed-union exhaustiveness guard */
|
|
7737
|
+
default: return assertNever(tone, "tui reader row tone");
|
|
7738
|
+
}
|
|
7739
|
+
}
|
|
7740
|
+
/**
|
|
7741
|
+
* One section's rows as the panel draws them: the prompt band, or a header
|
|
7742
|
+
* and the section's rows wrapped under it, every row behind the gutter that
|
|
7743
|
+
* carries the conversation walk's `┃` while the reader holds the section.
|
|
7744
|
+
* Never folded, because folding is a decision the transcript makes and this
|
|
7745
|
+
* is where the rest of the text is. How many rows come back depends on the
|
|
7746
|
+
* text and the width alone, never on the palette, the bands, or whether the
|
|
7747
|
+
* section is held.
|
|
7210
7748
|
* @param cursor - the section.
|
|
7211
7749
|
* @param blocks - the navigable blocks.
|
|
7212
|
-
* @param width - the panel's columns.
|
|
7213
|
-
* @
|
|
7750
|
+
* @param width - the panel's columns, the gutter included.
|
|
7751
|
+
* @param look - the palette, the bands, and whether the reader holds the section.
|
|
7752
|
+
* @returns the rows, or none for a section the transcript no longer carries.
|
|
7214
7753
|
*/
|
|
7215
|
-
function
|
|
7216
|
-
const
|
|
7217
|
-
if (
|
|
7218
|
-
|
|
7754
|
+
function sectionRows(cursor, blocks, width, look) {
|
|
7755
|
+
const found = sectionAt(cursor, blocks);
|
|
7756
|
+
if (found === void 0) return [];
|
|
7757
|
+
const { block, part } = found;
|
|
7758
|
+
const content = Math.max(1, width - visibleWidth(GUTTER));
|
|
7759
|
+
let rows;
|
|
7760
|
+
if (block.blockKind === "user") rows = promptRows(part.rows, content, look);
|
|
7761
|
+
else {
|
|
7762
|
+
const indent = part.kind === "result" ? `${RESULT_INDENT}${BODY_INDENT}` : BODY_INDENT;
|
|
7763
|
+
const room = Math.max(1, content - visibleWidth(indent));
|
|
7764
|
+
rows = [headerRow(block, part, content, look), ...bodySource(block, part).flatMap((row) => {
|
|
7765
|
+
const tone = rowTone(block, part, row);
|
|
7766
|
+
return wrapTextWithAnsi(row, room).map((line) => bodyRow(line, tone, indent, content, look));
|
|
7767
|
+
})];
|
|
7768
|
+
}
|
|
7769
|
+
const gutter = look.held ? look.palette.accent(HELD_GUTTER) : GUTTER;
|
|
7770
|
+
return rows.map((row) => `${gutter}${row}`);
|
|
7771
|
+
}
|
|
7772
|
+
/**
|
|
7773
|
+
* Lay out every section of one turn, a blank row between each two.
|
|
7774
|
+
* @param group - the turn the panel shows.
|
|
7775
|
+
* @param blocks - the navigable blocks.
|
|
7776
|
+
* @param width - the panel's columns.
|
|
7777
|
+
* @param look - the palette and bands, and which section the reader holds.
|
|
7778
|
+
* @returns each section's rows, the blank row after it included, in reading order.
|
|
7779
|
+
*/
|
|
7780
|
+
function turnLayout(group, blocks, width, look) {
|
|
7781
|
+
const last = group.sections.length - 1;
|
|
7782
|
+
return group.sections.map((section, index) => {
|
|
7783
|
+
const held = look.cursor !== void 0 && sameSection(section, look.cursor);
|
|
7784
|
+
const rows = sectionRows(section, blocks, width, {
|
|
7785
|
+
palette: look.palette,
|
|
7786
|
+
tints: look.tints,
|
|
7787
|
+
held
|
|
7788
|
+
});
|
|
7789
|
+
return index === last || rows.length === 0 ? rows : [...rows, ""];
|
|
7790
|
+
});
|
|
7219
7791
|
}
|
|
7792
|
+
/** An unstyled palette, which is all measuring needs: styling never changes a row count. */
|
|
7793
|
+
const MEASURING = createPalette(false);
|
|
7220
7794
|
/**
|
|
7221
7795
|
* Measure the turn panel, which is what the scroll keys move over.
|
|
7222
7796
|
* @param group - the turn the panel shows.
|
|
7223
7797
|
* @param blocks - the navigable blocks.
|
|
7224
7798
|
* @param width - the panel's columns.
|
|
7225
|
-
* @returns where each section's
|
|
7799
|
+
* @returns where each section's first row lands and how many rows the panel has.
|
|
7226
7800
|
*/
|
|
7227
7801
|
function measurePane(group, blocks, width) {
|
|
7228
7802
|
const headers = [];
|
|
7229
7803
|
let total = 0;
|
|
7230
|
-
for (const
|
|
7804
|
+
for (const rows of turnLayout(group, blocks, width, { palette: MEASURING })) {
|
|
7231
7805
|
headers.push(total);
|
|
7232
|
-
total +=
|
|
7806
|
+
total += rows.length;
|
|
7233
7807
|
}
|
|
7234
7808
|
return {
|
|
7235
7809
|
headers,
|
|
@@ -7287,7 +7861,7 @@ function readerGeometry(width, rows, state, minColumns) {
|
|
|
7287
7861
|
*/
|
|
7288
7862
|
function readerGeometryFor(state, groups, blocks, width, rows, minColumns) {
|
|
7289
7863
|
const layout = readerGeometry(width, rows, state, minColumns);
|
|
7290
|
-
const group =
|
|
7864
|
+
const group = readerTurn(state, groups);
|
|
7291
7865
|
if (group === void 0 || layout.pane === 0) return layout;
|
|
7292
7866
|
return {
|
|
7293
7867
|
...layout,
|
|
@@ -7315,7 +7889,7 @@ function readerOutline(state, groups) {
|
|
|
7315
7889
|
return [turn, ...group.sections.map((cursor) => ({
|
|
7316
7890
|
kind: "section",
|
|
7317
7891
|
cursor,
|
|
7318
|
-
held:
|
|
7892
|
+
held: sameSection(cursor, state.cursor)
|
|
7319
7893
|
}))];
|
|
7320
7894
|
});
|
|
7321
7895
|
}
|
|
@@ -7337,7 +7911,7 @@ function maxOffset(geometry) {
|
|
|
7337
7911
|
return Math.max(0, geometry.measure.total - geometry.body);
|
|
7338
7912
|
}
|
|
7339
7913
|
/**
|
|
7340
|
-
* Where the panel scrolls to put one section's
|
|
7914
|
+
* Where the panel scrolls to put one section's first row on its first row.
|
|
7341
7915
|
* @param index - the section, by position in its turn.
|
|
7342
7916
|
* @param geometry - the reader's geometry.
|
|
7343
7917
|
* @returns the offset.
|
|
@@ -7377,7 +7951,7 @@ function measureOf(group, held, geometry, blocks) {
|
|
|
7377
7951
|
return geometry.pane === 0 ? EMPTY_MEASURE : measurePane(group, blocks, geometry.pane);
|
|
7378
7952
|
}
|
|
7379
7953
|
/**
|
|
7380
|
-
* Put the reader on one section, with the panel scrolled to its
|
|
7954
|
+
* Put the reader on one section, with the panel scrolled to its first row.
|
|
7381
7955
|
* @param state - where the reader is.
|
|
7382
7956
|
* @param cursor - the section to read.
|
|
7383
7957
|
* @param groups - the turns the list names.
|
|
@@ -7386,12 +7960,12 @@ function measureOf(group, held, geometry, blocks) {
|
|
|
7386
7960
|
* @returns the state on that section.
|
|
7387
7961
|
*/
|
|
7388
7962
|
function readSection(state, cursor, groups, geometry, blocks) {
|
|
7389
|
-
const held =
|
|
7963
|
+
const held = readerTurn(state, groups);
|
|
7390
7964
|
const next = groups[turnIndexOf(cursor, groups)];
|
|
7391
7965
|
/* v8 ignore next -- every cursor the list steps to comes from a listed turn */
|
|
7392
7966
|
if (next === void 0) return state;
|
|
7393
7967
|
const measure = measureOf(next, held, geometry, blocks);
|
|
7394
|
-
const index = next.sections.findIndex((section) =>
|
|
7968
|
+
const index = next.sections.findIndex((section) => sameSection(section, cursor));
|
|
7395
7969
|
/* v8 ignore next -- the cursor came from this turn's own sections, so the measure has its row */
|
|
7396
7970
|
const header = measure.headers[index] ?? 0;
|
|
7397
7971
|
return {
|
|
@@ -7422,7 +7996,7 @@ function withoutQuery(state) {
|
|
|
7422
7996
|
* @returns the state at that row.
|
|
7423
7997
|
*/
|
|
7424
7998
|
function readAt(state, offset, groups, geometry) {
|
|
7425
|
-
const group =
|
|
7999
|
+
const group = readerTurn(state, groups);
|
|
7426
8000
|
const index = geometry.measure.headers.findLastIndex((header) => header <= offset);
|
|
7427
8001
|
const cursor = group?.sections[index];
|
|
7428
8002
|
return cursor === void 0 ? {
|
|
@@ -7492,7 +8066,7 @@ function reduceReader(state, intent, groups, geometry, blocks) {
|
|
|
7492
8066
|
switch (intent.kind) {
|
|
7493
8067
|
case "section": {
|
|
7494
8068
|
const sections = allSections(groups);
|
|
7495
|
-
const at = sections.findIndex((section) =>
|
|
8069
|
+
const at = sections.findIndex((section) => sameSection(section, state.cursor));
|
|
7496
8070
|
const cursor = sections[targetIndex(intent.to, Math.max(0, at), sections.length)];
|
|
7497
8071
|
return cursor === void 0 ? state : readSection(state, cursor, groups, geometry, blocks);
|
|
7498
8072
|
}
|
|
@@ -7536,7 +8110,7 @@ function reduceReader(state, intent, groups, geometry, blocks) {
|
|
|
7536
8110
|
* @returns the state with its offset settled.
|
|
7537
8111
|
*/
|
|
7538
8112
|
function anchorOffset(state, groups, geometry) {
|
|
7539
|
-
const group =
|
|
8113
|
+
const group = readerTurn(state, groups);
|
|
7540
8114
|
if (group === void 0) return state;
|
|
7541
8115
|
return {
|
|
7542
8116
|
...state,
|
|
@@ -7567,108 +8141,83 @@ function markerStrip(markers) {
|
|
|
7567
8141
|
if (markers.context > 0) marks.push(`⬡${String(markers.context)}`);
|
|
7568
8142
|
if (markers.reasoning) marks.push("✻");
|
|
7569
8143
|
if (markers.reply) marks.push("¶");
|
|
7570
|
-
if (markers.tools > 0) marks.push(
|
|
8144
|
+
if (markers.tools > 0) marks.push(`◆${String(markers.tools)}`);
|
|
7571
8145
|
return marks.join("");
|
|
7572
8146
|
}
|
|
7573
8147
|
/**
|
|
7574
|
-
*
|
|
7575
|
-
* @param text - the text
|
|
7576
|
-
* @param
|
|
7577
|
-
* @
|
|
8148
|
+
* Paint one list row by whether it is the selection.
|
|
8149
|
+
* @param text - the row's text.
|
|
8150
|
+
* @param selected - whether it is the open turn or the held section.
|
|
8151
|
+
* @param look - the list's focus and palette.
|
|
8152
|
+
* @returns the row accented for the selection, bold only while the list has
|
|
8153
|
+
* the keyboard, and recessed otherwise.
|
|
7578
8154
|
*/
|
|
7579
|
-
function
|
|
7580
|
-
const
|
|
7581
|
-
|
|
8155
|
+
function listPaint(text, selected, look) {
|
|
8156
|
+
const { palette, focused } = look;
|
|
8157
|
+
if (!selected) return palette.dim(text);
|
|
8158
|
+
return focused ? palette.bold(palette.accent(text)) : palette.accent(text);
|
|
7582
8159
|
}
|
|
7583
8160
|
/**
|
|
7584
|
-
* One row of the
|
|
7585
|
-
* the turn contributed.
|
|
8161
|
+
* One turn row of the list: `❯` on the turn being read, the turn number, its
|
|
8162
|
+
* prompt, and right-aligned what the turn contributed.
|
|
7586
8163
|
* @param group - the turn.
|
|
7587
8164
|
* @param open - whether this is the turn being read, whose sections follow it.
|
|
7588
|
-
* @param
|
|
7589
|
-
* @
|
|
7590
|
-
* @param width - the list's columns.
|
|
7591
|
-
* @returns the row, exactly `width` columns.
|
|
8165
|
+
* @param look - the list's focus, palette, width, and number column.
|
|
8166
|
+
* @returns the row, exactly `look.width` columns.
|
|
7592
8167
|
*/
|
|
7593
|
-
function
|
|
8168
|
+
function turnRow(group, open, look) {
|
|
7594
8169
|
const marks = markerStrip(group.markers);
|
|
7595
|
-
const room = Math.max(1, width - visibleWidth(marks));
|
|
7596
|
-
const
|
|
7597
|
-
|
|
7598
|
-
const head = `${lead}${open ? `[${label}]` : label}`;
|
|
7599
|
-
const paint = (text) => {
|
|
7600
|
-
if (!open) return palette.dim(text);
|
|
7601
|
-
return focused ? palette.bold(palette.accent(text)) : palette.accent(text);
|
|
7602
|
-
};
|
|
7603
|
-
const text = truncateToWidth(paint(head), room, ELLIPSIS$1);
|
|
7604
|
-
return `${text}${" ".repeat(Math.max(0, room - visibleWidth(text)))}${palette.dim(marks)}`;
|
|
8170
|
+
const room = Math.max(1, look.width - visibleWidth(marks) - (marks === "" ? 0 : 1));
|
|
8171
|
+
const text = truncateToWidth(listPaint(`${`${open ? PROMPT_GLYPH : " "} ${String(group.turn).padStart(look.digits)} `}${group.label}`, open, look), room, ELLIPSIS$1);
|
|
8172
|
+
return cell(`${text}${" ".repeat(Math.max(0, look.width - visibleWidth(text) - visibleWidth(marks)))}${look.palette.dim(marks)}`, look.width);
|
|
7605
8173
|
}
|
|
7606
|
-
/** Columns a section row is indented by, so the turn it belongs to reads as its heading. */
|
|
7607
|
-
const SECTION_INDENT = " ";
|
|
7608
8174
|
/**
|
|
7609
|
-
* One section row of the
|
|
7610
|
-
*
|
|
8175
|
+
* One section row of the list: `▸` on the section the reader holds, then the
|
|
8176
|
+
* glyph and the name its header in the panel carries.
|
|
7611
8177
|
* @param cursor - the section.
|
|
7612
8178
|
* @param blocks - the navigable blocks.
|
|
7613
|
-
* @param
|
|
7614
|
-
* @param
|
|
7615
|
-
* @
|
|
7616
|
-
* @param width - the list's columns.
|
|
7617
|
-
* @returns the row, exactly `width` columns.
|
|
8179
|
+
* @param held - whether the cursor holds it.
|
|
8180
|
+
* @param look - the list's focus, palette, and width.
|
|
8181
|
+
* @returns the row, exactly `look.width` columns.
|
|
7618
8182
|
*/
|
|
7619
|
-
function
|
|
8183
|
+
function outlineSectionRow(cursor, blocks, held, look) {
|
|
7620
8184
|
const found = sectionAt(cursor, blocks);
|
|
7621
|
-
const label = found === void 0 ? "" :
|
|
7622
|
-
|
|
7623
|
-
const paint = (text) => {
|
|
7624
|
-
if (!selected) return palette.dim(text);
|
|
7625
|
-
return focused ? palette.bold(palette.accent(text)) : palette.accent(text);
|
|
7626
|
-
};
|
|
7627
|
-
return cell(paint(head), width);
|
|
8185
|
+
const label = found === void 0 ? "" : `${sectionGlyph(found.block, found.part)} ${sectionName(found.block, found.part)}`;
|
|
8186
|
+
return cell(listPaint(` ${held ? LIST_MARK : " "} ${label}`, held, look), look.width);
|
|
7628
8187
|
}
|
|
7629
8188
|
/**
|
|
7630
8189
|
* The turn list's rows, windowed so the row the cursor holds is always drawn.
|
|
7631
8190
|
* @param rows - the outline the list draws.
|
|
7632
8191
|
* @param blocks - the navigable blocks, for each section's own label.
|
|
7633
|
-
* @param
|
|
7634
|
-
* @param palette - the palette the rows are styled with.
|
|
7635
|
-
* @param width - the list's columns.
|
|
8192
|
+
* @param look - the list's focus, palette, width, and number column.
|
|
7636
8193
|
* @param body - the rows the body has.
|
|
7637
8194
|
* @returns the rows to draw, oldest first.
|
|
7638
8195
|
*/
|
|
7639
|
-
function listColumn(rows, blocks,
|
|
8196
|
+
function listColumn(rows, blocks, look, body) {
|
|
7640
8197
|
const cursor = rows.findIndex((row) => row.kind === "section" && row.held);
|
|
7641
8198
|
const start = clamp(Math.max(0, cursor) - Math.floor(Math.max(0, body - 1) / 2), 0, Math.max(0, rows.length - body));
|
|
7642
|
-
return rows.slice(start, start + body).map((row) => row.kind === "turn" ?
|
|
7643
|
-
}
|
|
7644
|
-
/**
|
|
7645
|
-
* One section header inside the turn panel.
|
|
7646
|
-
* @param text - what the section is called, with its turn.
|
|
7647
|
-
* @param palette - the palette the header is styled with.
|
|
7648
|
-
* @param width - the panel's columns.
|
|
7649
|
-
* @param reading - whether this is the section the top row belongs to.
|
|
7650
|
-
* @returns the header row.
|
|
7651
|
-
*/
|
|
7652
|
-
function headerRow(text, palette, width, reading) {
|
|
7653
|
-
const body = ` ${text} `;
|
|
7654
|
-
const line = `${HEADER_LEAD}${body}${HEADER_FILL.repeat(Math.max(0, width - visibleWidth(HEADER_LEAD) - visibleWidth(body)))}`;
|
|
7655
|
-
return reading ? palette.bold(palette.accent(line)) : palette.dim(line);
|
|
8199
|
+
return rows.slice(start, start + body).map((row) => row.kind === "turn" ? turnRow(row.group, row.open, look) : outlineSectionRow(row.cursor, blocks, row.held, look));
|
|
7656
8200
|
}
|
|
7657
8201
|
/**
|
|
7658
8202
|
* The turn panel's rows: every section of the held turn, in reading order,
|
|
7659
|
-
*
|
|
8203
|
+
* the prompt on its band and every other section under its own header, with a
|
|
8204
|
+
* reveal in flight floating out the rows it covers.
|
|
7660
8205
|
* @param group - the turn the panel shows.
|
|
7661
8206
|
* @param blocks - the navigable blocks.
|
|
7662
|
-
* @param cursor - the section the
|
|
7663
|
-
* @param
|
|
8207
|
+
* @param cursor - the section the reader holds.
|
|
8208
|
+
* @param render - the palette, the bands, and the reveal.
|
|
7664
8209
|
* @param width - the panel's columns.
|
|
7665
8210
|
* @returns the rows, before the scroll window is applied.
|
|
7666
8211
|
*/
|
|
7667
|
-
function paneColumn(group, blocks, cursor,
|
|
7668
|
-
|
|
7669
|
-
|
|
7670
|
-
|
|
7671
|
-
|
|
8212
|
+
function paneColumn(group, blocks, cursor, render, width) {
|
|
8213
|
+
const { palette, tints, reveal } = render;
|
|
8214
|
+
return turnLayout(group, blocks, width, {
|
|
8215
|
+
palette,
|
|
8216
|
+
tints,
|
|
8217
|
+
cursor
|
|
8218
|
+
}).flatMap((rows, index) => {
|
|
8219
|
+
const section = group.sections[index];
|
|
8220
|
+
return reveal !== void 0 && (reveal.section === void 0 || section !== void 0 && sameSection(section, reveal.section)) ? recolorLines(rows, reveal.age, reveal.style) : rows;
|
|
7672
8221
|
});
|
|
7673
8222
|
}
|
|
7674
8223
|
/**
|
|
@@ -7679,12 +8228,11 @@ function paneColumn(group, blocks, cursor, palette, width) {
|
|
|
7679
8228
|
* @param width - the frame's columns.
|
|
7680
8229
|
* @returns the row, no wider than `width`.
|
|
7681
8230
|
*/
|
|
7682
|
-
function
|
|
7683
|
-
|
|
7684
|
-
let line = `${border} `;
|
|
8231
|
+
function frameRow(columns, row, palette, width) {
|
|
8232
|
+
let line = `${palette.accent(SIDE)} `;
|
|
7685
8233
|
for (const [index, column] of columns.entries()) {
|
|
7686
8234
|
const text = column.rows[row] ?? "";
|
|
7687
|
-
line += index === columns.length - 1 ? truncateToWidth(text, Math.max(1, column.width), ELLIPSIS$1) : `${cell(text, column.width)}${
|
|
8235
|
+
line += index === columns.length - 1 ? truncateToWidth(text, Math.max(1, column.width), ELLIPSIS$1) : `${cell(text, column.width)}${palette.dim(SIDE)} `;
|
|
7688
8236
|
}
|
|
7689
8237
|
return truncateToWidth(line, Math.max(1, width), ELLIPSIS$1);
|
|
7690
8238
|
}
|
|
@@ -7732,7 +8280,8 @@ function readout(state, groups, geometry, totalTurns) {
|
|
|
7732
8280
|
* Draw the reader.
|
|
7733
8281
|
* @param state - where the reader is.
|
|
7734
8282
|
* @param groups - the turns the list names, already narrowed by the query.
|
|
7735
|
-
* @param render - the palette, the blocks, the geometry inputs,
|
|
8283
|
+
* @param render - the palette, the blocks, the geometry inputs, the turn
|
|
8284
|
+
* total, and the bands and reveal the turn panel is drawn with.
|
|
7736
8285
|
* @returns exactly `render.rows` lines, none wider than `render.width`.
|
|
7737
8286
|
*/
|
|
7738
8287
|
function readerRows(state, groups, render) {
|
|
@@ -7747,16 +8296,24 @@ function readerRows(state, groups, render) {
|
|
|
7747
8296
|
const selected = groupIndex(state, groups);
|
|
7748
8297
|
const group = groups[selected];
|
|
7749
8298
|
const columns = [];
|
|
7750
|
-
if (geometry.list > 0)
|
|
7751
|
-
|
|
7752
|
-
|
|
7753
|
-
|
|
8299
|
+
if (geometry.list > 0) {
|
|
8300
|
+
const look = {
|
|
8301
|
+
focused: state.column !== "pane",
|
|
8302
|
+
palette,
|
|
8303
|
+
width: geometry.list,
|
|
8304
|
+
digits: Math.max(1, ...groups.map((entry) => String(entry.turn).length))
|
|
8305
|
+
};
|
|
8306
|
+
columns.push({
|
|
8307
|
+
width: geometry.list,
|
|
8308
|
+
rows: groups.length === 0 ? [palette.dim(`no turn matches "${state.query ?? ""}"`)] : listColumn(readerOutline(state, groups), blocks, look, geometry.body)
|
|
8309
|
+
});
|
|
8310
|
+
}
|
|
7754
8311
|
if (geometry.pane > 0) columns.push({
|
|
7755
8312
|
width: geometry.pane,
|
|
7756
|
-
rows: group === void 0 ? [] : paneColumn(group, blocks, state.cursor,
|
|
8313
|
+
rows: group === void 0 ? [] : paneColumn(group, blocks, state.cursor, render, geometry.pane).slice(state.offset)
|
|
7757
8314
|
});
|
|
7758
8315
|
const body = [];
|
|
7759
|
-
for (let row = 0; row < geometry.body; row += 1) body.push(
|
|
8316
|
+
for (let row = 0; row < geometry.body; row += 1) body.push(frameRow(columns, row, palette, width));
|
|
7760
8317
|
const report = readout(state, groups, geometry, totalTurns);
|
|
7761
8318
|
const legendRoom = ruleRoom(width) - visibleWidth(report) - 1;
|
|
7762
8319
|
return [
|
|
@@ -7800,10 +8357,76 @@ function readerRows(state, groups, render) {
|
|
|
7800
8357
|
* turns on every render, so a reply that is still streaming grows inside it,
|
|
7801
8358
|
* a tool result that lands appears, and a new turn joins the list, all with
|
|
7802
8359
|
* no push and no second clock.
|
|
8360
|
+
*
|
|
8361
|
+
* Opening the reader, showing another turn, and stepping the list to another
|
|
8362
|
+
* section of the same turn each start a reveal: the rows newly in view float
|
|
8363
|
+
* out from a lifted color to the colors they settle at, on a clock the
|
|
8364
|
+
* application runs on its fade tick. Scrolling, live growth, and a rewrap
|
|
8365
|
+
* reveal nothing. A reveal changes colors only, and a terminal that runs no
|
|
8366
|
+
* motion draws the settled reader from the first frame.
|
|
7803
8367
|
* @module @deepseek-ai/dsh-tui-app/reader-screen
|
|
7804
8368
|
*/
|
|
7805
8369
|
/** The key that opens the query line. */
|
|
7806
8370
|
const FILTER_KEY = "/";
|
|
8371
|
+
/** Printable keys either panel answers the way a pager does, beside the named keys. */
|
|
8372
|
+
const ALIASES$1 = [["[", {
|
|
8373
|
+
kind: "turn",
|
|
8374
|
+
step: -1
|
|
8375
|
+
}], ["]", {
|
|
8376
|
+
kind: "turn",
|
|
8377
|
+
step: 1
|
|
8378
|
+
}]];
|
|
8379
|
+
/** Printable keys the turn list answers beside the named keys. */
|
|
8380
|
+
const LIST_ALIASES = new Map([
|
|
8381
|
+
...ALIASES$1,
|
|
8382
|
+
["k", {
|
|
8383
|
+
kind: "section",
|
|
8384
|
+
to: "previous"
|
|
8385
|
+
}],
|
|
8386
|
+
["j", {
|
|
8387
|
+
kind: "section",
|
|
8388
|
+
to: "next"
|
|
8389
|
+
}],
|
|
8390
|
+
["g", {
|
|
8391
|
+
kind: "section",
|
|
8392
|
+
to: "first"
|
|
8393
|
+
}],
|
|
8394
|
+
["G", {
|
|
8395
|
+
kind: "section",
|
|
8396
|
+
to: "last"
|
|
8397
|
+
}],
|
|
8398
|
+
[FILTER_KEY, { kind: "filter" }]
|
|
8399
|
+
]);
|
|
8400
|
+
/** Printable keys the turn panel answers beside the named keys. */
|
|
8401
|
+
const PANE_ALIASES = new Map([
|
|
8402
|
+
...ALIASES$1,
|
|
8403
|
+
["k", {
|
|
8404
|
+
kind: "scroll",
|
|
8405
|
+
to: "previous"
|
|
8406
|
+
}],
|
|
8407
|
+
["j", {
|
|
8408
|
+
kind: "scroll",
|
|
8409
|
+
to: "next"
|
|
8410
|
+
}],
|
|
8411
|
+
["g", {
|
|
8412
|
+
kind: "scroll",
|
|
8413
|
+
to: "first"
|
|
8414
|
+
}],
|
|
8415
|
+
["G", {
|
|
8416
|
+
kind: "scroll",
|
|
8417
|
+
to: "last"
|
|
8418
|
+
}],
|
|
8419
|
+
[" ", {
|
|
8420
|
+
kind: "page",
|
|
8421
|
+
step: 1
|
|
8422
|
+
}],
|
|
8423
|
+
["b", {
|
|
8424
|
+
kind: "page",
|
|
8425
|
+
step: -1
|
|
8426
|
+
}]
|
|
8427
|
+
]);
|
|
8428
|
+
/** The printable key that closes the reader from either panel, as `Escape` does. */
|
|
8429
|
+
const QUIT_KEY = "q";
|
|
7807
8430
|
/**
|
|
7808
8431
|
* The reader pane: it renders exactly the rows it was given, maps every key
|
|
7809
8432
|
* to one {@link ReaderIntent}, and settles once when the reader closes.
|
|
@@ -7817,6 +8440,10 @@ var ReaderPane = class {
|
|
|
7817
8440
|
width = 0;
|
|
7818
8441
|
/** The body the last render anchored on, so one rewrap re-anchors exactly once. */
|
|
7819
8442
|
layout = "";
|
|
8443
|
+
/** The turn the last render showed, by index into every turn; -1 for none, undefined before the first render. */
|
|
8444
|
+
shownTurn;
|
|
8445
|
+
/** The reveal in flight, and the one section it covers when it covers no whole turn. */
|
|
8446
|
+
reveal;
|
|
7820
8447
|
/**
|
|
7821
8448
|
* @param options - the palette, the live transcript reads, and the section to open on.
|
|
7822
8449
|
*/
|
|
@@ -7856,13 +8483,22 @@ var ReaderPane = class {
|
|
|
7856
8483
|
this.layout = layout;
|
|
7857
8484
|
this.state = reduceReader(this.state, { kind: "anchor" }, visible, geometry, blocks);
|
|
7858
8485
|
}
|
|
8486
|
+
const held = readerTurn(this.state, visible);
|
|
8487
|
+
const turn = held === void 0 ? -1 : groups.indexOf(held);
|
|
8488
|
+
if (this.shownTurn !== turn) {
|
|
8489
|
+
this.shownTurn = turn;
|
|
8490
|
+
this.startReveal(void 0);
|
|
8491
|
+
}
|
|
8492
|
+
const effects = this.options.effects;
|
|
7859
8493
|
return readerRows(this.state, visible, {
|
|
7860
8494
|
palette: this.options.palette,
|
|
7861
8495
|
blocks,
|
|
7862
8496
|
width,
|
|
7863
8497
|
rows,
|
|
7864
8498
|
minColumns: this.options.minColumns,
|
|
7865
|
-
totalTurns: groups.length
|
|
8499
|
+
totalTurns: groups.length,
|
|
8500
|
+
tints: effects === void 0 ? void 0 : readerTints(effects.style(), effects.background()),
|
|
8501
|
+
reveal: this.revealNow()
|
|
7866
8502
|
});
|
|
7867
8503
|
}
|
|
7868
8504
|
/**
|
|
@@ -7881,19 +8517,56 @@ var ReaderPane = class {
|
|
|
7881
8517
|
if (matchesKey(data, "escape")) this.close("transcript");
|
|
7882
8518
|
return;
|
|
7883
8519
|
}
|
|
7884
|
-
if (matchesKey(data, "escape")
|
|
8520
|
+
if (readerClosesOnEscape(this.state) && (matchesKey(data, "escape") || typedText(data) === QUIT_KEY)) {
|
|
7885
8521
|
this.close("transcript");
|
|
7886
8522
|
return;
|
|
7887
8523
|
}
|
|
7888
8524
|
const intent = this.intentOf(data);
|
|
7889
8525
|
if (intent === void 0) return;
|
|
8526
|
+
const before = this.state.cursor;
|
|
7890
8527
|
this.state = reduceReader(this.state, intent, visible, geometry, blocks);
|
|
8528
|
+
if (intent.kind === "section" && !sameSection(before, this.state.cursor)) this.startReveal(this.state.cursor);
|
|
7891
8529
|
}
|
|
7892
8530
|
/** Close the reader from outside, which is what quitting and `Ctrl+C` do. */
|
|
7893
8531
|
withdraw() {
|
|
7894
8532
|
this.close("editor");
|
|
7895
8533
|
}
|
|
7896
8534
|
/**
|
|
8535
|
+
* Start a reveal, replacing the one in flight.
|
|
8536
|
+
* @param section - the one section it covers; undefined covers the whole turn.
|
|
8537
|
+
*/
|
|
8538
|
+
startReveal(section) {
|
|
8539
|
+
const clock = this.options.effects?.startReveal();
|
|
8540
|
+
if (clock === void 0) return;
|
|
8541
|
+
this.reveal = section === void 0 ? { clock } : {
|
|
8542
|
+
clock,
|
|
8543
|
+
section
|
|
8544
|
+
};
|
|
8545
|
+
}
|
|
8546
|
+
/**
|
|
8547
|
+
* The reveal as this render draws it.
|
|
8548
|
+
* @returns the age, the drawing settings, and the section it covers, or
|
|
8549
|
+
* undefined once it settled, which also forgets it.
|
|
8550
|
+
*/
|
|
8551
|
+
revealNow() {
|
|
8552
|
+
const reveal = this.reveal;
|
|
8553
|
+
const effects = this.options.effects;
|
|
8554
|
+
const age = reveal?.clock.age();
|
|
8555
|
+
if (reveal === void 0 || effects === void 0 || age === void 0) {
|
|
8556
|
+
this.reveal = void 0;
|
|
8557
|
+
return;
|
|
8558
|
+
}
|
|
8559
|
+
const style = effects.style();
|
|
8560
|
+
return reveal.section === void 0 ? {
|
|
8561
|
+
age,
|
|
8562
|
+
style
|
|
8563
|
+
} : {
|
|
8564
|
+
age,
|
|
8565
|
+
style,
|
|
8566
|
+
section: reveal.section
|
|
8567
|
+
};
|
|
8568
|
+
}
|
|
8569
|
+
/**
|
|
7897
8570
|
* The geometry of the frame as it stands.
|
|
7898
8571
|
* @param visible - the turns the rail lists.
|
|
7899
8572
|
* @param blocks - the navigable blocks.
|
|
@@ -7988,7 +8661,7 @@ function listIntent(data) {
|
|
|
7988
8661
|
kind: "column",
|
|
7989
8662
|
to: "pane"
|
|
7990
8663
|
};
|
|
7991
|
-
return
|
|
8664
|
+
return aliasOf(data, LIST_ALIASES);
|
|
7992
8665
|
}
|
|
7993
8666
|
/**
|
|
7994
8667
|
* What one key means while the turn panel owns the keyboard.
|
|
@@ -8024,6 +8697,17 @@ function paneIntent(data) {
|
|
|
8024
8697
|
kind: "column",
|
|
8025
8698
|
to: "list"
|
|
8026
8699
|
};
|
|
8700
|
+
return aliasOf(data, PANE_ALIASES);
|
|
8701
|
+
}
|
|
8702
|
+
/**
|
|
8703
|
+
* What one printable key means in a panel's alias table.
|
|
8704
|
+
* @param data - the raw key bytes.
|
|
8705
|
+
* @param aliases - the panel's printable keys.
|
|
8706
|
+
* @returns the intent, or undefined for a key the table names nothing for.
|
|
8707
|
+
*/
|
|
8708
|
+
function aliasOf(data, aliases) {
|
|
8709
|
+
const text = typedText(data);
|
|
8710
|
+
return text === void 0 ? void 0 : aliases.get(text);
|
|
8027
8711
|
}
|
|
8028
8712
|
//#endregion
|
|
8029
8713
|
//#region lib/types/highlight.js
|
|
@@ -9076,7 +9760,11 @@ const LOCAL_COMMANDS = [
|
|
|
9076
9760
|
},
|
|
9077
9761
|
{
|
|
9078
9762
|
name: "subagents",
|
|
9079
|
-
description: "Browse the subagent sessions under this session (Enter
|
|
9763
|
+
description: "Browse the subagent sessions under this session (Enter opens one as a live session view)"
|
|
9764
|
+
},
|
|
9765
|
+
{
|
|
9766
|
+
name: "parent",
|
|
9767
|
+
description: "Return from a subagent view to the session it was opened from"
|
|
9080
9768
|
},
|
|
9081
9769
|
{
|
|
9082
9770
|
name: "settings",
|
|
@@ -9244,6 +9932,8 @@ var TuiApp = class {
|
|
|
9244
9932
|
reasoningTail;
|
|
9245
9933
|
/** The card fades running right now; each drops itself once it settles. */
|
|
9246
9934
|
blockFades = new FadeRegistry();
|
|
9935
|
+
/** Streamed deltas waiting for a frame; absent when deltas are drawn as they arrive. */
|
|
9936
|
+
pacer;
|
|
9247
9937
|
/**
|
|
9248
9938
|
* The chrome motions running right now. It is consulted whatever the
|
|
9249
9939
|
* terminal draws, because a transient line has to come down again even on a
|
|
@@ -9282,6 +9972,11 @@ var TuiApp = class {
|
|
|
9282
9972
|
/** How streamed text is drawn; `none` until the background query settles. */
|
|
9283
9973
|
fadeStyle = NO_FADE;
|
|
9284
9974
|
bound;
|
|
9975
|
+
/**
|
|
9976
|
+
* The sessions a subagent view was entered from, root first; empty while
|
|
9977
|
+
* the root session is bound. `/parent` returns to the last one.
|
|
9978
|
+
*/
|
|
9979
|
+
parents = [];
|
|
9285
9980
|
streaming;
|
|
9286
9981
|
/** Whether the fold keys left every foldable block open; one appended later follows it. */
|
|
9287
9982
|
toolsExpanded = false;
|
|
@@ -9310,6 +10005,7 @@ var TuiApp = class {
|
|
|
9310
10005
|
this.deps = deps;
|
|
9311
10006
|
const palette = deps.palette;
|
|
9312
10007
|
this.bound = deps.initial;
|
|
10008
|
+
this.pacer = deps.reducedMotion || deps.streamPaceFrames === 0 ? void 0 : new StreamPacer({ drainFrames: deps.streamPaceFrames });
|
|
9313
10009
|
this.codeHighlight = new SyntaxHighlighter({
|
|
9314
10010
|
depth: deps.codeHighlight ? resolveColorDepth({
|
|
9315
10011
|
paletteEnabled: palette.enabled,
|
|
@@ -9361,6 +10057,7 @@ var TuiApp = class {
|
|
|
9361
10057
|
segments: this.segments,
|
|
9362
10058
|
render: {
|
|
9363
10059
|
palette: this.deps.palette,
|
|
10060
|
+
queue: this.queueView.length > 0,
|
|
9364
10061
|
...this.focus === "bar" ? {
|
|
9365
10062
|
selected: footerSelectionIndex(this.segments, this.barSelection),
|
|
9366
10063
|
level: this.markLift()
|
|
@@ -9499,7 +10196,13 @@ var TuiApp = class {
|
|
|
9499
10196
|
this.deps.terminal.write(SET_TERMINAL_DEFAULT_CURSOR);
|
|
9500
10197
|
this.tui.stop();
|
|
9501
10198
|
this.deps.releaseInput();
|
|
9502
|
-
this.
|
|
10199
|
+
const [root, ...views] = [...this.parents, this.bound];
|
|
10200
|
+
for (const view of views.reverse()) view.dispose().catch((error) => {
|
|
10201
|
+
this.deps.terminal.write(`releasing a subagent view failed: ${describeFailure(error)}\n`);
|
|
10202
|
+
});
|
|
10203
|
+
this.parents.length = 0;
|
|
10204
|
+
/* v8 ignore next -- the destructured list always holds the bound session */
|
|
10205
|
+
this.deps.onQuit(root ?? this.bound);
|
|
9503
10206
|
}
|
|
9504
10207
|
/** Draw `next` as the terminal's session: clear the transcript and replay its history. */
|
|
9505
10208
|
bind(next) {
|
|
@@ -9524,6 +10227,7 @@ var TuiApp = class {
|
|
|
9524
10227
|
this.turn = 0;
|
|
9525
10228
|
this.sawSystemPrompt = false;
|
|
9526
10229
|
this.turnStartedAt = void 0;
|
|
10230
|
+
this.pacer?.clear();
|
|
9527
10231
|
this.streaming = void 0;
|
|
9528
10232
|
this.endFade();
|
|
9529
10233
|
this.blockFades.clear();
|
|
@@ -9554,7 +10258,7 @@ var TuiApp = class {
|
|
|
9554
10258
|
* @param verb - what the notice calls the move.
|
|
9555
10259
|
*/
|
|
9556
10260
|
async switchSession(open, verb) {
|
|
9557
|
-
if (this.agent.status === "running") {
|
|
10261
|
+
if ([this.bound, ...this.parents].some((bound) => bound.agent.status === "running")) {
|
|
9558
10262
|
this.notice("stop the running turn (Esc twice) before switching sessions", "error");
|
|
9559
10263
|
return;
|
|
9560
10264
|
}
|
|
@@ -9573,17 +10277,94 @@ var TuiApp = class {
|
|
|
9573
10277
|
await next.dispose();
|
|
9574
10278
|
return;
|
|
9575
10279
|
}
|
|
9576
|
-
const
|
|
10280
|
+
const released = [this.bound, ...this.parents.splice(0).reverse()];
|
|
9577
10281
|
const dropped = this.pending.length;
|
|
9578
10282
|
this.bind(next);
|
|
9579
10283
|
this.notice(`${verb}: session ${next.agent.session.id}`, "success");
|
|
9580
10284
|
if (dropped > 0) this.notice(`${String(dropped)} pending attachment(s) stayed with the previous session`);
|
|
9581
|
-
try {
|
|
10285
|
+
for (const previous of released) try {
|
|
9582
10286
|
await previous.dispose();
|
|
9583
10287
|
} catch (error) {
|
|
9584
10288
|
this.notice(`releasing the previous session failed: ${describeFailure(error)}`, "error");
|
|
9585
10289
|
}
|
|
9586
10290
|
}
|
|
10291
|
+
/**
|
|
10292
|
+
* Draw one subagent session in place of the bound one, keeping the bound
|
|
10293
|
+
* one alive to return to: the whole conversation surface - the live
|
|
10294
|
+
* transcript, the conversation walk, the inspector, the reader, and that
|
|
10295
|
+
* session's own subagents - then reads the child. The entry's detail rows
|
|
10296
|
+
* follow the entry notice.
|
|
10297
|
+
* @param id - the subagent session.
|
|
10298
|
+
* @param row - the listing entry, for its label and detail rows.
|
|
10299
|
+
*/
|
|
10300
|
+
async enterSubagent(id, row) {
|
|
10301
|
+
if (this.switching) {
|
|
10302
|
+
this.notice("wait for the session switch to finish", "error");
|
|
10303
|
+
return;
|
|
10304
|
+
}
|
|
10305
|
+
this.switching = true;
|
|
10306
|
+
let next;
|
|
10307
|
+
try {
|
|
10308
|
+
next = await this.deps.host.observe(id);
|
|
10309
|
+
} catch (error) {
|
|
10310
|
+
this.switching = false;
|
|
10311
|
+
this.notice(`opening subagent ${id} failed: ${describeFailure(error)}`, "error");
|
|
10312
|
+
return;
|
|
10313
|
+
}
|
|
10314
|
+
this.switching = false;
|
|
10315
|
+
if (this.stopped) {
|
|
10316
|
+
await next.dispose();
|
|
10317
|
+
return;
|
|
10318
|
+
}
|
|
10319
|
+
const parent = this.bound;
|
|
10320
|
+
const dropped = this.pending.length;
|
|
10321
|
+
this.parents.push(parent);
|
|
10322
|
+
this.bind(next);
|
|
10323
|
+
this.notice(`subagent ${row.item.label} · Ctrl+P or /parent returns to session ${parent.agent.session.id}`, "success");
|
|
10324
|
+
if (dropped > 0) this.notice(`${String(dropped)} pending attachment(s) stayed with the parent session`);
|
|
10325
|
+
for (const line of await this.detailRows(row)) this.notice(line);
|
|
10326
|
+
}
|
|
10327
|
+
/**
|
|
10328
|
+
* Return from a subagent view to the session it was entered from, drawn
|
|
10329
|
+
* from its log as it stands now, and release the view.
|
|
10330
|
+
*/
|
|
10331
|
+
async leaveSubagent() {
|
|
10332
|
+
const parent = this.parents.at(-1);
|
|
10333
|
+
if (parent === void 0) {
|
|
10334
|
+
this.notice("this is the root session; /parent returns from a subagent view", "error");
|
|
10335
|
+
return;
|
|
10336
|
+
}
|
|
10337
|
+
if (this.switching) {
|
|
10338
|
+
this.notice("wait for the session switch to finish", "error");
|
|
10339
|
+
return;
|
|
10340
|
+
}
|
|
10341
|
+
this.switching = true;
|
|
10342
|
+
let history;
|
|
10343
|
+
try {
|
|
10344
|
+
const observed = await this.deps.host.observe(parent.agent.session.id);
|
|
10345
|
+
history = observed.history;
|
|
10346
|
+
await observed.dispose();
|
|
10347
|
+
} catch (error) {
|
|
10348
|
+
this.switching = false;
|
|
10349
|
+
this.notice(`returning to session ${parent.agent.session.id} failed: ${describeFailure(error)}`, "error");
|
|
10350
|
+
return;
|
|
10351
|
+
}
|
|
10352
|
+
this.switching = false;
|
|
10353
|
+
/* v8 ignore next -- quitting releases every view before a pending return settles */
|
|
10354
|
+
if (this.stopped) return;
|
|
10355
|
+
const view = this.bound;
|
|
10356
|
+
this.parents.pop();
|
|
10357
|
+
this.bind({
|
|
10358
|
+
...parent,
|
|
10359
|
+
history
|
|
10360
|
+
});
|
|
10361
|
+
this.notice(`back in session ${parent.agent.session.id}`, "success");
|
|
10362
|
+
try {
|
|
10363
|
+
await view.dispose();
|
|
10364
|
+
} catch (error) {
|
|
10365
|
+
this.notice(`releasing the subagent view failed: ${describeFailure(error)}`, "error");
|
|
10366
|
+
}
|
|
10367
|
+
}
|
|
9587
10368
|
completableCommands() {
|
|
9588
10369
|
const shared = (this.deps.ctx.get("commands")?.list(this.agent) ?? []).filter((command) => !LOCAL_COMMAND_NAMES.has(command.name));
|
|
9589
10370
|
return [...LOCAL_COMMANDS, ...shared.map((command) => ({
|
|
@@ -9650,7 +10431,8 @@ var TuiApp = class {
|
|
|
9650
10431
|
const session = this.agent.session;
|
|
9651
10432
|
const title = this.deps.ctx.get("sessionTitle")?.get(session)?.title;
|
|
9652
10433
|
const name = title === void 0 ? `session ${session.id}` : `${title} ${palette.dim(`(${session.id})`)}`;
|
|
9653
|
-
this.
|
|
10434
|
+
const trail = this.parents.length === 0 ? palette.dim("· /help for commands") : `${palette.accent(`◆ subagent view ${"›".repeat(this.parents.length)}`)} ${palette.dim("· Ctrl+P returns")}`;
|
|
10435
|
+
this.header.setText(`${palette.bold(palette.accent("dsh"))} ${palette.dim("·")} ${name} ${trail}`);
|
|
9654
10436
|
this.tui.requestRender();
|
|
9655
10437
|
}
|
|
9656
10438
|
refreshFooter() {
|
|
@@ -10214,6 +10996,28 @@ var TuiApp = class {
|
|
|
10214
10996
|
this.notice("usage: /plugins · /plugins bundles · /plugins enable|disable <entry id or bundle> · /plugins add <spec> · /plugins remove <bundle>", "error");
|
|
10215
10997
|
}
|
|
10216
10998
|
/**
|
|
10999
|
+
* Walk the subagent listing: `Enter` on a session opens it as a live view,
|
|
11000
|
+
* and on a row the listing could not read shows why, then reopens the list
|
|
11001
|
+
* on that row.
|
|
11002
|
+
* @param choices - the listing rows, in listing order.
|
|
11003
|
+
*/
|
|
11004
|
+
async browseSubagents(choices) {
|
|
11005
|
+
const rows = choices.map((choice) => this.subagentBrowseRow(choice));
|
|
11006
|
+
let visited;
|
|
11007
|
+
for (;;) {
|
|
11008
|
+
const picked = await this.showModal(new PickPrompt(this.deps.palette, "Subagent sessions", rows.map((row) => row.item), { ...visited === void 0 ? {} : { current: visited } }));
|
|
11009
|
+
const index = rows.findIndex((candidate) => candidate.item.value === picked?.value);
|
|
11010
|
+
const [choice, row] = [choices[index], rows[index]];
|
|
11011
|
+
if (choice === void 0 || row === void 0) return;
|
|
11012
|
+
if (choice.enterable) {
|
|
11013
|
+
await this.enterSubagent(choice.id, row);
|
|
11014
|
+
return;
|
|
11015
|
+
}
|
|
11016
|
+
visited = choice.id;
|
|
11017
|
+
await this.showDetail(row);
|
|
11018
|
+
}
|
|
11019
|
+
}
|
|
11020
|
+
/**
|
|
10217
11021
|
* The browsable entry behind one subagent row: the same detail page the
|
|
10218
11022
|
* `/subagents` list and the live panel open.
|
|
10219
11023
|
* @param choice - the listing row.
|
|
@@ -10231,9 +11035,9 @@ var TuiApp = class {
|
|
|
10231
11035
|
};
|
|
10232
11036
|
}
|
|
10233
11037
|
/**
|
|
10234
|
-
* Open the selected panel row
|
|
10235
|
-
*
|
|
10236
|
-
*
|
|
11038
|
+
* Open the selected panel row as a subagent view, which hands the keyboard
|
|
11039
|
+
* to the input of that view. A diagnostic row explains itself in the panel
|
|
11040
|
+
* and opens nothing.
|
|
10237
11041
|
*/
|
|
10238
11042
|
async openPanelRow() {
|
|
10239
11043
|
const rows = this.panelView.rows;
|
|
@@ -10244,8 +11048,7 @@ var TuiApp = class {
|
|
|
10244
11048
|
const entry = this.subagentEntries.find((candidate) => candidate.id === row.id);
|
|
10245
11049
|
/* v8 ignore next -- every drawn row comes from the entries of the last listing */
|
|
10246
11050
|
if (entry === void 0) return;
|
|
10247
|
-
await this.
|
|
10248
|
-
if (this.panelView.rows.length > 0) this.focusRegion("panel");
|
|
11051
|
+
await this.enterSubagent(entry.id, this.subagentBrowseRow(subagentChoice(entry)));
|
|
10249
11052
|
}
|
|
10250
11053
|
async settings(argument) {
|
|
10251
11054
|
const [first, second, ...rest] = argument === "" ? [] : argument.split(/\s+/u);
|
|
@@ -10355,7 +11158,8 @@ var TuiApp = class {
|
|
|
10355
11158
|
else this.focusBar();
|
|
10356
11159
|
return { consume: true };
|
|
10357
11160
|
case "leave":
|
|
10358
|
-
if (action.direction === "down") this.focusBelowEditor();
|
|
11161
|
+
if (this.focus === "editor") if (action.direction === "down") this.focusBelowEditor();
|
|
11162
|
+
else this.focusAboveEditor();
|
|
10359
11163
|
else this.focusAboveBar();
|
|
10360
11164
|
return { consume: true };
|
|
10361
11165
|
case "cycle":
|
|
@@ -10392,6 +11196,21 @@ var TuiApp = class {
|
|
|
10392
11196
|
}
|
|
10393
11197
|
this.dispatchCommand("/effort");
|
|
10394
11198
|
return { consume: true };
|
|
11199
|
+
case "todos":
|
|
11200
|
+
this.focusEditor();
|
|
11201
|
+
this.dispatchCommand("/todos");
|
|
11202
|
+
return { consume: true };
|
|
11203
|
+
case "parent":
|
|
11204
|
+
this.focusEditor();
|
|
11205
|
+
this.leaveSubagent();
|
|
11206
|
+
return { consume: true };
|
|
11207
|
+
case "help":
|
|
11208
|
+
if (this.editor.getText() !== "") return void 0;
|
|
11209
|
+
this.dispatchCommand("/help");
|
|
11210
|
+
return { consume: true };
|
|
11211
|
+
case "redraw":
|
|
11212
|
+
this.tui.requestRender(true);
|
|
11213
|
+
return { consume: true };
|
|
10395
11214
|
case "type":
|
|
10396
11215
|
this.focusEditor();
|
|
10397
11216
|
this.editor.handleInput(data);
|
|
@@ -10526,6 +11345,11 @@ var TuiApp = class {
|
|
|
10526
11345
|
rows: () => Math.max(1, this.deps.terminal.rows),
|
|
10527
11346
|
minColumns: this.deps.readerMinColumns,
|
|
10528
11347
|
cursor,
|
|
11348
|
+
effects: {
|
|
11349
|
+
style: () => this.fadeStyle,
|
|
11350
|
+
background: () => this.background,
|
|
11351
|
+
startReveal: () => this.startReaderReveal()
|
|
11352
|
+
},
|
|
10529
11353
|
onExit: (exit) => {
|
|
10530
11354
|
this.closeReader(exit);
|
|
10531
11355
|
}
|
|
@@ -10534,6 +11358,24 @@ var TuiApp = class {
|
|
|
10534
11358
|
this.showReader();
|
|
10535
11359
|
}
|
|
10536
11360
|
/**
|
|
11361
|
+
* Start one reveal of the reader on the application's fade tick, which
|
|
11362
|
+
* repaints the reader until the reveal settles. A terminal that runs no
|
|
11363
|
+
* motion reveals nothing, and the reader draws its settled rows.
|
|
11364
|
+
* @returns the reveal's clock, or undefined on a terminal that runs no motion.
|
|
11365
|
+
*/
|
|
11366
|
+
startReaderReveal() {
|
|
11367
|
+
if (!this.fading) return void 0;
|
|
11368
|
+
const clock = new BlockFadeClock({
|
|
11369
|
+
bornAt: this.deps.now(),
|
|
11370
|
+
stepMs: this.deps.fadeStepMs,
|
|
11371
|
+
steps: this.deps.fadeSteps,
|
|
11372
|
+
now: () => this.deps.now()
|
|
11373
|
+
});
|
|
11374
|
+
this.motions.add(clock);
|
|
11375
|
+
this.updateFadeTicker();
|
|
11376
|
+
return clock;
|
|
11377
|
+
}
|
|
11378
|
+
/**
|
|
10537
11379
|
* Put the open reader on the terminal: settle the conversation, hold the
|
|
10538
11380
|
* main screen off the terminal, and draw the reader on the alternate one.
|
|
10539
11381
|
*
|
|
@@ -10779,7 +11621,7 @@ var TuiApp = class {
|
|
|
10779
11621
|
const next = this.segments[barTarget(to, footerSelectionIndex(this.segments, this.barSelection), count)];
|
|
10780
11622
|
/* v8 ignore next -- the wrapped index stays inside the bar's own segments */
|
|
10781
11623
|
if (next !== void 0) this.barSelection = next.id;
|
|
10782
|
-
this.startChrome("selection",
|
|
11624
|
+
this.startChrome("selection", 8);
|
|
10783
11625
|
this.refreshFooter();
|
|
10784
11626
|
}
|
|
10785
11627
|
/**
|
|
@@ -10803,7 +11645,7 @@ var TuiApp = class {
|
|
|
10803
11645
|
this.focusRegion("bar");
|
|
10804
11646
|
return;
|
|
10805
11647
|
}
|
|
10806
|
-
this.startChrome("selection",
|
|
11648
|
+
this.startChrome("selection", 8);
|
|
10807
11649
|
this.refreshFooter();
|
|
10808
11650
|
}
|
|
10809
11651
|
/** Give the keyboard to the queued-prompt panel on one of its rows. */
|
|
@@ -10820,12 +11662,18 @@ var TuiApp = class {
|
|
|
10820
11662
|
this.focusRegion("panel");
|
|
10821
11663
|
}
|
|
10822
11664
|
/**
|
|
10823
|
-
* Give `Shift+
|
|
10824
|
-
*
|
|
11665
|
+
* Give `Shift+Up` to the pending-prompt panel when it is drawn, then the
|
|
11666
|
+
* conversation above the editor.
|
|
10825
11667
|
*/
|
|
10826
|
-
|
|
11668
|
+
focusAboveEditor() {
|
|
10827
11669
|
if (this.queueView.length > 0) this.focusQueue(0);
|
|
10828
|
-
else
|
|
11670
|
+
else this.focusTranscript();
|
|
11671
|
+
}
|
|
11672
|
+
/**
|
|
11673
|
+
* Give `Shift+Down` to the first region below the editor.
|
|
11674
|
+
*/
|
|
11675
|
+
focusBelowEditor() {
|
|
11676
|
+
if (this.panelView.rows.length > 0) this.focusPanel(0);
|
|
10829
11677
|
else this.focusBar();
|
|
10830
11678
|
}
|
|
10831
11679
|
/**
|
|
@@ -10897,7 +11745,7 @@ var TuiApp = class {
|
|
|
10897
11745
|
*/
|
|
10898
11746
|
moveCursor(cursor) {
|
|
10899
11747
|
this.cursor = cursor;
|
|
10900
|
-
this.startChrome("selection",
|
|
11748
|
+
this.startChrome("selection", 6);
|
|
10901
11749
|
this.tui.requestRender();
|
|
10902
11750
|
}
|
|
10903
11751
|
/**
|
|
@@ -10968,7 +11816,7 @@ var TuiApp = class {
|
|
|
10968
11816
|
*/
|
|
10969
11817
|
setFocus(region) {
|
|
10970
11818
|
if (region === "editor") this.chrome = void 0;
|
|
10971
|
-
else this.startChrome("landing",
|
|
11819
|
+
else this.startChrome("landing", 12);
|
|
10972
11820
|
this.focus = region;
|
|
10973
11821
|
if (this.reader === void 0) this.tui.setFocus(region === "editor" ? this.editor : null);
|
|
10974
11822
|
this.refreshFooter();
|
|
@@ -11273,9 +12121,12 @@ var TuiApp = class {
|
|
|
11273
12121
|
this.notice("no subagent sessions");
|
|
11274
12122
|
return;
|
|
11275
12123
|
}
|
|
11276
|
-
await this.
|
|
12124
|
+
await this.browseSubagents(choices);
|
|
11277
12125
|
return;
|
|
11278
12126
|
}
|
|
12127
|
+
case "parent":
|
|
12128
|
+
await this.leaveSubagent();
|
|
12129
|
+
return;
|
|
11279
12130
|
case "settings":
|
|
11280
12131
|
await this.settings(argument);
|
|
11281
12132
|
return;
|
|
@@ -11863,6 +12714,22 @@ var TuiApp = class {
|
|
|
11863
12714
|
return this.streaming;
|
|
11864
12715
|
}
|
|
11865
12716
|
/**
|
|
12717
|
+
* Hand one live-stream delta to the transcript: through the pacer, which
|
|
12718
|
+
* releases it on a later frame, or at once when deltas are not paced.
|
|
12719
|
+
* @param channel - what the delta belongs to; consecutive deltas of one
|
|
12720
|
+
* channel release through the first delta's `release`.
|
|
12721
|
+
* @param text - the delta.
|
|
12722
|
+
* @param release - draws a released part of the delta.
|
|
12723
|
+
*/
|
|
12724
|
+
pace(channel, text, release) {
|
|
12725
|
+
if (this.pacer === void 0) {
|
|
12726
|
+
release(text);
|
|
12727
|
+
return;
|
|
12728
|
+
}
|
|
12729
|
+
this.pacer.push(channel, text, release);
|
|
12730
|
+
this.updateFadeTicker();
|
|
12731
|
+
}
|
|
12732
|
+
/**
|
|
11866
12733
|
* Take one visible text delta: the block draws it and the tail of that same
|
|
11867
12734
|
* block ages it. The tail is created with the first delta of a message, so
|
|
11868
12735
|
* a block rebuilt from history or committed from the log never carries one.
|
|
@@ -12053,7 +12920,7 @@ var TuiApp = class {
|
|
|
12053
12920
|
* @returns true while a tail or a card fade keeps changing what is drawn.
|
|
12054
12921
|
*/
|
|
12055
12922
|
fadesMoving() {
|
|
12056
|
-
return this.textTail?.needsRepaint() === true || this.reasoningTail?.needsRepaint() === true || this.blockFades.needsRepaint() || this.motions.needsRepaint();
|
|
12923
|
+
return this.pacer?.pending() === true || this.textTail?.needsRepaint() === true || this.reasoningTail?.needsRepaint() === true || this.blockFades.needsRepaint() || this.motions.needsRepaint();
|
|
12057
12924
|
}
|
|
12058
12925
|
/**
|
|
12059
12926
|
* Apply everything the frame's geometry decides, on the frame that was just
|
|
@@ -12109,6 +12976,7 @@ var TuiApp = class {
|
|
|
12109
12976
|
* levels the elapsed time asks for however long the period itself ran.
|
|
12110
12977
|
*/
|
|
12111
12978
|
onFadeTick() {
|
|
12979
|
+
this.pacer?.frame();
|
|
12112
12980
|
this.textTail?.tick();
|
|
12113
12981
|
this.reasoningTail?.tick();
|
|
12114
12982
|
this.blockFades.tick();
|
|
@@ -12122,6 +12990,7 @@ var TuiApp = class {
|
|
|
12122
12990
|
onStreamFrame(frame) {
|
|
12123
12991
|
switch (frame.type) {
|
|
12124
12992
|
case "start":
|
|
12993
|
+
this.pacer?.flush();
|
|
12125
12994
|
this.streaming = void 0;
|
|
12126
12995
|
this.endFade();
|
|
12127
12996
|
this.beginLiveUsage();
|
|
@@ -12132,20 +13001,29 @@ var TuiApp = class {
|
|
|
12132
13001
|
switch (chunk.type) {
|
|
12133
13002
|
case "text-delta":
|
|
12134
13003
|
if (chunk.text !== "") {
|
|
12135
|
-
this.
|
|
13004
|
+
this.pace("text", chunk.text, (text) => {
|
|
13005
|
+
this.appendStreamedText(text);
|
|
13006
|
+
this.setStreamActivity("writing");
|
|
13007
|
+
});
|
|
12136
13008
|
this.noteStreamedChars(chunk.text.length);
|
|
12137
|
-
this.setStreamActivity("writing");
|
|
12138
13009
|
}
|
|
12139
13010
|
break;
|
|
12140
13011
|
case "reasoning-delta":
|
|
12141
13012
|
if (chunk.text !== "") {
|
|
12142
|
-
this.
|
|
13013
|
+
this.pace("reasoning", chunk.text, (text) => {
|
|
13014
|
+
this.appendStreamedReasoning(text);
|
|
13015
|
+
this.setStreamActivity("thinking");
|
|
13016
|
+
});
|
|
12143
13017
|
this.noteStreamedChars(chunk.text.length);
|
|
12144
|
-
this.setStreamActivity("thinking");
|
|
12145
13018
|
}
|
|
12146
13019
|
break;
|
|
12147
13020
|
case "tool-call-delta":
|
|
12148
|
-
this.
|
|
13021
|
+
this.pace(`tool:${chunk.id}:${chunk.name ?? ""}`, chunk.argumentsDelta, (text) => {
|
|
13022
|
+
this.onToolCallDelta({
|
|
13023
|
+
...chunk,
|
|
13024
|
+
argumentsDelta: text
|
|
13025
|
+
});
|
|
13026
|
+
});
|
|
12149
13027
|
this.noteStreamedChars(chunk.argumentsDelta.length);
|
|
12150
13028
|
break;
|
|
12151
13029
|
case "usage":
|
|
@@ -12157,10 +13035,11 @@ var TuiApp = class {
|
|
|
12157
13035
|
/* v8 ignore next -- closed-union exhaustiveness guard */
|
|
12158
13036
|
default: assertNever(chunk, "tui stream chunk");
|
|
12159
13037
|
}
|
|
12160
|
-
this.tui.requestRender();
|
|
13038
|
+
if (this.pacer === void 0) this.tui.requestRender();
|
|
12161
13039
|
return;
|
|
12162
13040
|
}
|
|
12163
13041
|
case "end":
|
|
13042
|
+
this.pacer?.flush();
|
|
12164
13043
|
this.streaming = void 0;
|
|
12165
13044
|
this.endFade();
|
|
12166
13045
|
if (frame.outcome.kind === "abandoned" || frame.outcome.kind === "committed" && frame.outcome.eventType === "assistant/attempt") this.dropUnconfirmedTools();
|
|
@@ -12176,6 +13055,7 @@ var TuiApp = class {
|
|
|
12176
13055
|
if (this.isBoundDescendant(session)) this.onDescendantActivity(session, event);
|
|
12177
13056
|
return;
|
|
12178
13057
|
}
|
|
13058
|
+
this.pacer?.flush();
|
|
12179
13059
|
switch (event.type) {
|
|
12180
13060
|
case "turn/start":
|
|
12181
13061
|
this.turn = event.data.turn;
|
|
@@ -12220,7 +13100,7 @@ var TuiApp = class {
|
|
|
12220
13100
|
if (block === void 0) break;
|
|
12221
13101
|
const isError = result.isError === true;
|
|
12222
13102
|
const body = toolResultBody(this.presentResult(block.name, this.toolArguments.get(result.toolCallId), result.content, isError, event.data.meta), result.content);
|
|
12223
|
-
block.setResult(body.lines, isError, body.code);
|
|
13103
|
+
block.setResult(body.lines, isError, body.code, body.diff);
|
|
12224
13104
|
this.fadeBlock((fade) => {
|
|
12225
13105
|
block.setResultFade(fade);
|
|
12226
13106
|
});
|
|
@@ -12451,10 +13331,12 @@ var TuiApp = class {
|
|
|
12451
13331
|
const existing = this.toolBlocks.get(callId);
|
|
12452
13332
|
if (existing !== void 0) {
|
|
12453
13333
|
existing.setCall(name, call);
|
|
13334
|
+
if (isSubagentTool(name)) existing.setSubagent(subagentRowFacts(args));
|
|
12454
13335
|
if (source === "log") this.unconfirmedTools.delete(callId);
|
|
12455
13336
|
return;
|
|
12456
13337
|
}
|
|
12457
13338
|
const block = new ToolBlock(this.theme, name, call, this.turn);
|
|
13339
|
+
if (isSubagentTool(name)) block.setSubagent(subagentRowFacts(args));
|
|
12458
13340
|
block.setExpanded(this.toolsExpanded);
|
|
12459
13341
|
this.toolBlocks.set(callId, block);
|
|
12460
13342
|
this.chat.addChild(block);
|
|
@@ -12590,8 +13472,9 @@ const Config = z.object({
|
|
|
12590
13472
|
codeHighlight: z.boolean().default(true),
|
|
12591
13473
|
toastMs: z.natural().min(500).default(TOAST_MS),
|
|
12592
13474
|
liveRefreshMs: z.natural().min(100).default(1e3),
|
|
12593
|
-
streamFadeSteps: z.natural().min(2).default(
|
|
12594
|
-
streamFadeStepMs: z.natural().min(16).default(
|
|
13475
|
+
streamFadeSteps: z.natural().min(2).default(24),
|
|
13476
|
+
streamFadeStepMs: z.natural().min(16).default(16),
|
|
13477
|
+
streamPaceFrames: z.natural().default(8),
|
|
12595
13478
|
reducedMotion: z.boolean().default(false),
|
|
12596
13479
|
openBrowser: z.boolean().default(true)
|
|
12597
13480
|
});
|
|
@@ -12729,28 +13612,42 @@ function sessionHost(ctx, core, cwd) {
|
|
|
12729
13612
|
setup
|
|
12730
13613
|
});
|
|
12731
13614
|
}, seed ?? []);
|
|
13615
|
+
const resume = async (id) => {
|
|
13616
|
+
const selection = {
|
|
13617
|
+
current: void 0,
|
|
13618
|
+
assembled: void 0
|
|
13619
|
+
};
|
|
13620
|
+
const handle = await agents.resume({
|
|
13621
|
+
resumeSessionId: id,
|
|
13622
|
+
setup: (agentCtx) => {
|
|
13623
|
+
installModelSelection(agentCtx, selection);
|
|
13624
|
+
}
|
|
13625
|
+
});
|
|
13626
|
+
await handle.agent.whenIdle();
|
|
13627
|
+
return {
|
|
13628
|
+
agent: handle.agent,
|
|
13629
|
+
selection,
|
|
13630
|
+
history: await observeBoundHistory(ctx, id),
|
|
13631
|
+
dispose: () => handle.dispose()
|
|
13632
|
+
};
|
|
13633
|
+
};
|
|
12732
13634
|
return {
|
|
12733
13635
|
create: () => create(void 0, void 0),
|
|
12734
|
-
resume
|
|
12735
|
-
|
|
12736
|
-
|
|
12737
|
-
|
|
12738
|
-
|
|
12739
|
-
const handle = await agents.resume({
|
|
12740
|
-
resumeSessionId: id,
|
|
12741
|
-
setup: (agentCtx) => {
|
|
12742
|
-
installModelSelection(agentCtx, selection);
|
|
12743
|
-
}
|
|
12744
|
-
});
|
|
12745
|
-
await handle.agent.whenIdle();
|
|
13636
|
+
resume,
|
|
13637
|
+
fork: async (id, turn) => create(await forkSeed(ctx, id, turn), id),
|
|
13638
|
+
observe: async (id) => {
|
|
13639
|
+
const resident = agents.get(id);
|
|
13640
|
+
if (resident === void 0) return resume(id);
|
|
12746
13641
|
return {
|
|
12747
|
-
agent:
|
|
12748
|
-
selection
|
|
13642
|
+
agent: resident,
|
|
13643
|
+
selection: {
|
|
13644
|
+
current: void 0,
|
|
13645
|
+
assembled: void 0
|
|
13646
|
+
},
|
|
12749
13647
|
history: await observeBoundHistory(ctx, id),
|
|
12750
|
-
dispose: () =>
|
|
13648
|
+
dispose: () => Promise.resolve()
|
|
12751
13649
|
};
|
|
12752
|
-
}
|
|
12753
|
-
fork: async (id, turn) => create(await forkSeed(ctx, id, turn), id)
|
|
13650
|
+
}
|
|
12754
13651
|
};
|
|
12755
13652
|
}
|
|
12756
13653
|
/** Report an unexpected runner failure and request a failing exit. */
|
|
@@ -12788,6 +13685,7 @@ async function run(ctx, config, host) {
|
|
|
12788
13685
|
liveRefreshMs: config.liveRefreshMs,
|
|
12789
13686
|
fadeSteps: config.streamFadeSteps,
|
|
12790
13687
|
fadeStepMs: config.streamFadeStepMs,
|
|
13688
|
+
streamPaceFrames: config.streamPaceFrames,
|
|
12791
13689
|
reducedMotion: config.reducedMotion,
|
|
12792
13690
|
env: process.env,
|
|
12793
13691
|
now: () => Date.now(),
|