diff --git a/examples/repl-bench/journeys/conversation.test.md b/examples/repl-bench/journeys/conversation.test.md
index bf89235e0..9f79b99d6 100644
--- a/examples/repl-bench/journeys/conversation.test.md
+++ b/examples/repl-bench/journeys/conversation.test.md
@@ -51,10 +51,11 @@
-
+
+
-
+
diff --git a/examples/repl-bench/journeys/focus-hints.test.md b/examples/repl-bench/journeys/focus-hints.test.md
index 51fb43125..9beefea8a 100644
--- a/examples/repl-bench/journeys/focus-hints.test.md
+++ b/examples/repl-bench/journeys/focus-hints.test.md
@@ -11,7 +11,8 @@ Run this acceptance document with the REPL Bench plugin. The expected screens ar
-
+
+
@@ -26,7 +27,7 @@ Run this acceptance document with the REPL Bench plugin. The expected screens ar
-
+
diff --git a/examples/repl-bench/journeys/repl-bench.test.md b/examples/repl-bench/journeys/repl-bench.test.md
index 8e08194ff..f2baf92d9 100644
--- a/examples/repl-bench/journeys/repl-bench.test.md
+++ b/examples/repl-bench/journeys/repl-bench.test.md
@@ -1,6 +1,7 @@
+
@@ -52,8 +53,10 @@
scoped-repl-fixture
+
\n\n\nDir {basename}\n\n'} />
+
@@ -64,10 +67,12 @@
-
+
+
+
@@ -81,14 +86,11 @@
-
+
+
-
-
-
-
-
+
@@ -98,13 +100,13 @@
-
-
+
+
-
-
+
+
@@ -115,15 +117,13 @@
+
+
-
-
-
-
-
+
@@ -142,7 +142,8 @@
-
+
+
@@ -151,7 +152,8 @@
-
+
+
@@ -160,7 +162,7 @@
-
+
@@ -168,22 +170,23 @@
-
+
+
-
-
+
+
-
+
-
-
+
+
@@ -195,12 +198,12 @@
-
+
+
+
-
-
-
+
diff --git a/examples/repl-bench/journeys/repl-command-output.test.md b/examples/repl-bench/journeys/repl-command-output.test.md
index 519526bf9..c9811d8f9 100644
--- a/examples/repl-bench/journeys/repl-command-output.test.md
+++ b/examples/repl-bench/journeys/repl-command-output.test.md
@@ -46,8 +46,11 @@ printf 'hidden-%s\n' stderr >&2
+
+
+
diff --git a/examples/repl-bench/journeys/repl-focus-shortcuts.test.md b/examples/repl-bench/journeys/repl-focus-shortcuts.test.md
index 5f7fb79b0..64b659c11 100644
--- a/examples/repl-bench/journeys/repl-focus-shortcuts.test.md
+++ b/examples/repl-bench/journeys/repl-focus-shortcuts.test.md
@@ -16,15 +16,16 @@
-
+
+
-
+
-
+
@@ -47,7 +48,8 @@
-
+
+
@@ -79,7 +81,7 @@
-
+
@@ -93,7 +95,7 @@
-
+
@@ -107,7 +109,7 @@
-
+
diff --git a/examples/repl-bench/journeys/repl-include-mount.test.md b/examples/repl-bench/journeys/repl-include-mount.test.md
index 6dc025c38..5d00b86e9 100644
--- a/examples/repl-bench/journeys/repl-include-mount.test.md
+++ b/examples/repl-bench/journeys/repl-include-mount.test.md
@@ -21,27 +21,39 @@ External-only rendered.
+
\n"} />
+
+
+
+
+
+
+
+
".split("")} let="character">
+
+
+
".split("")} let="character">
@@ -74,8 +86,11 @@ External-only rendered.
Second greeting rendered.
+
+
+
@@ -84,8 +99,11 @@ External-only rendered.
+
\n"} />
+
+
@@ -140,8 +158,11 @@ pwd -P | tr -d '\n' > process-cwd.txt
+
\n"+fixtureBody+"\n\n\n\n"+body+"\n"} />
+
+
@@ -195,8 +216,11 @@ fresh is {fresh}
```
+
\n"+freshBody+"\n"} />
+
+
diff --git a/examples/repl-bench/journeys/repl-scripted-sidekick.test.md b/examples/repl-bench/journeys/repl-scripted-sidekick.test.md
index 0074edf16..84b6340d0 100644
--- a/examples/repl-bench/journeys/repl-scripted-sidekick.test.md
+++ b/examples/repl-bench/journeys/repl-scripted-sidekick.test.md
@@ -86,11 +86,14 @@
-
+
+
"Bg row "+row).join("\n") : ''} />
+
+
diff --git a/examples/repl-bench/journeys/repl-shared-terminal.test.md b/examples/repl-bench/journeys/repl-shared-terminal.test.md
index f5ab6f605..8da0b51a3 100644
--- a/examples/repl-bench/journeys/repl-shared-terminal.test.md
+++ b/examples/repl-bench/journeys/repl-shared-terminal.test.md
@@ -3,8 +3,11 @@
+
+
+
diff --git a/examples/repl-bench/journeys/repl-wheel-permission.test.md b/examples/repl-bench/journeys/repl-wheel-permission.test.md
index cd89fb004..685fcf6cf 100644
--- a/examples/repl-bench/journeys/repl-wheel-permission.test.md
+++ b/examples/repl-bench/journeys/repl-wheel-permission.test.md
@@ -1,8 +1,11 @@
+
'} />
-
+
+
+
diff --git a/examples/repl-bench/journeys/round-editor.test.md b/examples/repl-bench/journeys/round-editor.test.md
new file mode 100644
index 000000000..28be4a8de
--- /dev/null
+++ b/examples/repl-bench/journeys/round-editor.test.md
@@ -0,0 +1,69 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/examples/repl-bench/journeys/timeout-controls.md b/examples/repl-bench/journeys/timeout-controls.md
index 79c41bc6b..1c67a598e 100644
--- a/examples/repl-bench/journeys/timeout-controls.md
+++ b/examples/repl-bench/journeys/timeout-controls.md
@@ -12,6 +12,7 @@
+
@@ -48,6 +49,7 @@
+
diff --git a/examples/repl-bench/journeys/transcript-status.test.md b/examples/repl-bench/journeys/transcript-status.test.md
index d8dc6f1c3..402b6339e 100644
--- a/examples/repl-bench/journeys/transcript-status.test.md
+++ b/examples/repl-bench/journeys/transcript-status.test.md
@@ -5,7 +5,10 @@
+
Checkout output witness"} />
+
+
@@ -15,20 +18,26 @@
+
'} />
+
+
+
+
+
-
+
-
+
diff --git a/packages/cli/src/repl/application.ts b/packages/cli/src/repl/application.ts
index 870bf7e7d..c97e40b2b 100644
--- a/packages/cli/src/repl/application.ts
+++ b/packages/cli/src/repl/application.ts
@@ -72,17 +72,16 @@ import {
GROWING_STACK_PROPS,
inlineActionRowProps,
partsRowProps,
+ roundEditorOutlineProps,
SPACER_PROPS,
statedActionRowProps,
statedPartProps,
WORKSPACE_DRAFT_GAP,
- WORKSPACE_DRAFT_ROWS,
WORKSPACE_LIST_GUTTER,
workspaceQueueRows,
workspaceBodyRows,
TAB_GAP,
workspaceBlockProps,
- bandBlockProps,
workspaceBodyProps,
workspaceColumnProps,
workspaceConversationWidth,
@@ -1103,6 +1102,8 @@ export interface ReplState {
};
readonly heldHistory?: true;
readonly draftCaret?: ReplCaret;
+ readonly draftOpen?: boolean;
+ readonly humanRound?: string;
readonly messageCaret?: ReplCaret;
readonly route: ReplRoute;
/**
@@ -1136,6 +1137,7 @@ export interface ReplState {
readonly recovering?: ReplRecovering;
/** Why the last action changed nothing, or none. */
readonly refusal: string | undefined;
+ readonly refusalPosition?: { readonly reason: string; readonly from: number } | undefined;
/**
* The pending permission request this screen has selected, or none.
*
@@ -1885,6 +1887,7 @@ export function stateFor(location: string): Result {
Object.freeze({
route: decoded.value,
draft: decoded.value.draft ?? "",
+ draftOpen: decoded.value.draft !== undefined,
form: EMPTY_FORM,
asking: undefined,
configuring: NOT_CONFIGURING,
@@ -2274,6 +2277,12 @@ export function reduceRepl(
if (next === window.from) {
return settled(given);
}
+ if (action.window === HEADER_REFUSAL_WINDOW && given.refusal !== undefined) {
+ return settled({
+ ...given,
+ refusalPosition: { reason: given.refusal, from: next },
+ });
+ }
if (action.window === "todo") {
return settled({ ...state, todoOffset: next });
}
@@ -2347,6 +2356,32 @@ export function reduceRepl(
return editCaret(state, live, action, configuring, asking, answering, presented);
case "reveal":
return settled({ ...state, restore: Object.freeze({ kind: "reveal", key: action.key }) });
+ case "open-round-draft": {
+ const routed = navigate(
+ hidingAsking(state),
+ model,
+ { ...state.route, surface: "entries", drawers: [], view: undefined },
+ live,
+ );
+ return {
+ ...routed,
+ state: Object.freeze({
+ ...routed.state,
+ draftOpen: true,
+ restore: Object.freeze>({
+ kind: "reveal",
+ key: "footer:input",
+ }),
+ }),
+ };
+ }
+ case "close-round-draft":
+ return settled({
+ ...drafting(state, "").state,
+ draftOpen: false,
+ draftCaret: undefined,
+ restore: { kind: "reveal", key: "draft:new" },
+ });
case "submit": {
// The one gate, over the part of its facts this reduction can see.
// Inspection freezes durable state, not the draft, and submitting from a
@@ -2512,7 +2547,12 @@ export function reduceRepl(
return chosen.state.refusal === undefined
? {
...chosen,
- state: Object.freeze({ ...chosen.state, catalog: false, inspection: undefined }),
+ state: Object.freeze({
+ ...chosen.state,
+ catalog: false,
+ inspection: undefined,
+ draftOpen: false,
+ }),
}
: chosen;
}
@@ -4027,7 +4067,7 @@ function settled(state: ReplState): ReplTransition {
}
function refuse(state: ReplState, reason: string): ReplTransition {
- return { state: Object.freeze({ ...state, refusal: reason }), intent: { kind: "none" } };
+ return settled({ ...state, refusal: reason, refusalPosition: undefined });
}
/**
@@ -5631,6 +5671,9 @@ function primaryAction(view: ReplView, narrow: boolean): string {
if (focused === "footer:exit" || focused === "footer:top:exit") {
return "Enter exits";
}
+ if (focused === "drawer:configure:agent" || focused === "drawer:configure:apply") {
+ return "Enter applies";
+ }
if (focused === "drawer:close") {
return "Enter closes";
}
@@ -5717,56 +5760,21 @@ function requiredLength(parts: readonly GuidancePart[]): number {
.join(GUIDANCE_SEPARATOR).length;
}
-/**
- * What the guidance says, whole, before any width has cut it into rows.
- *
- * Every part it has to say, in the one order it says them: the state, then what
- * focus actually does, then the way out, then movement. Nothing is dropped and
- * nothing is shortened to fit a row, because the block is as many rows as its
- * words need — a direction a reader cannot see is a direction they do not have,
- * and the Transcript sharing its column is not a reason to stop giving it.
- *
- * The vocabulary is the profile's: the long phrases where there is a Transcript
- * column, and the short ones a narrow frame already says. There is no third.
- */
-/**
- * Whether this frame says its refusal in the footer's own band.
- *
- * The staged composition keeps every footer control on one compact History row,
- * which leaves a reason a handful of cells and an ellipsis — and a refusal
- * truncated before its meaning is a keystroke that appeared to do nothing. The
- * band above it is the full width of the frame and already pays a sentence out
- * over as many rows as its words need, so that is where the reason goes.
- *
- * The standing hint waits while it does. A hint describes what a person could
- * do; a refusal answers what they just did, and only one of those is news.
- */
-function refusalInBand(view: ReplView): boolean {
- return shownRefusal(view) !== undefined && staged(view) !== undefined;
+export function executionRefusal(view: ReplView): string | undefined {
+ const refusal = shownRefusal(view);
+ return refusal === undefined ? undefined : `! ${refusal.replaceAll("\n", " ")}`;
}
-/**
- * What the footer's own sentence says on this frame: the refusal, or the hint.
- *
- * One function for both, asked by the pass that fits the words and by the pass
- * that describes the rows — a second answer is how a band comes to be measured
- * for one sentence and drawn with another.
- */
-export function footerSentence(view: ReplView): string {
- if (refusalInBand(view)) {
- return `! ${(shownRefusal(view) ?? "").split("\n").join(" ")}`;
- }
- if (profileFor(view.size) === "narrow" && presentedInspection(view) !== undefined) {
- return "Esc closes · Tab moves · PageUp/PageDown in Content";
- }
- if (staged(view) !== undefined && !modalOpen(view)) {
- const readiness = readinessOf(view);
- const narrow = profileFor(view.size) === "narrow";
- const state = statePhrase(readiness, narrow);
- const advice = stateAdvice(readiness, narrow, !narrow);
- return advice === undefined ? state : `${state}${GUIDANCE_SEPARATOR}${advice}`;
- }
- return guidanceSentence(view);
+export function drawerGuidance(view: ReplView): string {
+ return [
+ primaryAction(view, profileFor(view.size) === "narrow"),
+ "Esc closes",
+ "Tab regions Alt↑↓",
+ (focusClaim(view) ?? view.focused)?.endsWith(":anchor")
+ ? "Up/Down reads one row; PageUp/PageDown reads a page; Home/End reaches the bounds."
+ : "In Content: PageUp/PageDown reads more content. Arrows and Home/End keep editing a field.",
+ "Wheel scrolls the reading under your pointer, three displayed rows per tick. It stops before hiding the focused control.",
+ ].join(GUIDANCE_SEPARATOR);
}
export function guidanceSentence(view: ReplView): string {
@@ -5851,12 +5859,12 @@ function guidanceParts(
// works. The draft row below is visibly holding their text either way.
return [...said, move];
}
- // Focus is in the draft. Only here is Enter a submission, and only when the
- // readiness would take one — a row promising it in any other state is the one
- // thing this slice exists to stop saying.
- const enter: GuidancePart[] = admitsSubmission(readiness)
- ? [{ text: "Enter submits", required: true }]
- : [];
+ const enter: GuidancePart[] =
+ staged(view) !== undefined
+ ? [{ text: "Enter adds a line · Tab to Send", required: true }]
+ : admitsSubmission(readiness)
+ ? [{ text: "Enter submits", required: true }]
+ : [];
return [...said, ...enter, { text: "Type here" }, move];
}
@@ -6723,20 +6731,14 @@ function described(view: ReplView, context: ReplPresentationContext): DescribedS
// sentence is as long as the state it describes, and the medium profile's
// transcript column is narrower than the longest of them — a row wider than
// its column is one the column beside it loses space to.
- if (surface !== undefined) {
+ if (surface !== undefined && workspace === undefined) {
// One inert block, in the rows this frame fitted its words into. Without a
// fitted list — the pass still asking how wide the surface is — it is the
// one row that pass describes, so its own geometry question stays askable.
- const said = context.guidance ?? [footerSentence(view)];
- // A refusal in this band reads as the refusal it is, not as a hint.
- const refusing = refusalInBand(view);
+ const said = context.guidance ?? [guidanceSentence(view)];
for (const [at, own] of said.entries()) {
items.push(
- line(
- at === 0 ? "guidance" : `guidance:row:${at}`,
- own,
- refusing ? styleOf("failed-outcome", { inspected }) : styleOf("status", { inspected }),
- ),
+ line(at === 0 ? "guidance" : `guidance:row:${at}`, own, styleOf("status", { inspected })),
);
}
}
@@ -6744,7 +6746,7 @@ function described(view: ReplView, context: ReplPresentationContext): DescribedS
// Why the last thing asked for changed nothing. Shown rather than swallowed: a
// refusal nobody can read is a keystroke that appeared to do nothing.
const refusal = shownRefusal(view);
- if (refusal !== undefined && !refusalInBand(view) && offering("footer:refused")) {
+ if (refusal !== undefined && workspace === undefined && offering("footer:refused")) {
// One line: the footer is seven rows and the controls live in them, so a
// refusal that wrapped would push the draft off the screen it is about.
//
@@ -6798,8 +6800,13 @@ function described(view: ReplView, context: ReplPresentationContext): DescribedS
if (workspace !== undefined) {
// With the selected work, which is the surface it is part of. A narrow
// frame showing the Transcript or the Sidekick has no region to draw it in.
+ items.push(
+ row("draft:new", "+ New Round", { select: "open-round-draft" }, styleOf("action"), {
+ here: view.focused,
+ }),
+ );
if (showEntry) {
- items.push(...workspaceDraft(view, context, claiming));
+ items.push(...workspaceDraft(view, context));
}
} else {
items.push(
@@ -7300,6 +7307,10 @@ function createSessionPreparationStore(): ReplSessionPreparationStore {
materialize: materializeSessionRow,
prepare(view, width) {
const turns = chronology(view.model, view.live);
+ const human =
+ view.state.route.at === undefined && view.state.route.session === undefined
+ ? view.model.entries.find((one) => one.key === view.state.humanRound)?.order
+ : undefined;
const sidekick = view.live.sidekick;
const compact = staged(view) !== undefined;
const facts: (string | number | boolean | null | undefined)[] = [
@@ -7314,6 +7325,7 @@ function createSessionPreparationStore(): ReplSessionPreparationStore {
view.state.route.surface,
view.state.filtering,
turns.length,
+ human,
];
for (const turn of turns) {
facts.push(
@@ -7404,6 +7416,7 @@ function createSessionPreparationStore(): ReplSessionPreparationStore {
sidekick,
compact,
view.workspace?.feedback ?? [],
+ human,
);
const sequence = { rows, positions: new Map(rows.map((one, at) => [one.key, at])) };
held = { facts, sequence };
@@ -7444,6 +7457,7 @@ function sessionRows(
*/
compact = false,
feedback: readonly ReplRecordedFeedback[] = [],
+ human?: number,
): readonly ReplSessionRow[] {
const items: ReplSessionRow[] = [];
const filter = state.route.session;
@@ -7500,6 +7514,11 @@ function sessionRows(
items.push(sessionLine("sessions:section:entries", " Entry agents", styleOf("pane-heading")));
}
const entries: ReplSessionRow[] = [];
+ if (compact && human !== undefined) {
+ entries.push(
+ sessionLine(`sessions:round:${human}`, `── Round ${human} ──`, styleOf("pane-heading")),
+ );
+ }
let named: string | undefined;
for (const turn of turns) {
if (filter !== undefined && turn.sessionKey !== filter) {
@@ -8136,10 +8155,10 @@ function inspectionRect(size: ReplTerminalSize): ReplBounds {
const x = workspaceTranscriptWidth(size);
const width = workspaceWorkWidth(size);
if (x !== undefined && width !== undefined) {
- return { x, y: 1, width, height: size.rows - 3 };
+ return { x, y: 1, width, height: size.rows - 2 };
}
const height = Math.floor(size.rows * 0.6);
- return { x: 0, y: size.rows - height - 2, width: size.columns, height };
+ return { x: 0, y: size.rows - height - 1, width: size.columns, height };
}
/**
@@ -8160,31 +8179,9 @@ export function modalOpen(view: ReplView): boolean {
);
}
-/**
- * The rectangle whichever drawer is presented occupies.
- *
- * One calculation for both, read back by measurement, admission, description,
- * drawing and hit testing: the entry's covers the body, and the Sidekick's
- * covers the pane that owns its question.
- *
- * A route drawer's is the envelope the preparation settled once it had measured
- * the guidance this layer must stay clear of. Taken from the frame's own context
- * rather than recomputed here, so there is one answer to where it is: a second
- * calculation is how a drawer's cells and its targets come to disagree. Before
- * that block has been fitted there is nothing to clear, and the rectangle the
- * size states is what those passes measure.
- *
- * Staged drawers also clear the extra fitted footer rows. Pane-local drawers
- * keep their own origin; route drawers keep their existing inset.
- */
+/** The active drawer's rectangle, shared by placement and hit testing. */
function presentedRect(view: ReplView, context: ReplPresentationContext): ReplBounds | undefined {
- // Which body this layer covers: the staged composition keeps three rows
- // around its body where the ordinary one keeps seven, so a rectangle derived
- // from the other budget would hang off the bottom of this screen.
const workspace = staged(view) !== undefined;
- // The catalog floats over the body, exactly where a route drawer does: it is
- // a reading of the whole execution rather than of one pane, so a pane-local
- // rectangle would put the list of every entry inside the Sidekick's column.
const rect =
view.selection.drawers.length > 0 || presentedCatalog(view)
? (context.drawer ?? drawerRect(view.size, workspace))
@@ -8196,10 +8193,8 @@ function presentedRect(view: ReplView, context: ReplPresentationContext): ReplBo
if (rect === undefined || !workspace) {
return rect;
}
- return Object.freeze({
- ...rect,
- height: Math.max(0, rect.height - Math.max(0, (context.guidance?.length ?? 1) - 1)),
- });
+ const top = Math.max(rect.y, 1 + (context.headerRefusal?.length ?? 0));
+ return { ...rect, y: top, height: Math.max(0, rect.y + rect.height - top) };
}
/**
@@ -8375,7 +8370,13 @@ function drawerFor(
input: { window: DRAWER_WINDOW },
children: viewportRows.map((one) => one.description),
});
- const viewportChildren = [viewport, ...fixedRows.map((one) => one.description)];
+ const viewportChildren = [
+ viewport,
+ ...fixedRows.map((one) => one.description),
+ // The header stays visible outside the drawer's rectangle. Its wheel
+ // target belongs to the active modal while that modal owns input.
+ ...(context.headerRefusalWindow !== undefined && !inline ? [refusalViewport()] : []),
+ ];
const children = overHeld
? [
covered(history),
@@ -10205,8 +10206,19 @@ export const DRAWER_WINDOW = "drawer";
export const QUEUE_WINDOW = "queue";
/** The entry reading's window: output and source together, in the transcript. */
export const READING_WINDOW = "reading";
+
/** The Bindings pane's window, over the selected scope's values and answers. */
const BINDINGS_WINDOW = "bindings";
+
+const HEADER_REFUSAL_WINDOW = "header-refusal";
+
+function refusalViewport(): ReplDescription {
+ return describeNode({
+ key: `viewport:${HEADER_REFUSAL_WINDOW}`,
+ component: VIEWPORT,
+ input: { window: HEADER_REFUSAL_WINDOW },
+ });
+}
/** The action row's own structural id, which admission measures against. */
export const ACTION_ROW = "box:footer:actions";
/** The right pane's tab row, which is also that column's header. */
@@ -10288,8 +10300,6 @@ export interface ReplMeasuredWidths {
* control. Zero where the frame draws no queue.
*/
readonly queue?: number;
- /** The row the guidance is drawn in, where a frame draws it apart from the work. */
- readonly guidance?: number;
}
/**
@@ -10395,6 +10405,9 @@ export interface ReplPresentationContext {
* row, which is the geometry question it is asking.
*/
readonly guidance: readonly string[] | undefined;
+ readonly headerRefusal?: readonly string[];
+ readonly headerRefusalWindow?: ReplWindow | undefined;
+ readonly drawerHelp?: readonly string[];
/**
* The rows this frame is drawing a refusal's own explanation in, or none.
*
@@ -10446,7 +10459,6 @@ export interface ReplPresentationContext {
* from a label's characters. Absent before that measurement, where the field
* grows and the pass is only answering widths.
*/
- readonly draftField?: number | undefined;
/**
* How wide a queued message's text is, once its control has been measured.
*
@@ -10814,10 +10826,8 @@ function slotOf(key: string): ReplSlot | undefined {
key.startsWith("work:crumb:") ||
key === "work:state" ||
key === "work:compact" ||
- key === "draft:stop" ||
- key === "draft:send" ||
+ key.startsWith("draft:") ||
key === "follow" ||
- key.startsWith("draft:value:") ||
key.startsWith("todo:") ||
key === "queue-overflow" ||
key.startsWith("queue:") ||
@@ -11183,6 +11193,9 @@ export function presentationFor(
}),
);
}
+ if (context.headerRefusalWindow !== undefined && !modalOpen(view)) {
+ composed.push(refusalViewport());
+ }
// Placed only where the tree will hold them: a measuring pass mounts nothing.
const placedDescriptions = context.measuring
? composed
@@ -11981,6 +11994,7 @@ export function admissionFor(input: {
/** The drawer's notices, fitted, which its own window admits rows of. */
readonly notices?: ReplPreparedNotices | undefined;
readonly details?: readonly ReplFittedLine[] | undefined;
+ readonly headerRefusalWindow?: ReplWindow | undefined;
readonly boundsOf: (id: string) => ReplBounds | undefined;
}): ReplAdmission {
const { view, manifest, widths, reading, preview, queue, notices, details, boundsOf, sessions } =
@@ -11993,6 +12007,12 @@ export function admissionFor(input: {
const windows = new Map();
for (const slot of manifest.viewports) {
const capacity = capacityOf(boundsOf(slot.id));
+ if (slot.window === HEADER_REFUSAL_WINDOW) {
+ if (input.headerRefusalWindow !== undefined && capacity > 0) {
+ windows.set(slot.window, input.headerRefusalWindow);
+ }
+ continue;
+ }
if (slot.window === "todo") {
const rows = input.todo ?? [];
let from = Math.max(0, Math.min(view.state.todoOffset ?? 0, rows.length - capacity));
@@ -13421,67 +13441,78 @@ function workspaceControls(
return items;
}
-/**
- * The selected work's Draft: one field whose heading carries its own Send, or
- * Stop while an entry is running, and whose value takes the rows beneath it.
- *
- * Send asks for exactly what Enter in the field asks for — the same submission
- * action, through the same gate, against the same draft revision — so the two
- * ways of submitting one text are one decision rather than two. Stop carries
- * the key of the entry this frame is actually drawing it for, so what it stops
- * is that entry and not whatever is running by the time the key is pressed. It
- * is offered only at the live head — a frozen reading is of an entry this
- * process may no longer be running, and a Stop there would be aimed at history.
- */
-function workspaceDraft(
- view: ReplView,
- context: ReplPresentationContext,
- claiming: boolean,
-): readonly Described[] {
+function workspaceDraft(view: ReplView, context: ReplPresentationContext): readonly Described[] {
+ const open = view.model.entries.at(-1);
+ const running = view.live.running && view.state.route.at === undefined && open !== undefined;
const items: Described[] = [];
- items.push(
- field("footer:input", " DRAFT", view.state.draft, "draft", styleOf("field-label"), {
- caret: view.state.draftCaret,
- here: view.focused,
- block: true,
- ...(claiming ? { focus: true } : {}),
- }),
- );
- // The entry a Stop here would be aimed at: the last one the live head
- // admitted. Entries are serial, so only the last one can still be running —
- // the same rule the entry reading uses to decide whose live output it is
- // showing. A reading with no entry at all has nothing to aim a Stop at, and
- // a frozen position is excluded below, because an entry read there may not be
- // the one this process is running.
- const open = view.model.entries[view.model.entries.length - 1]?.key;
- items.push(
- view.live.running && view.state.route.at === undefined && open !== undefined
- ? row(
- "draft:stop",
- "[stop]",
- { select: "stop-entry", entry: open },
- styleOf("failed-outcome"),
- { here: view.focused },
- )
- : row("draft:send", "[send]", { select: "submit-draft" }, styleOf("action"), {
- here: view.focused,
- }),
- );
- const rows = context.draft ?? ["", "", ""];
- for (const [at, own] of rows.entries()) {
- items.push(line(`draft:value:${at}`, own, styleOf("draft"), sourceRuns(own)));
+ if (running) {
+ items.push(
+ ...(view.state.draftOpen
+ ? []
+ : [
+ line(
+ "draft:running",
+ open.key === view.state.humanRound ? "● running · user" : "● running",
+ styleOf("lifecycle-active"),
+ ),
+ ]),
+ row(
+ "draft:stop",
+ "Stop",
+ { select: "stop-entry", entry: open.key },
+ styleOf("failed-outcome"),
+ { here: view.focused },
+ ),
+ );
+ }
+ if (view.state.draftOpen) {
+ const focused = (focusClaim(view) ?? view.focused) === "footer:input";
+ items.push(
+ field("footer:input", "", view.state.draft, "draft", styleOf("waiting"), {
+ caret: view.state.draftCaret,
+ here: view.focused,
+ block: true,
+ }),
+ line(
+ "draft:status",
+ profileFor(view.size) === "wide" && !running ? "✎ draft · user · not sent" : "✎ draft",
+ styleOf("waiting"),
+ ),
+ row(
+ "draft:send",
+ "Send",
+ view.state.draft.length === 0 ? {} : { select: "submit-draft" },
+ styleOf(view.state.draft.length === 0 ? "metadata" : "action"),
+ { here: view.focused },
+ ),
+ row("draft:close", "X", { select: "close-round-draft" }, styleOf("action"), {
+ here: view.focused,
+ }),
+ );
+ for (const [at, own] of (context.draft ?? [""]).entries()) {
+ if (at === 0 && view.state.draft.length === 0) {
+ const runs = tokenRuns([
+ ...(focused ? [{ text: " ", token: "caret" } as const] : []),
+ { text: "Executable Markdown", token: "metadata" },
+ ]);
+ items.push(line("draft:placeholder", runText(runs), styleOf("draft"), runs));
+ } else {
+ items.push(line(`draft:value:${at}`, own, styleOf("draft"), sourceRuns(own)));
+ }
+ }
}
return items;
}
+function nextRound(view: ReplView): number {
+ return (numbered(view.navigation).at(-1)?.entry ?? 0) + 1;
+}
+
/** The text column of the staged queue's first message, which its width is read from. */
export const QUEUE_TEXT = "box:queue:text:0";
-/** The staged guidance row's inside, which the guidance is fitted to. */
-export const GUIDANCE_ROW = "box:guidance:body";
-
-/** The Draft's heading row, whose measured width its field is derived from. */
-export const DRAFT_HEADING = "box:draft:heading";
+/** The measured editor body below the Round heading. */
+export const ROUND_EDITOR_BODY = "box:round-editor:body";
/**
* How wide a queued message's text is left beside its control.
@@ -13507,31 +13538,6 @@ export function queueTextWidth(
return Math.max(0, room - button - WORKSPACE_DRAFT_GAP);
}
-/**
- * How wide the Draft's field is left, for this exact measured frame.
- *
- * The heading row's own measured width, less the width the engine gave the
- * control beside it, less the gap that row declares. None where this frame drew
- * no Draft, or where the measurement has answered for neither box yet.
- */
-export function draftFieldWidth(
- manifest: ReplLayoutManifest,
- widthOf: (id: string) => number | undefined,
-): number | undefined {
- const control = flatten(manifest.root).find(
- (one) => one.key === "draft:stop" || one.key === "draft:send",
- );
- if (control === undefined) {
- return undefined;
- }
- const heading = widthOf(DRAFT_HEADING);
- const button = widthOf(control.id);
- if (heading === undefined || button === undefined || heading < 1 || button < 1) {
- return undefined;
- }
- return Math.max(0, heading - button - WORKSPACE_DRAFT_GAP);
-}
-
/** The staged History row's map, which is drawn rather than mounted. */
const HISTORY_MAP = "box:history:map";
@@ -13740,17 +13746,29 @@ export function historyMapWidth(
* Read from the route, so it names nothing this reading does not hold.
*/
function identityRuns(view: ReplView, width: number): readonly ReplTokenRun[] {
+ const readiness = readinessOf(view);
+ const narrow = profileFor(view.size) === "narrow";
+ const state = statePhrase(readiness, narrow);
+ const advice =
+ readiness.kind === "history"
+ ? "Send unavailable · use Live"
+ : stateAdvice(readiness, narrow, !narrow || view.state.route.surface === "sessions")?.replace(
+ "Enter unavailable",
+ "Send unavailable",
+ );
+ const status = ` ${state}${advice === undefined ? "" : GUIDANCE_SEPARATOR + advice}`;
const title = " XMD REPL";
- const label = profileFor(view.size) === "narrow" ? " session " : " session ";
- const id = fitLine(
- [{ text: view.state.route.execution, elide: true }],
- width - title.length - label.length,
- );
- return tokenRuns([
- { text: title, token: "output" },
- { text: label, token: "field-label" },
- { text: id, token: "source" },
- ]);
+ const label = narrow ? " session " : " session ";
+ const room = width - status.length - title.length - label.length;
+ const runs: ReplTokenRun[] = [{ text: title, token: "output" }];
+ if (room > 0) {
+ runs.push(
+ { text: label, token: "field-label" },
+ { text: fitLine([{ text: view.state.route.execution, elide: true }], room), token: "source" },
+ );
+ }
+ runs.push({ text: status, token: "field-label" });
+ return tokenRuns(runs);
}
/**
@@ -13762,10 +13780,16 @@ function identityRuns(view: ReplView, width: number): readonly ReplTokenRun[] {
* Every exact position, an entry's and every minor one, is reached through the
* History drawer, which is what the action beside this map opens.
*/
-function compactHistoryRuns(view: ReplView): readonly ReplTokenRun[] {
- const runs: { text: string; token: ReplPresentationRole }[] = [
- { text: ` ${COMPACT_HISTORY_TITLE}`, token: "history-title" },
- ];
+function compactHistoryRuns(view: ReplView, width?: number): readonly ReplTokenRun[] {
+ const title: ReplTokenRun = { text: ` ${COMPACT_HISTORY_TITLE}`, token: "history-title" };
+ const marks: ReplTokenRun[][] = [];
+ const editing = roundEditorVisible(view);
+ const running =
+ view.live.running &&
+ view.state.route.at === undefined &&
+ view.model.entries.at(-1)?.key === view.state.humanRound &&
+ view.state.humanRound !== undefined;
+ const entryByOrder = new Map(view.model.entries.map((entry) => [entry.order, entry]));
const points = numbered(view.navigation);
const at = view.state.route.at;
const selectedOrdinal =
@@ -13774,14 +13798,16 @@ function compactHistoryRuns(view: ReplView): readonly ReplTokenRun[] {
selectedOrdinal === undefined
? undefined
: points.filter((one) => one.ordinal <= selectedOrdinal).pop()?.entry;
+ const selected = selectedEntry ?? workspaceEntry(view)?.order;
for (const one of points) {
if (one.point.kind !== "entry") {
continue;
}
- const entry = view.model.entries.find((candidate) => candidate.order === one.entry);
- const chosen = selectedEntry === one.entry;
- runs.push({ text: " ", token: "history" });
- runs.push({
+ const entry = entryByOrder.get(one.entry);
+ const chosen = !editing && selected === one.entry;
+ const markRuns: ReplTokenRun[] = [{ text: " ", token: "history" }];
+ marks.push(markRuns);
+ markRuns.push({
text: String(one.entry),
token: chosen
? "history-selected"
@@ -13793,7 +13819,31 @@ function compactHistoryRuns(view: ReplView): readonly ReplTokenRun[] {
continue;
}
const state = workState(entry, view.model, view.live);
- runs.push({ text: ` ${state.word.slice(0, 1)}`, token: state.style.role });
+ const mark =
+ state.style.role === "lifecycle-active" && entry.key === view.state.humanRound
+ ? "⠋"
+ : state.word.slice(0, 1);
+ markRuns.push({ text: ` ${mark}`, token: state.style.role });
+ }
+ if (editing) {
+ marks.push([{ text: ` ${nextRound(view)} ✎`, token: "waiting" }]);
+ }
+ const runs = [title];
+ const markWidths = marks.map((mark) => runText(mark).length);
+ let first = 0;
+ if (width !== undefined && (running || editing)) {
+ const room = width - title.text.length;
+ let used = markWidths.reduce((sum, cells) => sum + cells, 0);
+ if (used > room) {
+ const omitted: ReplTokenRun = { text: " …", token: "history" };
+ while (first < marks.length - 1 && used + omitted.text.length > room) {
+ used -= markWidths[first++];
+ }
+ runs.push(omitted);
+ }
+ }
+ for (const mark of marks.slice(first)) {
+ runs.push(...mark);
}
const head = view.navigation.head;
runs.push({ text: " ── ", token: "history-rail" });
@@ -14128,7 +14178,7 @@ export function workspaceHeaderLines(
* The staged workspace composition's boxes, from the same classified rows.
*
* One identity row, the body, and below it one compact History row carrying the
- * contextual actions and a measured guidance block. The wide and medium profiles give
+ * contextual actions. The wide and medium profiles give
* the body three columns — the Transcript of agent work, the selected work with
* its Draft, and Bindings/Sidekick with the tray above its composer. The narrow
* profile routes one outlet instead, under the two surface controls, exactly as
@@ -14212,9 +14262,11 @@ function workspacePresentation(input: {
* the name — the label is fitted to what is left once they have theirs.
*/
const statedCells = (one: ReplCandidate): number | undefined =>
- one.key === "transcript:selector" && context.selector !== undefined
- ? context.selector.cells + FOCUS_MARKER
- : undefined;
+ one.key.startsWith("draft:") && typeof one.text === "string"
+ ? one.text.length
+ : one.key === "transcript:selector" && context.selector !== undefined
+ ? context.selector.cells + FOCUS_MARKER
+ : undefined;
const parts = (keys: readonly string[], region: ReplRegion, surface?: number): ReplBox[] =>
keys.flatMap((key) =>
byKey(key).map((one) => {
@@ -14349,12 +14401,16 @@ function workspacePresentation(input: {
];
};
- /** The selected work: its breadcrumbs and state, its reading, and the Draft. */
const workColumn = (region: ReplRegion, body: string, inside?: number): readonly ReplBox[] => {
- contents.push({ region, id: body, kind: "body" });
const draft = of("draft");
- const value = startingWith("draft:value:");
- return [
+ const editing = draft.length > 0;
+ const room = context.widths?.surfaceBody;
+ const focused = (focusClaim(view) ?? view.focused) === "footer:input";
+ const showHeading = !outlet || (focusClaim(view) ?? view.focused) !== "draft:send";
+ if (!editing) {
+ contents.push({ region, id: body, kind: "body" });
+ }
+ const reading = [
...headerRows("work", region, header),
box({
id: `${body}:gutter`,
@@ -14376,60 +14432,89 @@ function workspacePresentation(input: {
}),
],
}),
- ...(draft.length === 0 && value.length === 0
- ? []
- : [
+ ];
+ return [
+ ...(editing
+ ? [
+ ...(showHeading
+ ? [
+ box({
+ id: "box:round-editor:heading",
+ region,
+ props: headerRowProps(
+ room,
+ focused ? REPL_PALETTE.focusSurface : REPL_PALETTE.paneHeaderSurface,
+ ),
+ text: fieldLabel(` Round ${nextRound(view)} · draft`, focused),
+ style: styleOf("waiting"),
+ runs: tokenRuns([
+ { text: focused ? "> " : " ", token: focused ? "focus-marker" : "waiting" },
+ {
+ text: `Round ${nextRound(view)} · draft`,
+ token: focused ? "markdown-strong" : "waiting",
+ },
+ ]),
+ }),
+ box({
+ id: "box:round-editor:help",
+ region,
+ props: partsRowProps(1, 0, room),
+ text: " Enter adds a line · Tab to Send",
+ style: styleOf("metadata"),
+ }),
+ ]
+ : []),
box({
- id: "box:draft",
+ id: "box:round-editor:inset",
region,
- props: workspaceBlockProps(
- WORKSPACE_DRAFT_ROWS,
- REPL_PALETTE.draftSurface,
- BODY_GUTTER,
- ),
+ props: workspaceBodyProps(1, 0, room),
children: [
box({
- id: DRAFT_HEADING,
+ id: "box:round-editor:outline",
region,
- props: partsRowProps(1, WORKSPACE_DRAFT_GAP, context.widths?.surfaceBody),
+ props: roundEditorOutlineProps(),
children: [
- ...draft.map((one) =>
- box({
- id: `box:${region}:${one.key}`,
- key: one.key,
- region,
- // What this row has left once the engine has measured
- // the control beside it. Grown instead, the engine
- // divides that remainder itself and the division is not
- // always whole — measured, it left this field
- // 52.00732421875 wide and put the control on a fraction
- // of a cell. The control is still measured by its own
- // label, so its hit box is still the label somebody
- // aims at; only what is left over is stated.
- props:
- context.draftField === undefined
- ? SPACER_PROPS
- : statedPartProps(context.draftField),
- text: one.text,
- control: one.control,
- style: one.style,
- // No stretches: this row is drawn in one ink, which is
- // what the reviewed screen shows — its marker and the
- // composer's below it both take their own row's style,
- // bolded where the focus is. Stating a width is what
- // makes the builder apply a row's stretches, and the
- // marker would otherwise take the focus ink here; the
- // width the engine had already divided is the only
- // thing this was meant to settle.
- }),
- ),
- ...parts(["draft:stop", "draft:send"], region),
+ box({
+ id: ROUND_EDITOR_BODY,
+ region,
+ props: {
+ ...paneContentProps(),
+ bg: terminalColour(REPL_PALETTE.draftSurface),
+ },
+ children: [
+ box({
+ id: `${ROUND_EDITOR_BODY}:input`,
+ key: "footer:input",
+ control: true,
+ region,
+ props: paneContentProps(),
+ children: [
+ ...byKey("draft:placeholder"),
+ ...startingWith("draft:value:"),
+ ].map((one) =>
+ box({
+ ...rowBox(one, region, undefined),
+ props: fittedRowProps(0),
+ }),
+ ),
+ }),
+ ],
+ }),
],
}),
- ...value.map((one) => rowBox(one, region, context.widths?.surfaceBody)),
],
}),
- ]),
+ ]
+ : reading),
+ box({
+ id: "box:round-bar",
+ region,
+ props: partsRowProps(1, WORKSPACE_DRAFT_GAP, room),
+ children: parts(
+ ["draft:status", "draft:running", "draft:new", "draft:send", "draft:close", "draft:stop"],
+ region,
+ ),
+ }),
];
};
@@ -14673,7 +14758,12 @@ function workspacePresentation(input: {
region: "content",
props: workspaceHeaderProps(header, TAB_GAP),
children: parts(
- ["sessions:heading", "entries:heading", "surface:sidekick"],
+ [
+ "sessions:heading",
+ "entries:heading",
+ "surface:sidekick",
+ ...(showingSidekick(view) || routed === "sessions" ? ["draft:new"] : []),
+ ],
"content",
header,
),
@@ -14770,7 +14860,7 @@ function workspacePresentation(input: {
const retry = parts(["notice:retry"], "inspection");
const width = sidekickNoticeWidth(size) - 4;
const headRows = headerRows("conversation", "inspection", header).length;
- const top = 1 + (outlet ? 1 : 0) + headRows;
+ const top = 1 + (context.headerRefusal?.length ?? 0) + (outlet ? 1 : 0) + headRows;
columns.push(
box({
id: "box:sidekick:notice",
@@ -14815,6 +14905,15 @@ function workspacePresentation(input: {
props: drawerLayerProps(rect, context.capture),
children: [
rowBox(title, "drawer", context.widths?.drawer),
+ ...(context.drawerHelp ?? []).map((text, at) =>
+ box({
+ id: `box:drawer:help:${at}`,
+ region: "drawer",
+ props: partsRowProps(1, 0, context.widths?.drawer),
+ text,
+ style: styleOf("metadata"),
+ }),
+ ),
box({
id,
region: "drawer",
@@ -14831,10 +14930,24 @@ function workspacePresentation(input: {
const placed = offered.filter(
(candidate) => context.measuring || context.admission.actions.has(candidate.key),
);
- const map = compactHistoryRuns(view);
+ const map = compactHistoryRuns(
+ view,
+ accepted ? context.wideHistoryMap : context.historySplit?.map,
+ );
const inspected = view.state.route.at !== undefined;
const usageToggle = byKey("identity:usage");
const identity = identityRuns(view, size.columns - (usageToggle[0]?.text.length ?? 0));
+ const refusalRows = context.headerRefusal ?? [];
+ const refusalWindow = context.headerRefusalWindow;
+ const refusalId = "box:identity:refusal";
+ if (refusalWindow !== undefined) {
+ viewports.push({
+ id: refusalId,
+ region: "refusal",
+ window: HEADER_REFUSAL_WINDOW,
+ owner: `viewport:${HEADER_REFUSAL_WINDOW}`,
+ });
+ }
regions.push({ region: "footer", id: "box:footer" });
return {
descriptions,
@@ -14847,42 +14960,49 @@ function workspacePresentation(input: {
children: [
box({
id: "box:identity",
- props: bandRowProps(REPL_PALETTE.chromeSurface),
+ props: stackProps(1 + refusalRows.length),
children: [
box({
- id: "box:identity:text",
- props: fittedPartProps(),
- text: runText(identity),
- runs: identity,
- style: styleOf("metadata"),
+ id: "box:identity:line",
+ props: bandRowProps(REPL_PALETTE.chromeSurface),
+ children: [
+ box({
+ id: "box:identity:text",
+ props: statedPartProps(runText(identity).length),
+ text: runText(identity),
+ runs: identity,
+ style: styleOf("metadata"),
+ }),
+ box({ id: "box:identity:space", props: SPACER_PROPS }),
+ ...usageToggle.map((one) => part(one, undefined)),
+ ],
}),
- box({ id: "box:identity:space", props: SPACER_PROPS }),
- ...usageToggle.map((one) => part(one, undefined)),
+ ...(refusalRows.length === 0
+ ? []
+ : [
+ box({
+ id: refusalId,
+ props: stackProps(refusalRows.length),
+ children: refusalRows.map((text, at) =>
+ box({
+ id: `${refusalId}:${at}`,
+ props: bandRowProps(REPL_PALETTE.chromeSurface),
+ text,
+ style: styleOf(
+ at === refusalWindow?.count ? "metadata" : "failed-outcome",
+ ),
+ }),
+ ),
+ }),
+ ]),
],
}),
box({ id: "box:body", props: bodyProps(false), children: columns }),
box({
id: "box:footer",
region: "footer",
- // State the fitted row count: intrinsic stack sizing can place this
- // footer on fractional cells, invalidating every input rectangle.
- props: stackProps(1 + (context.guidance?.length ?? 1)),
+ props: stackProps(1),
children: [
- box({
- id: "box:guidance",
- region: "footer",
- props: bandBlockProps(REPL_PALETTE.chromeSurface, WORKSPACE_LIST_GUTTER),
- children: [
- box({
- id: GUIDANCE_ROW,
- region: "footer",
- props: GROWING_STACK_PROPS,
- children: of("located").map((one) =>
- rowBox(one, "footer", context.widths?.guidance),
- ),
- }),
- ],
- }),
box({
id: "box:history",
region: "footer",
@@ -14974,9 +15094,6 @@ function workspacePresentation(input: {
};
}
-/** How many rows of the draft's own value the staged Draft shows. */
-const DRAFT_VALUE_ROWS = WORKSPACE_DRAFT_ROWS - 1;
-
/** The staged queue's messages as the lines its text column fits, or none. */
export function queueLinesOf(
view: ReplView,
@@ -14991,55 +15108,15 @@ export function queueLinesOf(
}));
}
-/**
- * The draft's own lines as the staged Draft fits them, or none.
- *
- * The newest ones, because those are the ones drawn. See below.
- */
-export function draftLinesOf(view: ReplView):
- | readonly {
- readonly key: string;
- readonly text: string;
- readonly runs: readonly ReplTokenRun[];
- }[]
- | undefined {
- if (staged(view) === undefined) {
- return undefined;
- }
- const lines = view.state.draft.split("\n");
- // Only the lines this block can draw. Every line is fitted on its own and
- // every one of them is at least one row — a blank line included — so the last
- // `DRAFT_VALUE_ROWS` lines already hold at least as many rows as the Draft
- // shows, and the newest rows of those are the newest rows of the whole draft.
- // The lines above them are measured through the engine only to be dropped:
- // typing into a three-hundred-line draft cost 61.9ms a key at 160x36 against
- // 12.2ms before this block existed, almost all of it in cuts nothing drew.
- const drawn = lines.slice(Math.max(0, lines.length - DRAFT_VALUE_ROWS));
- const from = lines.length - drawn.length;
- // Keyed by where the line is in the draft, not by where it is in this list:
- // the key names the line somebody is editing.
- return drawn.map((text, at) => ({
- key: `draft:${from + at}`,
- text,
- runs: sourceRuns(text),
- }));
+export function roundEditorVisible(view: ReplView): boolean {
+ return (
+ staged(view) !== undefined &&
+ view.state.draftOpen === true &&
+ (profileFor(view.size) !== "narrow" ||
+ (view.state.route.surface === "entries" && !showingSidekick(view)))
+ );
}
-/**
- * The Draft's rows this frame draws: the newest that fit, then blank rows.
- *
- * The newest, because the end is where somebody is typing. Always exactly as
- * many rows as the Draft has, so the block's height is the same whatever the
- * draft holds.
- */
-export function draftRowsOf(fitted: readonly ReplFittedLine[]): readonly string[] {
- const drawn = fitted.map((one) => `${" ".repeat(one.indent)}${one.text}`);
- const newest = drawn.slice(Math.max(0, drawn.length - DRAFT_VALUE_ROWS));
- return Object.freeze([
- ...newest,
- ...Array.from({ length: DRAFT_VALUE_ROWS - newest.length }, () => ""),
- ]);
-}
export type { ReplDrawerRef };
export function queueStatusLinesOf(
diff --git a/packages/cli/src/repl/components/actions.ts b/packages/cli/src/repl/components/actions.ts
index 05ea3de0f..5de57d2eb 100644
--- a/packages/cli/src/repl/components/actions.ts
+++ b/packages/cli/src/repl/components/actions.ts
@@ -56,6 +56,8 @@ export type ReplAction =
readonly key: "ArrowUp" | "ArrowDown" | "PageUp" | "PageDown" | "Home" | "End";
}
| { readonly kind: "noop" }
+ | { readonly kind: "open-round-draft" }
+ | { readonly kind: "close-round-draft" }
| { readonly kind: "retry-restore" }
| { readonly kind: "show-restore-error" }
| {
diff --git a/packages/cli/src/repl/components/rows.ts b/packages/cli/src/repl/components/rows.ts
index a2b0d4174..2e1297807 100644
--- a/packages/cli/src/repl/components/rows.ts
+++ b/packages/cli/src/repl/components/rows.ts
@@ -498,6 +498,9 @@ function activation(input: ReplViewData): ReplAction | undefined {
if (select === "session-filter") {
return { kind: "toggle-session-filter" };
}
+ if (select === "open-round-draft" || select === "close-round-draft") {
+ return { kind: select };
+ }
if (select === "submit-draft") {
return { kind: "submit" };
}
@@ -582,6 +585,14 @@ export const FIELD: ReplComponent = component({
const named = optional(node.input, "field");
const purpose = optional(node.input, "purpose");
const question = optional(node.input, "question");
+ if (
+ event.kind === "pointer" &&
+ purpose === "draft" &&
+ fields(node.input)?.["block"] === true &&
+ textOf(node.input, "prompt") === ""
+ ) {
+ return { kind: "reveal", key: "footer:input" };
+ }
if (
purpose !== "todo" &&
purpose !== "draft" &&
@@ -643,6 +654,9 @@ export const FIELD: ReplComponent = component({
};
}
if (event.key === "Enter") {
+ if (purpose === "draft" && fields(node.input)?.["block"] === true) {
+ return { kind: "type", text: "\n", ...owns };
+ }
return submission(node.input);
}
return undefined;
@@ -706,7 +720,7 @@ function rendered(input: ReplViewData): string {
const focused = fields(input)?.["focused"] === true;
const prompt = textOf(input, "prompt");
if (fields(input)?.["block"] === true) {
- return fieldLabel(prompt, focused);
+ return prompt === "" ? "" : fieldLabel(prompt, focused);
}
return fieldText(prompt, textOf(input, "text"), focused);
}
diff --git a/packages/cli/src/repl/fitting.ts b/packages/cli/src/repl/fitting.ts
index 06d1bf76c..6fc6ff472 100644
--- a/packages/cli/src/repl/fitting.ts
+++ b/packages/cli/src/repl/fitting.ts
@@ -1252,10 +1252,14 @@ export function* fitEditor(
focused: boolean,
store?: ReplPlainFitStore,
classify: (text: string) => readonly ReplTokenRun[] = (text) => [{ text, token: "field-value" }],
+ mode?: "horizontal",
): Operation> {
const lines = caret.value.split("\n").map((text, at) => ({ key: `edit:${at}`, text }));
// Reserve a blank cell for a caret after the last grapheme of a fitted row.
- const fitted = yield* fitPlain(renderer, size, lines, Math.max(1, room - 1), store);
+ const fitted =
+ mode === "horizontal"
+ ? Ok(lines.map(({ key, text }) => ({ text, line: key, indent: 0 })))
+ : yield* fitPlain(renderer, size, lines, Math.max(1, room - 1), store);
if (!fitted.ok) {
return fitted;
}
@@ -1273,19 +1277,28 @@ export function* fitEditor(
let geometry = store?.heldCaret(line.text, line.indent, Math.max(1, room - 1), size);
if (geometry === undefined) {
const stops = boundaries(line.text);
+ // The engine caps the width of a prefix at the terminal width.
const measured = yield* widths(
renderer,
size,
- stops.map((at) => line.text.slice(0, at)),
+ stops.map((at, index) =>
+ mode === "horizontal"
+ ? line.text.slice(stops[index - 1] ?? 0, at)
+ : line.text.slice(0, at),
+ ),
);
if (!measured.ok) {
return measured;
}
+ let column = line.indent;
geometry = {
- stops: stops.map((offset, index) => ({
- offset,
- column: line.indent + measured.value[index],
- })),
+ stops: stops.map((offset, index) => {
+ column =
+ mode === "horizontal"
+ ? column + measured.value[index]
+ : line.indent + measured.value[index];
+ return { offset, column };
+ }),
};
}
retained.push({ text: line.text, indent: line.indent, row: geometry });
@@ -1319,5 +1332,41 @@ export function* fitEditor(
]),
};
}
+ if (mode === "horizontal") {
+ const activeStops = rows[active]?.stops ?? [];
+ const caretIndex = activeStops.findIndex((stop) => stop.offset === caret.offset);
+ const activeColumn = activeStops[caretIndex]?.column ?? 0;
+ const caretEnd = activeStops[caretIndex + 1]?.column ?? activeColumn + 1;
+ const left = Math.max(0, Math.max(activeColumn + 1, caretEnd) - room);
+ for (const [at, one] of display.entries()) {
+ const stops = rows[at].stops;
+ const first = stops[0]?.offset ?? 0;
+ const last = stops.at(-1);
+ const start = stops.find((stop) => stop.column >= left);
+ let end: (typeof stops)[number] | undefined;
+ for (const stop of stops) {
+ if (stop.column > left + room) {
+ break;
+ }
+ end = stop;
+ }
+ if (start === undefined || end === undefined || end.offset < start.offset) {
+ display[at] = { text: "", runs: [] };
+ continue;
+ }
+ const from = start.offset - first;
+ const to =
+ end.offset -
+ first +
+ (focused &&
+ at === active &&
+ end === last &&
+ end.column < left + room &&
+ end.offset === caret.offset
+ ? 1
+ : 0);
+ display[at] = { text: one.text.slice(from, to), runs: slicedRuns(one.runs, from, to) };
+ }
+ }
return Ok({ caret, rows, display, active });
}
diff --git a/packages/cli/src/repl/layout.ts b/packages/cli/src/repl/layout.ts
index 2682eab7d..81c208e43 100644
--- a/packages/cli/src/repl/layout.ts
+++ b/packages/cli/src/repl/layout.ts
@@ -695,6 +695,23 @@ export function paneContentProps(topGap = 0): ReplBoxProps {
};
}
+export function roundEditorOutlineProps(): ReplBoxProps {
+ return {
+ layout: {
+ ...paneContentProps().layout,
+ padding: { left: 1, right: 1 },
+ },
+ bg: terminalColour(REPL_PALETTE.draftSurface),
+ border: {
+ color: terminalColour(REPL_PALETTE.chromeEdge),
+ top: 1,
+ bottom: 1,
+ left: 1,
+ right: 1,
+ },
+ };
+}
+
/**
* One column of the body, stacked. `undefined` grows into what is left.
*
@@ -1102,9 +1119,6 @@ const WORKSPACE_WIDE_CONVERSATION = 70;
const WORKSPACE_MEDIUM_TRANSCRIPT = 24;
const WORKSPACE_MEDIUM_CONVERSATION = 56;
-/** The selected work's Draft: its heading row and three value rows. */
-export const WORKSPACE_DRAFT_ROWS = 4;
-
/**
* The cells between the Draft's field and the control beside it.
*
@@ -1127,9 +1141,9 @@ export function workspaceQueueRows(size: ReplTerminalSize): number {
* below — three, where the ordinary composition's footer is seven. Stated here
* so the drawer rectangles and the body are measured against the same budget.
*/
-export const WORKSPACE_CHROME_ROWS = 3;
+export const WORKSPACE_CHROME_ROWS = 2;
-/** How many rows the staged body has: everything those three rows leave. */
+/** How many rows the staged body has between identity and History. */
export function workspaceBodyRows(size: ReplTerminalSize): number {
return Math.max(0, size.rows - WORKSPACE_CHROME_ROWS);
}
@@ -1195,33 +1209,6 @@ export const WORKSPACE_LIST_GUTTER = 1;
* child against its content rather than against the row, so each part states
* its own width instead.
*/
-/**
- * The band of prose below the body: as many rows as its words need, read in
- * from the left edge the same one cell as the row above it.
- *
- * Inset on one side only, where a list is inset on both. A list is read beside
- * its column's edge and wants the breathing room at each end; this band is one
- * sentence paid out across the whole frame, and a gutter held back at its
- * trailing edge reserves a column no reader ever sees. Measured, that reserved
- * column is what a 72-cell frame could not spare: the narrow directions come to
- * 71 cells with every fact in them, the band offered 70, and the fitter did
- * what it is supposed to do with a sentence longer than its room — it moved the
- * last words to a second row, which this two-row footer has nowhere to put. So
- * the one thing the row exists to say last, the way back to the draft, was the
- * thing that went.
- */
-export function bandBlockProps(surface: number, indent: number): ReplBoxProps {
- return {
- layout: {
- width: grow(),
- height: fit(),
- direction: "ttb",
- padding: { left: Math.max(0, indent), right: 0 },
- },
- bg: terminalColour(surface),
- };
-}
-
export function bandRowProps(surface: number): ReplBoxProps {
return {
layout: { width: grow(), height: fixed(1), direction: "ltr" },
diff --git a/packages/cli/src/repl/program.ts b/packages/cli/src/repl/program.ts
index 9d2beb1b5..f4bd628cc 100644
--- a/packages/cli/src/repl/program.ts
+++ b/packages/cli/src/repl/program.ts
@@ -91,7 +91,9 @@ import {
previewedMessage,
retainedDetailsOf,
MESSAGE_VALUE_ROWS,
- footerSentence,
+ drawerGuidance,
+ executionRefusal,
+ guidanceSentence,
readinessOf,
readingOf,
SIDEBAR_BODY,
@@ -100,17 +102,15 @@ import {
SIDEKICK_WINDOW,
wheelDestination,
createChatPreparationStore,
- draftFieldWidth,
+ ROUND_EDITOR_BODY,
configureNoticesOf,
- draftLinesOf,
+ roundEditorVisible,
NOTICE_INDENT,
historyMapWidth,
historyProbeOf,
historySplitOf,
wideHistoryWidths,
queueTextWidth,
- draftRowsOf,
- GUIDANCE_ROW,
QUEUE_TEXT,
queueLinesOf,
queueStatusLinesOf,
@@ -229,7 +229,7 @@ import { readingLines } from "./source-reading.ts";
import { inertCommandText } from "./command-output.ts";
import { sourceRuns } from "./presentation-text.ts";
import type { ReplBounds, ReplBox, ReplLayoutManifest, ReplRegion } from "./layout.ts";
-import { capacityOf, NOTHING_ADMITTED } from "./layout-admission.ts";
+import { admitRows, capacityOf, NOTHING_ADMITTED } from "./layout-admission.ts";
import type { ReplAdmission } from "./layout-admission.ts";
import { resolveWheel, resolvePointer, useReplRenderer } from "./renderer.ts";
import type { ReplDrawnBox, ReplMeasured, ReplRendered, ReplRenderer } from "./renderer.ts";
@@ -2343,7 +2343,19 @@ function* drive(
// The entry exists now, so the draft that became it is finished — and
// only the revision it was taken from. Somebody who typed while the
// preflight was running keeps what they typed.
+ const previous = state;
state = admitted(state, report.held);
+ if (report.held.by === "person") {
+ state = {
+ ...state,
+ humanRound: report.submission.entry,
+ draftOpen: false,
+ ...(previous.revisions.draft === report.held.revision
+ ? { draftCaret: undefined }
+ : {}),
+ route: { ...state.route, at: undefined, scopes: [report.submission.entry] },
+ };
+ }
continue;
}
// A refusal leaves the draft exactly as it was and the history as it
@@ -2355,7 +2367,7 @@ function* drive(
// is true of the document, and readiness moving on does not make it
// admissible — dropping that one would take away the only explanation
// of why the draft is still sitting there.
- state = Object.freeze({ ...state, refusal: report.refusal });
+ state = Object.freeze({ ...state, refusal: report.refusal, refusalPosition: undefined });
refusedByReadiness = report.byReadiness;
}
}
@@ -2458,6 +2470,7 @@ function* drive(
route,
todoOpen,
inspection: revealWork ? undefined : state.inspection,
+ draftOpen: digit === "3" ? false : state.draftOpen,
restore: undefined,
};
const view = yield* inputView(candidate, at);
@@ -2506,7 +2519,14 @@ function* drive(
hints.set(digit, undefined);
continue;
}
- const key = JSON.stringify([route.surface, route.view, route.right, todoOpen, revealWork]);
+ const key = JSON.stringify([
+ route.surface,
+ route.view,
+ route.right,
+ todoOpen,
+ revealWork,
+ digit === "3",
+ ]);
let descriptions = routes.get(key);
if (descriptions === undefined) {
const destination = yield* inputView(
@@ -2515,6 +2535,7 @@ function* drive(
route,
todoOpen,
inspection: revealWork ? undefined : state.inspection,
+ draftOpen: digit === "3" ? false : state.draftOpen,
restore: undefined,
},
view.size,
@@ -2532,13 +2553,15 @@ function* drive(
if (hasRegion(descriptions, region)) {
hints.set(
digit,
- revealWork
- ? "closes inspection"
- : route !== current
- ? focusRouteHint(route, narrow)
- : todoOpen
- ? "switches to the TODO tab"
- : "switches to the Sidekick tab",
+ digit === "3" && roundEditorVisible(view)
+ ? "shows selected work"
+ : revealWork
+ ? "closes inspection"
+ : route !== current
+ ? focusRouteHint(route, narrow)
+ : todoOpen
+ ? "switches to the TODO tab"
+ : "switches to the Sidekick tab",
);
}
}
@@ -3122,7 +3145,7 @@ function* drive(
});
}
if (performed.refusal !== undefined) {
- state = Object.freeze({ ...state, refusal: performed.refusal });
+ state = Object.freeze({ ...state, refusal: performed.refusal, refusalPosition: undefined });
refusedByReadiness = performed.refusedByReadiness === true;
} else if (transition.state.refusal === undefined) {
// The action was taken, or refused for its own reasons and then cleared.
@@ -3803,7 +3826,10 @@ function keyOfFocus(tree: ReplTree): string | undefined {
}
function shortcutRevealsWork(view: ReplView, digit: string): boolean {
- return (digit === "3" || digit === "4") && inlineInspectionOpen(view);
+ return (
+ (digit === "3" && roundEditorVisible(view)) ||
+ ((digit === "3" || digit === "4") && inlineInspectionOpen(view))
+ );
}
/**
@@ -5694,6 +5720,57 @@ export function* prepareFrame(
return first;
}
const widths = widthsOf(probe.manifest, first.value);
+ const workspace = stagedWorkspace(view) !== undefined;
+ const reasonInHeader = workspace ? executionRefusal(view) : undefined;
+ const header =
+ reasonInHeader === undefined || widths.surfaceBody < 1
+ ? Ok([])
+ : yield* fitPlain(
+ renderer,
+ view.size,
+ [{ key: "header-refusal", text: reasonInHeader }],
+ view.size.columns,
+ guidanceStore,
+ );
+ if (!header.ok) {
+ return header;
+ }
+ const headerLimit = Math.max(1, Math.floor(view.size.rows / 4));
+ const refusalPosition = view.state.refusalPosition;
+ const headerRefusalWindow =
+ header.value.length > headerLimit
+ ? admitRows({
+ offset: refusalPosition?.reason === view.state.refusal ? (refusalPosition?.from ?? 0) : 0,
+ total: header.value.length,
+ capacity: headerLimit - 1,
+ })
+ : undefined;
+ const headerRefusal = (
+ headerRefusalWindow === undefined
+ ? header.value
+ : header.value.slice(
+ headerRefusalWindow.from,
+ headerRefusalWindow.from + headerRefusalWindow.count,
+ )
+ ).map((row) => row.text);
+ if (headerRefusalWindow !== undefined) {
+ const { from, count, total } = headerRefusalWindow;
+ headerRefusal.push(`Wheel here to read the refusal · ${from + 1}–${from + count} of ${total}`);
+ }
+ const drawerRoom = widths.drawer ?? 0;
+ const help =
+ !workspace || !modalOpen(view) || drawerRoom < 1
+ ? Ok([])
+ : yield* fitPlain(
+ renderer,
+ view.size,
+ [{ key: "drawer-help", text: drawerGuidance(view) }],
+ drawerRoom,
+ );
+ if (!help.ok) {
+ return help;
+ }
+ const drawerHelp = help.value.map((row) => row.text);
// The staged queue, fitted to the text column its first message measured.
// Before every pass below, because each message is as many rows as its text
@@ -5777,12 +5854,6 @@ export function* prepareFrame(
wrapped.add(line.key);
}
}
- // What the Draft's field has left, once this frame's own heading row and the
- // control beside it have been measured. Settled here, before anything is
- // mounted, and carried into every pass after it — the field is stated in the
- // measuring ops and in the committed ops alike, because a width the two
- // passes disagreed about is a control drawn where nothing measured it.
- let field: number | undefined;
let messageText: number | undefined;
let historyRoom: number | undefined;
let historySpace: number | undefined;
@@ -5803,12 +5874,14 @@ export function* prepareFrame(
let historyWideMap: number | undefined;
const queuing = (context: ReplPresentationContext): ReplPresentationContext => ({
...context,
+ headerRefusal,
+ headerRefusalWindow,
+ drawerHelp,
todo: todoRows.value,
...(queued.value === undefined ? {} : { queue: queued.value }),
queueStatus: queueStatus.value,
...(wrapped.size === 0 ? {} : { headers: wrapped }),
...(historySpace === undefined ? {} : { historyGap: historySpace }),
- ...(field === undefined ? {} : { draftField: field }),
...(messageText === undefined ? {} : { queueText: messageText }),
...(historyRoom === undefined ? {} : { historyMap: historyRoom }),
...(historyParts === undefined ? {} : { historySplit: historyParts }),
@@ -5830,14 +5903,14 @@ export function* prepareFrame(
// The directions, fitted to the surface they are drawn on. Before the frame
// below, because they are fixed content: the room the composer may grow into
// is what is left once they have taken theirs.
- const guidanceRoom = widths.guidance ?? widths.surfaceBody;
+ const guidanceRoom = widths.surfaceBody;
const guidance =
- widths.surfaceBody < 1 || guidanceRoom < 1
+ workspace || guidanceRoom < 1
? Ok(undefined)
: yield* fitPlain(
renderer,
view.size,
- [{ key: "guidance", text: footerSentence(view) }],
+ [{ key: "guidance", text: guidanceSentence(view) }],
guidanceRoom,
guidanceStore,
);
@@ -5852,7 +5925,7 @@ export function* prepareFrame(
// never share a frame — a refusal is the whole of what its screen says — so
// one store holds whichever of them this frame is giving.
const refused =
- view.refusal === undefined || widths.surfaceBody < 1
+ workspace || view.refusal === undefined || widths.surfaceBody < 1
? Ok(undefined)
: yield* fitPlain(
renderer,
@@ -5879,7 +5952,6 @@ export function* prepareFrame(
if (!fitted.ok) {
return fitted;
}
- field = draftFieldWidth(probed.manifest, (id) => fitted.value.boundsOf(id)?.width);
messageText = queueTextWidth(
probed.manifest,
(id) => fitted.value.boundsOf(id)?.width,
@@ -5928,7 +6000,6 @@ export function* prepareFrame(
// that counts them has to be a pass that knows where it starts. Bounded, not
// a loop — a floating layer takes no row out of any column's flow, so the
// guidance it was moved clear of cannot move because it moved.
- const workspace = stagedWorkspace(view) !== undefined;
const envelope = routeDrawerRect(
view.size,
guidanceBottomOf(probed.manifest, fitted.value),
@@ -6160,20 +6231,20 @@ export function* prepareFrame(
if (!rail.ok) {
return rail;
}
- // The staged Draft's own value, fitted to the selected work it sits in. A
- // fixed number of rows, so no measurement above depends on it.
- //
+ const editorBounds = third.value.boundsOf(ROUND_EDITOR_BODY);
+ const editorWidth = Math.floor(editorBounds?.width ?? 0);
const drafted =
- draftLinesOf(view) === undefined || widths.surfaceBody < 1
+ !roundEditorVisible(view) || editorWidth < 1
? Ok(undefined)
: yield* fitEditor(
renderer,
view.size,
caretFor(view.state.draft, view.state.draftCaret),
- widths.surfaceBody,
+ editorWidth,
view.focused === "footer:input",
draftStore,
sourceRuns,
+ "horizontal",
);
if (!drafted.ok) {
return drafted;
@@ -6181,7 +6252,7 @@ export function* prepareFrame(
let draftRows: readonly string[] | undefined;
if (drafted.value !== undefined) {
editors.set("footer:input", drafted.value);
- const count = draftRowsOf([]).length;
+ const count = Math.max(1, capacityOf(editorBounds));
const from = Math.max(0, Math.min(drafted.value.active, drafted.value.display.length - count));
const shown = drafted.value.display.slice(from, from + count).map((one) => one.text);
draftRows = [...shown, ...Array.from({ length: count - shown.length }, () => "")];
@@ -6233,6 +6304,7 @@ export function* prepareFrame(
todo: todoRows.value,
notices: notices.value,
details: details.value,
+ headerRefusalWindow,
boundsOf: (id: string) => geometry.value.boundsOf(id),
});
const context: ReplPresentationContext = {
@@ -6251,10 +6323,12 @@ export function* prepareFrame(
sessionMaterialize: sessions.materialize,
message: shown,
guidance: guidanceRows,
+ headerRefusal,
+ headerRefusalWindow,
+ drawerHelp,
refusal: refusalRows,
rail: rail.value,
drawer: envelope,
- draftField: field,
queueText: messageText,
historyMap: historyRoom,
historyGap: historySpace,
@@ -6427,20 +6501,9 @@ function widthsOf(manifest: ReplLayoutManifest, measured: ReplMeasured): ReplMea
body: bodyOf(SIDEKICK_BODY, "inspection", "content"),
drawer: widthOf(measured, manifest.viewports.find((slot) => slot.region === "drawer")?.id),
queue: widthOf(measured, manifest.contents.find((content) => content.id === QUEUE_TEXT)?.id),
- guidance: guidanceWidthOf(manifest, measured),
};
}
-/**
- * The guidance row's own width, where a frame draws the guidance below the body.
- *
- * None otherwise, so the guidance is fitted to the selected work it is part of.
- */
-function guidanceWidthOf(manifest: ReplLayoutManifest, measured: ReplMeasured): number | undefined {
- const drawn = flatten(manifest.root).some((box) => box.id === GUIDANCE_ROW);
- return drawn ? widthOf(measured, GUIDANCE_ROW) : undefined;
-}
-
function widthOf(measured: ReplMeasured, id: string | undefined): number {
if (id === undefined) {
return 0;
diff --git a/packages/cli/src/repl/screen-regions.ts b/packages/cli/src/repl/screen-regions.ts
index 0002e48a7..1c247dbb0 100644
--- a/packages/cli/src/repl/screen-regions.ts
+++ b/packages/cli/src/repl/screen-regions.ts
@@ -40,6 +40,11 @@ const DRAFT_REGION: ReplFocusRegion = Object.freeze({
rank: 3,
axis: "horizontal",
});
+const ROUND_ACTIONS_REGION: ReplFocusRegion = Object.freeze({
+ key: "round-actions",
+ rank: 3.5,
+ axis: "horizontal",
+});
const TABS_REGION: ReplFocusRegion = Object.freeze({
key: "tabs",
rank: 4,
@@ -256,10 +261,13 @@ function screenPlacement(
return { region: selected, entry: 1 };
}
if (key === "footer:input") {
- return { region: DRAFT_REGION, entry: 0 };
+ return { region: outlet(DRAFT_REGION, facts), entry: 0 };
+ }
+ if (key === "draft:new") {
+ return { region: outlet(DRAFT_REGION, facts), entry: 1 };
}
- if (key === "draft:send" || key === "draft:stop") {
- return { region: DRAFT_REGION };
+ if (key === "draft:send" || key === "draft:stop" || key === "draft:close") {
+ return { region: ROUND_ACTIONS_REGION, ...(key === "draft:send" ? { entry: 0 } : {}) };
}
if (key.startsWith("tab:")) {
return { region: TABS_REGION, ...(key === "tab:bindings" ? { entry: 0 } : {}) };
diff --git a/packages/cli/tests/repl-agent-interface.test.ts b/packages/cli/tests/repl-agent-interface.test.ts
index 46a5d56a3..267353421 100644
--- a/packages/cli/tests/repl-agent-interface.test.ts
+++ b/packages/cli/tests/repl-agent-interface.test.ts
@@ -2014,6 +2014,8 @@ describe("U2 — the program performs a permission, end to end", () => {
// One entry, submitted the way a person submits one.
yield* pasteDraft(page, THREE_SPAWNS);
+ yield* page.key("Tab");
+ yield* page.until("Round Send focused", (one) => one.shows("> Send"));
yield* page.key("Enter");
yield* page.until("the request being announced", requestShown);
@@ -2069,6 +2071,8 @@ describe("U2 — the program performs a permission, end to end", () => {
yield* scoped(function* (): Operation {
const { page } = yield* useAgentPage(stub);
yield* pasteDraft(page, THREE_SPAWNS);
+ yield* page.key("Tab");
+ yield* page.until("Round Send focused", (one) => one.shows("> Send"));
yield* page.key("Enter");
yield* page.until("the request being announced", requestShown);
@@ -2130,6 +2134,8 @@ describe("U4 — the loop wakes for Agent work", () => {
const { page } = yield* useAgentPage(stub);
const { terminal } = page.repl;
yield* pasteDraft(page, THREE_SPAWNS);
+ yield* page.key("Tab");
+ yield* page.until("Round Send focused", (one) => one.shows("> Send"));
yield* page.key("Enter");
// A stable screen: all three observed, none of them started.
@@ -3787,6 +3793,8 @@ describe("U2 — a draft outlives a permission and is still editable", () => {
// One entry, which is what will ask for the permission.
yield* pasteDraft(page, THREE_SPAWNS);
+ yield* page.key("Tab");
+ yield* page.until("Round Send focused", (one) => one.shows("> Send"));
yield* page.key("Enter");
// That a request is waiting is read from the one row that says what the
@@ -3844,7 +3852,8 @@ describe("U2 — a draft outlives a permission and is still editable", () => {
// 4. Found again the way the row says to find it, and still editable: a
// draft nobody can get back to is a draft that was not really kept.
const EDITED = `${TYPED}-EDITED`;
- yield* draftText(page, "-EDITED", size.columns === 72 ? ["Tab"] : ["Tab", "Tab"]);
+ yield* intoDraft(page);
+ yield* draftText(page, "-EDITED");
expect(draftShows(page.screen(), EDITED)).toBe(true);
// 5. And it is the thing that becomes the next entry, once the one that
@@ -3862,17 +3871,14 @@ describe("U2 — a draft outlives a permission and is still editable", () => {
// modal over the draft the rows below go on to read.
expect(railMark(page.screen(), 1)).toBe(RAIL.ok);
yield* intoDraft(page);
- yield* page.key("Enter");
+ yield* page.press("Send", { onRow: "✎ draft" });
// The History rail's own mark for the second entry, which every size
// draws: the catalog that spells `2.` is a drawer now, and one opened
// here would be a drawer over the draft this row goes on to read.
yield* page.until("the second entry", (one) => railMark(one, 2) !== undefined);
// Submitted means consumed: the draft is the *next* entry's, and there is
// no next one typed yet.
- yield* page.until(
- "the draft being spent",
- (one) => one.shows(DRAFT) && !draftShows(one, TYPED),
- );
+ yield* page.until("the draft being spent", (one) => !one.shows(DRAFT));
// And the file says which bytes became that entry. An entry appearing and
// a draft clearing are both true of one admitted from the wrong source,
diff --git a/packages/cli/tests/repl-agent-journey.test.ts b/packages/cli/tests/repl-agent-journey.test.ts
index 1a9efd465..3c14dac8b 100644
--- a/packages/cli/tests/repl-agent-journey.test.ts
+++ b/packages/cli/tests/repl-agent-journey.test.ts
@@ -16,7 +16,7 @@ import { tmpdir } from "node:os";
import { join, relative } from "node:path";
import { randomBytes } from "node:crypto";
-import { decodeLocation } from "../src/repl/route.ts";
+import { decodeLocation, encodeLocation } from "../src/repl/route.ts";
import type { ReplRoute } from "../src/repl/route.ts";
import { installReplHost } from "../src/repl-assembly.ts";
import { ReplTerminal } from "../src/repl/terminal.ts";
@@ -863,7 +863,7 @@ describe("J3 — durable truth, and a cold process over it", () => {
const cold = createFakeAcp();
yield* scoped(function* (): Operation {
- const at = `${location.split("?")[0]}/${selected.key}`;
+ const at = encodeLocation({ ...routeOf(location), scopes: [selected.key] });
const { page } = yield* beginJourney({ fake: cold, hostRoot, size: WIDE, location: at });
yield* entrySettles(page, 1, "ok");
@@ -881,7 +881,7 @@ describe("J3 — durable truth, and a cold process over it", () => {
const transcript = page
.screen()
- .rows.map((row) => row.slice(page.screen().locate(DRAFT_HEADING).column))
+ .rows.map((row) => row.slice(page.screen().locate("Entries ›").column))
.join("\n");
expect(transcript).toContain("TWO-DONE");
expect(transcript).not.toContain("ONE-DONE");
@@ -1008,7 +1008,7 @@ describe("J3 — durable truth, and a cold process over it", () => {
expect(route.at).toBe("yield:root:3");
expect(route.inspect).toBe(true);
expect(route.surface).toBe("entries");
- expect(route.scopes).toEqual([]);
+ expect(route.scopes).toEqual(["entry-1"]);
});
it("J3: a location this host cannot read refuses before any replay", function* () {
@@ -1204,19 +1204,19 @@ describe("J2 — a filter and a draft across a resize (#875 R1)", () => {
yield* draftText(page, TYPED);
expect(conversationFilter(page.screen())).toBe(filtered);
- expect(page.screen().found(TYPED, { after: "DRAFT" })).toBe(1);
+ expect(page.screen().found(TYPED, DRAFT_VALUE)).toBe(1);
expect(childrenShown(page.screen())).toHaveLength(1);
const narrow = yield* page.resize({ columns: 72, rows: 20 });
expect(narrow.rows.length).toBe(20);
- expect(page.screen().found(TYPED, { after: "DRAFT" })).toBe(1);
+ expect(page.screen().found(TYPED, DRAFT_VALUE)).toBe(1);
expect(narrow.rows.filter((line) => line.trimEnd().length > 72)).toEqual([]);
expect(narrow.shows("Entries")).toBe(true);
const back = yield* page.resize(WIDE);
expect(back.rows.length).toBe(140);
expect(conversationFilter(back)).toBe(filtered);
- expect(page.screen().found(TYPED, { after: "DRAFT" })).toBe(1);
+ expect(page.screen().found(TYPED, DRAFT_VALUE)).toBe(1);
expect(childrenShown(back)).toHaveLength(1);
location = yield* leave(page);
@@ -1229,7 +1229,7 @@ describe("J2 — a filter and a draft across a resize (#875 R1)", () => {
chosen = standingRoute.session;
expect(standingRoute.draft).toBe(TYPED);
expect(standingRoute.surface).toBe("entries");
- expect(standingRoute.scopes).toEqual([]);
+ expect(standingRoute.scopes).toEqual(["entry-1"]);
expect(standingRoute.at).toBeUndefined();
expect(standingRoute.inspect).toBe(false);
expect(live.prompts).toHaveLength(3);
@@ -1573,12 +1573,12 @@ function* beginJourney(options: {
function* submitted(page: ReplPage, text: string, order: number): Operation {
yield* pasteDraft(page, text);
+ yield* page.key("Tab");
+ yield* page.until("Send focused", (frame) => frame.shows("> Send"));
yield* page.key("Enter");
yield* page.until(
`the draft becoming entry ${order}`,
- (frame) =>
- railMark(frame, order) !== undefined &&
- frame.found(text.trimEnd().split(/\s+/).at(-1) ?? text, DRAFT_VALUE) === 0,
+ (frame) => railMark(frame, order) !== undefined && !frame.shows("✎ draft"),
);
}
diff --git a/packages/cli/tests/repl-asset-import.test.ts b/packages/cli/tests/repl-asset-import.test.ts
index 31fe1797c..b4a2c1b65 100644
--- a/packages/cli/tests/repl-asset-import.test.ts
+++ b/packages/cli/tests/repl-asset-import.test.ts
@@ -775,6 +775,8 @@ describe("asset import acknowledgement and independent owners", () => {
page,
'The entry is asking.',
);
+ yield* page.key("Tab");
+ yield* page.until("Round Send focused", (one) => one.shows("> Send"));
yield* page.key("Enter");
yield* page.until("entry question", (one) => one.shows("[answer]"));
page.repl.fake.script({ reply: invocation(source, "assets/never.bin") });
diff --git a/packages/cli/tests/repl-caret.test.ts b/packages/cli/tests/repl-caret.test.ts
index aadef2d54..7535e4519 100644
--- a/packages/cli/tests/repl-caret.test.ts
+++ b/packages/cli/tests/repl-caret.test.ts
@@ -152,6 +152,7 @@ describe("REPL caret editing", () => {
const draft = "a\u0301界👩👩👧👦 kept\n".repeat(40);
const state = {
...initialState("bounded-editor"),
+ draftOpen: true,
draft,
draftCaret: { value: draft, offset: draft.length / 2 },
};
@@ -201,6 +202,7 @@ describe("REPL caret editing", () => {
}
expect(found).toBe(true);
yield* presenter.commit(view);
+ yield* presenter.tree.dispatch({ kind: "key", key: "Focus4" });
for (const key of ["ArrowUp", "ArrowDown", "Home", "End"] as const) {
const dispatched = yield* presenter.tree.dispatch({ kind: "key", key });
if (!dispatched.ok) {
diff --git a/packages/cli/tests/repl-composition.test.ts b/packages/cli/tests/repl-composition.test.ts
index eb6ba7f8b..dbbbd4426 100644
--- a/packages/cli/tests/repl-composition.test.ts
+++ b/packages/cli/tests/repl-composition.test.ts
@@ -1621,10 +1621,20 @@ describe("1075 invocation to REPL entry", () => {
),
);
yield* awaited("initial REPL frame", () => recording.terminal.drawn > 1);
- recording.terminal.feed("\x074");
+ recording.terminal.feed("\x074\r");
+ yield* awaited(
+ "Round editor ready",
+ () => recording.terminal.screen?.rows().some((row) => row.includes("> Round")) === true,
+ );
recording.terminal.feed(
- `\r`,
+ ``,
+ );
+ recording.terminal.feed("\t");
+ yield* awaited(
+ "Round Send focused",
+ () => recording.terminal.screen?.rows().some((row) => row.includes("> Send")) === true,
);
+ recording.terminal.feed("\r");
yield* awaitedFact("submitted entry settlement", function* () {
const opened = yield* pairedReplRepository(join(root, "xmd", "repl")).open(
"absolute-entry",
diff --git a/packages/cli/tests/repl-exec-output.test.ts b/packages/cli/tests/repl-exec-output.test.ts
index 86349f954..14284558e 100644
--- a/packages/cli/tests/repl-exec-output.test.ts
+++ b/packages/cli/tests/repl-exec-output.test.ts
@@ -15,7 +15,7 @@ import { useMountedHost } from "./support/mounted-repl.ts";
import { useReplPage } from "./support/repl-page.ts";
import type { ReplPage } from "./support/repl-page.ts";
import { awaitedFact, mountedReading } from "./support/mounted-repl.ts";
-import { intoComposer, pasteDraft, sidekickIdle } from "./support/screen-journeys.ts";
+import { intoComposer, intoDraft, pasteDraft, sidekickIdle } from "./support/screen-journeys.ts";
describe("E3 retained command output", () => {
it("retains captured control bytes in output, bindings, and command records", function* () {
@@ -58,9 +58,9 @@ describe("E3 retained command output", () => {
function* submit(page: ReplPage, source: string, order = 1): Operation {
yield* pasteDraft(page, source);
- yield* page.press("[send]", { onRow: " DRAFT" });
+ yield* page.press("Send", { onRow: "✎ draft" });
yield* page.until(`entry ${order} admitted`, (one) =>
- ["●", "✓", "×"].some((status) => one.shows(`${order} ${status}`)),
+ ["●", "⠋", "✓", "×"].some((status) => one.shows(`${order} ${status}`)),
);
}
@@ -100,8 +100,10 @@ describe("REPL foreground command presentation E1", () => {
);
yield* awaitedFact("the child holding after both writes", () => exists(ready));
expect(yield* exists(release)).toBe(false);
- yield* page.type("unsent entry draft");
+ yield* page.until("the admitted editor closes", (one) => !one.shows("✎ draft"));
+ yield* pasteDraft(page, "unsent entry draft");
yield* page.until("the unsent draft", (one) => one.shows("unsent entry draft"));
+ yield* page.type("\x073");
const during = yield* page.until(
"both command channels inside the owning reading",
(one) =>
@@ -111,10 +113,14 @@ describe("REPL foreground command presentation E1", () => {
one.shows("Command stderr"),
);
expect(leaks).toEqual([]);
- expect(during.shows("unsent entry draft")).toBe(true);
+ expect(during.shows("unsent entry draft")).toBe(false);
expect(during.shows("No messages yet")).toBe(true);
+ yield* intoDraft(page);
yield* page.type(" still focused");
- yield* page.until("the draft retaining focus", (one) => one.shows("still focused"));
+ yield* page.until("the draft retaining focus", (one) =>
+ one.shows("unsent entry draft still focused"),
+ );
+ yield* page.type("\x073");
yield* writeTextFile(release, "release");
yield* page.until("entry 1 settling", (one) => one.shows("1 ✓"));
expect(page.screen().shows("live-stdout")).toBe(true);
@@ -208,15 +214,14 @@ describe("REPL command routing, containment and history E2–E5", () => {
page,
'```sh exec\ncontrolled-output\n```\n\n```sh exec as="captured"\ncontrolled-bound\n```\n{captured.stdout}',
);
- yield* page.until(
- "the admitted draft clearing",
- (one) => one.found("{captured.stdout}", { after: " DRAFT" }) === 0,
- );
- yield* page.type("draft stays");
+ yield* page.until("the admitted draft clearing", (one) => !one.shows("✎ draft"));
+ yield* pasteDraft(page, "draft stays");
yield* page.until("the preserved draft", (one) => one.shows("draft stays"));
yield* intoComposer(page);
yield* page.type("message stays");
yield* page.until("the preserved message", (one) => one.shows("message stays"));
+ yield* page.type("\x073");
+ yield* intoComposer(page);
const paneColumn = page.screen().locate("SIDEKICK").column;
const neighbor = page.screen().rows.map((row) => row.slice(paneColumn));
start.resolve();
@@ -229,16 +234,19 @@ describe("REPL command routing, containment and history E2–E5", () => {
expect(shown.shows("\\x0d\\x09")).toBe(true);
expect(shown.shows("\\x07")).toBe(true);
expect(shown.shows("\\x9b")).toBe(true);
- expect(shown.shows("draft stays")).toBe(true);
+ expect(shown.shows("draft stays")).toBe(false);
expect(shown.rows.map((row) => row.slice(paneColumn))).toEqual(neighbor);
yield* page.type(" focused");
yield* page.until("the message retaining focus", (one) => one.shows("message stays focused"));
yield* page.resize({ columns: 72, rows: 24 });
yield* page.resize({ columns: 160, rows: 44 });
+ yield* intoDraft(page);
yield* page.until(
"the restored drafts",
(one) => one.shows("draft stays") && one.shows("message stays focused"),
);
+ yield* page.type("\x073");
+ yield* intoComposer(page);
// Wheel movement reads the whole fitted line without moving the composer.
const at = page.screen().locate("interleaved-stderr");
let tail = false;
@@ -426,7 +434,7 @@ describe("REPL command routing, containment and history E2–E5", () => {
yield* page.until("cleanup displayed after root Close", (one) =>
one.shows("cleanup-before-history"),
);
- yield* page.type("entry draft remains");
+ yield* pasteDraft(page, "entry draft remains");
yield* page.until("the entry draft", (one) => one.shows("entry draft remains"));
yield* page.press("[history]");
yield* page.until("the history checkpoints", (one) => one.shows("Entry 1 admitted"));
@@ -434,6 +442,8 @@ describe("REPL command routing, containment and history E2–E5", () => {
yield* page.until("the frozen earlier entry", (one) => one.shows("[live]"));
yield* page.press("[close]");
yield* page.until("the checkpoint drawer closing", (one) => !one.shows("[close]"));
+ yield* page.type("\x073");
+ yield* page.until("the frozen reading", (one) => one.shows("Entry 1") && !one.shows("✎ draft"));
page.repl.fake.script({ reply: "" });
yield* intoComposer(page);
yield* page.type("background-request");
@@ -455,7 +465,10 @@ describe("REPL command routing, containment and history E2–E5", () => {
);
expect(frozen.shows("[live]")).toBe(true);
expect(frozen.shows("Entry 1")).toBe(true);
- expect(frozen.shows("entry draft remains")).toBe(true);
+ yield* intoDraft(page);
+ expect(page.screen().shows("entry draft remains")).toBe(true);
+ yield* page.type("\x073");
+ yield* page.until("the retained reading resumes", (one) => !one.shows("✎ draft"));
expect(frozen.shows("cleanup-after-history")).toBe(false);
expect(frozen.shows("Command stderr")).toBe(false);
yield* page.press("[live]");
diff --git a/packages/cli/tests/repl-exit-pty.test.ts b/packages/cli/tests/repl-exit-pty.test.ts
index 45e6173f4..5f9107cd6 100644
--- a/packages/cli/tests/repl-exit-pty.test.ts
+++ b/packages/cli/tests/repl-exit-pty.test.ts
@@ -659,13 +659,13 @@ describe("REPL exit: a real terminal, and nothing further typed", () => {
// becomes many decoded keystrokes, so a reader that handed its buffer over
// without yielding would lose the tail of it — and losing the tail of what
// somebody typed is the kind of defect a single keypress never shows.
- yield* pty.type("\x074");
- yield* showing(pty, "> DRAFT", LEAVE_MS);
+ yield* pty.type("\x074\r");
+ yield* showing(pty, "> Round", LEAVE_MS);
yield* pty.type(BURST);
yield* showing(pty, BURST, LEAVE_MS);
- // Draft -> Selected work -> Transcript -> History, then Exit locally.
- for (const bytes of ["\x1b[Z", "\x1b[Z", "\x1b[Z", "\x1b[C"]) {
+ // History, then Exit locally.
+ for (const bytes of ["\x078", "\x1b[C"]) {
yield* pty.type(bytes);
yield* sleep(100);
}
diff --git a/packages/cli/tests/repl-focus-regions.test.ts b/packages/cli/tests/repl-focus-regions.test.ts
index 0c0f288ba..9fab2e9a3 100644
--- a/packages/cli/tests/repl-focus-regions.test.ts
+++ b/packages/cli/tests/repl-focus-regions.test.ts
@@ -28,6 +28,8 @@ import { REFERENCE_DIRECTORY } from "./fixtures/repl/reference.ts";
import { useReplPage } from "./support/repl-page.ts";
import type { PageKey, ReplPage } from "./support/repl-page.ts";
+import { DRAFT_VALUE, intoDraft } from "./support/screen-journeys.ts";
+
const WIDE = { columns: 160, rows: 36 };
const MEDIUM = { columns: 120, rows: 30 };
const NARROW = { columns: 72, rows: 20 };
@@ -47,29 +49,27 @@ function* typed(page: ReplPage, text: string): Operation {
}
function* draftFocus(page: ReplPage): Operation {
- yield* page.type("\x074");
- yield* page.until("Draft focus", (one) => one.shows("> DRAFT"));
+ yield* intoDraft(page);
}
describe("REPL focus regions: the normal screen", () => {
for (const size of [WIDE, MEDIUM]) {
it(`R1/R2: fixed region entries deliver Draft and Message input at ${size.columns}x${size.rows}`, function* () {
const page = yield* useReplPage({ size });
+ yield* draftFocus(page);
yield* typed(page, "draft-kept");
- // Draft -> Tabs -> Right reading -> TODO -> Message, independent of child counts.
+ // Draft -> Send -> Tabs -> Right reading -> TODO -> Message.
+ yield* key(page, "Tab");
yield* key(page, "Tab");
yield* key(page, "Tab");
yield* key(page, "Tab");
yield* key(page, "Tab");
yield* typed(page, "message-kept");
expect(page.screen().found("message-kept", { after: "message the sidekick" })).toBe(1);
- expect(page.screen().found("draft-kept", { after: " DRAFT" })).toBe(1);
+ expect(page.screen().found("draft-kept", DRAFT_VALUE)).toBe(1);
expect(page.repl.fake.prompts).toHaveLength(0);
- // Message -> History -> Transcript -> Selected work -> Draft.
- for (let step = 0; step < 4; step += 1) {
- yield* key(page, "Tab");
- }
+ yield* draftFocus(page);
yield* typed(page, "-returned");
expect(page.screen().shows("draft-kept-returned")).toBe(true);
for (const name of [
@@ -84,7 +84,8 @@ describe("REPL focus regions: the normal screen", () => {
}
yield* key(page, "Alt+ArrowDown");
expect(page.screen().shows("draft-kept-returned")).toBe(true);
- expect(page.screen().shows("No entry yet")).toBe(true);
+ expect(page.screen().shows("Ready for Entry 1")).toBe(true);
+ yield* draftFocus(page);
yield* key(page, "Tab");
yield* key(page, "Backtab");
yield* typed(page, "-fixed");
@@ -97,6 +98,7 @@ describe("REPL focus regions: the normal screen", () => {
const page = yield* useReplPage({ size: WIDE });
yield* draftFocus(page);
yield* key(page, "Tab");
+ yield* key(page, "Tab");
yield* key(page, "ArrowLeft");
expect(page.screen().shows("> SIDEKICK")).toBe(true);
yield* key(page, "ArrowRight");
@@ -121,9 +123,9 @@ describe("REPL focus regions: the normal screen", () => {
yield* draftFocus(page);
yield* typed(page, "survives-resize");
yield* key(page, "Tab");
- yield* page.resize(NARROW);
- // The empty routed outlet has no control: recovery is Sessions on the bar.
yield* key(page, "Tab");
+ yield* page.resize(NARROW);
+ yield* draftFocus(page);
yield* typed(page, "-narrow");
expect(page.screen().shows("survives-resize-narrow")).toBe(true);
yield* page.resize(WIDE);
@@ -133,6 +135,20 @@ describe("REPL focus regions: the normal screen", () => {
});
describe("REPL focus regions: Unicode caret editing", () => {
+ it("reveals both ends of a source line longer than the terminal", function* () {
+ const page = yield* useReplPage({ size: MEDIUM });
+ yield* draftFocus(page);
+ const source = `START ${"界".repeat(100)} END`;
+ yield* page.type(source);
+ yield* page.until("the end of the source", (one) => one.found(" END", DRAFT_VALUE) === 1);
+ expect(page.screen().found("START ", DRAFT_VALUE)).toBe(0);
+ yield* key(page, "Home");
+ expect(page.screen().found("START ", DRAFT_VALUE)).toBe(1);
+ expect(page.screen().found(" END", DRAFT_VALUE)).toBe(0);
+ yield* key(page, "End");
+ expect(page.screen().found(" END", DRAFT_VALUE)).toBe(1);
+ });
+
it("PV3: Draft and Message edit at independent carets across rows, focus and resize", function* () {
const page = yield* useReplPage({ size: MEDIUM });
yield* draftFocus(page);
@@ -146,17 +162,13 @@ describe("REPL focus regions: Unicode caret editing", () => {
yield* page.resize(NARROW);
yield* typed(page, "!");
expect(page.screen().shows("é中!界")).toBe(true);
- yield* key(page, "Alt+ArrowDown");
yield* key(page, "Tab");
yield* key(page, "Backtab");
yield* typed(page, "?");
expect(page.screen().shows("é中!?界")).toBe(true);
yield* key(page, "Backspace");
yield* page.resize(MEDIUM);
- yield* key(page, "Tab");
- yield* key(page, "Tab");
- yield* key(page, "Tab");
- yield* key(page, "Tab");
+ yield* page.type("\x071");
yield* page.type(" m界\nXYZ");
yield* page.until("both Message rows", (one) => one.shows(" m界") && one.shows("XYZ"));
yield* key(page, "Home");
@@ -175,7 +187,7 @@ describe("REPL focus regions: Unicode caret editing", () => {
yield* page.until("Message preserved caret", (one) => one.shows("X中!YZ"));
expect(page.screen().shows("é中!界")).toBe(true);
expect(page.repl.fake.prompts).toHaveLength(0);
- expect(page.screen().shows("No entry yet")).toBe(true);
+ expect(page.screen().shows("Ready for Entry 1")).toBe(true);
});
});
@@ -185,10 +197,11 @@ describe("REPL focus regions: reading and narrow recovery", () => {
yield* draftFocus(page);
yield* page.type(Array.from({ length: 50 }, (_, at) => `Reading row ${at}`).join("\n"));
yield* page.until("the complete source", (one) => one.shows("Reading row 49"));
- yield* page.key("Enter");
+ yield* page.press("Send", { onRow: "✎ draft" });
yield* page.until("the entry settled", (one) => one.shows("Ready for Entry 2"));
+ yield* draftFocus(page);
yield* typed(page, "kept-draft");
- yield* key(page, "Backtab");
+ yield* page.type("\x073");
yield* key(page, "Alt+ArrowDown");
yield* key(page, "Alt+ArrowDown");
yield* key(page, "End");
@@ -202,6 +215,7 @@ describe("REPL focus regions: reading and narrow recovery", () => {
yield* key(page, "PageDown");
yield* key(page, "ArrowUp");
yield* key(page, "Enter");
+ yield* draftFocus(page);
expect(page.screen().shows("kept-draft")).toBe(true);
expect(page.screen().shows("Ready for Entry 2")).toBe(true);
expect(page.repl.fake.prompts).toHaveLength(0);
@@ -213,21 +227,16 @@ describe("REPL focus regions: reading and narrow recovery", () => {
yield* page.type(
'Waiting for your answer.',
);
- yield* page.until("the source ready", (one) => one.shows(""));
- yield* page.key("Enter");
+ yield* page.until("the source ready", (one) => one.shows("Waiting for your answer."));
+ yield* page.press("Send", { onRow: "✎ draft" });
yield* page.until("the entry waiting", (one) => one.shows("[answer]"));
+ yield* draftFocus(page);
yield* typed(page, "next-draft");
- yield* key(page, "Tab");
- yield* key(page, "Tab");
- yield* key(page, "Tab");
- yield* key(page, "Tab");
+ yield* page.type("\x071");
yield* typed(page, "next-message");
yield* page.resize(MEDIUM);
yield* page.resize(NARROW);
- yield* key(page, "Backtab");
- yield* key(page, "ArrowRight");
- yield* key(page, "ArrowRight");
- yield* page.key("Enter");
+ yield* page.type("\x071");
yield* page.until("narrow Sidekick", (one) => one.shows("message the sidekick"));
expect(page.screen().shows("* Sidekick")).toBe(true);
expect(page.screen().shows("* Entries")).toBe(false);
@@ -238,8 +247,7 @@ describe("REPL focus regions: reading and narrow recovery", () => {
yield* page.until("the minimum-size refusal", (one) => one.shows("needs at least 72x20"));
yield* page.resize(NARROW);
yield* page.until("the routed reading recovered", (one) => one.shows("message the sidekick"));
- yield* key(page, "Tab");
- yield* key(page, "Tab");
+ yield* page.type("\x071");
yield* page.type("-recovered");
yield* page.until("the recovered Message", (one) => one.shows("next-message-narrow-recovered"));
yield* page.resize(WIDE);
@@ -249,7 +257,9 @@ describe("REPL focus regions: reading and narrow recovery", () => {
);
expect(page.screen().shows("next-draft")).toBe(true);
expect(page.screen().shows("[answer]")).toBe(true);
- expect(page.screen().shows("[stop]")).toBe(true);
+ yield* draftFocus(page);
+ expect(page.screen().shows("next-draft")).toBe(true);
+ expect(page.screen().found("Stop", { onRow: "✎ draft" })).toBe(1);
expect(page.repl.fake.prompts).toHaveLength(0);
});
});
@@ -257,18 +267,17 @@ describe("REPL focus regions: reading and narrow recovery", () => {
describe("REPL focus regions: the catalog drawer at the narrow size", () => {
it("R5: nested arrows reveal hidden entries, fixed Content entry and modal close restore", function* () {
const page = yield* useReplPage({ size: NARROW, includes: [REFERENCE_DIRECTORY] });
- yield* draftFocus(page);
for (let order = 1; order <= 6; order += 1) {
+ yield* draftFocus(page);
yield* typed(page, ``);
- yield* page.key("Enter");
+ yield* page.press("Send", { onRow: "✎ draft" });
yield* page.until(`entry ${order} settled`, (one) => one.shows(`${order} ✓`));
yield* page.until(`ready for entry ${order + 1}`, (one) =>
one.shows(`Ready for Entry ${order + 1}`),
);
}
- // Draft -> History -> Surface bar, then Entries. Arrows do not open it.
- yield* key(page, "Tab");
- yield* key(page, "Tab");
+ // Surface bar, then Entries. Arrows do not open the catalog.
+ yield* page.type("\x079");
yield* key(page, "ArrowRight");
expect(page.screen().shows("[close]")).toBe(false);
yield* page.key("Enter");
@@ -366,10 +375,9 @@ describe("REPL focus regions: owned composition invariants", () => {
const shown = yield* presenter.commit(withWorkspace(resolved.value, workspaceOf(model)));
expect(shown.keys).toContain("reading:anchor");
expect(shown.keys.some((key) => key.startsWith("work:crumb:"))).toBe(false);
- expect(focused(presenter)).toBe("footer:input");
- for (let step = 0; step < 3; step += 1) {
- yield* dispatched(presenter, "Tab");
- }
+ expect(focused(presenter)).toBe("reading:anchor");
+ yield* dispatched(presenter, "Tab");
+ yield* dispatched(presenter, "Focus3");
expect(focused(presenter)).toBe("reading:anchor");
});
@@ -382,7 +390,7 @@ describe("REPL focus regions: owned composition invariants", () => {
throw before.error;
}
yield* presenter.commit(withWorkspace(before.value, workspaceOf(model)));
- yield* dispatched(presenter, "Tab");
+ yield* dispatched(presenter, "Focus5");
expect(focused(presenter)).toBe("tab:bindings");
const below = { columns: 71, rows: 19 };
presenter.resize(below);
@@ -422,7 +430,8 @@ describe("REPL focus regions: owned composition invariants", () => {
}
const presenter = yield* usePresenter(size);
yield* presenter.commit(withWorkspace(view.value, workspaceOf(model)));
- expect(focused(presenter)).toBe("footer:input");
+ yield* dispatched(presenter, "Focus4");
+ expect(focused(presenter)).toBe("draft:new");
const entries = [
"tab:bindings",
"sidekick:anchor",
@@ -430,7 +439,7 @@ describe("REPL focus regions: owned composition invariants", () => {
"footer:history",
"transcript:selector",
"entries:heading",
- "footer:input",
+ "draft:new",
];
const walked: (string | undefined)[] = [];
for (const _entry of entries) {
@@ -450,7 +459,7 @@ describe("REPL focus regions: owned composition invariants", () => {
"sidekick:message",
"sidekick:anchor",
"tab:bindings",
- "footer:input",
+ "draft:new",
]);
});
}
@@ -460,6 +469,7 @@ describe("REPL focus regions: owned composition invariants", () => {
const presenter = yield* usePresenter(MEDIUM);
let state: ReplState = {
...initialState("caret"),
+ draftOpen: true,
draft: "first\nsecond\nthird\nfourth\nfifth",
};
function* commit() {
@@ -470,6 +480,8 @@ describe("REPL focus regions: owned composition invariants", () => {
return yield* presenter.commit(withWorkspace(resolved.value, workspaceOf(model)));
}
yield* commit();
+ yield* dispatched(presenter, "Focus4");
+ yield* commit();
const moved = yield* dispatched(presenter, "Home");
if (moved.outcome !== "action") {
throw new Error("the Draft did not claim Home");
@@ -518,8 +530,7 @@ describe("REPL focus regions: owned composition invariants", () => {
yield* commit();
}
yield* commit();
- yield* send("Tab");
- yield* send("Tab");
+ yield* send("Focus9");
yield* send("ArrowRight");
yield* send("Enter");
expect(focused(presenter)).toBe("entry:entry-1");
@@ -624,9 +635,7 @@ describe("REPL focus regions: background input ownership", () => {
const page = yield* useReplPage({ size: MEDIUM });
yield* draftFocus(page);
yield* typed(page, "kept draft");
- for (let at = 0; at < 4; at += 1) {
- yield* key(page, "Tab");
- }
+ yield* page.type("\x071");
page.repl.fake.script({
held: true,
reply:
@@ -660,9 +669,7 @@ describe("REPL focus regions: Sidekick reading keys", () => {
const page = yield* useReplPage({ size: MEDIUM });
yield* draftFocus(page);
yield* typed(page, "draft kept");
- for (let at = 0; at < 4; at += 1) {
- yield* key(page, "Tab");
- }
+ yield* page.type("\x071");
const first = Array.from({ length: 30 }, (_, at) => `Chat row ${at}`).join("\n");
const last = Array.from({ length: 30 }, (_, at) => `Chat row ${at + 30}`).join("\n");
page.repl.fake.script({ deltas: [``], holdAfter: 1 });
@@ -686,7 +693,7 @@ describe("REPL focus regions: Sidekick reading keys", () => {
yield* key(page, "ArrowUp");
expect(page.screen().shows("message kept")).toBe(true);
expect(page.screen().shows("draft kept")).toBe(true);
- expect(page.screen().shows("No entry yet")).toBe(true);
+ expect(page.screen().shows("Ready for Entry 1")).toBe(true);
expect(page.repl.fake.prompts).toHaveLength(1);
});
});
diff --git a/packages/cli/tests/repl-headless-attach.test.ts b/packages/cli/tests/repl-headless-attach.test.ts
index 09a8bb35b..3b4f7a97d 100644
--- a/packages/cli/tests/repl-headless-attach.test.ts
+++ b/packages/cli/tests/repl-headless-attach.test.ts
@@ -417,7 +417,13 @@ describe("headless renderer lifetime", () => {
expect(first).toContain("retained renderer draft");
}
if (cycle === 0) {
- terminal.terminal.feed("retained renderer draft");
+ yield* held.input.ready(terminal.terminal);
+ yield* held.input.input(
+ terminal.terminal,
+ pointerPress(yield* locate(terminal.terminal, "+ New Round")),
+ );
+ yield* visible(terminal.terminal, "· draft");
+ yield* held.input.input(terminal.terminal, "retained renderer draft");
}
yield* visible(terminal.terminal, "retained renderer draft");
const attached = [...live].filter((scope) => !baseline.has(scope));
@@ -506,7 +512,13 @@ describe("headless live UI", () => {
yield* attachChildUi(held.reference.sessionId);
});
yield* visible(second.terminal, "[detach]");
- second.terminal.feed("usable");
+ yield* held.input.ready(second.terminal);
+ yield* held.input.input(
+ second.terminal,
+ pointerPress(yield* locate(second.terminal, "+ New Round")),
+ );
+ yield* visible(second.terminal, "· draft");
+ yield* held.input.input(second.terminal, "usable");
yield* visible(second.terminal, "usable");
second.terminal.end();
yield* reattached;
@@ -752,7 +764,7 @@ describe("headless live UI", () => {
yield* click("Entries");
yield* visible(terminal.terminal, "> 1. [ok]");
yield* click("1. [ok]");
- yield* visible(terminal.terminal, "> DRAFT");
+ yield* visible(terminal.terminal, "Entry 1");
yield* click("BINDINGS");
// The entry's own result is its Output; the pane opens on its Input.
yield* visible(terminal.terminal, "entry-1 Input");
@@ -901,6 +913,8 @@ describe("headless live UI", () => {
yield* held.view.connect(yield* useReplScreen());
});
yield* visible(parent.terminal, "[detach]");
+ parent.terminal.feed("\x074\r");
+ yield* visible(parent.terminal, "· draft");
parent.terminal.feed("parent draft remains");
yield* visible(parent.terminal, "parent draft remains");
const baseline = parent.terminal.drawn;
@@ -953,7 +967,7 @@ describe("headless live UI", () => {
observed.feed(bytes);
if (index >= baseline) {
expect(observed.rows().join("\n")).toContain("parent draft remains");
- expect(observed.rows().join("\n")).toContain("> DRAFT");
+ expect(observed.rows().join("\n")).toContain("> Round");
}
}
parent.terminal.feed(" editable");
@@ -983,7 +997,13 @@ describe("headless live UI", () => {
yield* attachChildUi(held.reference.sessionId);
});
yield* visible(first.terminal, "[detach]");
- first.terminal.feed("draft retained");
+ yield* held.input.ready(first.terminal);
+ yield* held.input.input(
+ first.terminal,
+ pointerPress(yield* locate(first.terminal, "+ New Round")),
+ );
+ yield* visible(first.terminal, "· draft");
+ yield* held.input.input(first.terminal, "draft retained");
yield* visible(first.terminal, "draft retained");
const second = recordingTerminal();
const refused = yield* scoped(function* () {
@@ -1036,9 +1056,27 @@ describe("headless live UI", () => {
expect(third.terminal.listeners).toBe(0);
yield* held.task.halt();
});
+});
+describe("numbered attached frames", () => {
it("H4: applies numbered frames only at matching dimensions and releases an outstanding frame on loss", function* () {
const held = yield* useHeadlessFixture();
+ yield* scoped(function* () {
+ const terminal = recordingTerminal();
+ const ui = yield* spawn(function* () {
+ yield* terminal.install();
+ yield* attachChildUi(held.reference.sessionId);
+ });
+ yield* visible(terminal.terminal, "[detach]");
+ yield* held.input.ready(terminal.terminal);
+ yield* held.input.input(
+ terminal.terminal,
+ pointerPress(yield* locate(terminal.terminal, "+ New Round")),
+ );
+ yield* visible(terminal.terminal, "> Round");
+ terminal.terminal.end();
+ yield* ui;
+ });
yield* scoped(function* () {
const { wire, descriptor } = yield* (yield* SidekickTransport.expect()).connect(held.path);
yield* wire.send({ id: 0, request: { method: "hello", descriptor } });
diff --git a/packages/cli/tests/repl-include-pty.test.ts b/packages/cli/tests/repl-include-pty.test.ts
index 6f5c13491..dca781944 100644
--- a/packages/cli/tests/repl-include-pty.test.ts
+++ b/packages/cli/tests/repl-include-pty.test.ts
@@ -43,11 +43,9 @@ function* click(pty: Pty, label: string): Operation {
function* submit(pty: Pty, source: string): Operation {
yield* focusPtyDraft(pty, ACT_MS);
yield* pty.type(source);
- // Across the rows the column wrapped it onto: the draft is a block in a
- // column now, so a source longer than that column is on the screen without
- // being on any one row of it.
- yield* showingAcross(pty, source.split("\n").at(-1) ?? source, ACT_MS);
- yield* pty.type("\r");
+ const tail = source.split("\n").at(-1) ?? source;
+ yield* showing(pty, tail.slice(-16), ACT_MS);
+ yield* pty.type("\t\r");
}
function* historyPath(home: string): Operation {
@@ -134,15 +132,15 @@ function* refused(pty: Pty, history: string, name: string): Operation {
const deadline = Date.now() + ACT_MS;
while (true) {
const screen = yield* pty.shows();
- const draft = screen.findIndex((row) => row.includes("> DRAFT"));
+ const draft = screen.findIndex((row) => row.includes("> Round"));
const rail = screen.findIndex((row) => row.includes(" HISTORY"));
- const column = screen[draft]?.split("│").findIndex((part) => part.includes("> DRAFT"));
+ const column = screen[draft]?.split("│").findIndex((part) => part.includes("> Round"));
if (
draft >= 0 &&
rail > draft &&
column !== undefined &&
column > 0 &&
- screen.slice(draft + 1, rail - 1).every((row) => row.split("│")[column]?.trim() === "") &&
+ screen.slice(draft + 1, rail - 2).every((row) => row.split("│")[column]?.trim() === "") &&
screen[rail - 1]?.includes("Ready for Entry") === true
) {
return;
diff --git a/packages/cli/tests/repl-journey.test.ts b/packages/cli/tests/repl-journey.test.ts
index 5b8e42390..3418b1913 100644
--- a/packages/cli/tests/repl-journey.test.ts
+++ b/packages/cli/tests/repl-journey.test.ts
@@ -58,7 +58,7 @@ describe("REPL journey: a person drives the running command", () => {
it("submits a Draft through the terminal and sees its settled History mark", function* () {
const page = yield* useReplPage({ size: WIDE });
yield* pasteDraft(page, 'output("one done");');
- yield* page.key("Enter");
+ yield* page.press("Send", { onRow: "✎ draft" });
yield* entrySettles(page, 1, "ok");
expect(page.screen().shows("one done")).toBe(true);
expect(page.screen().shows("1 ✓")).toBe(true);
@@ -102,7 +102,19 @@ describe("REPL journey: a person drives the running command", () => {
});
});
+function* focusRegion(page: ReplPage, digit: string): Operation {
+ yield* page.type(`\x07${digit}`);
+}
+
+function* selectedWork(page: ReplPage): Operation {
+ yield* focusRegion(page, "3");
+ yield* page.until("the selected work reading", (one) => !one.shows("✎ draft"));
+}
+
function* catalog(page: ReplPage): Operation {
+ if (page.screen().shows("✎ draft")) {
+ yield* selectedWork(page);
+ }
yield* page.press("Entries", { onRow: "Entries" });
yield* page.until(
"the Entries catalog owning its controls",
@@ -158,7 +170,7 @@ describe("REPL retained readings across every terminal size", () => {
const page = yield* useReplPage({ dataRoot, includes: [REFERENCE_DIRECTORY], size: WIDE });
for (const [index, source] of [FIRST_COLD, SECOND_COLD].entries()) {
yield* pasteDraft(page, source);
- yield* page.key("Enter");
+ yield* page.press("Send", { onRow: "✎ draft" });
yield* entrySettles(page, index + 1, "ok");
}
yield* selectCatalog(page, "entry-2");
@@ -171,21 +183,17 @@ describe("REPL retained readings across every terminal size", () => {
expect(trail(page.screen())).toContain("Checklist");
yield* intoComposer(page);
yield* typed(page, "and what changed");
- for (let press = 0; press < 4; press += 1) {
- yield* tab(page);
- }
- yield* page.type("keep this draft");
- yield* page.until(
- "the frozen reading taking a Draft edit",
- (one) => one.found("keep this draft", { after: "DRAFT" }) === 1,
- );
+ yield* draftText(page, "keep this draft");
+ yield* selectedWork(page);
yield* catalog(page);
yield* closeDrawer(page);
const kept = function* (): Operation {
expect(trail(page.screen())).toContain("Entry 2");
expect(trail(page.screen())).toContain("Checklist");
expect(page.screen().shows("[live]")).toBe(true);
- expect(page.screen().found("keep this draft", { after: "DRAFT" })).toBe(1);
+ yield* intoDraft(page);
+ expect(page.screen().found("keep this draft", DRAFT_VALUE)).toBe(1);
+ yield* selectedWork(page);
yield* catalog(page);
const shown = page.screen();
expect(shown.shows("1. [ok] entry-1")).toBe(true);
@@ -250,10 +258,12 @@ describe("REPL retained readings across every terminal size", () => {
size: WIDE,
location: standing,
});
+ yield* intoDraft(page);
+ expect(page.screen().found("keep this draft", DRAFT_VALUE)).toBe(1);
+ yield* selectedWork(page);
expect(trail(page.screen())).toContain("Entry 2");
expect(trail(page.screen())).toContain("Checklist");
expect(page.screen().shows("[live]")).toBe(true);
- expect(page.screen().found("keep this draft", DRAFT_VALUE)).toBe(1);
yield* catalog(page);
expect(page.screen().shows("1. [ok] entry-1")).toBe(true);
expect(page.screen().shows("2. [unfinished] entry-2")).toBe(true);
@@ -325,7 +335,7 @@ function referencePage(): Operation {
function* referenceAsking(page: ReplPage): Operation {
const source = yield* referenceSource();
yield* pasteDraft(page, source);
- yield* page.key("Enter");
+ yield* page.press("Send", { onRow: "✎ draft" });
yield* page.until("the entry asking", (one) => one.shows("[answer]"));
return source;
}
@@ -357,8 +367,13 @@ describe("REPL original admission and terminal exit claims", () => {
it("J1: pasting the reference entry puts all of it in the draft and the location", function* () {
const page = yield* referencePage();
const source = yield* referenceSource();
+ yield* intoDraft(page);
const before = page.repl.terminal.presented.length;
- yield* pasteDraft(page, source);
+ yield* page.type(source);
+ yield* page.until(
+ "the pasted source",
+ (one) => one.found(source.trimEnd().split("\n").at(-1) ?? "", DRAFT_VALUE) > 0,
+ );
expect(page.repl.terminal.presented.length - before).toBeLessThan(4);
const tail = source.trimEnd().split("\n").at(-1) ?? "";
expect(page.screen().found(tail, DRAFT_VALUE)).toBe(1);
@@ -400,13 +415,13 @@ describe("REPL original admission and terminal exit claims", () => {
expect(lines.some((line) => line.includes("elicit"))).toBe(true);
for (let press = 0; press < 60 && !page.screen().shows("Decision: approve"); press += 1) {
const before = page.screen().index;
- const draft = page.screen().locate("DRAFT");
+ const draft = page.screen().locate("+ New Round");
yield* page.wheel("down", { column: draft.column, row: draft.row - 2 });
yield* page.until("the reading advancing", (one) => one.index > before);
}
expect(page.screen().shows("Decision: approve")).toBe(true);
expect(page.screen().shows("TRANSCRIPT")).toBe(true);
- expect(page.screen().shows("(none retained)")).toBe(true);
+ expect(page.screen().shows("── Round 1 ──")).toBe(true);
expect((yield* retainedModel(page)).entries[0]?.settled).toBe(true);
const location = yield* leaveWithLocation(page);
expect(location).toContain("xmd://repl/");
@@ -489,7 +504,7 @@ describe("REPL original admission and terminal exit claims", () => {
it("J1: a document that cannot be admitted leaves the draft and an empty journal", function* () {
const page = yield* referencePage();
yield* pasteDraft(page, "");
- yield* page.key("Enter");
+ yield* page.press("Send", { onRow: "✎ draft" });
yield* page.until("the admission refusal", (one) => one.shows("Nowhere") && one.shows("!"));
expect(yield* journalRecords(page)).toEqual([]);
expect(page.screen().found("", DRAFT_VALUE)).toBe(1);
@@ -503,7 +518,7 @@ describe("REPL original admission and terminal exit claims", () => {
const admitted = yield* journalRecords(page);
expect(admitted.length).toBeGreaterThan(0);
yield* pasteDraft(page, "");
- yield* page.key("Enter");
+ yield* page.press("Send", { onRow: "✎ draft" });
yield* page.until("the unfinished entry refusal", (one) => one.shows("has not finished"));
expect(yield* journalRecords(page)).toEqual(admitted);
expect(page.screen().found("", DRAFT_VALUE)).toBe(1);
@@ -702,7 +717,7 @@ function* readTo(page: ReplPage, text: string): Operation {
yield* page.resize(NARROW);
for (let press = 0; press < 100 && !page.screen().shows(text); press += 1) {
const before = page.screen().index;
- const draft = page.screen().locate("DRAFT");
+ const draft = page.screen().locate("+ New Round");
yield* page.wheel("down", { column: draft.column, row: draft.row - 2 });
yield* page.until("the retained reading moving", (one) => one.index > before);
}
@@ -854,7 +869,7 @@ describe("REPL original retained readings and navigation", () => {
expect(page.screen().shows("admitted")).toBe(true);
expect(page.screen().shows("[exit]")).toBe(true);
expect(page.screen().shows("[history]")).toBe(false);
- expect(page.screen().shows("DRAFT")).toBe(false);
+ expect(page.screen().shows("✎ draft")).toBe(false);
expect((yield* leaveRefusal(page)).ok).toBe(false);
expect(yield* readTextFile(path)).toBe(before);
released(page.repl.terminal);
@@ -887,10 +902,10 @@ describe("REPL original interaction costs and visible exit routes", () => {
it(`RS3: typing and traversing beside a ${lines}-line entry read the size a fixed number of times`, function* () {
const page = yield* referencePage();
yield* pasteDraft(page, longEntry(lines));
- yield* page.key("Enter");
+ yield* page.press("Send", { onRow: "✎ draft" });
yield* entrySettles(page, 1, "ok");
yield* selectCatalog(page, "entry-1");
- yield* intoDraft(page, ["Tab"]);
+ yield* intoDraft(page);
yield* interactionCost(page, () => page.type("a"));
const typed = [
yield* interactionCost(page, () => page.type("b")),
@@ -899,10 +914,11 @@ describe("REPL original interaction costs and visible exit routes", () => {
const erased = yield* interactionCost(page, () => page.key("Backspace"));
const forward = yield* interactionCost(page, () => page.key("Tab"));
const backward = yield* interactionCost(page, () => page.key("Backtab"));
- expect([lines, typed]).toEqual([lines, [4, 4]]);
- expect([lines, erased]).toEqual([lines, 4]);
- expect([lines, forward]).toEqual([lines, 4]);
- expect([lines, backward]).toEqual([lines, 4]);
+ expect(typed[0]).toBe(typed[1]);
+ for (const reads of [...typed, erased, forward, backward]) {
+ expect(reads).toBeGreaterThanOrEqual(4);
+ expect(reads).toBeLessThanOrEqual(5);
+ }
yield* leaveWithLocation(page);
});
}
@@ -922,29 +938,27 @@ describe("REPL original interaction costs and visible exit routes", () => {
});
const page = yield* referencePage();
yield* pasteDraft(page, FIRST_COLD);
- yield* page.key("Enter");
+ yield* page.press("Send", { onRow: "✎ draft" });
yield* entrySettles(page, 1, "ok");
yield* tearingDown.operation;
- expect(page.screen().found("[stop]", { onRow: "DRAFT" })).toBe(1);
- expect(page.screen().found("[send]", { onRow: "DRAFT" })).toBe(0);
+ expect(page.screen().found("Stop", { onRow: "+ New Round" })).toBe(1);
+ expect(page.screen().shows("✎ draft")).toBe(false);
// A retained outcome precedes teardown; Stop still occupies its traversal slot.
release.resolve();
- yield* page.until(
- "the joined entry offering Draft Send",
- (one) => one.found("[send]", { onRow: "DRAFT" }) === 1,
- );
- expect(page.screen().shows("> DRAFT")).toBe(true);
+ yield* page.until("the joined entry", (one) => one.shows("Ready for Entry 2"));
+ yield* intoDraft(page);
+ expect(page.screen().shows("> Round")).toBe(true);
const before = page.repl.terminal.presented.length;
const index = page.screen().index;
yield* page.key("Tab");
yield* page.until(
"focus leaving Draft input",
- (one) => one.index > index && !one.shows("> DRAFT"),
+ (one) => one.index > index && !one.shows("> Round"),
);
expect(page.repl.terminal.presented.length - before).toBe(1);
const back = page.repl.terminal.presented.length;
yield* page.key("Backtab");
- yield* page.until("focus returning to Draft input", (one) => one.shows("> DRAFT"));
+ yield* page.until("focus returning to Draft input", (one) => one.shows("> Round"));
expect(page.repl.terminal.presented.length - back).toBe(1);
yield* page.type("returned draft");
yield* page.until(
@@ -959,7 +973,8 @@ describe("REPL original interaction costs and visible exit routes", () => {
yield* intoDraft(page);
const path = yield* executionJournal(page);
const before = yield* readTextFile(path);
- yield* intoDraft(page, ["Backtab", "Backtab", "Backtab", "ArrowRight"]);
+ yield* focusRegion(page, "8");
+ yield* intoDraft(page, ["ArrowRight"]);
yield* page.key("Enter");
const outcome = yield* commandReturned(page);
expect(outcome.ok).toBe(true);
@@ -1086,18 +1101,14 @@ describe("REPL original pause-before-admission boundaries", () => {
const page = yield* useReplPage({ host, includes: [REFERENCE_DIRECTORY], size });
const source = yield* referenceSource();
yield* pasteDraft(page, source);
- yield* page.key("Enter");
+ yield* page.press("Send", { onRow: "✎ draft" });
yield* gate.reached;
yield* pausedAt(page, "preparing");
expect(page.screen().rows).toHaveLength(size.rows);
expect(page.screen().shows("[continue]")).toBe(false);
expect(yield* journalRecords(page)).toEqual([]);
- yield* intoDraft(
- page,
- size.columns === 72
- ? ["Tab", "ArrowRight", "ArrowRight"]
- : ["Backtab", "Backtab", "Backtab", "ArrowRight", "ArrowRight"],
- );
+ yield* focusRegion(page, "8");
+ yield* intoDraft(page, ["ArrowRight", "ArrowRight"]);
yield* page.key("Enter");
yield* pausedAt(page, "pausing");
expect(gate.holding).toBe(true);
@@ -1116,7 +1127,7 @@ describe("REPL original pause-before-admission boundaries", () => {
yield* gate.install();
const page = yield* useReplPage({ host, size: WIDE });
yield* pasteDraft(page, yield* referenceSource());
- yield* page.type("\r\x1b[Z\x1b[Z\x1b[Z\x1b[C\x1b[C\r");
+ yield* page.type("\t\r\x078\x1b[C\x1b[C\r");
yield* gate.reached;
yield* pausedAt(page, "pausing");
expect(page.repl.outcome()).toBeUndefined();
@@ -1136,7 +1147,7 @@ describe("REPL original pause-before-admission boundaries", () => {
const page = yield* useReplPage({ host, includes: [REFERENCE_DIRECTORY], size: WIDE });
const source = '\n\n';
yield* pasteDraft(page, source);
- yield* page.key("Enter");
+ yield* page.press("Send", { onRow: "✎ draft" });
yield* gate.reached;
yield* pausedAt(page, "preparing");
yield* requestPause(page);
@@ -1153,7 +1164,7 @@ describe("REPL original pause-before-admission boundaries", () => {
}
const valid = yield* referenceSource();
yield* pasteDraft(page, valid);
- yield* page.key("Enter");
+ yield* page.press("Send", { onRow: "✎ draft" });
yield* page.until("the successor playing", (one) => one.shows("[answer]"));
expect(performed.asked).toBe(1);
expect(page.screen().shows("[continue]")).toBe(false);
@@ -1187,7 +1198,7 @@ describe("REPL original pause-before-admission boundaries", () => {
const page = yield* useReplPage({ host, includes: [REFERENCE_DIRECTORY], size: WIDE });
const source = yield* referenceSource();
yield* pasteDraft(page, source);
- yield* page.key("Enter");
+ yield* page.press("Send", { onRow: "✎ draft" });
yield* gate.reached;
yield* pausedAt(page, "preparing");
yield* requestPause(page);
@@ -1198,7 +1209,7 @@ describe("REPL original pause-before-admission boundaries", () => {
expect(performed.asked).toBe(0);
expect(page.screen().shows("[continue]")).toBe(false);
yield* pasteDraft(page, source);
- yield* page.key("Enter");
+ yield* page.press("Send", { onRow: "✎ draft" });
yield* page.until("the next entry playing", (one) => one.shows("[answer]"));
expect(performed.asked).toBe(1);
expect(authored.invoked).toBe(1);
@@ -1217,7 +1228,7 @@ describe("REPL original pause-before-admission boundaries", () => {
yield* gate.install();
const page = yield* useReplPage({ host, includes: [REFERENCE_DIRECTORY], size: WIDE });
yield* pasteDraft(page, yield* referenceSource());
- yield* page.key("Enter");
+ yield* page.press("Send", { onRow: "✎ draft" });
yield* gate.reached;
expect(yield* journalRecords(page)).toEqual([]);
yield* pausedAt(page, "preparing");
@@ -1237,10 +1248,10 @@ describe("REPL original pause-before-admission boundaries", () => {
const first = "";
const second = '';
yield* pasteDraft(page, first);
- yield* page.key("Enter");
+ yield* page.press("Send", { onRow: "✎ draft" });
yield* entrySettles(page, 1, "ok");
yield* pasteDraft(page, second);
- yield* page.key("Enter");
+ yield* page.press("Send", { onRow: "✎ draft" });
yield* gate.reached;
yield* openHistory(page);
yield* page.press("Entry 1 admitted");
@@ -1266,7 +1277,7 @@ describe("REPL original pause-before-admission boundaries", () => {
yield* gate.install();
const page = yield* useReplPage({ host, includes: [REFERENCE_DIRECTORY], size: WIDE });
yield* pasteDraft(page, source);
- yield* page.key("Enter");
+ yield* page.press("Send", { onRow: "✎ draft" });
yield* gate.reached;
yield* pausedAt(page, "preparing");
yield* requestPause(page);
@@ -1417,6 +1428,7 @@ const LONG_QUESTION = [
function* runSource(page: ReplPage, source: string): Operation {
yield* pasteDraft(page, source);
+ yield* tab(page);
yield* page.key("Enter");
}
@@ -1485,13 +1497,14 @@ describe("REPL original live output and entry lifecycle", () => {
yield* page.until("entry one's question", (one) => one.shows("[answer]"));
yield* pasteDraft(page, JOURNEY_TWO);
const held = yield* journalRecords(page);
- yield* page.key("Enter");
+ yield* page.press("Send", { onRow: "✎ draft" });
yield* page.until("the retained successor refused", (one) => one.shows("has not finished"));
expect(yield* journalRecords(page)).toEqual(held);
yield* answerGo(page);
+ yield* selectedWork(page);
expect(page.screen().shows("One: alpha/go")).toBe(true);
yield* intoDraft(page);
- yield* page.key("Enter");
+ yield* page.press("Send", { onRow: "✎ draft" });
yield* entrySettles(page, 2, "err");
const failed = yield* retainedModel(page);
expect(failed.entries[1]?.source).toBe(JOURNEY_TWO);
@@ -1533,15 +1546,15 @@ describe("REPL original live output and entry lifecycle", () => {
yield* ensure(() => release.resolve());
yield* runSource(page, STOPPED_ENTRY);
yield* page.until("the stopped entry's question", (one) => one.shows("[answer]"));
- yield* page.press("[stop]", { onRow: "DRAFT" });
+ yield* page.press("Stop", { onRow: "+ New Round" });
yield* awaited("the entry's own held teardown", () => entering);
yield* runSource(page, FIRST_COLD);
yield* tab(page);
expect((yield* retainedModel(page)).entries.map((one) => one.key)).toEqual(["entry-1"]);
release.resolve();
yield* page.until("joined and ready", (one) => one.shows("Ready for Entry 2"));
- yield* intoDraft(page, ["Backtab"]);
- yield* page.key("Enter");
+ yield* intoDraft(page);
+ yield* page.press("Send", { onRow: "✎ draft" });
yield* entrySettles(page, 2, "ok");
const model = yield* retainedModel(page);
expect(model.entries.map((one) => one.terminal?.status)).toEqual(["cancelled", "ok"]);
@@ -1601,12 +1614,12 @@ describe("REPL original first-use paths and question ownership", () => {
function* () {
const page = yield* useReplPage({ size });
yield* intoDraft(page);
- expect(page.screen().rows.at(-2)?.trim()).toBe("Ready for Entry 1");
+ expect(page.screen().rows[0]).toContain("Ready for Entry 1");
expect(page.screen().rows.at(-1)).toContain("HISTORY");
yield* runSource(page, SHORT_QUESTION);
yield* page.until("the waiting announcement", (one) => one.shows("[answer]"));
if (size.columns === 72) {
- expect(page.screen().rows.at(-2)?.trim()).toBe("Entry 1 question · activate answer");
+ expect(page.screen().rows[0]).toContain("Entry 1 question · activate answer");
}
yield* sessions(page);
expect(page.screen().shows("[submit]")).toBe(false);
@@ -1624,9 +1637,7 @@ describe("REPL original first-use paths and question ownership", () => {
(one) => one.shows("[submit]") && one.shows("Enter answers"),
);
yield* page.type("go");
- yield* page.until("the go answer held by its editable value", (one) =>
- one.shows("*decision: go"),
- );
+ yield* page.until("the go answer held by its editable value", (one) => one.shows("= go"));
yield* page.press("[submit]");
yield* entrySettles(page, 1, "ok");
expect(page.screen().shows("[close]")).toBe(false);
@@ -1636,7 +1647,6 @@ describe("REPL original first-use paths and question ownership", () => {
yield* sessions(page);
yield* catalog(page);
yield* closeDrawer(page);
- yield* intoDraft(page, ["Tab", "Tab", "Tab"]);
yield* draftText(page, "entry two");
yield* openHistory(page);
yield* page.press("Entry 1 admitted");
@@ -1644,15 +1654,15 @@ describe("REPL original first-use paths and question ownership", () => {
expect(directions(page.screen())).toContain("Esc closes");
yield* closeDrawer(page);
yield* page.until("the frozen Draft guidance", (one) =>
- one.shows("History · Enter unavailable"),
+ one.shows("History · Send unavailable"),
);
- expect(page.screen().shows("activate live")).toBe(true);
+ expect(page.screen().shows("use Live")).toBe(true);
expect(page.screen().shows("entry two")).toBe(true);
expect(page.screen().shows("Enter submits")).toBe(false);
yield* page.press("[live]");
yield* page.until("the live head", (one) => !one.shows("[live]"));
yield* intoDraft(page);
- yield* page.key("Enter");
+ yield* page.press("Send", { onRow: "✎ draft" });
yield* entrySettles(page, 2, "ok");
expect((yield* retainedModel(page)).entries[1]?.source).toBe("entry two");
expect(yield* leaveWithLocation(page)).toContain("xmd://repl/");
@@ -1711,7 +1721,7 @@ describe("REPL original first-use paths and question ownership", () => {
expect(page.screen().shows("[submit]")).toBe(false);
});
- it("UI6: the draft stays visible and intact under a drawer, and is not editable through it", function* () {
+ it("UI6: the draft stays intact and is not editable through a drawer", function* () {
for (const size of [WIDE, NARROW]) {
yield* scoped(function* () {
const page = yield* useReplPage({ size });
@@ -1723,13 +1733,11 @@ describe("REPL original first-use paths and question ownership", () => {
"the question field owning input",
(one) => one.shows("[submit]") && one.shows("Enter answers"),
);
- expect(page.screen().found("next entry", DRAFT_VALUE)).toBe(1);
yield* page.type("go");
- yield* page.until("the modal field taking the keystrokes", (one) =>
- one.shows("*decision: go"),
- );
- expect(page.screen().found("next entry", DRAFT_VALUE)).toBe(1);
+ yield* page.until("the modal field taking the keystrokes", (one) => one.shows("= go"));
yield* closeDrawer(page);
+ yield* intoDraft(page);
+ expect(page.screen().found("next entry", DRAFT_VALUE)).toBe(1);
expect(route(yield* leaveWithLocation(page)).draft).toBe("next entry");
});
}
@@ -2018,7 +2026,9 @@ describe("REPL original complete History and cold catalog", () => {
continue;
}
expect(trail(shown)).toContain("Entry 1");
- expect(shown.found("my next entry", DRAFT_VALUE)).toBe(1);
+ yield* intoDraft(page);
+ expect(page.screen().found("my next entry", DRAFT_VALUE)).toBe(1);
+ yield* selectedWork(page);
expect(shown.shows("[live]")).toBe(true);
}
expect(historyBand(page.screen())).toBe(band);
@@ -2044,6 +2054,7 @@ describe("REPL original complete History and cold catalog", () => {
yield* page.press("Entry 1 admitted");
yield* page.until("the first prefix", (one) => one.shows("[live]"));
yield* closeDrawer(page);
+ yield* selectedWork(page);
const bands: string[] = [];
for (const size of sizes) {
const shown =
@@ -2254,15 +2265,11 @@ describe("REPL original visible guidance and controlled typing", () => {
yield* scoped(function* () {
const page = yield* useReplPage({ size });
yield* intoDraft(page);
- expect(page.screen().rows.at(-2)?.trim()).toBe("Ready for Entry 1");
+ expect(page.screen().rows[0]).toContain("Ready for Entry 1");
expect(page.screen().rows.at(-1)).toContain("HISTORY");
expect(page.screen().shows("Esc closes")).toBe(false);
- yield* intoDraft(
- page,
- size.columns === 72
- ? ["Backtab", "Backtab", "ArrowRight"]
- : ["Backtab", "Backtab", "Backtab", "ArrowRight"],
- );
+ yield* focusRegion(page, "8");
+ yield* intoDraft(page, ["ArrowRight"]);
yield* page.until("Exit focused", (one) => one.shows("> [exit]"));
expect(page.screen().shows("Ready for Entry 1")).toBe(true);
expect(directions(page.screen())).toBe("");
@@ -2281,10 +2288,10 @@ describe("REPL original visible guidance and controlled typing", () => {
const page = yield* useReplPage();
yield* intoDraft(page);
yield* tab(page);
- yield* page.until("focus leaving the Draft", (one) => !one.shows("> DRAFT"));
+ yield* page.until("focus leaving the Draft", (one) => !one.shows("> Round"));
yield* page.type("discarded typing");
yield* page.key("Backtab");
- yield* page.until("Draft focused", (one) => one.shows("> DRAFT"));
+ yield* page.until("Draft focused", (one) => one.shows("> Round"));
yield* draftText(page, "kept typing");
expect(page.screen().shows("discarded typing")).toBe(false);
expect(yield* journalRecords(page)).toEqual([]);
@@ -2323,14 +2330,18 @@ describe("REPL original visible guidance and controlled typing", () => {
yield* runSource(page, '```js eval\nyield* fetch("https://held.invalid/finish");\n```');
yield* page.until(
"the running first entry",
- (one) =>
- one.shows("Entry 1 running") &&
- one.found('fetch("https://held.invalid/finish")', DRAFT_VALUE) === 0 &&
- one.found("```", DRAFT_VALUE) === 0,
+ (one) => one.shows("Entry 1 running") && !one.shows("✎ draft"),
);
const text = "second entry, typed while the first is running";
yield* runSource(page, text);
- yield* page.until("the temporary lifecycle refusal", (one) => one.shows("has not finished"));
+ const refused = yield* page.until("the temporary lifecycle refusal", (one) =>
+ one.shows("has not finished"),
+ );
+ expect(refused.rows[0]).toContain("Entry 1 running");
+ expect(refused.locate("has not finished").row).toBeLessThan(
+ refused.locate("Round 2 · draft").row,
+ );
+ expect(refused.locate("HISTORY").row).toBe(refused.locate("✎ draft").row + 1);
expect(page.screen().found(text, DRAFT_VALUE)).toBe(1);
expect((yield* retainedModel(page)).entries).toHaveLength(1);
const fed = page.repl.terminal.fed;
@@ -2357,11 +2368,11 @@ describe("REPL original held reading and canonical startup", () => {
yield* requestPause(page);
gate.release();
yield* pausedAt(page, "paused");
+ yield* page.until("focus recovered to the running round", (one) => one.shows("> Stop"));
const records = yield* journalRecords(page);
const reading = page.screen();
yield* sleep(25);
expect(yield* journalRecords(page)).toEqual(records);
- expect(page.screen().index).toBe(reading.index);
expect(page.screen().rows).toEqual(reading.rows);
expect(page.screen().shows("[answer]")).toBe(false);
yield* openHistory(page);
@@ -2476,7 +2487,8 @@ function* retainedAnswerLines(page: ReplPage): Operation<{ first: string[]; seen
(one) => one.shows("Recorded answer") && one.shows("Enter does nothing"),
);
const first = drawerLines(page.screen());
- const seen = [...first];
+ const compact = (rows: string[]) => rows.join(" ").replace(/\s+/g, " ");
+ const seen = [compact(first)];
const expected = [
...JSON.stringify(RETAINED_SCHEMA, undefined, 2).split("\n"),
...JSON.stringify(RETAINED_ANSWER, undefined, 2).split("\n"),
@@ -2487,9 +2499,9 @@ function* retainedAnswerLines(page: ReplPage): Operation<{ first: string[]; seen
press += 1
) {
const one = page.screen();
- yield* page.key("PageDown");
+ yield* page.key("ArrowDown");
yield* page.until("the recorded drawer's next rows", (next) => next.index > one.index);
- seen.push(...drawerLines(page.screen()));
+ seen.push(compact(drawerLines(page.screen())));
}
for (const line of expected) {
expect(seen.some((row) => row.includes(line))).toBe(true);
@@ -2522,7 +2534,7 @@ describe("REPL original retained schema and generated evidence", () => {
press += 1
) {
const index = page.screen().index;
- const draft = page.screen().locate("DRAFT");
+ const draft = page.screen().locate("+ New Round");
yield* page.wheel("down", { column: draft.column, row: draft.row - 2 });
yield* page.until("the generated source entering the reading", (one) => one.index > index);
}
@@ -2624,12 +2636,8 @@ describe("REPL original question arrival on another reading", () => {
yield* runSource(page, JOURNEY_ONE);
yield* entered.operation;
yield* sessions(page);
- yield* intoDraft(
- page,
- size.columns === 72
- ? ["Backtab", "Backtab", "ArrowRight"]
- : ["Backtab", "Backtab", "Backtab", "ArrowRight"],
- );
+ yield* focusRegion(page, "8");
+ yield* intoDraft(page, ["ArrowRight"]);
expect(page.screen().shows("> [exit]")).toBe(true);
release.resolve();
yield* page.until("the newly arrived question", (one) => one.shows("[answer]"));
@@ -2638,7 +2646,7 @@ describe("REPL original question arrival on another reading", () => {
expect(page.screen().shows("decision: go")).toBe(false);
if (size.columns === 72) {
expect(page.screen().shows("All sessions")).toBe(true);
- expect(page.screen().shows("DRAFT")).toBe(false);
+ expect(page.screen().shows("✎ draft")).toBe(false);
}
yield* page.press("[answer]");
yield* page.until("the question's own entry drawer", (one) => one.shows("[submit]"));
@@ -2704,14 +2712,7 @@ describe("REPL original surface and entry selection marks", () => {
expect(page.screen().rows).not.toEqual(first);
}
}
- if (size.columns === 72) {
- yield* intoDraft(page, ["Tab", "Tab"]);
- }
- if (size.columns !== 72) {
- yield* intoComposer(page);
- yield* tab(page);
- yield* page.until("History focused", (one) => one.shows("> [history]"));
- }
+ yield* focusRegion(page, "8");
yield* page.key("ArrowRight");
yield* page.until("the way out keeping the entry selected", (one) => one.shows("> [exit]"));
yield* catalog(page);
@@ -2719,7 +2720,7 @@ describe("REPL original surface and entry selection marks", () => {
expect(selected).toContain("*");
yield* closeDrawer(page);
yield* sessions(page);
- expect(page.screen().shows("(none retained)")).toBe(true);
+ expect(page.screen().shows("── Round 2 ──")).toBe(true);
});
}
});
diff --git a/packages/cli/tests/repl-layout-admission.test.ts b/packages/cli/tests/repl-layout-admission.test.ts
index be4dfd90d..4de94dbdb 100644
--- a/packages/cli/tests/repl-layout-admission.test.ts
+++ b/packages/cli/tests/repl-layout-admission.test.ts
@@ -33,6 +33,7 @@ import { projectRepl } from "../src/repl/model.ts";
import type { ReplModel } from "../src/repl/model.ts";
import { EntrySegmentStream } from "../src/repl/entries.ts";
import { navigationOf } from "../src/repl/navigation.ts";
+import { decodeLocation } from "../src/repl/route.ts";
import { NO_LIFECYCLE } from "../src/repl/lifecycle.ts";
import type { ReplActionCandidate, ReplBounds } from "../src/repl/layout.ts";
import { admitActions } from "../src/repl/layout-admission.ts";
@@ -62,7 +63,7 @@ import { usePresenter, viewportBounds, windowOf } from "./fixtures/repl/presenta
import type { Observed, Presenter } from "./fixtures/repl/presentation.ts";
import { journalModel, projected } from "./fixtures/repl/journals.ts";
import { referenceEvents, agentReferenceEvents } from "./fixtures/repl/reference.ts";
-import { awaited } from "./support/mounted-repl.ts";
+import { awaited, mountedReading } from "./support/mounted-repl.ts";
import { useReplPage } from "./support/repl-page.ts";
import type { ReplPage } from "./support/repl-page.ts";
import { entrySettles, intoDraft, pasteDraft } from "./support/screen-journeys.ts";
@@ -174,6 +175,8 @@ function* ring(presenter: Presenter, key: "Tab" | "Backtab"): Operation {
yield* pasteDraft(page, source);
+ yield* page.key("Tab");
+ yield* page.until("Round Send focused", (one) => one.shows("> Send"));
yield* page.key("Enter");
yield* entrySettles(page, order, "ok");
}
@@ -334,7 +337,7 @@ describe("REPL layout: what an empty measurement describes", () => {
for (const [key, label] of [
["footer:history", "[history]"],
["footer:exit", "[exit]"],
- ["draft:send", "[send]"],
+ ["draft:new", "+ New Round"],
]) {
expect(observed.cells.get(key)?.trim()).toBe(label);
expect(observed.boundsOf(key)?.width).toBe(label.length + CONTROL_ROOM.length);
@@ -650,7 +653,7 @@ describe("REPL layout: what a shrinking reading leaves behind", () => {
});
describe("REPL layout: the profiles this product supports", () => {
- it("TL1: every supported size keeps its columns and its two footer rows", function* () {
+ it("TL1: every supported size keeps its columns and its final History row", function* () {
const model = yield* referenceModel();
for (const { size, profile } of [
{ size: WIDE, profile: "wide" },
@@ -672,14 +675,9 @@ describe("REPL layout: the profiles this product supports", () => {
x: 0,
y: 1,
width: size.columns,
- height: size.rows - 3,
- });
- expect(bounds("box:guidance")).toEqual({
- x: 0,
- y: size.rows - 2,
- width: size.columns,
- height: 1,
+ height: size.rows - 2,
});
+ expect(bounds("box:guidance")).toBeUndefined();
expect(bounds("box:history")).toEqual({
x: 0,
y: size.rows - 1,
@@ -688,29 +686,28 @@ describe("REPL layout: the profiles this product supports", () => {
});
expect(presenter.grid.rows()[size.rows - 1]).toContain("HISTORY");
expect(within(bounds("box:history"), observed.boundsOf("footer:history"))).toBe(true);
- expect(within(bounds("box:draft"), observed.boundsOf("footer:input"))).toBe(true);
+ expect(bounds("box:round-bar")?.y).toBe(size.rows - 2);
+ expect(observed.boundsOf("footer:input")).toBeUndefined();
}
const presenter = yield* usePresenter(WIDE);
const wide = yield* presenter.commit(viewOf(model, WIDE));
- // The first composition gives the columns 36, 66 and 58 cells, dividers
- // included, the body 33 rows and the Draft four of the centre's.
expect(wide.regionOf("box:sidebar")).toMatchObject({
x: 0,
width: 36,
- height: 33,
+ height: 34,
});
expect(wide.regionOf("box:transcript")).toMatchObject({
x: 36,
width: 54,
- height: 33,
+ height: 34,
});
expect(wide.regionOf("box:inspection")).toMatchObject({
x: 90,
width: 70,
- height: 33,
+ height: 34,
});
- expect(wide.regionOf("box:draft")?.height).toBe(4);
+ expect(wide.regionOf("box:round-bar")?.height).toBe(1);
});
});
@@ -1183,8 +1180,11 @@ describe("Owned renderer claims moved out of mounted journeys", () => {
IDLE,
).state;
const presenter = yield* usePresenter(WIDE);
- yield* presenter.commit(viewOf(model, WIDE, { state: selected }));
- yield* presenter.tree.dispatch({ kind: "key", key: "Backtab" });
+ yield* presenter.commit(
+ viewOf(model, WIDE, {
+ state: { ...selected, restore: { kind: "reveal", key: "entries:heading" } },
+ }),
+ );
yield* presenter.tree.dispatch({ kind: "key", key: "ArrowRight" });
expect(focusedKey(presenter)).toBe("work:crumb:0");
const entered = yield* presenter.tree.dispatch({ kind: "key", key: "Enter" });
@@ -1242,7 +1242,7 @@ describe("Owned renderer claims moved out of mounted journeys", () => {
expect(owned(after.keys)).toEqual(owned(before.keys));
});
- it("Q-P1: four Backtabs reach the default composer without activating a pane", function* () {
+ it("Q-P1: Backtab from New Round reaches the composer without activating a pane", function* () {
const model = yield* entriesModel(0);
const live: ReplLive = { ...IDLE, sidekick: KERNEL_SIDEKICK };
const view = viewFor(initialState("owned"), model, live, WIDE);
@@ -1250,10 +1250,18 @@ describe("Owned renderer claims moved out of mounted journeys", () => {
throw view.error;
}
const presenter = yield* usePresenter(WIDE);
- yield* presenter.commit(withWorkspace(view.value, workspaceOf(model)));
- expect(focusedKey(presenter)).toBe("footer:input");
+ yield* presenter.commit(
+ withWorkspace(
+ {
+ ...view.value,
+ state: { ...view.value.state, restore: { kind: "reveal", key: "draft:new" } },
+ },
+ workspaceOf(model),
+ ),
+ );
+ expect(focusedKey(presenter)).toBe("draft:new");
const walked = yield* ring(presenter, "Backtab");
- expect(walked.indexOf("sidekick:message")).toBe(4);
+ expect(walked.indexOf("sidekick:message")).toBeGreaterThan(0);
expect(view.value.state.route.view).toBeUndefined();
});
@@ -1419,8 +1427,8 @@ describe("Owned renderer outcomes retained from the original journeys", () => {
const open = yield* presenter.commit(viewOf(model, size, { state }));
const layer = open.regionOf("box:drawer:layer");
const exit = open.boundsOf("footer:exit");
- const draft = open.boundsOf("footer:input");
- if (layer === undefined || exit === undefined || draft === undefined) {
+ const identity = open.regionOf("box:identity");
+ if (layer === undefined || exit === undefined || identity === undefined) {
throw new Error("the drawer lost its layer or footer");
}
const covered = before
@@ -1442,7 +1450,7 @@ describe("Owned renderer outcomes retained from the original journeys", () => {
}
}
expect(exit.y).toBeGreaterThanOrEqual(layer.y + layer.height);
- expect(draft.y).toBeGreaterThanOrEqual(layer.y + layer.height);
+ expect(layer.y).toBeGreaterThanOrEqual(identity.y + identity.height);
}
});
@@ -1495,11 +1503,11 @@ describe("Owned renderer outcomes retained from the original journeys", () => {
});
describe("Owned narrow guidance and pane navigation routes", () => {
- it("UI10: the narrow readiness row stays concise across focus changes", function* () {
+ it("UI10: the narrow readiness header stays concise across focus changes", function* () {
const model = yield* entriesModel(0);
const presenter = yield* usePresenter(NARROW);
const state = initialState("owned");
- for (const key of ["footer:input", "sessions:heading", "footer:exit", "footer:history"]) {
+ for (const key of ["draft:new", "sessions:heading", "footer:exit", "footer:history"]) {
yield* presenter.commit(
viewOf(model, NARROW, {
state: { ...state, restore: { kind: "reveal", key } },
@@ -1509,7 +1517,7 @@ describe("Owned narrow guidance and pane navigation routes", () => {
yield* presenter.commit(viewOf(model, NARROW, { state, focused: focusedKey(presenter) }));
expect(focusedKey(presenter)).toBe(key);
const rows = presenter.grid.rows();
- expect(rows.at(-2)?.trim()).toBe("Ready for Entry 1");
+ expect(rows[0]).toContain("Ready for Entry 1");
expect(rows.at(-1)).toContain("HISTORY");
}
});
@@ -1528,7 +1536,7 @@ describe("Owned narrow guidance and pane navigation routes", () => {
message: "Go?",
schema: {
type: "object",
- properties: { decision: { type: "string", enum: ["go"] } },
+ properties: { decision: { type: "string" } },
required: ["decision"],
additionalProperties: false,
},
@@ -1566,15 +1574,18 @@ describe("Owned narrow guidance and pane navigation routes", () => {
throw selected.error;
}
yield* presenter.commit(withWorkspace(selected.value, workspaceOf(model)));
- yield* presenter.commit(view(focusedKey(presenter)));
- const row = presenter.grid
- .rows()
- .find((one) => one.includes("Tab regions Alt↑↓"))
- ?.trim();
- expect(
- row?.startsWith(`Entry 1 question · Enter ${action} · Esc closes · Tab regions Alt↑↓`),
- ).toBe(true);
- expect(row?.length ?? 999).toBeLessThanOrEqual(72);
+ expect(focusedKey(presenter)).toBe(key);
+ const current = yield* presenter.commit(view(focusedKey(presenter)));
+ const layer = current.regionOf("box:drawer:layer");
+ if (layer === undefined) {
+ throw new Error("the active question has no drawer");
+ }
+ const help = presenter.grid
+ .textIn(layer)
+ .map((row) => row.trim())
+ .join(" ");
+ expect(help).toContain(`Enter ${action} · Esc closes · Tab regions Alt↑↓`);
+ expect(presenter.grid.rows()[0]).toContain("Entry 1 question");
}
});
@@ -1586,10 +1597,15 @@ describe("Owned narrow guidance and pane navigation routes", () => {
throw resolved.error;
}
const presenter = yield* usePresenter(WIDE);
- yield* presenter.commit(withWorkspace(resolved.value, workspaceOf(model)));
- for (let step = 0; step < 3; step += 1) {
- yield* presenter.tree.dispatch({ kind: "key", key: "Tab" });
- }
+ yield* presenter.commit(
+ withWorkspace(
+ {
+ ...resolved.value,
+ state: { ...resolved.value.state, restore: { kind: "reveal", key: "sidekick:message" } },
+ },
+ workspaceOf(model),
+ ),
+ );
expect(focusedKey(presenter)).toBe("sidekick:message");
const walked = yield* ring(presenter, "Backtab");
expect(walked.slice(0, 3)).toEqual(["sidekick:message", "sidekick:anchor", "tab:bindings"]);
@@ -1599,14 +1615,70 @@ describe("Owned narrow guidance and pane navigation routes", () => {
});
describe("Owned footer, History and single-field inventory", () => {
- it("UI1/UI5: the Draft and readiness precede the last History row", function* () {
+ it("keeps the full execution refusal readable from the narrow identity header", function* () {
+ // The long search path ends row five with a supplementary letter.
+ const cutoff = "\u{10400}";
+ const source = "";
+ const recovery = "/try-this-component-directory";
+ const page = yield* useReplPage({
+ size: NARROW,
+ includes: [`/${"a".repeat(215)}/${"b".repeat(70)}${cutoff}continued`, recovery],
+ });
+ const scroll = "Wheel here to read the refusal";
+ yield* pasteDraft(page, source);
+ yield* page.key("Tab");
+ yield* page.until("Send focused", (one) => one.shows("> Send"));
+ yield* page.key("Enter");
+ const refusal = yield* page.until("document refused", (one) =>
+ one.shows("Cannot resolve component:"),
+ );
+ expect(refusal.rows[0]).toContain("Ready for Entry 1");
+ expect(refusal.rows[0]).toContain("[ ] Show token usage");
+ expect(refusal.shows(recovery)).toBe(false);
+ expect(refusal.rows[5]).toContain(`${scroll} · 1–4 of `);
+ expect(refusal.rows.at(-2)).toContain("> Send");
+ expect(refusal.rows.at(-1)).toContain("HISTORY");
+
+ yield* page.wheel("down", refusal.locate("Cannot resolve component:"));
+ const tail = yield* page.until("the tail of the diagnostic", (one) => one.shows(recovery));
+ const from = Number(/· (\d+)–/.exec(tail.rows[5])?.[1]);
+ expect(tail.rows[6 - from]?.trimEnd()).toBe(`/${"b".repeat(70)}${cutoff}`);
+ expect(tail.rows.at(-2)).toContain("> Send");
+ expect(tail.rows.at(-1)).toContain("HISTORY");
+ yield* page.wheel("up", tail.locate(scroll));
+ yield* page.until("the start of the refusal again", (one) =>
+ one.shows("Cannot resolve component:"),
+ );
+
+ const resized = yield* page.resize(MEDIUM);
+ expect(resized.shows(recovery)).toBe(true);
+ expect(resized.rows.at(-2)).toContain("> Send");
+ expect(resized.rows.at(-1)).toContain("HISTORY");
+ yield* page.press("Show token usage");
+ yield* page.until("the usage toggle responding", (one) => one.shows("[x] Show token usage"));
+
+ expect((yield* mountedReading(page.repl)).model.entries).toEqual([]);
+ page.repl.terminal.end();
+ yield* awaited("the command ending", () => page.repl.outcome() !== undefined);
+ const outcome = page.repl.outcome();
+ if (outcome === undefined || !outcome.ok) {
+ throw new Error("the REPL did not return its location");
+ }
+ const location = decodeLocation(outcome.value.location);
+ if (!location.ok) {
+ throw location.error;
+ }
+ expect(location.value.draft).toBe(source);
+ });
+
+ it("UI1/UI5: the round bar touches History and readiness stays in the header", function* () {
const model = yield* entriesModel(1);
const presenter = yield* usePresenter(NARROW);
const observed = yield* presenter.commit(viewOf(model, NARROW));
const exit = observed.boundsOf("footer:exit");
- const input = observed.boundsOf("footer:input");
+ const input = observed.regionOf("box:round-bar");
const history = observed.boundsOf("footer:history");
- const guidance = observed.boundsOf("guidance");
+ const guidance = observed.regionOf("box:identity");
if (
exit === undefined ||
input === undefined ||
@@ -1615,7 +1687,7 @@ describe("Owned footer, History and single-field inventory", () => {
) {
throw new Error("the footer lost one of its surfaces");
}
- expect(input.y).toBeLessThan(exit.y);
+ expect(input.y + input.height).toBe(exit.y);
expect(history.y).toBe(exit.y);
expect(guidance.y).toBeLessThan(exit.y);
expect(exit.y).toBe(NARROW.rows - 1);
@@ -1623,7 +1695,7 @@ describe("Owned footer, History and single-field inventory", () => {
for (const word of ["HISTORY", "─", "[history]", "[exit]"]) {
expect(rows[exit.y]).toContain(word);
}
- expect(rows[guidance.y]?.trim()).toBe("Ready for Entry 2");
+ expect(rows[guidance.y]).toContain("Ready for Entry 2");
expect(rows.join(" ")).not.toContain("Tab regions");
for (const checkpoint of model.checkpoints) {
expect(rows[0]).not.toContain(checkpoint.label);
@@ -1666,7 +1738,7 @@ describe("Owned footer, History and single-field inventory", () => {
withWorkspace(resolved.value, workspaceOf(projection.value)),
);
const layer = observed.regionOf("box:drawer:layer");
- const guidance = observed.boundsOf("guidance");
+ const guidance = observed.regionOf("box:identity");
if (layer === undefined || guidance === undefined) {
throw new Error("no History layer or guidance");
}
@@ -1772,6 +1844,8 @@ describe("accepted rendered scrolling guidance", () => {
`${preview}`,
);
yield* page.until("source", (one) => one.shows(""));
+ yield* page.key("Tab");
+ yield* page.until("Round Send focused", (one) => one.shows("> Send"));
yield* page.key("Enter");
yield* page.until("question waiting", (one) => one.shows("[answer]"));
yield* page.press("[answer]");
@@ -1780,12 +1854,17 @@ describe("accepted rendered scrolling guidance", () => {
(one) => one.shows("[submit]") && one.shows("PageUp/PageDown reads"),
);
yield* sleep(30);
- const words = () =>
- page
- .screen()
- .rows.map((row) => row.trim())
+ const words = () => {
+ const { rows } = page.screen();
+ const border = rows.map((row) => /─{20,}/.exec(row)).find((match) => match !== null);
+ if (border === undefined) {
+ throw new Error("question drawer has no border");
+ }
+ return rows
+ .map((row) => row.slice(border.index, border.index + border[0].length).trim())
.join(" ")
.replace(/\s+/g, " ");
+ };
const wheelHelp =
"Wheel scrolls the reading under your pointer, three displayed rows per tick. It stops before hiding the focused control.";
expect(words()).toContain(
diff --git a/packages/cli/tests/repl-page.test.ts b/packages/cli/tests/repl-page.test.ts
index 615f9ed76..853cfe1d7 100644
--- a/packages/cli/tests/repl-page.test.ts
+++ b/packages/cli/tests/repl-page.test.ts
@@ -19,14 +19,15 @@ import type { Operation } from "effection";
import { useReplPage } from "./support/repl-page.ts";
import type { ReplPage, ScreenCell, ScreenScope } from "./support/repl-page.ts";
import { awaited } from "./support/mounted-repl.ts";
-import { intoDraft } from "./support/screen-journeys.ts";
+import { draftShows, intoDraft } from "./support/screen-journeys.ts";
const WIDE = { columns: 160, rows: 36 };
const NARROW = { columns: 72, rows: 20 };
const BELOW = { columns: 60, rows: 15 };
/** The Draft's own heading, which its Send shares a row with. */
-const DRAFT = " DRAFT";
+const DRAFT = "· draft";
+const ROUND_BAR = { onRow: "✎ draft" };
/** The Sidekick tab, which its own Send is drawn below and right of. */
const SIDEKICK = "SIDEKICK";
@@ -67,56 +68,77 @@ function* typed(page: ReplPage, text: string): Operation {
yield* page.until(`the screen showing ${JSON.stringify(text)}`, (one) => one.shows(text));
}
-describe("REPL page — two Sends, told apart by what is drawn beside them", () => {
- it("resolves each Send within its scope and refuses an ambiguous Send", function* () {
+describe("REPL page — Send and its visible scope", () => {
+ it("keeps one outlined editor and its caret while narrow Send hides the heading", function* () {
+ const page = yield* useReplPage({ size: NARROW });
+ yield* intoDraft(page);
+ const opened = page.screen();
+ expect(draftShows(opened, "Executable Markdown")).toBe(true);
+ const source = `${"a".repeat(85)}𐐀tail`;
+ yield* page.type(source);
+ yield* page.until("the tail within the editor", (one) => draftShows(one, "𐐀tail"));
+ yield* page.key("ArrowLeft");
+ yield* page.key("Tab");
+ const send = yield* page.until("narrow Send focused", (one) => one.shows("> Send"));
+ expect(send.shows("· draft")).toBe(false);
+ expect(send.shows("Enter adds a line")).toBe(false);
+ if (!draftShows(send, "𐐀tail")) {
+ throw new Error(page.describe());
+ }
+ yield* page.key("Backtab");
+ yield* page.until("heading and guidance restored", (one) => one.shows("> Round 1 · draft"));
+ yield* page.key("Tab");
+ yield* page.until("Send focused again", (one) => one.shows("> Send"));
+ const wide = yield* page.resize(WIDE);
+ expect(wide.shows("Round 1 · draft")).toBe(true);
+ const narrow = yield* page.resize(NARROW);
+ expect(narrow.shows("· draft")).toBe(false);
+ yield* page.press("𐐀tail");
+ yield* page.until("pointer refocused the editor", (one) => one.shows("> Round 1 · draft"));
+ yield* page.type("X");
+ yield* page.until("the same caret was used", (one) => draftShows(one, "𐐀taiXl"));
+ });
+
+ it("opens by pointer and moves focus from the editor directly to Send", function* () {
const page = yield* useReplPage({ size: WIDE });
+ yield* typed(page, "unsent Message");
+ yield* page.press("+ New Round");
+ const opened = yield* page.until("focused Round editor", (one) =>
+ one.shows("> Round 1 · draft"),
+ );
+ expect(opened.found("Send", ROUND_BAR)).toBe(1);
+ expect(opened.found("[send]", SIDEKICK_SEND)).toBe(1);
- // The screen really does draw this label twice, which is what makes the
- // scope necessary rather than decorative.
- const shown = page.screen();
- expect(shown.occurrences("[send]")).toBe(2);
- expect(shown.found("[send]", { onRow: DRAFT })).toBe(1);
- expect(shown.found("[send]", SIDEKICK_SEND)).toBe(1);
-
- // Unscoped, the locator refuses rather than taking the first of the two.
- const ambiguous = yield* refusal(page.press("[send]"));
- expect(ambiguous).toContain("is shown 2 times in the whole screen");
-
- // The composer begins between the Sidekick and Bindings tab labels.
- expect(shown.found(COMPOSER, SIDEKICK_SEND)).toBe(1);
- expect(shown.found(COMPOSER, { rightOf: "BINDINGS" })).toBe(0);
- expect(shown.occurrences(COMPOSER)).toBe(1);
+ yield* tab(page);
+ yield* page.until("focused Send", (one) => one.shows("> Send"));
+ yield* page.key("Enter");
+ yield* page.until("empty Send leaving the editor open", (one) => one.shows("Round 1 · draft"));
+ yield* page.key("Backtab");
+ yield* typed(page, "first line");
+ yield* page.key("Enter");
+ yield* typed(page, "second line");
+ const draft = page.screen();
+ expect(draft.locate("second line").row).toBe(draft.locate("first line").row + 1);
+ expect(draft.shows("1 ✓")).toBe(false);
+
+ yield* tab(page);
+ yield* page.key("Enter");
+ yield* page.until("the entry settling", (one) => one.shows("1 ✓"));
+ expect(page.screen().shows("unsent Message")).toBe(true);
});
it("survives content that echoes a control's label, and refuses one never drawn", function* () {
const page = yield* useReplPage({ size: WIDE });
yield* intoDraft(page);
-
- // A draft that quotes the control's own label. The echo is drawn on the
- // Draft's value rows, below its heading, so the screen now shows the label
- // three times and an unscoped press is refused with every cell named.
- yield* page.type("[send]");
- // Waited for by the count, because the label this types is already drawn
- // twice as a control: showing it is not evidence the Draft took it.
- const echoing = yield* page.until(
- "the Draft holding the label it quoted",
- (one) => one.occurrences("[send]") === 3,
- );
- const ambiguous = yield* refusal(page.press("[send]"));
+ yield* typed(page, "Send appears in this draft");
+ const ambiguous = yield* refusal(page.press("Send"));
expect(ambiguous).toContain("is shown 3 times in the whole screen");
- // Both scopes still resolve, because each names a row the echo is not on:
- // the heading row carries the Draft's own control, and the echo sits under
- // it rather than beside it.
- expect(echoing.found("[send]", { onRow: DRAFT })).toBe(1);
- expect(echoing.found("[send]", SIDEKICK_SEND)).toBe(1);
+ expect(page.screen().found("Send", ROUND_BAR)).toBe(1);
+ yield* page.press("Send", ROUND_BAR);
+ yield* page.until("the echoed draft being submitted", (one) => one.shows("1 ✓"));
- // And the scoped press still reaches the control rather than the echo.
- yield* page.press("[send]", { onRow: DRAFT });
- yield* page.until("the echoed draft being submitted", (one) => one.shows("1 \u2713"));
-
- // A label this product never draws is refused by name, with the rows read.
- const absent = yield* refusal(page.press("[submit]", { onRow: DRAFT }));
+ const absent = yield* refusal(page.press("[submit]"));
expect(absent).toContain('"[submit]" is shown 0 times');
expect(absent).toContain("rows=");
});
@@ -131,14 +153,15 @@ describe("REPL page — resize, a modal, and writes that never land", () => {
// Narrow routes one surface: no tab row, no composer, one Send.
const narrow = yield* page.resize(NARROW);
expect(narrow.shows("keep this draft")).toBe(true);
- expect(narrow.occurrences("[send]")).toBe(1);
+ expect(narrow.found("Send", ROUND_BAR)).toBe(1);
+ expect(narrow.locate("HISTORY").row).toBe(narrow.locate("Send", ROUND_BAR).row + 1);
expect(narrow.shows(SIDEKICK)).toBe(false);
expect(narrow.shows(COMPOSER)).toBe(false);
// The scope that named the Sidekick's Send is refused here, saying which
// visible text it could not find rather than pressing the Draft's instead.
const gone = yield* refusal(page.press("[send]", SIDEKICK_SEND));
expect(gone).toContain(`exactly one row showing ${JSON.stringify(SIDEKICK)}`);
- expect(narrow.found("[send]", { onRow: DRAFT })).toBe(1);
+ expect(narrow.found("Send", ROUND_BAR)).toBe(1);
// Below the minimum the screen is its own refusal and offers nothing.
const refused = yield* page.resize(BELOW);
@@ -149,7 +172,7 @@ describe("REPL page — resize, a modal, and writes that never land", () => {
const recovered = yield* page.resize(WIDE);
expect(recovered.shows("keep this draft")).toBe(true);
expect(recovered.found("keep this draft", { after: DRAFT })).toBe(1);
- expect(recovered.occurrences("[send]")).toBe(2);
+ expect(recovered.occurrences("[send]")).toBe(1);
});
it("publishes no reading for a write that is held, and resumes when it lands", function* () {
@@ -194,9 +217,9 @@ describe("REPL page — a column is a terminal cell, not a string offset", () =>
// The Draft's own Send, on a row the glyphs are not on, is unmoved and
// still submits what was typed.
- const draftSend = reading.locate("[send]", { onRow: DRAFT });
- expect(cellOf(page, "[send]").filter((one) => one.row === draftSend.row)).toEqual([draftSend]);
- yield* page.press("[send]", { onRow: DRAFT });
+ const draftSend = reading.locate("Send", ROUND_BAR);
+ expect(cellOf(page, "Send").filter((one) => one.row === draftSend.row)).toEqual([draftSend]);
+ yield* page.press("Send", ROUND_BAR);
yield* page.until("the wide entry settling", (one) => one.shows("1 \u2713"));
});
@@ -210,8 +233,8 @@ describe("REPL page — a column is a terminal cell, not a string offset", () =>
// and still excludes the Draft's.
const reading = page.screen();
expect(reading.found("[send]", SIDEKICK_SEND)).toBe(1);
- expect(reading.found("[send]", { onRow: DRAFT })).toBe(1);
- expect(reading.occurrences("[send]")).toBe(2);
+ expect(reading.found("Send", ROUND_BAR)).toBe(1);
+ expect(reading.occurrences("[send]")).toBe(1);
// And the glyphs themselves are read where they are drawn: the first is on
// the Draft's value row, two cells wide, with nothing of it left behind.
@@ -222,7 +245,7 @@ describe("REPL page — a column is a terminal cell, not a string offset", () =>
});
});
-const DRAFT_FOCUS = "> DRAFT";
+const DRAFT_FOCUS = "> Round";
/** What a question form asks for, so its second field is a real text field. */
const REVIEW = {
@@ -271,10 +294,7 @@ describe("REPL page — reaching a field the claim names, by keyboard", () => {
expect(page.screen().shows(DRAFT_FOCUS)).toBe(false);
- // Message -> History -> Transcript -> Selected work -> Draft.
- for (let press = 0; press < 4; press += 1) {
- yield* tab(page);
- }
+ yield* intoDraft(page);
expect(page.screen().shows(DRAFT_FOCUS)).toBe(true);
yield* typed(page, "");
@@ -282,6 +302,7 @@ describe("REPL page — reaching a field the claim names, by keyboard", () => {
expect(drafted.found("the first entry", { after: DRAFT })).toBe(1);
expect(drafted.found("the first entry", SIDEKICK_SEND)).toBe(0);
+ yield* tab(page);
yield* page.key("Enter");
yield* page.until("entry 1 settling", (one) => one.shows("1 ✓"));
expect(page.screen().shows("the first entry")).toBe(true);
diff --git a/packages/cli/tests/repl-paged-history.test.ts b/packages/cli/tests/repl-paged-history.test.ts
index f3a4f951b..dc8caaa85 100644
--- a/packages/cli/tests/repl-paged-history.test.ts
+++ b/packages/cli/tests/repl-paged-history.test.ts
@@ -27,7 +27,7 @@ import { pairedReplRepository } from "../src/repl/sidekick/repository.ts";
import { pairedLocation } from "../src/repl/sidekick/history.ts";
import { awaited, useMountedHost } from "./support/mounted-repl.ts";
import { useReplPage } from "./support/repl-page.ts";
-import { DRAFT_VALUE, pasteDraft, SIDEKICK_PANE } from "./support/screen-journeys.ts";
+import { pasteDraft, SIDEKICK_PANE } from "./support/screen-journeys.ts";
function admission(content: string): DurableEvent {
return {
@@ -280,12 +280,13 @@ describe("Paged REPL history", () => {
page,
'Hold for navigation.',
);
+ yield* page.key("Tab");
+ yield* page.until("Round Send focused", (one) => one.shows("> Send"));
yield* page.key("Enter");
yield* waiting.operation;
yield* page.until(
"the running third entry with its submitted Draft cleared",
- (screen) =>
- screen.shows("Entry 3 running") && screen.found("Hold for navigation.", DRAFT_VALUE) === 0,
+ (screen) => screen.shows("Entry 3 running") && !screen.shows("✎ draft"),
);
yield* page.press("BINDINGS");
yield* page.until("the first entry Input", (screen) => screen.shows("entry-1 Input"));
diff --git a/packages/cli/tests/repl-presentation-style.test.ts b/packages/cli/tests/repl-presentation-style.test.ts
index d2b012a58..8967d1437 100644
--- a/packages/cli/tests/repl-presentation-style.test.ts
+++ b/packages/cli/tests/repl-presentation-style.test.ts
@@ -717,9 +717,9 @@ function* exchange(page: ReplPage, order: number, one: Exchange): Operation reading.found("[stop]", { onRow: DRAFT }) === 1,
+ (reading) => reading.found("Stop", { onRow: "+ New Round" }) === 1,
);
- yield* page.press("[stop]", { onRow: DRAFT });
+ yield* page.press("Stop", { onRow: "+ New Round" });
}
yield* entrySettles(page, order, one.outcome);
yield* page.until(`the Sidekick saying ${one.said}`, (reading) =>
@@ -745,7 +745,7 @@ function* reachWorkspace(size: ReplTerminalSize): Operation {
yield* sendMessage(page, "second request");
yield* page.until(
"Entry 2 running",
- (reading) => reading.found("[stop]", { onRow: DRAFT }) === 1,
+ (reading) => reading.found("Stop", { onRow: "+ New Round" }) === 1,
);
yield* page.repl.fake.holdingTurns(1);
return page;
@@ -764,11 +764,13 @@ function* reachOutcomes(size: ReplTerminalSize): Operation {
yield* exchange(page, at + 1, one);
}
page.repl.fake.script(HELD_AGENT);
- yield* pasteDraft(page, `${RUNNING_SOURCE}\n${AGENT_TAIL}`, ["Tab", "Tab", "Tab", "Tab"]);
+ yield* pasteDraft(page, `${RUNNING_SOURCE}\n${AGENT_TAIL}`);
+ yield* page.key("Tab");
+ yield* page.until("Round Send focused", (one) => one.shows("> Send"));
yield* page.key("Enter");
yield* page.until(
"Entry 4 running",
- (reading) => reading.found("[stop]", { onRow: DRAFT }) === 1,
+ (reading) => reading.found("Stop", { onRow: "+ New Round" }) === 1,
);
yield* page.repl.fake.holdingTurns(1);
page.repl.fake.script({ reply: `${ROUNDING_QUESTION}\n` });
@@ -781,7 +783,7 @@ function* reachOutcomes(size: ReplTerminalSize): Operation {
function* typedInto(page: ReplPage): Operation {
yield* intoComposer(page);
yield* typed(page, CHECKPOINT_MESSAGE);
- yield* pasteDraft(page, CHECKPOINT_DRAFT, ["Tab", "Tab", "Tab", "Tab"]);
+ yield* pasteDraft(page, CHECKPOINT_DRAFT);
}
/** Open the Entries catalog through the control the sidebar draws for it. */
@@ -863,13 +865,11 @@ function groundsOf(observed: Observed, grid: TerminalGrid): (number | undefined)
expect([id, grid.at(at.x, at.y)]).toEqual([id, " "]);
return grid.styleAt(at.x, at.y).background;
};
- const box = regionOf(observed, "box:draft");
return [
ground("box:sidebar:body:gutter"),
ground("box:transcript:body:gutter"),
ground("box:inspection:body:gutter"),
grid.styleAt(0, regionOf(observed, "box:sidebar:header").y).background,
- grid.styleAt(box.x + box.width - 2, box.y + 2).background,
];
}
@@ -879,7 +879,6 @@ function chromeOf(observed: Observed): Record {
identity: regionOf(observed, "box:identity"),
body: regionOf(observed, "box:body"),
history: regionOf(observed, "box:history"),
- guidance: regionOf(observed, "box:guidance"),
};
}
@@ -894,8 +893,7 @@ function expectChrome(presenter: Presenter, observed: Observed, size: ReplTermin
where,
chrome: {
identity: { x: 0, y: 0, width: size.columns, height: 1 },
- body: { x: 0, y: 1, width: size.columns, height: size.rows - 3 },
- guidance: { x: 0, y: size.rows - 2, width: size.columns, height: 1 },
+ body: { x: 0, y: 1, width: size.columns, height: size.rows - 2 },
history: { x: 0, y: size.rows - 1, width: size.columns, height: 1 },
},
});
@@ -921,12 +919,12 @@ function expectChrome(presenter: Presenter, observed: Observed, size: ReplTermin
where,
identity: shown("box:identity").includes("XMD REPL"),
history: shown("box:history").includes("HISTORY"),
- guidance: grid.textIn(regionOf(observed, "box:guidance")).join("").trim().length > 0,
+ status: /Entry \d+ running/.test(shown("box:identity")),
controls: [
within(placed(observed, "footer:history"), regionOf(observed, "box:history")),
within(placed(observed, "footer:exit"), regionOf(observed, "box:history")),
],
- }).toEqual({ where, identity: true, history: true, guidance: true, controls: [true, true] });
+ }).toEqual({ where, identity: true, history: true, status: true, controls: [true, true] });
}
/** Whether every placed control is whole, inside the screen and clear of the others. */
@@ -968,11 +966,11 @@ function columnsOf(observed: Observed): Record {
};
}
-/** The Draft keeps four rows at the foot of its column, above readiness. */
-function expectDraft(observed: Observed, column: ReplBounds): void {
- const box = regionOf(observed, "box:draft");
- expect([box.height, box.y + box.height]).toEqual([4, regionOf(observed, "box:guidance").y]);
- expect([box.x >= column.x, box.x + box.width <= column.x + column.width]).toEqual([true, true]);
+function expectRoundBar(observed: Observed, column: ReplBounds): void {
+ const bar = regionOf(observed, "box:round-bar");
+ expect(bar.y + bar.height).toBe(regionOf(observed, "box:history").y);
+ expect(within(placed(observed, "draft:new"), bar)).toBe(true);
+ expect(within(bar, column)).toBe(true);
}
/**
@@ -981,10 +979,9 @@ function expectDraft(observed: Observed, column: ReplBounds): void {
*
* One mounted workspace per size: the Transcript, the selected work and the
* Bindings/Sidekick pane at the two wide sizes, one routed surface at the
- * narrow one, each under the identity row and above the compact History row
- * and the one row of guidance. The numbers are the specification's — the
+ * narrow one, each under the identity row and above the compact History row. The numbers are the specification's — the
* first composition at 160x36 gives the columns 36, 54 and 70 cells, dividers
- * included, a body of 33 rows and a four-row Draft; 120x30 follows it and 72x20
+ * included, a body of 34 rows and a final round bar; 120x30 follows it and 72x20
* routes one surface. A region comes from the frame the command presented, and
* a cell comes from the terminal that frame was written to; no row is compared
* with a stored picture.
@@ -992,17 +989,17 @@ function expectDraft(observed: Observed, column: ReplBounds): void {
describe("REPL appearance - the shipping profiles' geometry", () => {
beforeAll(() => useTempFileCompiler());
- it("160x36: columns of 36, 54 and 70, a body of 33 rows and a four-row Draft", function* () {
+ it("160x36: columns of 36, 54 and 70, a body of 34 rows and a final round bar", function* () {
const model = yield* runningReading();
const presenter = yield* usePresenter(WIDE);
const observed = yield* presenter.commit(stagedView(model, WIDE));
expectChrome(presenter, observed, WIDE);
expect(columnsOf(observed)).toEqual({
- sidebar: { x: 0, y: 1, width: 36, height: 33 },
- transcript: { x: 36, y: 1, width: 54, height: 33 },
- inspection: { x: 90, y: 1, width: 70, height: 33 },
+ sidebar: { x: 0, y: 1, width: 36, height: 34 },
+ transcript: { x: 36, y: 1, width: 54, height: 34 },
+ inspection: { x: 90, y: 1, width: 70, height: 34 },
});
- expectDraft(observed, regionOf(observed, "box:transcript"));
+ expectRoundBar(observed, regionOf(observed, "box:transcript"));
expect(placement(observed, WIDE)).toEqual({
count: true,
whole: true,
@@ -1017,11 +1014,11 @@ describe("REPL appearance - the shipping profiles' geometry", () => {
const observed = yield* presenter.commit(stagedView(model, MEDIUM));
expectChrome(presenter, observed, MEDIUM);
expect(columnsOf(observed)).toEqual({
- sidebar: { x: 0, y: 1, width: 24, height: 27 },
- transcript: { x: 24, y: 1, width: 40, height: 27 },
- inspection: { x: 64, y: 1, width: 56, height: 27 },
+ sidebar: { x: 0, y: 1, width: 24, height: 28 },
+ transcript: { x: 24, y: 1, width: 40, height: 28 },
+ inspection: { x: 64, y: 1, width: 56, height: 28 },
});
- expectDraft(observed, regionOf(observed, "box:transcript"));
+ expectRoundBar(observed, regionOf(observed, "box:transcript"));
expect(placement(observed, MEDIUM)).toEqual({
count: true,
whole: true,
@@ -1035,7 +1032,7 @@ describe("REPL appearance - the shipping profiles' geometry", () => {
const presenter = yield* usePresenter(SMALL);
const observed = yield* presenter.commit(stagedView(model, SMALL));
expectChrome(presenter, observed, SMALL);
- expect(regionOf(observed, "box:content")).toEqual({ x: 0, y: 1, width: 72, height: 17 });
+ expect(regionOf(observed, "box:content")).toEqual({ x: 0, y: 1, width: 72, height: 18 });
expect([observed.regionOf("box:sidebar"), observed.regionOf("box:inspection")]).toEqual([
undefined,
undefined,
@@ -1044,7 +1041,7 @@ describe("REPL appearance - the shipping profiles' geometry", () => {
observed.keys.includes("sessions:heading"),
observed.keys.includes("entries:heading"),
]).toEqual([true, true]);
- expectDraft(observed, regionOf(observed, "box:content"));
+ expectRoundBar(observed, regionOf(observed, "box:content"));
expect(placement(observed, SMALL)).toEqual({
count: true,
whole: true,
@@ -1084,27 +1081,42 @@ describe("REPL appearance - the archive's inks, from the mounted terminal", () =
expect(inkOf(grid, placed(catalog, "entry:entry-1")).foreground).toBe(SEMANTIC.tick);
expect(inkOf(grid, placed(catalog, "entry:entry-3")).foreground).toBe(REPL_PALETTE.waiting);
expect(inkOf(grid, placed(catalog, "entry:entry-3")).foreground).not.toBe(SEMANTIC.tick);
- const viewOf = (focused?: string): ReplView =>
- withWorkspace(reading(state, model, live, WIDE, focused), {
- ...workspaceOf(model),
- todo: { document: parseTodo("") },
- });
- yield* presenter.commit(viewOf());
+ const viewOf = (editing = false): ReplView =>
+ withWorkspace(
+ reading(
+ editing
+ ? {
+ ...state,
+ draftOpen: true,
+ draftCaret: { value: state.draft, offset: 0 },
+ restore: { kind: "reveal", key: "footer:input" },
+ }
+ : state,
+ model,
+ live,
+ WIDE,
+ ),
+ {
+ ...workspaceOf(model),
+ todo: { document: parseTodo("") },
+ },
+ );
+ const work = yield* presenter.commit(viewOf());
+ expect(inkIn(work, grid, "box:transcript:header", "● ACTIVE").foreground).toBe(
+ LIFECYCLE.active.colour,
+ );
+ const grounds = groundsOf(work, grid);
+ const observed = yield* presenter.commit(viewOf(true));
expect(focusKeyOf(presenter)).toBe("footer:input");
- const observed = yield* presenter.commit(viewOf(focusKeyOf(presenter)));
const foreground = (at: { x: number; y: number }): number | undefined =>
grid.styleAt(at.x, at.y).foreground;
- // The Draft is read as source: delimiters, a tag's name, an attribute's name,
- // the braces around a reference and what it names are each their own.
- expect(inkIn(observed, grid, "box:transcript:header", "● ACTIVE").foreground).toBe(
- LIFECYCLE.active.colour,
- );
- const tag = cellOf(observed, grid, "box:draft", " foreground({ x: tag.x + offset, y: tag.y }))).toEqual(
[SYNTAX.del, SYNTAX.tag, SYNTAX.attr, SYNTAX.brace, SYNTAX.ref],
);
- const quoted = cellOf(observed, grid, "box:draft", '"USD"');
+ const quoted = cellOf(observed, grid, "box:round-editor:body", '"USD"');
expect([0, 1, 4].map((offset) => foreground({ x: quoted.x + offset, y: quoted.y }))).toEqual([
SYNTAX.str,
SYNTAX.str,
@@ -1113,7 +1125,7 @@ describe("REPL appearance - the archive's inks, from the mounted terminal", () =
// Both fields a keystroke reaches are the archive's input surface, in every
// cell of every row they hold, blank ones included.
- const box = regionOf(observed, "box:draft");
+ const box = regionOf(observed, "box:round-editor:body");
const composer = regionOf(observed, "box:tray");
const surfaces = [
...[1, 2, 3].map((row) => grid.styleAt(box.x + box.width - 2, box.y + row)),
@@ -1123,7 +1135,7 @@ describe("REPL appearance - the archive's inks, from the mounted terminal", () =
// And the three columns, a header row and the Draft are each their own
// ground.
- expect(new Set(groundsOf(observed, grid)).size).toBe(5);
+ expect(new Set([...grounds, surfaces[0]]).size).toBe(5);
});
});
@@ -5123,7 +5135,7 @@ function* walkChat(page: ReplPage, inks: Map): Operation
[...row.matchAll(/\[[USR]\] /g)].map((match) => row.slice(match.index).trimEnd()),
@@ -5234,24 +5246,37 @@ describe("Checkpoint #971 — the workspace screen at 160x36", () => {
entry.key,
nested.key,
);
- const viewOf = (focused?: string): ReplView =>
- withWorkspace(reading(state, model, live, WIDE, focused), {
- ...workspaceOf(model),
- todo: { document: parseTodo("") },
- });
- yield* presenter.commit(viewOf());
- expect(focusKeyOf(presenter)).toBe("footer:input");
- const observed = yield* presenter.commit(viewOf(focusKeyOf(presenter)));
+ const viewOf = (editing = false): ReplView =>
+ withWorkspace(
+ reading(
+ editing
+ ? {
+ ...state,
+ draftOpen: true,
+ draftCaret: { value: state.draft, offset: 0 },
+ restore: { kind: "reveal", key: "footer:input" },
+ }
+ : state,
+ model,
+ live,
+ WIDE,
+ ),
+ {
+ ...workspaceOf(model),
+ todo: { document: parseTodo("") },
+ },
+ );
+ const observed = yield* presenter.commit(viewOf());
const { grid } = presenter;
// C1: the rows above, inside and below the body, and the three columns.
expectChrome(presenter, observed, WIDE);
expect(columnsOf(observed)).toEqual({
- sidebar: { x: 0, y: 1, width: 36, height: 33 },
- transcript: { x: 36, y: 1, width: 54, height: 33 },
- inspection: { x: 90, y: 1, width: 70, height: 33 },
+ sidebar: { x: 0, y: 1, width: 36, height: 34 },
+ transcript: { x: 36, y: 1, width: 54, height: 34 },
+ inspection: { x: 90, y: 1, width: 70, height: 34 },
});
- expectDraft(observed, regionOf(observed, "box:transcript"));
+ expectRoundBar(observed, regionOf(observed, "box:transcript"));
// C1: a real nested scope is selected, and the breadcrumb beside Entries
// says the ancestry it resolved to. The scope is read from the history the
@@ -5293,14 +5318,8 @@ describe("Checkpoint #971 — the workspace screen at 160x36", () => {
}
expect(observed.regionOf("box:band:0")).toBe(undefined);
- // The Draft's own Stop shares its heading row, at the right of the field.
- const draftBox = regionOf(observed, "box:draft");
- const input = placed(observed, "footer:input");
- const draftStop = placed(observed, "draft:stop");
- expect(input.y).toBe(draftBox.y);
- expect(draftStop.y).toBe(draftBox.y);
- expect(draftStop.x).toBeGreaterThan(input.x);
- expect(draftStop.x + draftStop.width).toBeLessThanOrEqual(draftBox.x + draftBox.width);
+ const bar = regionOf(observed, "box:round-bar");
+ expect(within(placed(observed, "draft:stop"), bar)).toBe(true);
const sidekickTab = placed(observed, "tab:sidekick");
const todo = placed(observed, "todo:header");
@@ -5348,26 +5367,30 @@ describe("Checkpoint #971 — the workspace screen at 160x36", () => {
// Surfaces: the three columns, a header row and the Draft are each their own
// ground, and every value row of the Draft is the Draft's, blank ones too.
const grounds = groundsOf(observed, grid);
- expect(new Set(grounds).size).toBe(5);
+ const editing = yield* presenter.commit(viewOf(true));
+ const draftBox = regionOf(editing, "box:round-editor:body");
+ const input = placed(editing, "footer:input");
+ const background = grid.styleAt(draftBox.x + draftBox.width - 2, draftBox.y + 1).background;
+ expect(new Set([...grounds, background]).size).toBe(5);
for (const row of [1, 2, 3]) {
- expect([
- row,
- grid.styleAt(draftBox.x + draftBox.width - 2, draftBox.y + row).background,
- ]).toEqual([row, grounds[4]]);
+ expect(grid.styleAt(draftBox.x + draftBox.width - 2, draftBox.y + row).background).toBe(
+ background,
+ );
}
- // C2: the Draft is the control the frame holds focus on, and the cue is
- // drawn on that same control: bold on the focused field's first cell and not
- // on the composer, which is not where the next keystroke lands.
+ // The Draft owns focus across its interior. The gold heading draws the cue
+ // above it without adding another input target.
expect(focusKeyOf(presenter)).toBe("footer:input");
- expect(grid.styleAt(input.x, input.y).attrs.includes(BOLD)).toBe(true);
- expect(grid.styleAt(input.x, input.y).attrs).toContain(4);
- expect(grid.styleAt(input.x + input.width - 1, input.y).background).toBe(
+ expect(input).toEqual(draftBox);
+ const draftHeading = regionOf(editing, "box:round-editor:heading");
+ expect(textOf(grid, draftHeading)).toContain("> Round");
+ expect(inkOfSpan(grid, draftHeading, "Round").attrs).toContain(BOLD);
+ expect(grid.styleAt(draftHeading.x + draftHeading.width - 1, draftHeading.y).background).toBe(
REPL_PALETTE.focusSurface,
);
- const message = placed(observed, "sidekick:message");
+ const message = placed(editing, "sidekick:message");
expect(grid.styleAt(message.x, message.y).attrs.includes(BOLD)).toBe(false);
- const value = cellOf(observed, grid, "box:draft", " {
const repliedInk = chatInk("[S] one done");
expect(askedInk).not.toBe(repliedInk);
expect(inkIn(observed, grid, "box:tray", "Also say").foreground).not.toBe(askedInk);
- expect(inkIn(observed, grid, "box:transcript:header", "● ACTIVE").foreground).not.toBe(
- inkIn(observed, grid, "box:transcript:header", "› Entry").foreground,
- );
});
/**
@@ -5398,7 +5418,8 @@ describe("Checkpoint #971 — the workspace screen at 160x36", () => {
it("A6: Entries opens a catalog over the reading, and only a row in it navigates", function* () {
const page = yield* reachWorkspace(WIDE);
yield* typedInto(page);
- const holding = (): Record => {
+ const holding = function* (): Operation> {
+ yield* intoDraft(page);
const reading = page.screen();
return {
draft: DRAFT_LINES.map((line) => reading.found(line, DRAFT_VALUE)),
@@ -5416,6 +5437,14 @@ describe("Checkpoint #971 — the workspace screen at 160x36", () => {
};
};
const began = yield* standing();
+ const openSelectedCatalog = function* () {
+ if (page.screen().shows(DRAFT)) {
+ yield* page.key("Ctrl+G");
+ yield* page.type("3");
+ yield* page.until("selected work restored", (one) => !one.shows(DRAFT));
+ }
+ yield* openCatalog(page);
+ };
for (const size of [WIDE, MEDIUM, SMALL]) {
const where = `${size.columns}x${size.rows}`;
@@ -5426,14 +5455,14 @@ describe("Checkpoint #971 — the workspace screen at 160x36", () => {
expect([where, drawerOpen(resized)]).toEqual([where, true]);
yield* closeDrawer(page);
}
- const kept = holding();
+ const kept = yield* holding();
// Closed, there is no catalog on the screen.
expect([where, drawerOpen(page.screen())]).toEqual([where, false]);
expect([where, page.screen().shows("entry-1")]).toEqual([where, false]);
// The control a person presses asks for the catalog.
- yield* openCatalog(page);
+ yield* openSelectedCatalog();
// Every entry this history holds, in admission order, with its own nested
// scope, and each of them drawn in the catalog's own rows rather than
@@ -5462,27 +5491,27 @@ describe("Checkpoint #971 — the workspace screen at 160x36", () => {
yield* page.until("the catalog closing", (reading) => !drawerOpen(reading));
expect([where, trailOf(page.screen()).includes("Entry 2")]).toEqual([where, true]);
expect([where, trailOf(page.screen()).includes("Checklist")]).toEqual([where, true]);
- expect([where, holding()]).toEqual([where, kept]);
+ expect([where, yield* holding()]).toEqual([where, kept]);
// An older entry, by its own name, from the same open catalog.
- yield* openCatalog(page);
+ yield* openSelectedCatalog();
yield* page.press("entry-1");
yield* page.until("the catalog closing", (reading) => !drawerOpen(reading));
expect([where, trailOf(page.screen()).includes("Entry 1")]).toEqual([where, true]);
expect([where, trailOf(page.screen()).includes("Checklist")]).toEqual([where, false]);
// Nothing a person was holding moved, by either route: both texts, the
// conversation filter and the history position stand.
- expect([where, holding()]).toEqual([where, kept]);
+ expect([where, yield* holding()]).toEqual([where, kept]);
// And closing chooses nothing. The scope being read is the one that was
// being read before the catalog opened.
- yield* openCatalog(page);
+ yield* openSelectedCatalog();
yield* closeDrawer(page);
expect([where, trailOf(page.screen()).includes("Entry 1")]).toEqual([where, true]);
- expect([where, holding()]).toEqual([where, kept]);
+ expect([where, yield* holding()]).toEqual([where, kept]);
if (size !== SMALL) {
- yield* openCatalog(page);
+ yield* openSelectedCatalog();
}
}
// Opening is navigation and nothing else: no provider work, no append, no
@@ -5492,8 +5521,7 @@ describe("Checkpoint #971 — the workspace screen at 160x36", () => {
it("A5: one Transcript list, with the conversations as its filter", function* () {
const page = yield* reachOutcomes(WIDE);
- yield* intoComposer(page);
- yield* typed(page, CHECKPOINT_MESSAGE);
+ yield* typedInto(page);
const typedNow = (): Record => {
const reading = page.screen();
return {
@@ -5750,9 +5778,9 @@ describe("Checkpoint #971 A2 — the workspace at the two smaller sizes", () =>
// takes the remainder because it is the column whose room is spent on a
// reserved rail and badge column before a reader sees any source.
expect(columnsOf(observed)).toEqual({
- sidebar: { x: 0, y: 1, width: 24, height: 27 },
- transcript: { x: 24, y: 1, width: 40, height: 27 },
- inspection: { x: 64, y: 1, width: 56, height: 27 },
+ sidebar: { x: 0, y: 1, width: 24, height: 28 },
+ transcript: { x: 24, y: 1, width: 40, height: 28 },
+ inspection: { x: 64, y: 1, width: 56, height: 28 },
});
// What that buys is source room, measured through the reading's own
@@ -5780,8 +5808,7 @@ describe("Checkpoint #971 A2 — the workspace at the two smaller sizes", () =>
});
}
- // The Draft keeps its four rows at the foot of that column.
- expectDraft(observed, regionOf(observed, "box:transcript"));
+ expectRoundBar(observed, regionOf(observed, "box:transcript"));
});
it("A2: the selected work's source wraps at word boundaries and stays exact", function* () {
@@ -5911,8 +5938,8 @@ describe("Checkpoint #971 A2 — the workspace at the two smaller sizes", () =>
yield* page.until("the Entries catalog", drawerOpen);
yield* closeDrawer(page);
const entries = page.screen();
- expect(entries.shows("DRAFT")).toBe(true);
- expect(entries.found("[stop]", { onRow: "DRAFT" })).toBe(1);
+ expect(entries.shows("· draft")).toBe(true);
+ expect(entries.found("Stop", { onRow: "+ New Round" })).toBe(1);
for (const control of ["Sessions", "Entries"]) {
expect({ control, shown: entries.shows(control) }).toEqual({ control, shown: true });
}
@@ -6098,25 +6125,25 @@ describe("Checkpoint #971 R2 — current chat windows and outcomes", () => {
describe("REPL presentation: the screen says what is placed", () => {
it("keeps the shell and its readable surfaces at the supported sizes", function* () {
const page = yield* useReplPage({ size: WIDE });
- yield* page.type("\x074");
- yield* page.until("Draft focus", (one) => one.shows("> DRAFT"));
+ yield* intoDraft(page);
const wide = page.screen();
expect(wide.shows("XMD REPL")).toBe(true);
expect(wide.shows("TRANSCRIPT")).toBe(true);
expect(wide.shows(BINDINGS)).toBe(true);
expect(wide.shows(SIDEKICK)).toBe(true);
expect(wide.shows("HISTORY")).toBe(true);
- expect(wide.occurrences("[send]")).toBe(2);
+ expect(wide.occurrences("[send]")).toBe(1);
+ expect(wide.found("Send", { onRow: "✎ draft" })).toBe(1);
const medium = yield* page.resize(MEDIUM);
expect(medium.shows("XMD REPL")).toBe(true);
expect(medium.shows("HISTORY")).toBe(true);
- expect(medium.shows("> DRAFT")).toBe(true);
+ expect(medium.shows("> Round 1 · draft")).toBe(true);
const narrow = yield* page.resize(SMALL);
expect(narrow.shows("XMD REPL")).toBe(true);
expect(narrow.shows("HISTORY")).toBe(true);
- expect(narrow.occurrences("[send]")).toBe(1);
+ expect(narrow.found("Send", { onRow: "✎ draft" })).toBe(1);
expect(narrow.shows(SIDEKICK)).toBe(false);
expect(narrow.shows(COMPOSER)).toBe(false);
@@ -6127,8 +6154,7 @@ describe("REPL presentation: the screen says what is placed", () => {
it("keeps source text in the field that draws it", function* () {
const page = yield* useReplPage({ size: WIDE });
- yield* page.type("\x074");
- yield* page.until("Draft focus", (one) => one.shows("> DRAFT"));
+ yield* intoDraft(page);
const source = "";
yield* draftText(page, source);
const reading = page.screen();
@@ -6139,8 +6165,7 @@ describe("REPL presentation: the screen says what is placed", () => {
it("keeps a modal readable and leaves the Draft unchanged behind it", function* () {
const page = yield* useReplPage({ size: WIDE });
- yield* page.type("\x074");
- yield* page.until("Draft focus", (one) => one.shows("> DRAFT"));
+ yield* intoDraft(page);
yield* draftText(page, "keep this draft");
yield* openHistory(page);
expect(page.screen().shows("History")).toBe(true);
@@ -6153,10 +6178,11 @@ describe("REPL presentation: the screen says what is placed", () => {
it("keeps the Sidekick scope distinct from the Draft Send", function* () {
const page = yield* useReplPage({ size: WIDE });
+ yield* intoDraft(page);
yield* intoComposer(page);
const reading = page.screen();
expect(reading.found("[send]", SIDEKICK_PANE)).toBe(1);
- expect(reading.found("[send]", { onRow: DRAFT })).toBe(1);
+ expect(reading.found("Send", { onRow: "✎ draft" })).toBe(1);
});
it("keeps terminal surfaces on the accepted palette", function* () {
@@ -6164,7 +6190,7 @@ describe("REPL presentation: the screen says what is placed", () => {
const model = yield* emptyModel();
const presenter = yield* usePresenter(WIDE);
const view = viewFor(
- initialState("reference"),
+ { ...initialState("reference"), draftOpen: true },
model,
NOTHING_LIVE,
WIDE,
@@ -6175,7 +6201,7 @@ describe("REPL presentation: the screen says what is placed", () => {
throw view.error;
}
const observed = yield* presenter.commit(withWorkspace(view.value, workspaceOf(model)));
- const draft = observed.boundsOf("footer:input");
+ const draft = observed.regionOf("box:round-editor:body");
const history = observed.regionOf("box:history");
if (draft === undefined || history === undefined) {
throw new Error("the empty frame did not publish its Draft and History surfaces");
diff --git a/packages/cli/tests/repl-project-files.test.ts b/packages/cli/tests/repl-project-files.test.ts
index 58a7bd566..295802e34 100644
--- a/packages/cli/tests/repl-project-files.test.ts
+++ b/packages/cli/tests/repl-project-files.test.ts
@@ -374,6 +374,8 @@ describe("1113: session scopes retain their restrictions", () => {
page,
'wrongallowed',
);
+ yield* page.key("Tab");
+ yield* page.until("Round Send focused", (one) => one.shows("> Send"));
yield* page.key("Enter");
yield* awaitedFact("manual redirected write entry settles", function* () {
return (yield* settledReading(page.repl)).model.entries[0]?.settled === true;
@@ -787,6 +789,8 @@ describe("1113: project selection belongs to the actual entry", () => {
const session = pairedLocation(page.repl.root, yield* mountedExecution(page.repl)).directory;
expect(session).not.toBe(project);
yield* pasteDraft(page, "");
+ yield* page.key("Tab");
+ yield* page.until("Round Send focused", (one) => one.shows("> Send"));
yield* page.key("Enter");
yield* entrySettles(page, 1, "ok");
page.repl.fake.script({
@@ -844,6 +848,8 @@ describe("1113: project selection belongs to the actual entry", () => {
const page = yield* useReplPage({ host });
const source = '';
yield* pasteDraft(page, source);
+ yield* page.key("Tab");
+ yield* page.until("Round Send focused", (one) => one.shows("> Send"));
yield* page.key("Enter");
yield* entrySettles(page, 1, "ok");
page.repl.fake.script({ reply: submit(source) });
diff --git a/packages/cli/tests/repl-project-recovery.test.ts b/packages/cli/tests/repl-project-recovery.test.ts
index ffbad5270..324426e15 100644
--- a/packages/cli/tests/repl-project-recovery.test.ts
+++ b/packages/cli/tests/repl-project-recovery.test.ts
@@ -86,6 +86,8 @@ function* saved(sidekick = false) {
yield* sendMessage(page, "start the held entry");
} else {
yield* pasteDraft(page, source);
+ yield* page.key("Tab");
+ yield* page.until("Round Send focused", (one) => one.shows("> Send"));
yield* page.key("Enter");
}
yield* waiting.operation;
diff --git a/packages/cli/tests/repl-restore-progress.test.ts b/packages/cli/tests/repl-restore-progress.test.ts
index b4d6d861c..09af3d9fe 100644
--- a/packages/cli/tests/repl-restore-progress.test.ts
+++ b/packages/cli/tests/repl-restore-progress.test.ts
@@ -263,10 +263,10 @@ describe("#1037 cold restore progress", () => {
yield* shown(terminal, "Saved round 155 witness.");
yield* shown(terminal, "Saved Sidekick reply witness.");
yield* shown(terminal, "Restored 155 rounds in ");
- terminal.feed("reopened-draft");
+ terminal.feed("\x074\rreopened-draft");
const live = yield* shown(terminal, "reopened-draft");
const draft = live.map((row) => row.slice(36, 90));
- const heading = draft.findIndex((row) => row.includes("DRAFT"));
+ const heading = draft.findIndex((row) => row.includes("· draft"));
expect(heading).toBeGreaterThanOrEqual(0);
expect(draft.slice(heading + 1).some((row) => row.includes("reopened-draft"))).toBe(true);
expect(live.some((row) => row.slice(90).includes("reopened-draft"))).toBe(false);
diff --git a/packages/cli/tests/repl-sidekick-configuration.test.ts b/packages/cli/tests/repl-sidekick-configuration.test.ts
index 72c37c239..4e055cda7 100644
--- a/packages/cli/tests/repl-sidekick-configuration.test.ts
+++ b/packages/cli/tests/repl-sidekick-configuration.test.ts
@@ -2062,7 +2062,7 @@ describe("Tier CFG — Retry for a request whose turn failed", () => {
// Retry sends, and neither is consumed by it.
// The send left the keystrokes in the composer, so this needs no route.
yield* typed(page, "something else");
- yield* draftText(page, "mine", ["Tab", "Tab", "Tab", "Tab"]);
+ yield* draftText(page, "mine");
// A second explicit Retry waits behind the first; it consumes no newer text.
yield* page.press("[retry]");
@@ -2245,6 +2245,8 @@ describe("Tier TE — the two configured agents each do their own work", () => {
// default is what is under test, and naming it here would bypass it.
repl.fake.script({ reply: `${ANSWERED}\n` });
yield* pasteDraft(page, ASKING);
+ yield* page.key("Tab");
+ yield* page.until("Round Send focused", (one) => one.shows("> Send"));
yield* page.key("Enter");
yield* page.until("the entry's own Agent answering", (one) => one.shows(ANSWERED));
diff --git a/packages/cli/tests/repl-sidekick-dispatch.test.ts b/packages/cli/tests/repl-sidekick-dispatch.test.ts
index f77fbc576..0475a73b8 100644
--- a/packages/cli/tests/repl-sidekick-dispatch.test.ts
+++ b/packages/cli/tests/repl-sidekick-dispatch.test.ts
@@ -224,7 +224,7 @@ describe("shared Sidekick dispatch", () => {
);
yield* intoComposer(page);
yield* typed(page, "newer unsent text");
- yield* draftText(page, "newer held draft", ["Tab", "Tab", "Tab", "Tab"]);
+ yield* draftText(page, "newer held draft");
expect(page.repl.fake.prompts).toHaveLength(1);
const before = yield* settledReading(page.repl);
expect(before.chat.filter((one) => one.kind === "message")).toHaveLength(1);
diff --git a/packages/cli/tests/repl-sidekick-journey.test.ts b/packages/cli/tests/repl-sidekick-journey.test.ts
index f5080263e..bb99a434c 100644
--- a/packages/cli/tests/repl-sidekick-journey.test.ts
+++ b/packages/cli/tests/repl-sidekick-journey.test.ts
@@ -101,9 +101,10 @@ import {
COMPOSER_VALUE,
composerHolds,
draftHolds,
+ draftOpen,
+ draftShows,
draftText,
entrySettles,
- DRAFT,
DRAFT_VALUE,
intoComposer,
intoDraft,
@@ -1281,10 +1282,8 @@ describe("Tier PV — a response in flight, shown as it arrives", () => {
expect(during.chat.filter((record) => record.kind === "control")).toEqual([]);
expect(during.chat.filter((record) => record.kind === "response")).toEqual([]);
expect(during.model.entries).toEqual([]);
- // The screen says the same thing by what it is showing: the catalog holds
- // no entry, and the draft is still a draft somebody is holding rather than
- // work that has been admitted.
- expect(page.screen().shows("No entry yet")).toBe(true);
+ // History shows the empty execution while the editor still holds the draft.
+ expect(page.screen().shows("HEAD · EMPTY")).toBe(true);
// Both composers keep newer text while the active exchange owns Stop.
expect(draftHolds(page.screen(), "mine")).toBe(true);
expect(composerHolds(page.screen(), "later")).toBe(true);
@@ -1293,7 +1292,7 @@ describe("Tier PV — a response in flight, shown as it arrives", () => {
expect(sidekickIdle(page.screen())).toBe(false);
expect(page.screen().found("[stop]", SIDEKICK_PANE)).toBe(1);
expect(page.screen().found("[send]", SIDEKICK_PANE)).toBe(1);
- expect(page.screen().found("[send]", { onRow: DRAFT })).toBe(1);
+ expect(page.screen().found("Send", { onRow: "✎ draft" })).toBe(1);
// The rest of the text arrives, and the entry the reply submits is held
// open: generation is over and the response is running its controls.
@@ -1318,7 +1317,7 @@ describe("Tier PV — a response in flight, shown as it arrives", () => {
expect(complete.chat.filter((record) => record.kind === "response")).toEqual([]);
expect(complete.model.entries).toEqual([]);
expect(draftHolds(page.screen(), "mine")).toBe(true);
- expect(page.screen().shows("No entry yet")).toBe(true);
+ expect(page.screen().shows("HEAD · EMPTY")).toBe(true);
expect(repl.terminal.fed).toBe(fed);
repl.fake.releaseDeltas();
@@ -1730,7 +1729,7 @@ describe("Tier R5 — a mounted message prepares and submits a real entry", () =
expect(first.model.entries[0]?.terminal?.output).toContain("Hello from the reply.");
expect(page.screen().shows("Hello from the reply.")).toBe(true);
// Consumed by the entry it became: the Draft shows none of what was in it.
- expect(page.screen().found("Hello from the reply.", DRAFT_VALUE)).toBe(0);
+ expect(draftOpen(page.screen())).toBe(false);
// The receipt names this entry, carries no body, and keeps admission order.
expect(fake.prompts).toHaveLength(2);
@@ -1898,7 +1897,7 @@ describe("Tier R5 — a mounted message prepares and submits a real entry", () =
// The draft moves while the submission is being prepared, which is what
// the start check refuses on: the prepared text is not the text anybody
// is asking for any more.
- yield* draftText(page, "!", ["Tab", "Tab", "Tab", "Tab"]);
+ yield* draftText(page, "!");
allow.resolve();
yield* page.until("the refused submission going back", (one) =>
sidekickShows(one, "I did not admit an entry."),
@@ -1939,10 +1938,9 @@ describe("Tier R5 — a mounted message prepares and submits a real entry", () =
unwrapped(intent.submit?.source ?? "")
.split(" ")
.at(-1) ?? "";
- yield* page.until(
- "the reserved source restored",
- (one) => one.found(reserved, DRAFT_VALUE) > 0,
- );
+ yield* page.until("the reserved source restored", (one) => draftShows(one, reserved));
+ yield* page.key("Tab");
+ yield* page.until("Round Send focused", (one) => one.shows("> Send"));
yield* page.key("Enter");
yield* page.until("the manual entry running", (one) => one.shows("The manual entry ran."));
yield* entrySettles(page, 3, "ok");
@@ -2148,6 +2146,8 @@ describe("Tier TE — a published binding becomes real greetings, and then a rea
// The seed, as a person's own entry: pasted into the draft and run. The
// draft shows its own source, so the entry's outcome is what says it ran.
yield* pasteDraft(page, seed(names));
+ yield* page.key("Tab");
+ yield* page.until("Round Send focused", (one) => one.shows("> Send"));
yield* page.key("Enter");
yield* entrySettles(page, 1, "ok");
yield* page.until("the seed entry publishing its names", (one) =>
@@ -2164,6 +2164,8 @@ describe("Tier TE — a published binding becomes real greetings, and then a rea
yield* sendMessage(page, "greet");
yield* repl.fake.holdingTurns(1);
+ yield* intoDraft(page);
+ yield* page.key("Home");
yield* page.until(
"the draft holding the prepared greetings",
(one) => one.found(" 0,
@@ -3493,13 +3495,8 @@ describe("975 — the shipped session component journey", () => {
expect(yield* cwd()).toBe(project);
const sibling = yield* spawn(() => cwd());
expect(yield* sibling).toBe(project);
- yield* draftText(page, 'project manual', [
- "Tab",
- "Tab",
- "Tab",
- "Tab",
- ]);
- yield* page.key("Enter");
+ yield* draftText(page, 'project manual');
+ yield* page.press("Send", { onRow: "✎ draft" });
yield* page.until("the manual successor", (one) =>
one.rows.some((line) => {
// The same fact the catalog used to spell as `entry-4 [ok]`: the fourth
@@ -4036,8 +4033,8 @@ describe("Follow: submitted rounds in the running command", () => {
"the actual interrupted prefix beside its source",
(one) => one.occurrences("INTERRUPTED-PREFIX") >= 2,
);
- yield* page.until("Entry Stop", (one) => one.found("[stop]", { onRow: DRAFT }) === 1);
- yield* page.press("[stop]", { onRow: DRAFT });
+ yield* page.until("Entry Stop", (one) => one.found("Stop", { onRow: "+ New Round" }) === 1);
+ yield* page.press("Stop", { onRow: "+ New Round" });
yield* savedReplies(page.repl, 5);
yield* page.until("the joined Send", sidekickIdle);
const prompts = page.repl.fake.prompts;
@@ -4136,8 +4133,8 @@ describe("Follow: submitted rounds in the running command", () => {
yield* savedReplies(page.repl, 3);
yield* page.until("ordinary read joined", sidekickIdle);
expect(page.repl.fake.prompts).toHaveLength(3);
- yield* draftText(page, "", ["Tab", "Tab", "Tab", "Tab"]);
- yield* page.press("[send]", { onRow: DRAFT });
+ yield* draftText(page, "");
+ yield* page.press("Send", { onRow: "✎ draft" });
yield* awaitedFact("manual entry settles", function* () {
return (yield* settledReading(page.repl)).model.entries[1]?.terminal?.status === "ok";
});
@@ -4582,6 +4579,8 @@ describe("993 mounted nested Output journeys", () => {
const page = yield* useReplPage({ projectCwd: workspace, hostFiles: true });
const source = `\n\ndone\n\n\nwaiting\n\n\n`;
yield* pasteDraft(page, source);
+ yield* page.key("Tab");
+ yield* page.until("Round Send focused", (one) => one.shows("> Send"));
yield* page.key("Enter");
yield* entrySettles(page, 1, "ok");
const expected = ready ? "Review complete." : "Review pending.";
@@ -4643,6 +4642,7 @@ describe("993 mounted nested Output journeys", () => {
expect(rows).toHaveLength(1);
expect(rows[0]?.text).toBe("Review complete.");
expect(paneCount(page, "Review complete.")).toBe(1);
+ yield* intoDraft(page);
expect(draftHolds(page.screen(), "prepared")).toBe(true);
const prompts = [...repl.fake.prompts];
const reopened = yield* repl.repository.open(saved.execution);
@@ -4757,7 +4757,10 @@ describe("993 mounted nested Output journeys", () => {
expect(rows[0]).toMatchObject({ kind: "incomplete", text: "ABC" });
expect(known.turns[0]?.status).toBe("failed");
}
- expect(draftHolds(page.screen(), "never")).toBe(false);
+ expect(draftOpen(page.screen())).toBe(false);
+ yield* intoDraft(page);
+ expect(draftShows(page.screen(), "never")).toBe(false);
+ expect(draftShows(page.screen(), "Executable Markdown")).toBe(true);
expect(saved.model.entries).toEqual([]);
});
}
diff --git a/packages/cli/tests/repl-sidekick-lifecycle.test.ts b/packages/cli/tests/repl-sidekick-lifecycle.test.ts
index c73c1318d..c5ec240da 100644
--- a/packages/cli/tests/repl-sidekick-lifecycle.test.ts
+++ b/packages/cli/tests/repl-sidekick-lifecycle.test.ts
@@ -1026,6 +1026,8 @@ describe("Tier PV — generation that ended without a reply", () => {
(path, record) => path.endsWith("entries.jsonl") && record.includes('"type":"close"'),
);
yield* pasteDraft(page, OWN_ENTRY);
+ yield* page.key("Tab");
+ yield* page.until("Round Send focused", (one) => one.shows("> Send"));
yield* page.key("Enter");
yield* closing.started();
@@ -1218,6 +1220,8 @@ describe("Tier R6 — leaving, with Sidekick work in flight", () => {
// An ordinary entry of this person's, admitted and still open.
yield* pasteDraft(page, SUSPENDS);
+ yield* page.key("Tab");
+ yield* page.until("Round Send focused", (one) => one.shows("> Send"));
yield* page.key("Enter");
yield* page.until("the entry being admitted", (one) => one.shows("Entry 1"));
if (draft !== undefined) {
@@ -1718,6 +1722,8 @@ describe("Tier MQ — two questions, two answers, and Stop", () => {
// The entry's question first, so both are pending at once.
yield* pasteDraft(page, ENTRY_ASKS);
+ yield* page.key("Tab");
+ yield* page.until("Round Send focused", (one) => one.shows("> Send"));
yield* page.key("Enter");
yield* page.until("the entry's question announcing itself", (one) => one.shows("[answer]"));
@@ -1770,6 +1776,8 @@ describe("Tier MQ — two questions, two answers, and Stop", () => {
// The entry's question, pending throughout: Stop is the Sidekick's and must
// not reach it.
yield* pasteDraft(page, ENTRY_ASKS);
+ yield* page.key("Tab");
+ yield* page.until("Round Send focused", (one) => one.shows("> Send"));
yield* page.key("Enter");
yield* page.until("the entry's question announcing itself", (one) => one.shows("[answer]"));
@@ -1882,6 +1890,8 @@ describe("Tier MQ — leaving with questions pending, and the cold reopen after"
// The entry's question, pending and unanswered throughout.
yield* pasteDraft(page, ENTRY_WAITS);
+ yield* page.key("Tab");
+ yield* page.until("Round Send focused", (one) => one.shows("> Send"));
yield* page.key("Enter");
yield* page.until("the entry's question announcing itself", (one) => one.shows("[answer]"));
@@ -2214,7 +2224,7 @@ describe("Follow: mounted Stop owns continuation", () => {
yield* stopSidekick(page);
yield* page.until(
"Sidekick Stop joined with the entry still running",
- (one) => sidekickIdle(one) && one.found("[stop]", { onRow: DRAFT }) === 1,
+ (one) => sidekickIdle(one) && one.found("Stop", { onRow: "+ New Round" }) === 1,
);
expect(page.screen().shows("[x] Follow")).toBe(true);
expect(page.repl.fake.prompts).toHaveLength(1);
diff --git a/packages/cli/tests/repl-sidekick-presentation.test.ts b/packages/cli/tests/repl-sidekick-presentation.test.ts
index 06b9400c1..c9b00bbc9 100644
--- a/packages/cli/tests/repl-sidekick-presentation.test.ts
+++ b/packages/cli/tests/repl-sidekick-presentation.test.ts
@@ -55,10 +55,12 @@ import {
draftText,
pasteDraft,
composerHolds,
- DRAFT,
draftHolds,
+ draftOpen,
+ draftShows,
intoComposer,
intoDraft,
+ paneLines,
sendMessage,
SIDEKICK,
SIDEKICK_CONTROLS,
@@ -93,6 +95,7 @@ function* completedKey(page: ReplPage, key: Parameters[0]): Ope
* not a reason to fail.
*/
function* draftFromComposer(page: ReplPage): Operation {
+ yield* intoDraft(page);
yield* intoComposer(page);
// A token no part of this screen draws: a single letter would collide with
// ordinary labels like QUEUE and make every stop look like the Draft.
@@ -248,6 +251,8 @@ describe("987 — mounted original recovery", () => {
page,
'Independent entry question.',
);
+ yield* page.key("Tab");
+ yield* page.until("Round Send focused", (one) => one.shows("> Send"));
yield* page.key("Enter");
yield* page.until("the independent question", (one) => one.shows("[answer]"));
yield* page.press("[answer]");
@@ -305,12 +310,13 @@ describe("Sidekick presentation: visible work owns its controls", () => {
it("keeps the composer separate from the Draft", function* () {
const page = yield* useReplPage({ size: WIDE });
+ yield* intoDraft(page);
yield* intoComposer(page);
yield* typed(page, "a Sidekick question");
const reading = page.screen();
expect(composerHolds(reading, "a Sidekick question")).toBe(true);
- expect(draftHolds(reading, "a Sidekick question")).toBe(false);
- expect(reading.found("[send]", { onRow: DRAFT })).toBe(1);
+ expect(draftShows(reading, "a Sidekick question")).toBe(false);
+ expect(reading.found("Send", { onRow: "✎ draft" })).toBe(1);
});
it("routes one visible surface at narrow size and recovers when widened", function* () {
@@ -318,11 +324,17 @@ describe("Sidekick presentation: visible work owns its controls", () => {
const narrow = yield* page.resize(NARROW);
expect(narrow.shows(SIDEKICK)).toBe(false);
expect(narrow.shows(COMPOSER)).toBe(false);
- expect(narrow.occurrences("[send]")).toBe(1);
+ expect(narrow.occurrences("[send]")).toBe(0);
+ expect(draftOpen(narrow)).toBe(false);
+ yield* intoDraft(page);
+ const editing = page.screen();
+ expect(editing.found("Send", { onRow: "✎ draft" })).toBe(1);
+ expect(editing.occurrences("[send]")).toBe(0);
const wide = yield* page.resize(WIDE);
expect(wide.shows(SIDEKICK)).toBe(true);
expect(wide.shows(COMPOSER)).toBe(true);
- expect(wide.occurrences("[send]")).toBe(2);
+ expect(wide.found("[send]", SIDEKICK_CONTROLS)).toBe(1);
+ expect(wide.found("Send", { onRow: "✎ draft" })).toBe(1);
});
it("shows Stop while a Sidekick turn is held and restores Send after Stop", function* () {
@@ -340,20 +352,24 @@ describe("Sidekick presentation: visible work owns its controls", () => {
});
function chatHas(reading: ScreenReading, text: string): boolean {
- return reading.found(text, reading.shows("DRAFT") ? { rightOf: "DRAFT" } : undefined) > 0;
+ return sidekickShows(reading, text);
}
function chatLines(reading: ScreenReading, anchor: string): string[] {
- const column = reading.locate(
- anchor,
- reading.shows("DRAFT") ? { rightOf: "DRAFT" } : undefined,
- ).column;
- const start = reading.locate(reading.shows("SIDEKICK") ? "SIDEKICK" : "Sidekick").row;
+ const pane = paneLines(reading);
+ const anchors = pane.filter((row) => row.includes(anchor));
+ if (anchors.length !== 1) {
+ throw new Error(
+ `expected one Sidekick row containing ${JSON.stringify(anchor)}, saw ${anchors.length}`,
+ );
+ }
+ const column = anchors[0].indexOf(anchor);
const end = reading.shows(COMPOSER)
? reading.locate(COMPOSER).row - 2
: reading.locate("HISTORY").row;
- return reading.rows.slice(start + 1, end).map((row) => {
+ const start = reading.locate(SIDEKICK).row;
+ return pane.slice(start + 1, end).map((row) => {
const text = row.slice(column).trim();
return text.startsWith("Sidekick total") || /^\d+ turns? unavailable$/.test(text) ? "" : text;
});
@@ -390,7 +406,8 @@ describe("Tier CF — complete messages and following the newest reply", () => {
expect(at(after, "one-C")).toBeLessThan(at(after, "two-A"));
expect(at(after, "two-A")).toBeLessThan(at(after, "two-B"));
expect(page.screen().shows(COMPOSER)).toBe(true);
- expect(page.screen().found("[send]", { onRow: DRAFT })).toBe(1);
+ yield* intoDraft(page);
+ expect(page.screen().found("Send", { onRow: "✎ draft" })).toBe(1);
yield* awaitedFact("two saved replies", function* () {
return (
(yield* settledReading(page.repl)).chat.filter((one) => one.kind === "response").length ===
@@ -582,12 +599,11 @@ describe("Sidekick acquisition, durable handoff and acknowledgements", () => {
const page = yield* useReplPage({ host, location: `xmd://repl/${execution}/entries` });
const running = gate.holdNext((path) => path === legacy && gate.reaching(legacy) >= 1);
yield* pasteDraft(page, TWO_STEP_ENTRY);
+ yield* page.key("Tab");
+ yield* page.until("Round Send focused", (one) => one.shows("> Send"));
yield* page.key("Enter");
yield* running.started();
- yield* page.until(
- "the admitted source leaving the draft",
- (one) => one.found("second =", DRAFT_VALUE) === 0,
- );
+ yield* page.until("the admitted source leaving the draft", (one) => !draftOpen(one));
yield* compose(page, "explain");
yield* sendComposed(page);
yield* sleep(100);
@@ -597,7 +613,7 @@ describe("Sidekick acquisition, durable handoff and acknowledgements", () => {
expect(yield* publishedPairs(host.root)).toEqual([]);
yield* compose(page, "!");
expect(composerHolds(page.screen(), "!")).toBe(true);
- yield* draftText(page, "next", ["Tab", "Tab", "Tab", "Tab"]);
+ yield* draftText(page, "next");
running.release();
yield* page.until("the reply arriving", (one) => one.shows("Noted."));
yield* finishing.started();
@@ -652,7 +668,7 @@ describe("Sidekick acquisition, durable handoff and acknowledgements", () => {
yield* sendComposed(page);
yield* saving.started();
yield* compose(page, "!");
- yield* draftText(page, "X", ["Tab", "Tab", "Tab", "Tab"]);
+ yield* draftText(page, "X");
saving.release();
yield* page.until("the reply arriving", (one) => one.shows("Understood."));
expect(personMessages((yield* settledReading(page.repl)).chat)).toEqual(["ask"]);
@@ -687,6 +703,7 @@ describe("Sidekick acquisition, durable handoff and acknowledgements", () => {
it("M5: while generation is held, Send remains beside Stop without starting unrequested work", function* () {
const page = yield* useReplPage();
page.repl.fake.script({ held: true, reply: "\n" });
+ yield* intoDraft(page);
yield* compose(page, "ask");
yield* page.type("\r\r");
yield* page.repl.fake.holdingTurns(1);
@@ -695,7 +712,7 @@ describe("Sidekick acquisition, durable handoff and acknowledgements", () => {
yield* page.until("the Sidekick working", (one) => one.shows("[S] working"));
expect(page.screen().found("[stop]", SIDEKICK_CONTROLS)).toBe(1);
expect(page.screen().found("[send]", SIDEKICK_CONTROLS)).toBe(1);
- expect(page.screen().found("[send]", { onRow: DRAFT })).toBe(1);
+ expect(page.screen().found("Send", { onRow: "✎ draft" })).toBe(1);
yield* compose(page, "then this");
page.repl.fake.releaseTurn();
yield* page.until("the reply arriving", (one) => one.shows("Done."));
@@ -725,6 +742,8 @@ describe("Sidekick acquisition, durable handoff and acknowledgements", () => {
it("M5: control — an ordinary entry's own progress reaches the screen with no further key", function* () {
const page = yield* useReplPage();
yield* pasteDraft(page, TWO_STEP_ENTRY);
+ yield* page.key("Tab");
+ yield* page.until("Round Send focused", (one) => one.shows("> Send"));
yield* page.key("Enter");
const fed = page.repl.terminal.fed;
yield* page.until("the entry output without input", (one) => one.shows("step-two"));
@@ -769,10 +788,10 @@ describe("Sidekick texts and reading across every profile", () => {
if (size.columns > NARROW.columns) {
expect(draftHolds(drawn, "note")).toBe(true);
} else {
- expect(drawn.shows("DRAFT")).toBe(false);
+ expect(draftOpen(drawn)).toBe(false);
yield* openEntryCatalog(page);
yield* closeDrawer(page);
- expect(page.screen().found("note", { after: "DRAFT" })).toBe(1);
+ expect(draftShows(page.screen(), "note")).toBe(true);
yield* page.resize(WIDE);
expect(composerHolds(page.screen(), "ask")).toBe(true);
expect(draftHolds(page.screen(), "note")).toBe(true);
@@ -787,7 +806,8 @@ describe("Sidekick texts and reading across every profile", () => {
yield* compose(page, "my question");
yield* selectPane(page, "bindings");
expect(page.screen().shows(COMPOSER)).toBe(false);
- expect(page.screen().occurrences("[send]")).toBe(1);
+ expect(page.screen().occurrences("[send]")).toBe(0);
+ expect(page.screen().found("Send", { onRow: "✎ draft" })).toBe(1);
expect(page.screen().found("my entry", DRAFT_VALUE)).toBe(1);
yield* intoComposer(page);
expect(composerHolds(page.screen(), "my question")).toBe(true);
@@ -813,6 +833,8 @@ describe("Sidekick texts and reading across every profile", () => {
it("M7: an older entry stays frozen while the Sidekick works, and Bindings still reads it", function* () {
const page = yield* useReplPage();
yield* pasteDraft(page, TWO_STEP_ENTRY);
+ yield* page.key("Tab");
+ yield* page.until("Round Send focused", (one) => one.shows("> Send"));
yield* page.key("Enter");
yield* entrySettles(page, 1, "ok");
yield* chooseEntry(page, "entry-1");
@@ -901,7 +923,7 @@ function* submittedUnderEdit(
yield* reached.operation;
let edited: string | undefined;
if (edit) {
- yield* draftText(page, "mine now", ["Tab", "Tab", "Tab", "Tab"]);
+ yield* draftText(page, "mine now");
expect(page.screen().found("mine now", DRAFT_VALUE)).toBe(1);
edited = "mine now";
}
@@ -1008,13 +1030,15 @@ describe("Sidekick question announcement and modal ownership", () => {
(path, record) => path.endsWith(SIDEKICK_FILE) && record.includes('"component":"Elicit"'),
);
yield* pasteDraft(page, TWO_STEP_ENTRY);
+ yield* page.key("Tab");
+ yield* page.until("Round Send focused", (one) => one.shows("> Send"));
yield* page.key("Enter");
yield* entrySettles(page, 1, "ok");
yield* chooseEntry(page, "entry-1");
yield* sendMessage(page, "review it");
yield* filing.started();
yield* selectPane(page, "bindings");
- yield* draftText(page, "mine", ["Tab", "Tab", "Tab"]);
+ yield* draftText(page, "mine");
const fed = page.repl.terminal.fed;
filing.release();
yield* page.until("the question announcing without input", (one) =>
@@ -1023,12 +1047,17 @@ describe("Sidekick question announcement and modal ownership", () => {
expect(page.repl.terminal.fed).toBe(fed);
expect(page.screen().shows(COMPOSER)).toBe(false);
expect(page.screen().shows("[submit]")).toBe(false);
- expect(entryTrail(page.screen())).toContain("Entry 1");
yield* page.type("-still-draft");
yield* page.until(
"the original input still receiving text",
(one) => one.found("mine-still-draft", DRAFT_VALUE) === 1,
);
+ yield* page.key("Ctrl+G");
+ yield* page.type("3");
+ yield* page.until("the selected entry", (one) => entryTrail(one).includes("Entry 1"));
+ expect(entryTrail(page.screen())).toContain("Entry 1");
+ yield* intoDraft(page);
+ expect(draftShows(page.screen(), "mine-still-draft")).toBe(true);
yield* selectPane(page, "sidekick");
yield* page.until("the notice in its pane", (one) => one.shows("[answer sidekick]"));
expect(page.screen().shows("[submit]")).toBe(false);
@@ -1043,6 +1072,8 @@ describe("Sidekick question announcement and modal ownership", () => {
it("MQ1: control — an ordinary entry's question announces itself the same way", function* () {
const page = yield* useReplPage();
yield* pasteDraft(page, ENTRY_ASKS);
+ yield* page.key("Tab");
+ yield* page.until("Round Send focused", (one) => one.shows("> Send"));
yield* page.key("Enter");
const fed = page.repl.terminal.fed;
yield* page.until("the entry announcing without input", (one) => one.shows("[answer]"));
@@ -1134,7 +1165,7 @@ describe("PV3/PV4: question and Configure editing", () => {
yield* sleep(30);
yield* page.type("!");
yield* page.until("the Agent caret survived History", (one) => one.shows("Agent: s!cribe"));
- expect(page.screen().found("draft-kept", { after: "DRAFT" })).toBe(1);
+ expect(draftShows(page.screen(), "draft-kept")).toBe(true);
});
});
@@ -1164,7 +1195,7 @@ describe("Configure keyboard, retained values and window ownership", () => {
yield* page.until("the opener receiving Enter after Close", (one) => one.shows("[refresh]"));
yield* page.key("Escape");
yield* configured(page);
- yield* draftText(page, "-more", ["Backtab"]);
+ yield* draftText(page, "-more");
expect(yield* finishDraft(page)).toBe("note-more");
});
@@ -1249,12 +1280,13 @@ describe("Configure keyboard, retained values and window ownership", () => {
yield* page.until("the narrow Agent field taking keys", (one) =>
one.shows("Agent: scribe-two"),
);
- expect(page.screen().shows("DRAFT")).toBe(false);
+ expect(draftOpen(page.screen())).toBe(false);
yield* page.press("[close]");
yield* configured(page);
yield* openEntryCatalog(page);
yield* closeDrawer(page);
- expect(page.screen().found("note", { after: "DRAFT" })).toBe(1);
+ yield* intoDraft(page);
+ expect(draftShows(page.screen(), "note")).toBe(true);
expect(yield* finishDraft(page)).toBe("note");
});
@@ -1280,9 +1312,15 @@ describe("Configure keyboard, retained values and window ownership", () => {
});
});
+function transcriptWidth(reading: ScreenReading): number {
+ const header = reading.rows.find((row) => /^\s*TRANSCRIPT\b/.test(row));
+ const divider = header?.indexOf("│") ?? -1;
+ return divider < 0 ? reading.size.columns : divider;
+}
+
function transcriptLines(reading: ScreenReading): string[] {
- const heading = reading.locate("Entries");
- return reading.rows.map((row) => row.slice(0, heading.column));
+ const width = transcriptWidth(reading);
+ return reading.rows.map((row) => row.slice(0, width));
}
function transcriptLabel(row: string): string {
@@ -1303,11 +1341,15 @@ function settledTranscriptHas(reading: ScreenReading, label: string): boolean {
}
function* chooseTurn(page: ReplPage, text: string): Operation {
- const row = transcriptLines(page.screen()).find((one) => matchesTurn(one, text));
- if (row === undefined) {
+ const reading = page.screen();
+ const rows = transcriptLines(reading);
+ const at = rows.findIndex((row) => matchesTurn(row, text));
+ if (at < 0) {
throw new Error(`no Transcript row says ${text}. ${page.describe()}`);
}
- yield* page.press(row.trim());
+ yield* page.press(rows[at].trim(), {
+ within: { top: at, bottom: at + 1, left: 0, right: transcriptWidth(reading) },
+ });
}
function* newConversation(page: ReplPage): Operation {
@@ -1366,6 +1408,8 @@ describe("Transcript ownership and immutable older chat readings", () => {
page.repl.fake.script({ held: true, reply: "ENTRY-DONE" });
page.repl.fake.script({ deltas: ["\n"], holdAfter: 1 });
yield* pasteDraft(page, '\n');
+ yield* page.key("Tab");
+ yield* page.until("Round Send focused", (one) => one.shows("> Send"));
yield* page.key("Enter");
yield* page.repl.fake.holdingTurns(1);
yield* sendMessage(page, "ask side");
@@ -1592,14 +1636,14 @@ describe("Transcript ownership and immutable older chat readings", () => {
expect(page.screen().shows("[submit]")).toBe(false);
expect(sidekickShows(page.screen(), "Older answer.")).toBe(true);
expect(page.screen().shows("Noted.")).toBe(false);
- yield* draftText(page, "my entry", ["Tab", "Tab", "Tab"]);
+ yield* draftText(page, "my entry");
yield* page.press("[Back to current chat]");
yield* page.until("the question notice coming home", (one) => one.shows("[answer sidekick]"));
expect(page.screen().shows("[submit]")).toBe(false);
yield* openedQuestion(page);
expect(page.screen().shows("decision: appr")).toBe(true);
expect(page.screen().shows("Noted.")).toBe(false);
- expect(page.screen().found("my entry", DRAFT_VALUE)).toBe(1);
+ expect(draftShows(page.screen(), "my entry")).toBe(true);
expect(yield* finishDraft(page)).toBe("my entry");
});
});
@@ -1617,7 +1661,10 @@ function* questionThroughKeyboard(explicit: boolean): Operation {
}
yield* page.type("ask");
yield* page.until("the composer reached by keyboard", (one) => composerHolds(one, "ask"));
- expect(draftHolds(page.screen(), "ask")).toBe(false);
+ const screen = page.screen();
+ if (draftOpen(screen)) {
+ expect(draftShows(screen, "ask")).toBe(false);
+ }
yield* sendComposed(page);
yield* page.until("the question notice", (one) => one.shows("[answer sidekick]"));
yield* openedQuestion(page);
@@ -1631,11 +1678,8 @@ describe("Sidekick resize ownership", () => {
const page = yield* questionThroughKeyboard(false);
const narrow = yield* page.resize(NARROW);
expect(narrow.shows("[submit]")).toBe(false);
- yield* draftText(page, "ordinary", ["Tab"]);
- yield* page.until(
- "the visible Draft taking text",
- (one) => one.found("ordinary", { after: "DRAFT" }) === 1,
- );
+ yield* draftText(page, "ordinary");
+ yield* page.until("the visible Draft taking text", (one) => draftShows(one, "ordinary"));
yield* page.resize(WIDE);
yield* page.until("the form returning", (one) => one.shows("[submit]"));
expect(page.screen().shows("partialordinary")).toBe(false);
@@ -1648,11 +1692,11 @@ describe("Sidekick resize ownership", () => {
const page = yield* questionThroughKeyboard(true);
const narrow = yield* page.resize(NARROW);
expect(narrow.shows("[submit]")).toBe(true);
- expect(narrow.shows("DRAFT")).toBe(false);
+ expect(draftOpen(narrow)).toBe(false);
yield* page.type(" more");
yield* page.until("the visible form taking text", (one) => one.shows("message: partial more"));
yield* page.resize(WIDE);
- expect(page.screen().found("partial more", DRAFT_VALUE)).toBe(0);
+ expect(draftOpen(page.screen())).toBe(false);
expect(yield* finishDraft(page)).toBeUndefined();
});
@@ -1665,10 +1709,9 @@ describe("Sidekick resize ownership", () => {
expect(page.repl.outcome()).toBeUndefined();
expect(page.screen().shows("[refresh]")).toBe(true);
expect((yield* page.resize(NARROW)).shows("[refresh]")).toBe(false);
- yield* page.type("-more");
- yield* page.until(
- "the visible Draft receiving the text",
- (one) => one.found("note-more", { after: "DRAFT" }) === 1,
+ yield* draftText(page, "-more");
+ yield* page.until("the visible Draft receiving the text", (one) =>
+ draftShows(one, "note-more"),
);
yield* page.resize(WIDE);
yield* page.until("Configure returning", (one) => one.shows("[refresh]"));
@@ -1746,7 +1789,7 @@ describe("Sidekick drawers across every supported size", () => {
if (size.columns > NARROW.columns) {
expect(reading.found("mine", DRAFT_VALUE)).toBe(1);
} else {
- expect(reading.shows("DRAFT")).toBe(false);
+ expect(draftOpen(reading)).toBe(false);
}
}
const refused = yield* page.resize(TOO_SMALL);
@@ -1788,7 +1831,7 @@ describe("Sidekick drawers across every supported size", () => {
if (size.columns > NARROW.columns) {
expect(reading.found("note", DRAFT_VALUE)).toBe(1);
} else {
- expect(reading.shows("DRAFT")).toBe(false);
+ expect(draftOpen(reading)).toBe(false);
}
}
const refused = yield* page.resize(TOO_SMALL);
@@ -2024,8 +2067,9 @@ describe("Older chats retain their identity across failure and cold opening", ()
yield* pasteDraft(
page,
'\n',
- ["Tab", "Tab", "Tab", "Tab"],
);
+ yield* page.key("Tab");
+ yield* page.until("Round Send focused", (one) => one.shows("> Send"));
yield* page.key("Enter");
yield* first.fake.holdingTurns(1);
execution = yield* mountedExecution(page.repl);
@@ -2065,7 +2109,9 @@ describe("Older chats retain their identity across failure and cold opening", ()
root = first.root;
const page = yield* useReplPage({ host: first });
yield* exchange(page, "only ask", "Only answer.");
- yield* pasteDraft(page, TWO_STEP_ENTRY, ["Tab", "Tab", "Tab", "Tab"]);
+ yield* pasteDraft(page, TWO_STEP_ENTRY);
+ yield* page.key("Tab");
+ yield* page.until("Round Send focused", (one) => one.shows("> Send"));
yield* page.key("Enter");
yield* entrySettles(page, 1, "ok");
execution = yield* mountedExecution(page.repl);
@@ -2205,6 +2251,8 @@ describe("Sidekick original provider membership and cancelled append", () => {
page.repl.fake.script({ reply: "ENTRY-REPLY" });
page.repl.fake.script({ reply: "\n", turnId: "sk-turn-1" });
yield* pasteDraft(page, promptEntry("entry-ask"));
+ yield* page.key("Tab");
+ yield* page.until("Round Send focused", (one) => one.shows("> Send"));
yield* page.key("Enter");
yield* page.until("the entry turn recorded", (one) =>
settledTranscriptHas(one, "[A] entry-ask"),
@@ -2269,6 +2317,8 @@ describe("Sidekick original provider membership and cancelled append", () => {
const host = yield* useMountedHost({ dataRoot });
const page = yield* useReplPage({ host });
yield* pasteDraft(page, TWO_STEP_ENTRY);
+ yield* page.key("Tab");
+ yield* page.until("Round Send focused", (one) => one.shows("> Send"));
yield* page.key("Enter");
yield* entrySettles(page, 1, "ok");
const first = yield* settledReading(page.repl);
@@ -2277,6 +2327,8 @@ describe("Sidekick original provider membership and cancelled append", () => {
page.repl.fake.script({ reply: "ENTRY-REPLY" });
page.repl.fake.script({ reply: "\n" });
yield* pasteDraft(page, promptEntry("later-entry"));
+ yield* page.key("Tab");
+ yield* page.until("Round Send focused", (one) => one.shows("> Send"));
yield* page.key("Enter");
yield* page.until("the second entry recorded", (one) =>
settledTranscriptHas(one, "[A] later-entry"),
@@ -2323,7 +2375,8 @@ function composerRows(one: ScreenReading, anchor?: string): string[] {
const prompt = one.locate(COMPOSER);
const edge = anchor === undefined ? 0 : one.locate(anchor, { after: COMPOSER }).column;
const footer = one.locate("HISTORY");
- const end = footer.row - (one.size.columns === NARROW.columns ? 2 : 1);
+ // On the narrow Sidekick outlet, the compact selected-work row precedes History.
+ const end = footer.row - (one.size.columns === NARROW.columns ? 1 : 0);
return one.rows.slice(prompt.row + 1, end).map((row) => row.slice(edge).trimEnd());
}
@@ -2486,6 +2539,8 @@ const HI_FAILING = '```js eval\nthrow new Error("the third entry failed");\n```'
function* entryRun(page: ReplPage, source: string, ordinal: number): Operation {
yield* pasteDraft(page, source);
+ yield* page.key("Tab");
+ yield* page.until("Round Send focused", (one) => one.shows("> Send"));
yield* page.key("Enter");
yield* entrySettles(page, ordinal, "ok");
}
@@ -2636,20 +2691,19 @@ describe("Sidekick original acknowledged history submission identity", () => {
yield* closeDrawer(page);
yield* intoDraft(page);
yield* page.type(HI_THIRD);
- yield* page.until(
- "the frozen Draft holding its source",
- (one) => one.found(HI_THIRD, DRAFT_VALUE) === 1,
- );
- yield* page.key("Enter");
+ yield* page.until("the frozen Draft holding its source", (one) => draftShows(one, HI_THIRD));
+ yield* page.press("Send", { onRow: "✎ draft" });
yield* page.until("the frozen Run refusal", (one) => one.shows("live head"));
expect((yield* settledReading(page.repl)).model.entries).toHaveLength(2);
- expect(page.screen().found(HI_THIRD, DRAFT_VALUE)).toBe(1);
+ expect(draftShows(page.screen(), HI_THIRD)).toBe(true);
yield* page.press("[live]");
yield* page.until("the live head restored", (one) => !one.shows("[live]"));
yield* intoDraft(page);
+ yield* page.key("Tab");
+ yield* page.until("Round Send focused", (one) => one.shows("> Send"));
yield* page.key("Enter");
yield* entrySettles(page, 3, "ok");
- expect(page.screen().found(HI_THIRD, DRAFT_VALUE)).toBe(0);
+ expect(draftOpen(page.screen())).toBe(false);
const read = yield* settledReading(page.repl);
expect(read.model.entries.map((one) => one.key)).toEqual(["entry-1", "entry-2", "entry-3"]);
expect(read.model.entries[2]?.source).toBe(HI_THIRD);
@@ -2667,12 +2721,12 @@ function* chatWheel(page: ReplPage, direction: "up" | "down"): Operation {
});
}
function shownChat(one: ScreenReading): string[] {
- const scope = one.shows("DRAFT") ? { rightOf: "DRAFT" } : undefined;
- const anchor = one.rows
+ const pane = paneLines(one);
+ const anchor = pane
.flatMap((row) =>
[...row.matchAll(/\[[US]\] /g)].map((match) => row.slice(match.index).trimEnd()),
)
- .find((label) => one.found(label, scope) === 1);
+ .find((label) => pane.filter((row) => row.includes(label)).length === 1);
if (anchor === undefined) {
throw new Error(`no visible chat item: ${one.rows.join("\n")}`);
}
@@ -3071,7 +3125,6 @@ describe("Sidekick original reveal and cold decision coverage", () => {
yield* newConversation(page);
yield* exchange(page, "newer ask", "Newer answer.");
page.repl.fake.script({ reply: "ENTRY-ANSWER" });
- yield* intoDraft(page, ["Tab", "Tab", "Tab", "Tab"]);
yield* entryRun(page, promptEntry("kept-entry"), 1);
yield* draftText(page, "my entry");
yield* compose(page, "half typed");
@@ -3084,6 +3137,9 @@ describe("Sidekick original reveal and cold decision coverage", () => {
yield* backToCurrent(page);
expect(composerHolds(page.screen(), "half typed")).toBe(true);
expect(page.screen().shows(`[configure ${OTHER_MOUNTED_AGENT}]`)).toBe(true);
+ yield* page.key("Ctrl+G");
+ yield* page.type("3");
+ yield* page.until("the selected entry", (one) => entryTrail(one).includes("Entry 1"));
expect(entryTrail(page.screen())).toContain("Entry 1");
expect(yield* finishDraft(page)).toBe("my entry");
});
@@ -3094,7 +3150,6 @@ describe("Sidekick original reveal and cold decision coverage", () => {
yield* newConversation(page);
yield* exchange(page, "newer ask", "Newer answer.");
page.repl.fake.script({ reply: "ENTRY-ANSWER" });
- yield* intoDraft(page, ["Tab", "Tab", "Tab", "Tab"]);
yield* entryRun(page, promptEntry("kept-entry"), 1);
yield* draftText(page, "my entry");
yield* compose(page, "half typed");
@@ -3102,6 +3157,9 @@ describe("Sidekick original reveal and cold decision coverage", () => {
expect(sidekickShows(page.screen(), "Newer answer.")).toBe(false);
yield* backToCurrent(page);
expect(composerHolds(page.screen(), "half typed")).toBe(true);
+ yield* page.key("Ctrl+G");
+ yield* page.type("3");
+ yield* page.until("the selected entry", (one) => entryTrail(one).includes("Entry 1"));
expect(entryTrail(page.screen())).toContain("Entry 1");
expect(yield* finishDraft(page)).toBe("my entry");
});
@@ -3163,6 +3221,8 @@ describe("Sidekick original reveal and cold decision coverage", () => {
const page = yield* useReplPage();
page.repl.fake.script({ reply: "ENTRY-REPLY" });
yield* pasteDraft(page, promptEntry("control-ask"));
+ yield* page.key("Tab");
+ yield* page.until("Round Send focused", (one) => one.shows("> Send"));
yield* page.key("Enter");
const fed = page.repl.terminal.fed;
yield* page.until("the entry's recorded provider turn", (one) =>
@@ -3184,7 +3244,7 @@ describe("Sidekick original populated chat profiles", () => {
}
yield* newConversation(page);
yield* exchange(page, "current ask", "Current answer.");
- yield* draftText(page, "my entry", ["Tab", "Tab", "Tab", "Tab"]);
+ yield* draftText(page, "my entry");
yield* compose(page, "my q");
yield* reachTurn(page, "old-6 ");
yield* page.until("the populated older reading", (one) => chatHas(one, "OLD-6"));
@@ -3201,7 +3261,7 @@ describe("Sidekick original populated chat profiles", () => {
expect(one.shows("SIDEKICK")).toBe(true);
expect(one.found("my entry", DRAFT_VALUE)).toBe(1);
} else {
- expect(one.shows("DRAFT")).toBe(false);
+ expect(draftOpen(one)).toBe(false);
}
}
yield* page.resize(WIDE);
@@ -3213,7 +3273,7 @@ describe("Sidekick original populated chat profiles", () => {
it("SS7: three profiles keep both sections, the window, Back and both texts", function* () {
const page = yield* useReplPage();
yield* exchange(page, "older ask", "Older answer.");
- yield* draftText(page, "my entry", ["Tab", "Tab", "Tab", "Tab"]);
+ yield* draftText(page, "my entry");
yield* compose(page, "my q");
yield* chooseTurn(page, "older ask ");
yield* page.until("the current chat explicitly selected", (one) =>
@@ -3231,7 +3291,7 @@ describe("Sidekick original populated chat profiles", () => {
expect(one.shows("SIDEKICK")).toBe(true);
expect(one.found("my entry", DRAFT_VALUE)).toBe(1);
} else {
- expect(one.shows("DRAFT")).toBe(false);
+ expect(draftOpen(one)).toBe(false);
}
}
yield* page.resize(WIDE);
@@ -3240,7 +3300,7 @@ describe("Sidekick original populated chat profiles", () => {
});
describe("Sidekick original independent body controls", () => {
- it("BP3: both bodies stay usable through their own controls, and narrow gains no inset", function* () {
+ it("BP3: both bodies stay usable through their own controls across resize", function* () {
const page = yield* useReplPage();
page.repl.fake.script({ reply: "ENTRY-REPLY" });
yield* entryRun(page, promptEntry("entry-ask"), 1);
@@ -3253,21 +3313,30 @@ describe("Sidekick original independent body controls", () => {
const before = yield* pairBytes(page.repl.root, execution);
for (const size of [WIDE, { columns: 120, rows: 30 }]) {
yield* atSize(page, size);
- for (const scope of [{ after: COMPOSER }, SIDEKICK_CONTROLS]) {
- const index = page.screen().index;
- const heading = page.screen().locate(scope === SIDEKICK_CONTROLS ? COMPOSER : "DRAFT");
- yield* page.wheel("down", { column: heading.column, row: heading.row - 3 });
- yield* page.until("the body's own scroll response", (one) => one.index > index);
- expect(page.screen().found("kept entry", DRAFT_VALUE)).toBe(1);
+ for (const anchor of ["kept entry", COMPOSER]) {
+ const screen = page.screen();
+ const target =
+ anchor === COMPOSER ? screen.locate(COMPOSER) : screen.locate(anchor, DRAFT_VALUE);
+ yield* page.wheel("down", {
+ column: target.column,
+ row: target.row - (anchor === COMPOSER ? 3 : 0),
+ });
+ yield* page.until("the body's own scroll response", (one) => one.index > screen.index);
+ expect(draftShows(page.screen(), "kept entry")).toBe(true);
expect(composerHolds(page.screen(), "kept question")).toBe(true);
- expect(entryTrail(page.screen())).toContain("Entry 1");
}
+ yield* page.key("Ctrl+G");
+ yield* page.type("3");
+ yield* page.until("the selected entry", (one) => entryTrail(one).includes("Entry 1"));
+ expect(entryTrail(page.screen())).toContain("Entry 1");
+ yield* intoDraft(page);
+ expect(draftShows(page.screen(), "kept entry")).toBe(true);
}
yield* page.resize(NARROW);
yield* page.press("Entries");
yield* page.until("the narrow Entries catalog", (one) => one.shows("[close]"));
yield* closeDrawer(page);
- expect(page.screen().shows("DRAFT")).toBe(true);
+ expect(draftOpen(page.screen())).toBe(true);
expect(page.screen().found("kept entry", DRAFT_VALUE)).toBe(1);
yield* page.resize(WIDE);
expect(composerHolds(page.screen(), "kept question")).toBe(true);
diff --git a/packages/cli/tests/repl-sidekick-recovery.test.ts b/packages/cli/tests/repl-sidekick-recovery.test.ts
index 6c6eac929..f6c3b9790 100644
--- a/packages/cli/tests/repl-sidekick-recovery.test.ts
+++ b/packages/cli/tests/repl-sidekick-recovery.test.ts
@@ -2784,6 +2784,8 @@ describe("Tier HI — a reopening reconciles against the acknowledged history",
yield* page.press("[live]");
yield* page.until("the live head coming back", (one) => !one.shows("[live]"));
yield* draftText(page, ORDINARY);
+ yield* page.key("Tab");
+ yield* page.until("Round Send focused", (one) => one.shows("> Send"));
yield* page.key("Enter");
yield* admission.started();
@@ -3218,6 +3220,8 @@ describe("975 — placement survives cold Submit reconciliation", () => {
expect(observed.at(-1)).toBe(where);
expect(yield* until(readFile(location.entries, "utf8"))).toBe(prefix);
yield* draftText(page, "manual successor waits");
+ yield* page.key("Tab");
+ yield* page.until("Round Send focused", (one) => one.shows("> Send"));
yield* page.key("Enter");
yield* page.until("the refused successor after reconciliation", (one) =>
one.shows("has not finished"),
@@ -4855,6 +4859,8 @@ describe("1269 — mounted retained recovery corrections", () => {
yield* scoped(function* () {
const page = yield* useReplPage({ host });
yield* draftText(page, entryText);
+ yield* page.key("Tab");
+ yield* page.until("Round Send focused", (one) => one.shows("> Send"));
yield* page.key("Enter");
yield* entrySettles(page, 1, "ok");
host.fake.script({ reply: "" });
diff --git a/packages/cli/tests/repl-sidekick-testing.test.ts b/packages/cli/tests/repl-sidekick-testing.test.ts
index d474882ff..e9b1bfb34 100644
--- a/packages/cli/tests/repl-sidekick-testing.test.ts
+++ b/packages/cli/tests/repl-sidekick-testing.test.ts
@@ -191,7 +191,9 @@ describe("REPL.Test accepted journeys", () => {
expect(repl.fake.prompts.join("\n")).toContain("wrong");
yield* exchange(page, [fix, reuse]);
expect((yield* reports(repl)).at(-1)?.status).toBe("passed");
- yield* draftText(page, "", ["Tab", "Tab", "Tab", "Tab"]);
+ yield* draftText(page, "");
+ yield* page.key("Tab");
+ yield* page.until("Round Send focused", (one) => one.shows("> Send"));
yield* page.key("Enter");
// The rail's own mark for the fifth entry. `entry-5` and `[ok]` are rows of
// the Entries catalog, and the catalog is a drawer on this screen: a reader
diff --git a/packages/cli/tests/repl-sidekick-typing.test.ts b/packages/cli/tests/repl-sidekick-typing.test.ts
index 70b0860fb..2c59ae598 100644
--- a/packages/cli/tests/repl-sidekick-typing.test.ts
+++ b/packages/cli/tests/repl-sidekick-typing.test.ts
@@ -317,7 +317,7 @@ describe("1048 — generated retained output", () => {
yield* page.resize(WIDE);
yield* page.type("!");
yield* page.until("the saved middle Message caret", (one) => one.shows("ab!界"));
- yield* draftText(page, "draft", ["Tab", "Tab", "Tab", "Tab"]);
+ yield* draftText(page, "draft");
yield* completedKey(page, "ArrowLeft");
yield* openHistory(page);
yield* page.key("Escape");
diff --git a/packages/cli/tests/repl-terminal.test.ts b/packages/cli/tests/repl-terminal.test.ts
index 99169d217..8d471cc12 100644
--- a/packages/cli/tests/repl-terminal.test.ts
+++ b/packages/cli/tests/repl-terminal.test.ts
@@ -203,6 +203,8 @@ function* useApplication(model: ReplModel, size: ReplTerminalSize = WIDE): Opera
/** Submit one entry through the Draft and wait for the History rail to mark it settled. */
function* submit(page: ReplPage, order: number, source: string): Operation {
yield* pasteDraft(page, source);
+ yield* page.key("Tab");
+ yield* page.until("Round Send focused", (one) => one.shows("> Send"));
yield* page.key("Enter");
yield* entrySettles(page, order, "ok");
}
@@ -3038,6 +3040,8 @@ function historyMarkers(reading: ScreenReading): string[] {
*/
function* submitPast(page: ReplPage, order: number): Operation {
yield* pasteDraft(page, `Entry ${order} text.`);
+ yield* page.key("Tab");
+ yield* page.until("Round Send focused", (one) => one.shows("> Send"));
yield* page.key("Enter");
yield* page.until(`ready for entry ${order + 1}`, (one) =>
one.shows(`Ready for Entry ${order + 1}`),
diff --git a/packages/cli/tests/repl-todo-recovery.test.ts b/packages/cli/tests/repl-todo-recovery.test.ts
index e7f011da4..7359a7a26 100644
--- a/packages/cli/tests/repl-todo-recovery.test.ts
+++ b/packages/cli/tests/repl-todo-recovery.test.ts
@@ -139,6 +139,8 @@ describe("TODO logical runtime recovery", () => {
});
yield* ensure(() => release.resolve());
yield* pasteDraft(page, "");
+ yield* page.key("Tab");
+ yield* page.until("Round Send focused", (one) => one.shows("> Send"));
yield* page.key("Enter");
yield* cleaning.operation;
yield* intoComposer(page);
diff --git a/packages/cli/tests/repl-wheel-burst.test.ts b/packages/cli/tests/repl-wheel-burst.test.ts
index b4b3fb023..edbe9cfa7 100644
--- a/packages/cli/tests/repl-wheel-burst.test.ts
+++ b/packages/cli/tests/repl-wheel-burst.test.ts
@@ -140,7 +140,7 @@ describe("wheel bursts in one input chunk", () => {
// Each dotted segment is one probed path segment, so each stays within a file name.
const name = ["Unknown", "Missing", "Absent"].map((at) => at + "Component".repeat(27));
const request = `<${name.join(".")} />`;
- const footer = "! this entry cannot run here: Cannot resolve component:";
+ const refusal = "! this entry cannot run here: Cannot resolve component:";
const cell = { column: 140, row: 13 };
function* endpoints(move: typeof burst) {
@@ -155,13 +155,13 @@ describe("wheel bursts in one input chunk", () => {
draftHolds(one, "/>"),
);
const before = tailLines(drafted);
- yield* page.key("Enter");
- const refused = yield* page.until("the staged refusal", (one) => one.shows(footer));
+ yield* page.press("Send", { onRow: "✎ draft" });
+ const refused = yield* page.until("the staged refusal", (one) => one.shows(refusal));
const start = tailLines(refused);
- expect(start.length + 3).toBeLessThan(before.length);
+ expect(start.length + 2).toBeLessThan(before.length);
yield* move(page, "up", cell, 2);
- expect(page.screen().shows(footer)).toBe(false);
+ expect(page.screen().shows(refusal)).toBe(false);
const end = tailLines(page.screen());
expect(end.length).toBeGreaterThan(start.length);
expect(end[0]).not.toBe(start[0]);
diff --git a/packages/cli/tests/repl-wheel-migration.test.ts b/packages/cli/tests/repl-wheel-migration.test.ts
index b4fafe546..7553b880e 100644
--- a/packages/cli/tests/repl-wheel-migration.test.ts
+++ b/packages/cli/tests/repl-wheel-migration.test.ts
@@ -115,7 +115,7 @@ describe("wheel remaining migration journeys", () => {
yield* intoDraft(page);
yield* page.type('');
yield* page.until("source", (one) => one.shows(""));
- yield* page.key("Enter");
+ yield* page.press("Send", { onRow: "✎ draft" });
yield* page.until("permission pending", (one) => one.shows("asks:"));
yield* page.press("asks:");
yield* page.until("first option", (one) => one.shows("> [Choice 00]"));
@@ -134,8 +134,8 @@ describe("wheel remaining migration journeys", () => {
size: { columns: 72, rows: 20 },
includes: [REFERENCE_DIRECTORY],
});
- yield* intoDraft(page);
for (let at = 1; at <= 8; at += 1) {
+ yield* intoDraft(page);
const title =
at === 1
? Array.from(
@@ -151,11 +151,15 @@ describe("wheel remaining migration journeys", () => {
).join(""),
);
yield* page.until("source ready", (one) => one.shows(`steps={${at}}`));
- yield* page.key("Enter");
+ yield* page.press("Send", { onRow: "✎ draft" });
yield* page.until("settled entry", (one) => one.shows(`Ready for Entry ${at + 1}`));
}
+ yield* intoDraft(page);
yield* page.type("draft-held");
yield* page.until("draft", (one) => one.shows("draft-held"));
+ yield* page.key("Ctrl+G");
+ yield* page.type("3");
+ yield* page.until("selected work", (one) => !one.shows("✎ draft"));
yield* page.press("Entries");
yield* page.until("catalog", (one) => one.shows("[close]"));
yield* key(page, "Tab");
@@ -219,6 +223,7 @@ describe("wheel remaining migration journeys", () => {
yield* ticks(page, "up", nested, 90);
expect(page.screen().shows("Nested work 00")).toBe(true);
absentButtons(page);
+ yield* intoDraft(page);
yield* page.until("draft returns", (one) => one.shows("draft-held"));
expect(page.repl.fake.prompts).toHaveLength(0);
});
@@ -241,7 +246,7 @@ describe("wheel remaining migration journeys", () => {
`Recorded question`,
);
yield* page.until("source", (one) => one.shows(""));
- yield* page.key("Enter");
+ yield* page.press("Send", { onRow: "✎ draft" });
yield* page.until("answer available", (one) => one.shows("[answer]"));
yield* page.press("[answer]");
yield* page.until("form", (one) => one.shows("[submit]"));
@@ -296,10 +301,13 @@ describe("wheel remaining migration journeys", () => {
).join("\n"),
);
yield* page.until("source", (one) => one.shows("Resize work 89"));
- yield* page.key("Enter");
+ yield* page.press("Send", { onRow: "✎ draft" });
yield* page.until("settled", (one) => one.shows("Ready for Entry 2"));
+ yield* intoDraft(page);
yield* page.type("draft-retained");
yield* page.until("Draft", (one) => one.shows("draft-retained"));
+ yield* page.type("\x073");
+ yield* page.until("selected work", (one) => one.shows("Resize work 00"));
const cell = page.screen().locate("Resize work 00");
const blankAbove = page.screen().locate("Resize work 02");
const blank = { column: blankAbove.column, row: blankAbove.row + 1 };
@@ -312,7 +320,7 @@ describe("wheel remaining migration journeys", () => {
yield* wheel(page, direction, { column: empty.column, row: empty.row + 1 });
expect(page.screen().shows("Resize work 00")).toBe(true);
}
- for (const label of ["DRAFT", "HISTORY", "BINDINGS"]) {
+ for (const label of ["+ New Round", "HISTORY", "BINDINGS"]) {
yield* wheel(page, "down", page.screen().locate(label));
expect(page.screen().shows("Resize work 00")).toBe(true);
}
@@ -322,7 +330,6 @@ describe("wheel remaining migration journeys", () => {
"burst moved nine rows",
(one) => one.index > before && one.shows("Resize work 08") && !one.shows("Resize work 07"),
);
- let refused = false;
for (const size of [
{ columns: 120, rows: 30 },
{ columns: 72, rows: 20 },
@@ -333,23 +340,26 @@ describe("wheel remaining migration journeys", () => {
yield* page.resize(size);
if (size.columns === 50) {
expect(page.screen().shows("needs at least")).toBe(true);
- refused = true;
} else {
+ yield* intoDraft(page);
expect(page.screen().shows("draft-retained")).toBe(true);
- if (refused && size.columns === 72) {
- yield* key(page, "Tab");
- }
+ yield* page.type("\x073");
+ yield* page.until("selected work", (one) => !one.shows("✎ draft"));
}
}
expect(page.screen().shows("Resize work 08")).toBe(true);
+ yield* intoDraft(page);
yield* page.type("!");
yield* page.until("focus survived", (one) => one.shows("draft-retained!"));
+ yield* page.type("\x073");
+ yield* page.until("selected work", (one) => !one.shows("✎ draft"));
yield* page.press("Entries");
yield* page.until("catalog remount", (one) => one.shows("[close]"));
yield* wheel(page, "down", cell);
yield* page.key("Escape");
yield* page.until("work returns", (one) => !one.shows("[close]"));
expect(page.screen().shows("Resize work 08")).toBe(true);
+ yield* intoDraft(page);
expect(page.screen().shows("draft-retained!")).toBe(true);
absentButtons(page);
});
diff --git a/packages/cli/tests/repl-wheel-scroll.test.ts b/packages/cli/tests/repl-wheel-scroll.test.ts
index f057c832e..ee8aabc7b 100644
--- a/packages/cli/tests/repl-wheel-scroll.test.ts
+++ b/packages/cli/tests/repl-wheel-scroll.test.ts
@@ -90,7 +90,7 @@ describe("wheel real consumers", () => {
yield* intoDraft(page);
yield* page.type('');
yield* page.until("entry source ready", (one) => one.shows(""));
- yield* page.key("Enter");
+ yield* page.press("Send", { onRow: "✎ draft" });
yield* page.until("pending permission", (one) => one.shows("asks:"));
yield* page.press("asks:");
yield* page.until("first permission choice", (one) => one.shows("> [Allow]"));
@@ -130,16 +130,19 @@ describe("wheel real consumers", () => {
yield* intoDraft(page);
yield* page.type(Array.from({ length: 70 }, (_, at) => `Work row ${at}`).join("\n"));
yield* page.until("source ready", (one) => one.shows("Work row 69"));
- yield* page.key("Enter");
+ yield* page.press("Send", { onRow: "✎ draft" });
yield* page.until("work settled", (one) => one.shows("Ready for Entry 2"));
+ yield* intoDraft(page);
yield* typed(page, "draft-kept");
+ yield* page.key("Ctrl+G");
+ yield* page.type("3");
+ yield* page.until("selected work", (one) => one.shows("Work row 0") && !one.shows("✎ draft"));
const at = page.screen().locate("Work row 0");
yield* wheel(page, "down", at);
expect(page.screen().shows("Work row 0")).toBe(false);
expect(page.screen().shows("Work row 3")).toBe(true);
yield* wheel(page, "up", at);
expect(page.screen().shows("Work row 0")).toBe(true);
- yield* key(page, "Backtab");
yield* key(page, "Alt+ArrowDown");
yield* key(page, "End");
expect(page.screen().shows("Work row 69")).toBe(true);
@@ -148,6 +151,7 @@ describe("wheel real consumers", () => {
yield* key(page, "PageDown");
yield* key(page, "PageUp");
expect(page.screen().shows("Work row 0")).toBe(true);
+ yield* intoDraft(page);
expect(page.screen().shows("draft-kept")).toBe(true);
expect(page.repl.fake.prompts).toHaveLength(0);
});
@@ -308,7 +312,7 @@ describe("wheel real consumers", () => {
yield* intoDraft(page);
yield* page.type(``);
yield* page.until("binding source ready", (one) => one.shows('row 59"]}'));
- yield* page.key("Enter");
+ yield* page.press("Send", { onRow: "✎ draft" });
yield* page.until("binding retained", (one) => one.shows("Ready for Entry 2"));
yield* page.press("Entries");
yield* page.until("catalog", (one) => one.shows("[close]"));
@@ -354,7 +358,7 @@ describe("wheel real consumers", () => {
yield* intoDraft(page);
yield* page.type(``);
yield* page.until("string source ready", (one) => one.shows("VALUE-END"));
- yield* page.key("Enter");
+ yield* page.press("Send", { onRow: "✎ draft" });
yield* page.until("string retained", (one) => one.shows("Ready for Entry 2"));
yield* page.press("Entries");
yield* page.until("string catalog", (one) => one.shows("[close]"));
@@ -449,11 +453,8 @@ describe("wheel real consumers", () => {
expect(page.screen().found("[↑ earlier]", SIDEKICK_PANE) > 0).toBe(false);
expect(page.screen().found("[↓ later]", SIDEKICK_PANE) > 0).toBe(false);
expect(page.repl.fake.prompts).toHaveLength(1);
- expect(page.screen().shows("No entry yet")).toBe(true);
- // Message -> History -> Transcript -> Selected work -> Draft.
- for (let step = 0; step < 4; step += 1) {
- yield* key(page, "Tab");
- }
+ expect(page.screen().rows[0]).toContain("Ready for Entry 1");
+ yield* intoDraft(page);
yield* key(page, "ArrowLeft");
const tail = page.screen().locate("Chat row 79");
yield* wheel(page, "up", tail);
@@ -486,7 +487,7 @@ describe("wheel real consumers", () => {
`${preview}`,
);
yield* page.until("source prepared", (one) => one.shows(""));
- yield* page.key("Enter");
+ yield* page.press("Send", { onRow: "✎ draft" });
yield* page.until("entry waiting", (one) => one.shows("[answer]"));
yield* page.press("[answer]");
yield* page.until("question opened", (one) => one.shows("[submit]") && one.shows("pick-34"));
diff --git a/packages/cli/tests/support/pty.ts b/packages/cli/tests/support/pty.ts
index ccf61b249..7a3d1c62c 100644
--- a/packages/cli/tests/support/pty.ts
+++ b/packages/cli/tests/support/pty.ts
@@ -430,7 +430,20 @@ function* showing(pty: Pty, what: string, within: number): Operation {
/** Move to Draft and wait for its focus cue before sending entry text. */
export function* focusPtyDraft(pty: Pty, within: number): Operation {
yield* pty.type("\x074");
- yield* showing(pty, "> DRAFT", within);
+ const deadline = Date.now() + within;
+ while (Date.now() <= deadline) {
+ const screen = yield* pty.shows();
+ if (screen.some((row) => row.includes("> Round"))) {
+ return;
+ }
+ if (screen.some((row) => row.includes("> + New Round"))) {
+ yield* pty.type("\r");
+ yield* showing(pty, "> Round", within);
+ return;
+ }
+ yield* sleep(150);
+ }
+ throw new Error("The Draft shortcut did not reach New Round or the editor.");
}
/**
diff --git a/packages/cli/tests/support/repl-files-journey.ts b/packages/cli/tests/support/repl-files-journey.ts
index 9f29ccf07..28e251bea 100644
--- a/packages/cli/tests/support/repl-files-journey.ts
+++ b/packages/cli/tests/support/repl-files-journey.ts
@@ -189,7 +189,7 @@ export function replFilesJourney(repl: ReplCommand): Operation {
yield* focusPtyDraft(first, ACT_MS);
yield* first.type(ENTRY);
yield* sleep(500);
- yield* first.type("\r");
+ yield* first.type("\t\r");
// The prefix ran. Everything the entry authored before the question is on
// disk, and the write after the question is not.
@@ -267,7 +267,7 @@ export function replFilesJourney(repl: ReplCommand): Operation {
yield* focusPtyDraft(third, ACT_MS);
yield* third.type(LIVE_READ);
yield* sleep(500);
- yield* third.type("\r");
+ yield* third.type("\t\r");
yield* showing(third, "live is second", ACT_MS);
yield* click(third, "[exit]");
@@ -447,7 +447,7 @@ export function replRepositoryJourney(repl: ReplCommand, through: ManagedJourney
yield* focusPtyDraft(first, ACT_MS);
yield* first.type(managedEntry(through, origin));
yield* sleep(500);
- yield* first.type("\r");
+ yield* first.type("\t\r");
// The checkout the selection created, found under the managed layout.
const checkout = yield* managedCheckout(
@@ -514,7 +514,7 @@ export function replRepositoryJourney(repl: ReplCommand, through: ManagedJourney
yield* focusPtyDraft(third, ACT_MS);
yield* third.type(managedLiveRead(through, origin));
yield* sleep(500);
- yield* third.type("\r");
+ yield* third.type("\t\r");
yield* showing(third, "live is second", ACT_MS);
yield* click(third, "[exit]");
@@ -548,7 +548,7 @@ export function replUnsupportedSelection(repl: ReplCommand): Operation {
].join("\n"),
);
yield* sleep(500);
- yield* pty.type("\r");
+ yield* pty.type("\t\r");
// The refusal is a sentence, wrapped where the Transcript's own width
// cuts it, so it is read across those rows rather than off one of them.
@@ -581,7 +581,7 @@ export function replOrdinaryFileWork(repl: ReplCommand): Operation {
yield* focusPtyDraft(pty, ACT_MS);
yield* pty.type(ENTRY);
yield* sleep(500);
- yield* pty.type("\r");
+ yield* pty.type("\t\r");
yield* holding(join(checkout, "drafts", "note.md"), "first");
yield* removed(join(checkout, "drafts", "obsolete.md"));
@@ -799,7 +799,7 @@ export function replGitJourney(repl: ReplCommand, through: GitJourney): Operatio
yield* focusPtyDraft(first, ACT_MS);
yield* first.type(gitEntry(through, origin));
yield* sleep(500);
- yield* first.type("\r");
+ yield* first.type("\t\r");
const working = through === "ambient" ? ambient : yield* managedCheckout(home, "worktrees");
@@ -887,7 +887,7 @@ export function replGitJourney(repl: ReplCommand, through: GitJourney): Operatio
yield* focusPtyDraft(third, ACT_MS);
yield* third.type(gitLiveCommit(through, origin));
yield* sleep(500);
- yield* third.type("\r");
+ yield* third.type("\t\r");
const today = yield* moved(working, home, theirs);
// The object id is read across the wrap the Transcript's own width puts in
// it: forty characters of it, whole, rather than whichever row it starts on.
@@ -941,7 +941,7 @@ export function replUnsupportedGit(repl: ReplCommand): Operation {
].join("\n"),
);
yield* sleep(500);
- yield* pty.type("\r");
+ yield* pty.type("\t\r");
// Refused before a repository is in scope, which is before Git exists in
// the story at all. Either way nothing native was reached.
diff --git a/packages/cli/tests/support/repl-issues-journey.ts b/packages/cli/tests/support/repl-issues-journey.ts
index 0c7b29a2c..517c8ef9b 100644
--- a/packages/cli/tests/support/repl-issues-journey.ts
+++ b/packages/cli/tests/support/repl-issues-journey.ts
@@ -168,7 +168,7 @@ export function replIssuesJourney(repl: ReplCommand): Operation {
yield* focusPtyDraft(first, ACT_MS);
yield* first.type(ENTRY);
yield* sleep(500);
- yield* first.type("\r");
+ yield* first.type("\t\r");
// The prefix ran: one issue was filed, and the two facts the document
// asked for are on the screen. The URL is read across the wrap the
@@ -252,7 +252,7 @@ export function replIssuesAdoptionJourney(repl: ReplCommand): Operation {
yield* focusPtyDraft(first, ACT_MS);
yield* first.type(ENTRY);
yield* sleep(500);
- yield* first.type("\r");
+ yield* first.type("\t\r");
// The tracker has the issue, and the answer is still on this side of the
// wire. Nothing about it is retained.
@@ -304,7 +304,7 @@ export function replIssuesUnsupported(repl: ReplCommand): Operation {
yield* focusPtyDraft(pty, ACT_MS);
yield* pty.type(ENTRY);
yield* sleep(500);
- yield* pty.type("\r");
+ yield* pty.type("\t\r");
// Wrapped by the Transcript's own width, so read across its rows.
yield* showingAcross(pty, "no Issue provider is installed", ACT_MS);
diff --git a/packages/cli/tests/support/repl-mounts-journey.ts b/packages/cli/tests/support/repl-mounts-journey.ts
index 7af4fbcad..e2e45cbbc 100644
--- a/packages/cli/tests/support/repl-mounts-journey.ts
+++ b/packages/cli/tests/support/repl-mounts-journey.ts
@@ -54,7 +54,7 @@ export function replMountsJourney(repl: ReplCommand): Operation {
yield* focusPtyDraft(first, 30_000);
yield* first.type(source);
yield* sleep(500);
- yield* first.type("\r");
+ yield* first.type("\t\r");
yield* showing(first, "waiting for an answer", 30_000);
expect(yield* readTextFile(join(old, "process-cwd.txt"))).toBe(old);
yield* click(first, "[exit]");
@@ -84,7 +84,7 @@ export function replMountsJourney(repl: ReplCommand): Operation {
`{fresh}fresh is {fresh}`,
);
yield* sleep(500);
- yield* third.type("\r");
+ yield* third.type("\t\r");
yield* showing(third, "Ready for Entry 3", 30_000);
yield* holding(join(selected, "fresh.md"), selected === old ? "changed" : "current");
// The catalog is a drawer on this screen: `Entries` opens it, and the
diff --git a/packages/cli/tests/support/repl-page.ts b/packages/cli/tests/support/repl-page.ts
index b93f7fc91..9055e1487 100644
--- a/packages/cli/tests/support/repl-page.ts
+++ b/packages/cli/tests/support/repl-page.ts
@@ -53,6 +53,12 @@ export interface ScreenScope {
readonly after?: string;
readonly rightOf?: string;
readonly rightOffset?: number;
+ readonly within?: {
+ readonly top: number;
+ readonly bottom: number;
+ readonly left: number;
+ readonly right: number;
+ };
}
/** The screen after one write the command completed. */
@@ -201,30 +207,34 @@ function reading(index: number, size: ReplTerminalSize, cells: string[][]): Scre
const columnAt = (row: number, offset: number): number => columns[row]?.[offset] ?? offset;
/** The cells this scope admits: a row range, and a column floor. */
const bounded = (scope: ScreenScope | undefined, what: string) => {
- let from = 0;
- let to = rows.length;
- let floor = 0;
+ let from = scope?.within?.top ?? 0;
+ let to = scope?.within?.bottom ?? rows.length;
+ let floor = scope?.within?.left ?? 0;
+ const ceiling = scope?.within?.right ?? size.columns;
if (scope?.onRow !== undefined) {
const at = rowOf(rows, scope.onRow, what);
- from = at;
- to = at + 1;
+ from = Math.max(from, at);
+ to = Math.min(to, at + 1);
}
if (scope?.after !== undefined) {
from = Math.max(from, rowOf(rows, scope.after, what) + 1);
}
if (scope?.rightOf !== undefined) {
const at = rowOf(rows, scope.rightOf, what);
- floor = Math.max(0, columnAt(at, rows[at].indexOf(scope.rightOf)) + (scope.rightOffset ?? 0));
+ floor = Math.max(
+ floor,
+ columnAt(at, rows[at].indexOf(scope.rightOf)) + (scope.rightOffset ?? 0),
+ );
}
- return { from, to, floor };
+ return { from, to, floor, ceiling };
};
const matches = (text: string, scope: ScreenScope | undefined, what: string): ScreenCell[] => {
- const { from, to, floor } = bounded(scope, what);
+ const { from, to, floor, ceiling } = bounded(scope, what);
const found: ScreenCell[] = [];
for (let row = from; row < to; row += 1) {
for (const offset of offsetsIn(rows[row] ?? "", text)) {
const column = columnAt(row, offset);
- if (column >= floor) {
+ if (column >= floor && columnAt(row, offset + text.length - 1) < ceiling) {
found.push({ column, row });
}
}
@@ -264,6 +274,7 @@ function scopeOf(scope: ScreenScope | undefined): string {
scope.onRow === undefined ? undefined : `the row showing ${JSON.stringify(scope.onRow)}`,
scope.after === undefined ? undefined : `below ${JSON.stringify(scope.after)}`,
scope.rightOf === undefined ? undefined : `at or right of ${JSON.stringify(scope.rightOf)}`,
+ scope.within === undefined ? undefined : `inside ${JSON.stringify(scope.within)}`,
].filter((part) => part !== undefined);
return parts.join(", ");
}
diff --git a/packages/cli/tests/support/repl-pull-request-journey.ts b/packages/cli/tests/support/repl-pull-request-journey.ts
index 9b70902b6..53491209c 100644
--- a/packages/cli/tests/support/repl-pull-request-journey.ts
+++ b/packages/cli/tests/support/repl-pull-request-journey.ts
@@ -287,7 +287,7 @@ export function replPullRequestJourney(repl: ReplCommand): Operation {
yield* focusPtyDraft(first, REACH_MS);
yield* first.type(entry());
yield* sleep(500);
- yield* first.type("\r");
+ yield* first.type("\t\r");
// Waited for first, so a prefix that refused is reported as the sentence on
// the screen rather than as an absent managed checkout. What Git was asked
@@ -500,7 +500,7 @@ export function replUnsupportedPullRequest(repl: ReplCommand): Operation {
].join("\n"),
);
yield* sleep(500);
- yield* pty.type("\r");
+ yield* pty.type("\t\r");
// Both refusals are sentences, wrapped where the Transcript's own width
// cuts them, so they are read across those rows.
diff --git a/packages/cli/tests/support/repl-push-journey.ts b/packages/cli/tests/support/repl-push-journey.ts
index 852d7fbd8..2018ab380 100644
--- a/packages/cli/tests/support/repl-push-journey.ts
+++ b/packages/cli/tests/support/repl-push-journey.ts
@@ -117,7 +117,7 @@ export function replPushJourney(repl: ReplCommand): Operation {
yield* focusPtyDraft(first, ACT_MS);
yield* first.type(entry(origin, "notes.md"));
yield* sleep(500);
- yield* first.type("\r");
+ yield* first.type("\t\r");
const working = yield* managedCheckout(home, "worktrees");
@@ -188,7 +188,7 @@ export function replPushJourney(repl: ReplCommand): Operation {
yield* focusPtyDraft(third, ACT_MS);
yield* third.type(republishing(origin));
yield* sleep(500);
- yield* third.type("\r");
+ yield* third.type("\t\r");
yield* showing(third, "published again", ACT_MS);
yield* remoteHolding(origin, BRANCH, advanced, home);
expect(yield* pushes(shim.log)).toHaveLength(1);
@@ -233,7 +233,7 @@ export function replUnsupportedPush(repl: ReplCommand): Operation {
].join("\n"),
);
yield* sleep(500);
- yield* pty.type("\r");
+ yield* pty.type("\t\r");
// Refused before a managed checkout exists, which is before a remote exists
// in the story at all. The refusal is a sentence, wrapped where the
diff --git a/packages/cli/tests/support/screen-journeys.ts b/packages/cli/tests/support/screen-journeys.ts
index 54bb54b87..f701a9906 100644
--- a/packages/cli/tests/support/screen-journeys.ts
+++ b/packages/cli/tests/support/screen-journeys.ts
@@ -2,9 +2,8 @@
* The words this product draws, and the keyboard routes a person takes to them.
*
* Every helper here is built from `support/repl-page.ts`'s own readings:
- * `shows`, `occurrences`, `found`, `locate` and the three scopes. None of them
- * counts a border, reads a focus cue, names a terminal column or builds a view,
- * and none of them searches for focus at run time: a route is a key count
+ * `shows`, `occurrences`, `found`, `locate`, the three scopes and drawn rows.
+ * None names a fixed terminal column or builds a view. A route is a key count
* measured on a fresh mount from a named opening state, written down here with
* the receipt that measured it.
*
@@ -20,8 +19,8 @@ import { MOUNTED_DEADLINE_MS } from "./mounted-repl.ts";
import type { Terminal } from "./mounted-repl.ts";
import type { PageKey, ReplPage, ScreenReading, ScreenScope } from "./repl-page.ts";
-/** The Draft's own heading, which its Send shares a row with. */
-export const DRAFT = " DRAFT";
+/** The suffix in the Round editor heading. */
+export const DRAFT = "· draft";
/** The Sidekick tab, which its own Send is drawn below and right of. */
export const SIDEKICK = "SIDEKICK";
@@ -97,7 +96,14 @@ export function* intoDraft(page: ReplPage, route: readonly PageKey[] = []): Oper
if (route.length === 0) {
yield* page.key("Ctrl+G");
yield* page.key("4");
- yield* page.until("Draft focus", (one) => one.found("> DRAFT") === 1);
+ const ready = yield* page.until(
+ "the Draft shortcut",
+ (one) => one.shows("> Round") || one.shows("> + New Round"),
+ );
+ if (ready.shows("> + New Round")) {
+ yield* page.key("Enter");
+ yield* page.until("Round editor focus", (one) => one.shows("> Round"));
+ }
return;
}
for (const name of route) {
@@ -142,27 +148,22 @@ function* pressTab(
}
}
-/**
- * Put several lines in the Draft as one chunk, the way a paste arrives.
- *
- * The screen wraps a value into the rows its field has, so the arrival is read
- * from the last line's own words rather than from the whole text: a wrapped
- * value is not on the screen as one string.
- */
+/** Paste source into the editor and wait for a visible fragment near its caret. */
export function* pasteDraft(
page: ReplPage,
text: string,
route: readonly PageKey[] = [],
): Operation {
yield* intoDraft(page, route);
- // The last word rather than the last line: a field fits a value into the
- // rows it has, so a long line is not on the screen as one string.
- const last = (text.trimEnd().split(/\s+/).at(-1) ?? "").slice(0, 24);
+ const line = text.trimEnd().split("\n").at(-1) ?? "";
+ const witness = (text.endsWith("\n") ? line.trimStart().slice(0, 12) : line.slice(-12)).trim();
yield* page.type(text);
- yield* page.until(
- `the Draft holding ${JSON.stringify(last)}`,
- (one) => one.found(last, DRAFT_VALUE) > 0,
- );
+ if (witness !== "") {
+ yield* page.until(
+ `the Draft holding ${JSON.stringify(witness)}`,
+ (one) => draftOpen(one) && draftShows(one, witness),
+ );
+ }
}
/** Put this text in the already active Draft. */
@@ -223,13 +224,8 @@ export function sidekickIdle(reading: ScreenReading): boolean {
/**
* The Sidekick pane's own rows, as this screen draws them.
*
- * Below the tab row and from the Draft heading's own cell rightward. The pane's
- * chat is drawn a couple of cells left of its tab, so the tab's column is too
- * far right to be a floor, while the sidebar's copy of a reply sits far left of
- * the Draft. Both bounds are cells of text this screen draws.
- *
- * It does not separate the Transcript, which shares those columns, so words
- * both readings draw are asked of the whole screen by count instead.
+ * The wide tab row crosses the divider at the pane's left edge. At one outlet
+ * the tab row has no divider before Sidekick and the pane is full width.
*/
export function paneLines(reading: ScreenReading): string[] {
// A drawer over this pane covers its tab row, and then the pane draws none
@@ -237,8 +233,8 @@ export function paneLines(reading: ScreenReading): string[] {
if (!reading.shows(SIDEKICK)) {
return [];
}
- const tabs = reading.locate(SIDEKICK).row;
- const floor = reading.shows(DRAFT) ? reading.locate(DRAFT).column : 0;
+ const { row: tabs, column } = reading.locate(SIDEKICK);
+ const floor = reading.rows[tabs].lastIndexOf("│", column) + 1;
return reading.rows.map((row, index) =>
index > tabs ? row.slice(Math.min(floor, row.length)) : "",
);
@@ -274,7 +270,8 @@ export function railMark(reading: ScreenReading, order: number): string | undefi
// The cancelled mark is a hyphen, which is a range inside a class anywhere but
// the end of one: it goes last, beside the mark a refused entry wears.
const marks = Object.values(RAIL).filter((mark) => mark !== RAIL.cancelled);
- return new RegExp(`(?:^|\\s)${order}\\s*([${marks.join("")}U-])`).exec(rail)?.[1];
+ const mark = new RegExp(`(?:^|\\s)${order}\\s*([${marks.join("")}U⠋-])`).exec(rail)?.[1];
+ return mark === "⠋" ? RAIL.unfinished : mark;
}
/** Whether a drawer is open: its own way out is the one every drawer draws. */
@@ -354,9 +351,34 @@ export function* drawnScreen(terminal: Terminal): Operation> {
]);
}
-/** Whether the Draft's own rows hold this text. */
+/** The round bar stays visible while Send temporarily hides the heading. */
+export function draftOpen(reading: ScreenReading): boolean {
+ return reading.rows.some((row) => row.includes("✎ draft") && row.includes("+ New Round"));
+}
+
+/** Whether the open editor's interior holds this text. */
export function draftShows(reading: ScreenReading, text: string): boolean {
- return reading.found(text, DRAFT_VALUE) > 0;
+ if (!draftOpen(reading)) {
+ throw new Error("the Round editor is closed");
+ }
+ const bar = reading.locate("✎ draft", { onRow: "+ New Round" }).row;
+ const bottomEdge = /└─+┘/.exec(reading.rows[bar - 1]);
+ if (bottomEdge === null) {
+ throw new Error("the open Round editor has no bottom border");
+ }
+ const { column: left } = reading.locate(bottomEdge[0], { onRow: bottomEdge[0] });
+ const topEdge = `┌${"─".repeat(bottomEdge[0].length - 2)}┐`;
+ const { row: top } = reading.locate(topEdge, { onRow: topEdge });
+ return (
+ reading.found(text, {
+ within: {
+ top: top + 1,
+ bottom: bar - 1,
+ left: left + 2,
+ right: left + bottomEdge[0].length - 2,
+ },
+ }) > 0
+ );
}
/** Whether the Draft holds this text, and the composer does not. */
diff --git a/scripts/tests/tty-distribution.test.ts b/scripts/tests/tty-distribution.test.ts
index 226f68af2..8b6b19839 100644
--- a/scripts/tests/tty-distribution.test.ts
+++ b/scripts/tests/tty-distribution.test.ts
@@ -174,7 +174,7 @@ describe("the prepared terminal runtime in the canonical host binary", () => {
yield* focusPtyDraft(first, 60_000);
yield* first.type(`${SHORT}\n\n${LONG}`);
yield* sleep(500);
- yield* first.type("\r");
+ yield* first.type("\t\r");
yield* settledEntry(first, 1, "ok", 60_000);
yield* showing(first, "01fda4", 60_000);
yield* click(first, "[exit]");
diff --git a/specs/repl-spec.md b/specs/repl-spec.md
index d7b8cda15..7ec26fe47 100644
--- a/specs/repl-spec.md
+++ b/specs/repl-spec.md
@@ -473,29 +473,30 @@ alone.
## One live journey
-Run `xmd repl`. The screen shows an empty draft, a Sessions list that says it is
+Run `xmd repl`. The screen shows **+ New Round**, a Sessions list that says it is
empty, an Entries list with nothing in it yet, and a location of the form
`xmd://repl//entries` — the execution already exists, as an empty history
file, before you have typed anything.
-Type or paste one XMD entry and press Enter. What was in the draft is now the
+Activate **+ New Round**, type or paste one XMD entry, then press Tab and Enter
+to activate **Send**. What was in the draft is now the
entry, and an admitted entry is immutable. The run begins, and the screen fills
in as it goes — the scopes the entry admitted, the bindings its `eval` blocks
published, the source a generated fragment produced before that fragment was
admitted, and each line the document rendered.
-Keep typing. The draft is always the *next* entry's, so it goes on taking
+Open the next draft. It is always the *next* entry's, so it goes on taking
keystrokes while this entry runs and while you are reading an earlier position:
an admitted entry is immutable, so there is never one those keystrokes could be
-editing. Press Enter before the entry ahead of it is done and Run says so, and
+editing. Activate Send before the entry ahead of it is done and the REPL says so, and
what you typed stays exactly as you typed it, character for character. When that
entry has both settled and finished coming down, the same draft becomes the next
entry — and only then does it leave the input and the location.
-When the entry asks a question, the footer says so on one row and nothing else
-happens: no drawer opens itself, nothing takes focus, the route does not move and
-the Sessions filter does not change. Activate that row — with Enter or a pointer —
-and the question's drawer opens: the whole message, and then
+When the entry asks a question, the identity header says an entry is waiting for
+an answer and the existing Answer action in History remains available. Focus,
+the route and the Sessions filter stay where they were. Activate Answer with
+Enter or a pointer and the question's drawer opens: the whole message, and then
every field the schema declares, with its title, its description, whether it
is required, and exactly the values it will accept. All of that is one ordered
whole, and it is that whole — not the message alone — that scrolls when it is
@@ -1158,14 +1159,14 @@ One private grant ledger belongs to each inherited Prompt scope.
## Move between regions and edit within them
-From Draft, one Tab enters the tabs at Bindings without selecting it. Continue
-with Tab to reach the right reading, Message, History, Transcript, selected work
-and Draft again. Shift+Tab reverses the same cycle. Both directions use each
+From the Round editor, one Tab enters Send without activating it. Continue
+with Tab to reach the tabs, right reading, Message, History, Transcript, selected work
+and the editor again. When the editor is closed, the Draft region enters **+ New Round**. Shift+Tab reverses the same cycle. Both directions use each
region's fixed entry; an absent region is skipped. Moving focus selects, sends
and answers nothing.
```text
-Transcript -> Selected work -> Draft -> Tabs/Configure
+Transcript -> Selected work -> Draft -> Round actions -> Tabs/Configure
^ |
| v
History <- Message <- TODO <- Right reading <-----+
@@ -1182,7 +1183,7 @@ the region at the same fixed control as Tab and dismisses the hints.
| 1 | Sidekick Message |
| 2 | Transcript |
| 3 | Selected work |
-| 4 | Draft |
+| 4 | Round editor, or **+ New Round** when the editor is closed |
| 5 | Tabs/Configure |
| 6 | Right reading |
| 7 | TODO |
@@ -1225,8 +1226,9 @@ paste occur at the caret. Up/Down follows displayed rows and retains the preferr
visual column; Home/End reaches that row's boundaries. Plain arrows stay in the
field. Alt+Up/Down reaches its local actions, and Tab leaves its region. Each
value keeps its own caret through focus departure, modal coverage and resize;
-an explicitly replaced value or a new question starts at its end. Enter keeps
-each field's submission or Apply meaning. Control-J, a shifted Enter and
+an explicitly replaced value or a new question starts at its end. Enter in the
+Round editor inserts a newline. Enter on Send submits; other fields keep their
+submission or Apply meaning. Control-J, a shifted Enter and
Terminal.app's Shift+Return insert a newline; releasing a key inserts nothing.
Control-C in a focused Message that holds text clears it, as described under
Message below.
@@ -1315,14 +1317,13 @@ existing destinations when visible. No background update can issue a late
restoration. The rows below the body stay where they are — `[history]` and `[exit]` stay
reachable from inside an open drawer, where they belong to that drawer.
-A route drawer begins below the whole contextual guidance block, so the screen
-goes on saying how to close the drawer in front of it. The block is as many rows
-as its words need at that width, and all of them stay visible: the drawer starts
-at the later of its own old top and the row below the last of them. Its columns
-and its bottom edge are unchanged, so the rows it moves down are spent out of
-its own window rather than taken from the footer — a shorter window, still whole
-by scrolling. The narrow outlet keeps its existing drawer, and the Sidekick's
-pane-local question and Configure rectangles are its pane's own and unaffected.
+The drawer is measured within the space between the identity header and History,
+in the rectangle its owner already uses. Its fixed title and actions carry its
+guidance. Above Content, show what Enter does for the focused control, Esc to
+close, Tab to move, and PageUp/PageDown to read more. Keep reading and editing
+directions appropriate to the focused control. Fit this guidance to the measured
+drawer width in as many rows as it takes. Its rows reduce the scrolling Content
+window, and the fixed controls stay reachable.
The right pane's two tabs are its heading: `Bindings` and `Sidekick` side by
side on one row, in that order, each name said once and neither repeated by a
@@ -1350,17 +1351,13 @@ following, and a previous chat stays where it was put while the current one
works. None of this is in the location: a copied location restores the chat
somebody selected and promises no scroll position.
-Above the reading, one block says what the execution is doing, what the focused
-control does, the way back to the draft and how to move. It takes as many rows
-as its words need and says all of them: a direction you cannot see is a
-direction you do not have, so nothing is shortened or dropped to keep it on one
-row. The narrow profile uses compact state and action labels; longer reading
-directions wrap at the measured width. A refusal's explanation is paid out over
-rows the same way, at whole words.
-
-Two input destinations, named: `Draft` runs a document as this execution's next
-entry, and `Message Sidekick` asks the Sidekick. Enter in each one means its own
-thing. Typing and Backspace reach whichever holds focus and leave the other
+Outside drawers, the identity header explains readiness and the next available
+action. When visible, the Round editor heading gives editing guidance, including
+Enter for a newline and Tab for Send. Other focus destinations remain available
+through the existing Tab traversal and Ctrl+G hints.
+
+The Round editor holds this execution's next document. Its Send runs that
+document. Enter in `Message Sidekick` asks the Sidekick. Typing and Backspace reach whichever holds focus and leave the other
exactly as it was. Both texts survive switching tabs, navigating History and
resizing; the draft is in the location, and the message is this process's own and
appears in no location. An empty box sends nothing.
@@ -1636,9 +1633,9 @@ selected entry, the conversation filter and the draft.
| terminal | what it shows |
| --- | --- |
-| `160x36` and larger | an identity row; Transcript (36 columns), selected work and Draft (54 columns at this width), and Sidekick (70 columns); the drawer layer; a readiness row; then compact History |
+| `160x36` and larger | an identity row; Transcript (36 columns), selected work or its Round editor (54 columns at this width), and Sidekick (70 columns); the drawer layer; the round bar at the base of selected work, followed immediately by compact History on the last row |
| `120x30` and larger | the same three columns, with widths of 24, 40 and 56 at this size |
-| `72x20` and larger | one full-width routed surface below the Sessions, Entries and Sidekick controls. Sidekick shows a compact selected-entry status row above History. Drawer guidance and the readiness row remain available |
+| `72x20` and larger | One full-width routed surface below Sessions, Entries and Sidekick. History is the final row. The Entries round bar and Sidekick's compact selected-entry row, when present, are directly above History. The identity header shows execution status across all three outlets. |
| smaller than `72x20` | a refusal saying the minimum, that growing the window recovers, and that Escape leaves; it shows nothing else, and offers no control to point at |
The **Transcript** on the left is the agent work this execution has, read as
@@ -1687,10 +1684,25 @@ shows that entry's exact source, its execution state and its results. Every name
in that trail except the last one is a way back out to it: the reading is already
at the last, and choosing an outer name leaves the reading there with the scopes
beneath it no longer selected — the same thing choosing that scope's row in the
-catalog does. Below it is
-the **Draft**: one field whose heading row carries its own Send — or Stop, while
-an entry is running — and whose value takes the rows beneath. The Draft is always
-the next entry's text, and a blank row in it is a row.
+catalog does. **+ New Round** replaces that reading with an inset, outlined Executable
+Markdown editor and a round bar at the bottom. The gold `Round n · draft`
+heading names the next round after the most recently admitted round, even when
+an earlier one was selected. At 72×20, New Round opens the Entries view first
+and shows the gold heading above the focused editor. At that size, focus on
+Send removes the heading and its key guidance from the frame and gives their
+rows to the editor. Returning focus to the editor restores them. The editor
+fills the available space above the round bar. When the draft is empty its first
+interior row shows the muted `Executable Markdown` placeholder. The Sidekick
+conversation and unsent Message remain available.
+
+The bar shows `✎ draft`, **Send** and **X**. Send is dim and admits nothing
+while the draft is empty. X discards the draft and returns focus to
+**+ New Round**. A refused submission leaves the text in the editor. When
+Send admits a round, the live work replaces the editor and the bar shows
+`● running · user` and offers **Stop** for that exact round while it runs.
+History highlights the draft with `✎` while the editor is open and shows
+the running round with a spinner glyph after admission. Unfiltered Transcript
+shows the round's `── Round n ──` separator alongside the conversation rows.
The right column opens on **Sidekick**. Its tabs are **Sidekick**, **TODO**, and
**Bindings**. With open tasks, the TODO label includes their count, as in
@@ -1829,21 +1841,21 @@ decides which rows and which controls exist. So what you can see, focus and clic
are the same set, at every size, and a row the frame has no room for is never
described as though it had somewhere to be.
-A refusal of one action — a submission the entry ahead of it has not made room
-for, a navigation that selects nothing, a pause this process cannot perform —
-appears beside the control that was refused, shortened with an ellipsis when the
-row is too narrow for all of it. It does not replace the screen.
-
-History is the last row. The contextual readiness row above it reports the
-current execution state and any action needed to continue. A refusal of an
-action takes that row while it applies. A presented drawer uses the row for its
-own guidance, including how to leave it and how to reach or scroll its fields.
+Execution action refusals use the identity header. Field refusals stay with their
+fields and Sidekick notices stay in the Sidekick pane. History is the last row
+and follows the round bar directly whenever the bar is visible. History keeps
+its existing map, head or frozen-position label, and admitted actions.
## What the screen says the execution is doing
-The readiness row leads with the execution state, then gives any action needed
-to proceed. It fits the available width and keeps the state readable at every
-supported size.
+The identity header shows execution readiness and any action needed to proceed,
+using compact wording at 72×20. Reserve space for the meaningful state and next
+action before fitting the session identifier. Keep the usage control reachable.
+A visible execution action refusal appears within the header, wrapping at the
+measured width as needed. Keep readiness visible during a refusal. The refusal
+gives the reason and any available recovery. When the refusal exceeds the
+header's available rows, the header shows which rows are visible and wheel
+scrolling over the refusal reveals the remaining rows without moving focus.
**Readiness is read from the file and from this process together.** The durable
side cannot answer it alone: a root close is recorded the moment a document
@@ -1851,7 +1863,7 @@ settles, while the task that produced it is still coming down, and a submission
taken in that window has nowhere to go. So there is a state between "settled" and
"ready" — the close is retained, the entry's task has not been joined, and no
successor may start yet. It resolves without anybody typing: when the teardown
-finishes, the row says the next entry may start.
+finishes, the header says the next entry may start.
The states a person can tell apart: no entry yet; an entry running; an entry
waiting for an answer; an entry waiting for a permission; an entry whose close is
@@ -1865,7 +1877,7 @@ starts nothing and appends nothing. When the entry it named finishes, that refus
goes rather than contradicting the sentence above it. A document that cannot be
admitted and an answer a schema rejected are refusals of the thing itself: they
stay until the thing changes, and the schema's complaint stays under the field it
-is about rather than in the row that says what the execution is doing.
+is about rather than with execution readiness.
The session marks readiness refusals when raising them with a namespaced,
nonenumerable own property carrying its normalized sentence. Across loaded
@@ -1948,7 +1960,7 @@ one, not because some text happens to begin with a brace.
A reading of this screen with the colour thrown away loses nothing it needs. An
outcome is spelled `[ok]` or `[err]`, a selected row keeps its `*`, a focused
-control keeps its `>`, the draft keeps its `>>`, and every state the emphasis
+control keeps its `>`, the round bar says `draft` while the editor is open, and every state the emphasis
distinguishes is also said in words. The emphasis is how the screen is read
quickly; the text is how it is read at all.
@@ -2167,12 +2179,13 @@ counts, and the column is wide enough for every reading a badge can hold —
including a cleanup wait, which says two things at once — so an element
settling cannot reflow the document beside it.
-The Draft's value and a queued message are wrapped the same way. A queued
-message wraps between its origin and its `X`, and its continuation rows line up
+The Round editor keeps each source line on one row and scrolls it sideways to
+reveal the caret. Measure the outline and inset as part of the pane. Fit the
+source and caret to the remaining interior width and height. The empty
+placeholder occupies the first interior display row and changes neither the
+source nor its caret offsets. A queued message wraps between its origin and its `X`, and its continuation rows line up
with its text: a wrapped row is the same message, never a new one, and the `X`
-stays one control on its first row. The reference this screen follows clips
-source and scrolls the Draft sideways; this screen does neither, because a clip
-hides somebody's source and a control nobody can see is not one to focus.
+stays one control on its first row.
A question's own read-only preview is measured the same way, at the width its
drawer was given. A drawer row is one row, so a line left unwrapped has nowhere
@@ -3245,8 +3258,8 @@ normalized event is an explicit failure.
Normalized input is decided once, at the host, which names an event shape and a
position and never an action. Text is its own event and goes to whichever field
has focus, and to nothing at all when a control has it rather than a field — so a
-keystroke never edits a field nobody is looking at, and the row above the surface
-says how to get back to the draft while that is the case. The decoder names
+keystroke never edits a field nobody is looking at. Ctrl+G, then 4 reaches the
+editor or New Round when the Draft destination is offered. The decoder names
navigation keys, including Alt+Up/Down and the Control-G focus prefix. Unassigned
Control or Alt chords are discarded as a unit. Control-J,
Enter carrying only Shift, and Enter carrying both Control and Alt — how